• Anand Jain's avatar
    btrfs: use proper endianness accessors for super_copy · 3c181c12
    Anand Jain authored
    The fs_info::super_copy is a byte copy of the on-disk structure and all
    members must use the accessor macros/functions to obtain the right
    value.  This was missing in update_super_roots and in sysfs readers.
    
    Moving between opposite endianness hosts will report bogus numbers in
    sysfs, and mount may fail as the root will not be restored correctly. If
    the filesystem is always used on a same endian host, this will not be a
    problem.
    
    Fix this by using the btrfs_set_super...() functions to set
    fs_info::super_copy values, and for the sysfs, use the cached
    fs_info::nodesize/sectorsize values.
    
    CC: stable@vger.kernel.org
    Fixes: df93589a ("btrfs: export more from FS_INFO to sysfs")
    Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
    Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    [ update changelog ]
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    3c181c12
sysfs.c 23.6 KB