Commit 160b5a78 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: hoist the already_fixed variable to the scrub context

Now that we no longer memset the scrub context, we can move the
already_fixed variable into the scrub context's state flags instead of
passing around pointers to separate stack variables.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent f8c2a225
...@@ -46,8 +46,7 @@ ...@@ -46,8 +46,7 @@
int int
xrep_attempt( xrep_attempt(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_scrub *sc, struct xfs_scrub *sc)
bool *fixed)
{ {
int error = 0; int error = 0;
...@@ -66,7 +65,7 @@ xrep_attempt( ...@@ -66,7 +65,7 @@ xrep_attempt(
* scrub so that we can tell userspace if we fixed the problem. * scrub so that we can tell userspace if we fixed the problem.
*/ */
sc->sm->sm_flags &= ~XFS_SCRUB_FLAGS_OUT; sc->sm->sm_flags &= ~XFS_SCRUB_FLAGS_OUT;
*fixed = true; sc->flags |= XREP_ALREADY_FIXED;
return -EAGAIN; return -EAGAIN;
case -EDEADLOCK: case -EDEADLOCK:
case -EAGAIN: case -EAGAIN:
......
...@@ -15,7 +15,7 @@ static inline int xrep_notsupported(struct xfs_scrub *sc) ...@@ -15,7 +15,7 @@ static inline int xrep_notsupported(struct xfs_scrub *sc)
/* Repair helpers */ /* Repair helpers */
int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, bool *fixed); int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc);
void xrep_failure(struct xfs_mount *mp); void xrep_failure(struct xfs_mount *mp);
int xrep_roll_ag_trans(struct xfs_scrub *sc); int xrep_roll_ag_trans(struct xfs_scrub *sc);
bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks, bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
...@@ -64,8 +64,7 @@ int xrep_agi(struct xfs_scrub *sc); ...@@ -64,8 +64,7 @@ int xrep_agi(struct xfs_scrub *sc);
static inline int xrep_attempt( static inline int xrep_attempt(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_scrub *sc, struct xfs_scrub *sc)
bool *fixed)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -476,7 +476,6 @@ xfs_scrub_metadata( ...@@ -476,7 +476,6 @@ xfs_scrub_metadata(
}, },
}; };
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
bool already_fixed = false;
int error = 0; int error = 0;
BUILD_BUG_ON(sizeof(meta_scrub_ops) != BUILD_BUG_ON(sizeof(meta_scrub_ops) !=
...@@ -521,7 +520,8 @@ xfs_scrub_metadata( ...@@ -521,7 +520,8 @@ xfs_scrub_metadata(
} else if (error) } else if (error)
goto out_teardown; goto out_teardown;
if ((sc.sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) && !already_fixed) { if ((sc.sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) &&
!(sc.flags & XREP_ALREADY_FIXED)) {
bool needs_fix; bool needs_fix;
/* Let debug users force us into the repair routines. */ /* Let debug users force us into the repair routines. */
...@@ -544,7 +544,7 @@ xfs_scrub_metadata( ...@@ -544,7 +544,7 @@ xfs_scrub_metadata(
* If it's broken, userspace wants us to fix it, and we haven't * If it's broken, userspace wants us to fix it, and we haven't
* already tried to fix it, then attempt a repair. * already tried to fix it, then attempt a repair.
*/ */
error = xrep_attempt(ip, &sc, &already_fixed); error = xrep_attempt(ip, &sc);
if (error == -EAGAIN) { if (error == -EAGAIN) {
/* /*
* Either the repair function succeeded or it couldn't * Either the repair function succeeded or it couldn't
......
...@@ -63,16 +63,17 @@ struct xfs_scrub { ...@@ -63,16 +63,17 @@ struct xfs_scrub {
void *buf; void *buf;
uint ilock_flags; uint ilock_flags;
/* See the XCHK state flags below. */ /* See the XCHK/XREP state flags below. */
unsigned int flags; 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 */ /* XCHK state flags grow up from zero, XREP state flags grown down from 2^31 */
#define XCHK_TRY_HARDER (1 << 0) /* can't get resources, try again */ #define XCHK_TRY_HARDER (1 << 0) /* can't get resources, try again */
#define XCHK_HAS_QUOTAOFFLOCK (1 << 1) /* we hold the quotaoff lock */ #define XCHK_HAS_QUOTAOFFLOCK (1 << 1) /* we hold the quotaoff lock */
#define XREP_ALREADY_FIXED (1 << 31) /* checking our repair work */
/* Metadata scrubbers */ /* Metadata scrubbers */
int xchk_tester(struct xfs_scrub *sc); int xchk_tester(struct xfs_scrub *sc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment