From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B1D7C43461 for ; Fri, 21 May 2021 06:15:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5280D613BF for ; Fri, 21 May 2021 06:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbhEUGRG (ORCPT ); Fri, 21 May 2021 02:17:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:34600 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbhEUGRG (ORCPT ); Fri, 21 May 2021 02:17:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C9DB4AC87; Fri, 21 May 2021 06:15:41 +0000 (UTC) To: Christoph Hellwig Cc: linux-block@vger.kernel.org, dm-devel@redhat.com, linux-m68k@lists.linux-m68k.org, linux-xtensa@linux-xtensa.org, drbd-dev@lists.linbit.com, linuxppc-dev@lists.ozlabs.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, Jens Axboe , Geert Uytterhoeven , Chris Zankel , Max Filippov , Philipp Reisner , Lars Ellenberg , Jim Paris , Joshua Morris , Philip Kelleher , Minchan Kim , Nitin Gupta , Matias Bjorling , Mike Snitzer , Song Liu , Maxim Levitsky , Alex Dubov , Ulf Hansson , Dan Williams , Vishal Verma , Dave Jiang , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-mmc@vger.kernel.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-s390@vger.kernel.org References: <20210521055116.1053587-1-hch@lst.de> <20210521055116.1053587-13-hch@lst.de> From: Coly Li Subject: Re: [PATCH 12/26] bcache: convert to blk_alloc_disk/blk_cleanup_disk Message-ID: Date: Fri, 21 May 2021 14:15:32 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210521055116.1053587-13-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On 5/21/21 1:51 PM, Christoph Hellwig wrote: > Convert the bcache driver to use the blk_alloc_disk and blk_cleanup_disk > helpers to simplify gendisk and request_queue allocation. > > Signed-off-by: Christoph Hellwig > --- > drivers/md/bcache/super.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index bea8c4429ae8..185246a0d855 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -890,13 +890,9 @@ static void bcache_device_free(struct bcache_device *d) > if (disk_added) > del_gendisk(disk); > > - if (disk->queue) > - blk_cleanup_queue(disk->queue); > - > + blk_cleanup_disk(disk); > ida_simple_remove(&bcache_device_idx, > first_minor_to_idx(disk->first_minor)); > - if (disk_added) > - put_disk(disk); The above 2 lines are added on purpose to prevent an refcount underflow. It is from commit 86da9f736740 ("bcache: fix refcount underflow in bcache_device_free()"). Maybe add a parameter to blk_cleanup_disk() or checking (disk->flags & GENHD_FL_UP) inside blk_cleanup_disk() ? Coly Li > } > > bioset_exit(&d->bio_split); > @@ -946,7 +942,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size, > BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER)) > goto err; > > - d->disk = alloc_disk(BCACHE_MINORS); > + d->disk = blk_alloc_disk(NUMA_NO_NODE); > if (!d->disk) > goto err; > > @@ -955,14 +951,11 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size, > > d->disk->major = bcache_major; > d->disk->first_minor = idx_to_first_minor(idx); > + d->disk->minors = BCACHE_MINORS; > d->disk->fops = ops; > d->disk->private_data = d; > > - q = blk_alloc_queue(NUMA_NO_NODE); > - if (!q) > - return -ENOMEM; > - > - d->disk->queue = q; > + q = d->disk->queue; > q->limits.max_hw_sectors = UINT_MAX; > q->limits.max_sectors = UINT_MAX; > q->limits.max_segment_size = UINT_MAX; > The rested looks fine to me. Thanks. Coly Li