From patchwork Thu Jun 22 01:36:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Junxiao Bi X-Patchwork-Id: 9803237 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 80A9E60329 for ; Thu, 22 Jun 2017 01:41:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69D6427DCD for ; Thu, 22 Jun 2017 01:41:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D0C42855E; Thu, 22 Jun 2017 01:41:04 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D75D727DCD for ; Thu, 22 Jun 2017 01:41:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNr53-0006VD-LL; Thu, 22 Jun 2017 01:38:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNr52-0006V7-Jk for xen-devel@lists.xenproject.org; Thu, 22 Jun 2017 01:38:44 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 84/35-03058-4AF1B495; Thu, 22 Jun 2017 01:38:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsUyZ7p8oO5iee9 Ig4eLFSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owZU26xFfzkqvi/r5ulgfEWRxcjF4eQwDYm iYeHXrJAOLOZJOZdmccI4VxjlHhx6CpUZjqjxOGtC1i7GDk52AQ0JJZPmsgOYosIKEncWzWZC cQWFjCVOLt7H1gNi4CqRPe61ywgNq+Aq8Tf69uZuxg5OCQEFCTmTLIBCUsIGEqcfriNcQIj9w JGhlWM6sWpRWWpRbrmeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgR5mAIIdjDM v+x9ilORgUhLlfSnlHSnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgrdDDignWJSanlqRlpkDDDWY tAQHj5IIr44AUJq3uCAxtzgzHSJ1ilFRSpw3GqRPACSRUZoH1wYL70uMslLCvIxAhwjxFKQW5 WaWoMq/YhTnYFQS5l0IMoUnM68EbvoroMVMQItfHPEAWVySiJCSamAscN9rx82hI7rv1Yepj/ Iuv2x4ES60wtCHd6XKNMNeuSbn5auKrutEXbvD+m3y7RMsit/ixH6wb9yVuOx6PlvuPOkFilz LFy7eWbSjTo4vsZ9h+b3u7ct4bCX+OoTY9/Byf9j6wO2a7u91qwWDuSLVHi9f//XjvQztUgZe nf6DyoLdQbyfXI2VWIozEg21mIuKEwEABJwpagIAAA== X-Env-Sender: junxiao.bi@oracle.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1498095521!56006730!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39373 invoked from network); 22 Jun 2017 01:38:43 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Jun 2017 01:38:43 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5M1cerS016470 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 22 Jun 2017 01:38:40 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v5M1cd05024715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 22 Jun 2017 01:38:39 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v5M1cat9005276 for ; Thu, 22 Jun 2017 01:38:38 GMT Received: from bijx-OptiPlex-780.cn.oracle.com (/10.182.64.189) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Jun 2017 18:38:35 -0700 From: Junxiao Bi To: xen-devel@lists.xenproject.org Date: Thu, 22 Jun 2017 09:36:52 +0800 Message-Id: <1498095412-18731-1-git-send-email-junxiao.bi@oracle.com> X-Mailer: git-send-email 1.7.9.5 X-Source-IP: userv0021.oracle.com [156.151.31.71] Subject: [Xen-devel] [PATCH] xen-blkfront: fix mq start/stop race X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When ring buf full, hw queue will be stopped. While blkif interrupt consume request and make free space in ring buf, hw queue will be started again. But since start queue is protected by spin lock while stop not, that will cause a race. interrupt: process: blkif_interrupt() blkif_queue_rq() kick_pending_request_queues_locked() blk_mq_start_stopped_hw_queues() clear_bit(BLK_MQ_S_STOPPED, &hctx->state) blk_mq_stop_hw_queue(hctx) blk_mq_run_hw_queue(hctx, async) If ring buf is made empty in this case, interrupt will never come, then the hw queue will be stopped forever, all processes waiting for the pending io in the queue will hung. Signed-off-by: Junxiao Bi Reviewed-by: Ankur Arora Reviewed-by: Boris Ostrovsky Acked-by: Roger Pau Monné --- drivers/block/xen-blkfront.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 8bb160cd00e1..4767b82b2cf6 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -912,8 +912,8 @@ out_err: return BLK_MQ_RQ_QUEUE_ERROR; out_busy: - spin_unlock_irqrestore(&rinfo->ring_lock, flags); blk_mq_stop_hw_queue(hctx); + spin_unlock_irqrestore(&rinfo->ring_lock, flags); return BLK_MQ_RQ_QUEUE_BUSY; }