Skip to content

Commit 971ee3a

Browse files
author
Darrick J. Wong
committed
xfs: change bmap scrubber to store the previous mapping
Convert the inode data/attr/cow fork scrubber to remember the entire previous mapping, not just the next expected offset. No behavior changes here, but this will enable some better checking in subsequent patches. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 1fc7a05 commit 971ee3a

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

fs/xfs/scrub/bmap.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,23 @@ xchk_setup_inode_bmap(
9696

9797
struct xchk_bmap_info {
9898
struct xfs_scrub *sc;
99+
100+
/* Incore extent tree cursor */
99101
struct xfs_iext_cursor icur;
100-
xfs_fileoff_t lastoff;
102+
103+
/* Previous fork mapping that we examined */
104+
struct xfs_bmbt_irec prev_rec;
105+
106+
/* Is this a realtime fork? */
101107
bool is_rt;
108+
109+
/* May mappings point to shared space? */
102110
bool is_shared;
111+
112+
/* Was the incore extent tree loaded? */
103113
bool was_loaded;
114+
115+
/* Which inode fork are we checking? */
104116
int whichfork;
105117
};
106118

@@ -405,7 +417,8 @@ xchk_bmap_iextent(
405417
* Check for out-of-order extents. This record could have come
406418
* from the incore list, for which there is no ordering check.
407419
*/
408-
if (irec->br_startoff < info->lastoff)
420+
if (irec->br_startoff < info->prev_rec.br_startoff +
421+
info->prev_rec.br_blockcount)
409422
xchk_fblock_set_corrupt(info->sc, info->whichfork,
410423
irec->br_startoff);
411424

@@ -712,7 +725,8 @@ xchk_bmap_iextent_delalloc(
712725
* Check for out-of-order extents. This record could have come
713726
* from the incore list, for which there is no ordering check.
714727
*/
715-
if (irec->br_startoff < info->lastoff)
728+
if (irec->br_startoff < info->prev_rec.br_startoff +
729+
info->prev_rec.br_blockcount)
716730
xchk_fblock_set_corrupt(info->sc, info->whichfork,
717731
irec->br_startoff);
718732

@@ -806,7 +820,6 @@ xchk_bmap(
806820
goto out;
807821

808822
/* Scrub extent records. */
809-
info.lastoff = 0;
810823
ifp = xfs_ifork_ptr(ip, whichfork);
811824
for_each_xfs_iext(ifp, &info.icur, &irec) {
812825
if (xchk_should_terminate(sc, &error) ||
@@ -823,7 +836,7 @@ xchk_bmap(
823836
xchk_bmap_iextent_delalloc(ip, &info, &irec);
824837
else
825838
xchk_bmap_iextent(ip, &info, &irec);
826-
info.lastoff = irec.br_startoff + irec.br_blockcount;
839+
memcpy(&info.prev_rec, &irec, sizeof(struct xfs_bmbt_irec));
827840
}
828841

829842
error = xchk_bmap_check_rmaps(sc, whichfork);

0 commit comments

Comments
 (0)