Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d9c9028 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: refactor scrub transaction allocation function



Since the transaction allocation helper is about to become more complex,
move it to common.c and remove the redundant parameters.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 08a3a692
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -51,7 +51,6 @@ xfs_scrub_setup_inode_bmap(
	struct xfs_scrub_context	*sc,
	struct xfs_scrub_context	*sc,
	struct xfs_inode		*ip)
	struct xfs_inode		*ip)
{
{
	struct xfs_mount		*mp = sc->mp;
	int				error;
	int				error;


	error = xfs_scrub_get_inode(sc, ip);
	error = xfs_scrub_get_inode(sc, ip);
@@ -75,7 +74,7 @@ xfs_scrub_setup_inode_bmap(
	}
	}


	/* Got the inode, lock it and we're ready to go. */
	/* Got the inode, lock it and we're ready to go. */
	error = xfs_scrub_trans_alloc(sc->sm, mp, &sc->tp);
	error = xfs_scrub_trans_alloc(sc);
	if (error)
	if (error)
		goto out;
		goto out;
	sc->ilock_flags |= XFS_ILOCK_EXCL;
	sc->ilock_flags |= XFS_ILOCK_EXCL;
+13 −3
Original line number Original line Diff line number Diff line
@@ -568,13 +568,24 @@ xfs_scrub_ag_init(


/* Per-scrubber setup functions */
/* Per-scrubber setup functions */


/*
 * Grab an empty transaction so that we can re-grab locked buffers if
 * one of our btrees turns out to be cyclic.
 */
int
xfs_scrub_trans_alloc(
	struct xfs_scrub_context	*sc)
{
	return xfs_trans_alloc_empty(sc->mp, &sc->tp);
}

/* Set us up with a transaction and an empty context. */
/* Set us up with a transaction and an empty context. */
int
int
xfs_scrub_setup_fs(
xfs_scrub_setup_fs(
	struct xfs_scrub_context	*sc,
	struct xfs_scrub_context	*sc,
	struct xfs_inode		*ip)
	struct xfs_inode		*ip)
{
{
	return xfs_scrub_trans_alloc(sc->sm, sc->mp, &sc->tp);
	return xfs_scrub_trans_alloc(sc);
}
}


/* Set us up with AG headers and btree cursors. */
/* Set us up with AG headers and btree cursors. */
@@ -695,7 +706,6 @@ xfs_scrub_setup_inode_contents(
	struct xfs_inode		*ip,
	struct xfs_inode		*ip,
	unsigned int			resblks)
	unsigned int			resblks)
{
{
	struct xfs_mount		*mp = sc->mp;
	int				error;
	int				error;


	error = xfs_scrub_get_inode(sc, ip);
	error = xfs_scrub_get_inode(sc, ip);
@@ -705,7 +715,7 @@ xfs_scrub_setup_inode_contents(
	/* Got the inode, lock it and we're ready to go. */
	/* Got the inode, lock it and we're ready to go. */
	sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
	sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
	xfs_ilock(sc->ip, sc->ilock_flags);
	xfs_ilock(sc->ip, sc->ilock_flags);
	error = xfs_scrub_trans_alloc(sc->sm, mp, &sc->tp);
	error = xfs_scrub_trans_alloc(sc);
	if (error)
	if (error)
		goto out;
		goto out;
	sc->ilock_flags |= XFS_ILOCK_EXCL;
	sc->ilock_flags |= XFS_ILOCK_EXCL;
+1 −13
Original line number Original line Diff line number Diff line
@@ -38,19 +38,7 @@ xfs_scrub_should_terminate(
	return false;
	return false;
}
}


/*
int xfs_scrub_trans_alloc(struct xfs_scrub_context *sc);
 * Grab an empty transaction so that we can re-grab locked buffers if
 * one of our btrees turns out to be cyclic.
 */
static inline int
xfs_scrub_trans_alloc(
	struct xfs_scrub_metadata	*sm,
	struct xfs_mount		*mp,
	struct xfs_trans		**tpp)
{
	return xfs_trans_alloc_empty(mp, tpp);
}

bool xfs_scrub_process_error(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
bool xfs_scrub_process_error(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
		xfs_agblock_t bno, int *error);
		xfs_agblock_t bno, int *error);
bool xfs_scrub_fblock_process_error(struct xfs_scrub_context *sc, int whichfork,
bool xfs_scrub_fblock_process_error(struct xfs_scrub_context *sc, int whichfork,
+2 −3
Original line number Original line Diff line number Diff line
@@ -55,7 +55,6 @@ xfs_scrub_setup_inode(
	struct xfs_scrub_context	*sc,
	struct xfs_scrub_context	*sc,
	struct xfs_inode		*ip)
	struct xfs_inode		*ip)
{
{
	struct xfs_mount		*mp = sc->mp;
	int				error;
	int				error;


	/*
	/*
@@ -68,7 +67,7 @@ xfs_scrub_setup_inode(
		break;
		break;
	case -EFSCORRUPTED:
	case -EFSCORRUPTED:
	case -EFSBADCRC:
	case -EFSBADCRC:
		return xfs_scrub_trans_alloc(sc->sm, mp, &sc->tp);
		return xfs_scrub_trans_alloc(sc);
	default:
	default:
		return error;
		return error;
	}
	}
@@ -76,7 +75,7 @@ xfs_scrub_setup_inode(
	/* Got the inode, lock it and we're ready to go. */
	/* Got the inode, lock it and we're ready to go. */
	sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
	sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
	xfs_ilock(sc->ip, sc->ilock_flags);
	xfs_ilock(sc->ip, sc->ilock_flags);
	error = xfs_scrub_trans_alloc(sc->sm, mp, &sc->tp);
	error = xfs_scrub_trans_alloc(sc);
	if (error)
	if (error)
		goto out;
		goto out;
	sc->ilock_flags |= XFS_ILOCK_EXCL;
	sc->ilock_flags |= XFS_ILOCK_EXCL;