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>
This commit is contained in:
Darrick J. Wong 2019-04-16 08:21:59 -07:00
parent 9d71e15586
commit f8c2a2257c
6 changed files with 17 additions and 12 deletions

View File

@ -39,7 +39,7 @@ xchk_setup_ag_iallocbt(
struct xfs_scrub *sc, struct xfs_scrub *sc,
struct xfs_inode *ip) struct xfs_inode *ip)
{ {
return xchk_setup_ag_btree(sc, ip, sc->try_harder); return xchk_setup_ag_btree(sc, ip, sc->flags & XCHK_TRY_HARDER);
} }
/* Inode btree scrubber. */ /* Inode btree scrubber. */
@ -185,7 +185,7 @@ xchk_iallocbt_check_cluster_ifree(
if (error == -ENODATA) { if (error == -ENODATA) {
/* Not cached, just read the disk buffer */ /* Not cached, just read the disk buffer */
freemask_ok = irec_free ^ !!(dip->di_mode); freemask_ok = irec_free ^ !!(dip->di_mode);
if (!bs->sc->try_harder && !freemask_ok) if (!(bs->sc->flags & XCHK_TRY_HARDER) && !freemask_ok)
return -EDEADLOCK; return -EDEADLOCK;
} else if (error < 0) { } else if (error < 0) {
/* /*

View File

@ -320,7 +320,7 @@ xchk_parent(
* If we failed to lock the parent inode even after a retry, just mark * If we failed to lock the parent inode even after a retry, just mark
* this scrub incomplete and return. * this scrub incomplete and return.
*/ */
if (sc->try_harder && error == -EDEADLOCK) { if ((sc->flags & XCHK_TRY_HARDER) && error == -EDEADLOCK) {
error = 0; error = 0;
xchk_set_incomplete(sc); xchk_set_incomplete(sc);
} }

View File

@ -60,7 +60,7 @@ xchk_setup_quota(
dqtype = xchk_quota_to_dqtype(sc); dqtype = xchk_quota_to_dqtype(sc);
if (dqtype == 0) if (dqtype == 0)
return -EINVAL; return -EINVAL;
sc->has_quotaofflock = true; sc->flags |= XCHK_HAS_QUOTAOFFLOCK;
mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock); mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock);
if (!xfs_this_quota_on(sc->mp, dqtype)) if (!xfs_this_quota_on(sc->mp, dqtype))
return -ENOENT; return -ENOENT;

View File

@ -71,8 +71,8 @@ xrep_attempt(
case -EDEADLOCK: case -EDEADLOCK:
case -EAGAIN: case -EAGAIN:
/* Tell the caller to try again having grabbed all the locks. */ /* Tell the caller to try again having grabbed all the locks. */
if (!sc->try_harder) { if (!(sc->flags & XCHK_TRY_HARDER)) {
sc->try_harder = true; sc->flags |= XCHK_TRY_HARDER;
return -EAGAIN; return -EAGAIN;
} }
/* /*

View File

@ -186,9 +186,9 @@ xchk_teardown(
xfs_irele(sc->ip); xfs_irele(sc->ip);
sc->ip = NULL; sc->ip = NULL;
} }
if (sc->has_quotaofflock) { if (sc->flags & XCHK_HAS_QUOTAOFFLOCK) {
mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock); mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
sc->has_quotaofflock = false; sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
} }
if (sc->buf) { if (sc->buf) {
kmem_free(sc->buf); kmem_free(sc->buf);
@ -507,7 +507,7 @@ xfs_scrub_metadata(
/* Scrub for errors. */ /* Scrub for errors. */
error = sc.ops->scrub(&sc); error = sc.ops->scrub(&sc);
if (!sc.try_harder && error == -EDEADLOCK) { if (!(sc.flags & XCHK_TRY_HARDER) && error == -EDEADLOCK) {
/* /*
* Scrubbers return -EDEADLOCK to mean 'try harder'. * Scrubbers return -EDEADLOCK to mean 'try harder'.
* Tear down everything we hold, then set up again with * Tear down everything we hold, then set up again with
@ -516,7 +516,7 @@ xfs_scrub_metadata(
error = xchk_teardown(&sc, ip, 0); error = xchk_teardown(&sc, ip, 0);
if (error) if (error)
goto out; goto out;
sc.try_harder = true; sc.flags |= XCHK_TRY_HARDER;
goto retry_op; goto retry_op;
} else if (error) } else if (error)
goto out_teardown; goto out_teardown;

View File

@ -62,13 +62,18 @@ struct xfs_scrub {
struct xfs_inode *ip; struct xfs_inode *ip;
void *buf; void *buf;
uint ilock_flags; uint ilock_flags;
bool try_harder;
bool has_quotaofflock; /* See the XCHK state flags below. */
unsigned int flags;
/* State tracking for single-AG operations. */ /* State tracking for single-AG operations. */
struct xchk_ag sa; struct xchk_ag sa;
}; };
/* XCHK state flags */
#define XCHK_TRY_HARDER (1 << 0) /* can't get resources, try again */
#define XCHK_HAS_QUOTAOFFLOCK (1 << 1) /* we hold the quotaoff lock */
/* Metadata scrubbers */ /* Metadata scrubbers */
int xchk_tester(struct xfs_scrub *sc); int xchk_tester(struct xfs_scrub *sc);
int xchk_superblock(struct xfs_scrub *sc); int xchk_superblock(struct xfs_scrub *sc);