From patchwork Mon Mar 19 18:46:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10294287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 67C0960385 for ; Mon, 19 Mar 2018 18:46:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56C412948A for ; Mon, 19 Mar 2018 18:46:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AF6829494; Mon, 19 Mar 2018 18:46:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC9712948A for ; Mon, 19 Mar 2018 18:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970433AbeCSSqS (ORCPT ); Mon, 19 Mar 2018 14:46:18 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:46720 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970408AbeCSSqO (ORCPT ); Mon, 19 Mar 2018 14:46:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1521485174; x=1553021174; h=from:to:cc:subject:date:message-id; bh=QNjuszCNToq66PRk5bJZYLugXRxWao6gO2NgL7kW1gE=; b=FOU95ik4O6s5+qJ/xnKemPeFkStqV9E+zUqJeskgQhD0IsNswBzl4vRJ SdlWcNbg3qqOWzLKZMJRhrDy+WkiBNvveE7v0X68GSp8NyF6nqL1pioqg IsI7fx1yiilt7GiO06W4ps0QHhKSHVat9yy5czw7Z+pAMxRn3C2IOkdz5 G9ndagmL0Avn0MU1Odmp2as05d2UQgHdtsv8WW5nHF1+JQhacWl/ytQMx zvp6kQin5puw2J8GEVWW+FKz4Lwr2aTKIx36T/4yNC3ZwWmGEogvimDzF FZzx063nWN8baXh5ETl//c/or14DBqczvY+/siy9JQ1G9CfGTaNph0rOG g==; X-IronPort-AV: E=Sophos;i="5.48,331,1517846400"; d="scan'208";a="73987081" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Mar 2018 02:46:14 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Mar 2018 11:39:01 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Mar 2018 11:46:13 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Tejun Heo , Hannes Reinecke , Ming Lei , Johannes Thumshirn , Oleksandr Natalenko , Martin Steigerwald , stable@vger.kernel.org Subject: [PATCH v2] block: Change a rcu_read_{lock, unlock}_sched() pair into rcu_read_{lock, unlock}() Date: Mon, 19 Mar 2018 11:46:13 -0700 Message-Id: <20180319184613.14161-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.2 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP scsi_device_quiesce() uses synchronize_rcu() to guarantee that the effect of blk_set_preempt_only() will be visible for percpu_ref_tryget() calls that occur after the queue unfreeze by using the approach explained in https://lwn.net/Articles/573497/. The rcu read lock and unlock calls in blk_queue_enter() form a pair with the synchronize_rcu() call in scsi_device_quiesce(). Both scsi_device_quiesce() and blk_queue_enter() must either use regular RCU or RCU-sched. Since neither the RCU-protected code in blk_queue_enter() nor blk_queue_usage_counter_release() sleeps, regular RCU protection is sufficient. Note: scsi_device_quiesce() does not have to be modified since it already uses synchronize_rcu(). Reported-by: Tejun Heo Fixes: 3a0a529971ec ("block, scsi: Make SCSI quiesce and resume work reliably") Signed-off-by: Bart Van Assche Acked-by: Tejun Heo Cc: Tejun Heo Cc: Hannes Reinecke Cc: Ming Lei Cc: Christoph Hellwig Cc: Johannes Thumshirn Cc: Oleksandr Natalenko Cc: Martin Steigerwald Cc: stable@vger.kernel.org # v4.15 --- Changes between v1 and v2: - Explained in the interaction between scsi_device_quiesce() and blk_queue_enter() in the patch description. block/blk-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 5e88c579e896..a0f675f84f86 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -917,7 +917,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) bool success = false; int ret; - rcu_read_lock_sched(); + rcu_read_lock(); if (percpu_ref_tryget_live(&q->q_usage_counter)) { /* * The code that sets the PREEMPT_ONLY flag is @@ -930,7 +930,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) percpu_ref_put(&q->q_usage_counter); } } - rcu_read_unlock_sched(); + rcu_read_unlock(); if (success) return 0;