Skip to content

Commit 06b20ef

Browse files
author
Darrick J. Wong
committed
xfs: check pre-metadir fields correctly
The checks that were added to the superblock scrubber for metadata directories aren't quite right -- the old inode pointers are now defined to be zeroes until someone else reuses them. Also consolidate the new metadir field checks to one place; they were inexplicably scattered around. Cc: <[email protected]> # v6.13-rc1 Fixes: 28d756d ("xfs: update sb field checks when metadir is turned on") Signed-off-by: "Darrick J. Wong" <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent e57e083 commit 06b20ef

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

fs/xfs/scrub/agheader.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,11 @@ xchk_superblock(
145145
xchk_block_set_preen(sc, bp);
146146

147147
if (xfs_has_metadir(sc->mp)) {
148-
if (sb->sb_metadirino != cpu_to_be64(mp->m_sb.sb_metadirino))
149-
xchk_block_set_preen(sc, bp);
148+
if (sb->sb_rbmino != cpu_to_be64(0))
149+
xchk_block_set_corrupt(sc, bp);
150+
151+
if (sb->sb_rsumino != cpu_to_be64(0))
152+
xchk_block_set_corrupt(sc, bp);
150153
} else {
151154
if (sb->sb_rbmino != cpu_to_be64(mp->m_sb.sb_rbmino))
152155
xchk_block_set_preen(sc, bp);
@@ -229,7 +232,13 @@ xchk_superblock(
229232
* sb_icount, sb_ifree, sb_fdblocks, sb_frexents
230233
*/
231234

232-
if (!xfs_has_metadir(mp)) {
235+
if (xfs_has_metadir(mp)) {
236+
if (sb->sb_uquotino != cpu_to_be64(0))
237+
xchk_block_set_corrupt(sc, bp);
238+
239+
if (sb->sb_gquotino != cpu_to_be64(0))
240+
xchk_block_set_preen(sc, bp);
241+
} else {
233242
if (sb->sb_uquotino != cpu_to_be64(mp->m_sb.sb_uquotino))
234243
xchk_block_set_preen(sc, bp);
235244

@@ -281,15 +290,8 @@ xchk_superblock(
281290
if (!!(sb->sb_features2 & cpu_to_be32(~v2_ok)))
282291
xchk_block_set_corrupt(sc, bp);
283292

284-
if (xfs_has_metadir(mp)) {
285-
if (sb->sb_rgblklog != mp->m_sb.sb_rgblklog)
286-
xchk_block_set_corrupt(sc, bp);
287-
if (memchr_inv(sb->sb_pad, 0, sizeof(sb->sb_pad)))
288-
xchk_block_set_preen(sc, bp);
289-
} else {
290-
if (sb->sb_features2 != sb->sb_bad_features2)
291-
xchk_block_set_preen(sc, bp);
292-
}
293+
if (sb->sb_features2 != sb->sb_bad_features2)
294+
xchk_block_set_preen(sc, bp);
293295
}
294296

295297
/* Check sb_features2 flags that are set at mkfs time. */
@@ -351,7 +353,10 @@ xchk_superblock(
351353
if (sb->sb_spino_align != cpu_to_be32(mp->m_sb.sb_spino_align))
352354
xchk_block_set_corrupt(sc, bp);
353355

354-
if (!xfs_has_metadir(mp)) {
356+
if (xfs_has_metadir(mp)) {
357+
if (sb->sb_pquotino != cpu_to_be64(0))
358+
xchk_block_set_corrupt(sc, bp);
359+
} else {
355360
if (sb->sb_pquotino != cpu_to_be64(mp->m_sb.sb_pquotino))
356361
xchk_block_set_preen(sc, bp);
357362
}
@@ -366,11 +371,20 @@ xchk_superblock(
366371
}
367372

368373
if (xfs_has_metadir(mp)) {
374+
if (sb->sb_metadirino != cpu_to_be64(mp->m_sb.sb_metadirino))
375+
xchk_block_set_preen(sc, bp);
376+
369377
if (sb->sb_rgcount != cpu_to_be32(mp->m_sb.sb_rgcount))
370378
xchk_block_set_corrupt(sc, bp);
371379

372380
if (sb->sb_rgextents != cpu_to_be32(mp->m_sb.sb_rgextents))
373381
xchk_block_set_corrupt(sc, bp);
382+
383+
if (sb->sb_rgblklog != mp->m_sb.sb_rgblklog)
384+
xchk_block_set_corrupt(sc, bp);
385+
386+
if (memchr_inv(sb->sb_pad, 0, sizeof(sb->sb_pad)))
387+
xchk_block_set_corrupt(sc, bp);
374388
}
375389

376390
/* Everything else must be zero. */

0 commit comments

Comments
 (0)