Commit 70393313 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: saner xfs_trans_commit interface

The flags argument to xfs_trans_commit is not useful for most callers, as
a commit of a transaction without a permanent log reservation must pass
0 here, and all callers for a transaction with a permanent log reservation
except for xfs_trans_roll must pass XFS_TRANS_RELEASE_LOG_RES.  So remove
the flags argument from the public xfs_trans_commit interfaces, and
introduce low-level __xfs_trans_commit variant just for xfs_trans_roll
that regrants a log reservation instead of releasing it.
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 4906e215
...@@ -320,8 +320,7 @@ xfs_attr_set( ...@@ -320,8 +320,7 @@ xfs_attr_set(
xfs_trans_ichgtime(args.trans, dp, xfs_trans_ichgtime(args.trans, dp,
XFS_ICHGTIME_CHG); XFS_ICHGTIME_CHG);
} }
err2 = xfs_trans_commit(args.trans, err2 = xfs_trans_commit(args.trans);
XFS_TRANS_RELEASE_LOG_RES);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error ? error : err2; return error ? error : err2;
...@@ -383,7 +382,7 @@ xfs_attr_set( ...@@ -383,7 +382,7 @@ xfs_attr_set(
* Commit the last in the sequence of transactions. * Commit the last in the sequence of transactions.
*/ */
xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE); xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE);
error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(args.trans);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error; return error;
...@@ -499,7 +498,7 @@ xfs_attr_remove( ...@@ -499,7 +498,7 @@ xfs_attr_remove(
* Commit the last in the sequence of transactions. * Commit the last in the sequence of transactions.
*/ */
xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE); xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE);
error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(args.trans);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error; return error;
......
...@@ -1215,7 +1215,7 @@ xfs_bmap_add_attrfork( ...@@ -1215,7 +1215,7 @@ xfs_bmap_add_attrfork(
error = xfs_bmap_finish(&tp, &flist, &committed); error = xfs_bmap_finish(&tp, &flist, &committed);
if (error) if (error)
goto bmap_cancel; goto bmap_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
...@@ -5926,8 +5926,7 @@ xfs_bmap_split_extent( ...@@ -5926,8 +5926,7 @@ xfs_bmap_split_extent(
if (error) if (error)
goto out; goto out;
return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); return xfs_trans_commit(tp);
out: out:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
......
...@@ -799,5 +799,5 @@ xfs_sync_sb( ...@@ -799,5 +799,5 @@ xfs_sync_sb(
xfs_log_sb(tp); xfs_log_sb(tp);
if (wait) if (wait)
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
return xfs_trans_commit(tp, 0); return xfs_trans_commit(tp);
} }
...@@ -181,11 +181,6 @@ int xfs_log_calc_minimum_size(struct xfs_mount *); ...@@ -181,11 +181,6 @@ int xfs_log_calc_minimum_size(struct xfs_mount *);
#define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */ #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
#define XFS_TRANS_FREEZE_PROT 0x40 /* Transaction has elevated writer #define XFS_TRANS_FREEZE_PROT 0x40 /* Transaction has elevated writer
count in superblock */ count in superblock */
/*
* Values for call flags parameter.
*/
#define XFS_TRANS_RELEASE_LOG_RES 0x4
/* /*
* Field values for xfs_trans_mod_sb. * Field values for xfs_trans_mod_sb.
*/ */
......
...@@ -155,7 +155,7 @@ xfs_setfilesize( ...@@ -155,7 +155,7 @@ xfs_setfilesize(
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
return xfs_trans_commit(tp, 0); return xfs_trans_commit(tp);
} }
STATIC int STATIC int
......
...@@ -438,7 +438,7 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -438,7 +438,7 @@ xfs_attr_inactive(xfs_inode_t *dp)
if (error) if (error)
goto out; goto out;
error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(trans);
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
return error; return error;
......
...@@ -893,8 +893,7 @@ xfs_free_eofblocks( ...@@ -893,8 +893,7 @@ xfs_free_eofblocks(
*/ */
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
} else { } else {
error = xfs_trans_commit(tp, error = xfs_trans_commit(tp);
XFS_TRANS_RELEASE_LOG_RES);
if (!error) if (!error)
xfs_inode_clear_eofblocks_tag(ip); xfs_inode_clear_eofblocks_tag(ip);
} }
...@@ -1034,7 +1033,7 @@ xfs_alloc_file_space( ...@@ -1034,7 +1033,7 @@ xfs_alloc_file_space(
goto error0; goto error0;
} }
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error) { if (error) {
break; break;
...@@ -1301,7 +1300,7 @@ xfs_free_file_space( ...@@ -1301,7 +1300,7 @@ xfs_free_file_space(
goto error0; goto error0;
} }
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
} }
...@@ -1473,7 +1472,7 @@ xfs_shift_file_space( ...@@ -1473,7 +1472,7 @@ xfs_shift_file_space(
if (error) if (error)
goto out; goto out;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
} }
return error; return error;
...@@ -1882,7 +1881,7 @@ xfs_swap_extents( ...@@ -1882,7 +1881,7 @@ xfs_swap_extents(
if (mp->m_flags & XFS_MOUNT_WSYNC) if (mp->m_flags & XFS_MOUNT_WSYNC)
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
trace_xfs_swap_extent_after(ip, 0); trace_xfs_swap_extent_after(ip, 0);
trace_xfs_swap_extent_after(tip, 1); trace_xfs_swap_extent_after(tip, 1);
......
...@@ -666,7 +666,7 @@ xfs_qm_dqread( ...@@ -666,7 +666,7 @@ xfs_qm_dqread(
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
if (tp) { if (tp) {
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto error0; goto error0;
} }
......
...@@ -160,7 +160,7 @@ xfs_update_prealloc_flags( ...@@ -160,7 +160,7 @@ xfs_update_prealloc_flags(
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
if (flags & XFS_PREALLOC_SYNC) if (flags & XFS_PREALLOC_SYNC)
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
return xfs_trans_commit(tp, 0); return xfs_trans_commit(tp);
} }
/* /*
......
...@@ -489,7 +489,7 @@ xfs_growfs_data_private( ...@@ -489,7 +489,7 @@ xfs_growfs_data_private(
if (dpct) if (dpct)
xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct); xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct);
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
if (error) if (error)
return error; return error;
......
...@@ -1230,7 +1230,7 @@ xfs_create( ...@@ -1230,7 +1230,7 @@ xfs_create(
if (error) if (error)
goto out_bmap_cancel; goto out_bmap_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_release_inode; goto out_release_inode;
...@@ -1339,7 +1339,7 @@ xfs_create_tmpfile( ...@@ -1339,7 +1339,7 @@ xfs_create_tmpfile(
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_release_inode; goto out_release_inode;
...@@ -1465,7 +1465,7 @@ xfs_link( ...@@ -1465,7 +1465,7 @@ xfs_link(
goto error_return; goto error_return;
} }
return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); return xfs_trans_commit(tp);
error_return: error_return:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
...@@ -1702,7 +1702,7 @@ xfs_inactive_truncate( ...@@ -1702,7 +1702,7 @@ xfs_inactive_truncate(
ASSERT(ip->i_d.di_nextents == 0); ASSERT(ip->i_d.di_nextents == 0);
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto error_unlock; goto error_unlock;
...@@ -1799,7 +1799,7 @@ xfs_inactive_ifree( ...@@ -1799,7 +1799,7 @@ xfs_inactive_ifree(
if (error) if (error)
xfs_notice(mp, "%s: xfs_bmap_finish returned error %d", xfs_notice(mp, "%s: xfs_bmap_finish returned error %d",
__func__, error); __func__, error);
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
xfs_notice(mp, "%s: xfs_trans_commit returned error %d", xfs_notice(mp, "%s: xfs_trans_commit returned error %d",
__func__, error); __func__, error);
...@@ -2569,7 +2569,7 @@ xfs_remove( ...@@ -2569,7 +2569,7 @@ xfs_remove(
if (error) if (error)
goto out_bmap_cancel; goto out_bmap_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto std_return; goto std_return;
...@@ -2659,7 +2659,7 @@ xfs_finish_rename( ...@@ -2659,7 +2659,7 @@ xfs_finish_rename(
return error; return error;
} }
return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); return xfs_trans_commit(tp);
} }
/* /*
......
...@@ -346,7 +346,7 @@ xfs_set_dmattrs( ...@@ -346,7 +346,7 @@ xfs_set_dmattrs(
ip->i_d.di_dmstate = state; ip->i_d.di_dmstate = state;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
return error; return error;
} }
...@@ -1253,7 +1253,7 @@ xfs_ioctl_setattr( ...@@ -1253,7 +1253,7 @@ xfs_ioctl_setattr(
else else
ip->i_d.di_extsize = 0; ip->i_d.di_extsize = 0;
code = xfs_trans_commit(tp, 0); code = xfs_trans_commit(tp);
/* /*
* Release any dquot(s) the inode had kept before chown. * Release any dquot(s) the inode had kept before chown.
...@@ -1342,7 +1342,7 @@ xfs_ioc_setxflags( ...@@ -1342,7 +1342,7 @@ xfs_ioc_setxflags(
goto out_drop_write; goto out_drop_write;
} }
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
out_drop_write: out_drop_write:
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
return error; return error;
......
...@@ -213,7 +213,7 @@ xfs_iomap_write_direct( ...@@ -213,7 +213,7 @@ xfs_iomap_write_direct(
error = xfs_bmap_finish(&tp, &free_list, &committed); error = xfs_bmap_finish(&tp, &free_list, &committed);
if (error) if (error)
goto out_bmap_cancel; goto out_bmap_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_unlock; goto out_unlock;
...@@ -760,7 +760,7 @@ xfs_iomap_write_allocate( ...@@ -760,7 +760,7 @@ xfs_iomap_write_allocate(
if (error) if (error)
goto trans_cancel; goto trans_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto error0; goto error0;
...@@ -890,7 +890,7 @@ xfs_iomap_write_unwritten( ...@@ -890,7 +890,7 @@ xfs_iomap_write_unwritten(
if (error) if (error)
goto error_on_bmapi_transaction; goto error_on_bmapi_transaction;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error) if (error)
return error; return error;
......
...@@ -702,7 +702,7 @@ xfs_setattr_nonsize( ...@@ -702,7 +702,7 @@ xfs_setattr_nonsize(
if (mp->m_flags & XFS_MOUNT_WSYNC) if (mp->m_flags & XFS_MOUNT_WSYNC)
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
...@@ -926,7 +926,7 @@ xfs_setattr_size( ...@@ -926,7 +926,7 @@ xfs_setattr_size(
if (mp->m_flags & XFS_MOUNT_WSYNC) if (mp->m_flags & XFS_MOUNT_WSYNC)
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
out_unlock: out_unlock:
if (lock_flags) if (lock_flags)
xfs_iunlock(ip, lock_flags); xfs_iunlock(ip, lock_flags);
...@@ -1002,7 +1002,7 @@ xfs_vn_update_time( ...@@ -1002,7 +1002,7 @@ xfs_vn_update_time(
} }
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP); xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
return xfs_trans_commit(tp, 0); return xfs_trans_commit(tp);
} }
#define XFS_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC|FIEMAP_FLAG_XATTR) #define XFS_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC|FIEMAP_FLAG_XATTR)
......
...@@ -183,7 +183,7 @@ struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket); ...@@ -183,7 +183,7 @@ struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket);
void xfs_log_ticket_put(struct xlog_ticket *ticket); void xfs_log_ticket_put(struct xlog_ticket *ticket);
void xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp, void xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_lsn_t *commit_lsn, int flags); xfs_lsn_t *commit_lsn, bool regrant);
bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip); bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
void xfs_log_work_queue(struct xfs_mount *mp); void xfs_log_work_queue(struct xfs_mount *mp);
......
...@@ -773,13 +773,13 @@ xfs_log_commit_cil( ...@@ -773,13 +773,13 @@ xfs_log_commit_cil(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_lsn_t *commit_lsn, xfs_lsn_t *commit_lsn,
int flags) bool regrant)
{ {
struct xlog *log = mp->m_log; struct xlog *log = mp->m_log;
struct xfs_cil *cil = log->l_cilp; struct xfs_cil *cil = log->l_cilp;
int log_flags = 0; int log_flags = 0;
if (flags & XFS_TRANS_RELEASE_LOG_RES) if (!regrant)
log_flags = XFS_LOG_REL_PERM_RESERV; log_flags = XFS_LOG_REL_PERM_RESERV;
/* lock out background commit */ /* lock out background commit */
......
...@@ -3751,7 +3751,7 @@ xlog_recover_process_efi( ...@@ -3751,7 +3751,7 @@ xlog_recover_process_efi(
} }
set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); set_bit(XFS_EFI_RECOVERED, &efip->efi_flags);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
return error; return error;
abort_error: abort_error:
...@@ -3857,7 +3857,7 @@ xlog_recover_clear_agi_bucket( ...@@ -3857,7 +3857,7 @@ xlog_recover_clear_agi_bucket(
xfs_trans_log_buf(tp, agibp, offset, xfs_trans_log_buf(tp, agibp, offset,
(offset + sizeof(xfs_agino_t) - 1)); (offset + sizeof(xfs_agino_t) - 1));
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_error; goto out_error;
return; return;
......
...@@ -321,7 +321,7 @@ xfs_fs_commit_blocks( ...@@ -321,7 +321,7 @@ xfs_fs_commit_blocks(
} }
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
out_drop_iolock: out_drop_iolock:
xfs_iunlock(ip, XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_IOLOCK_EXCL);
......
...@@ -795,7 +795,7 @@ xfs_qm_qino_alloc( ...@@ -795,7 +795,7 @@ xfs_qm_qino_alloc(
spin_unlock(&mp->m_sb_lock); spin_unlock(&mp->m_sb_lock);
xfs_log_sb(tp); xfs_log_sb(tp);
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) { if (error) {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
xfs_alert(mp, "%s failed (error %d)!", __func__, error); xfs_alert(mp, "%s failed (error %d)!", __func__, error);
......
...@@ -259,7 +259,7 @@ xfs_qm_scall_trunc_qfile( ...@@ -259,7 +259,7 @@ xfs_qm_scall_trunc_qfile(
ASSERT(ip->i_d.di_nextents == 0); ASSERT(ip->i_d.di_nextents == 0);
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
out_unlock: out_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
...@@ -547,7 +547,7 @@ xfs_qm_scall_setqlim( ...@@ -547,7 +547,7 @@ xfs_qm_scall_setqlim(
dqp->dq_flags |= XFS_DQ_DIRTY; dqp->dq_flags |= XFS_DQ_DIRTY;
xfs_trans_log_dquot(tp, dqp); xfs_trans_log_dquot(tp, dqp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
out_rele: out_rele:
xfs_qm_dqrele(dqp); xfs_qm_dqrele(dqp);
...@@ -584,8 +584,7 @@ xfs_qm_log_quotaoff_end( ...@@ -584,8 +584,7 @@ xfs_qm_log_quotaoff_end(
* We don't care about quotoff's performance. * We don't care about quotoff's performance.
*/ */
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); return xfs_trans_commit(tp);
return error;
} }
...@@ -623,7 +622,7 @@ xfs_qm_log_quotaoff( ...@@ -623,7 +622,7 @@ xfs_qm_log_quotaoff(
* We don't care about quotoff's performance. * We don't care about quotoff's performance.
*/ */
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
if (error) if (error)
goto out; goto out;
......
...@@ -815,7 +815,7 @@ xfs_growfs_rt_alloc( ...@@ -815,7 +815,7 @@ xfs_growfs_rt_alloc(
error = xfs_bmap_finish(&tp, &flist, &committed); error = xfs_bmap_finish(&tp, &flist, &committed);
if (error) if (error)
goto error_cancel; goto error_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto error; goto error;
/* /*
...@@ -855,7 +855,7 @@ xfs_growfs_rt_alloc( ...@@ -855,7 +855,7 @@ xfs_growfs_rt_alloc(
/* /*
* Commit the transaction. * Commit the transaction.
*/ */
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
if (error) if (error)
goto error; goto error;
} }
...@@ -1070,7 +1070,7 @@ xfs_growfs_rt( ...@@ -1070,7 +1070,7 @@ xfs_growfs_rt(
mp->m_rsumlevels = nrsumlevels; mp->m_rsumlevels = nrsumlevels;
mp->m_rsumsize = nrsumsize; mp->m_rsumsize = nrsumsize;
error = xfs_trans_commit(tp, 0); error = xfs_trans_commit(tp);
if (error) if (error)
break; break;
} }
......
...@@ -390,7 +390,7 @@ xfs_symlink( ...@@ -390,7 +390,7 @@ xfs_symlink(
if (error) if (error)
goto out_bmap_cancel; goto out_bmap_cancel;
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_release_inode; goto out_release_inode;
...@@ -528,7 +528,7 @@ xfs_inactive_symlink_rmt( ...@@ -528,7 +528,7 @@ xfs_inactive_symlink_rmt(
/* /*
* Commit the transaction containing extent freeing and EFDs. * Commit the transaction containing extent freeing and EFDs.
*/ */
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); error = xfs_trans_commit(tp);
if (error) { if (error) {
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
goto error_unlock; goto error_unlock;
......
...@@ -892,26 +892,16 @@ xfs_trans_committed_bulk( ...@@ -892,26 +892,16 @@ xfs_trans_committed_bulk(
* have already been unlocked as if the commit had succeeded. * have already been unlocked as if the commit had succeeded.
* Do not reference the transaction structure after this call. * Do not reference the transaction structure after this call.
*/ */
int static int
xfs_trans_commit( __xfs_trans_commit(
struct xfs_trans *tp, struct xfs_trans *tp,
uint flags) bool regrant)
{ {
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
xfs_lsn_t commit_lsn = -1; xfs_lsn_t commit_lsn = -1;
int error = 0; int error = 0;
int log_flags = 0;
int sync = tp->t_flags & XFS_TRANS_SYNC; int sync = tp->t_flags & XFS_TRANS_SYNC;
/*
* Determine whether this commit is releasing a permanent
* log reservation or not.
*/
if (flags & XFS_TRANS_RELEASE_LOG_RES) {
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
log_flags = XFS_LOG_REL_PERM_RESERV;
}
/* /*
* If there is nothing to be logged by the transaction, * If there is nothing to be logged by the transaction,
* then unlock all of the items associated with the * then unlock all of the items associated with the
...@@ -936,7 +926,7 @@ xfs_trans_commit( ...@@ -936,7 +926,7 @@ xfs_trans_commit(
xfs_trans_apply_sb_deltas(tp); xfs_trans_apply_sb_deltas(tp);
xfs_trans_apply_dquot_deltas(tp); xfs_trans_apply_dquot_deltas(tp);
xfs_log_commit_cil(mp, tp, &commit_lsn, flags); xfs_log_commit_cil(mp, tp, &commit_lsn, regrant);
current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
xfs_trans_free(tp); xfs_trans_free(tp);
...@@ -964,6 +954,12 @@ xfs_trans_commit( ...@@ -964,6 +954,12 @@ xfs_trans_commit(
*/ */
xfs_trans_unreserve_and_mod_dquots(tp); xfs_trans_unreserve_and_mod_dquots(tp);
if (tp->t_ticket) { if (tp->t_ticket) {
int log_flags = 0;
if (regrant)
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
else
log_flags = XFS_LOG_REL_PERM_RESERV;
commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags); commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags);
if (commit_lsn == -1 && !error) if (commit_lsn == -1 && !error)
error = -EIO; error = -EIO;
...@@ -976,6 +972,13 @@ xfs_trans_commit( ...@@ -976,6 +972,13 @@ xfs_trans_commit(
return error; return error;
} }
int
xfs_trans_commit(
struct xfs_trans *tp)
{
return __xfs_trans_commit(tp, false);
}
/* /*
* Unlock all of the transaction's items and free the transaction. * Unlock all of the transaction's items and free the transaction.
* The transaction must not have modified any of its items, because * The transaction must not have modified any of its items, because
...@@ -1029,7 +1032,7 @@ xfs_trans_cancel( ...@@ -1029,7 +1032,7 @@ xfs_trans_cancel(
/* /*
* Roll from one trans in the sequence of PERMANENT transactions to * Roll from one trans in the sequence of PERMANENT transactions to
* the next: permanent transactions are only flushed out when * the next: permanent transactions are only flushed out when
* committed with XFS_TRANS_RELEASE_LOG_RES, but we still want as soon * committed with xfs_trans_commit(), but we still want as soon
* as possible to let chunks of it go to the log. So we commit the * as possible to let chunks of it go to the log. So we commit the
* chunk we've been working on and get a new transaction to continue. * chunk we've been working on and get a new transaction to continue.
*/ */
...@@ -1063,7 +1066,7 @@ xfs_trans_roll( ...@@ -1063,7 +1066,7 @@ xfs_trans_roll(
* is in progress. The caller takes the responsibility to cancel * is in progress. The caller takes the responsibility to cancel
* the duplicate transaction that gets returned. * the duplicate transaction that gets returned.
*/ */
error = xfs_trans_commit(trans, 0); error = __xfs_trans_commit(trans, true);
if (error) if (error)
return error; return error;
......
...@@ -225,7 +225,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *, ...@@ -225,7 +225,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *,
struct xfs_efd_log_item *, struct xfs_efd_log_item *,
xfs_fsblock_t, xfs_fsblock_t,
xfs_extlen_t); xfs_extlen_t);
int xfs_trans_commit(xfs_trans_t *, uint flags); int xfs_trans_commit(struct xfs_trans *);
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 *); void xfs_trans_cancel(xfs_trans_t *);
int xfs_trans_ail_init(struct xfs_mount *); int xfs_trans_ail_init(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