From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>,
Jens Axboe <axboe@kernel.dk>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v2 13/34] bcache: port block device access to files
Date: Thu, 1 Feb 2024 10:45:49 +0100 [thread overview]
Message-ID: <20240201094549.tw3dskvc336bim5d@quack3> (raw)
In-Reply-To: <20240123-vfs-bdev-file-v2-13-adbd023e19cc@kernel.org>
On Tue 23-01-24 14:26:30, Christian Brauner wrote:
> Signed-off-by: Christian Brauner <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> drivers/md/bcache/bcache.h | 4 +--
> drivers/md/bcache/super.c | 74 +++++++++++++++++++++++-----------------------
> 2 files changed, 39 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
> index 6ae2329052c9..4e6afa89921f 100644
> --- a/drivers/md/bcache/bcache.h
> +++ b/drivers/md/bcache/bcache.h
> @@ -300,7 +300,7 @@ struct cached_dev {
> struct list_head list;
> struct bcache_device disk;
> struct block_device *bdev;
> - struct bdev_handle *bdev_handle;
> + struct file *bdev_file;
>
> struct cache_sb sb;
> struct cache_sb_disk *sb_disk;
> @@ -423,7 +423,7 @@ struct cache {
>
> struct kobject kobj;
> struct block_device *bdev;
> - struct bdev_handle *bdev_handle;
> + struct file *bdev_file;
>
> struct task_struct *alloc_thread;
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index dc3f50f69714..d00b3abab133 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1369,8 +1369,8 @@ static CLOSURE_CALLBACK(cached_dev_free)
> if (dc->sb_disk)
> put_page(virt_to_page(dc->sb_disk));
>
> - if (dc->bdev_handle)
> - bdev_release(dc->bdev_handle);
> + if (dc->bdev_file)
> + fput(dc->bdev_file);
>
> wake_up(&unregister_wait);
>
> @@ -1445,7 +1445,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
> /* Cached device - bcache superblock */
>
> static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> - struct bdev_handle *bdev_handle,
> + struct file *bdev_file,
> struct cached_dev *dc)
> {
> const char *err = "cannot allocate memory";
> @@ -1453,8 +1453,8 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> int ret = -ENOMEM;
>
> memcpy(&dc->sb, sb, sizeof(struct cache_sb));
> - dc->bdev_handle = bdev_handle;
> - dc->bdev = bdev_handle->bdev;
> + dc->bdev_file = bdev_file;
> + dc->bdev = file_bdev(bdev_file);
> dc->sb_disk = sb_disk;
>
> if (cached_dev_init(dc, sb->block_size << 9))
> @@ -2218,8 +2218,8 @@ void bch_cache_release(struct kobject *kobj)
> if (ca->sb_disk)
> put_page(virt_to_page(ca->sb_disk));
>
> - if (ca->bdev_handle)
> - bdev_release(ca->bdev_handle);
> + if (ca->bdev_file)
> + fput(ca->bdev_file);
>
> kfree(ca);
> module_put(THIS_MODULE);
> @@ -2339,18 +2339,18 @@ static int cache_alloc(struct cache *ca)
> }
>
> static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> - struct bdev_handle *bdev_handle,
> + struct file *bdev_file,
> struct cache *ca)
> {
> const char *err = NULL; /* must be set for any error case */
> int ret = 0;
>
> memcpy(&ca->sb, sb, sizeof(struct cache_sb));
> - ca->bdev_handle = bdev_handle;
> - ca->bdev = bdev_handle->bdev;
> + ca->bdev_file = bdev_file;
> + ca->bdev = file_bdev(bdev_file);
> ca->sb_disk = sb_disk;
>
> - if (bdev_max_discard_sectors((bdev_handle->bdev)))
> + if (bdev_max_discard_sectors(file_bdev(bdev_file)))
> ca->discard = CACHE_DISCARD(&ca->sb);
>
> ret = cache_alloc(ca);
> @@ -2361,20 +2361,20 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> err = "cache_alloc(): cache device is too small";
> else
> err = "cache_alloc(): unknown error";
> - pr_notice("error %pg: %s\n", bdev_handle->bdev, err);
> + pr_notice("error %pg: %s\n", file_bdev(bdev_file), err);
> /*
> * If we failed here, it means ca->kobj is not initialized yet,
> * kobject_put() won't be called and there is no chance to
> - * call bdev_release() to bdev in bch_cache_release(). So
> - * we explicitly call bdev_release() here.
> + * call fput() to bdev in bch_cache_release(). So
> + * we explicitly call fput() on the block device here.
> */
> - bdev_release(bdev_handle);
> + fput(bdev_file);
> return ret;
> }
>
> - if (kobject_add(&ca->kobj, bdev_kobj(bdev_handle->bdev), "bcache")) {
> + if (kobject_add(&ca->kobj, bdev_kobj(file_bdev(bdev_file)), "bcache")) {
> pr_notice("error %pg: error calling kobject_add\n",
> - bdev_handle->bdev);
> + file_bdev(bdev_file));
> ret = -ENOMEM;
> goto out;
> }
> @@ -2388,7 +2388,7 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
> goto out;
> }
>
> - pr_info("registered cache device %pg\n", ca->bdev_handle->bdev);
> + pr_info("registered cache device %pg\n", file_bdev(ca->bdev_file));
>
> out:
> kobject_put(&ca->kobj);
> @@ -2446,7 +2446,7 @@ struct async_reg_args {
> char *path;
> struct cache_sb *sb;
> struct cache_sb_disk *sb_disk;
> - struct bdev_handle *bdev_handle;
> + struct file *bdev_file;
> void *holder;
> };
>
> @@ -2457,7 +2457,7 @@ static void register_bdev_worker(struct work_struct *work)
> container_of(work, struct async_reg_args, reg_work.work);
>
> mutex_lock(&bch_register_lock);
> - if (register_bdev(args->sb, args->sb_disk, args->bdev_handle,
> + if (register_bdev(args->sb, args->sb_disk, args->bdev_file,
> args->holder) < 0)
> fail = true;
> mutex_unlock(&bch_register_lock);
> @@ -2478,7 +2478,7 @@ static void register_cache_worker(struct work_struct *work)
> container_of(work, struct async_reg_args, reg_work.work);
>
> /* blkdev_put() will be called in bch_cache_release() */
> - if (register_cache(args->sb, args->sb_disk, args->bdev_handle,
> + if (register_cache(args->sb, args->sb_disk, args->bdev_file,
> args->holder))
> fail = true;
>
> @@ -2516,7 +2516,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> char *path = NULL;
> struct cache_sb *sb;
> struct cache_sb_disk *sb_disk;
> - struct bdev_handle *bdev_handle, *bdev_handle2;
> + struct file *bdev_file, *bdev_file2;
> void *holder = NULL;
> ssize_t ret;
> bool async_registration = false;
> @@ -2549,15 +2549,15 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>
> ret = -EINVAL;
> err = "failed to open device";
> - bdev_handle = bdev_open_by_path(strim(path), BLK_OPEN_READ, NULL, NULL);
> - if (IS_ERR(bdev_handle))
> + bdev_file = bdev_file_open_by_path(strim(path), BLK_OPEN_READ, NULL, NULL);
> + if (IS_ERR(bdev_file))
> goto out_free_sb;
>
> err = "failed to set blocksize";
> - if (set_blocksize(bdev_handle->bdev, 4096))
> + if (set_blocksize(file_bdev(bdev_file), 4096))
> goto out_blkdev_put;
>
> - err = read_super(sb, bdev_handle->bdev, &sb_disk);
> + err = read_super(sb, file_bdev(bdev_file), &sb_disk);
> if (err)
> goto out_blkdev_put;
>
> @@ -2569,13 +2569,13 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> }
>
> /* Now reopen in exclusive mode with proper holder */
> - bdev_handle2 = bdev_open_by_dev(bdev_handle->bdev->bd_dev,
> + bdev_file2 = bdev_file_open_by_dev(file_bdev(bdev_file)->bd_dev,
> BLK_OPEN_READ | BLK_OPEN_WRITE, holder, NULL);
> - bdev_release(bdev_handle);
> - bdev_handle = bdev_handle2;
> - if (IS_ERR(bdev_handle)) {
> - ret = PTR_ERR(bdev_handle);
> - bdev_handle = NULL;
> + fput(bdev_file);
> + bdev_file = bdev_file2;
> + if (IS_ERR(bdev_file)) {
> + ret = PTR_ERR(bdev_file);
> + bdev_file = NULL;
> if (ret == -EBUSY) {
> dev_t dev;
>
> @@ -2610,7 +2610,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> args->path = path;
> args->sb = sb;
> args->sb_disk = sb_disk;
> - args->bdev_handle = bdev_handle;
> + args->bdev_file = bdev_file;
> args->holder = holder;
> register_device_async(args);
> /* No wait and returns to user space */
> @@ -2619,14 +2619,14 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>
> if (SB_IS_BDEV(sb)) {
> mutex_lock(&bch_register_lock);
> - ret = register_bdev(sb, sb_disk, bdev_handle, holder);
> + ret = register_bdev(sb, sb_disk, bdev_file, holder);
> mutex_unlock(&bch_register_lock);
> /* blkdev_put() will be called in cached_dev_free() */
> if (ret < 0)
> goto out_free_sb;
> } else {
> /* blkdev_put() will be called in bch_cache_release() */
> - ret = register_cache(sb, sb_disk, bdev_handle, holder);
> + ret = register_cache(sb, sb_disk, bdev_file, holder);
> if (ret)
> goto out_free_sb;
> }
> @@ -2642,8 +2642,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> out_put_sb_page:
> put_page(virt_to_page(sb_disk));
> out_blkdev_put:
> - if (bdev_handle)
> - bdev_release(bdev_handle);
> + if (bdev_file)
> + fput(bdev_file);
> out_free_sb:
> kfree(sb);
> out_free_path:
>
> --
> 2.43.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-02-01 9:45 UTC|newest]
Thread overview: 146+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 13:26 [PATCH v2 00/34] Open block devices as files Christian Brauner
2024-01-23 13:26 ` [PATCH v2 01/34] bdev: open block device " Christian Brauner
2024-01-29 16:02 ` Christoph Hellwig
2024-02-01 17:08 ` Christian Brauner
2024-02-02 6:43 ` Christoph Hellwig
2024-02-02 11:46 ` Christian Brauner
2024-02-09 11:39 ` Christian Brauner
2024-03-13 2:32 ` Christoph Hellwig
2024-03-14 11:10 ` Christian Brauner
2024-03-14 14:47 ` Christian Brauner
2024-03-14 16:45 ` Christian Brauner
2024-03-14 16:58 ` Jan Kara
2024-03-15 13:23 ` [PATCH] fs,block: get holder during claim Christian Brauner
2024-03-15 14:28 ` Jan Kara
2024-03-19 16:24 ` remove holder ops Christian Brauner
2024-03-19 17:03 ` Matthew Wilcox
2024-03-19 23:13 ` Christoph Hellwig
2024-03-17 20:53 ` [PATCH] fs,block: get holder during claim Christoph Hellwig
2024-03-18 8:33 ` Christian Brauner
2024-03-18 9:10 ` Yi Zhang
2024-01-23 13:26 ` [PATCH v2 02/34] block/ioctl: port blkdev_bszset() to file Christian Brauner
2024-01-29 16:14 ` Christoph Hellwig
2024-01-31 18:10 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 03/34] block/genhd: port disk_scan_partitions() " Christian Brauner
2024-01-29 16:14 ` Christoph Hellwig
2024-01-31 18:13 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 04/34] md: port block device access " Christian Brauner
2024-01-29 16:14 ` Christoph Hellwig
2024-01-31 18:15 ` Jan Kara
2024-04-15 9:26 ` Ming Lei
2024-04-15 12:35 ` Christian Brauner
2024-04-15 13:56 ` Mike Snitzer
2024-04-15 14:35 ` Ming Lei
2024-04-15 14:53 ` Christian Brauner
2024-04-15 15:11 ` Ming Lei
2024-04-15 15:53 ` Mike Snitzer
2024-04-15 16:22 ` Jan Kara
2024-04-16 0:27 ` Ming Lei
2024-01-23 13:26 ` [PATCH v2 05/34] swap: port block device usage " Christian Brauner
2024-01-29 16:15 ` Christoph Hellwig
2024-01-31 18:16 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 06/34] power: port block device access " Christian Brauner
2024-01-29 16:15 ` Christoph Hellwig
2024-01-31 18:17 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 07/34] xfs: port block device access to files Christian Brauner
2024-01-29 16:17 ` Christoph Hellwig
2024-02-01 14:33 ` Christian Brauner
2024-01-31 18:19 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 08/34] drbd: port block device access to file Christian Brauner
2024-01-31 18:22 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 09/34] pktcdvd: " Christian Brauner
2024-01-31 18:26 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 10/34] rnbd: " Christian Brauner
2024-01-31 18:28 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 11/34] xen: " Christian Brauner
2024-01-31 18:31 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 12/34] zram: " Christian Brauner
2024-01-31 18:32 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 13/34] bcache: port block device access to files Christian Brauner
2024-02-01 9:45 ` Jan Kara [this message]
2024-01-23 13:26 ` [PATCH v2 14/34] block2mtd: port " Christian Brauner
2024-02-01 9:47 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 15/34] nvme: port block device access to file Christian Brauner
2024-02-01 9:48 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 16/34] s390: " Christian Brauner
2024-02-01 10:11 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 17/34] target: " Christian Brauner
2024-02-01 10:12 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 18/34] bcachefs: " Christian Brauner
2024-02-01 10:13 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 19/34] btrfs: port " Christian Brauner
2024-02-01 10:16 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 20/34] erofs: " Christian Brauner
2024-02-01 10:16 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 21/34] ext4: port block " Christian Brauner
2024-02-01 10:18 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 22/34] f2fs: port block device access to files Christian Brauner
2024-02-01 10:19 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 23/34] jfs: port block device access to file Christian Brauner
2024-02-01 10:19 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 24/34] nfs: port block device access to files Christian Brauner
2024-02-01 10:22 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 25/34] ocfs2: port block device access to file Christian Brauner
2024-02-01 10:22 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 26/34] reiserfs: " Christian Brauner
2024-02-01 10:24 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 27/34] bdev: remove bdev_open_by_path() Christian Brauner
2024-01-29 16:17 ` Christoph Hellwig
2024-02-01 10:24 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 28/34] bdev: make bdev_release() private to block layer Christian Brauner
2024-01-29 16:19 ` Christoph Hellwig
2024-02-01 10:26 ` Jan Kara
2024-02-01 14:48 ` Christian Brauner
2024-01-23 13:26 ` [PATCH v2 29/34] bdev: make struct bdev_handle private to the " Christian Brauner
2024-01-29 16:22 ` Christoph Hellwig
2024-02-01 14:50 ` Christian Brauner
2024-02-01 10:54 ` Jan Kara
2024-02-01 15:07 ` Christian Brauner
2024-02-01 17:42 ` Jan Kara
2024-02-01 11:23 ` Jan Kara
2024-02-01 14:52 ` Christian Brauner
2024-01-23 13:26 ` [PATCH v2 30/34] bdev: remove bdev pointer from struct bdev_handle Christian Brauner
2024-01-29 16:22 ` Christoph Hellwig
2024-02-01 10:57 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 31/34] block: use file->f_op to indicate restricted writes Christian Brauner
2024-01-29 16:49 ` Christoph Hellwig
2024-01-29 17:09 ` [PATCH v2 31/34] block: use file->f_op to indicate restricted writes^[ Christian Brauner
2024-01-30 8:32 ` Christoph Hellwig
2024-01-30 9:11 ` Christian Brauner
2024-02-01 11:08 ` [PATCH v2 31/34] block: use file->f_op to indicate restricted writes Jan Kara
2024-02-01 16:16 ` Christian Brauner
2024-02-01 17:36 ` Jan Kara
2024-02-02 11:45 ` Christian Brauner
2024-02-02 11:51 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 32/34] block: remove bdev_handle completely Christian Brauner
2024-01-29 16:50 ` Christoph Hellwig
2024-02-01 11:20 ` Jan Kara
2024-02-01 16:18 ` Christian Brauner
2024-01-23 13:26 ` [PATCH v2 33/34] block: expose bdev_file_inode() Christian Brauner
2024-02-01 10:09 ` Jan Kara
2024-01-23 13:26 ` [PATCH v2 34/34] ext4: rely on sb->f_bdev only Christian Brauner
2024-02-01 11:34 ` Jan Kara
2024-02-01 13:40 ` Christian Brauner
2024-01-29 6:17 ` [PATCH v2 00/34] Open block devices as files Christoph Hellwig
2024-01-29 10:17 ` Christian Brauner
2024-01-29 10:56 ` [PATCH RFC 0/2] fs & block: remove bd_inode Christian Brauner
2024-01-29 10:56 ` [PATCH RFC 1/2] fs & block: remove bdev->bd_inode Christian Brauner
2024-02-20 11:57 ` Yu Kuai
2024-02-21 7:36 ` Christian Brauner
2024-01-29 10:56 ` [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers Christian Brauner
2024-01-29 14:37 ` Christoph Hellwig
2024-01-29 15:29 ` Christian Brauner
2024-01-29 15:36 ` Christoph Hellwig
2024-02-19 13:34 ` Yu Kuai
2024-02-19 13:42 ` Yu Kuai
2024-02-05 11:55 ` [PATCH v2 00/34] Open block devices as files Christian Brauner
2024-02-05 14:19 ` Jan Kara
2024-02-06 13:39 ` Christian Brauner
2024-02-06 13:58 ` Jan Kara
2024-02-06 16:10 ` Christian Brauner
2024-03-21 22:17 ` Matthew Wilcox
2024-03-22 3:38 ` Kent Overstreet
2024-03-22 13:56 ` Christian Brauner
2024-03-22 12:31 ` Christian Brauner
2024-03-22 12:40 ` Matthew Wilcox
2024-03-22 13:53 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201094549.tw3dskvc336bim5d@quack3 \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox