On Tue, Nov 29, 2022 at 02:01:36PM -0800, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > 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@xxxxxxxxxx> > --- > fs/xfs/libxfs/xfs_refcount.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) Looks good to me. Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> -- Dave Chinner david@xxxxxxxxxxxxx