• Jan Kara's avatar
    ext4: fixup free space calculations when expanding inodes · e3014d14
    Jan Kara authored
    Conditions checking whether there is enough free space in an xattr block
    and when xattr is large enough to make enough space in the inode forgot
    to account for the fact that inode need not be completely filled up with
    xattrs. Thus we could move unnecessarily many xattrs out of inode or
    even falsely claim there is not enough space to expand the inode. We
    also forgot to update the amount of free space in xattr block when moving
    more xattrs and thus could decide to move too big xattr resulting in
    unexpected failure.
    
    Fix these problems by properly updating free space in the inode and
    xattr block as we move xattrs. To simplify the math, avoid shifting
    xattrs after removing each one xattr and instead just shift xattrs only
    once there is enough free space in the inode.
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
    e3014d14
xattr.c 48.1 KB