aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-04-16 11:21:59 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-04-16 13:01:57 -0400
commitf8c2a2257ca12fb3a04830bbacc85ce860f04ba9 (patch)
tree6f7c3b5d9e07ddf2dd643008df046122fdc2add0 /fs/xfs
parent9d71e15586fd7d274a23dd0bbf54278c86fe263f (diff)
xfs: collapse scrub bool state flags into a single unsigned int
Combine all the boolean state flags in struct xfs_scrub into a single unsigned int, because we're going to be adding more state flags soon. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/scrub/ialloc.c4
-rw-r--r--fs/xfs/scrub/parent.c2
-rw-r--r--fs/xfs/scrub/quota.c2
-rw-r--r--fs/xfs/scrub/repair.c4
-rw-r--r--fs/xfs/scrub/scrub.c8
-rw-r--r--fs/xfs/scrub/scrub.h9
6 files changed, 17 insertions, 12 deletions
diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
index 700114f79a7d..693eb51f5efb 100644
--- a/fs/xfs/scrub/ialloc.c
+++ b/fs/xfs/scrub/ialloc.c
@@ -39,7 +39,7 @@ xchk_setup_ag_iallocbt(
39 struct xfs_scrub *sc, 39 struct xfs_scrub *sc,
40 struct xfs_inode *ip) 40 struct xfs_inode *ip)
41{ 41{
42 return xchk_setup_ag_btree(sc, ip, sc->try_harder); 42 return xchk_setup_ag_btree(sc, ip, sc->flags & XCHK_TRY_HARDER);
43} 43}
44 44
45/* Inode btree scrubber. */ 45/* Inode btree scrubber. */
@@ -185,7 +185,7 @@ xchk_iallocbt_check_cluster_ifree(
185 if (error == -ENODATA) { 185 if (error == -ENODATA) {
186 /* Not cached, just read the disk buffer */ 186 /* Not cached, just read the disk buffer */
187 freemask_ok = irec_free ^ !!(dip->di_mode); 187 freemask_ok = irec_free ^ !!(dip->di_mode);
188 if (!bs->sc->try_harder && !freemask_ok) 188 if (!(bs->sc->flags & XCHK_TRY_HARDER) && !freemask_ok)
189 return -EDEADLOCK; 189 return -EDEADLOCK;
190 } else if (error < 0) { 190 } else if (error < 0) {
191 /* 191 /*
diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c
index 1c9d7c7f64f5..d5d197f1b80f 100644
--- a/fs/xfs/scrub/parent.c
+++ b/fs/xfs/scrub/parent.c
@@ -320,7 +320,7 @@ out:
320 * If we failed to lock the parent inode even after a retry, just mark 320 * If we failed to lock the parent inode even after a retry, just mark
321 * this scrub incomplete and return. 321 * this scrub incomplete and return.
322 */ 322 */
323 if (sc->try_harder && error == -EDEADLOCK) { 323 if ((sc->flags & XCHK_TRY_HARDER) && error == -EDEADLOCK) {
324 error = 0; 324 error = 0;
325 xchk_set_incomplete(sc); 325 xchk_set_incomplete(sc);
326 } 326 }
diff --git a/fs/xfs/scrub/quota.c b/fs/xfs/scrub/quota.c
index 782d582d3edd..5dfe2b5924db 100644
--- a/fs/xfs/scrub/quota.c
+++ b/fs/xfs/scrub/quota.c
@@ -60,7 +60,7 @@ xchk_setup_quota(
60 dqtype = xchk_quota_to_dqtype(sc); 60 dqtype = xchk_quota_to_dqtype(sc);
61 if (dqtype == 0) 61 if (dqtype == 0)
62 return -EINVAL; 62 return -EINVAL;
63 sc->has_quotaofflock = true; 63 sc->flags |= XCHK_HAS_QUOTAOFFLOCK;
64 mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock); 64 mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock);
65 if (!xfs_this_quota_on(sc->mp, dqtype)) 65 if (!xfs_this_quota_on(sc->mp, dqtype))
66 return -ENOENT; 66 return -ENOENT;
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index f28f4bad317b..c093939fe35a 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -71,8 +71,8 @@ xrep_attempt(
71 case -EDEADLOCK: 71 case -EDEADLOCK:
72 case -EAGAIN: 72 case -EAGAIN:
73 /* Tell the caller to try again having grabbed all the locks. */ 73 /* Tell the caller to try again having grabbed all the locks. */
74 if (!sc->try_harder) { 74 if (!(sc->flags & XCHK_TRY_HARDER)) {
75 sc->try_harder = true; 75 sc->flags |= XCHK_TRY_HARDER;
76 return -EAGAIN; 76 return -EAGAIN;
77 } 77 }
78 /* 78 /*
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index 08df00911dd3..6e18a1178e26 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -186,9 +186,9 @@ xchk_teardown(
186 xfs_irele(sc->ip); 186 xfs_irele(sc->ip);
187 sc->ip = NULL; 187 sc->ip = NULL;
188 } 188 }
189 if (sc->has_quotaofflock) { 189 if (sc->flags & XCHK_HAS_QUOTAOFFLOCK) {
190 mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock); 190 mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
191 sc->has_quotaofflock = false; 191 sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
192 } 192 }
193 if (sc->buf) { 193 if (sc->buf) {
194 kmem_free(sc->buf); 194 kmem_free(sc->buf);
@@ -507,7 +507,7 @@ retry_op:
507 507
508 /* Scrub for errors. */ 508 /* Scrub for errors. */
509 error = sc.ops->scrub(&sc); 509 error = sc.ops->scrub(&sc);
510 if (!sc.try_harder && error == -EDEADLOCK) { 510 if (!(sc.flags & XCHK_TRY_HARDER) && error == -EDEADLOCK) {
511 /* 511 /*
512 * Scrubbers return -EDEADLOCK to mean 'try harder'. 512 * Scrubbers return -EDEADLOCK to mean 'try harder'.
513 * Tear down everything we hold, then set up again with 513 * Tear down everything we hold, then set up again with
@@ -516,7 +516,7 @@ retry_op:
516 error = xchk_teardown(&sc, ip, 0); 516 error = xchk_teardown(&sc, ip, 0);
517 if (error) 517 if (error)
518 goto out; 518 goto out;
519 sc.try_harder = true; 519 sc.flags |= XCHK_TRY_HARDER;
520 goto retry_op; 520 goto retry_op;
521 } else if (error) 521 } else if (error)
522 goto out_teardown; 522 goto out_teardown;
diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h
index 22f754fba8e5..60359e7de930 100644
--- a/fs/xfs/scrub/scrub.h
+++ b/fs/xfs/scrub/scrub.h
@@ -62,13 +62,18 @@ struct xfs_scrub {
62 struct xfs_inode *ip; 62 struct xfs_inode *ip;
63 void *buf; 63 void *buf;
64 uint ilock_flags; 64 uint ilock_flags;
65 bool try_harder; 65
66 bool has_quotaofflock; 66 /* See the XCHK state flags below. */
67 unsigned int flags;
67 68
68 /* State tracking for single-AG operations. */ 69 /* State tracking for single-AG operations. */
69 struct xchk_ag sa; 70 struct xchk_ag sa;
70}; 71};
71 72
73/* XCHK state flags */
74#define XCHK_TRY_HARDER (1 << 0) /* can't get resources, try again */
75#define XCHK_HAS_QUOTAOFFLOCK (1 << 1) /* we hold the quotaoff lock */
76
72/* Metadata scrubbers */ 77/* Metadata scrubbers */
73int xchk_tester(struct xfs_scrub *sc); 78int xchk_tester(struct xfs_scrub *sc);
74int xchk_superblock(struct xfs_scrub *sc); 79int xchk_superblock(struct xfs_scrub *sc);