Skip to content

Commit 9f2f767

Browse files
committed
bcachefs: port block device access to file
Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 034f0cf commit 9f2f767

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

fs/bcachefs/super-io.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ void bch2_sb_field_delete(struct bch_sb_handle *sb,
142142
void bch2_free_super(struct bch_sb_handle *sb)
143143
{
144144
kfree(sb->bio);
145-
if (!IS_ERR_OR_NULL(sb->bdev_handle))
146-
bdev_release(sb->bdev_handle);
145+
if (!IS_ERR_OR_NULL(sb->s_bdev_file))
146+
fput(sb->s_bdev_file);
147147
kfree(sb->holder);
148148
kfree(sb->sb_name);
149149

@@ -704,22 +704,22 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts,
704704
if (!opt_get(*opts, nochanges))
705705
sb->mode |= BLK_OPEN_WRITE;
706706

707-
sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
708-
if (IS_ERR(sb->bdev_handle) &&
709-
PTR_ERR(sb->bdev_handle) == -EACCES &&
707+
sb->s_bdev_file = bdev_file_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
708+
if (IS_ERR(sb->s_bdev_file) &&
709+
PTR_ERR(sb->s_bdev_file) == -EACCES &&
710710
opt_get(*opts, read_only)) {
711711
sb->mode &= ~BLK_OPEN_WRITE;
712712

713-
sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
714-
if (!IS_ERR(sb->bdev_handle))
713+
sb->s_bdev_file = bdev_file_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
714+
if (!IS_ERR(sb->s_bdev_file))
715715
opt_set(*opts, nochanges, true);
716716
}
717717

718-
if (IS_ERR(sb->bdev_handle)) {
719-
ret = PTR_ERR(sb->bdev_handle);
718+
if (IS_ERR(sb->s_bdev_file)) {
719+
ret = PTR_ERR(sb->s_bdev_file);
720720
goto out;
721721
}
722-
sb->bdev = sb->bdev_handle->bdev;
722+
sb->bdev = file_bdev(sb->s_bdev_file);
723723

724724
ret = bch2_sb_realloc(sb, 0);
725725
if (ret) {

fs/bcachefs/super_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
struct bch_sb_handle {
66
struct bch_sb *sb;
7-
struct bdev_handle *bdev_handle;
7+
struct file *s_bdev_file;
88
struct block_device *bdev;
99
char *sb_name;
1010
struct bio *bio;

0 commit comments

Comments
 (0)