Commit 411350df authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong
Browse files

xfs: refactor xfs_trans_roll



Split xfs_trans_roll into a low-level helper that just rolls the
actual transaction and a new higher level xfs_trans_roll_inode
that takes care of logging and rejoining the inode.  This gets
rid of the NULL inode case, and allows to simplify the special
cases in the deferred operation code.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent f2e9ad21
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ xfs_attr_set(
		 * transaction to add the new attribute to the leaf.
		 */

		error = xfs_trans_roll(&args.trans, dp);
		error = xfs_trans_roll_inode(&args.trans, dp);
		if (error)
			goto out;

@@ -605,7 +605,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
		 * Commit the current trans (including the inode) and start
		 * a new one.
		 */
		error = xfs_trans_roll(&args->trans, dp);
		error = xfs_trans_roll_inode(&args->trans, dp);
		if (error)
			return error;

@@ -620,7 +620,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
	 * Commit the transaction that added the attr name so that
	 * later routines can manage their own transactions.
	 */
	error = xfs_trans_roll(&args->trans, dp);
	error = xfs_trans_roll_inode(&args->trans, dp);
	if (error)
		return error;

@@ -697,7 +697,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
		/*
		 * Commit the remove and start the next trans in series.
		 */
		error = xfs_trans_roll(&args->trans, dp);
		error = xfs_trans_roll_inode(&args->trans, dp);

	} else if (args->rmtblkno > 0) {
		/*
@@ -885,7 +885,7 @@ restart:
			 * Commit the node conversion and start the next
			 * trans in the chain.
			 */
			error = xfs_trans_roll(&args->trans, dp);
			error = xfs_trans_roll_inode(&args->trans, dp);
			if (error)
				goto out;

@@ -925,7 +925,7 @@ restart:
	 * Commit the leaf addition or btree split and start the next
	 * trans in the chain.
	 */
	error = xfs_trans_roll(&args->trans, dp);
	error = xfs_trans_roll_inode(&args->trans, dp);
	if (error)
		goto out;

@@ -1012,7 +1012,7 @@ restart:
		/*
		 * Commit and start the next trans in the chain.
		 */
		error = xfs_trans_roll(&args->trans, dp);
		error = xfs_trans_roll_inode(&args->trans, dp);
		if (error)
			goto out;

@@ -1132,7 +1132,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
		/*
		 * Commit the Btree join operation and start a new trans.
		 */
		error = xfs_trans_roll(&args->trans, dp);
		error = xfs_trans_roll_inode(&args->trans, dp);
		if (error)
			goto out;
	}
+3 −3
Original line number Diff line number Diff line
@@ -2608,7 +2608,7 @@ xfs_attr3_leaf_clearflag(
	/*
	 * Commit the flag value change and start the next trans in series.
	 */
	return xfs_trans_roll(&args->trans, args->dp);
	return xfs_trans_roll_inode(&args->trans, args->dp);
}

/*
@@ -2659,7 +2659,7 @@ xfs_attr3_leaf_setflag(
	/*
	 * Commit the flag value change and start the next trans in series.
	 */
	return xfs_trans_roll(&args->trans, args->dp);
	return xfs_trans_roll_inode(&args->trans, args->dp);
}

/*
@@ -2777,7 +2777,7 @@ xfs_attr3_leaf_flipflags(
	/*
	 * Commit the flag value change and start the next trans in series.
	 */
	error = xfs_trans_roll(&args->trans, args->dp);
	error = xfs_trans_roll_inode(&args->trans, args->dp);

	return error;
}
+2 −2
Original line number Diff line number Diff line
@@ -484,7 +484,7 @@ xfs_attr_rmtval_set(
		/*
		 * Start the next trans in the chain.
		 */
		error = xfs_trans_roll(&args->trans, dp);
		error = xfs_trans_roll_inode(&args->trans, dp);
		if (error)
			return error;
	}
@@ -621,7 +621,7 @@ xfs_attr_rmtval_remove(
		/*
		 * Close out trans and start the next one in the chain.
		 */
		error = xfs_trans_roll(&args->trans, args->dp);
		error = xfs_trans_roll_inode(&args->trans, args->dp);
		if (error)
			return error;
	}
+9 −14
Original line number Diff line number Diff line
@@ -240,23 +240,19 @@ xfs_defer_trans_abort(
STATIC int
xfs_defer_trans_roll(
	struct xfs_trans		**tp,
	struct xfs_defer_ops		*dop,
	struct xfs_inode		*ip)
	struct xfs_defer_ops		*dop)
{
	int				i;
	int				error;

	/* Log all the joined inodes except the one we passed in. */
	for (i = 0; i < XFS_DEFER_OPS_NR_INODES && dop->dop_inodes[i]; i++) {
		if (dop->dop_inodes[i] == ip)
			continue;
	/* Log all the joined inodes. */
	for (i = 0; i < XFS_DEFER_OPS_NR_INODES && dop->dop_inodes[i]; i++)
		xfs_trans_log_inode(*tp, dop->dop_inodes[i], XFS_ILOG_CORE);
	}

	trace_xfs_defer_trans_roll((*tp)->t_mountp, dop);

	/* Roll the transaction. */
	error = xfs_trans_roll(tp, ip);
	error = xfs_trans_roll(tp);
	if (error) {
		trace_xfs_defer_trans_roll_error((*tp)->t_mountp, dop, error);
		xfs_defer_trans_abort(*tp, dop, error);
@@ -264,12 +260,9 @@ xfs_defer_trans_roll(
	}
	dop->dop_committed = true;

	/* Rejoin the joined inodes except the one we passed in. */
	for (i = 0; i < XFS_DEFER_OPS_NR_INODES && dop->dop_inodes[i]; i++) {
		if (dop->dop_inodes[i] == ip)
			continue;
	/* Rejoin the joined inodes. */
	for (i = 0; i < XFS_DEFER_OPS_NR_INODES && dop->dop_inodes[i]; i++)
		xfs_trans_ijoin(*tp, dop->dop_inodes[i], 0);
	}

	return error;
}
@@ -331,13 +324,15 @@ xfs_defer_finish(

	trace_xfs_defer_finish((*tp)->t_mountp, dop);

	xfs_defer_join(dop, ip);

	/* Until we run out of pending work to finish... */
	while (xfs_defer_has_unfinished_work(dop)) {
		/* Log intents for work items sitting in the intake. */
		xfs_defer_intake_work(*tp, dop);

		/* Roll the transaction. */
		error = xfs_defer_trans_roll(tp, dop, ip);
		error = xfs_defer_trans_roll(tp, dop);
		if (error)
			goto out;

+3 −3
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ xfs_attr3_leaf_freextent(
			/*
			 * Roll to next transaction.
			 */
			error = xfs_trans_roll(trans, dp);
			error = xfs_trans_roll_inode(trans, dp);
			if (error)
				return error;
		}
@@ -308,7 +308,7 @@ xfs_attr3_node_inactive(
		/*
		 * Atomically commit the whole invalidate stuff.
		 */
		error = xfs_trans_roll(trans, dp);
		error = xfs_trans_roll_inode(trans, dp);
		if (error)
			return  error;
	}
@@ -375,7 +375,7 @@ xfs_attr3_root_inactive(
	/*
	 * Commit the invalidate and start the next transaction.
	 */
	error = xfs_trans_roll(trans, dp);
	error = xfs_trans_roll_inode(trans, dp);

	return error;
}
Loading