• Brian Foster's avatar
    xfs: use larger in-core attr firstused field and detect overflow · e87021a2
    Brian Foster authored
    The on-disk xfs_attr3_leaf_hdr structure firstused field is 16-bit and
    subject to overflow when fs block size is 64k. The field is typically
    initialized to block size when an attr leaf block is initialized. This
    problem is demonstrated by assert failures when running xfstests
    generic/117 on an fs with 64k blocks.
    
    To support the existing attr leaf block algorithms for insertion,
    rebalance and entry movement, increase the size of the in-core firstused
    field to 32-bit and handle the potential overflow on conversion to/from
    the on-disk structure. If the overflow condition occurs, set a special
    value in the firstused field that is translated back on header read. The
    special value is only required in the case of an empty 64k attr block. A
    value of zero is used because firstused is initialized to the block size
    and grows backwards from there. Furthermore, the attribute block header
    occupies the first bytes of the block. Thus, a value of zero has no
    other legitimate meaning for this structure. Two new conversion helpers
    are created to manage the conversion of firstused to and from disk.
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    e87021a2
xfs_da_format.h 28.7 KB