• Lukas Czerner's avatar
    ext4: implement support for get/set fs label · bbc605cd
    Lukas Czerner authored
    Implement support for FS_IOC_GETFSLABEL and FS_IOC_SETFSLABEL ioctls for
    online reading and setting of file system label.
    
    ext4_ioctl_getlabel() is simple, just get the label from the primary
    superblock. This might not be the first sb on the file system if
    'sb=' mount option is used.
    
    In ext4_ioctl_setlabel() we update what ext4 currently views as a
    primary superblock and then proceed to update backup superblocks. There
    are two caveats:
     - the primary superblock might not be the first superblock and so it
       might not be the one used by userspace tools if read directly
       off the disk.
     - because the primary superblock might not be the first superblock we
       potentialy have to update it as part of backup superblock update.
       However the first sb location is a bit more complicated than the rest
       so we have to account for that.
    
    The superblock modification is created generic enough so the
    infrastructure can be used for other potential superblock modification
    operations, such as chaning UUID.
    
    Tested with generic/492 with various configurations. I also checked the
    behavior with 'sb=' mount options, including very large file systems
    with and without sparse_super/sparse_super2.
    Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
    Link: https://lore.kernel.org/r/20211213135618.43303-1-lczerner@redhat.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
    bbc605cd
resize.c 61.3 KB