simplify transaction commit and cancel interfaces V2
Changes since V1:
- rebased to todays for-next branch
- fix the inverted regrant logic in path 4
(the full series was already corrent in the previous version)
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/5 xfs: switch remaining xfs_trans_dup users to xfs_trans_roll
We have three remaining callers of xfs_trans_dup:
- xfs_itruncate_extents which open codes xfs_trans_roll
- xfs_bmap_finish doesn't have an xfs_inode argument and thus leaves attaching them to it's callers, but otherwise is identical to xfs_trans_roll
- xfs_dir_ialloc looks at the log reservations in the old xfs_trans structure instead of the log reservation parameters, but otherwise is identical to xfs_trans_roll.
By allowing a NULL xfs_inode argument to xfs_trans_roll we can switch these three remaining users over to xfs_trans_roll and mark xfs_trans_dup static.
--- fs/xfs/xfs_bmap_util.c | 31 ++++++------------------ fs/xfs/xfs_inode.c | 66 +++----------------------------------------------- fs/xfs/xfs_trans.c | 8 +++--- fs/xfs/xfs_trans.h | 3 --- 4 files changed, 16 insertions(+), 92 deletions(-)
fs/xfs/xfs_bmap_util.c +7 -24
@@ -75,28 +75,20 @@ xfs_bmap_finish(xfs_efi_log_item_t *efi;/* extent free intention */ int error;/* error return value */ xfs_bmap_free_item_t *free;/* free extent item */ -struct xfs_trans_res tres;/* new log reservation */ xfs_mount_t *mp;/* filesystem mount structure */ xfs_bmap_free_item_t *next;/* next item on free list */ -xfs_trans_t *ntp;/* new transaction pointer */ ASSERT ((*tp)->t_flags &XFS_TRANS_PERM_LOG_RES );if (flist->xbf_count ==0 ) { *committed =0 ;return 0 ; } - ntp = *tp; - efi =xfs_trans_get_efi (ntp, flist->xbf_count); + efi =xfs_trans_get_efi (*tp, flist->xbf_count);for (free = flist->xbf_first; free; free = free->xbfi_next) -xfs_trans_log_efi_extent (ntp, efi, free->xbfi_startblock, +xfs_trans_log_efi_extent (*tp, efi, free->xbfi_startblock, free->xbfi_blockcount); - tres.tr_logres = ntp->t_log_res; - tres.tr_logcount = ntp->t_log_count; - tres.tr_logflags =XFS_TRANS_PERM_LOG_RES ; - ntp =xfs_trans_dup (*tp); - error =xfs_trans_commit (*tp,0 ); - *tp = ntp; + error =xfs_trans_roll (tp,NULL ); *committed =1 ;/* * We have a new transaction, so we should return committed=1,
@@ -105,19 +97,10 @@ xfs_bmap_finish(if (error)return error; -/* -* transaction commit worked ok so we can drop the extra ticket -* reference that we gained in xfs_trans_dup() -*/ -xfs_log_ticket_put (ntp->t_ticket); - - error =xfs_trans_reserve (ntp, &tres,0 ,0 ); -if (error) -return error; - efd =xfs_trans_get_efd (ntp, efi, flist->xbf_count); + efd =xfs_trans_get_efd (*tp, efi, flist->xbf_count);for (free = flist->xbf_first; free !=NULL ; free = next) { next = free->xbfi_next; -if ((error =xfs_free_extent (ntp, free->xbfi_startblock, +if ((error =xfs_free_extent (*tp, free->xbfi_startblock, free->xbfi_blockcount))) {/* * The bmap free list will be cleaned up at a
@@ -127,7 +110,7 @@ xfs_bmap_finish(* happens, since this transaction may not be * dirty yet. */ - mp = ntp->t_mountp; + mp = (*tp)->t_mountp;if (!XFS_FORCED_SHUTDOWN (mp)) xfs_force_shutdown(mp, (error == -EFSCORRUPTED) ?
@@ -135,7 +118,7 @@ xfs_bmap_finish( SHUTDOWN_META_IO_ERROR);return error; } -xfs_trans_log_efd_extent (ntp, efd, free->xbfi_startblock, +xfs_trans_log_efd_extent (*tp, efd, free->xbfi_startblock, free->xbfi_blockcount);xfs_bmap_del_free (flist,NULL , free); }
fs/xfs/xfs_inode.c +4 -62
109 lines not on this page · raw message
fs/xfs/xfs_trans.c +5 -3
@@ -113,7 +113,7 @@ xfs_trans_free(* blocks. Locks and log items, however, are no inherited. They must * be added to the new transaction explicitly. */ -xfs_trans_t * +STATIC xfs_trans_t *xfs_trans_dup (xfs_trans_t *tp) {
@@ -1055,7 +1055,8 @@ xfs_trans_roll(* Ensure that the inode is always logged. */ trans = *tpp; -xfs_trans_log_inode (trans, dp,XFS_ILOG_CORE ); +if (dp) +xfs_trans_log_inode (trans, dp,XFS_ILOG_CORE );/* * Copy the critical parameters from one trans to the next.
@@ -1100,6 +1101,7 @@ xfs_trans_roll(if (error)return error; -xfs_trans_ijoin (trans, dp,0 ); +if (dp) +xfs_trans_ijoin (trans, dp,0 );return 0 ; }
fs/xfs/xfs_trans.h +0 -3
@@ -133,8 +133,6 @@ typedef struct xfs_trans {* XFS transaction mechanism exported interfaces that are * actually macros. */ -#define xfs_trans_get_log_res (tp) ((tp)->t_log_res) -#define xfs_trans_get_log_count (tp) ((tp)->t_log_count)#define xfs_trans_get_block_res (tp) ((tp)->t_blk_res)#define xfs_trans_set_sync (tp) ((tp)->t_flags |= XFS_TRANS_SYNC)
@@ -153,7 +151,6 @@ typedef struct xfs_trans {*/ xfs_trans_t *xfs_trans_alloc (struct xfs_mount *,uint );xfs_trans_t *_xfs_trans_alloc (struct xfs_mount *,uint ,xfs_km_flags_t ); -xfs_trans_t *xfs_trans_dup (xfs_trans_t *);int xfs_trans_reserve (struct xfs_trans *,struct xfs_trans_res *,uint ,uint );void xfs_trans_mod_sb (xfs_trans_t *,uint ,int64_t );
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/5 xfs: pass a boolean flag to xfs_trans_free_items
In reply to Christoph HellwigThe flags value always was 0 or XFS_TRANS_ABORT. Switch to a bool parameter to allow further cleanups.
--- fs/xfs/xfs_log_cil.c | 2 +- fs/xfs/xfs_trans.c | 8 ++++---- fs/xfs/xfs_trans_priv.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
fs/xfs/xfs_log_cil.c +1 -1
@@ -809,7 +809,7 @@ xfs_log_commit_cil(* the log items. This affects (at least) processing of stale buffers, * inodes and EFIs. */ -xfs_trans_free_items (tp, tp->t_commit_lsn,0 ); +xfs_trans_free_items (tp, tp->t_commit_lsn, false);xlog_cil_push_background (log);
fs/xfs/xfs_trans.c +4 -4
@@ -744,7 +744,7 @@ voidxfs_trans_free_items ( struct xfs_trans *tp, xfs_lsn_t commit_lsn, - int flags) + bool abort) { struct xfs_log_item_desc *lidp, *next;
@@ -755,7 +755,7 @@ xfs_trans_free_items(if (commit_lsn !=NULLCOMMITLSN ) lip->li_ops->iop_committing (lip, commit_lsn); -if (flags &XFS_TRANS_ABORT ) +if (abort) lip->li_flags |=XFS_LI_ABORTED ; lip->li_ops->iop_unlock (lip);
@@ -969,7 +969,7 @@ out_unreserve: error = -EIO ; }current_restore_flags_nested (&tp->t_pflags,PF_FSTRANS ); -xfs_trans_free_items (tp,NULLCOMMITLSN , error ?XFS_TRANS_ABORT :0 ); +xfs_trans_free_items (tp,NULLCOMMITLSN , !!error);xfs_trans_free (tp);XFS_STATS_INC (xs_trans_empty);
@@ -1031,7 +1031,7 @@ xfs_trans_cancel(/* mark this thread as no longer being in a transaction */ current_restore_flags_nested (&tp->t_pflags,PF_FSTRANS ); -xfs_trans_free_items (tp,NULLCOMMITLSN , flags); +xfs_trans_free_items (tp,NULLCOMMITLSN , flags &XFS_TRANS_ABORT );xfs_trans_free (tp); }
fs/xfs/xfs_trans_priv.h +1 -1
@@ -30,7 +30,7 @@ void xfs_trans_init(struct xfs_mount *);void xfs_trans_add_item (struct xfs_trans *,struct xfs_log_item *);void xfs_trans_del_item (struct xfs_log_item *);void xfs_trans_free_items (struct xfs_trans *tp,xfs_lsn_t commit_lsn, -int flags); +bool abort);void xfs_trans_unreserve_and_mod_sb (struct xfs_trans *tp); void xfs_trans_committed_bulk(struct xfs_ail *ailp, struct xfs_log_vec *lv,
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/5 xfs: remove the flags argument to xfs_trans_cancel
In reply to Christoph Hellwigxfs_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.
--- fs/xfs/libxfs/xfs_attr.c | 18 ++++----- fs/xfs/libxfs/xfs_bmap.c | 11 ++---- fs/xfs/libxfs/xfs_sb.c | 2 +- fs/xfs/libxfs/xfs_shared.h | 1 - fs/xfs/xfs_aops.c | 4 +- fs/xfs/xfs_attr_inactive.c | 4 +- fs/xfs/xfs_bmap_util.c | 24 ++++++------ fs/xfs/xfs_dquot.c | 6 +-- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_fsops.c | 4 +- fs/xfs/xfs_inode.c | 93 ++++++++++++++++------------------------------ fs/xfs/xfs_ioctl.c | 8 ++-- fs/xfs/xfs_iomap.c | 12 +++--- fs/xfs/xfs_iops.c | 12 ++---- fs/xfs/xfs_log_recover.c | 4 +- fs/xfs/xfs_pnfs.c | 2 +- fs/xfs/xfs_qm.c | 5 +-- fs/xfs/xfs_qm_syscalls.c | 11 +++--- fs/xfs/xfs_rtalloc.c | 10 +---- fs/xfs/xfs_symlink.c | 13 ++----- fs/xfs/xfs_trans.c | 27 +++++--------- fs/xfs/xfs_trans.h | 2 +- 22 files changed, 103 insertions(+), 172 deletions(-)
fs/xfs/libxfs/xfs_attr.c +7 -11
@@ -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; }
fs/xfs/libxfs/xfs_bmap.c +4 -7
@@ -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; }
@@ -5926,7 +5923,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; }
@@ -5948,6 +5945,6 @@ xfs_bmap_split_extent( out: -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);return error; }
fs/xfs/libxfs/xfs_sb.c +1 -1
@@ -818,7 +818,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; }
fs/xfs/libxfs/xfs_shared.h +0 -1
@@ -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.
fs/xfs/xfs_aops.c +2 -2
@@ -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 ; }
fs/xfs/xfs_attr_inactive.c +1 -3
@@ -394,7 +394,6 @@ xfs_attr_inactive( {struct xfs_trans *trans;struct xfs_mount *mp; -int cancel_flags =0 ;int lock_mode =XFS_ILOCK_SHARED ;int error =0 ;
@@ -423,7 +422,6 @@ xfs_attr_inactive( goto out_cancel; lock_mode =XFS_ILOCK_EXCL ; - cancel_flags =XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ;xfs_ilock (dp, lock_mode);if (!XFS_IFORK_Q (dp))
@@ -454,7 +452,7 @@ xfs_attr_inactive(return error; out_cancel: -xfs_trans_cancel (trans, cancel_flags); +xfs_trans_cancel (trans); out_destroy_fork:/* kill the in-core attr fork before we drop the inode lock */ if (dp->i_afp)
fs/xfs/xfs_bmap_util.c +11 -13
@@ -861,7 +861,7 @@ xfs_free_eofblocks(if (need_iolock) {if (!xfs_ilock_nowait (ip,XFS_IOLOCK_EXCL )) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return -EAGAIN ; } }
@@ -869,7 +869,7 @@ xfs_free_eofblocks( error =xfs_trans_reserve (tp, &M_RES (mp)->tr_itruncate,0 ,0 );if (error) {ASSERT (XFS_FORCED_SHUTDOWN (mp)); -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);if (need_iolock)xfs_iunlock (ip,XFS_IOLOCK_EXCL );return error;
@@ -891,9 +891,7 @@ xfs_free_eofblocks(* If we get an error at this point we simply don't * bother truncating the file. */ -xfs_trans_cancel (tp, - (XFS_TRANS_RELEASE_LOG_RES | -XFS_TRANS_ABORT )); +xfs_trans_cancel (tp); }else { error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES );
@@ -1009,7 +1007,7 @@ xfs_alloc_file_space(* Free the transaction structure. */ ASSERT (error == -ENOSPC ||XFS_FORCED_SHUTDOWN (mp)); -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);break ; }xfs_ilock (ip,XFS_ILOCK_EXCL );
@@ -1060,7 +1058,7 @@ error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */xfs_trans_unreserve_quota_nblks (tp, ip, (long )qblocks,0 , quota_flag); 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 );return error; }
@@ -1272,7 +1270,7 @@ xfs_free_file_space(* Free the transaction structure. */ ASSERT (error == -ENOSPC ||XFS_FORCED_SHUTDOWN (mp)); -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);break ; }xfs_ilock (ip,XFS_ILOCK_EXCL );
@@ -1313,7 +1311,7 @@ xfs_free_file_space( error0:xfs_bmap_cancel (&free_list); error1: -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL ); goto out; }
@@ -1445,7 +1443,7 @@ xfs_shift_file_space( 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);break ; }
@@ -1481,7 +1479,7 @@ xfs_shift_file_space(return error; out: -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);return error; }
@@ -1701,7 +1699,7 @@ xfs_swap_extents( tp =xfs_trans_alloc (mp,XFS_TRANS_SWAPEXT ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_ichange,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); goto out_unlock; }
@@ -1898,6 +1896,6 @@ out_unlock: goto out; out_trans_cancel: -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); goto out; }
fs/xfs/xfs_dquot.c +1 -5
@@ -568,8 +568,6 @@ xfs_qm_dqread(struct xfs_buf *bp;struct xfs_trans *tp =NULL ;int error; -int cancelflags =0 ; - dqp =kmem_zone_zalloc (xfs_qm_dqzone,KM_SLEEP );
@@ -617,7 +615,6 @@ xfs_qm_dqread( XFS_QM_DQALLOC_SPACE_RES(mp), 0);if (error) goto error1; - cancelflags =XFS_TRANS_RELEASE_LOG_RES ; }/*
@@ -632,7 +629,6 @@ xfs_qm_dqread(* allocate (ENOENT). */ trace_xfs_dqread_fail (dqp); - cancelflags |=XFS_TRANS_ABORT ; goto error1; }
@@ -680,7 +676,7 @@ xfs_qm_dqread( error1:if (tp) -xfs_trans_cancel (tp, cancelflags); +xfs_trans_cancel (tp); error0:xfs_qm_dqdestroy (dqp); *O_dqpp =NULL ;
fs/xfs/xfs_file.c +1 -1
@@ -138,7 +138,7 @@ xfs_update_prealloc_flags( tp =xfs_trans_alloc (ip->i_mount,XFS_TRANS_WRITEID ); error =xfs_trans_reserve (tp, &M_RES (ip->i_mount)->tr_writeid,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
fs/xfs/xfs_fsops.c +2 -2
@@ -203,7 +203,7 @@ xfs_growfs_data_private( error =xfs_trans_reserve (tp, &M_RES (mp)->tr_growdata,XFS_GROWFS_SPACE_RES (mp),0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
@@ -559,7 +559,7 @@ xfs_growfs_data_private(return saved_error ? saved_error : error; error0: -xfs_trans_cancel (tp,XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);return error; }
fs/xfs/xfs_inode.c +33 -60
353 lines not on this page · raw message
fs/xfs/xfs_ioctl.c +4 -4
@@ -336,7 +336,7 @@ xfs_set_dmattrs( tp =xfs_trans_alloc (mp,XFS_TRANS_SET_DMATTRS ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_ichange,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }xfs_ilock (ip,XFS_ILOCK_EXCL );
@@ -1076,7 +1076,7 @@ xfs_ioctl_setattr_get_trans(return tp; out_cancel: -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return ERR_PTR (error); }
@@ -1265,7 +1265,7 @@ xfs_ioctl_setattr(return code; error_trans_cancel: -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); error_free_dquots:xfs_qm_dqrele (udqp);xfs_qm_dqrele (pdqp);
@@ -1338,7 +1338,7 @@ xfs_ioc_setxflags( error =xfs_ioctl_setattr_xflags (tp, ip, &fa);if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); goto out_drop_write; }
fs/xfs/xfs_iomap.c +6 -6
@@ -183,7 +183,7 @@ xfs_iomap_write_direct(* Check for running out of space, note: need lock to return */ if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
@@ -236,7 +236,7 @@ out_bmap_cancel:xfs_bmap_cancel (&free_list);xfs_trans_unreserve_quota_nblks (tp, ip, (long )qblocks,0 , quota_flag); out_trans_cancel: -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp); goto out_unlock; }
@@ -690,7 +690,7 @@ xfs_iomap_write_allocate( error =xfs_trans_reserve (tp, &M_RES (mp)->tr_write, nres,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }xfs_ilock (ip,XFS_ILOCK_EXCL );
@@ -791,7 +791,7 @@ xfs_iomap_write_allocate( trans_cancel:xfs_bmap_cancel (&free_list); -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp); error0:xfs_iunlock (ip,XFS_ILOCK_EXCL );return error;
@@ -853,7 +853,7 @@ xfs_iomap_write_unwritten( error =xfs_trans_reserve (tp, &M_RES (mp)->tr_write, resblks,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
@@ -914,7 +914,7 @@ xfs_iomap_write_unwritten( error_on_bmapi_transaction: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 );return error; }
fs/xfs/xfs_iops.c +4 -8
@@ -733,7 +733,7 @@ xfs_setattr_nonsize(return 0 ; out_trans_cancel: -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL ); out_dqrele:xfs_qm_dqrele (udqp);
@@ -755,7 +755,6 @@ xfs_setattr_size(struct xfs_trans *tp;int error;uint lock_flags =0 ; -uint commit_flags =0 ;bool did_zeroing = false;trace_xfs_setattr (ip);
@@ -861,7 +860,6 @@ xfs_setattr_size(if (error) goto out_trans_cancel; - commit_flags =XFS_TRANS_RELEASE_LOG_RES ; lock_flags |=XFS_ILOCK_EXCL ;xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,0 );
@@ -901,7 +899,7 @@ xfs_setattr_size(if (newsize <= oldsize) { error =xfs_itruncate_extents (&tp, ip,XFS_DATA_FORK , newsize);if (error) - goto out_trans_abort; + goto out_trans_cancel;/* * Truncated "down", so we're removing references to old data
@@ -934,10 +932,8 @@ out_unlock:xfs_iunlock (ip, lock_flags);return error; -out_trans_abort: - commit_flags |=XFS_TRANS_ABORT ; out_trans_cancel: -xfs_trans_cancel (tp, commit_flags); +xfs_trans_cancel (tp); goto out_unlock; }
@@ -984,7 +980,7 @@ xfs_vn_update_time( tp =xfs_trans_alloc (mp,XFS_TRANS_FSYNC_TS ); 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; }
fs/xfs/xfs_log_recover.c +2 -2
@@ -3765,7 +3765,7 @@ xlog_recover_process_efi(return error; abort_error: -xfs_trans_cancel (tp,XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);return error; }
@@ -3873,7 +3873,7 @@ xlog_recover_clear_agi_bucket(return ; out_abort: -xfs_trans_cancel (tp,XFS_TRANS_ABORT ); +xfs_trans_cancel (tp); out_error:xfs_warn (mp,"%s: failed to clear agi %d. Continuing." , __func__, agno);return ;
fs/xfs/xfs_pnfs.c +1 -1
@@ -306,7 +306,7 @@ xfs_fs_commit_blocks( tp =xfs_trans_alloc (mp,XFS_TRANS_SETATTR_NOT_SIZE ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_ichange,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); goto out_drop_iolock; }
fs/xfs/xfs_qm.c +2 -3
@@ -756,7 +756,7 @@ xfs_qm_qino_alloc( error =xfs_trans_reserve (tp, &M_RES (mp)->tr_create,XFS_QM_QINOCREATE_SPACE_RES (mp),0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
@@ -764,8 +764,7 @@ xfs_qm_qino_alloc( error =xfs_dir_ialloc (&tp,NULL ,S_IFREG ,1 ,0 ,0 ,1 , ip, &committed);if (error) { -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES | -XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);return error; } }
fs/xfs/xfs_qm_syscalls.c +5 -6
@@ -239,7 +239,7 @@ xfs_qm_scall_trunc_qfile( tp =xfs_trans_alloc (mp,XFS_TRANS_TRUNCATE_FILE ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_itruncate,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_IOLOCK_EXCL ); goto out_put; }
@@ -252,8 +252,7 @@ xfs_qm_scall_trunc_qfile( error =xfs_itruncate_extents (&tp, ip,XFS_DATA_FORK ,0 );if (error) { -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES | -XFS_TRANS_ABORT ); +xfs_trans_cancel (tp); goto out_unlock; }
@@ -437,7 +436,7 @@ xfs_qm_scall_setqlim( tp =xfs_trans_alloc (mp,XFS_TRANS_QM_SETQLIM ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_qm_setqlim,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); goto out_rele; }
@@ -571,7 +570,7 @@ xfs_qm_log_quotaoff_end( error =xfs_trans_reserve (tp, &M_RES (mp)->tr_qm_equotaoff,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
@@ -605,7 +604,7 @@ xfs_qm_log_quotaoff( tp =xfs_trans_alloc (mp,XFS_TRANS_QM_QUOTAOFF ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_qm_quotaoff,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp); goto out; }
fs/xfs/xfs_rtalloc.c +2 -8
@@ -780,7 +780,6 @@ xfs_growfs_rt_alloc(* Allocate space to the file, as necessary. */ while (oblocks < nblocks) { -int cancelflags =0 ;xfs_trans_t *tp; tp =xfs_trans_alloc (mp,XFS_TRANS_GROWFSRT_ALLOC );
@@ -792,7 +791,6 @@ xfs_growfs_rt_alloc( resblks, 0);if (error) goto error_cancel; - cancelflags =XFS_TRANS_RELEASE_LOG_RES ;/* * Lock the inode. */
@@ -804,7 +802,6 @@ xfs_growfs_rt_alloc(* Allocate blocks to the bitmap file. */ nmap =1 ; - cancelflags |=XFS_TRANS_ABORT ; error =xfs_bmapi_write (tp, ip, oblocks, nblocks - oblocks,XFS_BMAPI_METADATA , &firstblock, resblks, &map, &nmap, &flist);
@@ -825,7 +822,6 @@ xfs_growfs_rt_alloc(* Now we need to clear the allocated blocks. * Do this one block per transaction, to keep it simple. */ - cancelflags =0 ;for (bno = map.br_startoff, fsbno = map.br_startblock; bno < map.br_startoff + map.br_blockcount; bno++, fsbno++) {
@@ -851,7 +847,7 @@ xfs_growfs_rt_alloc(if (bp ==NULL ) { error = -EIO ; error_cancel: -xfs_trans_cancel (tp, cancelflags); +xfs_trans_cancel (tp); goto error; }memset (bp->b_addr,0 , mp->m_sb.sb_blocksize);
@@ -973,7 +969,6 @@ xfs_growfs_rt( bmbno < nrbmblocks; bmbno++) {xfs_trans_t *tp; -int cancelflags =0 ; *nmp = *mp; nsbp = &nmp->m_sb;
@@ -1015,7 +1010,6 @@ xfs_growfs_rt( mp->m_rbmip->i_d.di_size = nsbp->sb_rbmblocks * nsbp->sb_blocksize;xfs_trans_log_inode (tp, mp->m_rbmip,XFS_ILOG_CORE ); - cancelflags |=XFS_TRANS_ABORT ;/* * Get the summary inode into the transaction. */
@@ -1062,7 +1056,7 @@ xfs_growfs_rt( nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno);if (error) { error_cancel: -xfs_trans_cancel (tp, cancelflags); +xfs_trans_cancel (tp);break ; }/*
fs/xfs/xfs_symlink.c +4 -9
@@ -178,7 +178,6 @@ xfs_symlink(struct xfs_bmap_free free_list;xfs_fsblock_t first_block;bool unlock_dp_on_error = false; -uint cancel_flags;int committed;xfs_fileoff_t first_fsb;xfs_filblks_t fs_blocks;
@@ -224,7 +223,6 @@ xfs_symlink(return error; tp =xfs_trans_alloc (mp,XFS_TRANS_SYMLINK ); - cancel_flags =XFS_TRANS_RELEASE_LOG_RES ;/* * The symlink will fit into the inode data fork? * There can't be any attributes so we get the whole variable part.
@@ -239,10 +237,8 @@ xfs_symlink( resblks =0 ; error =xfs_trans_reserve (tp, &M_RES (mp)->tr_symlink,0 ,0 ); } -if (error) { - cancel_flags =0 ; +if (error) goto out_trans_cancel; - }xfs_ilock (dp,XFS_ILOCK_EXCL |XFS_ILOCK_PARENT ); unlock_dp_on_error = true;
@@ -407,9 +403,8 @@ xfs_symlink( out_bmap_cancel:xfs_bmap_cancel (&free_list); - cancel_flags |=XFS_TRANS_ABORT ; out_trans_cancel: -xfs_trans_cancel (tp, cancel_flags); +xfs_trans_cancel (tp); out_release_inode:/* * Wait until after the current transaction is aborted to finish the
@@ -464,7 +459,7 @@ xfs_inactive_symlink_rmt( tp =xfs_trans_alloc (mp,XFS_TRANS_INACTIVE ); error =xfs_trans_reserve (tp, &M_RES (mp)->tr_itruncate,0 ,0 );if (error) { -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
@@ -552,7 +547,7 @@ xfs_inactive_symlink_rmt( error_bmap_cancel:xfs_bmap_cancel (&free_list); error_trans_cancel: -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp); error_unlock:xfs_iunlock (ip,XFS_ILOCK_EXCL );return error;
fs/xfs/xfs_trans.c +9 -18
@@ -986,29 +986,22 @@ out_unreserve:*/ void xfs_trans_cancel ( -xfs_trans_t *tp, -int flags) +struct xfs_trans *tp) { -int log_flags; -xfs_mount_t *mp = tp->t_mountp; +struct xfs_mount *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 * filesystem. This happens in paths where we detect * 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_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); }#ifdef DEBUG -if (!(flags &XFS_TRANS_ABORT ) && !XFS_FORCED_SHUTDOWN (mp)) { +if (!dirty && !XFS_FORCED_SHUTDOWN (mp)) {struct xfs_log_item_desc *lidp;list_for_each_entry (lidp, &tp->t_items, lid_trans)
@@ -1019,19 +1012,17 @@ xfs_trans_cancel(xfs_trans_unreserve_and_mod_dquots (tp);if (tp->t_ticket) { -if (flags &XFS_TRANS_RELEASE_LOG_RES ) { -ASSERT (tp->t_flags &XFS_TRANS_PERM_LOG_RES ); +uint log_flags =0 ; + +if (tp->t_flags &XFS_TRANS_PERM_LOG_RES ) log_flags =XFS_LOG_REL_PERM_RESERV ; - }else { - log_flags =0 ; - }xfs_log_done (mp, tp->t_ticket,NULL , log_flags); }/* mark this thread as no longer being in a transaction */ 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); }
fs/xfs/xfs_trans.h +1 -1
@@ -227,7 +227,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *, xfs_extlen_t);int xfs_trans_commit (xfs_trans_t *,uint flags);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 *);void xfs_trans_ail_destroy (struct xfs_mount *);
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/5 xfs: saner xfs_trans_commit interface
In reply to Christoph HellwigThe 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.
--- fs/xfs/libxfs/xfs_attr.c | 7 +++---- fs/xfs/libxfs/xfs_bmap.c | 5 ++--- fs/xfs/libxfs/xfs_sb.c | 2 +- fs/xfs/libxfs/xfs_shared.h | 5 ----- fs/xfs/xfs_aops.c | 2 +- fs/xfs/xfs_attr_inactive.c | 2 +- fs/xfs/xfs_bmap_util.c | 11 +++++------ fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_fsops.c | 2 +- fs/xfs/xfs_inode.c | 14 +++++++------- fs/xfs/xfs_ioctl.c | 6 +++--- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_iops.c | 6 +++--- fs/xfs/xfs_log.h | 2 +- fs/xfs/xfs_log_cil.c | 4 ++-- fs/xfs/xfs_log_recover.c | 4 ++-- fs/xfs/xfs_pnfs.c | 2 +- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_qm_syscalls.c | 9 ++++----- fs/xfs/xfs_rtalloc.c | 6 +++--- fs/xfs/xfs_symlink.c | 4 ++-- fs/xfs/xfs_trans.c | 35 +++++++++++++++++++---------------- fs/xfs/xfs_trans.h | 2 +- 24 files changed, 68 insertions(+), 74 deletions(-)
fs/xfs/libxfs/xfs_attr.c +3 -4
@@ -320,8 +320,7 @@ xfs_attr_set(xfs_trans_ichgtime (args.trans, dp,XFS_ICHGTIME_CHG ); } - err2 =xfs_trans_commit (args.trans, -XFS_TRANS_RELEASE_LOG_RES ); + err2 =xfs_trans_commit (args.trans);xfs_iunlock (dp,XFS_ILOCK_EXCL );return error ? error : err2;
@@ -383,7 +382,7 @@ xfs_attr_set(* Commit the last in the sequence of transactions. */ 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 );return error;
@@ -499,7 +498,7 @@ xfs_attr_remove(* Commit the last in the sequence of transactions. */ 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 );return error;
fs/xfs/libxfs/xfs_bmap.c +2 -3
@@ -1215,7 +1215,7 @@ xfs_bmap_add_attrfork( error =xfs_bmap_finish (&tp, &flist, &committed);if (error) goto bmap_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );return error;
@@ -5941,8 +5941,7 @@ xfs_bmap_split_extent(if (error) goto out; -return xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); - +return xfs_trans_commit (tp); out:xfs_trans_cancel (tp);
fs/xfs/libxfs/xfs_sb.c +1 -1
@@ -825,5 +825,5 @@ xfs_sync_sb(xfs_log_sb (tp);if (wait)xfs_trans_set_sync (tp); -return xfs_trans_commit (tp,0 ); +return xfs_trans_commit (tp); }
fs/xfs/libxfs/xfs_shared.h +0 -5
@@ -182,11 +182,6 @@ int xfs_log_calc_minimum_size(struct xfs_mount *);#define XFS_TRANS_FREEZE_PROT 0x40/* Transaction has elevated writer count in superblock */ /* -* Values for call flags parameter. -*/ -#define XFS_TRANS_RELEASE_LOG_RES 0x4 - -/* * Field values for xfs_trans_mod_sb. */ #define XFS_TRANS_SB_ICOUNT 0x00000001
fs/xfs/xfs_aops.c +1 -1
@@ -155,7 +155,7 @@ xfs_setfilesize(xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -return xfs_trans_commit (tp,0 ); +return xfs_trans_commit (tp); }STATIC int
fs/xfs/xfs_attr_inactive.c +1 -1
@@ -447,7 +447,7 @@ xfs_attr_inactive(/* Reset the attribute fork - this also destroys the in-core fork */ xfs_attr_fork_remove (dp, trans); - error =xfs_trans_commit (trans,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (trans);xfs_iunlock (dp, lock_mode);return error;
fs/xfs/xfs_bmap_util.c +5 -6
@@ -893,8 +893,7 @@ xfs_free_eofblocks(*/ xfs_trans_cancel (tp); }else { - error =xfs_trans_commit (tp, -XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (!error)xfs_inode_clear_eofblocks_tag (ip); }
@@ -1034,7 +1033,7 @@ xfs_alloc_file_space( goto error0; } - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );if (error) {break ;
@@ -1301,7 +1300,7 @@ xfs_free_file_space( goto error0; } - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL ); }
@@ -1473,7 +1472,7 @@ xfs_shift_file_space(if (error) goto out; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp); }return error;
@@ -1882,7 +1881,7 @@ xfs_swap_extents(if (mp->m_flags &XFS_MOUNT_WSYNC )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 (tip,1 );
fs/xfs/xfs_dquot.c +1 -1
@@ -666,7 +666,7 @@ xfs_qm_dqread(xfs_trans_brelse (tp, bp);if (tp) { - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto error0; }
fs/xfs/xfs_file.c +1 -1
@@ -160,7 +160,7 @@ xfs_update_prealloc_flags(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );if (flags &XFS_PREALLOC_SYNC )xfs_trans_set_sync (tp); -return xfs_trans_commit (tp,0 ); +return xfs_trans_commit (tp); }/*
fs/xfs/xfs_fsops.c +1 -1
@@ -491,7 +491,7 @@ xfs_growfs_data_private(if (dpct)xfs_trans_mod_sb (tp,XFS_TRANS_SB_IMAXPCT , dpct);xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);if (error)return error;
fs/xfs/xfs_inode.c +7 -7
@@ -1230,7 +1230,7 @@ xfs_create(if (error) goto out_bmap_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto out_release_inode;
@@ -1339,7 +1339,7 @@ xfs_create_tmpfile(if (error) goto out_trans_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto out_release_inode;
@@ -1465,7 +1465,7 @@ xfs_link( goto error_return; } -return xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); +return xfs_trans_commit (tp); error_return:xfs_trans_cancel (tp);
@@ -1702,7 +1702,7 @@ xfs_inactive_truncate(ASSERT (ip->i_d.di_nextents ==0 ); - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto error_unlock;
@@ -1799,7 +1799,7 @@ xfs_inactive_ifree(if (error)xfs_notice (mp,"%s: xfs_bmap_finish returned error %d" , __func__, error); - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error)xfs_notice (mp,"%s: xfs_trans_commit returned error %d" , __func__, error);
@@ -2577,7 +2577,7 @@ xfs_remove(if (error) goto out_bmap_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto std_return;
@@ -2667,7 +2667,7 @@ xfs_finish_rename(return error; } -return xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); +return xfs_trans_commit (tp); }/*
fs/xfs/xfs_ioctl.c +3 -3
@@ -346,7 +346,7 @@ xfs_set_dmattrs( ip->i_d.di_dmstate = state;xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);return error; }
@@ -1253,7 +1253,7 @@ xfs_ioctl_setattr(else 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.
@@ -1342,7 +1342,7 @@ xfs_ioc_setxflags( goto out_drop_write; } - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp); out_drop_write:mnt_drop_write_file (filp);return error;
fs/xfs/xfs_iomap.c +3 -3
@@ -213,7 +213,7 @@ xfs_iomap_write_direct( error =xfs_bmap_finish (&tp, &free_list, &committed);if (error) goto out_bmap_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto out_unlock;
@@ -760,7 +760,7 @@ xfs_iomap_write_allocate(if (error) goto trans_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto error0;
@@ -890,7 +890,7 @@ xfs_iomap_write_unwritten(if (error) 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 );if (error)return error;
fs/xfs/xfs_iops.c +3 -3
@@ -702,7 +702,7 @@ xfs_setattr_nonsize(if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );
@@ -926,7 +926,7 @@ xfs_setattr_size(if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp); out_unlock:if (lock_flags)xfs_iunlock (ip, lock_flags);
@@ -1002,7 +1002,7 @@ xfs_vn_update_time( }xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );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)
fs/xfs/xfs_log.h +1 -1
@@ -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_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);void xfs_log_work_queue (struct xfs_mount *mp);
fs/xfs/xfs_log_cil.c +2 -2
@@ -773,13 +773,13 @@ xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp, xfs_lsn_t *commit_lsn, - int flags) + bool regrant) { struct xlog *log = mp->m_log;struct xfs_cil *cil = log->l_cilp;int log_flags =0 ; -if (flags &XFS_TRANS_RELEASE_LOG_RES ) +if (!regrant) log_flags =XFS_LOG_REL_PERM_RESERV ;/* lock out background commit */
fs/xfs/xfs_log_recover.c +2 -2
@@ -3761,7 +3761,7 @@ xlog_recover_process_efi( }set_bit (XFS_EFI_RECOVERED , &efip->efi_flags); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);return error; abort_error:
@@ -3867,7 +3867,7 @@ xlog_recover_clear_agi_bucket(xfs_trans_log_buf (tp, agibp, offset, (offset +sizeof (xfs_agino_t) -1 )); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);if (error) goto out_error;return ;
fs/xfs/xfs_pnfs.c +1 -1
@@ -321,7 +321,7 @@ xfs_fs_commit_blocks( }xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp); out_drop_iolock:xfs_iunlock (ip,XFS_IOLOCK_EXCL );
fs/xfs/xfs_qm.c +1 -1
@@ -795,7 +795,7 @@ xfs_qm_qino_alloc(spin_unlock (&mp->m_sb_lock);xfs_log_sb (tp); - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) {ASSERT (XFS_FORCED_SHUTDOWN (mp));xfs_alert (mp,"%s failed (error %d)!" , __func__, error);
fs/xfs/xfs_qm_syscalls.c +4 -5
@@ -259,7 +259,7 @@ xfs_qm_scall_trunc_qfile(ASSERT (ip->i_d.di_nextents ==0 );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:xfs_iunlock (ip,XFS_ILOCK_EXCL |XFS_IOLOCK_EXCL );
@@ -547,7 +547,7 @@ xfs_qm_scall_setqlim( dqp->dq_flags |=XFS_DQ_DIRTY ;xfs_trans_log_dquot (tp, dqp); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp); out_rele:xfs_qm_dqrele (dqp);
@@ -584,8 +584,7 @@ xfs_qm_log_quotaoff_end(* We don't care about quotoff's performance. */ xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp,0 ); -return error; +return xfs_trans_commit (tp); }
@@ -623,7 +622,7 @@ xfs_qm_log_quotaoff(* We don't care about quotoff's performance. */ xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);if (error) goto out;
fs/xfs/xfs_rtalloc.c +3 -3
@@ -815,7 +815,7 @@ xfs_growfs_rt_alloc( error =xfs_bmap_finish (&tp, &flist, &committed);if (error) goto error_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto error;/*
@@ -855,7 +855,7 @@ error_cancel:/* * Commit the transaction. */ - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);if (error) goto error; }
@@ -1070,7 +1070,7 @@ error_cancel: mp->m_rsumlevels = nrsumlevels; mp->m_rsumsize = nrsumsize; - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);if (error)break ; }
fs/xfs/xfs_symlink.c +2 -2
@@ -390,7 +390,7 @@ xfs_symlink(if (error) goto out_bmap_cancel; - error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES ); + error =xfs_trans_commit (tp);if (error) goto out_release_inode;
@@ -528,7 +528,7 @@ xfs_inactive_symlink_rmt(/* * 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) {ASSERT (XFS_FORCED_SHUTDOWN (mp)); goto error_unlock;
fs/xfs/xfs_trans.c +19 -16
@@ -892,27 +892,17 @@ xfs_trans_committed_bulk(* have already been unlocked as if the commit had succeeded. * Do not reference the transaction structure after this call. */ -int -xfs_trans_commit ( +static int +__xfs_trans_commit (struct xfs_trans *tp, -uint flags) +bool regrant) {struct xfs_mount *mp = tp->t_mountp;xfs_lsn_t commit_lsn =-1 ;int error =0 ; -int log_flags =0 ;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, * then unlock all of the items associated with the * transaction and free the transaction structure.
@@ -936,7 +926,7 @@ xfs_trans_commit(xfs_trans_apply_sb_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 );xfs_trans_free (tp);
@@ -964,6 +954,12 @@ out_unreserve:*/ xfs_trans_unreserve_and_mod_dquots (tp);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);if (commit_lsn ==-1 && !error) error = -EIO ;
@@ -976,6 +972,13 @@ out_unreserve: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. * The transaction must not have modified any of its items, because
@@ -1029,7 +1032,7 @@ xfs_trans_cancel(/* * Roll from one trans in the sequence of PERMANENT transactions to * 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 * chunk we've been working on and get a new transaction to continue. */
@@ -1063,7 +1066,7 @@ xfs_trans_roll(* is in progress. The caller takes the responsibility to cancel * the duplicate transaction that gets returned. */ - error =xfs_trans_commit (trans,0 ); + error =__xfs_trans_commit (trans, true);if (error)return error;
fs/xfs/xfs_trans.h +1 -1
@@ -225,7 +225,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *, struct xfs_efd_log_item *, xfs_fsblock_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 *);void xfs_trans_cancel (xfs_trans_t *);int xfs_trans_ail_init (struct xfs_mount *);
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/5 xfs: fix xfs_log_done interface
In reply to Christoph HellwigInstead of the confusing flags argument pass a boolean flag to indicate if we want to release or regrant a log reservation.
Also ensure that xfs_log_done always drop the reference on the log ticket, to both simplify the code and make the logic in xfs_trans_roll easier to understand.
--- fs/xfs/xfs_log.c | 11 ++++------- fs/xfs/xfs_log.h | 11 +---------- fs/xfs/xfs_log_cil.c | 8 ++------ fs/xfs/xfs_trans.c | 33 ++++----------------------------- 4 files changed, 11 insertions(+), 52 deletions(-)
fs/xfs/xfs_log.c +4 -7
@@ -513,7 +513,7 @@ xfs_log_done(struct xfs_mount *mp, struct xlog_ticket *ticket, struct xlog_in_core **iclog, - uint flags) + bool regrant) { struct xlog *log = mp->m_log;xfs_lsn_t lsn =0 ;
@@ -526,14 +526,11 @@ xfs_log_done( (((ticket->t_flags & XLOG_TIC_INITED) == 0) && (xlog_commit_record(log, ticket, iclog, &lsn)))) { lsn = (xfs_lsn_t) -1 ; -if (ticket->t_flags &XLOG_TIC_PERM_RESERV ) { - flags |=XFS_LOG_REL_PERM_RESERV ; - } + regrant = false; } -if ((ticket->t_flags &XLOG_TIC_PERM_RESERV ) ==0 || - (flags &XFS_LOG_REL_PERM_RESERV )) { +if (!regrant) {trace_xfs_log_done_nonperm (log, ticket);/*
@@ -541,7 +538,6 @@ xfs_log_done(* request has been made to release a permanent reservation. */ xlog_ungrant_log_space (log, ticket); -xfs_log_ticket_put (ticket); }else {trace_xfs_log_done_perm (log, ticket);
@@ -553,6 +549,7 @@ xfs_log_done( ticket->t_flags |=XLOG_TIC_INITED ; } +xfs_log_ticket_put (ticket);return lsn; }
fs/xfs/xfs_log.h +1 -10
@@ -111,15 +111,6 @@ static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)#define XFS_LSN_CMP (x,y) _lsn_cmp(x,y)/* -* Macros, structures, prototypes for interface to the log manager. -*/ - -/* -* Flags to xfs_log_done() -*/ -#define XFS_LOG_REL_PERM_RESERV 0x1 - -/* * Flags to xfs_log_force() * * XFS_LOG_SYNC: Synchronous force in-core log to disk
@@ -138,7 +129,7 @@ struct xfs_log_callback;xfs_lsn_t xfs_log_done (struct xfs_mount *mp,struct xlog_ticket *ticket,struct xlog_in_core **iclog, -uint flags); +bool regrant);int _xfs_log_force (struct xfs_mount *mp,uint flags,int *log_forced);
fs/xfs/xfs_log_cil.c +2 -6
@@ -624,7 +624,7 @@ restart:spin_unlock (&cil->xc_push_lock);/* xfs_log_done always frees the ticket on error. */ - commit_lsn =xfs_log_done (log->l_mp, tic, &commit_iclog,0 ); + commit_lsn =xfs_log_done (log->l_mp, tic, &commit_iclog, false);if (commit_lsn ==-1 ) goto out_abort;
@@ -777,10 +777,6 @@ xfs_log_commit_cil( {struct xlog *log = mp->m_log;struct xfs_cil *cil = log->l_cilp; -int log_flags =0 ; - -if (!regrant) - log_flags =XFS_LOG_REL_PERM_RESERV ;/* lock out background commit */ down_read (&cil->xc_ctx_lock);
@@ -795,7 +791,7 @@ xfs_log_commit_cil(if (commit_lsn) *commit_lsn = tp->t_commit_lsn; -xfs_log_done (mp, tp->t_ticket,NULL , log_flags); +xfs_log_done (mp, tp->t_ticket,NULL , regrant);xfs_trans_unreserve_and_mod_sb (tp);/*
fs/xfs/xfs_trans.c +4 -29
@@ -251,14 +251,7 @@ xfs_trans_reserve(*/ undo_log:if (resp->tr_logres >0 ) { -int log_flags; - -if (resp->tr_logflags &XFS_TRANS_PERM_LOG_RES ) { - log_flags =XFS_LOG_REL_PERM_RESERV ; - }else { - log_flags =0 ; - } -xfs_log_done (tp->t_mountp, tp->t_ticket,NULL , log_flags); +xfs_log_done (tp->t_mountp, tp->t_ticket,NULL , false); tp->t_ticket =NULL ; tp->t_log_res =0 ; tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES ;
@@ -954,13 +947,7 @@ out_unreserve:*/ xfs_trans_unreserve_and_mod_dquots (tp);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 , regrant);if (commit_lsn ==-1 && !error) error = -EIO ; }
@@ -1014,13 +1001,8 @@ xfs_trans_cancel(xfs_trans_unreserve_and_mod_sb (tp);xfs_trans_unreserve_and_mod_dquots (tp); -if (tp->t_ticket) { -uint log_flags =0 ; - -if (tp->t_flags &XFS_TRANS_PERM_LOG_RES ) - log_flags =XFS_LOG_REL_PERM_RESERV ; -xfs_log_done (mp, tp->t_ticket,NULL , log_flags); - } +if (tp->t_ticket) +xfs_log_done (mp, tp->t_ticket,NULL , false);/* mark this thread as no longer being in a transaction */ current_restore_flags_nested (&tp->t_pflags,PF_FSTRANS );
@@ -1073,13 +1055,6 @@ xfs_trans_roll( trans = *tpp;/* -* transaction commit worked ok so we can drop the extra ticket -* reference that we gained in xfs_trans_dup() -*/ -xfs_log_ticket_put (trans->t_ticket); - - -/* * Reserve space in the log for th next transaction. * This also pushes items in the "AIL", the list of logged items, * out to disk if they are taking up space at the tail of the log
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 4 lines · Christoph Hellwig
Changes since V1:
- rebased to todays for-next branch
- fix the inverted regrant logic in path 4
(the full series was already corrent in the previous version)
Hi Christoph, with this series now committed to the kernel code, can you port it to the xfsprogs codebase? The for-next branch of thegit://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git tree woul dbe the best target as it should mostly just apply to the libxfs/ side of things. Thanks!
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs