btrfs: sysfs: fix direct super block member reads

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")
CC: stable@vger.kernel.org
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Qu Wenruo and committed by
David Sterba
fca432e7 f2363e6f

+3 -3
+3 -3
fs/btrfs/sysfs.c
··· 1118 { 1119 struct btrfs_fs_info *fs_info = to_fs_info(kobj); 1120 1121 - return sysfs_emit(buf, "%u\n", fs_info->super_copy->nodesize); 1122 } 1123 1124 BTRFS_ATTR(, nodesize, btrfs_nodesize_show); ··· 1128 { 1129 struct btrfs_fs_info *fs_info = to_fs_info(kobj); 1130 1131 - return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize); 1132 } 1133 1134 BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show); ··· 1180 { 1181 struct btrfs_fs_info *fs_info = to_fs_info(kobj); 1182 1183 - return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize); 1184 } 1185 1186 BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);
··· 1118 { 1119 struct btrfs_fs_info *fs_info = to_fs_info(kobj); 1120 1121 + return sysfs_emit(buf, "%u\n", fs_info->nodesize); 1122 } 1123 1124 BTRFS_ATTR(, nodesize, btrfs_nodesize_show); ··· 1128 { 1129 struct btrfs_fs_info *fs_info = to_fs_info(kobj); 1130 1131 + return sysfs_emit(buf, "%u\n", fs_info->sectorsize); 1132 } 1133 1134 BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show); ··· 1180 { 1181 struct btrfs_fs_info *fs_info = to_fs_info(kobj); 1182 1183 + return sysfs_emit(buf, "%u\n", fs_info->sectorsize); 1184 } 1185 1186 BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);