Commit 8e630837 authored by Eric Sandeen's avatar Eric Sandeen Committed by Darrick J. Wong
Browse files

xfs: move all scrub input checking to xfs_scrub_validate



There were ad-hoc checks for some scrub types but not others;
mark each scrub type with ... it's type, and use that to validate
the allowed and/or required input fields.

Moving these checks out of xfs_scrub_setup_ag_header makes it
a thin wrapper, so unwrap it in the process.

Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
[darrick: add xfs_ prefix to enum, check scrub args after checking type]
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 0a085ddf
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -37,23 +37,6 @@
#include "scrub/common.h"
#include "scrub/trace.h"

/*
 * Set up scrub to check all the static metadata in each AG.
 * This means the SB, AGF, AGI, and AGFL headers.
 */
int
xfs_scrub_setup_ag_header(
	struct xfs_scrub_context	*sc,
	struct xfs_inode		*ip)
{
	struct xfs_mount		*mp = sc->mp;

	if (sc->sm->sm_agno >= mp->m_sb.sb_agcount ||
	    sc->sm->sm_ino || sc->sm->sm_gen)
		return -EINVAL;
	return xfs_scrub_setup_fs(sc, ip);
}

/* Walk all the blocks in the AGFL. */
int
xfs_scrub_walk_agfl(
+1 −9
Original line number Diff line number Diff line
@@ -472,7 +472,7 @@ xfs_scrub_setup_ag_btree(
			return error;
	}

	error = xfs_scrub_setup_ag_header(sc, ip);
	error = xfs_scrub_setup_fs(sc, ip);
	if (error)
		return error;

@@ -507,14 +507,6 @@ xfs_scrub_get_inode(
	struct xfs_inode		*ip = NULL;
	int				error;

	/*
	 * If userspace passed us an AG number or a generation number
	 * without an inode number, they haven't got a clue so bail out
	 * immediately.
	 */
	if (sc->sm->sm_agno || (sc->sm->sm_gen && !sc->sm->sm_ino))
		return -EINVAL;

	/* We want to scan the inode we already had opened. */
	if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) {
		sc->ip = ip_in;
+0 −2
Original line number Diff line number Diff line
@@ -78,8 +78,6 @@ int xfs_scrub_checkpoint_log(struct xfs_mount *mp);

/* Setup functions */
int xfs_scrub_setup_fs(struct xfs_scrub_context *sc, struct xfs_inode *ip);
int xfs_scrub_setup_ag_header(struct xfs_scrub_context *sc,
			      struct xfs_inode *ip);
int xfs_scrub_setup_ag_allocbt(struct xfs_scrub_context *sc,
			       struct xfs_inode *ip);
int xfs_scrub_setup_ag_iallocbt(struct xfs_scrub_context *sc,
+0 −7
Original line number Diff line number Diff line
@@ -67,13 +67,6 @@ xfs_scrub_setup_quota(
{
	uint				dqtype;

	/*
	 * If userspace gave us an AG number or inode data, they don't
	 * know what they're doing.  Get out.
	 */
	if (sc->sm->sm_agno || sc->sm->sm_ino || sc->sm->sm_gen)
		return -EINVAL;

	dqtype = xfs_scrub_quota_to_dqtype(sc);
	if (dqtype == 0)
		return -EINVAL;
+2 −10
Original line number Diff line number Diff line
@@ -43,22 +43,14 @@ xfs_scrub_setup_rt(
	struct xfs_scrub_context	*sc,
	struct xfs_inode		*ip)
{
	struct xfs_mount		*mp = sc->mp;
	int				error = 0;

	/*
	 * If userspace gave us an AG number or inode data, they don't
	 * know what they're doing.  Get out.
	 */
	if (sc->sm->sm_agno || sc->sm->sm_ino || sc->sm->sm_gen)
		return -EINVAL;
	int				error;

	error = xfs_scrub_setup_fs(sc, ip);
	if (error)
		return error;

	sc->ilock_flags = XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP;
	sc->ip = mp->m_rbmip;
	sc->ip = sc->mp->m_rbmip;
	xfs_ilock(sc->ip, sc->ilock_flags);

	return 0;
Loading