[1/2] xfs: add a repair revalidation function pointer
diff mbox series

Message ID 157063977906.2913625.11610063964985485066.stgit@magnolia
State New
Headers show
Series
  • xfs: health evaluations for repair
Related show

Commit Message

Darrick J. Wong Oct. 9, 2019, 4:49 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Allow repair functions to set a separate function pointer to validate
the metadata that they've rebuilt.  This prevents us from exiting from a
repair function that rebuilds both A and B without checking that both A
and B can pass a scrub test.  We'll need this for the free space and
inode btree repair strategies.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/scrub.c |    5 ++++-
 fs/xfs/scrub/scrub.h |    8 ++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Brian Foster Oct. 23, 2019, 11:09 a.m. UTC | #1
On Wed, Oct 09, 2019 at 09:49:39AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Allow repair functions to set a separate function pointer to validate
> the metadata that they've rebuilt.  This prevents us from exiting from a
> repair function that rebuilds both A and B without checking that both A
> and B can pass a scrub test.  We'll need this for the free space and
> inode btree repair strategies.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Seems reasonable, but perhaps should be placed along with the first
patch that uses the callback..

Brian

>  fs/xfs/scrub/scrub.c |    5 ++++-
>  fs/xfs/scrub/scrub.h |    8 ++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
> index 15c8c5f3f688..0f0b64d7164b 100644
> --- a/fs/xfs/scrub/scrub.c
> +++ b/fs/xfs/scrub/scrub.c
> @@ -495,7 +495,10 @@ xfs_scrub_metadata(
>  		goto out_teardown;
>  
>  	/* Scrub for errors. */
> -	error = sc.ops->scrub(&sc);
> +	if ((sc.flags & XREP_ALREADY_FIXED) && sc.ops->repair_eval != NULL)
> +		error = sc.ops->repair_eval(&sc);
> +	else
> +		error = sc.ops->scrub(&sc);
>  	if (!(sc.flags & XCHK_TRY_HARDER) && error == -EDEADLOCK) {
>  		/*
>  		 * Scrubbers return -EDEADLOCK to mean 'try harder'.
> diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h
> index ad1ceb44a628..94a30637a127 100644
> --- a/fs/xfs/scrub/scrub.h
> +++ b/fs/xfs/scrub/scrub.h
> @@ -27,6 +27,14 @@ struct xchk_meta_ops {
>  	/* Repair or optimize the metadata. */
>  	int		(*repair)(struct xfs_scrub *);
>  
> +	/*
> +	 * Re-scrub the metadata we repaired, in case there's extra work that
> +	 * we need to do to check our repair work.  If this is NULL, we'll use
> +	 * the ->scrub function pointer, assuming that the regular scrub is
> +	 * sufficient.
> +	 */
> +	int		(*repair_eval)(struct xfs_scrub *sc);
> +
>  	/* Decide if we even have this piece of metadata. */
>  	bool		(*has)(struct xfs_sb *);
>  
>

Patch
diff mbox series

diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index 15c8c5f3f688..0f0b64d7164b 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -495,7 +495,10 @@  xfs_scrub_metadata(
 		goto out_teardown;
 
 	/* Scrub for errors. */
-	error = sc.ops->scrub(&sc);
+	if ((sc.flags & XREP_ALREADY_FIXED) && sc.ops->repair_eval != NULL)
+		error = sc.ops->repair_eval(&sc);
+	else
+		error = sc.ops->scrub(&sc);
 	if (!(sc.flags & XCHK_TRY_HARDER) && error == -EDEADLOCK) {
 		/*
 		 * Scrubbers return -EDEADLOCK to mean 'try harder'.
diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h
index ad1ceb44a628..94a30637a127 100644
--- a/fs/xfs/scrub/scrub.h
+++ b/fs/xfs/scrub/scrub.h
@@ -27,6 +27,14 @@  struct xchk_meta_ops {
 	/* Repair or optimize the metadata. */
 	int		(*repair)(struct xfs_scrub *);
 
+	/*
+	 * Re-scrub the metadata we repaired, in case there's extra work that
+	 * we need to do to check our repair work.  If this is NULL, we'll use
+	 * the ->scrub function pointer, assuming that the regular scrub is
+	 * sufficient.
+	 */
+	int		(*repair_eval)(struct xfs_scrub *sc);
+
 	/* Decide if we even have this piece of metadata. */
 	bool		(*has)(struct xfs_sb *);