Message ID | 20240123-vfs-bdev-file-v2-18-adbd023e19cc@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Open block devices as files | expand |
On Tue 23-01-24 14:26:35, 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 > --- > fs/bcachefs/super-io.c | 20 ++++++++++---------- > fs/bcachefs/super_types.h | 2 +- > 2 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c > index d60c7d27a047..ce8cf2d91f84 100644 > --- a/fs/bcachefs/super-io.c > +++ b/fs/bcachefs/super-io.c > @@ -142,8 +142,8 @@ void bch2_sb_field_delete(struct bch_sb_handle *sb, > void bch2_free_super(struct bch_sb_handle *sb) > { > kfree(sb->bio); > - if (!IS_ERR_OR_NULL(sb->bdev_handle)) > - bdev_release(sb->bdev_handle); > + if (!IS_ERR_OR_NULL(sb->s_bdev_file)) > + fput(sb->s_bdev_file); > kfree(sb->holder); > kfree(sb->sb_name); > > @@ -704,22 +704,22 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts, > if (!opt_get(*opts, nochanges)) > sb->mode |= BLK_OPEN_WRITE; > > - sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); > - if (IS_ERR(sb->bdev_handle) && > - PTR_ERR(sb->bdev_handle) == -EACCES && > + sb->s_bdev_file = bdev_file_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); > + if (IS_ERR(sb->s_bdev_file) && > + PTR_ERR(sb->s_bdev_file) == -EACCES && > opt_get(*opts, read_only)) { > sb->mode &= ~BLK_OPEN_WRITE; > > - sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); > - if (!IS_ERR(sb->bdev_handle)) > + sb->s_bdev_file = bdev_file_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); > + if (!IS_ERR(sb->s_bdev_file)) > opt_set(*opts, nochanges, true); > } > > - if (IS_ERR(sb->bdev_handle)) { > - ret = PTR_ERR(sb->bdev_handle); > + if (IS_ERR(sb->s_bdev_file)) { > + ret = PTR_ERR(sb->s_bdev_file); > goto out; > } > - sb->bdev = sb->bdev_handle->bdev; > + sb->bdev = file_bdev(sb->s_bdev_file); > > ret = bch2_sb_realloc(sb, 0); > if (ret) { > diff --git a/fs/bcachefs/super_types.h b/fs/bcachefs/super_types.h > index 0e5a14fc8e7f..ec784d975f66 100644 > --- a/fs/bcachefs/super_types.h > +++ b/fs/bcachefs/super_types.h > @@ -4,7 +4,7 @@ > > struct bch_sb_handle { > struct bch_sb *sb; > - struct bdev_handle *bdev_handle; > + struct file *s_bdev_file; > struct block_device *bdev; > char *sb_name; > struct bio *bio; > > -- > 2.43.0 >
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index d60c7d27a047..ce8cf2d91f84 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -142,8 +142,8 @@ void bch2_sb_field_delete(struct bch_sb_handle *sb, void bch2_free_super(struct bch_sb_handle *sb) { kfree(sb->bio); - if (!IS_ERR_OR_NULL(sb->bdev_handle)) - bdev_release(sb->bdev_handle); + if (!IS_ERR_OR_NULL(sb->s_bdev_file)) + fput(sb->s_bdev_file); kfree(sb->holder); kfree(sb->sb_name); @@ -704,22 +704,22 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts, if (!opt_get(*opts, nochanges)) sb->mode |= BLK_OPEN_WRITE; - sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); - if (IS_ERR(sb->bdev_handle) && - PTR_ERR(sb->bdev_handle) == -EACCES && + sb->s_bdev_file = bdev_file_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); + if (IS_ERR(sb->s_bdev_file) && + PTR_ERR(sb->s_bdev_file) == -EACCES && opt_get(*opts, read_only)) { sb->mode &= ~BLK_OPEN_WRITE; - sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); - if (!IS_ERR(sb->bdev_handle)) + sb->s_bdev_file = bdev_file_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops); + if (!IS_ERR(sb->s_bdev_file)) opt_set(*opts, nochanges, true); } - if (IS_ERR(sb->bdev_handle)) { - ret = PTR_ERR(sb->bdev_handle); + if (IS_ERR(sb->s_bdev_file)) { + ret = PTR_ERR(sb->s_bdev_file); goto out; } - sb->bdev = sb->bdev_handle->bdev; + sb->bdev = file_bdev(sb->s_bdev_file); ret = bch2_sb_realloc(sb, 0); if (ret) { diff --git a/fs/bcachefs/super_types.h b/fs/bcachefs/super_types.h index 0e5a14fc8e7f..ec784d975f66 100644 --- a/fs/bcachefs/super_types.h +++ b/fs/bcachefs/super_types.h @@ -4,7 +4,7 @@ struct bch_sb_handle { struct bch_sb *sb; - struct bdev_handle *bdev_handle; + struct file *s_bdev_file; struct block_device *bdev; char *sb_name; struct bio *bio;
Signed-off-by: Christian Brauner <brauner@kernel.org> --- fs/bcachefs/super-io.c | 20 ++++++++++---------- fs/bcachefs/super_types.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-)