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

Commit 4906e215 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner
Browse files

xfs: remove the flags argument to xfs_trans_cancel



xfs_trans_cancel takes two flags arguments: XFS_TRANS_RELEASE_LOG_RES and
XFS_TRANS_ABORT.  Both of them are a direct product of the transaction
state, and can be deducted:

 - any dirty transaction needs XFS_TRANS_ABORT to be properly canceled,
   and XFS_TRANS_ABORT is a noop for a transaction that is not dirty.
 - any transaction with a permanent log reservation needs
   XFS_TRANS_RELEASE_LOG_RES to be properly canceled, and passing
   XFS_TRANS_RELEASE_LOG_RES for a transaction without a permanent
   log reservation is invalid.

So just remove the flags argument and do the right thing.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent eacb24e7
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ xfs_attr_set(
	tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
	error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
	if (error) {
		xfs_trans_cancel(args.trans, 0);
		xfs_trans_cancel(args.trans);
		return error;
	}
	xfs_ilock(dp, XFS_ILOCK_EXCL);
@@ -276,7 +276,7 @@ xfs_attr_set(
				       XFS_QMOPT_RES_REGBLKS);
	if (error) {
		xfs_iunlock(dp, XFS_ILOCK_EXCL);
		xfs_trans_cancel(args.trans, XFS_TRANS_RELEASE_LOG_RES);
		xfs_trans_cancel(args.trans);
		return error;
	}

@@ -389,10 +389,8 @@ xfs_attr_set(
	return error;

out:
	if (args.trans) {
		xfs_trans_cancel(args.trans,
			XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
	}
	if (args.trans)
		xfs_trans_cancel(args.trans);
	xfs_iunlock(dp, XFS_ILOCK_EXCL);
	return error;
}
@@ -462,7 +460,7 @@ xfs_attr_remove(
	error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm,
				  XFS_ATTRRM_SPACE_RES(mp), 0);
	if (error) {
		xfs_trans_cancel(args.trans, 0);
		xfs_trans_cancel(args.trans);
		return error;
	}

@@ -507,10 +505,8 @@ xfs_attr_remove(
	return error;

out:
	if (args.trans) {
		xfs_trans_cancel(args.trans,
			XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
	}
	if (args.trans)
		xfs_trans_cancel(args.trans);
	xfs_iunlock(dp, XFS_ILOCK_EXCL);
	return error;
}
+4 −7
Original line number Diff line number Diff line
@@ -1112,7 +1112,6 @@ xfs_bmap_add_attrfork(
	int			committed;	/* xaction was committed */
	int			logflags;	/* logging flags */
	int			error;		/* error return value */
	int			cancel_flags = 0;

	ASSERT(XFS_IFORK_Q(ip) == 0);

@@ -1124,17 +1123,15 @@ xfs_bmap_add_attrfork(
		tp->t_flags |= XFS_TRANS_RESERVE;
	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0);
	if (error) {
		xfs_trans_cancel(tp, 0);
		xfs_trans_cancel(tp);
		return error;
	}
	cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
	xfs_ilock(ip, XFS_ILOCK_EXCL);
	error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
			XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
			XFS_QMOPT_RES_REGBLKS);
	if (error)
		goto trans_cancel;
	cancel_flags |= XFS_TRANS_ABORT;
	if (XFS_IFORK_Q(ip))
		goto trans_cancel;
	if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS) {
@@ -1225,7 +1222,7 @@ xfs_bmap_add_attrfork(
bmap_cancel:
	xfs_bmap_cancel(&flist);
trans_cancel:
	xfs_trans_cancel(tp, cancel_flags);
	xfs_trans_cancel(tp);
	xfs_iunlock(ip, XFS_ILOCK_EXCL);
	return error;
}
@@ -5911,7 +5908,7 @@ xfs_bmap_split_extent(
	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
			XFS_DIOSTRAT_SPACE_RES(mp, 0), 0);
	if (error) {
		xfs_trans_cancel(tp, 0);
		xfs_trans_cancel(tp);
		return error;
	}

@@ -5933,6 +5930,6 @@ xfs_bmap_split_extent(


out:
	xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
	xfs_trans_cancel(tp);
	return error;
}
+1 −1
Original line number Diff line number Diff line
@@ -792,7 +792,7 @@ xfs_sync_sb(
	tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP);
	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
	if (error) {
		xfs_trans_cancel(tp, 0);
		xfs_trans_cancel(tp);
		return error;
	}

+0 −1
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ int xfs_log_calc_minimum_size(struct xfs_mount *);
 * Values for call flags parameter.
 */
#define	XFS_TRANS_RELEASE_LOG_RES	0x4
#define	XFS_TRANS_ABORT			0x8

/*
 * Field values for xfs_trans_mod_sb.
+2 −2
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ xfs_setfilesize_trans_alloc(

	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);
	if (error) {
		xfs_trans_cancel(tp, 0);
		xfs_trans_cancel(tp);
		return error;
	}

@@ -145,7 +145,7 @@ xfs_setfilesize(
	isize = xfs_new_eof(ip, offset + size);
	if (!isize) {
		xfs_iunlock(ip, XFS_ILOCK_EXCL);
		xfs_trans_cancel(tp, 0);
		xfs_trans_cancel(tp);
		return 0;
	}

Loading