From patchwork Thu Dec 1 08:45:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masayoshi Mizuma X-Patchwork-Id: 9455643 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 462A660585 for ; Thu, 1 Dec 2016 09:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B97328448 for ; Thu, 1 Dec 2016 09:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D0622847F; Thu, 1 Dec 2016 09:08:40 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 92E3E28448 for ; Thu, 1 Dec 2016 09:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756396AbcLAJI3 (ORCPT ); Thu, 1 Dec 2016 04:08:29 -0500 Received: from mgwkm01.jp.fujitsu.com ([202.219.69.168]:53785 "EHLO mgwkm01.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758923AbcLAJI0 (ORCPT ); Thu, 1 Dec 2016 04:08:26 -0500 X-Greylist: delayed 626 seconds by postgrey-1.27 at vger.kernel.org; Thu, 01 Dec 2016 04:08:26 EST Received: from kw-mxq.gw.nic.fujitsu.com (unknown [192.168.231.130]) by mgwkm01.jp.fujitsu.com with smtp id 0a9d_5535_e5707f93_0602_4a65_abcf_5da3a20b3b9b; Thu, 01 Dec 2016 17:45:59 +0900 Received: from g01jpfmpwkw03.exch.g01.fujitsu.local (g01jpfmpwkw03.exch.g01.fujitsu.local [10.0.193.57]) by kw-mxq.gw.nic.fujitsu.com (Postfix) with ESMTP id 91FA6AC00F2 for ; Thu, 1 Dec 2016 17:45:59 +0900 (JST) Received: from g01jpexchkw37.g01.fujitsu.local (unknown [10.0.193.4]) by g01jpfmpwkw03.exch.g01.fujitsu.local (Postfix) with ESMTP id 09CBFBD6514; Thu, 1 Dec 2016 17:45:05 +0900 (JST) Received: from [10.124.101.104] (10.124.101.104) by g01jpexchkw37.g01.fujitsu.local (10.0.193.67) with Microsoft SMTP Server id 14.3.266.1; Thu, 1 Dec 2016 17:45:05 +0900 Message-ID: <583FE310.7040607@jp.fujitsu.com> Date: Thu, 1 Dec 2016 17:45:04 +0900 From: Masayoshi Mizuma User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Jens Axboe CC: Subject: [PATCH] block: avoid incorrect bdi_unregiter call in blk_cleanup_queue X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable 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 blk_cleanup_queue() should call bdi_unregister() only if WB_registered is set to bdi->wb.state. Because, blk_cleanup_queue() may be called before bdi_register() is called, for example, error path. Signed-off-by: Masayoshi Mizuma --- block/blk-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 14d7c07..c1ab17e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -595,7 +595,8 @@ void blk_cleanup_queue(struct request_queue *q) q->queue_lock = &q->__queue_lock; spin_unlock_irq(lock); - bdi_unregister(&q->backing_dev_info); + if (test_bit(WB_registered, &q->backing_dev_info.wb.state)) + bdi_unregister(&q->backing_dev_info); /* @q is and will stay empty, shutdown and put */ blk_put_queue(q);