Message ID | 20231218044933.706042-6-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/5] btrfs: always open the device read-only in btrfs_scan_one_device | expand |
On 18.12.23 05:50, Christoph Hellwig wrote: > The file system type is not a very useful holder as it doesn't allow us > to go back to the actual file system instance. Pass the super_block > instead which is useful when passed back to the file system driver. > > This matches what is done for all other block device based file systems. > Small Nit: ext4, f2fs and xfs use the super_block, erofs uses 'sb->s_type' as well here. Reiser uses the journal and so does jfs. So while these two might not be the best examples in the world, all other is an exaggeration. I'd just kill the last sentence.
On Mon, Dec 18, 2023 at 12:14:35PM +0000, Johannes Thumshirn wrote: > Small Nit: > ext4, f2fs and xfs use the super_block, erofs uses 'sb->s_type' as well > here. Reiser uses the journal and so does jfs. So while these two might > not be the best examples in the world, all other is an exaggeration. As of 6.8-rc every file system but btrfs should be using the superblock.
Hi Christoph, On 2023/12/18 23:02, Christoph Hellwig wrote: > On Mon, Dec 18, 2023 at 12:14:35PM +0000, Johannes Thumshirn wrote: >> Small Nit: >> ext4, f2fs and xfs use the super_block, erofs uses 'sb->s_type' as well >> here. Reiser uses the journal and so does jfs. So while these two might >> not be the best examples in the world, all other is an exaggeration. > > As of 6.8-rc every file system but btrfs should be using the superblock. Just saw this by chance. Currently EROFS uses 'sb->s_type' to refer external binary source devices (blobs) across different mounts. Since these devices are treated readonly so such external sources can be shared between mounts as some shared data layer. Thanks, Gao Xiang
On Tue, Dec 19, 2023 at 01:33:54PM +0800, Gao Xiang wrote: >>> ext4, f2fs and xfs use the super_block, erofs uses 'sb->s_type' as well >>> here. Reiser uses the journal and so does jfs. So while these two might >>> not be the best examples in the world, all other is an exaggeration. >> >> As of 6.8-rc every file system but btrfs should be using the superblock. > > Just saw this by chance. Currently EROFS uses 'sb->s_type' to refer > external binary source devices (blobs) across different mounts. Since > these devices are treated readonly so such external sources can be > shared between mounts as some shared data layer. Makes sense for that somewhat unusual use case. Note that this means you can't really use blk_holder_ops based notifications from the block driver, but for read-only devices that's not all that important anyway.
On 2023/12/19 20:19, Christoph Hellwig wrote: > On Tue, Dec 19, 2023 at 01:33:54PM +0800, Gao Xiang wrote: >>>> ext4, f2fs and xfs use the super_block, erofs uses 'sb->s_type' as well >>>> here. Reiser uses the journal and so does jfs. So while these two might >>>> not be the best examples in the world, all other is an exaggeration. >>> >>> As of 6.8-rc every file system but btrfs should be using the superblock. >> >> Just saw this by chance. Currently EROFS uses 'sb->s_type' to refer >> external binary source devices (blobs) across different mounts. Since >> these devices are treated readonly so such external sources can be >> shared between mounts as some shared data layer. > > Makes sense for that somewhat unusual use case. Note that this means > you can't really use blk_holder_ops based notifications from the block > driver, but for read-only devices that's not all that important anyway. Yeah, anyway even if notifications is used in the future, I will think more about this later. Thanks, Gao Xiang
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 62a933b47e03c3..2dfa2274b19387 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1831,7 +1831,7 @@ static int btrfs_get_tree_super(struct fs_context *fc) struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; mutex_lock(&uuid_mutex); - ret = btrfs_open_devices(fs_devices, mode, &btrfs_fs_type); + ret = btrfs_open_devices(fs_devices, mode, sb); mutex_unlock(&uuid_mutex); if (ret) goto error_deactivate; @@ -1844,7 +1844,7 @@ static int btrfs_get_tree_super(struct fs_context *fc) snprintf(sb->s_id, sizeof(sb->s_id), "%pg", fs_devices->latest_dev->bdev); shrinker_debugfs_rename(sb->s_shrink, "sb-btrfs:%s", sb->s_id); - btrfs_sb(sb)->bdev_holder = &btrfs_fs_type; + btrfs_sb(sb)->bdev_holder = sb; ret = btrfs_fill_super(sb, fs_devices, NULL); if (ret) goto error_deactivate;
The file system type is not a very useful holder as it doesn't allow us to go back to the actual file system instance. Pass the super_block instead which is useful when passed back to the file system driver. This matches what is done for all other block device based file systems. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/btrfs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)