summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/dirtree.h
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-04-22 09:48:22 -0700
committerDarrick J. Wong <djwong@kernel.org>2024-04-23 16:55:17 -0700
commit3f31406aef493b3f19020909d29974e28253f91c (patch)
treec064e7aee0ce09ea1a410d0178d32fa091ac008d /fs/xfs/scrub/dirtree.h
parent37056912d5721324ac28787a4f903798f7361099 (diff)
xfs: fix corruptions in the directory tree
Repair corruptions in the directory tree itself. Cycles are broken by removing an incoming parent->child link. Multiply-owned directories are fixed by pruning the extra parent -> child links Disconnected subtrees are reconnected to the lost and found. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/scrub/dirtree.h')
-rw-r--r--fs/xfs/scrub/dirtree.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/xfs/scrub/dirtree.h b/fs/xfs/scrub/dirtree.h
index 2ddbcf43c291..1e1686365c61 100644
--- a/fs/xfs/scrub/dirtree.h
+++ b/fs/xfs/scrub/dirtree.h
@@ -26,6 +26,11 @@ enum xchk_dirpath_outcome {
XCHK_DIRPATH_LOOP, /* cycle detected further up */
XCHK_DIRPATH_STALE, /* path is stale */
XCHK_DIRPATH_OK, /* path reaches the root */
+
+ XREP_DIRPATH_DELETING, /* path is being deleted */
+ XREP_DIRPATH_DELETED, /* path has been deleted */
+ XREP_DIRPATH_ADOPTING, /* path is being adopted */
+ XREP_DIRPATH_ADOPTED, /* path has been adopted */
};
/*
@@ -64,6 +69,9 @@ struct xchk_dirtree_outcomes {
/* Number of XCHK_DIRPATH_OK */
unsigned int good;
+
+ /* Directory needs to be added to lost+found */
+ bool needs_adoption;
};
struct xchk_dirtree {
@@ -79,6 +87,14 @@ struct xchk_dirtree {
*/
xfs_ino_t scan_ino;
+ /*
+ * If we start deleting redundant paths to this subdirectory, this is
+ * the inode number of the surviving parent and the dotdot entry will
+ * be set to this value. If the value is NULLFSINO, then use @root_ino
+ * as a stand-in until the orphanage can adopt the subdirectory.
+ */
+ xfs_ino_t parent_ino;
+
/* Scratch buffer for scanning pptr xattrs */
struct xfs_parent_rec pptr_rec;
struct xfs_da_args pptr_args;
@@ -87,12 +103,18 @@ struct xchk_dirtree {
struct xfs_name xname;
char namebuf[MAXNAMELEN];
+ /* Information for reparenting this directory. */
+ struct xrep_adoption adoption;
+
/*
* Hook into directory updates so that we can receive live updates
* from other writer threads.
*/
struct xfs_dir_hook dhook;
+ /* Parent pointer update arguments. */
+ struct xfs_parent_args ppargs;
+
/* lock for everything below here */
struct mutex lock;
@@ -146,4 +168,11 @@ xchk_dirtree_parentless(const struct xchk_dirtree *dl)
return false;
}
+int xchk_dirtree_find_paths_to_root(struct xchk_dirtree *dl);
+int xchk_dirpath_append(struct xchk_dirtree *dl, struct xfs_inode *ip,
+ struct xchk_dirpath *path, const struct xfs_name *name,
+ const struct xfs_parent_rec *pptr);
+void xchk_dirtree_evaluate(struct xchk_dirtree *dl,
+ struct xchk_dirtree_outcomes *oc);
+
#endif /* __XFS_SCRUB_DIRTREE_H__ */