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

Commit 9d9e6233 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong
Browse files

xfs: fold dfops into the transaction



struct xfs_defer_ops has now been reduced to a single list_head. The
external dfops mechanism is unused and thus everywhere a (permanent)
transaction is accessible the associated dfops structure is as well.

Remove the xfs_defer_ops structure and fold the list_head into the
transaction. Also remove the last remnant of external dfops in
xfs_trans_dup().

Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent c03edc9e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -4286,7 +4286,6 @@ xfs_bmapi_write(
	bma.ip = ip;
	bma.total = total;
	bma.datatype = 0;
	ASSERT(!tp || tp->t_dfops);

	while (bno < end && n < *nmap) {
		bool			need_alloc = false, wasdelay = false;
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
#define	__XFS_BTREE_H__

struct xfs_buf;
struct xfs_defer_ops;
struct xfs_inode;
struct xfs_mount;
struct xfs_trans;
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
#ifndef __XFS_DA_BTREE_H__
#define	__XFS_DA_BTREE_H__

struct xfs_defer_ops;
struct xfs_inode;
struct xfs_trans;
struct zone;
+19 −48
Original line number Diff line number Diff line
@@ -183,11 +183,10 @@ STATIC void
xfs_defer_create_intents(
	struct xfs_trans		*tp)
{
	struct xfs_defer_ops		*dop = tp->t_dfops;
	struct list_head		*li;
	struct xfs_defer_pending	*dfp;

	list_for_each_entry(dfp, &dop->dop_intake, dfp_list) {
	list_for_each_entry(dfp, &tp->t_dfops, dfp_list) {
		dfp->dfp_intent = dfp->dfp_type->create_intent(tp,
				dfp->dfp_count);
		trace_xfs_defer_create_intent(tp->t_mountp, dfp);
@@ -204,10 +203,9 @@ xfs_defer_trans_abort(
	struct xfs_trans		*tp,
	struct list_head		*dop_pending)
{
	struct xfs_defer_ops		*dop = tp->t_dfops;
	struct xfs_defer_pending	*dfp;

	trace_xfs_defer_trans_abort(tp->t_mountp, dop, _RET_IP_);
	trace_xfs_defer_trans_abort(tp, _RET_IP_);

	/* Abort intent items that don't have a done item. */
	list_for_each_entry(dfp, dop_pending, dfp_list) {
@@ -266,14 +264,13 @@ xfs_defer_trans_roll(
		}
	}

	trace_xfs_defer_trans_roll(tp->t_mountp, tp->t_dfops, _RET_IP_);
	trace_xfs_defer_trans_roll(tp, _RET_IP_);

	/* Roll the transaction. */
	error = xfs_trans_roll(tpp);
	tp = *tpp;
	if (error) {
		trace_xfs_defer_trans_roll_error(tp->t_mountp,
						 tp->t_dfops, error);
		trace_xfs_defer_trans_roll_error(tp, error);
		return error;
	}

@@ -297,7 +294,7 @@ static void
xfs_defer_reset(
	struct xfs_trans	*tp)
{
	ASSERT(list_empty(&tp->t_dfops->dop_intake));
	ASSERT(list_empty(&tp->t_dfops));

	/*
	 * Low mode state transfers across transaction rolls to mirror dfops
@@ -358,15 +355,13 @@ xfs_defer_finish_noroll(

	ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES);

	trace_xfs_defer_finish((*tp)->t_mountp, (*tp)->t_dfops, _RET_IP_);
	trace_xfs_defer_finish(*tp, _RET_IP_);

	/* Until we run out of pending work to finish... */
	while (!list_empty(&dop_pending) ||
	       !list_empty(&(*tp)->t_dfops->dop_intake)) {
	while (!list_empty(&dop_pending) || !list_empty(&(*tp)->t_dfops)) {
		/* log intents and pull in intake items */
		xfs_defer_create_intents(*tp);
		list_splice_tail_init(&(*tp)->t_dfops->dop_intake,
				      &dop_pending);
		list_splice_tail_init(&(*tp)->t_dfops, &dop_pending);

		/*
		 * Roll the transaction.
@@ -438,14 +433,13 @@ xfs_defer_finish_noroll(
	if (error) {
		xfs_defer_trans_abort(*tp, &dop_pending);
		xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE);
		trace_xfs_defer_finish_error((*tp)->t_mountp, (*tp)->t_dfops,
					     error);
		trace_xfs_defer_finish_error(*tp, error);
		xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending);
		xfs_defer_cancel(*tp);
		return error;
	}

	trace_xfs_defer_finish_done((*tp)->t_mountp, (*tp)->t_dfops, _RET_IP_);
	trace_xfs_defer_finish_done(*tp, _RET_IP_);
	return 0;
}

@@ -480,8 +474,8 @@ xfs_defer_cancel(
{
	struct xfs_mount	*mp = tp->t_mountp;

	trace_xfs_defer_cancel(mp, tp->t_dfops, _RET_IP_);
	xfs_defer_cancel_list(mp, &tp->t_dfops->dop_intake);
	trace_xfs_defer_cancel(tp, _RET_IP_);
	xfs_defer_cancel_list(mp, &tp->t_dfops);
}

/* Add an item for later deferred processing. */
@@ -491,7 +485,6 @@ xfs_defer_add(
	enum xfs_defer_ops_type		type,
	struct list_head		*li)
{
	struct xfs_defer_ops		*dop = tp->t_dfops;
	struct xfs_defer_pending	*dfp = NULL;

	ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
@@ -501,8 +494,8 @@ xfs_defer_add(
	 * If the last pending item has the same type, reuse it.  Else,
	 * create a new pending item at the end of the intake list.
	 */
	if (!list_empty(&dop->dop_intake)) {
		dfp = list_last_entry(&dop->dop_intake,
	if (!list_empty(&tp->t_dfops)) {
		dfp = list_last_entry(&tp->t_dfops,
				struct xfs_defer_pending, dfp_list);
		if (dfp->dfp_type->type != type ||
		    (dfp->dfp_type->max_items &&
@@ -517,7 +510,7 @@ xfs_defer_add(
		dfp->dfp_done = NULL;
		dfp->dfp_count = 0;
		INIT_LIST_HEAD(&dfp->dfp_work);
		list_add_tail(&dfp->dfp_list, &dop->dop_intake);
		list_add_tail(&dfp->dfp_list, &tp->t_dfops);
	}

	list_add_tail(li, &dfp->dfp_work);
@@ -532,39 +525,17 @@ xfs_defer_init_op_type(
	defer_op_types[type->type] = type;
}

/* Initialize a deferred operation. */
void
xfs_defer_init(
	struct xfs_trans		*tp,
	struct xfs_defer_ops		*dop)
{
	struct xfs_mount		*mp = NULL;

	memset(dop, 0, sizeof(struct xfs_defer_ops));
	INIT_LIST_HEAD(&dop->dop_intake);
	if (tp) {
		ASSERT(tp->t_firstblock == NULLFSBLOCK);
		tp->t_dfops = dop;
		mp = tp->t_mountp;
	}
	trace_xfs_defer_init(mp, dop, _RET_IP_);
}

/*
 * Move state from one xfs_defer_ops to another and reset the source to initial
 * state. This is primarily used to carry state forward across transaction rolls
 * with internal dfops.
 * Move deferred ops from one transaction to another and reset the source to
 * initial state. This is primarily used to carry state forward across
 * transaction rolls with pending dfops.
 */
void
xfs_defer_move(
	struct xfs_trans	*dtp,
	struct xfs_trans	*stp)
{
	struct xfs_defer_ops	*dst = dtp->t_dfops;
	struct xfs_defer_ops	*src = stp->t_dfops;
	ASSERT(dst != src);

	list_splice_init(&src->dop_intake, &dst->dop_intake);
	list_splice_init(&stp->t_dfops, &dtp->t_dfops);

	/*
	 * Low free space mode was historically controlled by a dfops field.
+0 −2
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
#define	__XFS_DEFER_H__

struct xfs_defer_op_type;
struct xfs_defer_ops;

/*
 * Save a log intent item and a list of extents, so that we can replay
@@ -40,7 +39,6 @@ void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
int xfs_defer_finish_noroll(struct xfs_trans **tp);
int xfs_defer_finish(struct xfs_trans **tp);
void xfs_defer_cancel(struct xfs_trans *);
void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);

/* Description of a deferred type. */
Loading