Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932710AbdCIQ7S (ORCPT ); Thu, 9 Mar 2017 11:59:18 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:40026 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754769AbdCIQ6s (ORCPT ); Thu, 9 Mar 2017 11:58:48 -0500 X-IronPort-AV: E=Sophos;i="5.36,136,1486396800"; d="scan'208";a="1961561" Authentication-Results: spf=pass (sender IP is 74.221.232.54) smtp.mailfrom=sandisk.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=sandisk.com; X-AuditID: ac1c2133-99bff7000000c960-d2-58c189b401fb From: Bart Van Assche To: "linux-kernel@vger.kernel.org" , "hch@infradead.org" , "linux-block@vger.kernel.org" , "tom.leiming@gmail.com" , "axboe@fb.com" CC: "yizhan@redhat.com" , "tj@kernel.org" Subject: Re: [PATCH 2/2] blk-mq: start to freeze queue just after setting dying Thread-Topic: [PATCH 2/2] blk-mq: start to freeze queue just after setting dying Thread-Index: AQHSmPZe5nYT78/Ep0GJ+9WTi9E4LQ== Date: Thu, 9 Mar 2017 16:58:26 +0000 Message-ID: <1489078694.2597.5.camel@sandisk.com> References: <1489064578-17305-1-git-send-email-tom.leiming@gmail.com> <1489064578-17305-4-git-send-email-tom.leiming@gmail.com> In-Reply-To: <1489064578-17305-4-git-send-email-tom.leiming@gmail.com> Accept-Language: nl-NL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.28.1.254] Content-Type: text/plain; charset="iso-8859-1" Content-ID: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsWyRobxn+72zoMRBttWq1r833OMzeL0hEVM FntvaVtc3jWHzeLX8qOMFu9/XGe32HLlLpsDu8fE5nfsHjtn3WX32LxCy2PTqk42j/f7rrJ5 fN4kF8AWxWWTkpqTWZZapG+XwJWx7tFMloJ9IhVXrzcwAqFgFyMnh4SAicSSjQuZuxi5OIQE ljBJvNhziwXCOc8osWDqEiaQKjYBI4nZE/aAJUQE/jJKTO6+wQySYBbwkZjYPAGsSFggUOJx xz3GLkYOoKIgiSeba0HCIgJ6Ej+372cHsVkEVCS2f/wK1sorYChx8uNVdohlTYwS31eeYQXp 5RRwk7j8xRfEZBSQlWh5zQ2xSVzi1pP5TBBHC0gs2XOeGcIWlXj5+B8rhK0g8XnFPzaIej2J G1OnsIGMYRawknh/UgkirC2xbOFrqAsEJU7OfMIygVFsFpINs5B0z0LonoWkexaS7gWMrKsY xYoTk4tz01MLDE30ihPzUjKLs/WS83M3MYIjVdF4B+O/De6HGAU4GJV4eD/kHowQYk0sK67M PcQowcGsJMLr1AoU4k1JrKxKLcqPLyrNSS0+xCjNwaIkzhsze2qEkEB6YklqdmpqQWoRTJaJ g1OqgVH86e0wXQ/B37OqZh14t9Ppsc3yKO+3BYLrWPhDgjRMed2XXf37dfaT40YamlrL74fw ivSo1skmLBf9/qBJa8mirAUO9bUiiy496/728LTu7E159w4Up+zZv85gTal1zv6vJ9yrQk5e UZLm6SuOuqAQPpvtzh7O6kNzA0Rq++/NkrmaL5qx+YYSS3FGoqEWc1FxIgDFSlRp0AIAAA== X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:74.221.232.54;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(39450400003)(39840400002)(39850400002)(39410400002)(2980300002)(438002)(24454002)(377424004)(189002)(199003)(9170700003)(6116002)(81166006)(8676002)(5660300001)(102836003)(3846002)(7736002)(106466001)(33646002)(8936002)(47776003)(229853002)(305945005)(106116001)(8746002)(2501003)(356003)(2950100002)(53936002)(23756003)(6246003)(76176999)(189998001)(2201001)(4326008)(38730400002)(2270400002)(39060400002)(50986999)(103116003)(2900100001)(54906002)(36756003)(86362001)(54356999)(50466002)(2906002)(7099028);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR0401MB1492;H:sacsmgep14.sandisk.com;FPR:;SPF:Pass;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM04FT032;1:qi98RB+5ieLOqjiZ6xmLEsL+2pC+p64JP8ON6277SKLcMtf8zfw2fPJTq+sCfojfjSt0IEIaOyMmuaUOvWTxD4+uaZnpCr8YQV9YzeMbtq/taXNfzbJuC4sxFgJB1nruHjOzr8JHtRu/dNAbLJPDzbHhqouVep/yo3EA59ftfpWuNV6BuwSOy057zXv8ePG3H6wKaZ0Mx8wsxgR6/vZYkCKxsK3Rn3Jj1KZsl3z2fDDiFZhICUhLBj7yCwrF7Faz2FtC/aTg1TsLy8KM+sONUIboEqc0jKFoswxBAftTWWMVvqOhc9EYyXVykgtV+j6H2mHIZqiQtQZJGE1CEZ3lCQ1qMlp6jveNPWGAhcg2S0VMZZUyE+a8EWzzsOOXAjT42OAX0/C1FyiltzrC0xgWJ9Ha7uWh0T/PjjTmF0JP21hYmQY+A6lwx3c5jrInhMd5ZKPAdrR86HyOd7rzAbPK2G0o4HVvV3jK2CU3WHJuoxPXVjVMTANb2pSBiMXjkihxI+PPGXGNmv1C+m5mLIRJ1YfT0/HREsKjwPP9mc+VHgYXyRwjk5YhPnn8KmZgoqWs X-MS-Office365-Filtering-Correlation-Id: cae61150-5f8f-4cb3-8709-08d4670d84aa X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002);SRVR:BLUPR0401MB1492; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0401MB1492;3:lxyJLu+AbCVDyiLhiZLquJc9knqJN+rM9fs6bdcUwyhgP+yZ5XN7NSXTgsDocYZAn3Tp1dOnbO1TE+jGBRRmYXoJNV/CnhkXygyx8bK73eVCZhjRp9iT5DQtD0vhtJzy6gp0yoMKWCfyHUTrE55cdIC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oP/d0TiYP0uFlva1tCP08hIu1/UvtK//7M3cGDEANLiLTUD4V2o4SyBZ2VKvemBJa7NQoL5+YX8ZpIf5ULoQcghUm3+BTUt8XuuazPuXr7mEsARzQhayFiThvCrLwHiT8TV12EnHLN2w0TMOtI+rE/LSgubR+j9ZaVh3C3uR6LnU2AmJmF7MsTTFBMJ/3bDFGHfTJ/ZPEufRi/WkZwRlGj76febGNxtidEMesdD2m2csFF9vkJbgTCF7z2z3QBuAMul+M6HVqJz9rOaQsXV1CU2GFu5+tQn2L79EzwsKP6NVHq1mu6rTHcixKKR/Nroy85/N7xp1gnwU1nc8VrVFAwVg9SUGRinDM4R6asuSX+RCRyIHRxVeFBB10E9i5DTbmeGjhrwwwJ3m9UnLJ+RGHRcuxEvE8AwQTkHVKyrk4CCqGaftDPnFXoVMIs4c+8QgHxsHOH5jktaqT0KcnTNL WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(13024025)(13023025)(13016025)(13018025)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123558025)(20161123562025)(20161123555025)(20161123560025)(6072148);SRVR:BLUPR0401MB1492;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0401MB1492; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0401MB1492;4:EhOHjxZk2sEWjlLzX+lkARs/Rg6DhBICwiO6JKDwBvpxhVZSxzO+9t3ZcxwnpUiRbW35UhxWb11BVIY4mGBksuqx9ngBzYNekyXMl+XxhMxWfiYEB9ArTY1TQdMojNTwBQWuaizKl6KMUZVGB0EjAHveLaUUTErN3B+vr9LT/KwmxaQnmazByePsGLRrkRy6zMI683wJhqtgUDTLypbPl8+opi3VGo+U9QhUSGANE0IphY5XRn1AhUUz+UPwBjiN12hypcoBOVM8KJy+A/wLCD2d7pq1I5o2/neN61L6FX1fWCUWw/HA0AFMRaPDzRsxNBUe/wv32U8EDyAlum1L7E1z6wRPgLmWinu3kD3Qo9c7yLE7rlqYFmVdZxZGJTe/OaKP+h+VZBDpM4JTDzEZV1Dxx31n1CGqonFt+mk6/IJexHooa2qrgg+iQDrVEZphZ3nHjD1Z7CI87WA0MKJNLMlP5g0B96iSg6pKjVi645cenaxT/YGLvnv5m6ndoGAD8TLqxiiG701Rvr3f8/EbGqKYl9HHWdxP7LrHUYzrYRqKinhtkiMeNMHkfj/Mn2iBaBG9kl/4MoiYFpqMVq9+6InzxoP0siebJp4HtbtbAge4ad03qEevt04OdyBrXGl4r++iJb9gavrWOnEIsdIYZIorFJH2QdxgaxyPxNEKHZBuGnalgwvuXspL2MvJ2NCG X-Forefront-PRVS: 0241D5F98C X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;BLUPR0401MB1492;23:LSQ84fXaEIUXUdHbb4ch4XdIHDgCE8IDPVqQA?= =?iso-8859-1?Q?G1uq56+L2B13d4bvrh0i8r/Mms+0M6bbAXvWW1qftFMeS3jPS9NZJZM8SB?= =?iso-8859-1?Q?iMNu6BxsslBTwtdK/EaoehV0ZPMCC++I6PBip0arbf6+LkpCvZCDyiHFKA?= =?iso-8859-1?Q?8YLSDMHXSBQycZWZMGKATAhbEiOicy2ORRgklXllOLC8e8sajha1juMFDy?= =?iso-8859-1?Q?VGaSUBazB0Ix0PFueqD65De6dovT1kTi8cVkph3QuDfoopc1q2QXzNWzRU?= =?iso-8859-1?Q?QFnZ29y+6uU5rplUhjNhrehSUsihP+e/gF+G6tX4jSNZUW2K04oKrjFQL9?= =?iso-8859-1?Q?sOBg0Kou+24SnHoz61fBOTEIYTLpxv9y92/aXj45CxcfnbXDHPIo4+bQVr?= =?iso-8859-1?Q?W/ZiDl9MS/znp/t7RF1M6x/O5Sv6GRzCnpDxYNpm9V/SaWkPl4FzqpW0vL?= =?iso-8859-1?Q?38yMMiVCmzCV+e7NgIrqbkL9VcKJ8VmpT7fDyWaOc9U+jFvvnemUTa87wa?= =?iso-8859-1?Q?vIsbCAvQVjwuCE0g45hWRNTRfxYayMaCBl+6LKJmhCmVCqhHuAzuQMDHAn?= =?iso-8859-1?Q?mRwrJPDm49MfBkZ9ZaMy4BIt1JYTaC+LhvS0LbTgTwpBuyFuZnQ9TWVnUF?= =?iso-8859-1?Q?RCc7XTnKNPUIX70Kglfk2NxGhds+aLEFWvMJgJhYEffa7Sz0JtgcJO4L8f?= =?iso-8859-1?Q?BITt1cu2o1oy6GWHvf0P4/aB3Cn+u6HtYRsj+6XaZvXXEnozuhxuQdIJOv?= =?iso-8859-1?Q?AjgyVKEFapIhYDN0wZeQ0TQNklVr7QMJJfwanuYDOAgHeTyi9Rmr3meP6D?= =?iso-8859-1?Q?g/sOyRFux3mNrD5KkSOfYYEJjNMlUlvmkQSVPxKFEqOWahZiuUtvFaJ1Iy?= =?iso-8859-1?Q?iBrq8szOIRN3zscSD38DtE/KzJQTdKCLkrOhBWHOU4SGADkn5q9zSGGbqO?= =?iso-8859-1?Q?bGq0atW2HOj+A4525lOhZGpbqEIDfv9RJVyoBR/mirCd84FkNaZpKH7006?= =?iso-8859-1?Q?n84l+esom0ZBbqP0ZceWBAOhGYCLfkWpipJPpoY0QUkWf978OkLK1+Vckj?= =?iso-8859-1?Q?63yTC9wttCdno6luIguO+PtS25YqVBeTO8j5Imi6cAxWwYeMUJovM8GVM2?= =?iso-8859-1?Q?Ag6RIexhnkJicpG0WzKVKeeGldIzzr5C+ED5BcKDAFsNQBRE5O9/bAISi2?= =?iso-8859-1?Q?P5dWP/Lcf7/YML1JFluWns//yv1UrahC8qL/QMoNZMamEy2EG+rS3sdmky?= =?iso-8859-1?Q?AUHQehexfrYFdO7Mz5xgVJtYS75HG7OYaVywFpld46bplRfPw2KpMLsFIB?= =?iso-8859-1?Q?3EUA=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0401MB1492;6:DVriUeQzi/5eAdbDAB7VpcGwlDhrybgaV8M1iG6J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XrruJOg==;20:0SEyTeeOGgHlapcRxBcjTE9aGWYhJewjiaVyiC0/hykV2tzrbBPoYkzw/QcQVvIjupg15+POk/g8oeb0t1Q3R4jp67f+DYG3sdm/lU9XTleJZOzNuJlRQ+/SRESUdBGu9dgY3Qxd2vIhd0EJYAHkWSm81GXlFD1t+RhJREISWOk= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2017 16:58:31.7992 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86;Ip=[74.221.232.54];Helo=[sacsmgep14.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0401MB1492 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v29GxeJl004328 Content-Length: 2497 Lines: 76 On Thu, 2017-03-09 at 21:02 +0800, Ming Lei wrote: > 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); The comment above blk_mq_freeze_queue_start() should explain more clearly why that call is needed. Additionally, I think this patch makes the blk_freeze_queue() call in blk_cleanup_queue() superfluous. How about the (entirely untested) patch below? diff --git a/block/blk-core.c b/block/blk-core.c index 1086dac8724c..3ce48f2d65cf 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -500,6 +500,12 @@ void blk_set_queue_dying(struct request_queue *q) ? queue_flag_set(QUEUE_FLAG_DYING, q); ? spin_unlock_irq(q->queue_lock); ? + /* + ?* Force blk_queue_enter() and blk_mq_queue_enter() to check the + ?* "dying" flag. + ?*/ + blk_freeze_queue(q); + ? if (q->mq_ops) ? blk_mq_wake_waiters(q); ? else { @@ -555,7 +561,7 @@ void blk_cleanup_queue(struct request_queue *q) ? ?* Drain all requests queued before DYING marking. Set DEAD flag to ? ?* prevent that q->request_fn() gets invoked after draining finished. ? ?*/ - blk_freeze_queue(q); + WARN_ON_ONCE(!atomic_read(&q->mq_freeze_depth)); ? spin_lock_irq(lock); ? if (!q->mq_ops) ? __blk_drain_queue(q, true); Thanks, Bart.