xfs: clear zapped attr fork state when bmap repair finds no attr fork
PATCH 1/1 xfs: clear zapped attr fork state when bmap repair finds no attr fork
xfstests xfs/377 can make xfs_scrub repeatedly check and repair the attr block map after inode repair zaps an attr fork.
When inode repair zaps an attr fork, it records XFS_SICK_INO_BMBTA_ZAPPED so that scrub/repair can revisit the attr fork block map. If the fork has been reset to an empty state and removed, BMBTA repair has no attr fork mappings to rebuild and can return success.
The post-repair scrub then runs with XREP_ALREADY_FIXED set, which means xchk_file_looks_zapped() deliberately ignores the stale zapped health bit and asks xchk_bmap() to check the current attr fork. For an absent attr fork, xchk_bmap() returns -ENOENT. Returning that error prevents xchk_bmap_attr() from marking XFS_SICK_INO_BMBTA_ZAPPED healthy, leaving the zapped health state behind even though there are no attr fork mappings left to check.
Treat -ENOENT during post-repair BMBTA revalidation as a clean result for the zapped attr fork: clear XFS_SICK_INO_BMBTA_ZAPPED and return success. Keep the existing -ENOENT behavior for ordinary scrubs of absent attr forks.
--- fs/xfs/scrub/bmap.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/xfs/scrub/bmap.c +5 -0
@@ -1170,6 +1170,11 @@ xchk_bmap_attr( } error =xchk_bmap (sc,XFS_ATTR_FORK ); +if (error == -ENOENT && (sc->flags &XREP_ALREADY_FIXED )) { +/* A repaired, empty attr fork no longer has mappings to check. */ +xchk_mark_healthy_if_clean (sc,XFS_SICK_INO_BMBTA_ZAPPED ); +return 0 ; + }if (error)return error;
Signature · 1 line
2.20.1
Quoted 32 lines · Qiang Ma
xfstests xfs/377 can make
xfs_scrubrepeatedly check and repair the attr block map after inode repair zaps an attr fork.When inode repair zaps an attr fork, it records
XFS_SICK_INO_BMBTA_ZAPPEDso that scrub/repair can revisit the attr fork block map. If the fork has been reset to an empty state and removed, BMBTA repair has no attr fork mappings to rebuild and can return success.The post-repair scrub then runs with
XREP_ALREADY_FIXEDset, which meansxchk_file_looks_zapped()deliberately ignores the stale zapped health bit and asksxchk_bmap()to check the current attr fork. For an absent attr fork,xchk_bmap()returns-ENOENT. Returning that error preventsxchk_bmap_attr()from markingXFS_SICK_INO_BMBTA_ZAPPEDhealthy, leaving the zapped health state behind even though there are no attr fork mappings left to check.Treat
-ENOENTduring post-repair BMBTA revalidation as a clean result for the zapped attr fork: clearXFS_SICK_INO_BMBTA_ZAPPEDand return success. Keep the existing-ENOENTbehavior for ordinary scrubs of absent attr forks.Fixes d9041681dd2f ("xfs: set inode sick state flags when we zap either ondisk fork")Signed-off-by Qiang Ma <[email protected]>--- fs/xfs/scrub/bmap.c | 5 +++++ 1 file changed, 5 insertions(+)fs/xfs/scrub/bmap.c +0
-0
fs/xfs/scrub/bmap.c xchk_bmap_attr( · line 1177
Quoted 8 lines
fs/xfs/scrub/bmap.c +5
-0@@ -1170,6 +1170,11 @@ xchk_bmap_attr( } error =xchk_bmap (sc,XFS_ATTR_FORK ); +if (error == -ENOENT && (sc->flags &XREP_ALREADY_FIXED )) { +/* A repaired, empty attr fork no longer has mappings to check. */ +xchk_mark_healthy_if_clean (sc,XFS_SICK_INO_BMBTA_ZAPPED ); +return 0 ; + }
That makes sense.
--D
Quoted 8 lines
fs/xfs/scrub/bmap.c +0
-0if (error)return error;Signature · 1 line
2.20.1
fs/xfs/scrub/bmap.c xchk_bmap_attr( · line 1174
Quoted 2 lines · Qiang Ma
fs/xfs/scrub/bmap.c +2
-0+if (error == -ENOENT && (sc->flags &XREP_ALREADY_FIXED )) { +/* A repaired, empty attr fork no longer has mappings to check. */
Overly long, either move it above the if or turn it into a multiline comment.
Otherwise this looks good.