libxfs port of the transaction commit/cancel cleanups
Not a whole lot to port actually, but the cleanups are worth it even more in userspace.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/4 libxfs: simplify xfs_trans_free_items
Remove the unused flags parameter and mark the function as static.
--- libxfs/libxfs_priv.h | 1 - libxfs/trans.c | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
libxfs/libxfs_priv.h +0 -1
@@ -423,7 +423,6 @@ int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);/* xfs_trans_item.c */ 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 *,int );/* xfs_inode_item.c */ void xfs_inode_item_init (struct xfs_inode *,struct xfs_mount *);
libxfs/trans.c +6 -5
@@ -30,6 +30,8 @@#include "xfs_trans.h" #include "xfs_sb.h" +static void xfs_trans_free_items (struct xfs_trans *tp); +/* * Simple transaction interface */
@@ -205,7 +207,7 @@ libxfs_trans_cancel(xfs_trans_t *otp = tp;#endif if (tp !=NULL ) { -xfs_trans_free_items (tp, flags); +xfs_trans_free_items (tp);free (tp); tp =NULL ; }
@@ -778,10 +780,9 @@ inode_item_unlock(* Unlock all of the items of a transaction and free all the descriptors * of that transaction. */ -void +static void xfs_trans_free_items ( -struct xfs_trans *tp, -int flags) +struct xfs_trans *tp) {struct xfs_log_item_desc *lidp, *next;
@@ -818,7 +819,7 @@ libxfs_trans_commit(#ifdef XACT_DEBUG fprintf (stderr,"committed clean transaction %p\n" , tp);#endif -xfs_trans_free_items (tp, flags); +xfs_trans_free_items (tp);free (tp); tp =NULL ;return 0 ;
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/4 libxfs: switch the remaining xfs_trans_dup user to xfs_trans_roll
In reply to Christoph HellwigMatch the kernel API change. Also libxfs_trans_dup can be folded into the only caller now.
--- include/xfs_trans.h | 1 - libxfs/libxfs_api_defs.h | 1 - libxfs/trans.c | 21 +++++---------------- libxfs/util.c | 14 +++----------- 4 files changed, 8 insertions(+), 29 deletions(-)
include/xfs_trans.h +0 -1
@@ -87,7 +87,6 @@ void xfs_trans_init(struct xfs_mount *);int xfs_trans_roll (struct xfs_trans **,struct xfs_inode *);xfs_trans_t *libxfs_trans_alloc (struct xfs_mount *,int ); -xfs_trans_t *libxfs_trans_dup (struct xfs_trans *);int libxfs_trans_reserve (struct xfs_trans *,struct xfs_trans_res *,uint ,uint );int libxfs_trans_commit (struct xfs_trans *,uint );
libxfs/libxfs_api_defs.h +0 -1
@@ -40,7 +40,6 @@#define xfs_trans_commit libxfs_trans_commit#define xfs_trans_cancel libxfs_trans_cancel#define xfs_trans_del_item libxfs_trans_del_item -#define xfs_trans_dup libxfs_trans_dup#define xfs_trans_get_buf libxfs_trans_get_buf#define xfs_trans_getsb libxfs_trans_getsb#define xfs_trans_iget libxfs_trans_iget
libxfs/trans.c +5 -16
@@ -109,14 +109,15 @@ libxfs_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. */ tres.tr_logres = trans->t_log_res; tres.tr_logcount = trans->t_log_count; - *tpp =xfs_trans_dup (trans); + *tpp =libxfs_trans_alloc (trans->t_mountp, trans->t_type);/* * Commit the current transaction.
@@ -147,7 +148,8 @@ libxfs_trans_roll(if (error)return error; -xfs_trans_ijoin (trans, dp,0 ); +if (dp) +xfs_trans_ijoin (trans, dp,0 );return 0 ; }
@@ -172,19 +174,6 @@ libxfs_trans_alloc(return ptr; } -xfs_trans_t * -libxfs_trans_dup ( -xfs_trans_t *tp) -{ -xfs_trans_t *ptr; - - ptr =libxfs_trans_alloc (tp->t_mountp, tp->t_type); -#ifdef XACT_DEBUG -fprintf (stderr,"duplicated transaction %p (new=%p)\n" , tp, ptr); -#endif -return ptr; -} - int libxfs_trans_reserve( struct xfs_trans *tp,
libxfs/util.c +3 -11
@@ -641,7 +641,6 @@ libxfs_inode_alloc( {xfs_buf_t *ialloc_context;xfs_inode_t *ip; -xfs_trans_t *ntp;int error; ialloc_context = (xfs_buf_t *)0 ;
@@ -657,19 +656,12 @@ libxfs_inode_alloc( }if (ialloc_context) { -struct xfs_trans_res tres;xfs_trans_bhold (*tp, ialloc_context); - tres.tr_logres = (*tp)->t_log_res; - tres.tr_logcount = (*tp)->t_log_count; - - ntp =xfs_trans_dup (*tp); -xfs_trans_commit (*tp,0 ); - *tp = ntp; - tres.tr_logflags =XFS_TRANS_PERM_LOG_RES ; - error =xfs_trans_reserve (*tp, &tres,0 ,0 ); + + error =xfs_trans_roll (tp,NULL );if (error) { -fprintf (stderr,_ ("%s: cannot reserve space: %s\n" ), +fprintf (stderr,_ ("%s: cannot duplicate transaction: %s\n" ), progname,strerror (error));exit (1 ); }
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/4 libxfs: remove the flags argument to xfs_trans_cancel
In reply to Christoph HellwigSynchronize with the kernel changes that dropped the argument. Unlike the kernel libxfs always ignored the flags anyway.
--- include/xfs_trans.h | 2 +- libxfs/trans.c | 3 +-- libxfs/util.c | 4 ++-- libxfs/xfs_attr.c | 18 +++++++----------- libxfs/xfs_bmap.c | 11 ++++------- libxfs/xfs_sb.c | 2 +- libxfs/xfs_shared.h | 1 - repair/phase6.c | 5 ++--- repair/phase7.c | 2 +- 9 files changed, 19 insertions(+), 29 deletions(-)
include/xfs_trans.h +1 -1
@@ -90,7 +90,7 @@ xfs_trans_t *libxfs_trans_alloc(struct xfs_mount *, int);int libxfs_trans_reserve (struct xfs_trans *,struct xfs_trans_res *,uint ,uint );int libxfs_trans_commit (struct xfs_trans *,uint ); -void libxfs_trans_cancel (struct xfs_trans *,int ); +void libxfs_trans_cancel (struct xfs_trans *);struct xfs_buf *libxfs_trans_getsb (struct xfs_trans *,struct xfs_mount *,int ); int libxfs_trans_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
libxfs/trans.c +1 -2
@@ -200,8 +200,7 @@ libxfs_trans_reserve(void libxfs_trans_cancel ( -xfs_trans_t *tp, -int flags) +xfs_trans_t *tp) {#ifdef XACT_DEBUG xfs_trans_t *otp = tp;
libxfs/util.c +2 -2
@@ -572,7 +572,7 @@ libxfs_alloc_file_space(* Free the transaction structure. */ ASSERT (error == -ENOSPC ); -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);break ; }xfs_trans_ijoin (tp, ip,0 );
@@ -605,7 +605,7 @@ libxfs_alloc_file_space( error0:/* Cancel bmap, cancel trans */ xfs_bmap_cancel (&free_list); -xfs_trans_cancel (tp,0 ); +xfs_trans_cancel (tp);return error; }
libxfs/xfs_attr.c +7 -11
@@ -261,7 +261,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 );
@@ -271,7 +271,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; }
@@ -384,10 +384,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; }
@@ -457,7 +455,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; }
@@ -502,10 +500,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; }
libxfs/xfs_bmap.c +4 -7
@@ -1104,7 +1104,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 );
@@ -1116,17 +1115,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 ) {
@@ -1217,7 +1214,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; }
@@ -5903,7 +5900,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; }
@@ -5925,6 +5922,6 @@ xfs_bmap_split_extent( out: -xfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +xfs_trans_cancel (tp);return error; }
libxfs/xfs_sb.c +1 -1
@@ -798,7 +798,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; }
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.
repair/phase6.c +2 -3
@@ -1403,7 +1403,7 @@ _("name create failed in ino %" PRIu64 " (%d), filesystem may be out of space\n" out_bmap_cancel:libxfs_bmap_cancel (&flist); -libxfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES |XFS_TRANS_ABORT ); +libxfs_trans_cancel (tp);return ; }
@@ -2949,8 +2949,7 @@ process_dir_inode(XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_SYNC); }else { -libxfs_trans_cancel (tp, -XFS_TRANS_RELEASE_LOG_RES ); +libxfs_trans_cancel (tp); }break ;
repair/phase7.c +1 -1
@@ -93,7 +93,7 @@ update_inode_nlinks(set_nlinks (&ip->i_d, ino, nlinks, &dirty);if (!dirty) { -libxfs_trans_cancel (tp,XFS_TRANS_RELEASE_LOG_RES ); +libxfs_trans_cancel (tp); }else {libxfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );/*
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/4 xfs: saner xfs_trans_commit interface
In reply to Christoph HellwigRemove the unused xfs_trans_commit flags argument. Unlike the kernel libxfs alwasy ignored the flags argument anyway.
--- include/xfs_trans.h | 2 +- libxfs/trans.c | 5 ++--- libxfs/util.c | 2 +- libxfs/xfs_attr.c | 7 +++---- libxfs/xfs_bmap.c | 5 ++--- libxfs/xfs_sb.c | 2 +- libxfs/xfs_shared.h | 5 ----- mkfs/proto.c | 16 ++++++++-------- mkfs/xfs_mkfs.c | 2 +- repair/phase5.c | 2 +- repair/phase6.c | 43 ++++++++++++++++++------------------------- repair/phase7.c | 3 +-- 12 files changed, 39 insertions(+), 55 deletions(-)
include/xfs_trans.h +1 -1
@@ -89,7 +89,7 @@ int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);xfs_trans_t *libxfs_trans_alloc (struct xfs_mount *,int );int libxfs_trans_reserve (struct xfs_trans *,struct xfs_trans_res *,uint ,uint ); -int libxfs_trans_commit (struct xfs_trans *,uint ); +int libxfs_trans_commit (struct xfs_trans *);void libxfs_trans_cancel (struct xfs_trans *);struct xfs_buf *libxfs_trans_getsb (struct xfs_trans *,struct xfs_mount *,int );
libxfs/trans.c +2 -3
@@ -128,7 +128,7 @@ libxfs_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);if (error)return error;
@@ -806,8 +806,7 @@ xfs_trans_free_items(*/ int libxfs_trans_commit ( -xfs_trans_t *tp, -uint flags) +xfs_trans_t *tp) {xfs_sb_t *sbp;
libxfs/util.c +1 -1
@@ -590,7 +590,7 @@ libxfs_alloc_file_space(if (error) goto error0; - error =xfs_trans_commit (tp,0 ); + error =xfs_trans_commit (tp);if (error)break ;
libxfs/xfs_attr.c +3 -4
@@ -315,8 +315,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;
@@ -378,7 +377,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;
@@ -494,7 +493,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;
libxfs/xfs_bmap.c +2 -3
@@ -1207,7 +1207,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;
@@ -5918,8 +5918,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);
libxfs/xfs_sb.c +1 -1
@@ -805,5 +805,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); }
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
mkfs/proto.c +8 -8
@@ -215,7 +215,7 @@ rsvfile( ip->i_d.di_flags |=XFS_DIFLAG_PREALLOC ;libxfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp); } static int
@@ -484,7 +484,7 @@ parseproto( error = -libxfs_bmap_finish (&tp, &flist, &committed);if (error)fail (_ ("Pre-allocated file creation failed" ), error); -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp);rsvfile (mp, ip, llen);IRELE (ip);return ;
@@ -566,7 +566,7 @@ parseproto( error = -libxfs_bmap_finish (&tp, &flist, &committed);if (error)fail (_ ("Directory creation failed" ), error); -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp);/* * RT initialization. Do this here to ensure that * the RT inodes get placed after the root inode.
@@ -594,7 +594,7 @@ parseproto(fail (_ ("Error encountered creating file from prototype file" ), error); } -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp);IRELE (ip); }
@@ -668,7 +668,7 @@ rtinit( rsumip->i_d.di_size = mp->m_rsumsize;libxfs_trans_log_inode (tp, rsumip,XFS_ILOG_CORE );libxfs_log_sb (tp); -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp); mp->m_rsumip = rsumip;/* * Next, give the bitmap file some zero-filled blocks.
@@ -704,7 +704,7 @@ rtinit(if (error) {fail (_ ("Completion of the realtime bitmap failed" ), error); } -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp);/* * Give the summary file some zero-filled blocks.
@@ -739,7 +739,7 @@ rtinit(if (error) {fail (_ ("Completion of the realtime summary failed" ), error); } -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp);/* * Free the whole area using transactions.
@@ -763,7 +763,7 @@ rtinit(if (error) {fail (_ ("Error completing the realtime space" ), error); } -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp); } }
mkfs/xfs_mkfs.c +1 -1
@@ -3035,7 +3035,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),libxfs_alloc_fix_freelist (&args,0 );xfs_perag_put (args.pag); -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp); }/*
repair/phase5.c +1 -1
@@ -1515,7 +1515,7 @@ build_agf_agfl(xfs_mount_t *mp,do_error (_ ("failed to fix AGFL on AG %d, error %d\n" ), agno, error); } -libxfs_trans_commit (tp,0 ); +libxfs_trans_commit (tp); }#ifdef XR_BLD_FREE_TRACE
repair/phase6.c +18 -25
151 lines not on this page · raw message
repair/phase7.c +1 -2
@@ -101,8 +101,7 @@ update_inode_nlinks(* we're not allocating anything */ ASSERT (error ==0 ); - error = -libxfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES | -XFS_TRANS_SYNC ); + error = -libxfs_trans_commit (tp);ASSERT (error ==0 ); }
Signature · 6 lines
1.9.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs