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.3 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 47092C56201 for ; Tue, 24 Nov 2020 13:38:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B1EB220872 for ; Tue, 24 Nov 2020 13:38:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1EB220872 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 25CED6B0136; Tue, 24 Nov 2020 08:38:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 20D456B0138; Tue, 24 Nov 2020 08:38:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FD7B6B0139; Tue, 24 Nov 2020 08:38:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id ECCAF6B0136 for ; Tue, 24 Nov 2020 08:38:39 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B5F941EE6 for ; Tue, 24 Nov 2020 13:38:39 +0000 (UTC) X-FDA: 77519416758.24.flame30_020fca42736e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 967861A4A7 for ; Tue, 24 Nov 2020 13:38:39 +0000 (UTC) X-HE-Tag: flame30_020fca42736e X-Filterd-Recvd-Size: 5373 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 13:38:38 +0000 (UTC) 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 E8E43AC2D; Tue, 24 Nov 2020 13:38:37 +0000 (UTC) Subject: Re: [PATCH 23/45] block: remove i_bdev To: Christoph Hellwig , Jens Axboe Cc: Tejun Heo , Josef Bacik , Konrad Rzeszutek Wilk , Mike Snitzer , Greg Kroah-Hartman , Jan Kara , Johannes Thumshirn , dm-devel@redhat.com, Richard Weinberger , Jan Kara , linux-block@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20201124132751.3747337-1-hch@lst.de> <20201124132751.3747337-24-hch@lst.de> From: Coly Li Message-ID: Date: Tue, 24 Nov 2020 21:38:27 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20201124132751.3747337-24-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 11/24/20 9:27 PM, Christoph Hellwig wrote: > Switch the block device lookup interfaces to directly work with a dev_t > so that struct block_device references are only acquired by the > blkdev_get variants (and the blk-cgroup special case). This means that > we not don't need an extra reference in the inode and can generally > simplify handling of struct block_device to keep the lookups contained > in the core block layer code. > > Signed-off-by: Christoph Hellwig For the bcache part, Acked-by: Coly Li Thanks. Coly Li > --- > block/ioctl.c | 3 +- > drivers/block/loop.c | 8 +- > drivers/md/bcache/super.c | 20 +- > drivers/md/dm-table.c | 9 +- > drivers/mtd/mtdsuper.c | 17 +- > drivers/target/target_core_file.c | 6 +- > drivers/usb/gadget/function/storage_common.c | 8 +- > fs/block_dev.c | 195 +++++-------------- > fs/btrfs/volumes.c | 13 +- > fs/inode.c | 3 - > fs/internal.h | 7 +- > fs/io_uring.c | 10 +- > fs/pipe.c | 5 +- > fs/quota/quota.c | 19 +- > fs/statfs.c | 2 +- > fs/super.c | 37 ++-- > include/linux/blkdev.h | 2 +- > include/linux/fs.h | 1 - > 18 files changed, 114 insertions(+), 251 deletions(-) > [snipped] > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index a6a5e21e4fd136..c55d3c58a7ef55 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -2380,38 +2380,38 @@ kobj_attribute_write(register, register_bcache); > kobj_attribute_write(register_quiet, register_bcache); > kobj_attribute_write(pendings_cleanup, bch_pending_bdevs_cleanup); > > -static bool bch_is_open_backing(struct block_device *bdev) > +static bool bch_is_open_backing(dev_t dev) > { > struct cache_set *c, *tc; > struct cached_dev *dc, *t; > > list_for_each_entry_safe(c, tc, &bch_cache_sets, list) > list_for_each_entry_safe(dc, t, &c->cached_devs, list) > - if (dc->bdev == bdev) > + if (dc->bdev->bd_dev == dev) > return true; > list_for_each_entry_safe(dc, t, &uncached_devices, list) > - if (dc->bdev == bdev) > + if (dc->bdev->bd_dev == dev) > return true; > return false; > } > > -static bool bch_is_open_cache(struct block_device *bdev) > +static bool bch_is_open_cache(dev_t dev) > { > struct cache_set *c, *tc; > > list_for_each_entry_safe(c, tc, &bch_cache_sets, list) { > struct cache *ca = c->cache; > > - if (ca->bdev == bdev) > + if (ca->bdev->bd_dev == dev) > return true; > } > > return false; > } > > -static bool bch_is_open(struct block_device *bdev) > +static bool bch_is_open(dev_t dev) > { > - return bch_is_open_cache(bdev) || bch_is_open_backing(bdev); > + return bch_is_open_cache(dev) || bch_is_open_backing(dev); > } > > struct async_reg_args { > @@ -2535,9 +2535,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, > sb); > if (IS_ERR(bdev)) { > if (bdev == ERR_PTR(-EBUSY)) { > - bdev = lookup_bdev(strim(path)); > + dev_t dev; > + > mutex_lock(&bch_register_lock); > - if (!IS_ERR(bdev) && bch_is_open(bdev)) > + if (lookup_bdev(strim(path), &dev) == 0 && > + bch_is_open(dev)) > err = "device already registered"; > else > err = "device busy"; [snipped]