xfs: rmapbt swapext block reservation overrun test
authorBrian Foster <bfoster@redhat.com>
Thu, 8 Feb 2018 16:04:29 +0000 (11:04 -0500)
committerEryu Guan <eguan@redhat.com>
Thu, 8 Feb 2018 17:15:31 +0000 (01:15 +0800)
commit03cc97346b1d2ace4c85583764c7f94024155cb1
tree303742a2086ccd7c2e1c2b72e72a2d8eb9b9edc0
parentf2d7e7573b34996d6516c4e9a61ab63b547ac65c
xfs: rmapbt swapext block reservation overrun test

The XFS rmapbt extent swap mechanism performs an extent by extent
swap to ensure the rmapbt is rectified with the appropriate extent
owner information after the operation. This implementation suffers
from a corner case that requires extra reservation if the swap
operation results in bouncing one of the associated inodes between
extent and btree formats. When this corner case occurs, it results
in a transaction block reservation overrun and possible corruption
of the free space accounting.

This regression test provides coverage for this corner case. It
creates two files with a large enough extent count to require btree
format, regardless of inode size, and performs a sequence of extent
swaps between them with a decreasing extent count until all extents
are removed from the file(s). This ensures that one of the swaps
covers the btree <-> extent fork format boundary case.

This test reproduces fs corruption on rmapbt enabled filesystems
running on kernels without the associated extent swap fix.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
tests/xfs/443 [new file with mode: 0755]
tests/xfs/443.out [new file with mode: 0644]
tests/xfs/group