xfs: refactor repair forcing tests into a repair.c helper
There are a couple of conditions that userspace can set to force repairs of metadata. These really belong in the repair code and not open-coded into the check code, so refactor them into a helper. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
8f71bede8e
commit
48a72f6086
3 changed files with 25 additions and 13 deletions
|
@ -27,6 +27,8 @@
|
||||||
#include "xfs_quota.h"
|
#include "xfs_quota.h"
|
||||||
#include "xfs_qm.h"
|
#include "xfs_qm.h"
|
||||||
#include "xfs_defer.h"
|
#include "xfs_defer.h"
|
||||||
|
#include "xfs_errortag.h"
|
||||||
|
#include "xfs_error.h"
|
||||||
#include "scrub/scrub.h"
|
#include "scrub/scrub.h"
|
||||||
#include "scrub/common.h"
|
#include "scrub/common.h"
|
||||||
#include "scrub/trace.h"
|
#include "scrub/trace.h"
|
||||||
|
@ -940,3 +942,23 @@ xrep_reset_perag_resv(
|
||||||
out:
|
out:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Decide if we are going to call the repair function for a scrub type. */
|
||||||
|
bool
|
||||||
|
xrep_will_attempt(
|
||||||
|
struct xfs_scrub *sc)
|
||||||
|
{
|
||||||
|
/* Userspace asked us to rebuild the structure regardless. */
|
||||||
|
if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Let debug users force us into the repair routines. */
|
||||||
|
if (XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Metadata is corrupt or failed cross-referencing. */
|
||||||
|
if (xchk_needs_repair(sc->sm))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ static inline int xrep_notsupported(struct xfs_scrub *sc)
|
||||||
/* Repair helpers */
|
/* Repair helpers */
|
||||||
|
|
||||||
int xrep_attempt(struct xfs_scrub *sc, struct xchk_stats_run *run);
|
int xrep_attempt(struct xfs_scrub *sc, struct xchk_stats_run *run);
|
||||||
|
bool xrep_will_attempt(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);
|
||||||
int xrep_roll_trans(struct xfs_scrub *sc);
|
int xrep_roll_trans(struct xfs_scrub *sc);
|
||||||
|
@ -117,6 +118,7 @@ int xrep_reinit_pagi(struct xfs_scrub *sc);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define xrep_ino_dqattach(sc) (0)
|
#define xrep_ino_dqattach(sc) (0)
|
||||||
|
#define xrep_will_attempt(sc) (false)
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
xrep_attempt(
|
xrep_attempt(
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
#include "xfs_inode.h"
|
#include "xfs_inode.h"
|
||||||
#include "xfs_quota.h"
|
#include "xfs_quota.h"
|
||||||
#include "xfs_qm.h"
|
#include "xfs_qm.h"
|
||||||
#include "xfs_errortag.h"
|
|
||||||
#include "xfs_error.h"
|
|
||||||
#include "xfs_scrub.h"
|
#include "xfs_scrub.h"
|
||||||
#include "scrub/scrub.h"
|
#include "scrub/scrub.h"
|
||||||
#include "scrub/common.h"
|
#include "scrub/common.h"
|
||||||
|
@ -550,21 +548,11 @@ retry_op:
|
||||||
xchk_update_health(sc);
|
xchk_update_health(sc);
|
||||||
|
|
||||||
if (xchk_could_repair(sc)) {
|
if (xchk_could_repair(sc)) {
|
||||||
bool needs_fix = xchk_needs_repair(sc->sm);
|
|
||||||
|
|
||||||
/* Userspace asked us to rebuild the structure regardless. */
|
|
||||||
if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD)
|
|
||||||
needs_fix = true;
|
|
||||||
|
|
||||||
/* Let debug users force us into the repair routines. */
|
|
||||||
if (XFS_TEST_ERROR(needs_fix, mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
|
|
||||||
needs_fix = true;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If userspace asked for a repair but it wasn't necessary,
|
* If userspace asked for a repair but it wasn't necessary,
|
||||||
* report that back to userspace.
|
* report that back to userspace.
|
||||||
*/
|
*/
|
||||||
if (!needs_fix) {
|
if (!xrep_will_attempt(sc)) {
|
||||||
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED;
|
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED;
|
||||||
goto out_nofix;
|
goto out_nofix;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue