From patchwork Fri Jul 14 23:15:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9841821 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 CD4F5602D8 for ; Fri, 14 Jul 2017 23:19:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDAAE287B9 for ; Fri, 14 Jul 2017 23:19:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B27EA287C3; Fri, 14 Jul 2017 23:19:10 +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 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 379E9287B9 for ; Fri, 14 Jul 2017 23:19:09 +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 1dW9p5-00014K-FC; Fri, 14 Jul 2017 23:16:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dW9p4-00014E-EA for xen-devel@lists.xenproject.org; Fri, 14 Jul 2017 23:16:34 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 1C/ED-03406-1D059695; Fri, 14 Jul 2017 23:16:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRWlGSWpSXmKPExsVysWW7jO6FgMx Ig8u3rCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozVl6oLDkpVbLj+nrmB8Z9YFyMXh5DAbCaJ 94ePsHQxcnKwCNhLrFh/nB3EZhQok+hu28UMYedKLH+3D6rGTmLbj/usEM3LGSVOP5sIlmATU JF4e+EcK4gtIpAsMXXnJyaQImaBTUwSF5dtApsqLBAu8f5oCyvEJFWJD/NesIHYvAIWEovvfW TsYuTg4BSwlFg1xw0kLAQU/nPxNlSJoMTJmU9YQEqYBdQl1s8TAgkzC8hLNG+dDXanhIC2RMP 5n2C3SQj0MUpsX9PJNoFReBaS9lkI7bOQtC9gZF7FqFGcWlSWWqRrbKSXVJSZnlGSm5iZo2to YKaXm1pcnJiempOYVKyXnJ+7iREY5AxAsIPx9LrAQ4ySHExKorzvbmdECvEl5adUZiQWZ8QXl eakFh9ilOHgUJLgveaXGSkkWJSanlqRlpkDjDeYtAQHj5IIr7M/UJq3uCAxtzgzHSJ1ilGXY8 Pq9V+YhFjy8vNSpcR5r4DMEAApyijNgxsBi/1LjLJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEub 1BFnFk5lXArfpFdARTEBHtGVlgBxRkoiQkmpgNFT1qJwjsaRiaafi3b8zn985y/5gs//662ov dXblXK7IF1W4Waev9/0Mb0RMuJb6vjMhj6KLav2MWj6v6HrVUxdpt6Kvhqlp55yUY5m6nHN6S 3uK2VO+NHXl//ER/72A4yxD/Y/tebPtqqNm32bm3/Sf59flmZUtP6cHTHq2TKbzOl/tdmFLJZ bijERDLeai4kQAlMNjiPgCAAA= X-Env-Sender: ming.lei@redhat.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1500074191!73183197!1 X-Originating-IP: [209.132.183.28] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMjA5LjEzMi4xODMuMjggPT4gNTQwNjQ=\n X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13710 invoked from network); 14 Jul 2017 23:16:32 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by server-15.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Jul 2017 23:16:32 -0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB5518553E; Fri, 14 Jul 2017 23:16:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DB5518553E DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DB5518553E Received: from localhost (ovpn-12-21.pek2.redhat.com [10.72.12.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C3636031D; Fri, 14 Jul 2017 23:16:23 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig Date: Sat, 15 Jul 2017 07:15:56 +0800 Message-Id: <20170714231601.14444-2-ming.lei@redhat.com> In-Reply-To: <20170714231601.14444-1-ming.lei@redhat.com> References: <20170714231601.14444-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 14 Jul 2017 23:16:31 +0000 (UTC) Cc: Juergen Gross , Ming Lei , xen-devel@lists.xenproject.org, Bart Van Assche , Boris Ostrovsky , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH 1/6] xen-blkfront: quiesce/unquiesce queue instead of start/stop queues 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP stopping queue may cause race and may not stop the queue really after the API returns, and we have improved quiescing interface and it really can block dispatching once it returns. So switch to quiesce/unquiece like what we did on other drivers (NVMe, NBD, mtip32xx, ...) The blk_mq_stop_hw_queues() and blk_mq_start_stopped_hw_queues() used in blkif_queue_rq() and blkif_interrupt() are for congestion control, we leave it as it is since it is safe for this usage. Cc: Konrad Rzeszutek Wilk Cc: "Roger Pau Monné" Cc: Boris Ostrovsky Cc: Juergen Gross Cc: xen-devel@lists.xenproject.org Signed-off-by: Ming Lei --- drivers/block/xen-blkfront.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index c852ed3c01d5..1578befda635 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1187,7 +1187,7 @@ static void xlvbd_release_gendisk(struct blkfront_info *info) return; /* No more blkif_request(). */ - blk_mq_stop_hw_queues(info->rq); + blk_mq_quiesce_queue(info->rq); for (i = 0; i < info->nr_rings; i++) { struct blkfront_ring_info *rinfo = &info->rinfo[i]; @@ -1216,8 +1216,10 @@ static void xlvbd_release_gendisk(struct blkfront_info *info) /* Already hold rinfo->ring_lock. */ static inline void kick_pending_request_queues_locked(struct blkfront_ring_info *rinfo) { - if (!RING_FULL(&rinfo->ring)) + if (!RING_FULL(&rinfo->ring)) { blk_mq_start_stopped_hw_queues(rinfo->dev_info->rq, true); + blk_mq_kick_requeue_list(rinfo->dev_info->rq); + } } static void kick_pending_request_queues(struct blkfront_ring_info *rinfo) @@ -1225,7 +1227,8 @@ static void kick_pending_request_queues(struct blkfront_ring_info *rinfo) unsigned long flags; spin_lock_irqsave(&rinfo->ring_lock, flags); - kick_pending_request_queues_locked(rinfo); + if (!RING_FULL(&rinfo->ring)) + blk_mq_run_hw_queues(rinfo->dev_info->rq, true); spin_unlock_irqrestore(&rinfo->ring_lock, flags); } @@ -1346,7 +1349,7 @@ static void blkif_free(struct blkfront_info *info, int suspend) BLKIF_STATE_SUSPENDED : BLKIF_STATE_DISCONNECTED; /* No more blkif_request(). */ if (info->rq) - blk_mq_stop_hw_queues(info->rq); + blk_mq_quiesce_queue(info->rq); for (i = 0; i < info->nr_rings; i++) blkif_free_ring(&info->rinfo[i]); @@ -2018,22 +2021,13 @@ static int blkif_recover(struct blkfront_info *info) /* Now safe for us to use the shared ring */ info->connected = BLKIF_STATE_CONNECTED; - for (r_index = 0; r_index < info->nr_rings; r_index++) { - struct blkfront_ring_info *rinfo; - - rinfo = &info->rinfo[r_index]; - /* Kick any other new requests queued since we resumed */ - kick_pending_request_queues(rinfo); - } - list_for_each_entry_safe(req, n, &info->requests, queuelist) { /* Requeue pending requests (flush or discard) */ list_del_init(&req->queuelist); BUG_ON(req->nr_phys_segments > segs); blk_mq_requeue_request(req, false); } - blk_mq_start_stopped_hw_queues(info->rq, true); - blk_mq_kick_requeue_list(info->rq); + blk_mq_unquiesce_queue(info->rq); while ((bio = bio_list_pop(&info->bio_list)) != NULL) { /* Traverse the list of pending bios and re-queue them */