From patchwork Thu Mar 9 13:02:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9613331 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 4B91E604D9 for ; Thu, 9 Mar 2017 13:12:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 431E7252D5 for ; Thu, 9 Mar 2017 13:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 341B526419; Thu, 9 Mar 2017 13:12:08 +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=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 BF508252D5 for ; Thu, 9 Mar 2017 13:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932258AbdCINMH (ORCPT ); Thu, 9 Mar 2017 08:12:07 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33490 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932250AbdCINMG (ORCPT ); Thu, 9 Mar 2017 08:12:06 -0500 Received: by mail-pg0-f68.google.com with SMTP id 77so6780666pgc.0; Thu, 09 Mar 2017 05:12:05 -0800 (PST) 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=kPh2xUeCnqsIFF8m/AICi0AUVm+uHnji+AWlxZNfoss=; b=N0N6+FkNctkx6/tIauITacrVIQc3AONoWKnxGEEI3W/kJJC2jzd2fn4UvYYptF+K5M ygHbg4OWnKTzLyF78gR8KTCQ/+tc7KFi8mQMimQ2zC6siomGG23OT/B3tzozOoIHs5Wi dlvqJoJLpg1JAr7EuIMV+oqrc28acQBA8rWGgp3+1JbUnmHyAAfA8kjMl3h/p+nYn/XS YR6Az3B2CqXpbEYrpFgzXOOBp8tTNNd9/AmgprWnEULQqjuBkDb3PeIl0mFmjfng+R1C tb6+HqoAv5PkL7++G6y3tsb3oxV0zlh+4hwEV6OMgV9ygILDrpbfOj3uSsQ4cJGAonaJ mwxA== 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=kPh2xUeCnqsIFF8m/AICi0AUVm+uHnji+AWlxZNfoss=; b=TDlWLKvnIgqjNAEKbC2ekPlgx/92XBTjcJIBkn7se0HJrdGdekLsbl0yEYKgZ59rqp nMLbNHDE7vxPmoMoFo58xXf9L2fz9xkSRKo93asJyMV4cdncKna6VafSgsnkgZmms8bf G4DbwVBRs32RAz7L6GMDNx57hgXDE6domGWyzN8WJIpW63+8oduJKQt71ixOH3FMn8eP athh3XfJrx19aoZsYp1hvZS6t/PmCpwDnREcR9gWbJpPtznnV5CC9+CevaGNXCGkja99 Dl+YpvVyHOFA4N+WgxsmCs9SEiNUMKpvUZLz9yDfrtFpQz1gj4A4ujAPgWHmJfqyVWX9 nqNg== X-Gm-Message-State: AMke39lmdf6MSGFDj4C6ptX8F2VBDryCtLqcBxWTDWD3TvAZTonv5vyVD2j7aa9im62MPg== X-Received: by 10.84.236.67 with SMTP id h3mr17039560pln.12.1489064637040; Thu, 09 Mar 2017 05:03:57 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id b195sm12532573pfb.106.2017.03.09.05.03.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 05:03:56 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig Cc: Yi Zhang , Ming Lei , Tejun Heo Subject: [PATCH 2/2] blk-mq: start to freeze queue just after setting dying Date: Thu, 9 Mar 2017 21:02:58 +0800 Message-Id: <1489064578-17305-4-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489064578-17305-1-git-send-email-tom.leiming@gmail.com> References: <1489064578-17305-1-git-send-email-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 undo of the counter. Cc: Tejun Heo Signed-off-by: Ming Lei --- 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 0eeb99ef654f..559487e58296 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);