summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-07-14 11:15:14 -0700
committerDarrick J. Wong <djwong@kernel.org>2022-11-09 19:07:50 -0800
commitcfa6e1e497f40921e9861a8975a1923c39d5d400 (patch)
tree492fe0f0026e8e87275496c14565949d86d44b8f
parent5fb05a1a2df73b606bbddbee413b33cfc7d1afc6 (diff)
xfs: teach nlink scrubber to deal with metadata directory roots
Enhance the inode link count online fsck code alter their behavior when they detect metadata directory tree roots, just like they do for the regular root directory. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/scrub/nlinks.c12
-rw-r--r--fs/xfs/scrub/nlinks_repair.c2
2 files changed, 8 insertions, 6 deletions
diff --git a/fs/xfs/scrub/nlinks.c b/fs/xfs/scrub/nlinks.c
index 485735672077..b34dc1a345e8 100644
--- a/fs/xfs/scrub/nlinks.c
+++ b/fs/xfs/scrub/nlinks.c
@@ -281,7 +281,7 @@ xchk_nlinks_collect_dirent(
* Otherwise, increment the number of backrefs pointing back to ino.
*/
if (dotdot) {
- if (dp == sc->mp->m_rootip)
+ if (dp == sc->mp->m_rootip || dp == sc->mp->m_metadirip)
error = xchk_nlinks_update_incore(xnc, ino, 1, 0, 0);
else
error = xchk_nlinks_update_incore(xnc, ino, 0, 1, 0);
@@ -448,9 +448,11 @@ xchk_nlinks_collect(
int error;
/* Count the rt and quota files that are rooted in the superblock. */
- error = xchk_nlinks_collect_metafiles(xnc);
- if (error)
- return error;
+ if (!xfs_has_metadir(sc->mp)) {
+ error = xchk_nlinks_collect_metafiles(xnc);
+ if (error)
+ return error;
+ }
/*
* Set up for a potentially lengthy filesystem scan by reducing our
@@ -638,7 +640,7 @@ xchk_nlinks_compare_inode(
xchk_ino_set_corrupt(sc, ip->i_ino);
}
- if (ip == sc->mp->m_rootip) {
+ if (ip == sc->mp->m_rootip || ip == sc->mp->m_metadirip) {
/*
* For the root of a directory tree, both the '.' and '..'
* entries should point to the root directory. The dot entry
diff --git a/fs/xfs/scrub/nlinks_repair.c b/fs/xfs/scrub/nlinks_repair.c
index d8ec6b16da66..0d9a3679e255 100644
--- a/fs/xfs/scrub/nlinks_repair.c
+++ b/fs/xfs/scrub/nlinks_repair.c
@@ -85,7 +85,7 @@ xrep_nlinks_is_orphaned(
if (obs->parents != 0)
return false;
- if (ip == mp->m_rootip || ip == sc->orphanage)
+ if (ip == mp->m_rootip || ip == sc->orphanage || ip == mp->m_metadirip)
return false;
return actual_nlink != 0;
}