diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-07-14 11:06:09 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-10-14 14:16:39 -0700 |
commit | 8a2c37c52290fffec4f0d616da9a9f43de68fd7a (patch) | |
tree | 11e60d64ac72693ec3a5850099e7854cb339dcff | |
parent | 022822a223989d719744fcab70dc38fdf176948f (diff) |
xfs: try to attach dquots to files before repairing them
Soon, we will be adding the ability to repair inodes. Inode resource
usage is tracked in quota, which means that if we think we might have to
repair a file, we ought to attach dquots from the start. Do this before
we take the file's ILOCK, though we don't require success here because
quota itself could also be in need of repair.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r-- | fs/xfs/scrub/common.c | 19 | ||||
-rw-r--r-- | fs/xfs/scrub/common.h | 8 |
2 files changed, 27 insertions, 0 deletions
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 30b2737451bc..d83ce0258897 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -29,6 +29,7 @@ #include "xfs_attr.h" #include "xfs_reflink.h" #include "xfs_ag.h" +#include "xfs_quota.h" #include "scrub/scrub.h" #include "scrub/common.h" #include "scrub/trace.h" @@ -789,6 +790,22 @@ again: return error; } +#ifdef CONFIG_XFS_QUOTA +/* + * Try to attach dquots to this inode if we think we might want to repair it. + * Quota itself could need repairs, so we don't require success here. + */ +void +xchk_try_dqattach( + struct xfs_scrub *sc) +{ + ASSERT(sc->ip != NULL); + + if (xchk_could_repair(sc)) + xfs_qm_dqattach(sc->ip); +} +#endif + /* Install an inode that we opened by handle for scrubbing. */ int xchk_install_handle_inode( @@ -801,6 +818,7 @@ xchk_install_handle_inode( } sc->ip = ip; + xchk_try_dqattach(sc); return 0; } @@ -820,6 +838,7 @@ xchk_install_live_inode( } sc->ip = ip; + xchk_try_dqattach(sc); return 0; } diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index 49dcaa43d0ed..9cea43a4fd6c 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -102,9 +102,17 @@ xchk_setup_rtsummary(struct xfs_scrub *sc) return -ENOENT; } #endif + #ifdef CONFIG_XFS_QUOTA +void xchk_try_dqattach(struct xfs_scrub *sc); int xchk_setup_quota(struct xfs_scrub *sc); #else +static inline void +xchk_try_dqattach(struct xfs_scrub *sc) +{ + ASSERT(sc->ip != NULL); +} + static inline int xchk_setup_quota(struct xfs_scrub *sc) { |