diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-09-01 10:59:08 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-09-17 18:55:01 -0700 |
commit | de1d5d9c3c194f4d8330fff5e6526c43a80a3d0d (patch) | |
tree | 786ec362b4c2ba50202e039374ef39476444840c /fs/xfs/scrub/parent.c | |
parent | ef1221bcd0249d035074b8f39faab255697eba5b (diff) |
xfs: move orphan files to the orphanagerepair-dirs_2021-09-17
If we can't find a parent for a file, move it to the orphanage.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/scrub/parent.c')
-rw-r--r-- | fs/xfs/scrub/parent.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c index cac9f270e1af..02c682be29de 100644 --- a/fs/xfs/scrub/parent.c +++ b/fs/xfs/scrub/parent.c @@ -17,27 +17,49 @@ #include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/parent.h" +#include "scrub/repair.h" /* Set us up to scrub parents. */ int xchk_setup_parent( struct xfs_scrub *sc) { - int error; - - /* - * If we're attempting a repair having failed a previous repair due to - * being unable to lock an inode (TRY_HARDER), we need to freeze the - * filesystem to make the repair happen. Note that we don't bother - * with the fs freeze when TRY_HARDER is set but IFLAG_REPAIR isn't, - * because a plain scrub is allowed to return with INCOMPLETE set. - */ - if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) && - (sc->flags & XCHK_TRY_HARDER)) { - error = xchk_fs_freeze(sc); - if (error) +#if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) + if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) { + int error; + + error = xrep_setup_orphanage(sc); + switch (error) { + case 0: + case -ENOENT: + case -ENOTDIR: + case -ENOSPC: + /* + * If the orphanage can't be found or isn't a + * directory, we'll keep going, but we won't be able to + * attach the file to the orphanage if we can't find + * any parents. + */ + break; + default: return error; + } + + /* + * If we're attempting a repair having failed a previous repair + * due to being unable to lock an inode (TRY_HARDER), we need + * to freeze the filesystem to make the repair happen. Note + * that we don't bother with the fs freeze when TRY_HARDER is + * set but IFLAG_REPAIR isn't, because a plain scrub is allowed + * to return with INCOMPLETE set. + */ + if (sc->flags & XCHK_TRY_HARDER) { + error = xchk_fs_freeze(sc); + if (error) + return error; + } } +#endif return xchk_setup_inode_contents(sc, 0); } |