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

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
...@@ -266,7 +266,7 @@ xfs_attr_set( ...@@ -266,7 +266,7 @@ xfs_attr_set(
tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
error = xfs_trans_reserve(args.trans, &tres, args.total, 0); error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
if (error) { if (error) {
xfs_trans_cancel(args.trans, 0); xfs_trans_cancel(args.trans);
return error; return error;
} }
xfs_ilock(dp, XFS_ILOCK_EXCL); xfs_ilock(dp, XFS_ILOCK_EXCL);
...@@ -276,7 +276,7 @@ xfs_attr_set( ...@@ -276,7 +276,7 @@ xfs_attr_set(
XFS_QMOPT_RES_REGBLKS); XFS_QMOPT_RES_REGBLKS);
if (error) { if (error) {
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
xfs_trans_cancel(args.trans, XFS_TRANS_RELEASE_LOG_RES); xfs_trans_cancel(args.trans);
return error; return error;
} }
...@@ -389,10 +389,8 @@ xfs_attr_set( ...@@ -389,10 +389,8 @@ xfs_attr_set(
return error; return error;
out: out:
if (args.trans) { if (args.trans)
xfs_trans_cancel(args.trans, xfs_trans_cancel(args.trans);
XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
}
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error; return error;
} }
...@@ -462,7 +460,7 @@ xfs_attr_remove( ...@@ -462,7 +460,7 @@ xfs_attr_remove(
error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm, error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm,
XFS_ATTRRM_SPACE_RES(mp), 0); XFS_ATTRRM_SPACE_RES(mp), 0);
if (error) { if (error) {
xfs_trans_cancel(args.trans, 0); xfs_trans_cancel(args.trans);
return error; return error;
} }
...@@ -507,10 +505,8 @@ xfs_attr_remove( ...@@ -507,10 +505,8 @@ xfs_attr_remove(
return error; return error;
out: out:
if (args.trans) { if (args.trans)
xfs_trans_cancel(args.trans, xfs_trans_cancel(args.trans);
XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
}
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error; return error;
} }
......
...@@ -1112,7 +1112,6 @@ xfs_bmap_add_attrfork( ...@@ -1112,7 +1112,6 @@ xfs_bmap_add_attrfork(
int committed; /* xaction was committed */ int committed; /* xaction was committed */
int logflags; /* logging flags */ int logflags; /* logging flags */
int error; /* error return value */ int error; /* error return value */
int cancel_flags = 0;
ASSERT(XFS_IFORK_Q(ip) == 0); ASSERT(XFS_IFORK_Q(ip) == 0);
...@@ -1124,17 +1123,15 @@ xfs_bmap_add_attrfork( ...@@ -1124,17 +1123,15 @@ xfs_bmap_add_attrfork(
tp->t_flags |= XFS_TRANS_RESERVE; tp->t_flags |= XFS_TRANS_RESERVE;
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ? error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
XFS_QMOPT_RES_REGBLKS); XFS_QMOPT_RES_REGBLKS);
if (error) if (error)
goto trans_cancel; goto trans_cancel;
cancel_flags |= XFS_TRANS_ABORT;
if (XFS_IFORK_Q(ip)) if (XFS_IFORK_Q(ip))
goto trans_cancel; goto trans_cancel;
if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS) { if (ip->i_d.di_aformat != XFS_DINODE_FMT_EXTENTS) {
...@@ -1225,7 +1222,7 @@ xfs_bmap_add_attrfork( ...@@ -1225,7 +1222,7 @@ xfs_bmap_add_attrfork(
bmap_cancel: bmap_cancel:
xfs_bmap_cancel(&flist); xfs_bmap_cancel(&flist);
trans_cancel: trans_cancel:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
} }
...@@ -5911,7 +5908,7 @@ xfs_bmap_split_extent( ...@@ -5911,7 +5908,7 @@ xfs_bmap_split_extent(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
XFS_DIOSTRAT_SPACE_RES(mp, 0), 0); XFS_DIOSTRAT_SPACE_RES(mp, 0), 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -5933,6 +5930,6 @@ xfs_bmap_split_extent( ...@@ -5933,6 +5930,6 @@ xfs_bmap_split_extent(
out: out:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -792,7 +792,7 @@ xfs_sync_sb( ...@@ -792,7 +792,7 @@ xfs_sync_sb(
tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP); tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
......
...@@ -185,7 +185,6 @@ int xfs_log_calc_minimum_size(struct xfs_mount *); ...@@ -185,7 +185,6 @@ int xfs_log_calc_minimum_size(struct xfs_mount *);
* Values for call flags parameter. * Values for call flags parameter.
*/ */
#define XFS_TRANS_RELEASE_LOG_RES 0x4 #define XFS_TRANS_RELEASE_LOG_RES 0x4
#define XFS_TRANS_ABORT 0x8
/* /*
* Field values for xfs_trans_mod_sb. * Field values for xfs_trans_mod_sb.
......
...@@ -109,7 +109,7 @@ xfs_setfilesize_trans_alloc( ...@@ -109,7 +109,7 @@ xfs_setfilesize_trans_alloc(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -145,7 +145,7 @@ xfs_setfilesize( ...@@ -145,7 +145,7 @@ xfs_setfilesize(
isize = xfs_new_eof(ip, offset + size); isize = xfs_new_eof(ip, offset + size);
if (!isize) { if (!isize) {
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return 0; return 0;
} }
......
...@@ -411,7 +411,7 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -411,7 +411,7 @@ xfs_attr_inactive(xfs_inode_t *dp)
trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL); trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL);
error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0); error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(trans, 0); xfs_trans_cancel(trans);
return error; return error;
} }
xfs_ilock(dp, XFS_ILOCK_EXCL); xfs_ilock(dp, XFS_ILOCK_EXCL);
...@@ -444,7 +444,7 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -444,7 +444,7 @@ xfs_attr_inactive(xfs_inode_t *dp)
return error; return error;
out: out:
xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); xfs_trans_cancel(trans);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error; return error;
} }
...@@ -861,7 +861,7 @@ xfs_free_eofblocks( ...@@ -861,7 +861,7 @@ xfs_free_eofblocks(
if (need_iolock) { if (need_iolock) {
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return -EAGAIN; return -EAGAIN;
} }
} }
...@@ -869,7 +869,7 @@ xfs_free_eofblocks( ...@@ -869,7 +869,7 @@ xfs_free_eofblocks(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
if (error) { if (error) {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
if (need_iolock) if (need_iolock)
xfs_iunlock(ip, XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_IOLOCK_EXCL);
return error; return error;
...@@ -891,9 +891,7 @@ xfs_free_eofblocks( ...@@ -891,9 +891,7 @@ xfs_free_eofblocks(
* If we get an error at this point we simply don't * If we get an error at this point we simply don't
* bother truncating the file. * bother truncating the file.
*/ */
xfs_trans_cancel(tp, xfs_trans_cancel(tp);
(XFS_TRANS_RELEASE_LOG_RES |
XFS_TRANS_ABORT));
} else { } else {
error = xfs_trans_commit(tp, error = xfs_trans_commit(tp,
XFS_TRANS_RELEASE_LOG_RES); XFS_TRANS_RELEASE_LOG_RES);
...@@ -1009,7 +1007,7 @@ xfs_alloc_file_space( ...@@ -1009,7 +1007,7 @@ xfs_alloc_file_space(
* Free the transaction structure. * Free the transaction structure.
*/ */
ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp)); ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
break; break;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
...@@ -1060,7 +1058,7 @@ xfs_alloc_file_space( ...@@ -1060,7 +1058,7 @@ xfs_alloc_file_space(
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag); xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
error1: /* Just cancel transaction */ error1: /* Just cancel transaction */
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
} }
...@@ -1272,7 +1270,7 @@ xfs_free_file_space( ...@@ -1272,7 +1270,7 @@ xfs_free_file_space(
* Free the transaction structure. * Free the transaction structure.
*/ */
ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp)); ASSERT(error == -ENOSPC || XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
break; break;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
...@@ -1313,7 +1311,7 @@ xfs_free_file_space( ...@@ -1313,7 +1311,7 @@ xfs_free_file_space(
error0: error0:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
error1: error1:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
goto out; goto out;
} }
...@@ -1445,7 +1443,7 @@ xfs_shift_file_space( ...@@ -1445,7 +1443,7 @@ xfs_shift_file_space(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
XFS_DIOSTRAT_SPACE_RES(mp, 0), 0); XFS_DIOSTRAT_SPACE_RES(mp, 0), 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
break; break;
} }
...@@ -1481,7 +1479,7 @@ xfs_shift_file_space( ...@@ -1481,7 +1479,7 @@ xfs_shift_file_space(
return error; return error;
out: out:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -1701,7 +1699,7 @@ xfs_swap_extents( ...@@ -1701,7 +1699,7 @@ xfs_swap_extents(
tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT); tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
goto out_unlock; goto out_unlock;
} }
...@@ -1898,6 +1896,6 @@ xfs_swap_extents( ...@@ -1898,6 +1896,6 @@ xfs_swap_extents(
goto out; goto out;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
goto out; goto out;
} }
...@@ -568,8 +568,6 @@ xfs_qm_dqread( ...@@ -568,8 +568,6 @@ xfs_qm_dqread(
struct xfs_buf *bp; struct xfs_buf *bp;
struct xfs_trans *tp = NULL; struct xfs_trans *tp = NULL;
int error; int error;
int cancelflags = 0;
dqp = kmem_zone_zalloc(xfs_qm_dqzone, KM_SLEEP); dqp = kmem_zone_zalloc(xfs_qm_dqzone, KM_SLEEP);
...@@ -617,7 +615,6 @@ xfs_qm_dqread( ...@@ -617,7 +615,6 @@ xfs_qm_dqread(
XFS_QM_DQALLOC_SPACE_RES(mp), 0); XFS_QM_DQALLOC_SPACE_RES(mp), 0);
if (error) if (error)
goto error1; goto error1;
cancelflags = XFS_TRANS_RELEASE_LOG_RES;
} }
/* /*
...@@ -632,7 +629,6 @@ xfs_qm_dqread( ...@@ -632,7 +629,6 @@ xfs_qm_dqread(
* allocate (ENOENT). * allocate (ENOENT).
*/ */
trace_xfs_dqread_fail(dqp); trace_xfs_dqread_fail(dqp);
cancelflags |= XFS_TRANS_ABORT;
goto error1; goto error1;
} }
...@@ -680,7 +676,7 @@ xfs_qm_dqread( ...@@ -680,7 +676,7 @@ xfs_qm_dqread(
error1: error1:
if (tp) if (tp)
xfs_trans_cancel(tp, cancelflags); xfs_trans_cancel(tp);
error0: error0:
xfs_qm_dqdestroy(dqp); xfs_qm_dqdestroy(dqp);
*O_dqpp = NULL; *O_dqpp = NULL;
......
...@@ -138,7 +138,7 @@ xfs_update_prealloc_flags( ...@@ -138,7 +138,7 @@ xfs_update_prealloc_flags(
tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_WRITEID); tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_WRITEID);
error = xfs_trans_reserve(tp, &M_RES(ip->i_mount)->tr_writeid, 0, 0); error = xfs_trans_reserve(tp, &M_RES(ip->i_mount)->tr_writeid, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
......
...@@ -201,7 +201,7 @@ xfs_growfs_data_private( ...@@ -201,7 +201,7 @@ xfs_growfs_data_private(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_growdata, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_growdata,
XFS_GROWFS_SPACE_RES(mp), 0); XFS_GROWFS_SPACE_RES(mp), 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -557,7 +557,7 @@ xfs_growfs_data_private( ...@@ -557,7 +557,7 @@ xfs_growfs_data_private(
return saved_error ? saved_error : error; return saved_error ? saved_error : error;
error0: error0:
xfs_trans_cancel(tp, XFS_TRANS_ABORT); xfs_trans_cancel(tp);
return error; return error;
} }
......
...@@ -1092,7 +1092,6 @@ xfs_create( ...@@ -1092,7 +1092,6 @@ xfs_create(
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
xfs_fsblock_t first_block; xfs_fsblock_t first_block;
bool unlock_dp_on_error = false; bool unlock_dp_on_error = false;
uint cancel_flags;
int committed; int committed;
prid_t prid; prid_t prid;
struct xfs_dquot *udqp = NULL; struct xfs_dquot *udqp = NULL;
...@@ -1129,8 +1128,6 @@ xfs_create( ...@@ -1129,8 +1128,6 @@ xfs_create(
tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE);
} }
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
/* /*
* Initially assume that the file does not exist and * Initially assume that the file does not exist and
* reserve the resources for that case. If that is not * reserve the resources for that case. If that is not
...@@ -1148,10 +1145,9 @@ xfs_create( ...@@ -1148,10 +1145,9 @@ xfs_create(
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, tres, 0, 0); error = xfs_trans_reserve(tp, tres, 0, 0);
} }
if (error) { if (error)
cancel_flags = 0;
goto out_trans_cancel; goto out_trans_cancel;
}
xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
unlock_dp_on_error = true; unlock_dp_on_error = true;
...@@ -1182,7 +1178,7 @@ xfs_create( ...@@ -1182,7 +1178,7 @@ xfs_create(
if (error) { if (error) {
if (error == -ENOSPC) if (error == -ENOSPC)
goto out_trans_cancel; goto out_trans_cancel;
goto out_trans_abort; goto out_trans_cancel;
} }
/* /*
...@@ -1200,7 +1196,7 @@ xfs_create( ...@@ -1200,7 +1196,7 @@ xfs_create(
resblks - XFS_IALLOC_SPACE_RES(mp) : 0); resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
if (error) { if (error) {
ASSERT(error != -ENOSPC); ASSERT(error != -ENOSPC);
goto out_trans_abort; goto out_trans_cancel;
} }
xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
...@@ -1247,10 +1243,8 @@ xfs_create( ...@@ -1247,10 +1243,8 @@ xfs_create(
out_bmap_cancel: out_bmap_cancel:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
out_trans_abort:
cancel_flags |= XFS_TRANS_ABORT;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
out_release_inode: out_release_inode:
/* /*
* Wait until after the current transaction is aborted to finish the * Wait until after the current transaction is aborted to finish the
...@@ -1282,7 +1276,6 @@ xfs_create_tmpfile( ...@@ -1282,7 +1276,6 @@ xfs_create_tmpfile(
struct xfs_inode *ip = NULL; struct xfs_inode *ip = NULL;
struct xfs_trans *tp = NULL; struct xfs_trans *tp = NULL;
int error; int error;
uint cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
prid_t prid; prid_t prid;
struct xfs_dquot *udqp = NULL; struct xfs_dquot *udqp = NULL;
struct xfs_dquot *gdqp = NULL; struct xfs_dquot *gdqp = NULL;
...@@ -1315,10 +1308,8 @@ xfs_create_tmpfile( ...@@ -1315,10 +1308,8 @@ xfs_create_tmpfile(
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, tres, 0, 0); error = xfs_trans_reserve(tp, tres, 0, 0);
} }
if (error) { if (error)
cancel_flags = 0;
goto out_trans_cancel; goto out_trans_cancel;
}
error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
pdqp, resblks, 1, 0); pdqp, resblks, 1, 0);
...@@ -1330,7 +1321,7 @@ xfs_create_tmpfile( ...@@ -1330,7 +1321,7 @@ xfs_create_tmpfile(
if (error) { if (error) {
if (error == -ENOSPC) if (error == -ENOSPC)
goto out_trans_cancel; goto out_trans_cancel;
goto out_trans_abort; goto out_trans_cancel;
} }
if (mp->m_flags & XFS_MOUNT_WSYNC) if (mp->m_flags & XFS_MOUNT_WSYNC)
...@@ -1346,7 +1337,7 @@ xfs_create_tmpfile( ...@@ -1346,7 +1337,7 @@ xfs_create_tmpfile(
ip->i_d.di_nlink--; ip->i_d.di_nlink--;
error = xfs_iunlink(tp, ip); error = xfs_iunlink(tp, ip);
if (error) if (error)
goto out_trans_abort; goto out_trans_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
if (error) if (error)
...@@ -1359,10 +1350,8 @@ xfs_create_tmpfile( ...@@ -1359,10 +1350,8 @@ xfs_create_tmpfile(
*ipp = ip; *ipp = ip;
return 0; return 0;
out_trans_abort:
cancel_flags |= XFS_TRANS_ABORT;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
out_release_inode: out_release_inode:
/* /*
* Wait until after the current transaction is aborted to finish the * Wait until after the current transaction is aborted to finish the
...@@ -1392,7 +1381,6 @@ xfs_link( ...@@ -1392,7 +1381,6 @@ xfs_link(
int error; int error;
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
xfs_fsblock_t first_block; xfs_fsblock_t first_block;
int cancel_flags;
int committed; int committed;
int resblks; int resblks;
...@@ -1412,17 +1400,14 @@ xfs_link( ...@@ -1412,17 +1400,14 @@ xfs_link(
goto std_return; goto std_return;
tp = xfs_trans_alloc(mp, XFS_TRANS_LINK); tp = xfs_trans_alloc(mp, XFS_TRANS_LINK);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
resblks = XFS_LINK_SPACE_RES(mp, target_name->len); resblks = XFS_LINK_SPACE_RES(mp, target_name->len);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0);
if (error == -ENOSPC) { if (error == -ENOSPC) {
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0);
} }
if (error) { if (error)
cancel_flags = 0;
goto error_return; goto error_return;
}
xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL); xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL);
...@@ -1451,19 +1436,19 @@ xfs_link( ...@@ -1451,19 +1436,19 @@ xfs_link(
if (sip->i_d.di_nlink == 0) { if (sip->i_d.di_nlink == 0) {
error = xfs_iunlink_remove(tp, sip); error = xfs_iunlink_remove(tp, sip);
if (error) if (error)
goto abort_return; goto error_return;
} }
error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
&first_block, &free_list, resblks); &first_block, &free_list, resblks);
if (error) if (error)
goto abort_return; goto error_return;
xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE); xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE);
error = xfs_bumplink(tp, sip); error = xfs_bumplink(tp, sip);
if (error) if (error)
goto abort_return; goto error_return;
/* /*
* If this is a synchronous mount, make sure that the * If this is a synchronous mount, make sure that the
...@@ -1477,15 +1462,13 @@ xfs_link( ...@@ -1477,15 +1462,13 @@ xfs_link(
error = xfs_bmap_finish (&tp, &free_list, &committed); error = xfs_bmap_finish (&tp, &free_list, &committed);
if (error) { if (error) {
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
goto abort_return; goto error_return;
} }
return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
abort_return:
cancel_flags |= XFS_TRANS_ABORT;
error_return: error_return:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
std_return: std_return:
return error; return error;
} }
...@@ -1698,7 +1681,7 @@ xfs_inactive_truncate( ...@@ -1698,7 +1681,7 @@ xfs_inactive_truncate(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
if (error) { if (error) {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -1727,7 +1710,7 @@ xfs_inactive_truncate( ...@@ -1727,7 +1710,7 @@ xfs_inactive_truncate(
return 0; return 0;
error_trans_cancel: error_trans_cancel:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
error_unlock: error_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
...@@ -1777,7 +1760,7 @@ xfs_inactive_ifree( ...@@ -1777,7 +1760,7 @@ xfs_inactive_ifree(
} else { } else {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
} }
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -1797,7 +1780,7 @@ xfs_inactive_ifree( ...@@ -1797,7 +1780,7 @@ xfs_inactive_ifree(
__func__, error); __func__, error);
xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
} }
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
} }
...@@ -2482,7 +2465,6 @@ xfs_remove( ...@@ -2482,7 +2465,6 @@ xfs_remove(
int error = 0; int error = 0;
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
xfs_fsblock_t first_block; xfs_fsblock_t first_block;
int cancel_flags;
int committed; int committed;
uint resblks; uint resblks;
...@@ -2503,7 +2485,6 @@ xfs_remove( ...@@ -2503,7 +2485,6 @@ xfs_remove(
tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR); tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR);
else else
tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE); tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
/* /*
* We try to get the real space reservation first, * We try to get the real space reservation first,
...@@ -2522,7 +2503,6 @@ xfs_remove( ...@@ -2522,7 +2503,6 @@ xfs_remove(
} }
if (error) { if (error) {
ASSERT(error != -ENOSPC); ASSERT(error != -ENOSPC);
cancel_flags = 0;
goto out_trans_cancel; goto out_trans_cancel;
} }
...@@ -2534,7 +2514,6 @@ xfs_remove( ...@@ -2534,7 +2514,6 @@ xfs_remove(
/* /*
* If we're removing a directory perform some additional validation. * If we're removing a directory perform some additional validation.
*/ */
cancel_flags |= XFS_TRANS_ABORT;
if (is_dir) { if (is_dir) {
ASSERT(ip->i_d.di_nlink >= 2); ASSERT(ip->i_d.di_nlink >= 2);
if (ip->i_d.di_nlink != 2) { if (ip->i_d.di_nlink != 2) {
...@@ -2602,7 +2581,7 @@ xfs_remove( ...@@ -2602,7 +2581,7 @@ xfs_remove(
out_bmap_cancel: out_bmap_cancel:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
std_return: std_return:
return error; return error;
} }
...@@ -2676,7 +2655,7 @@ xfs_finish_rename( ...@@ -2676,7 +2655,7 @@ xfs_finish_rename(
error = xfs_bmap_finish(&tp, free_list, &committed); error = xfs_bmap_finish(&tp, free_list, &committed);
if (error) { if (error) {
xfs_bmap_cancel(free_list); xfs_bmap_cancel(free_list);
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -2801,7 +2780,7 @@ xfs_cross_rename( ...@@ -2801,7 +2780,7 @@ xfs_cross_rename(
out_trans_abort: out_trans_abort:
xfs_bmap_cancel(free_list); xfs_bmap_cancel(free_list);
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -2855,7 +2834,6 @@ xfs_rename( ...@@ -2855,7 +2834,6 @@ xfs_rename(
int num_inodes = __XFS_SORT_INODES; int num_inodes = __XFS_SORT_INODES;
bool new_parent = (src_dp != target_dp); bool new_parent = (src_dp != target_dp);
bool src_is_directory = S_ISDIR(src_ip->i_d.di_mode); bool src_is_directory = S_ISDIR(src_ip->i_d.di_mode);
int cancel_flags = 0;
int spaceres; int spaceres;
int error; int error;
...@@ -2891,7 +2869,6 @@ xfs_rename( ...@@ -2891,7 +2869,6 @@ xfs_rename(
} }
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
/* /*
* Attach the dquots to the inodes * Attach the dquots to the inodes
...@@ -2962,10 +2939,8 @@ xfs_rename( ...@@ -2962,10 +2939,8 @@ xfs_rename(
error = xfs_dir_createname(tp, target_dp, target_name, error = xfs_dir_createname(tp, target_dp, target_name,
src_ip->i_ino, &first_block, src_ip->i_ino, &first_block,
&free_list, spaceres); &free_list, spaceres);
if (error == -ENOSPC)
goto out_bmap_cancel;
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
xfs_trans_ichgtime(tp, target_dp, xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -2973,7 +2948,7 @@ xfs_rename( ...@@ -2973,7 +2948,7 @@ xfs_rename(
if (new_parent && src_is_directory) { if (new_parent && src_is_directory) {
error = xfs_bumplink(tp, target_dp); error = xfs_bumplink(tp, target_dp);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
} }
} else { /* target_ip != NULL */ } else { /* target_ip != NULL */
/* /*
...@@ -3005,7 +2980,7 @@ xfs_rename( ...@@ -3005,7 +2980,7 @@ xfs_rename(
src_ip->i_ino, src_ip->i_ino,
&first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
xfs_trans_ichgtime(tp, target_dp, xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -3016,7 +2991,7 @@ xfs_rename( ...@@ -3016,7 +2991,7 @@ xfs_rename(
*/ */
error = xfs_droplink(tp, target_ip); error = xfs_droplink(tp, target_ip);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
if (src_is_directory) { if (src_is_directory) {
/* /*
...@@ -3024,7 +2999,7 @@ xfs_rename( ...@@ -3024,7 +2999,7 @@ xfs_rename(
*/ */
error = xfs_droplink(tp, target_ip); error = xfs_droplink(tp, target_ip);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
} }
} /* target_ip != NULL */ } /* target_ip != NULL */
...@@ -3041,7 +3016,7 @@ xfs_rename( ...@@ -3041,7 +3016,7 @@ xfs_rename(
&first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
ASSERT(error != -EEXIST); ASSERT(error != -EEXIST);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
} }
/* /*
...@@ -3067,7 +3042,7 @@ xfs_rename( ...@@ -3067,7 +3042,7 @@ xfs_rename(
*/ */
error = xfs_droplink(tp, src_dp); error = xfs_droplink(tp, src_dp);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
} }
/* /*
...@@ -3082,7 +3057,7 @@ xfs_rename( ...@@ -3082,7 +3057,7 @@ xfs_rename(
error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
&first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
/* /*
* For whiteouts, we need to bump the link count on the whiteout inode. * For whiteouts, we need to bump the link count on the whiteout inode.
...@@ -3096,10 +3071,10 @@ xfs_rename( ...@@ -3096,10 +3071,10 @@ xfs_rename(
ASSERT(wip->i_d.di_nlink == 0); ASSERT(wip->i_d.di_nlink == 0);
error = xfs_bumplink(tp, wip); error = xfs_bumplink(tp, wip);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
error = xfs_iunlink_remove(tp, wip); error = xfs_iunlink_remove(tp, wip);
if (error) if (error)
goto out_trans_abort; goto out_bmap_cancel;
xfs_trans_log_inode(tp, wip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, wip, XFS_ILOG_CORE);
/* /*
...@@ -3120,12 +3095,10 @@ xfs_rename( ...@@ -3120,12 +3095,10 @@ xfs_rename(
IRELE(wip); IRELE(wip);
return error; return error;
out_trans_abort:
cancel_flags |= XFS_TRANS_ABORT;
out_bmap_cancel: out_bmap_cancel:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
if (wip) if (wip)
IRELE(wip); IRELE(wip);
return error; return error;
......
...@@ -336,7 +336,7 @@ xfs_set_dmattrs( ...@@ -336,7 +336,7 @@ xfs_set_dmattrs(
tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS); tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
...@@ -1076,7 +1076,7 @@ xfs_ioctl_setattr_get_trans( ...@@ -1076,7 +1076,7 @@ xfs_ioctl_setattr_get_trans(
return tp; return tp;
out_cancel: out_cancel:
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return ERR_PTR(error); return ERR_PTR(error);
} }
...@@ -1265,7 +1265,7 @@ xfs_ioctl_setattr( ...@@ -1265,7 +1265,7 @@ xfs_ioctl_setattr(
return code; return code;
error_trans_cancel: error_trans_cancel:
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
error_free_dquots: error_free_dquots:
xfs_qm_dqrele(udqp); xfs_qm_dqrele(udqp);
xfs_qm_dqrele(pdqp); xfs_qm_dqrele(pdqp);
...@@ -1338,7 +1338,7 @@ xfs_ioc_setxflags( ...@@ -1338,7 +1338,7 @@ xfs_ioc_setxflags(
error = xfs_ioctl_setattr_xflags(tp, ip, &fa); error = xfs_ioctl_setattr_xflags(tp, ip, &fa);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
goto out_drop_write; goto out_drop_write;
} }
......
...@@ -183,7 +183,7 @@ xfs_iomap_write_direct( ...@@ -183,7 +183,7 @@ xfs_iomap_write_direct(
* Check for running out of space, note: need lock to return * Check for running out of space, note: need lock to return
*/ */
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -236,7 +236,7 @@ xfs_iomap_write_direct( ...@@ -236,7 +236,7 @@ xfs_iomap_write_direct(
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag); xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
goto out_unlock; goto out_unlock;
} }
...@@ -690,7 +690,7 @@ xfs_iomap_write_allocate( ...@@ -690,7 +690,7 @@ xfs_iomap_write_allocate(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
nres, 0); nres, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
...@@ -791,7 +791,7 @@ xfs_iomap_write_allocate( ...@@ -791,7 +791,7 @@ xfs_iomap_write_allocate(
trans_cancel: trans_cancel:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
error0: error0:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
...@@ -853,7 +853,7 @@ xfs_iomap_write_unwritten( ...@@ -853,7 +853,7 @@ xfs_iomap_write_unwritten(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
resblks, 0); resblks, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -914,7 +914,7 @@ xfs_iomap_write_unwritten( ...@@ -914,7 +914,7 @@ xfs_iomap_write_unwritten(
error_on_bmapi_transaction: error_on_bmapi_transaction:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT)); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
} }
...@@ -733,7 +733,7 @@ xfs_setattr_nonsize( ...@@ -733,7 +733,7 @@ xfs_setattr_nonsize(
return 0; return 0;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
out_dqrele: out_dqrele:
xfs_qm_dqrele(udqp); xfs_qm_dqrele(udqp);
...@@ -755,7 +755,6 @@ xfs_setattr_size( ...@@ -755,7 +755,6 @@ xfs_setattr_size(
struct xfs_trans *tp; struct xfs_trans *tp;
int error; int error;
uint lock_flags = 0; uint lock_flags = 0;
uint commit_flags = 0;
bool did_zeroing = false; bool did_zeroing = false;
trace_xfs_setattr(ip); trace_xfs_setattr(ip);
...@@ -861,7 +860,6 @@ xfs_setattr_size( ...@@ -861,7 +860,6 @@ xfs_setattr_size(
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
commit_flags = XFS_TRANS_RELEASE_LOG_RES;
lock_flags |= XFS_ILOCK_EXCL; lock_flags |= XFS_ILOCK_EXCL;
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
...@@ -901,7 +899,7 @@ xfs_setattr_size( ...@@ -901,7 +899,7 @@ xfs_setattr_size(
if (newsize <= oldsize) { if (newsize <= oldsize) {
error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, newsize); error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, newsize);
if (error) if (error)
goto out_trans_abort; goto out_trans_cancel;
/* /*
* Truncated "down", so we're removing references to old data * Truncated "down", so we're removing references to old data
...@@ -934,10 +932,8 @@ xfs_setattr_size( ...@@ -934,10 +932,8 @@ xfs_setattr_size(
xfs_iunlock(ip, lock_flags); xfs_iunlock(ip, lock_flags);
return error; return error;
out_trans_abort:
commit_flags |= XFS_TRANS_ABORT;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, commit_flags); xfs_trans_cancel(tp);
goto out_unlock; goto out_unlock;
} }
...@@ -984,7 +980,7 @@ xfs_vn_update_time( ...@@ -984,7 +980,7 @@ xfs_vn_update_time(
tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
......
...@@ -3755,7 +3755,7 @@ xlog_recover_process_efi( ...@@ -3755,7 +3755,7 @@ xlog_recover_process_efi(
return error; return error;
abort_error: abort_error:
xfs_trans_cancel(tp, XFS_TRANS_ABORT); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -3863,7 +3863,7 @@ xlog_recover_clear_agi_bucket( ...@@ -3863,7 +3863,7 @@ xlog_recover_clear_agi_bucket(
return; return;
out_abort: out_abort:
xfs_trans_cancel(tp, XFS_TRANS_ABORT); xfs_trans_cancel(tp);
out_error: out_error:
xfs_warn(mp, "%s: failed to clear agi %d. Continuing.", __func__, agno); xfs_warn(mp, "%s: failed to clear agi %d. Continuing.", __func__, agno);
return; return;
......
...@@ -306,7 +306,7 @@ xfs_fs_commit_blocks( ...@@ -306,7 +306,7 @@ xfs_fs_commit_blocks(
tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
goto out_drop_iolock; goto out_drop_iolock;
} }
......
...@@ -756,7 +756,7 @@ xfs_qm_qino_alloc( ...@@ -756,7 +756,7 @@ xfs_qm_qino_alloc(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_create, error = xfs_trans_reserve(tp, &M_RES(mp)->tr_create,
XFS_QM_QINOCREATE_SPACE_RES(mp), 0); XFS_QM_QINOCREATE_SPACE_RES(mp), 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -764,8 +764,7 @@ xfs_qm_qino_alloc( ...@@ -764,8 +764,7 @@ xfs_qm_qino_alloc(
error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, 1, ip, error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, 1, ip,
&committed); &committed);
if (error) { if (error) {
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | xfs_trans_cancel(tp);
XFS_TRANS_ABORT);
return error; return error;
} }
} }
......
...@@ -239,7 +239,7 @@ xfs_qm_scall_trunc_qfile( ...@@ -239,7 +239,7 @@ xfs_qm_scall_trunc_qfile(
tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE); tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_IOLOCK_EXCL);
goto out_put; goto out_put;
} }
...@@ -252,8 +252,7 @@ xfs_qm_scall_trunc_qfile( ...@@ -252,8 +252,7 @@ xfs_qm_scall_trunc_qfile(
error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0); error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | xfs_trans_cancel(tp);
XFS_TRANS_ABORT);
goto out_unlock; goto out_unlock;
} }
...@@ -437,7 +436,7 @@ xfs_qm_scall_setqlim( ...@@ -437,7 +436,7 @@ xfs_qm_scall_setqlim(
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM); tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_setqlim, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_setqlim, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
goto out_rele; goto out_rele;
} }
...@@ -571,7 +570,7 @@ xfs_qm_log_quotaoff_end( ...@@ -571,7 +570,7 @@ xfs_qm_log_quotaoff_end(
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_equotaoff, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_equotaoff, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -605,7 +604,7 @@ xfs_qm_log_quotaoff( ...@@ -605,7 +604,7 @@ xfs_qm_log_quotaoff(
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
goto out; goto out;
} }
......
...@@ -780,7 +780,6 @@ xfs_growfs_rt_alloc( ...@@ -780,7 +780,6 @@ xfs_growfs_rt_alloc(
* Allocate space to the file, as necessary. * Allocate space to the file, as necessary.
*/ */
while (oblocks < nblocks) { while (oblocks < nblocks) {
int cancelflags = 0;
xfs_trans_t *tp; xfs_trans_t *tp;
tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_ALLOC); tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_ALLOC);
...@@ -792,7 +791,6 @@ xfs_growfs_rt_alloc( ...@@ -792,7 +791,6 @@ xfs_growfs_rt_alloc(
resblks, 0); resblks, 0);
if (error) if (error)
goto error_cancel; goto error_cancel;
cancelflags = XFS_TRANS_RELEASE_LOG_RES;
/* /*
* Lock the inode. * Lock the inode.
*/ */
...@@ -804,7 +802,6 @@ xfs_growfs_rt_alloc( ...@@ -804,7 +802,6 @@ xfs_growfs_rt_alloc(
* Allocate blocks to the bitmap file. * Allocate blocks to the bitmap file.
*/ */
nmap = 1; nmap = 1;
cancelflags |= XFS_TRANS_ABORT;
error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks, error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks,
XFS_BMAPI_METADATA, &firstblock, XFS_BMAPI_METADATA, &firstblock,
resblks, &map, &nmap, &flist); resblks, &map, &nmap, &flist);
...@@ -825,7 +822,6 @@ xfs_growfs_rt_alloc( ...@@ -825,7 +822,6 @@ xfs_growfs_rt_alloc(
* Now we need to clear the allocated blocks. * Now we need to clear the allocated blocks.
* Do this one block per transaction, to keep it simple. * Do this one block per transaction, to keep it simple.
*/ */
cancelflags = 0;
for (bno = map.br_startoff, fsbno = map.br_startblock; for (bno = map.br_startoff, fsbno = map.br_startblock;
bno < map.br_startoff + map.br_blockcount; bno < map.br_startoff + map.br_blockcount;
bno++, fsbno++) { bno++, fsbno++) {
...@@ -851,7 +847,7 @@ xfs_growfs_rt_alloc( ...@@ -851,7 +847,7 @@ xfs_growfs_rt_alloc(
if (bp == NULL) { if (bp == NULL) {
error = -EIO; error = -EIO;
error_cancel: error_cancel:
xfs_trans_cancel(tp, cancelflags); xfs_trans_cancel(tp);
goto error; goto error;
} }
memset(bp->b_addr, 0, mp->m_sb.sb_blocksize); memset(bp->b_addr, 0, mp->m_sb.sb_blocksize);
...@@ -973,7 +969,6 @@ xfs_growfs_rt( ...@@ -973,7 +969,6 @@ xfs_growfs_rt(
bmbno < nrbmblocks; bmbno < nrbmblocks;
bmbno++) { bmbno++) {
xfs_trans_t *tp; xfs_trans_t *tp;
int cancelflags = 0;
*nmp = *mp; *nmp = *mp;
nsbp = &nmp->m_sb; nsbp = &nmp->m_sb;
...@@ -1015,7 +1010,6 @@ xfs_growfs_rt( ...@@ -1015,7 +1010,6 @@ xfs_growfs_rt(
mp->m_rbmip->i_d.di_size = mp->m_rbmip->i_d.di_size =
nsbp->sb_rbmblocks * nsbp->sb_blocksize; nsbp->sb_rbmblocks * nsbp->sb_blocksize;
xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
cancelflags |= XFS_TRANS_ABORT;
/* /*
* Get the summary inode into the transaction. * Get the summary inode into the transaction.
*/ */
...@@ -1062,7 +1056,7 @@ xfs_growfs_rt( ...@@ -1062,7 +1056,7 @@ xfs_growfs_rt(
nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno); nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno);
if (error) { if (error) {
error_cancel: error_cancel:
xfs_trans_cancel(tp, cancelflags); xfs_trans_cancel(tp);
break; break;
} }
/* /*
......
...@@ -178,7 +178,6 @@ xfs_symlink( ...@@ -178,7 +178,6 @@ xfs_symlink(
struct xfs_bmap_free free_list; struct xfs_bmap_free free_list;
xfs_fsblock_t first_block; xfs_fsblock_t first_block;
bool unlock_dp_on_error = false; bool unlock_dp_on_error = false;
uint cancel_flags;
int committed; int committed;
xfs_fileoff_t first_fsb; xfs_fileoff_t first_fsb;
xfs_filblks_t fs_blocks; xfs_filblks_t fs_blocks;
...@@ -224,7 +223,6 @@ xfs_symlink( ...@@ -224,7 +223,6 @@ xfs_symlink(
return error; return error;
tp = xfs_trans_alloc(mp, XFS_TRANS_SYMLINK); tp = xfs_trans_alloc(mp, XFS_TRANS_SYMLINK);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
/* /*
* The symlink will fit into the inode data fork? * The symlink will fit into the inode data fork?
* There can't be any attributes so we get the whole variable part. * There can't be any attributes so we get the whole variable part.
...@@ -239,10 +237,8 @@ xfs_symlink( ...@@ -239,10 +237,8 @@ xfs_symlink(
resblks = 0; resblks = 0;
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, 0, 0);
} }
if (error) { if (error)
cancel_flags = 0;
goto out_trans_cancel; goto out_trans_cancel;
}
xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
unlock_dp_on_error = true; unlock_dp_on_error = true;
...@@ -407,9 +403,8 @@ xfs_symlink( ...@@ -407,9 +403,8 @@ xfs_symlink(
out_bmap_cancel: out_bmap_cancel:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
cancel_flags |= XFS_TRANS_ABORT;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp);
out_release_inode: out_release_inode:
/* /*
* Wait until after the current transaction is aborted to finish the * Wait until after the current transaction is aborted to finish the
...@@ -464,7 +459,7 @@ xfs_inactive_symlink_rmt( ...@@ -464,7 +459,7 @@ xfs_inactive_symlink_rmt(
tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
if (error) { if (error) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -552,7 +547,7 @@ xfs_inactive_symlink_rmt( ...@@ -552,7 +547,7 @@ xfs_inactive_symlink_rmt(
error_bmap_cancel: error_bmap_cancel:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
error_trans_cancel: error_trans_cancel:
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); xfs_trans_cancel(tp);
error_unlock: error_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
......
...@@ -986,29 +986,22 @@ xfs_trans_commit( ...@@ -986,29 +986,22 @@ xfs_trans_commit(
*/ */
void void
xfs_trans_cancel( xfs_trans_cancel(
xfs_trans_t *tp, struct xfs_trans *tp)
int flags)
{ {
int log_flags; struct xfs_mount *mp = tp->t_mountp;
xfs_mount_t *mp = tp->t_mountp; bool dirty = (tp->t_flags & XFS_TRANS_DIRTY);
/*
* See if the caller is being too lazy to figure out if
* the transaction really needs an abort.
*/
if ((flags & XFS_TRANS_ABORT) && !(tp->t_flags & XFS_TRANS_DIRTY))
flags &= ~XFS_TRANS_ABORT;
/* /*
* See if the caller is relying on us to shut down the * See if the caller is relying on us to shut down the
* filesystem. This happens in paths where we detect * filesystem. This happens in paths where we detect
* corruption and decide to give up. * corruption and decide to give up.
*/ */
if ((tp->t_flags & XFS_TRANS_DIRTY) && !XFS_FORCED_SHUTDOWN(mp)) { if (dirty && !XFS_FORCED_SHUTDOWN(mp)) {
XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
} }
#ifdef DEBUG #ifdef DEBUG
if (!(flags & XFS_TRANS_ABORT) && !XFS_FORCED_SHUTDOWN(mp)) { if (!dirty && !XFS_FORCED_SHUTDOWN(mp)) {
struct xfs_log_item_desc *lidp; struct xfs_log_item_desc *lidp;
list_for_each_entry(lidp, &tp->t_items, lid_trans) list_for_each_entry(lidp, &tp->t_items, lid_trans)
...@@ -1019,19 +1012,17 @@ xfs_trans_cancel( ...@@ -1019,19 +1012,17 @@ xfs_trans_cancel(
xfs_trans_unreserve_and_mod_dquots(tp); xfs_trans_unreserve_and_mod_dquots(tp);
if (tp->t_ticket) { if (tp->t_ticket) {
if (flags & XFS_TRANS_RELEASE_LOG_RES) { uint log_flags = 0;
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
if (tp->t_flags & XFS_TRANS_PERM_LOG_RES)
log_flags = XFS_LOG_REL_PERM_RESERV; log_flags = XFS_LOG_REL_PERM_RESERV;
} else {
log_flags = 0;
}
xfs_log_done(mp, tp->t_ticket, NULL, log_flags); xfs_log_done(mp, tp->t_ticket, NULL, log_flags);
} }
/* mark this thread as no longer being in a transaction */ /* mark this thread as no longer being in a transaction */
current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
xfs_trans_free_items(tp, NULLCOMMITLSN, flags & XFS_TRANS_ABORT); xfs_trans_free_items(tp, NULLCOMMITLSN, dirty);
xfs_trans_free(tp); xfs_trans_free(tp);
} }
......
...@@ -227,7 +227,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *, ...@@ -227,7 +227,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *,
xfs_extlen_t); xfs_extlen_t);
int xfs_trans_commit(xfs_trans_t *, uint flags); int xfs_trans_commit(xfs_trans_t *, uint flags);
int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *); int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
void xfs_trans_cancel(xfs_trans_t *, int); void xfs_trans_cancel(xfs_trans_t *);
int xfs_trans_ail_init(struct xfs_mount *); int xfs_trans_ail_init(struct xfs_mount *);
void xfs_trans_ail_destroy(struct xfs_mount *); void xfs_trans_ail_destroy(struct xfs_mount *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment