libxfs: spring cleaning
cover libxfs: spring cleaning
The first 4 should be easy, just basic cleanups.
Patch 5 gets rid of some "libxfs-ification" of what I think are core libxfs functions that don't need the prefix, but please correct me if I've got that wrong.
Patches 6-10 are splitting out the misc functions we've accumulated over time in various files, and tries to re-organize them to more or less match their kernel counterparts. This is just a first step toward being able to see what we've got, and how we've diverged from kernelspace. Hopefully it'll help guide us to sharing more files - but in some cases it's only a couple shared functions, so maye splitting this way doesn't make sense.
Patch 11 is just cosmetic changes to the resulting kernel-ish files, to eliminate cosmetic differences and really start to show where things diverge. With all these patches applied, a graphical diff between userspace and kernelspace starts to make a little sense.
If the spawning of new files doesn't seem prudent, I could keep them all in 1 or 2 bigger files, but keep them in order to match the kernel, and achieve similar purposes. Curious to see what folks think.
My main goal with the 2nd half was to get things sliced, diced, and sorted enough that I could even spot the differences.
Thanks,
-Eric
PATCH 1/11 libxfs: remove i_transp
i_transp was removed from kernel code back in 2011, but it was left in userspace. It's only used in a few asserts in transaction code (as it was in the kernel) so there doesnt' seem to be a compelling reason to carry it around anymore.
Source kernel commit: f3ca87389dbff0a3dc1a7cb2fa7c62e25421c66c
--- include/xfs_inode.h | 1 - libxfs/trans.c | 11 ----------- 2 files changed, 12 deletions(-)
include/xfs_inode.h +0 -1
@@ -41,7 +41,6 @@ typedef struct xfs_inode {struct xfs_ifork *i_afp;/* attribute fork pointer */ struct xfs_ifork *i_cowfp;/* copy on write extents */ struct xfs_ifork i_df;/* data fork */ -struct xfs_trans *i_transp;/* ptr to owning transaction */ struct xfs_inode_log_item *i_itemp;/* logging information */ unsigned int i_delayed_blks;/* count of delay alloc blks */ struct xfs_icdinode i_d;/* most of ondisk inode */
libxfs/trans.c +0 -11
@@ -344,7 +344,6 @@ libxfs_trans_ijoin( {xfs_inode_log_item_t *iip; -ASSERT (ip->i_transp ==NULL );if (ip->i_itemp ==NULL )xfs_inode_item_init (ip, ip->i_mount); iip = ip->i_itemp;
@@ -356,7 +355,6 @@ libxfs_trans_ijoin(xfs_trans_add_item (tp, (xfs_log_item_t *)(iip)); - ip->i_transp = tp;#ifdef XACT_DEBUG fprintf (stderr,"ijoin'd inode %llu, transaction %p\n" , ip->i_ino, tp);#endif
@@ -368,7 +366,6 @@ libxfs_trans_ijoin_ref( xfs_inode_t *ip, int lock_flags) { -ASSERT (ip->i_transp == tp);ASSERT (ip->i_itemp !=NULL );xfs_trans_ijoin (tp, ip, lock_flags);
@@ -406,7 +403,6 @@ xfs_trans_log_inode( xfs_inode_t *ip, uint flags) { -ASSERT (ip->i_transp == tp);ASSERT (ip->i_itemp !=NULL );#ifdef XACT_DEBUG fprintf (stderr,"dirtied inode %llu, transaction %p\n" , ip->i_ino, tp);
@@ -817,7 +813,6 @@ inode_item_done(ASSERT (ip !=NULL );if (!(iip->ili_fields &XFS_ILOG_ALL )) { - ip->i_transp =NULL ;/* disassociate from transaction */ iip->ili_flags =0 ;/* reset all flags */ goto free; }
@@ -838,7 +833,6 @@ inode_item_done(* we still release the buffer reference we currently hold. */ error =libxfs_iflush_int (ip, bp); - ip->i_transp =NULL ;/* disassociate from transaction */ bp->b_transp =NULL ;/* remove xact ptr */ if (error) {
@@ -927,11 +921,6 @@ static voidinode_item_unlock ( xfs_inode_log_item_t *iip) { -xfs_inode_t *ip = iip->ili_inode; - -/* Clear the transaction pointer in the inode. */ - ip->i_transp =NULL ; - iip->ili_flags =0 ;xfs_inode_item_put (iip); }
Signature · 1 line
1.8.3.1
Re: [PATCH 01/11] libxfs: remove i_transp
Quoted 8 lines · Eric Sandeen
i_transpwas removed from kernel code back in 2011, but it was left in userspace. It's only used in a few asserts in transaction code (as it was in the kernel) so there doesnt' seem to be a compelling reason to carry it around anymore.Source kernel commit:
f3ca87389dbff0a3dc1a7cb2fa7c62e25421c66cSigned-off-by Eric Sandeen <[email protected]>
looks good.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 01/11] libxfs: remove i_transp
In reply to Eric SandeenLooks good,
PATCH 2/11 libxfs: remove xfs_inode_log_item ili_flags
In reply to Eric Sandeenili_flags is only set to zero and asserted to be zero; it serves no purpose, so remove it.
(it was renamed to ili_lock_flags in the kernel in commit 898621d5, for some reason userspace had both, with ili_flags ~unused)
--- include/xfs_trans.h | 1 - libxfs/trans.c | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-)
include/xfs_trans.h +0 -1
@@ -29,7 +29,6 @@ typedef struct xfs_log_item { typedef struct xfs_inode_log_item { xfs_log_item_t ili_item; /* common portion */ struct xfs_inode *ili_inode; /* inode pointer */ - unsigned short ili_flags; /* misc flags */ unsigned short ili_lock_flags; /* lock flags */ unsigned int ili_fields; /* fields to be logged */ unsigned int ili_last_fields; /* fields when flushed*/
libxfs/trans.c +1 -5
@@ -347,7 +347,6 @@ libxfs_trans_ijoin(if (ip->i_itemp ==NULL )xfs_inode_item_init (ip, ip->i_mount); iip = ip->i_itemp; -ASSERT (iip->ili_flags ==0 );ASSERT (iip->ili_inode !=NULL );ASSERT (iip->ili_lock_flags ==0 );
@@ -812,10 +811,8 @@ inode_item_done( mp = iip->ili_item.li_mountp;ASSERT (ip !=NULL ); -if (!(iip->ili_fields &XFS_ILOG_ALL )) { - iip->ili_flags =0 ;/* reset all flags */ +if (!(iip->ili_fields &XFS_ILOG_ALL )) goto free; - }/* * Get the buffer containing the on-disk inode.
@@ -921,7 +918,6 @@ static voidinode_item_unlock ( xfs_inode_log_item_t *iip) { - iip->ili_flags =0 ;xfs_inode_item_put (iip); }
Signature · 1 line
1.8.3.1
Re: [PATCH 02/11] libxfs: remove xfs_inode_log_item ili_flags
Quoted 5 lines · Eric Sandeen
ili_flagsis only set to zero and asserted to be zero; it serves no purpose, so remove it.(it was renamed to
ili_lock_flagsin the kernel in commit898621d5, for some reason userspace had both, withili_flags~unused)
Probably something that wasn't properly cleaned up in a big merge. Good to get rid of it, thought.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 02/11] libxfs: remove xfs_inode_log_item ili_flags
In reply to Eric SandeenQuoted 5 lines · Eric Sandeen
ili_flagsis only set to zero and asserted to be zero; it serves no purpose, so remove it.(it was renamed to
ili_lock_flagsin the kernel in commit898621d5, for some reason userspace had both, withili_flags~unused)
Looks good,
PATCH 3/11 libxfs: remove unused cruft
In reply to Eric SandeenRemove many unused #defines and functions.
--- include/libxfs.h | 3 --- include/xfs_trans.h | 8 -------- libxfs/libxfs_api_defs.h | 5 ----- libxfs/libxfs_priv.h | 9 --------- libxfs/util.c | 29 ----------------------------- 5 files changed, 54 deletions(-)
include/libxfs.h +0 -3
@@ -154,9 +154,6 @@ extern int libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,extern int libxfs_alloc_file_space (struct xfs_inode *,xfs_off_t ,xfs_off_t ,int ,int ); -extern void libxfs_fs_repair_cmn_err (int ,struct xfs_mount *,char *, ...); -extern void libxfs_fs_cmn_err (int ,struct xfs_mount *,char *, ...); -/* XXX: this is messy and needs fixing */ #ifndef __LIBXFS_INTERNAL_XFS_H__extern void cmn_err (int ,char *, ...);
include/xfs_trans.h +0 -8
@@ -47,13 +47,6 @@ typedef struct xfs_buf_log_item {#define XFS_BLI_STALE (1<<2)#define XFS_BLI_INODE_ALLOC_BUF (1<<3) -typedef struct xfs_dq_logitem { -xfs_log_item_t qli_item;/* common portion */ -struct xfs_dquot *qli_dquot;/* dquot ptr */ -xfs_lsn_t qli_flush_lsn;/* lsn at last flush */ -xfs_dq_logformat_t qli_format;/* logged structure */ -}xfs_dq_logitem_t ; - typedef struct xfs_qoff_logitem { xfs_log_item_t qql_item; /* common portion */ struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
@@ -64,7 +57,6 @@ typedef struct xfs_qoff_logitem {#define XFS_DEFER_OPS_NR_BUFS 2/* join up to two buffers */ typedef struct xfs_trans { - unsigned int t_type; /* transaction type */ unsigned int t_log_res; /* amt of log space resvd */ unsigned int t_log_count; /* count for perm log res */ unsigned int t_blk_res; /* # of blocks resvd */
libxfs/libxfs_api_defs.h +0 -5
@@ -16,9 +16,6 @@#define xfs_highbit32 libxfs_highbit32#define xfs_highbit64 libxfs_highbit64 -#define xfs_fs_repair_cmn_err libxfs_fs_repair_cmn_err -#define xfs_fs_cmn_err libxfs_fs_cmn_err -#define xfs_trans_alloc libxfs_trans_alloc#define xfs_trans_alloc_empty libxfs_trans_alloc_empty#define xfs_trans_add_item libxfs_trans_add_item
@@ -61,7 +58,6 @@#define xfs_bmapi_write libxfs_bmapi_write#define xfs_bmapi_read libxfs_bmapi_read#define xfs_bunmapi libxfs_bunmapi -#define xfs_bmbt_get_all libxfs_bmbt_get_all#define xfs_rtfree_extent libxfs_rtfree_extent#define xfs_verify_rtbno libxfs_verify_rtbno#define xfs_verify_ino libxfs_verify_ino
@@ -70,7 +66,6 @@#define xfs_defer_finish libxfs_defer_finish#define xfs_defer_cancel libxfs_defer_cancel -#define xfs_da_brelse libxfs_da_brelse#define xfs_da_hashname libxfs_da_hashname#define xfs_da_shrink_inode libxfs_da_shrink_inode#define xfs_da_read_buf libxfs_da_read_buf
libxfs/libxfs_priv.h +0 -9
@@ -122,7 +122,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args) #define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) #define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) -#define xfs_alert_tag(mp,tag,fmt,args...) cmn_err(CE_ALERT,fmt, ## args)#define xfs_hex_dump (d,n) ((void) 0)#define xfs_stack_trace () ((void) 0)
@@ -195,8 +194,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };#endif /* miscellaneous kernel routines not in user space */ -#define down_read (a) ((void) 0) -#define up_read (a) ((void) 0)#define spin_lock_init (a) ((void) 0)#define spin_lock (a) ((void) 0)#define spin_unlock (a) ((void) 0)
@@ -400,7 +397,6 @@ roundup_64(uint64_t x, uint32_t y)#define XBRW_READ LIBXFS_BREAD#define XBRW_WRITE LIBXFS_BWRITE -#define xfs_buf_iomove (bp,off,len,data,f) libxfs_iomove(bp,off,len,data,f)#define xfs_buf_zero (bp,off,len) libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)/* mount stuff */
@@ -436,8 +432,6 @@ roundup_64(uint64_t x, uint32_t y)#define xfs_sort qsort#define xfs_ilock (ip,mode) ((void) 0) -#define xfs_ilock_nowait (ip,mode) ((void) 0) -#define xfs_ilock_demote (ip,mode) ((void) 0)#define xfs_ilock_data_map_shared (ip) (0)#define xfs_ilock_attr_map_shared (ip) (0)#define xfs_iunlock (ip,mode) ({ \
@@ -470,9 +464,6 @@ roundup_64(uint64_t x, uint32_t y)#define xfs_filestream_lookup_ag (ip) (0)#define xfs_filestream_new_ag (ip,ag) (0) -#define xfs_log_force (mp,flags) ((void) 0) -#define XFS_LOG_SYNC 1 -/* quota bits */ #define xfs_trans_mod_dquot_byino (t,i,f,d) ((void) 0)#define xfs_trans_reserve_quota_nblks (t,i,b,n,f) (0)
libxfs/util.c +0 -29
@@ -603,35 +603,6 @@ libxfs_inode_alloc(return error; } -/* -* Userspace versions of common diagnostic routines (varargs fun). -*/ -void -libxfs_fs_repair_cmn_err (int level,xfs_mount_t *mp,char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -fprintf (stderr," This is a bug.\n" ); -fprintf (stderr,"%s version %s\n" , progname,VERSION ); -fprintf (stderr, -"Please capture the filesystem metadata with xfs_metadump and\n" -"report it to [email protected]\n" ); -va_end (ap); -} - -void -libxfs_fs_cmn_err (int level,xfs_mount_t *mp,char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -fputs ("\n" , stderr); -va_end (ap); -} -void cmn_err (int level,char *fmt, ...) {
Signature · 1 line
1.8.3.1
PATCH v2 3/11 libxfs: remove unused cruft
Remove many unused #defines and functions.
---
V2: Remove libxfs_trans_ijoin_ref as well
include/libxfs.h +0 -3
@@ -154,9 +154,6 @@ extern int libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,extern int libxfs_alloc_file_space (struct xfs_inode *,xfs_off_t ,xfs_off_t ,int ,int ); -extern void libxfs_fs_repair_cmn_err (int ,struct xfs_mount *,char *, ...); -extern void libxfs_fs_cmn_err (int ,struct xfs_mount *,char *, ...); -/* XXX: this is messy and needs fixing */ #ifndef __LIBXFS_INTERNAL_XFS_H__extern void cmn_err (int ,char *, ...);
include/xfs_trans.h +0 -9
@@ -47,13 +47,6 @@ typedef struct xfs_buf_log_item {#define XFS_BLI_STALE (1<<2)#define XFS_BLI_INODE_ALLOC_BUF (1<<3) -typedef struct xfs_dq_logitem { -xfs_log_item_t qli_item;/* common portion */ -struct xfs_dquot *qli_dquot;/* dquot ptr */ -xfs_lsn_t qli_flush_lsn;/* lsn at last flush */ -xfs_dq_logformat_t qli_format;/* logged structure */ -}xfs_dq_logitem_t ; - typedef struct xfs_qoff_logitem { xfs_log_item_t qql_item; /* common portion */ struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */
@@ -64,7 +57,6 @@ typedef struct xfs_qoff_logitem {#define XFS_DEFER_OPS_NR_BUFS 2/* join up to two buffers */ typedef struct xfs_trans { - unsigned int t_type; /* transaction type */ unsigned int t_log_res; /* amt of log space resvd */ unsigned int t_log_count; /* count for perm log res */ unsigned int t_blk_res; /* # of blocks resvd */
@@ -98,7 +90,6 @@ void xfs_defer_cancel(struct xfs_trans *);struct xfs_buf *libxfs_trans_getsb (struct xfs_trans *,struct xfs_mount *,int );void libxfs_trans_ijoin (struct xfs_trans *,struct xfs_inode *,uint ); -void libxfs_trans_ijoin_ref (struct xfs_trans *,struct xfs_inode *,int );void libxfs_trans_log_inode (struct xfs_trans *,struct xfs_inode *,uint );int libxfs_trans_roll_inode (struct xfs_trans **,struct xfs_inode *);
libxfs/libxfs_api_defs.h +0 -5
@@ -16,9 +16,6 @@#define xfs_highbit32 libxfs_highbit32#define xfs_highbit64 libxfs_highbit64 -#define xfs_fs_repair_cmn_err libxfs_fs_repair_cmn_err -#define xfs_fs_cmn_err libxfs_fs_cmn_err -#define xfs_trans_alloc libxfs_trans_alloc#define xfs_trans_alloc_empty libxfs_trans_alloc_empty#define xfs_trans_add_item libxfs_trans_add_item
@@ -61,7 +58,6 @@#define xfs_bmapi_write libxfs_bmapi_write#define xfs_bmapi_read libxfs_bmapi_read#define xfs_bunmapi libxfs_bunmapi -#define xfs_bmbt_get_all libxfs_bmbt_get_all#define xfs_rtfree_extent libxfs_rtfree_extent#define xfs_verify_rtbno libxfs_verify_rtbno#define xfs_verify_ino libxfs_verify_ino
@@ -70,7 +66,6 @@#define xfs_defer_finish libxfs_defer_finish#define xfs_defer_cancel libxfs_defer_cancel -#define xfs_da_brelse libxfs_da_brelse#define xfs_da_hashname libxfs_da_hashname#define xfs_da_shrink_inode libxfs_da_shrink_inode#define xfs_da_read_buf libxfs_da_read_buf
libxfs/libxfs_priv.h +0 -9
@@ -122,7 +122,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args) #define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) #define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) -#define xfs_alert_tag(mp,tag,fmt,args...) cmn_err(CE_ALERT,fmt, ## args)#define xfs_hex_dump (d,n) ((void) 0)#define xfs_stack_trace () ((void) 0)
@@ -195,8 +194,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };#endif /* miscellaneous kernel routines not in user space */ -#define down_read (a) ((void) 0) -#define up_read (a) ((void) 0)#define spin_lock_init (a) ((void) 0)#define spin_lock (a) ((void) 0)#define spin_unlock (a) ((void) 0)
@@ -400,7 +397,6 @@ roundup_64(uint64_t x, uint32_t y)#define XBRW_READ LIBXFS_BREAD#define XBRW_WRITE LIBXFS_BWRITE -#define xfs_buf_iomove (bp,off,len,data,f) libxfs_iomove(bp,off,len,data,f)#define xfs_buf_zero (bp,off,len) libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)/* mount stuff */
@@ -436,8 +432,6 @@ roundup_64(uint64_t x, uint32_t y)#define xfs_sort qsort#define xfs_ilock (ip,mode) ((void) 0) -#define xfs_ilock_nowait (ip,mode) ((void) 0) -#define xfs_ilock_demote (ip,mode) ((void) 0)#define xfs_ilock_data_map_shared (ip) (0)#define xfs_ilock_attr_map_shared (ip) (0)#define xfs_iunlock (ip,mode) ({ \
@@ -470,9 +464,6 @@ roundup_64(uint64_t x, uint32_t y)#define xfs_filestream_lookup_ag (ip) (0)#define xfs_filestream_new_ag (ip,ag) (0) -#define xfs_log_force (mp,flags) ((void) 0) -#define XFS_LOG_SYNC 1 -/* quota bits */ #define xfs_trans_mod_dquot_byino (t,i,f,d) ((void) 0)#define xfs_trans_reserve_quota_nblks (t,i,b,n,f) (0)
libxfs/trans.c +0 -15
@@ -360,21 +360,6 @@ libxfs_trans_ijoin( }void -libxfs_trans_ijoin_ref ( -xfs_trans_t *tp, -xfs_inode_t *ip, -int lock_flags) -{ -ASSERT (ip->i_itemp !=NULL ); - -xfs_trans_ijoin (tp, ip, lock_flags); - -#ifdef XACT_DEBUG -fprintf (stderr,"ijoin_ref'd inode %llu, transaction %p\n" , ip->i_ino, tp); -#endif -} - -void libxfs_trans_inode_alloc_buf (xfs_trans_t *tp,xfs_buf_t *bp)
libxfs/util.c +0 -29
@@ -603,35 +603,6 @@ libxfs_inode_alloc(return error; } -/* -* Userspace versions of common diagnostic routines (varargs fun). -*/ -void -libxfs_fs_repair_cmn_err (int level,xfs_mount_t *mp,char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -fprintf (stderr," This is a bug.\n" ); -fprintf (stderr,"%s version %s\n" , progname,VERSION ); -fprintf (stderr, -"Please capture the filesystem metadata with xfs_metadump and\n" -"report it to [email protected]\n" ); -va_end (ap); -} - -void -libxfs_fs_cmn_err (int level,xfs_mount_t *mp,char *fmt, ...) -{ -va_list ap; - -va_start (ap, fmt); -vfprintf (stderr, fmt, ap); -fputs ("\n" , stderr); -va_end (ap); -} -void cmn_err (int level,char *fmt, ...) {
Re: [PATCH 03/11 V2] libxfs: remove unused cruft
Quoted 4 lines · Eric Sandeen
Remove many unused #defines and functions.
Signed-off-by Eric Sandeen <[email protected]>---
....
libxfs/libxfs_priv.h enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; · line 199
Quoted 6 lines
/* miscellaneous kernel routines not in user space */
libxfs/libxfs_priv.h +0
-2-#define down_read (a) ((void) 0) -#define up_read (a) ((void) 0)#define spin_lock_init (a) ((void) 0)#define spin_lock (a) ((void) 0)#define spin_unlock (a) ((void) 0)
The lack of locking in the userspace code scares me somewhat :P
Quoted 9 lines
libxfs/libxfs_priv.h +0
-1@@ -400,7 +397,6 @@ roundup_64(uint64_t x, uint32_t y)#define XBRW_READ LIBXFS_BREAD#define XBRW_WRITE LIBXFS_BWRITE -#define xfs_buf_iomove (bp,off,len,data,f) libxfs_iomove(bp,off,len,data,f)#define xfs_buf_zero (bp,off,len) libxfs_iomove(bp,off,len,NULL,LIBXFS_BZERO)/* mount stuff */
libxfs/libxfs_priv.h roundup_64(uint64_t x, uint32_t y) · line 440
Quoted 5 lines
libxfs/libxfs_priv.h +0
-2@@ -436,8 +432,6 @@ roundup_64(uint64_t x, uint32_t y)#define xfs_sort qsort#define xfs_ilock (ip,mode) ((void) 0) -#define xfs_ilock_nowait (ip,mode) ((void) 0) -#define xfs_ilock_demote (ip,mode) ((void) 0)
Especially that we have transactions that run without inode locks.
But that's not a problem this patch solves, so may as well get rid of the unused interfaces...
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 03/11] libxfs: remove unused cruft
In reply to Eric SandeenQuoted 3 lines · Eric Sandeen
Remove many unused #defines and functions.
Signed-off-by Eric Sandeen <[email protected]>
Looks good,
PATCH 4/11 libxfs: rename bp_transp to b_transp in ASSERTs
In reply to Eric Sandeenxfs_buf no longer has a bp_transp member; it's b_transp now. These ASSERTs get #defined away, but it's still best to not have invalid structure members cluttering up the code.
--- libxfs/trans.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
libxfs/trans.c +10 -10
@@ -381,7 +381,7 @@ libxfs_trans_inode_alloc_buf( {xfs_buf_log_item_t *bip = bp->b_log_item; -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp);ASSERT (bip !=NULL ); bip->bli_flags |=XFS_BLI_INODE_ALLOC_BUF ;xfs_trans_buf_set_type (tp, bp,XFS_BLFT_DINO_BUF );
@@ -446,7 +446,7 @@ libxfs_trans_dirty_buf( {struct xfs_buf_log_item *bip = bp->b_log_item; -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp);ASSERT (bip !=NULL );#ifdef XACT_DEBUG
@@ -521,11 +521,11 @@ libxfs_trans_brelse(#endif if (tp ==NULL ) { -ASSERT (bp->bp_transp ==NULL ); +ASSERT (bp->b_transp ==NULL );libxfs_putbuf (bp);return ; } -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp); bip = bp->b_log_item;ASSERT (bip->bli_item.li_type ==XFS_LI_BUF );if (bip->bli_recur >0 ) {
@@ -555,7 +555,7 @@ libxfs_trans_binval(fprintf (stderr,"binval'd buffer %p, transaction %p\n" , bp, tp);#endif -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp);ASSERT (bip !=NULL );if (bip->bli_flags &XFS_BLI_STALE )
@@ -577,7 +577,7 @@ libxfs_trans_bjoin( {xfs_buf_log_item_t *bip; -ASSERT (bp->bp_transp ==NULL ); +ASSERT (bp->b_transp ==NULL );#ifdef XACT_DEBUG fprintf (stderr,"bjoin'd buffer %p, transaction %p\n" , bp, tp);#endif
@@ -595,7 +595,7 @@ libxfs_trans_bhold( {xfs_buf_log_item_t *bip = bp->b_log_item; -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp);ASSERT (bip !=NULL );#ifdef XACT_DEBUG fprintf (stderr,"bhold'd buffer %p, transaction %p\n" , bp, tp);
@@ -620,7 +620,7 @@ libxfs_trans_get_buf_map( bp =xfs_trans_buf_item_match (tp, btp, map, nmaps);if (bp !=NULL ) { -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp); bip = bp->b_log_item;ASSERT (bip !=NULL ); bip->bli_recur++;
@@ -656,7 +656,7 @@ libxfs_trans_getsb( bp =xfs_trans_buf_item_match (tp, mp->m_dev, &map,1 );if (bp !=NULL ) { -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp); bip = bp->b_log_item;ASSERT (bip !=NULL ); bip->bli_recur++;
@@ -703,7 +703,7 @@ libxfs_trans_read_buf_map( bp =xfs_trans_buf_item_match (tp, btp, map, nmaps);if (bp !=NULL ) { -ASSERT (bp->bp_transp == tp); +ASSERT (bp->b_transp == tp);ASSERT (bp->b_log_item !=NULL ); bip = bp->b_log_item; bip->bli_recur++;
Signature · 1 line
1.8.3.1
Re: [PATCH 04/11] libxfs: rename bp_transp to b_transp in ASSERTs
Quoted 5 lines · Eric Sandeen
xfs_bufno longer has abp_transpmember; it'sb_transpnow. These ASSERTs get #defined away, but it's still best to not have invalid structure members cluttering up the code.Signed-off-by Eric Sandeen <[email protected]>
looks good.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 04/11] libxfs: rename bp_transp to b_transp in ASSERTs
In reply to Eric SandeenLooks good,
PATCH 5/11 libxfs: de-libxfsify core(-ish) functions.
In reply to Eric SandeenThere are a ton of "libxfs_" prefixed functions in libxfs/trans.c which are only called internally by code in libxfs/ - As I understand it, these should probably be just "xfs_" functions, and indeed many of them have counterparts in the kernel libxfs/ code. This is one small step towards better sync-up of some of the misc libxfs/* transaction code with kernel code.
--- libxfs/libxfs_api_defs.h | 1 + libxfs/trans.c | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 24 deletions(-)
libxfs/libxfs_api_defs.h +1 -0
@@ -17,6 +17,7 @@#define xfs_highbit64 libxfs_highbit64#define xfs_trans_alloc libxfs_trans_alloc +#define xfs_trans_alloc_rollable libxfs_trans_alloc_rollable#define xfs_trans_alloc_empty libxfs_trans_alloc_empty#define xfs_trans_add_item libxfs_trans_add_item#define xfs_trans_bhold libxfs_trans_bhold
libxfs/trans.c +24 -24
192 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 05/11] libxfs: de-libxfsify core(-ish) functions.
Quoted 6 lines · Eric Sandeen
There are a ton of "
libxfs_" prefixed functions inlibxfs/trans.cwhich are only called internally by code in libxfs/ - As I understand it, these should probably be just "xfs_" functions, and indeed many of them have counterparts in the kernel libxfs/ code. This is one small step towards better sync-up of some of the misc libxfs/* transaction code with kernel code.
I should have changed internal callers too, will resend after other review.
Quoted 239 lines
Signed-off-by Eric Sandeen <[email protected]>--- libxfs/libxfs_api_defs.h | 1 + libxfs/trans.c | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 24 deletions(-)libxfs/libxfs_api_defs.h +1
-0@@ -17,6 +17,7 @@#define xfs_highbit64 libxfs_highbit64#define xfs_trans_alloc libxfs_trans_alloc +#define xfs_trans_alloc_rollable libxfs_trans_alloc_rollable#define xfs_trans_alloc_empty libxfs_trans_alloc_empty#define xfs_trans_add_item libxfs_trans_add_item#define xfs_trans_bhold libxfs_trans_bholdlibxfs/trans.c +24
-24@@ -36,7 +36,7 @@ kmem_zone_t *xfs_trans_zone;* in the mount structure. */ void -libxfs_trans_init ( +xfs_trans_init (struct xfs_mount *mp) {xfs_trans_resv_calc (mp, &mp->m_resv);@@ -46,7 +46,7 @@ libxfs_trans_init(* Add the given log item to the transaction's list of log items. */ void -libxfs_trans_add_item ( +xfs_trans_add_item (struct xfs_trans *tp,struct xfs_log_item *lip) {@@ -62,7 +62,7 @@ libxfs_trans_add_item(* Unlink and free the given descriptor. */ void -libxfs_trans_del_item ( +xfs_trans_del_item (struct xfs_log_item *lip) {clear_bit (XFS_LI_DIRTY , &lip->li_flags);@@ -77,7 +77,7 @@ libxfs_trans_del_item(* chunk we've been working on and get a new transaction to continue. */ int -libxfs_trans_roll ( +xfs_trans_roll (struct xfs_trans **tpp) {struct xfs_trans *trans = *tpp;@@ -245,7 +245,7 @@ undo_blocks: } int -libxfs_trans_alloc( +xfs_trans_alloc( struct xfs_mount *mp, struct xfs_trans_res *resp, unsigned int blocks,@@ -289,7 +289,7 @@ libxfs_trans_alloc(* without any dirty data. */ int -libxfs_trans_alloc_empty ( +xfs_trans_alloc_empty (struct xfs_mount *mp,struct xfs_trans **tpp) {@@ -304,7 +304,7 @@ libxfs_trans_alloc_empty(* permanent log reservation flag to avoid blowing asserts. */ int -libxfs_trans_alloc_rollable ( +xfs_trans_alloc_rollable (struct xfs_mount *mp,unsigned int blocks,struct xfs_trans **tpp)@@ -314,7 +314,7 @@ libxfs_trans_alloc_rollable( }void -libxfs_trans_cancel ( +xfs_trans_cancel (struct xfs_trans *tp) {#ifdef XACT_DEBUG @@ -337,7 +337,7 @@ out: }void -libxfs_trans_ijoin ( +xfs_trans_ijoin (xfs_trans_t *tp,xfs_inode_t *ip,uint lock_flags)@@ -360,7 +360,7 @@ libxfs_trans_ijoin( }void -libxfs_trans_ijoin_ref ( +xfs_trans_ijoin_ref (xfs_trans_t *tp,xfs_inode_t *ip,int lock_flags)@@ -375,7 +375,7 @@ libxfs_trans_ijoin_ref( }void -libxfs_trans_inode_alloc_buf ( +xfs_trans_inode_alloc_buf (xfs_trans_t *tp,xfs_buf_t *bp) {@@ -422,7 +422,7 @@ xfs_trans_log_inode( }int -libxfs_trans_roll_inode ( +xfs_trans_roll_inode (struct xfs_trans **tpp,struct xfs_inode *ip) {@@ -440,7 +440,7 @@ libxfs_trans_roll_inode(* Mark a buffer dirty in the transaction. */ void -libxfs_trans_dirty_buf ( +xfs_trans_dirty_buf (struct xfs_trans *tp,struct xfs_buf *bp) {@@ -466,7 +466,7 @@ libxfs_trans_dirty_buf(* value of b_blkno. */ void -libxfs_trans_log_buf( +xfs_trans_log_buf( struct xfs_trans *tp, struct xfs_buf *bp, uint first,@@ -488,7 +488,7 @@ libxfs_trans_log_buf(* If the buffer is already dirty, trigger the "already logged" return condition. */ bool -libxfs_trans_ordered_buf ( +xfs_trans_ordered_buf (struct xfs_trans *tp,struct xfs_buf *bp) {@@ -511,7 +511,7 @@ xfs_buf_item_put( }void -libxfs_trans_brelse ( +xfs_trans_brelse (xfs_trans_t *tp,xfs_buf_t *bp) {@@ -546,7 +546,7 @@ libxfs_trans_brelse( }void -libxfs_trans_binval ( +xfs_trans_binval (xfs_trans_t *tp,xfs_buf_t *bp) {@@ -571,7 +571,7 @@ libxfs_trans_binval( }void -libxfs_trans_bjoin ( +xfs_trans_bjoin (xfs_trans_t *tp,xfs_buf_t *bp) {@@ -589,7 +589,7 @@ libxfs_trans_bjoin( }void -libxfs_trans_bhold ( +xfs_trans_bhold (xfs_trans_t *tp,xfs_buf_t *bp) {@@ -605,7 +605,7 @@ libxfs_trans_bhold( }xfs_buf_t * -libxfs_trans_get_buf_map( +xfs_trans_get_buf_map( xfs_trans_t *tp, struct xfs_buftarg *btp, struct xfs_buf_map *map,@@ -641,7 +641,7 @@ libxfs_trans_get_buf_map( }xfs_buf_t * -libxfs_trans_getsb ( +xfs_trans_getsb (xfs_trans_t *tp,xfs_mount_t *mp,int flags)@@ -675,7 +675,7 @@ libxfs_trans_getsb( } int -libxfs_trans_read_buf_map( +xfs_trans_read_buf_map( xfs_mount_t *mp, xfs_trans_t *tp, struct xfs_buftarg *btp,@@ -743,7 +743,7 @@ out_relse:* Originally derived from xfs_trans_mod_sb(). */ void -libxfs_trans_mod_sb ( +xfs_trans_mod_sb (xfs_trans_t *tp,uint field,long delta)@@ -1004,7 +1004,7 @@ out_unreserve: }int -libxfs_trans_commit ( +xfs_trans_commit (struct xfs_trans *tp) {return __xfs_trans_commit (tp, false);
Re: [PATCH 05/11] libxfs: de-libxfsify core(-ish) functions.
Quoted 10 lines · Eric Sandeen
Quoted 6 lines · Eric Sandeen
There are a ton of "
libxfs_" prefixed functions inlibxfs/trans.cwhich are only called internally by code in libxfs/ - As I understand it, these should probably be just "xfs_" functions, and indeed many of them have counterparts in the kernel libxfs/ code. This is one small step towards better sync-up of some of the misc libxfs/* transaction code with kernel code.I should have changed internal callers too, will resend after other review.
I have to admit I never got this whole libxfs renaming. Why can't we just use the xfs_* namespace for libxfs as well to start with?
Re: [PATCH 05/11] libxfs: de-libxfsify core(-ish) functions.
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Eric Sandeen
Quoted 6 lines · Eric Sandeen
There are a ton of "
libxfs_" prefixed functions inlibxfs/trans.cwhich are only called internally by code in libxfs/ - As I understand it, these should probably be just "xfs_" functions, and indeed many of them have counterparts in the kernel libxfs/ code. This is one small step towards better sync-up of some of the misc libxfs/* transaction code with kernel code.
Quoted 6 lines
Quoted 2 lines
I should have changed internal callers too, will resend after other review.
I have to admit I never got this whole libxfs renaming. Why can't we just use the xfs_* namespace for libxfs as well to start with?
I'm struggling to understand it as well. I have a 2nd patch to move still more of the shared-ish xfs functions to strip off the "lib" part, and for the rest I don't know - I'm trying to get to where I understand the original intent of all this ...
Thanks,
-Eric
PATCH 6/11 libxfs: create new file trans_buf.c
In reply to Eric SandeenPull functions out of libxfs/*.c into trans_buf.c, if they roughly match the kernel's xfs_trans_buf.c file.
--- libxfs/Makefile | 1 + libxfs/libxfs_priv.h | 1 + libxfs/logitem.c | 36 ------ libxfs/trans.c | 301 ------------------------------------------- libxfs/trans_buf.c | 354 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 356 insertions(+), 337 deletions(-) create mode 100644 libxfs/trans_buf.c
libxfs/Makefile +1 -0
@@ -58,6 +58,7 @@ CFILES = cache.c \ logitem.c \ rdwr.c \ trans.c \ + trans_buf.c \ util.c \ xfs_ag.c \ xfs_ag_resv.c \
libxfs/libxfs_priv.h +1 -0
@@ -519,6 +519,7 @@ void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);/* xfs_buf_item.c */ void xfs_buf_item_init (struct xfs_buf *,struct xfs_mount *);void xfs_buf_item_log (struct xfs_buf_log_item *,uint ,uint ); +void xfs_buf_item_put (struct xfs_buf_log_item *bip);/* xfs_trans_buf.c */ struct xfs_buf *xfs_trans_buf_item_match(struct xfs_trans *,
libxfs/logitem.c +0 -36
@@ -20,42 +20,6 @@ kmem_zone_t *xfs_buf_item_zone;kmem_zone_t *xfs_ili_zone;/* inode log item zone */ /* -* Following functions from fs/xfs/xfs_trans_buf.c -*/ - -/* -* Check to see if a buffer matching the given parameters is already -* a part of the given transaction. -*/ -xfs_buf_t * -xfs_trans_buf_item_match ( -xfs_trans_t *tp, -struct xfs_buftarg *btp, -struct xfs_buf_map *map, -int nmaps) -{ -struct xfs_log_item *lip; -struct xfs_buf_log_item *blip; -int len =0 ; -int i; - -for (i =0 ; i < nmaps; i++) - len += map[i].bm_len; - -list_for_each_entry (lip, &tp->t_items, li_trans) { - blip = (struct xfs_buf_log_item *)lip; -if (blip->bli_item.li_type ==XFS_LI_BUF && - blip->bli_buf->b_target->dev == btp->dev && -XFS_BUF_ADDR (blip->bli_buf) == map[0 ].bm_bn && - blip->bli_buf->b_bcount ==BBTOB (len)) { -ASSERT (blip->bli_buf->b_map_count == nmaps); -return blip->bli_buf; - } - } - -return NULL ; -} -/* * The following are from fs/xfs/xfs_buf_item.c */
libxfs/trans.c +0 -301
320 lines not on this page · raw message
libxfs/trans_buf.c new file +354 -0
354 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 06/11] libxfs: create new file trans_buf.c
Quoted 4 lines · Eric Sandeen
Pull functions out of libxfs/*.c into
trans_buf.c, if they roughly match the kernel'sxfs_trans_buf.cfile.Signed-off-by Eric Sandeen <[email protected]>
So I have no problems with this, but I'm not sure what the eventual goal is? Just sharing code, or is there some functionality that requires a more complete transaction subsystem in userspace?
I'm asking because if the goal is eventual unification with the kernel code, then we probably should name the files the same as the kernel code so we don't have to rename them again when we do the unification. That will make history searching a bit easier - less file names to follow across and git blame works a whole lot better...
libxfs/trans_buf.c line 153
Quoted 10 lines
libxfs/trans_buf.c new file +10
-0+int +xfs_trans_read_buf_map ( +xfs_mount_t *mp, +xfs_trans_t *tp, +struct xfs_buftarg *btp, +struct xfs_buf_map *map, +int nmaps, +uint flags, +xfs_buf_t **bpp, +const struct xfs_buf_ops *ops)
Hmmmm. Will there be any follow-up to de-typedef these new files?
/me would love to just have a flag day that de-typedefs all of the userspace code.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 06/11] libxfs: create new file trans_buf.c
Quoted 10 lines · Dave Chinner
Quoted 4 lines · Eric Sandeen
Pull functions out of libxfs/*.c into
trans_buf.c, if they roughly match the kernel'sxfs_trans_buf.cfile.Signed-off-by Eric Sandeen <[email protected]>So I have no problems with this, but I'm not sure what the eventual goal is? Just sharing code, or is there some functionality that requires a more complete transaction subsystem in userspace?
Quoted 5 lines
I'm asking because if the goal is eventual unification with the kernel code, then we probably should name the files the same as the kernel code so we don't have to rename them again when we do the unification. That will make history searching a bit easier - less file names to follow across and git blame works a whole lot better...
Even if we don't want to directly share code having the same file name would still be nice..
Re: [PATCH 06/11] libxfs: create new file trans_buf.c
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Dave Chinner
Quoted 4 lines · Eric Sandeen
Pull functions out of libxfs/*.c into
trans_buf.c, if they roughly match the kernel'sxfs_trans_buf.cfile.Signed-off-by Eric Sandeen <[email protected]>So I have no problems with this, but I'm not sure what the eventual goal is? Just sharing code, or is there some functionality that requires a more complete transaction subsystem in userspace?
Quoted 8 lines
Quoted 5 lines
I'm asking because if the goal is eventual unification with the kernel code, then we probably should name the files the same as the kernel code so we don't have to rename them again when we do the unification. That will make history searching a bit easier - less file names to follow across and git blame works a whole lot better...
Even if we don't want to directly share code having the same file name would still be nice..
That's the goal, but I didn't want to do it until they really were shared. Right now scripts to merge and diff assume that libxfs/xfs_* are shared w/ kernel.
We could work around that, but I just figured I wouldn't give them the same name until they are really the same file.
Doesn't matter much to me either way tbh.
-Eric
Re: [PATCH 06/11] libxfs: create new file trans_buf.c
In reply to Dave ChinnerQuoted 29 lines · Dave Chinner
Quoted 4 lines · Eric Sandeen
Pull functions out of libxfs/*.c into
trans_buf.c, if they roughly match the kernel'sxfs_trans_buf.cfile.Signed-off-by Eric Sandeen <[email protected]>So I have no problems with this, but I'm not sure what the eventual goal is? Just sharing code, or is there some functionality that requires a more complete transaction subsystem in userspace?
I'm asking because if the goal is eventual unification with the kernel code, then we probably should name the files the same as the kernel code so we don't have to rename them again when we do the unification. That will make history searching a bit easier - less file names to follow across and git blame works a whole lot better...
libxfs/trans_buf.c line 153
Quoted 10 lines
libxfs/trans_buf.c new file +10
-0+int +xfs_trans_read_buf_map ( +xfs_mount_t *mp, +xfs_trans_t *tp, +struct xfs_buftarg *btp, +struct xfs_buf_map *map, +int nmaps, +uint flags, +xfs_buf_t **bpp, +const struct xfs_buf_ops *ops)Hmmmm. Will there be any follow-up to de-typedef these new files?
Quoted 2 lines
/me would love to just have a flag day that de-typedefs all of the userspace code.
Yes, after I moved stuff enough to see how/if it matches the kernel, I de-typdefed to match where the kernel has done so.
I could certainly roll that into this patch. I was trying to do small steps but maybe that just makes things more complex to follow...
-Eric
PATCH 7/11 libxfs: create new file buf_item.c
In reply to Eric SandeenPull functions out of libxfs/* into buf_item.c, if they roughly match the kernel's xfs_buf_item.c file.
--- libxfs/Makefile | 1 + libxfs/buf_item.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_priv.h | 2 + libxfs/logitem.c | 77 --------------------------- libxfs/trans.c | 55 ------------------- 5 files changed, 149 insertions(+), 132 deletions(-) create mode 100644 libxfs/buf_item.c
libxfs/Makefile +1 -0
@@ -52,6 +52,7 @@ HFILES = \ xfs_dir2_priv.h CFILES = cache.c \ + buf_item.c \ defer_item.c \ init.c \ kmem.c \
libxfs/buf_item.c new file +146 -0
146 lines not on this page · raw message
libxfs/libxfs_priv.h +2 -0
@@ -520,6 +520,8 @@ void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);void xfs_buf_item_init (struct xfs_buf *,struct xfs_mount *);void xfs_buf_item_log (struct xfs_buf_log_item *,uint ,uint );void xfs_buf_item_put (struct xfs_buf_log_item *bip); +void buf_item_unlock (struct xfs_buf_log_item *bip); +void buf_item_done (struct xfs_buf_log_item *bip);/* xfs_trans_buf.c */ struct xfs_buf *xfs_trans_buf_item_match(struct xfs_trans *,
libxfs/logitem.c +0 -77
86 lines not on this page · raw message
libxfs/trans.c +0 -55
73 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 8/11 libxfs: create new file inode_item.c
In reply to Eric SandeenPull functions out of libxfs/* into inode_item.c, if they roughly match the kernel's xfs_inode_item.c file.
--- libxfs/Makefile | 2 +- libxfs/inode_item.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_priv.h | 3 ++ libxfs/logitem.c | 43 ------------------- libxfs/trans.c | 75 --------------------------------- 5 files changed, 121 insertions(+), 119 deletions(-) create mode 100644 libxfs/inode_item.c delete mode 100644 libxfs/logitem.c
libxfs/Makefile +1 -1
@@ -55,8 +55,8 @@ CFILES = cache.c \ buf_item.c \ defer_item.c \ init.c \ + inode_item.c \ kmem.c \ - logitem.c \ rdwr.c \ trans.c \ trans_buf.c \
libxfs/inode_item.c new file +117 -0
117 lines not on this page · raw message
libxfs/libxfs_priv.h +3 -0
@@ -491,6 +491,7 @@ struct xfs_log_item;struct xfs_buf ;struct xfs_buf_map ;struct xfs_buf_log_item ; +struct xfs_inode_log_item ;struct xfs_buftarg ;/* xfs_attr.c */
@@ -515,6 +516,8 @@ void xfs_trans_del_item(struct xfs_log_item *);/* xfs_inode_item.c */ void xfs_inode_item_init (struct xfs_inode *,struct xfs_mount *); +void inode_item_done (struct xfs_inode_log_item *iip); +void inode_item_unlock (struct xfs_inode_log_item *iip);/* xfs_buf_item.c */ void xfs_buf_item_init (struct xfs_buf *,struct xfs_mount *);
libxfs/logitem.c deleted +0 -43
43 lines not on this page · raw message
libxfs/trans.c +0 -75
87 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 9/11 libxfs: create new file trans_inode.c
In reply to Eric SandeenPull functions out of libxfs/trans.c into trans_inode.c, if they roughly match the kernel's xfs_trans_inode.c file.
--- libxfs/Makefile | 1 + libxfs/trans.c | 86 ----------------------------------------- libxfs/trans_inode.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 86 deletions(-) create mode 100644 libxfs/trans_inode.c
libxfs/Makefile +1 -0
@@ -60,6 +60,7 @@ CFILES = cache.c \ rdwr.c \ trans.c \ trans_buf.c \ + trans_inode.c \ util.c \ xfs_ag.c \ xfs_ag_resv.c \
libxfs/trans.c +0 -86
92 lines not on this page · raw message
libxfs/trans_inode.c new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 10/11 libxfs: reorder trans.c to match xfs_trans.c
In reply to Eric SandeenReorder the functions in libxfs/trans.c to more closely match the order in the kernel's xfs_trans.c. It's not 1:1 but much closer now, and the forward declarations can be removed as well.
--- libxfs/trans.c | 251 +++++++++++++++++++++++++++------------------------------ 1 file changed, 121 insertions(+), 130 deletions(-)
libxfs/trans.c +121 -130
@@ -12,19 +12,10 @@#include "xfs_log_format.h" #include "xfs_trans_resv.h" #include "xfs_mount.h" -#include "xfs_inode_buf.h" -#include "xfs_inode_fork.h" -#include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_sb.h" #include "xfs_defer.h" -static void xfs_trans_free_items (struct xfs_trans *tp); -STATIC struct xfs_trans *xfs_trans_dup(struct xfs_trans *tp); -static int xfs_trans_reserve (struct xfs_trans *tp,struct xfs_trans_res *resp, -uint blocks,uint rtextents); -static int __xfs_trans_commit (struct xfs_trans *tp,bool regrant); -/* * Simple transaction interface */
@@ -43,79 +34,6 @@ xfs_trans_init( }/* -* Add the given log item to the transaction's list of log items. -*/ -void -xfs_trans_add_item ( -struct xfs_trans *tp, -struct xfs_log_item *lip) -{ -ASSERT (lip->li_mountp == tp->t_mountp); -ASSERT (lip->li_ailp == tp->t_mountp->m_ail); -ASSERT (list_empty (&lip->li_trans)); -ASSERT (!test_bit (XFS_LI_DIRTY , &lip->li_flags)); - -list_add_tail (&lip->li_trans, &tp->t_items); -} - -/* -* Unlink and free the given descriptor. -*/ -void -xfs_trans_del_item ( -struct xfs_log_item *lip) -{ -clear_bit (XFS_LI_DIRTY , &lip->li_flags); -list_del_init (&lip->li_trans); -} - -/* -* 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 -* 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. -*/ -int -xfs_trans_roll ( -struct xfs_trans **tpp) -{ -struct xfs_trans *trans = *tpp; -struct xfs_trans_res tres; -int error; - -/* -* 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); - -/* -* Commit the current transaction. -* If this commit failed, then it'd just unlock those items that -* are marked to be released. That also means that a filesystem shutdown -* is in progress. The caller takes the responsibility to cancel -* the duplicate transaction that gets returned. -*/ - error =__xfs_trans_commit (trans, true); -if (error) -return error; - -/* -* Reserve space in the log for the 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 -* that we want to use. This requires that either nothing be locked -* across this call, or that anything that is locked be logged in -* the prior and the next transactions. -*/ - tres.tr_logflags =XFS_TRANS_PERM_LOG_RES ; -return xfs_trans_reserve (*tpp, &tres,0 ,0 ); -} - -/* * Free the transaction structure. If there is more clean up * to do when the structure is freed, add it here. */
@@ -277,6 +195,21 @@ xfs_trans_alloc( }/* +* Allocate a transaction that can be rolled. Since userspace doesn't have +* a need for log reservations, we really only tr_itruncate to get the +* permanent log reservation flag to avoid blowing asserts. +*/ +int +libxfs_trans_alloc_rollable ( +struct xfs_mount *mp, +unsigned int blocks, +struct xfs_trans **tpp) +{ +return xfs_trans_alloc (mp, &M_RES (mp)->tr_itruncate, blocks, +0 ,0 , tpp); +} + +/* * Create an empty transaction with no reservation. This is a defensive * mechanism for routines that query metadata without actually modifying * them -- if the metadata being queried is somehow cross-linked (think a
@@ -299,44 +232,6 @@ xfs_trans_alloc_empty( }/* -* Allocate a transaction that can be rolled. Since userspace doesn't have -* a need for log reservations, we really only tr_itruncate to get the -* permanent log reservation flag to avoid blowing asserts. -*/ -int -xfs_trans_alloc_rollable ( -struct xfs_mount *mp, -unsigned int blocks, -struct xfs_trans **tpp) -{ -return libxfs_trans_alloc (mp, &M_RES (mp)->tr_itruncate, blocks, -0 ,0 , tpp); -} - -void -xfs_trans_cancel ( -struct xfs_trans *tp) -{ -#ifdef XACT_DEBUG -struct xfs_trans *otp = tp; -#endif -if (tp ==NULL ) - goto out; - -if (tp->t_flags &XFS_TRANS_PERM_LOG_RES ) -xfs_defer_cancel (tp); - -xfs_trans_free_items (tp); -xfs_trans_free (tp); - -out: -#ifdef XACT_DEBUG -fprintf (stderr,"## cancelled transaction %p\n" , otp); -#endif -return ; -} - -/* * Record the indicated change to the given field for application * to the file system's superblock when the transaction commits. * For now, just store the change in the transaction structure.
@@ -383,19 +278,46 @@ _("Transaction block reservation exceeded! %u > %u\n"), tp->t_flags |= (XFS_TRANS_SB_DIRTY |XFS_TRANS_DIRTY ); } +/* +* Add the given log item to the transaction's list of log items. +*/ +void +xfs_trans_add_item ( +struct xfs_trans *tp, +struct xfs_log_item *lip) +{ +ASSERT (lip->li_mountp == tp->t_mountp); +ASSERT (lip->li_ailp == tp->t_mountp->m_ail); +ASSERT (list_empty (&lip->li_trans)); +ASSERT (!test_bit (XFS_LI_DIRTY , &lip->li_flags)); + +list_add_tail (&lip->li_trans, &tp->t_items); +} + +/* +* Unlink and free the given descriptor. +*/ +void +xfs_trans_del_item ( +struct xfs_log_item *lip) +{ +clear_bit (XFS_LI_DIRTY , &lip->li_flags); +list_del_init (&lip->li_trans); +} + +/* Detach and unlock all of the items in a transaction */ static void -trans_committed ( -xfs_trans_t *tp) +xfs_trans_free_items ( +struct xfs_trans *tp) {struct xfs_log_item *lip, *next;list_for_each_entry_safe (lip, next, &tp->t_items, li_trans) {xfs_trans_del_item (lip); -if (lip->li_type ==XFS_LI_BUF ) -buf_item_done ((xfs_buf_log_item_t *)lip); +buf_item_unlock ((xfs_buf_log_item_t *)lip);else if (lip->li_type ==XFS_LI_INODE ) -inode_item_done ((xfs_inode_log_item_t *)lip); +inode_item_unlock ((xfs_inode_log_item_t *)lip);else {fprintf (stderr,_ ("%s: unrecognised log item type\n" ), progname);
@@ -404,19 +326,19 @@ trans_committed( } } -/* Detach and unlock all of the items in a transaction */ static void -xfs_trans_free_items ( -struct xfs_trans *tp) +trans_committed ( +xfs_trans_t *tp) {struct xfs_log_item *lip, *next;list_for_each_entry_safe (lip, next, &tp->t_items, li_trans) {xfs_trans_del_item (lip); +if (lip->li_type ==XFS_LI_BUF ) -buf_item_unlock ((xfs_buf_log_item_t *)lip); +buf_item_done ((xfs_buf_log_item_t *)lip);else if (lip->li_type ==XFS_LI_INODE ) -inode_item_unlock ((xfs_inode_log_item_t *)lip); +inode_item_done ((xfs_inode_log_item_t *)lip);else {fprintf (stderr,_ ("%s: unrecognised log item type\n" ), progname);
@@ -492,3 +414,72 @@ xfs_trans_commit( {return __xfs_trans_commit (tp, false); } + +void +xfs_trans_cancel ( +struct xfs_trans *tp) +{ +#ifdef XACT_DEBUG +struct xfs_trans *otp = tp; +#endif +if (tp ==NULL ) + goto out; + +if (tp->t_flags &XFS_TRANS_PERM_LOG_RES ) +xfs_defer_cancel (tp); + +xfs_trans_free_items (tp); +xfs_trans_free (tp); + +out: +#ifdef XACT_DEBUG +fprintf (stderr,"## cancelled transaction %p\n" , otp); +#endif +return ; +} + +/* +* 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 +* 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. +*/ +int +xfs_trans_roll ( +struct xfs_trans **tpp) +{ +struct xfs_trans *trans = *tpp; +struct xfs_trans_res tres; +int error; + +/* +* 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); + +/* +* Commit the current transaction. +* If this commit failed, then it'd just unlock those items that +* are marked to be released. That also means that a filesystem shutdown +* is in progress. The caller takes the responsibility to cancel +* the duplicate transaction that gets returned. +*/ + error =__xfs_trans_commit (trans, true); +if (error) +return error; + +/* +* Reserve space in the log for the 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 +* that we want to use. This requires that either nothing be locked +* across this call, or that anything that is locked be logged in +* the prior and the next transactions. +*/ + tres.tr_logflags =XFS_TRANS_PERM_LOG_RES ; +return xfs_trans_reserve (*tpp, &tres,0 ,0 ); +}
Signature · 1 line
1.8.3.1
PATCH 11/11 libxfs: minor sync-ups to kernel-ish functions
In reply to Eric SandeenChange typedefs to structs, add comments, and other very minor changes to userspace libxfs/ functions so that they more closely match kernelspace. Should be no functional changes.
--- libxfs/buf_item.c | 13 +--- libxfs/inode_item.c | 9 +-- libxfs/libxfs_priv.h | 4 - libxfs/trans.c | 80 ++++++++++++-------- libxfs/trans_buf.c | 205 ++++++++++++++++++++++++++++++++++++++------------- 5 files changed, 211 insertions(+), 100 deletions(-)
libxfs/buf_item.c +4 -9
@@ -16,10 +16,6 @@kmem_zone_t *xfs_buf_item_zone; -/* -* The following are from fs/xfs/xfs_buf_item.c -*/ -void xfs_buf_item_put (struct xfs_buf_log_item *bip)
@@ -56,8 +52,8 @@ buf_item_unlock(*/ void xfs_buf_item_init ( -xfs_buf_t *bp, -xfs_mount_t *mp) +struct xfs_buf *bp, +struct xfs_mount *mp) {xfs_log_item_t *lip;xfs_buf_log_item_t *bip;
@@ -85,8 +81,7 @@ xfs_buf_item_init( } } - bip = (xfs_buf_log_item_t *)kmem_zone_zalloc (xfs_buf_item_zone, -KM_SLEEP ); + bip =kmem_zone_zalloc (xfs_buf_item_zone,KM_SLEEP );#ifdef LI_DEBUG fprintf (stderr,"adding buf item %p for not-logged buffer %p\n" , bip, bp);
@@ -107,7 +102,7 @@ xfs_buf_item_init(*/ void xfs_buf_item_log ( -xfs_buf_log_item_t *bip, +struct xfs_buf_log_item *bip,uint first,uint last) {
libxfs/inode_item.c +4 -5
@@ -23,14 +23,13 @@ kmem_zone_t *xfs_ili_zone; /* inode log item zone */*/ void xfs_inode_item_init ( -xfs_inode_t *ip, -xfs_mount_t *mp) +struct xfs_inode *ip, +struct xfs_mount *mp) { -xfs_inode_log_item_t *iip; +struct xfs_inode_log_item *iip;ASSERT (ip->i_itemp ==NULL ); - iip = ip->i_itemp = (xfs_inode_log_item_t *) -kmem_zone_zalloc (xfs_ili_zone,KM_SLEEP ); + iip = ip->i_itemp =kmem_zone_zalloc (xfs_ili_zone,KM_SLEEP );#ifdef LI_DEBUG fprintf (stderr,"inode_item_init for inode %llu, iip=%p\n" , ip->i_ino, iip);
libxfs/libxfs_priv.h +0 -4
@@ -526,10 +526,6 @@ void xfs_buf_item_put(struct xfs_buf_log_item *bip);void buf_item_unlock (struct xfs_buf_log_item *bip);void buf_item_done (struct xfs_buf_log_item *bip); -/* xfs_trans_buf.c */ -struct xfs_buf *xfs_trans_buf_item_match (struct xfs_trans *, -struct xfs_buftarg *,struct xfs_buf_map *,int ); -/* local source files */ #define xfs_mod_fdblocks (mp, delta, rsvd) \ libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FDBLOCKS, delta, rsvd)
libxfs/trans.c +49 -31
200 lines not on this page · raw message
libxfs/trans_buf.c +154 -51
370 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 11/11] libxfs: minor sync-ups to kernel-ish functions
Quoted 6 lines · Eric Sandeen
Change typedefs to structs, add comments, and other very minor changes to userspace libxfs/ functions so that they more closely match kernelspace. Should be no functional changes.
Signed-off-by Eric Sandeen <[email protected]>
Ah, there's the typedef removal....
....
Quoted 19 lines
/*
* Free the transaction structure. If there is more clean up
* to do when the structure is freed, add it here. */libxfs/trans.c +2
-2-static void +STATIC voidxfs_trans_free (struct xfs_trans *tp) {@@ -106,7 +102,7 @@ xfs_trans_reserve( uint blocks, uint rtextents) { -int error =0 ; +int error =0 ;/* * Attempt to reserve the needed disk blocks by decrementing
libxfs/trans.c xfs_trans_reserve( · line 117
Quoted 9 lines
libxfs/trans.c +2
-1@@ -114,8 +110,9 @@ xfs_trans_reserve(* fail if the count would go below zero. */ if (blocks >0 ) { -if (tp->t_mountp->m_sb.sb_fdblocks < blocks) +if (tp->t_mountp->m_sb.sb_fdblocks < blocks) {return -ENOSPC ; + } tp->t_blk_res += blocks; }
These seem a bit weird by themselves. I know, the kernel code has more code in the branches and this reduces the diff a bit, but it does look a inconsistent now...
Quoted 6 lines
libxfs/trans.c +1
-0@@ -235,18 +233,24 @@ xfs_trans_alloc_empty(* Record the indicated change to the given field for application * to the file system's superblock when the transaction commits. * For now, just store the change in the transaction structure. +* * Mark the transaction structure to indicate that the superblock
libxfs/trans.c xfs_trans_alloc_empty( · line 242
Quoted 10 lines
libxfs/trans.c +1
-5* needs to be updated before committing. -* -* Originally derived from xfs_trans_mod_sb(). */ void xfs_trans_mod_sb( -xfs_trans_t *tp, -uint field, -long delta) + xfs_trans_t *tp,
typedef removal :)
Kernel side, too, I guess...
Quoted 18 lines
libxfs/trans_buf.c +12
-3-xfs_buf_t * +/* +* Get and lock the buffer for the caller if it is not already +* locked within the given transaction. If it is already locked +* within the transaction, just increment its lock recursion count +* and return a pointer to it. +* +* If the transaction pointer is NULL, make this just a normal +* get_buf() call. +*/ +struct xfs_buf * xfs_trans_get_buf_map( - xfs_trans_t *tp, - struct xfs_buftarg *btp, + struct xfs_trans *tp, + struct xfs_buftarg *target, struct xfs_buf_map *map,
libxfs/trans_buf.c xfs_trans_bjoin( · line 86
Quoted 5 lines
libxfs/trans_buf.c +1
-1int nmaps, - uint f) + uint flags) {xfs_buf_t *bp;
You missed a typedef.
Quoted 10 lines
+/*
+ * Get and lock the superblock buffer of this file system for the
+ * given transaction.
+ *
+ * We don't need to useincore_match()here, because the superblock
+ * buffer is a private buffer which we keep a pointer to in the
+ * mount structure.
+ */
xfs_buf_t*
typedef
Quoted 2 lines
xfs_trans_getsb(
xfs_trans_t*tp,
Another
libxfs/trans_buf.c xfs_trans_get_buf_map( · line 135
Quoted 5 lines
libxfs/trans_buf.c +1
-1- xfs_mount_t *mp, + struct xfs_mount *mp, int flags) {xfs_buf_t *bp;
And another.
yup, kernel code needs fixing, too.
.....
Quoted 37 lines
+ * transaction began, then also free the
buf_log_itemassociated with it.
+ *
+ * If the transaction pointer is NULL, this is a normalxfs_buf_relse()call.
+ */
void
xfs_trans_brelse(libxfs/trans_buf.c +9
-7- xfs_trans_t *tp, - xfs_buf_t *bp) +struct xfs_trans *tp, + struct xfs_buf *bp) { -xfs_buf_log_item_t *bip; + struct xfs_buf_log_item *bip = bp->b_log_item;#ifdef XACT_DEBUG fprintf (stderr,"released buffer %p, transaction %p\n" , bp, tp);#endif -if (tp ==NULL ) { +if (!tp) {ASSERT (bp->b_transp ==NULL );libxfs_putbuf (bp);return ; }ASSERT (bp->b_transp == tp); - bip = bp->b_log_item;ASSERT (bip->bli_item.li_type ==XFS_LI_BUF ); + +/* +* If the release is for a recursive lookup, then decrement the count +* and return. +*/ if (bip->bli_recur >0 ) { bip->bli_recur--;return ; } -/* If dirty/stale, can't release till transaction committed */ -if (bip->bli_flags &XFS_BLI_STALE )
libxfs/trans_buf.c out_relse: · line 278
Quoted 10 lines
libxfs/trans_buf.c +7
-1-return ; + +/* +* If the buffer is invalidated or dirty in this transaction, we can't +* release it until we commit. +*/ if (test_bit (XFS_LI_DIRTY , &bip->bli_item.li_flags))return ; +if (bip->bli_flags &XFS_BLI_STALE ) +return ;
THis is a change of behaviour for userspace, right? What does checking for a dirty log item do?
Quoted 23 lines
+/*
+ * Invalidate a buffer that is being used within a transaction.
+ *
+ * Typically this is because the blocks in the buffer are being freed, so we
+ * need to prevent it from being written out when we're done. Allowing it
+ * to be written again might overwrite data in the free blocks if they are
+ * reallocated to a file.
+ *
+ * We prevent the buffer from being written out by marking it stale. We can't
+ * get rid of the buf log item at this point because the buffer may still be
+ * pinned by another transaction. If that is the case, then we'll wait until
+ * the buffer is committed to disk for the last time (we can tell by the ref
+ * count) and free it inxfs_buf_item_unpin(). Until that happens we will
+ * keep the buffer locked so that the buffer and buf log item are not reused.
+ *
+ * We also set theXFS_BLF_CANCELflag in the buf log format structure and log
+ * the buf item. This will be used at recovery time to determine that copies
+ * of the buffer in the log before this should not be replayed.
+ *
+ * We mark the item descriptor and the transaction dirty so that we'll hold
+ * the buffer until after the commit.
+ *
+ * Since we're invalidating the buffer, we also clear the state about which
Quoted 8 lines
+ * parts of the buffer have been logged. We also clear the flag indicating
+ * that this is an inode buffer since the data in the buffer will no longer
+ * be valid.
+ *
+ * We set the stale bit in the buffer as well since we're getting rid of it.
+ */
void
xfs_trans_binval(
Does userspace even have half of this functionality? Does marking the buffer stale in userspace give the same guarantees as the kernel? There's no point bringing across comments that don't reflect how userspace works at this point in time...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 11/11] libxfs: minor sync-ups to kernel-ish functions
Quoted 27 lines · Dave Chinner
Quoted 6 lines · Eric Sandeen
Change typedefs to structs, add comments, and other very minor changes to userspace libxfs/ functions so that they more closely match kernelspace. Should be no functional changes.
Signed-off-by Eric Sandeen <[email protected]>Ah, there's the typedef removal....
....
Quoted 16 lines
/*
* Free the transaction structure. If there is more clean up
* to do when the structure is freed, add it here. */libxfs/trans.c +2
-2-static void +STATIC voidxfs_trans_free (struct xfs_trans *tp) {@@ -106,7 +102,7 @@ xfs_trans_reserve( uint blocks, uint rtextents) { -int error =0 ; +int error =0 ;
Quoted 16 lines
libxfs/trans.c xfs_trans_reserve( · line 117
Quoted 12 lines
libxfs/trans.c +2
-1/* * Attempt to reserve the needed disk blocks by decrementing @@ -114,8 +110,9 @@ xfs_trans_reserve(* fail if the count would go below zero. */ if (blocks >0 ) { -if (tp->t_mountp->m_sb.sb_fdblocks < blocks) +if (tp->t_mountp->m_sb.sb_fdblocks < blocks) {return -ENOSPC ; + } tp->t_blk_res += blocks; }These seem a bit weird by themselves. I know, the kernel code has more code in the branches and this reduces the diff a bit, but it does look a inconsistent now...
The goal would be to add the other bits back in later. But doing it in small steps like this just causes confusion, I guess?
Quoted 19 lines
Quoted 6 lines
libxfs/trans.c +1
-0@@ -235,18 +233,24 @@ xfs_trans_alloc_empty(* Record the indicated change to the given field for application * to the file system's superblock when the transaction commits. * For now, just store the change in the transaction structure. +* * Mark the transaction structure to indicate that the superblock libxfs/trans.c xfs_trans_alloc_empty( · line 242
Quoted 10 lines
libxfs/trans.c +1
-5* needs to be updated before committing. -* -* Originally derived from xfs_trans_mod_sb(). */ void xfs_trans_mod_sb( -xfs_trans_t *tp, -uint field, -long delta) + xfs_trans_t *tp,typedef removal :)
Quoted 1 line
Kernel side, too, I guess...
Right, the goal here is to sync up with the kernel, not diverge more.
Quoted 17 lines
Quoted 17 lines
libxfs/trans_buf.c +12
-3-xfs_buf_t * +/* +* Get and lock the buffer for the caller if it is not already +* locked within the given transaction. If it is already locked +* within the transaction, just increment its lock recursion count +* and return a pointer to it. +* +* If the transaction pointer is NULL, make this just a normal +* get_buf() call. +*/ +struct xfs_buf * xfs_trans_get_buf_map( - xfs_trans_t *tp, - struct xfs_buftarg *btp, + struct xfs_trans *tp, + struct xfs_buftarg *target,
Quoted 8 lines
libxfs/trans_buf.c xfs_trans_bjoin( · line 86
Quoted 6 lines
(quoted diff) +0
-0struct xfs_buf_map *map,libxfs/trans_buf.c +1
-1int nmaps, - uint f) + uint flags) {xfs_buf_t *bp;You missed a typedef.
kernel missed a typedef ;)
[sandeen@sandeen linux-xfs]$ grep -A7 ^xfs_trans_get_buf_map fs/xfs/*.c fs/xfs/*/*.c fs/xfs/xfs_trans_buf.c:xfs_trans_get_buf_map(fs/xfs/xfs_trans_buf.c- struct xfs_trans *tp,fs/xfs/xfs_trans_buf.c- struct xfs_buftarg *target,fs/xfs/xfs_trans_buf.c- struct xfs_buf_map *map,fs/xfs/xfs_trans_buf.c- int nmaps,fs/xfs/xfs_trans_buf.c- xfs_buf_flags_t flags)fs/xfs/xfs_trans_buf.c-{fs/xfs/xfs_trans_buf.c- xfs_buf_t *bp;
Quoted 26 lines
Quoted 10 lines
+/*
+ * Get and lock the superblock buffer of this file system for the
+ * given transaction.
+ *
+ * We don't need to useincore_match()here, because the superblock
+ * buffer is a private buffer which we keep a pointer to in the
+ * mount structure.
+ */
xfs_buf_t*typedef
Quoted 2 lines
xfs_trans_getsb(
xfs_trans_t*tp,Another
libxfs/trans_buf.c xfs_trans_get_buf_map( · line 135
Quoted 5 lines
libxfs/trans_buf.c +1
-1- xfs_mount_t *mp, + struct xfs_mount *mp, int flags) {xfs_buf_t *bp;And another.
Quoted 1 line
yup, kernel code needs fixing, too.
"you go first!" ;)
Quoted 43 lines
.....
Quoted 42 lines
+ * transaction began, then also free the
buf_log_itemassociated with it.
+ *
+ * If the transaction pointer is NULL, this is a normalxfs_buf_relse()call.
+ */
void
xfs_trans_brelse(libxfs/trans_buf.c +13
-8- xfs_trans_t *tp, - xfs_buf_t *bp) +struct xfs_trans *tp, + struct xfs_buf *bp) { -xfs_buf_log_item_t *bip; + struct xfs_buf_log_item *bip = bp->b_log_item;#ifdef XACT_DEBUG fprintf (stderr,"released buffer %p, transaction %p\n" , bp, tp);#endif -if (tp ==NULL ) { +if (!tp) {ASSERT (bp->b_transp ==NULL );libxfs_putbuf (bp);return ; }ASSERT (bp->b_transp == tp); - bip = bp->b_log_item;ASSERT (bip->bli_item.li_type ==XFS_LI_BUF ); + +/* +* If the release is for a recursive lookup, then decrement the count +* and return. +*/ if (bip->bli_recur >0 ) { bip->bli_recur--;return ; } -/* If dirty/stale, can't release till transaction committed */ -if (bip->bli_flags &XFS_BLI_STALE ) -return ; + +/* +* If the buffer is invalidated or dirty in this transaction, we can't +* release it until we commit.
Quoted 8 lines
libxfs/trans_buf.c out_relse: · line 278
Quoted 5 lines
libxfs/trans_buf.c +3
-0+*/ if (test_bit (XFS_LI_DIRTY , &bip->bli_item.li_flags))return ; +if (bip->bli_flags &XFS_BLI_STALE ) +return ;THis is a change of behaviour for userspace, right? What does checking for a dirty log item do?
No, it just re-orders an existing test, look up a few lines.
Quoted 32 lines
Quoted 23 lines
+/*
+ * Invalidate a buffer that is being used within a transaction.
+ *
+ * Typically this is because the blocks in the buffer are being freed, so we
+ * need to prevent it from being written out when we're done. Allowing it
+ * to be written again might overwrite data in the free blocks if they are
+ * reallocated to a file.
+ *
+ * We prevent the buffer from being written out by marking it stale. We can't
+ * get rid of the buf log item at this point because the buffer may still be
+ * pinned by another transaction. If that is the case, then we'll wait until
+ * the buffer is committed to disk for the last time (we can tell by the ref
+ * count) and free it inxfs_buf_item_unpin(). Until that happens we will
+ * keep the buffer locked so that the buffer and buf log item are not reused.
+ *
+ * We also set theXFS_BLF_CANCELflag in the buf log format structure and log
+ * the buf item. This will be used at recovery time to determine that copies
+ * of the buffer in the log before this should not be replayed.
+ *
+ * We mark the item descriptor and the transaction dirty so that we'll hold
+ * the buffer until after the commit.
+ *
+ * Since we're invalidating the buffer, we also clear the state about whichQuoted 8 lines
+ * parts of the buffer have been logged. We also clear the flag indicating
+ * that this is an inode buffer since the data in the buffer will no longer
+ * be valid.
+ *
+ * We set the stale bit in the buffer as well since we're getting rid of it.
+ */
void
xfs_trans_binval(
Quoted 4 lines
Does userspace even have half of this functionality? Does marking the buffer stale in userspace give the same guarantees as the kernel? There's no point bringing across comments that don't reflect how userspace works at this point in time...
We have a lot of comments in userspace libxfs/* that reference locking that is defined away, etc. IOWs we have this today, and I thought it was understood that shared kernelspace comments didn't always reflect userspace reality...
*shrug*
Thanks for looking it over,
-Eric
Quoted 4 lines
Cheers,
Dave.