Message ID | 67a25027c7d05f33c71015b60fcfb75d89ac0ab9.1734503454.git.wqu@suse.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs: sysfs: fix direct super block member read | expand |
On Wed, Dec 18, 2024 at 05:00:56PM +1030, Qu Wenruo wrote: > The following sysfs entries are reading super block member directly, > which can have a different endian and cause wrong values: > > - sys/fs/btrfs/<uuid>/nodesize > - sys/fs/btrfs/<uuid>/sectorsize > - sys/fs/btrfs/<uuid>/clone_alignment > > Thankfully those values (nodesize and sectorsize) are always aligned > inside the btrfs_super_block, so it won't trigger unaligned read errors, > just endian problems. > > Fix them by using the native cached members instead. > > Fixes: df93589a1737 ("btrfs: export more from FS_INFO to sysfs") > Signed-off-by: Qu Wenruo <wqu@suse.com> > --- > fs/btrfs/sysfs.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) Looks good to me. Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On Wed, Dec 18, 2024 at 05:00:56PM +1030, Qu Wenruo wrote: > The following sysfs entries are reading super block member directly, > which can have a different endian and cause wrong values: > > - sys/fs/btrfs/<uuid>/nodesize > - sys/fs/btrfs/<uuid>/sectorsize > - sys/fs/btrfs/<uuid>/clone_alignment > > Thankfully those values (nodesize and sectorsize) are always aligned > inside the btrfs_super_block, so it won't trigger unaligned read errors, > just endian problems. > > Fix them by using the native cached members instead. > > Fixes: df93589a1737 ("btrfs: export more from FS_INFO to sysfs") > Signed-off-by: Qu Wenruo <wqu@suse.com> That's an old one. Reviewed-by: David Sterba <dsterba@suse.com>
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index fdcbf650ac31..7f09b6c9cc2d 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1118,7 +1118,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj, { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return sysfs_emit(buf, "%u\n", fs_info->super_copy->nodesize); + return sysfs_emit(buf, "%u\n", fs_info->nodesize); } BTRFS_ATTR(, nodesize, btrfs_nodesize_show); @@ -1128,7 +1128,7 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj, { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize); + return sysfs_emit(buf, "%u\n", fs_info->sectorsize); } BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show); @@ -1180,7 +1180,7 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj, { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize); + return sysfs_emit(buf, "%u\n", fs_info->sectorsize); } BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);
The following sysfs entries are reading super block member directly, which can have a different endian and cause wrong values: - sys/fs/btrfs/<uuid>/nodesize - sys/fs/btrfs/<uuid>/sectorsize - sys/fs/btrfs/<uuid>/clone_alignment Thankfully those values (nodesize and sectorsize) are always aligned inside the btrfs_super_block, so it won't trigger unaligned read errors, just endian problems. Fix them by using the native cached members instead. Fixes: df93589a1737 ("btrfs: export more from FS_INFO to sysfs") Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)