From patchwork Fri May 18 18:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10411865 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 51C536031B for ; Fri, 18 May 2018 18:40:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4145828707 for ; Fri, 18 May 2018 18:40:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3438228A8D; Fri, 18 May 2018 18:40:06 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 9606D287E6 for ; Fri, 18 May 2018 18:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751049AbeERSkE (ORCPT ); Fri, 18 May 2018 14:40:04 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:38072 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbeERSkD (ORCPT ); Fri, 18 May 2018 14:40:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1526668804; x=1558204804; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=FmR6nxDMLWvIsndfMTTiq24csjrSrT0L7ZI/0hhEslc=; b=EUkPewfwz2BZ66Sniouhd32eJlsUDW1PFLg8RQAQYbQEseAj/bbYLWxV YKmUDP2WS+eP8lY+gD5c6AfGYU2G3xaGVTVvtuOxa7trqG8VUgNAcnX6e qzLwanUlb16RNtSuKvkjw3I24FJ/GieL/9dqRDDeDvaISEPHYOZQgW7RA dnSv5T5bdrDLzU5v3equG+mdyGK1bQukpYVsmIWwK8blh0O6GhZLwLw3a OKZvBai6Y0DhHXmKUyBOH4YZl6epHFSDMZ0k7BriRJRO8tymw53EgQxfW SvSi4JC5atS5/Yo2S6tGrtdkHhXhoMUredzEK0TzVcJV8OcQDSIxGt786 Q==; X-IronPort-AV: E=Sophos;i="5.49,415,1520870400"; d="scan'208";a="78309426" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 May 2018 02:40:04 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 18 May 2018 11:30:37 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.70.1]) by uls-op-cesaip01.wdc.com with ESMTP; 18 May 2018 11:40:04 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Alexandru Moise <00moses.alexander00@gmail.com>, Hannes Reinecke , Ming Lei , Omar Sandoval , Joseph Qi Subject: [PATCH v3 1/2] block: Introduce blk_exit_queue() Date: Fri, 18 May 2018 11:40:02 -0700 Message-Id: <20180518184003.29738-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180518184003.29738-1-bart.vanassche@wdc.com> References: <20180518184003.29738-1-bart.vanassche@wdc.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 This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Alexandru Moise <00moses.alexander00@gmail.com> Cc: Hannes Reinecke Cc: Ming Lei Cc: Omar Sandoval Cc: Joseph Qi --- block/blk-core.c | 54 ++++++++++++++++++++++++++++++------------------------ block/blk.h | 1 + 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 4dadff238b02..ac28a9c7136f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -720,6 +720,35 @@ void blk_set_queue_dying(struct request_queue *q) } EXPORT_SYMBOL_GPL(blk_set_queue_dying); +/* Unconfigure the I/O scheduler and dissociate from the cgroup controller. */ +void blk_exit_queue(struct request_queue *q) +{ + /* + * Since the I/O scheduler exit code may access cgroup information, + * perform I/O scheduler exit before disassociating from the block + * cgroup controller. + */ + if (q->elevator) { + ioc_clear_queue(q); + elevator_exit(q, q->elevator); + q->elevator = NULL; + } + + /* + * Remove all references to @q from the block cgroup controller before + * restoring @q->queue_lock to avoid that restoring this pointer causes + * e.g. blkcg_print_blkgs() to crash. + */ + blkcg_exit_queue(q); + + /* + * Since the cgroup code may dereference the @q->backing_dev_info + * pointer, only decrease its reference count after having removed the + * association with the block cgroup controller. + */ + bdi_put(q->backing_dev_info); +} + /** * blk_cleanup_queue - shutdown a request queue * @q: request queue to shutdown @@ -785,30 +814,7 @@ void blk_cleanup_queue(struct request_queue *q) */ WARN_ON_ONCE(q->kobj.state_in_sysfs); - /* - * Since the I/O scheduler exit code may access cgroup information, - * perform I/O scheduler exit before disassociating from the block - * cgroup controller. - */ - if (q->elevator) { - ioc_clear_queue(q); - elevator_exit(q, q->elevator); - q->elevator = NULL; - } - - /* - * Remove all references to @q from the block cgroup controller before - * restoring @q->queue_lock to avoid that restoring this pointer causes - * e.g. blkcg_print_blkgs() to crash. - */ - blkcg_exit_queue(q); - - /* - * Since the cgroup code may dereference the @q->backing_dev_info - * pointer, only decrease its reference count after having removed the - * association with the block cgroup controller. - */ - bdi_put(q->backing_dev_info); + blk_exit_queue(q); if (q->mq_ops) blk_mq_free_queue(q); diff --git a/block/blk.h b/block/blk.h index 204a0345996c..ec914ae7130c 100644 --- a/block/blk.h +++ b/block/blk.h @@ -130,6 +130,7 @@ void blk_free_flush_queue(struct blk_flush_queue *q); int blk_init_rl(struct request_list *rl, struct request_queue *q, gfp_t gfp_mask); void blk_exit_rl(struct request_queue *q, struct request_list *rl); +void blk_exit_queue(struct request_queue *q); void blk_rq_bio_prep(struct request_queue *q, struct request *rq, struct bio *bio); void blk_queue_bypass_start(struct request_queue *q);