Skip to content

Commit 54e9b09

Browse files
committed
xfs: fix brainos in the refcount scrubber's rmap fragment processor
Fix some serious WTF in the reference count scrubber's rmap fragment processing. The code comment says that this loop is supposed to move all fragment records starting at or before bno onto the worklist, but there's no obvious reason why nr (the number of items added) should increment starting from 1, and breaking the loop when we've added the target number seems dubious since we could have more rmap fragments that should have been added to the worklist. This seems to manifest in xfs/411 when adding one to the refcount field. Fixes: dbde19d ("xfs: cross-reference the rmapbt data with the refcountbt") Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 6ff646b commit 54e9b09

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fs/xfs/scrub/refcount.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ xchk_refcountbt_process_rmap_fragments(
170170
*/
171171
INIT_LIST_HEAD(&worklist);
172172
rbno = NULLAGBLOCK;
173-
nr = 1;
174173

175174
/* Make sure the fragments actually /are/ in agbno order. */
176175
bno = 0;
@@ -184,15 +183,14 @@ xchk_refcountbt_process_rmap_fragments(
184183
* Find all the rmaps that start at or before the refc extent,
185184
* and put them on the worklist.
186185
*/
186+
nr = 0;
187187
list_for_each_entry_safe(frag, n, &refchk->fragments, list) {
188-
if (frag->rm.rm_startblock > refchk->bno)
189-
goto done;
188+
if (frag->rm.rm_startblock > refchk->bno || nr > target_nr)
189+
break;
190190
bno = frag->rm.rm_startblock + frag->rm.rm_blockcount;
191191
if (bno < rbno)
192192
rbno = bno;
193193
list_move_tail(&frag->list, &worklist);
194-
if (nr == target_nr)
195-
break;
196194
nr++;
197195
}
198196

0 commit comments

Comments
 (0)