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

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

xfs: refactor internal dfops initialization



The current transaction allocation code conditionally initializes
the ->t_dfops indirection pointer. Transaction commit/cancel check
the validity of the pointer to determine whether to finish/cancel
the internal dfops.

This disallows the ability to use the internal dfops list as a
temporary container (via xfs_trans_alloc_empty()). Refactor
transaction allocation to always initialize ->t_dfops and check
permanent reservation state on transaction commit/cancel.

Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-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 56830d6c
Loading
Loading
Loading
Loading
+9 −10
Original line number Original line Diff line number Diff line
@@ -281,12 +281,6 @@ xfs_trans_alloc(
	INIT_LIST_HEAD(&tp->t_items);
	INIT_LIST_HEAD(&tp->t_items);
	INIT_LIST_HEAD(&tp->t_busy);
	INIT_LIST_HEAD(&tp->t_busy);
	tp->t_firstblock = NULLFSBLOCK;
	tp->t_firstblock = NULLFSBLOCK;
	/*
	 * We only roll transactions with permanent log reservation. Don't init
	 * ->t_dfops to skip attempts to finish or cancel an empty dfops with a
	 * non-permanent res.
	 */
	if (resp->tr_logflags & XFS_TRANS_PERM_LOG_RES)
	xfs_defer_init(tp, &tp->t_dfops_internal);
	xfs_defer_init(tp, &tp->t_dfops_internal);


	error = xfs_trans_reserve(tp, resp, blocks, rtextents);
	error = xfs_trans_reserve(tp, resp, blocks, rtextents);
@@ -931,8 +925,13 @@ __xfs_trans_commit(


	trace_xfs_trans_commit(tp, _RET_IP_);
	trace_xfs_trans_commit(tp, _RET_IP_);


	/* finish deferred items on final commit */
	/*
	if (!regrant && tp->t_dfops) {
	 * Finish deferred items on final commit. Only permanent transactions
	 * should ever have deferred ops.
	 */
	WARN_ON_ONCE(xfs_defer_has_unfinished_work(tp->t_dfops) &&
		     !(tp->t_flags & XFS_TRANS_PERM_LOG_RES));
	if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) {
		error = xfs_defer_finish_noroll(&tp);
		error = xfs_defer_finish_noroll(&tp);
		if (error) {
		if (error) {
			xfs_defer_cancel(tp);
			xfs_defer_cancel(tp);
@@ -1029,7 +1028,7 @@ xfs_trans_cancel(


	trace_xfs_trans_cancel(tp, _RET_IP_);
	trace_xfs_trans_cancel(tp, _RET_IP_);


	if (tp->t_dfops)
	if (tp->t_flags & XFS_TRANS_PERM_LOG_RES)
		xfs_defer_cancel(tp);
		xfs_defer_cancel(tp);


	/*
	/*