From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH 3/4] xfs: factor out scrub input checking
Date: Fri, 1 Dec 2017 14:25:42 -0800 [thread overview]
Message-ID: <20171201222542.GX21412@magnolia> (raw)
In-Reply-To: <1d269656-35e3-f54a-884d-9ba01ae3f5ba@sandeen.net>
On Fri, Dec 01, 2017 at 04:14:15PM -0600, Eric Sandeen wrote:
> Do this before adding more core checks.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
> index dc1f33a..16932f9 100644
> --- a/fs/xfs/scrub/scrub.c
> +++ b/fs/xfs/scrub/scrub.c
> @@ -285,47 +285,34 @@
> "EXPERIMENTAL online scrub feature in use. Use at your own risk!");
> }
>
> -/* Dispatch metadata scrubbing. */
> -int
> -xfs_scrub_metadata(
> - struct xfs_inode *ip,
> +static int
> +xfs_scrub_validate(
> + struct xfs_mount *mp,
> struct xfs_scrub_metadata *sm)
> {
> - struct xfs_scrub_context sc;
> - struct xfs_mount *mp = ip->i_mount;
> + int error;
> const struct xfs_scrub_meta_ops *ops;
> - bool try_harder = false;
> - int error = 0;
> -
> - BUILD_BUG_ON(sizeof(meta_scrub_ops) !=
> - (sizeof(struct xfs_scrub_meta_ops) * XFS_SCRUB_TYPE_NR));
> -
> - trace_xfs_scrub_start(ip, sm, error);
> -
> - /* Forbidden if we are shut down or mounted norecovery. */
> - error = -ESHUTDOWN;
> - if (XFS_FORCED_SHUTDOWN(mp))
> - goto out;
> - error = -ENOTRECOVERABLE;
> - if (mp->m_flags & XFS_MOUNT_NORECOVERY)
> - goto out;
>
> - /* Check our inputs. */
> error = -EINVAL;
> + /* Check our inputs. */
> sm->sm_flags &= ~XFS_SCRUB_FLAGS_OUT;
> if (sm->sm_flags & ~XFS_SCRUB_FLAGS_IN)
> goto out;
> if (memchr_inv(sm->sm_reserved, 0, sizeof(sm->sm_reserved)))
> goto out;
>
> - /* Do we know about this type of metadata? */
> error = -ENOENT;
> + /* Do we know about this type of metadata? */
> if (sm->sm_type >= XFS_SCRUB_TYPE_NR)
> goto out;
> ops = &meta_scrub_ops[sm->sm_type];
> if (ops->setup == NULL || ops->scrub == NULL)
> goto out;
> + /* Does this fs even support this type of metadata? */
> + if (ops->has && !ops->has(&mp->m_sb))
> + goto out;
>
> + error = -EOPNOTSUPP;
> /*
> * We won't scrub any filesystem that doesn't have the ability
> * to record unwritten extents. The option was made default in
> @@ -335,20 +322,46 @@
> * We also don't support v1-v3 filesystems, which aren't
> * mountable.
> */
> - error = -EOPNOTSUPP;
> if (!xfs_sb_version_hasextflgbit(&mp->m_sb))
> goto out;
>
> - /* Does this fs even support this type of metadata? */
> - error = -ENOENT;
> - if (ops->has && !ops->has(&mp->m_sb))
> - goto out;
> -
> /* We don't know how to repair anything yet. */
> - error = -EOPNOTSUPP;
> if (sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)
> goto out;
>
> + error = 0;
> +out:
> + return error;
> +}
> +
> +/* Dispatch metadata scrubbing. */
> +int
> +xfs_scrub_metadata(
> + struct xfs_inode *ip,
> + struct xfs_scrub_metadata *sm)
> +{
> + struct xfs_scrub_context sc;
> + struct xfs_mount *mp = ip->i_mount;
> + bool try_harder = false;
> + int error = 0;
> +
> + BUILD_BUG_ON(sizeof(meta_scrub_ops) !=
> + (sizeof(struct xfs_scrub_meta_ops) * XFS_SCRUB_TYPE_NR));
> +
> + trace_xfs_scrub_start(ip, sm, error);
> +
> + /* Forbidden if we are shut down or mounted norecovery. */
> + error = -ESHUTDOWN;
> + if (XFS_FORCED_SHUTDOWN(mp))
> + goto out;
> + error = -ENOTRECOVERABLE;
> + if (mp->m_flags & XFS_MOUNT_NORECOVERY)
> + goto out;
> +
> + error = xfs_scrub_validate(mp, sm);
I might've named this xfs_scrub_validate_inputs, but eh.
> + if (error)
> + goto out;
> +
> xfs_scrub_experimental_warning(mp);
>
> retry_op:
> @@ -356,7 +369,7 @@
> memset(&sc, 0, sizeof(sc));
> sc.mp = ip->i_mount;
> sc.sm = sm;
> - sc.ops = ops;
> + sc.ops = &meta_scrub_ops[sm->sm_type];
Trailing whitespace.
--D
> sc.try_harder = try_harder;
> sc.sa.agno = NULLAGNUMBER;
> error = sc.ops->setup(&sc, ip);
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-12-01 22:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 22:11 [PATCH 0/4] xfs: scrub tweaks Eric Sandeen
2017-12-01 22:12 ` [PATCH 1/4] xfs: add scrub to XFS_BUILD_OPTIONS Eric Sandeen
2017-12-01 22:29 ` Darrick J. Wong
2017-12-01 22:31 ` Eric Sandeen
2018-02-01 0:03 ` Darrick J. Wong
2017-12-01 22:13 ` [PATCH 2/4] xfs: explicitly initialize meta_scrub_ops array by type Eric Sandeen
2017-12-01 22:26 ` Darrick J. Wong
2017-12-01 22:14 ` [PATCH 3/4] xfs: factor out scrub input checking Eric Sandeen
2017-12-01 22:25 ` Darrick J. Wong [this message]
2017-12-01 23:23 ` [PATCH v2 " Darrick J. Wong
2017-12-01 22:15 ` [PATCH 4/4] xfs: move all scrub input checking to xfs_scrub_validate Eric Sandeen
2017-12-01 22:24 ` Darrick J. Wong
2017-12-01 22:25 ` Eric Sandeen
2017-12-01 23:02 ` Darrick J. Wong
2017-12-01 23:24 ` [PATCH v2 " Darrick J. Wong
2017-12-01 22:39 ` [PATCH 0/4] xfs: scrub tweaks Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171201222542.GX21412@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).