7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Darrick J. Wong commit 95e213c1ddb40dfb0a8178ed35c9f29992a320e1 upstream. LOLLM noticed that xchk_refcountbt_process_rmap_fragments returns early if there are enough rmap records that overlap the space referenced by a refcountbt record to match the refcount in that refcountbt record. Unfortunately, it never checks the fragment list in this case, so it won't find the discrepancy between the rmap and refcount btrees. Cc: stable@vger.kernel.org # v4.16 Fixes: dbde19da963706 ("xfs: cross-reference the rmapbt data with the refcountbt") Signed-off-by: Darrick J. Wong Assisted-by: LOLLM # finding obvious bugs Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/scrub/refcount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/xfs/scrub/refcount.c +++ b/fs/xfs/scrub/refcount.c @@ -173,8 +173,11 @@ xchk_refcountbt_process_rmap_fragments( xfs_nlink_t target_nr; target_nr = refchk->refcount - refchk->seen; - if (target_nr == 0) + if (target_nr == 0) { + if (!list_empty(&refchk->fragments)) + refchk->seen = 0; return; + } /* * There are (refchk->rc.rc_refcount - refchk->nr refcount)