diff options
author | Jan Kara <jack@suse.cz> | 2023-09-27 11:34:25 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2023-10-28 13:29:19 +0200 |
commit | f4a48bc36cdfae7c603e8e3f2a51e2a283f3f365 (patch) | |
tree | cd0ea5f3e0aff2143ad21c8db7ec01456659c103 /fs/super.c | |
parent | 4c6bca43c547fe9bc1d7d1519b1d6430fee2cae2 (diff) | |
download | linux-f4a48bc36cdfae7c603e8e3f2a51e2a283f3f365.tar.gz linux-f4a48bc36cdfae7c603e8e3f2a51e2a283f3f365.tar.bz2 linux-f4a48bc36cdfae7c603e8e3f2a51e2a283f3f365.zip |
fs: Convert to bdev_open_by_dev()
Convert mount code to use bdev_open_by_dev() and propagate the handle
around to bdev_release().
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230927093442.25915-19-jack@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/super.c b/fs/super.c index 2d762ce67f6e..26b96191e9b3 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1479,14 +1479,16 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, struct fs_context *fc) { blk_mode_t mode = sb_open_mode(sb_flags); + struct bdev_handle *bdev_handle; struct block_device *bdev; - bdev = blkdev_get_by_dev(sb->s_dev, mode, sb, &fs_holder_ops); - if (IS_ERR(bdev)) { + bdev_handle = bdev_open_by_dev(sb->s_dev, mode, sb, &fs_holder_ops); + if (IS_ERR(bdev_handle)) { if (fc) errorf(fc, "%s: Can't open blockdev", fc->source); - return PTR_ERR(bdev); + return PTR_ERR(bdev_handle); } + bdev = bdev_handle->bdev; /* * This really should be in blkdev_get_by_dev, but right now can't due @@ -1494,7 +1496,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, * writable from userspace even for a read-only block device. */ if ((mode & BLK_OPEN_WRITE) && bdev_read_only(bdev)) { - blkdev_put(bdev, sb); + bdev_release(bdev_handle); return -EACCES; } @@ -1510,10 +1512,11 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, mutex_unlock(&bdev->bd_fsfreeze_mutex); if (fc) warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev); - blkdev_put(bdev, sb); + bdev_release(bdev_handle); return -EBUSY; } spin_lock(&sb_lock); + sb->s_bdev_handle = bdev_handle; sb->s_bdev = bdev; sb->s_bdi = bdi_get(bdev->bd_disk->bdi); if (bdev_stable_writes(bdev)) @@ -1646,7 +1649,7 @@ void kill_block_super(struct super_block *sb) generic_shutdown_super(sb); if (bdev) { sync_blockdev(bdev); - blkdev_put(bdev, sb); + bdev_release(sb->s_bdev_handle); } } |