From patchwork Thu Mar 31 10:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Kleibel X-Patchwork-Id: 12796969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D732C433EF for ; Thu, 31 Mar 2022 10:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234429AbiCaKCC (ORCPT ); Thu, 31 Mar 2022 06:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233813AbiCaKCB (ORCPT ); Thu, 31 Mar 2022 06:02:01 -0400 Received: from iris.vrvis.at (iris.vrvis.at [92.60.8.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FD4338A7; Thu, 31 Mar 2022 03:00:12 -0700 (PDT) Received: from [10.43.0.42] by iris.vrvis.at with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZrb7-0006OG-6E; Thu, 31 Mar 2022 12:00:09 +0200 Message-ID: Date: Thu, 31 Mar 2022 12:00:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Cc: stable@vger.kernel.org, Jens Axboe , Justin Sanders , linux-block@vger.kernel.org Content-Language: en-US From: Valentin Kleibel To: Greg Kroah-Hartman References: <50ddedf1-5ac3-91c3-0b50-645ceb541071@vrvis.at> <9dd4a25a-7deb-fcdf-0c05-d37d4c894d86@vrvis.at> In-Reply-To: Subject: [PATCH v2 1/2] block: add blk_alloc_disk and blk_cleanup_disk APIs Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add two new APIs to allocate and free a gendisk including the request_queue for use with BIO based drivers. This is to avoid boilerplate code in drivers. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Ulf Hansson Link: https://lore.kernel.org/r/20210521055116.1053587-6-hch@lst.de Signed-off-by: Jens Axboe (cherry picked from commit f525464a8000f092c20b00eead3eaa9d849c599e) Fixes: 3582dd291788 (aoe: convert aoeblk to blk-mq) Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215647 Signed-off-by: Valentin Kleibel --- block/genhd.c | 15 +++++++++++++++ include/linux/genhd.h | 1 + 2 files changed, 16 insertions(+) void revalidate_disk_size(struct gendisk *disk, bool verbose); diff --git a/block/genhd.c b/block/genhd.c index 796baf761202..421cad085502 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1836,6 +1836,21 @@ void put_disk_and_module(struct gendisk *disk) } } EXPORT_SYMBOL(put_disk_and_module); +/** + * blk_cleanup_disk - shutdown a gendisk allocated by blk_alloc_disk + * @disk: gendisk to shutdown + * + * Mark the queue hanging off @disk DYING, drain all pending requests, then mark + * the queue DEAD, destroy and put it and the gendisk structure. + * + * Context: can sleep + */ +void blk_cleanup_disk(struct gendisk *disk) +{ + blk_cleanup_queue(disk->queue); + put_disk(disk); +} +EXPORT_SYMBOL(blk_cleanup_disk); static void set_disk_ro_uevent(struct gendisk *gd, int ro) { diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 03da3f603d30..b7b180d3734a 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -369,6 +369,7 @@ extern void blk_unregister_region(dev_t devt, unsigned long range); #define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE) int register_blkdev(unsigned int major, const char *name); +void blk_cleanup_disk(struct gendisk *disk); void unregister_blkdev(unsigned int major, const char *name); From patchwork Thu Mar 31 10:01:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Kleibel X-Patchwork-Id: 12796970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70076C433FE for ; Thu, 31 Mar 2022 10:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234220AbiCaKDN (ORCPT ); Thu, 31 Mar 2022 06:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233682AbiCaKDL (ORCPT ); Thu, 31 Mar 2022 06:03:11 -0400 Received: from iris.vrvis.at (iris.vrvis.at [92.60.8.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2867964BF5; Thu, 31 Mar 2022 03:01:22 -0700 (PDT) Received: from [10.43.0.42] by iris.vrvis.at with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZrcG-0006PH-P5; Thu, 31 Mar 2022 12:01:21 +0200 Message-ID: <774968b2-5d34-0f36-5ec6-284aaabb4585@vrvis.at> Date: Thu, 31 Mar 2022 12:01:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Cc: stable@vger.kernel.org, Jens Axboe , Justin Sanders , linux-block@vger.kernel.org Content-Language: en-US From: Valentin Kleibel To: Greg Kroah-Hartman References: <50ddedf1-5ac3-91c3-0b50-645ceb541071@vrvis.at> <9dd4a25a-7deb-fcdf-0c05-d37d4c894d86@vrvis.at> In-Reply-To: Subject: [PATCH v2 2/2] aoe: use blk_mq_alloc_disk and blk_cleanup_disk Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Link: https://lore.kernel.org/r/20210602065345.355274-17-hch@lst.de Signed-off-by: Jens Axboe (cherry picked from commit 6560ec961a080944f8d5e1fef17b771bfaf189cb) Fixes: 3582dd291788 (aoe: convert aoeblk to blk-mq) Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215647 Signed-off-by: Valentin Kleibel --- drivers/block/aoe/aoedev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index e2ea2356da06..c5753c6bfe80 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -277,9 +277,8 @@ freedev(struct aoedev *d) if (d->gd) { aoedisk_rm_debugfs(d); del_gendisk(d->gd); - put_disk(d->gd); + blk_cleanup_disk(d->gd); blk_mq_free_tag_set(&d->tag_set); - blk_cleanup_queue(d->blkq); } t = d->targets; e = t + d->ntargets;