Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: port block device access to file

Link: https://lore.kernel.org/r/20240123-vfs-bdev-file-v2-18-adbd023e19cc@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+11 -11
+10 -10
fs/bcachefs/super-io.c
··· 142 142 void bch2_free_super(struct bch_sb_handle *sb) 143 143 { 144 144 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); 147 147 kfree(sb->holder); 148 148 kfree(sb->sb_name); 149 149 ··· 704 704 if (!opt_get(*opts, nochanges)) 705 705 sb->mode |= BLK_OPEN_WRITE; 706 706 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 && 710 710 opt_get(*opts, read_only)) { 711 711 sb->mode &= ~BLK_OPEN_WRITE; 712 712 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)) 715 715 opt_set(*opts, nochanges, true); 716 716 } 717 717 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); 720 720 goto out; 721 721 } 722 - sb->bdev = sb->bdev_handle->bdev; 722 + sb->bdev = file_bdev(sb->s_bdev_file); 723 723 724 724 ret = bch2_sb_realloc(sb, 0); 725 725 if (ret) {
+1 -1
fs/bcachefs/super_types.h
··· 4 4 5 5 struct bch_sb_handle { 6 6 struct bch_sb *sb; 7 - struct bdev_handle *bdev_handle; 7 + struct file *s_bdev_file; 8 8 struct block_device *bdev; 9 9 char *sb_name; 10 10 struct bio *bio;