]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: estimate post-merge refcounts correctly libxfs-sync-6.2_2022-11-30
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Nov 2022 19:18:47 +0000 (11:18 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 1 Dec 2022 01:55:55 +0000 (17:55 -0800)
commitad66e859e7b2987df211c88fcb77ea336b5618c4
tree23fe520a4d01be9338e15144eb0bd37e08ac99b3
parentc0606499ec3d1290843a7013d756e61125b452c7
xfs: estimate post-merge refcounts correctly

Source kernel commit: 65ef77b98122a713774bb2f7b90fca9da39c9ea5

Upon enabling fsdax + reflink for XFS, xfs/179 began to report refcount
metadata corruptions after being run.  Specifically, xfs_repair noticed
single-block refcount records that could be combined but had not been.

The root cause of this is improper MAXREFCOUNT edge case handling in
xfs_refcount_merge_extents.  When we're trying to find candidates for a
refcount btree record merge, we compute the refcount attribute of the
merged record, but we fail to account for the fact that once a record
hits rc_refcount == MAXREFCOUNT, it is pinned that way forever.  Hence
the computed refcount is wrong, and we fail to merge the extents.

Fix this by adjusting the merge predicates to compute the adjusted
refcount correctly.

Fixes: 3172725814f9 ("xfs: adjust refcount of an extent of blocks in refcount btree")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_refcount.c