From patchwork Fri Mar 17 09:57:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9630171 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 164A460249 for ; Fri, 17 Mar 2017 10:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8FE0286A2 for ; Fri, 17 Mar 2017 10:00:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD967286A4; Fri, 17 Mar 2017 10:00:33 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 6C3C6286A2 for ; Fri, 17 Mar 2017 10:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751061AbdCQJ70 (ORCPT ); Fri, 17 Mar 2017 05:59:26 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34534 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbdCQJ7X (ORCPT ); Fri, 17 Mar 2017 05:59:23 -0400 Received: by mail-pf0-f195.google.com with SMTP id o126so8737103pfb.1; Fri, 17 Mar 2017 02:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P7QOoP4+VcZX8pS76PkM61jFNK2sjElGMAihiAGLs5A=; b=pIaBoyue+3QtIEuNcBSjI0OPcEbFA3qqasVVbsouozKHsOgAZOI8ClMKoo4YSFSQVh HMM5gxfPYNkYyr6G8YvsLFwjcBe3WAMkyACAr8ArurzaKGwuLMoMn7m+5VeSFB/Vf0uA zbGMFgmsbtzHgGxD713u2BzckfxiS2xkcJUP1zBPhiLBWihZLRuC1swI3OMCaZ7WlUYe TmI1YJR4PAtPv5hNb9ZVHHNZjzvSA0jEFKQHqnfzs/PNTBxXsmXLuLMyu4bVeYyTDjRP 2w4RYaRJKf1S1mTADVGKq1aAqnbDGjLNzvgVnC99NCD50vIHcSueB4ZrctiFMetjBxcp Ueyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P7QOoP4+VcZX8pS76PkM61jFNK2sjElGMAihiAGLs5A=; b=itesMR2uHFfgi3XTZy/nabm3q4488tQs4SleJSiGV1xhE5XF7m2cOvJEGybLjk+B1O YnXntvpn5ygavMbeC/5a5MkZwg+eNL3xiV25RduQkRYTS9ovd+pcSwHIn193bpXz0ruh WWwudSRLPslsvlKfcsxo/PI5yS270GShk6+ccq8DIv7mH1cNa7UrmP0IT3MLuJm+OoD6 akQCN7hxDjlqWmYJ+RqLcqbaVfX3ux8I+sx//G29qtXFkfasaAGnL/HBzbn4QLwzyFDu o+yV+e41dzEpTA76vMq+Nwib1OT5z+538Nln5JADA87dWqrSfVpBwI2Ngv+N1lrD7KHE W+ew== X-Gm-Message-State: AFeK/H0wl18v+4jKOfjiJ4vgxvZT5cBeyo7dn7gWcyycIQbj5BforXyVyaGgqMg9ADLnUQ== X-Received: by 10.98.108.1 with SMTP id h1mr721414pfc.95.1489744651790; Fri, 17 Mar 2017 02:57:31 -0700 (PDT) Received: from localhost ([103.192.224.52]) by smtp.gmail.com with ESMTPSA id f21sm15649458pff.48.2017.03.17.02.57.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Mar 2017 02:57:31 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig Cc: Yi Zhang , Bart Van Assche , Ming Lei , Tejun Heo Subject: [PATCH v1 3/3] blk-mq: start to freeze queue just after setting dying Date: Fri, 17 Mar 2017 17:57:11 +0800 Message-Id: <20170317095711.5819-4-tom.leiming@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170317095711.5819-1-tom.leiming@gmail.com> References: <20170317095711.5819-1-tom.leiming@gmail.com> 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 Before commit 780db2071a(blk-mq: decouble blk-mq freezing from generic bypassing), the dying flag is checked before entering queue, and Tejun converts the checking into .mq_freeze_depth, and assumes the counter is increased just after dying flag is set. Unfortunately we doesn't do that in blk_set_queue_dying(). This patch calls blk_mq_freeze_queue_start() for blk-mq in blk_set_queue_dying(), so that we can block new I/O coming once the queue is set as dying. Given blk_set_queue_dying() is always called in remove path of block device, and queue will be cleaned up later, we don't need to worry about undoing the counter. Cc: Bart Van Assche Cc: Tejun Heo Signed-off-by: Ming Lei Reviewed-by: Hannes Reinecke --- block/blk-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d772c221cc17..62d4967c369f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -500,9 +500,12 @@ void blk_set_queue_dying(struct request_queue *q) queue_flag_set(QUEUE_FLAG_DYING, q); spin_unlock_irq(q->queue_lock); - if (q->mq_ops) + if (q->mq_ops) { blk_mq_wake_waiters(q); - else { + + /* block new I/O coming */ + blk_mq_freeze_queue_start(q); + } else { struct request_list *rl; spin_lock_irq(q->queue_lock);