xfs: use larger in-core attr firstused field and detect overflow
authorBrian Foster <bfoster@redhat.com>
Mon, 13 Apr 2015 01:27:10 +0000 (11:27 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 13 Apr 2015 01:27:10 +0000 (11:27 +1000)
commite87021a2bc100d330ae859c2cc0614be3e335c5a
treeccda58aff1bf2497ed11f2cc4bc6bbf37552f6ad
parent2f6612415436bab4d923a61d8df399b134247810
xfs: use larger in-core attr firstused field and detect overflow

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: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_da_format.h