xfsprogs: Delayed Ready Attributes
v6 cover xfsprogs: Delayed Ready Attributes
This set applies the corresponding changes for delayed ready attributes to xfsprogs. I will pick up the reviews from the kernel side series and mirror them here.
Thanks all!
Allison
Allison Collins (17):
xfsprogs: Remove all strlen in all xfs_attr_* functions for attr
names.
xfsprogs: Replace attribute parameters with struct xfs_name
xfsprogs: Embed struct xfs_name in xfs_da_args
xfsprogs: Add xfs_has_attr and subroutines
xfsprogs: Factor out new helper functions xfs_attr_rmtval_set
xfsprogs: Factor out trans handling in xfs_attr3_leaf_flipflags
xfsprogs: Factor out xfs_attr_leaf_addname helper
xfsprogs: Refactor xfs_attr_try_sf_addname
xfsprogs: Factor out trans roll from xfs_attr3_leaf_setflag
xfsprogs: Factor out xfs_attr_rmtval_invalidate
xfsprogs: Factor out trans roll in xfs_attr3_leaf_clearflag
xfsprogs: Check for -ENOATTR or -EEXIST
xfsprogs: Add helper function xfs_attr_init_unmapstate
xfsprogs: Add helper function xfs_attr_rmtval_unmap
xfsprogs: Simplify xfs_attr_set_args
xfsprogs: Add delay ready attr remove routines
xfsprogs: Add delay ready attr set routines
db/attrset.c | 11 +- libxfs/libxfs_priv.h | 11 +- libxfs/xfs_attr.c | 859 ++++++++++++++++++++++++++++++++--------------- libxfs/xfs_attr.h | 9 +- libxfs/xfs_attr_leaf.c | 222 ++++++------ libxfs/xfs_attr_leaf.h | 3 + libxfs/xfs_attr_remote.c | 265 +++++++++++---- libxfs/xfs_attr_remote.h | 7 +- libxfs/xfs_da_btree.c | 6 +- libxfs/xfs_da_btree.h | 41 ++- libxfs/xfs_dir2.c | 18 +- libxfs/xfs_dir2_block.c | 6 +- libxfs/xfs_dir2_leaf.c | 6 +- libxfs/xfs_dir2_node.c | 8 +- libxfs/xfs_dir2_sf.c | 30 +- libxfs/xfs_types.c | 11 + libxfs/xfs_types.h | 1 + 17 files changed, 1033 insertions(+), 481 deletions(-)
Signature · 1 line
2.7.4
PATCH v6 1/17 xfsprogs: Remove all strlen in all xfs_attr_* functions for attr names.
This helps to pre-simplify the extra handling of the null terminator in delayed operations which use memcpy rather than strlen. Later when we introduce parent pointers, attribute names will become binary, so strlen will not work at all. Removing uses of strlen now will help reduce complexities later
--- db/attrset.c | 4 ++-- libxfs/libxfs_priv.h | 9 +++++---- libxfs/xfs_attr.c | 12 ++++++++---- libxfs/xfs_attr.h | 8 +++++--- 4 files changed, 20 insertions(+), 13 deletions(-)
db/attrset.c +2 -2
@@ -146,7 +146,7 @@ attr_set_f( goto out; } -if (libxfs_attr_set (ip, (unsigned char *)name, +if (libxfs_attr_set (ip, (unsigned char *)name,strlen (name), (unsigned char *)value, valuelen, flags)) {dbprintf (_ ("failed to set attr %s on inode %llu\n" ), name, (unsigned long long )iocur_top->ino);
@@ -222,7 +222,7 @@ attr_remove_f( goto out; } -if (libxfs_attr_remove (ip, (unsigned char *)name, flags)) { +if (libxfs_attr_remove (ip, (unsigned char *)name,strlen (name), flags)) {dbprintf (_ ("failed to remove attr %s from inode %llu\n" ), name, (unsigned long long )iocur_top->ino); goto out;
libxfs/libxfs_priv.h +5 -4
@@ -610,11 +610,12 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr)int xfs_inode_hasattr (struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_inode *ip,struct xfs_da_args *args);int xfs_attr_get (struct xfs_inode *ip,const unsigned char *name, -unsigned char **value,int *valuelenp,int flags); +size_t namelen,unsigned char **value,int *valuelenp, +int flags);int xfs_attr_set (struct xfs_inode *dp,const unsigned char *name, -unsigned char *value,int valuelen,int flags); -int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name,int flags); - +size_t namelen,unsigned char *value,int valuelen,int flags); +int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name, +size_t namelen,int flags);int xfs_rtbuf_get (struct xfs_mount *mp,struct xfs_trans *tp,xfs_rtblock_t block,int issum,struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp,
libxfs/xfs_attr.c +8 -4
@@ -61,6 +61,7 @@ xfs_attr_args_init(struct xfs_da_args *args, struct xfs_inode *dp, const unsigned char *name, + size_t namelen, int flags) {
@@ -73,7 +74,7 @@ xfs_attr_args_init( args->dp = dp; args->flags = flags; args->name = name; - args->namelen =strlen ((const char *)name); + args->namelen = namelen;if (args->namelen >=MAXNAMELEN )return -EFAULT ;/* match IRIX behaviour */
@@ -138,6 +139,7 @@ intxfs_attr_get ( struct xfs_inode *ip, const unsigned char *name, + size_t namelen, unsigned char **value, int *valuelenp, int flags)
@@ -153,7 +155,7 @@ xfs_attr_get(if (XFS_FORCED_SHUTDOWN (ip->i_mount))return -EIO ; - error =xfs_attr_args_init (&args, ip, name, flags); + error =xfs_attr_args_init (&args, ip, name, namelen, flags);if (error)return error;
@@ -337,6 +339,7 @@ intxfs_attr_set ( struct xfs_inode *dp, const unsigned char *name, + size_t namelen, unsigned char *value, int valuelen, int flags)
@@ -352,7 +355,7 @@ xfs_attr_set(if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ; - error =xfs_attr_args_init (&args, dp, name, flags); + error =xfs_attr_args_init (&args, dp, name, namelen, flags);if (error)return error;
@@ -441,6 +444,7 @@ intxfs_attr_remove ( struct xfs_inode *dp, const unsigned char *name, + size_t namelen, int flags) { struct xfs_mount *mp = dp->i_mount;
@@ -452,7 +456,7 @@ xfs_attr_remove(if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ; - error =xfs_attr_args_init (&args, dp, name, flags); + error =xfs_attr_args_init (&args, dp, name, namelen, flags);if (error)return error;
libxfs/xfs_attr.h +5 -3
@@ -145,11 +145,13 @@ int xfs_attr_list_int(struct xfs_attr_list_context *);int xfs_inode_hasattr (struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_inode *ip,struct xfs_da_args *args);int xfs_attr_get (struct xfs_inode *ip,const unsigned char *name, -unsigned char **value,int *valuelenp,int flags); +size_t namelen,unsigned char **value,int *valuelenp, +int flags);int xfs_attr_set (struct xfs_inode *dp,const unsigned char *name, -unsigned char *value,int valuelen,int flags); +size_t namelen,unsigned char *value,int valuelen,int flags);int xfs_attr_set_args (struct xfs_da_args *args); -int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name,int flags); +int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name, +size_t namelen,int flags);int xfs_attr_remove_args (struct xfs_da_args *args);int xfs_attr_list (struct xfs_inode *dp,char *buffer,int bufsize,int flags,struct attrlist_cursor_kern *cursor);
Signature · 1 line
2.7.4
PATCH v6 2/17 xfsprogs: Replace attribute parameters with struct xfs_name
In reply to Allison CollinsThis patch replaces the attribute name and length parameters with a single struct xfs_name parameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.
--- db/attrset.c | 11 ++++++++--- libxfs/libxfs_priv.h | 12 +++++------- libxfs/xfs_attr.c | 22 +++++++++------------- libxfs/xfs_attr.h | 12 +++++------- libxfs/xfs_types.c | 11 +++++++++++ libxfs/xfs_types.h | 1 + 6 files changed, 39 insertions(+), 30 deletions(-)
db/attrset.c +8 -3
@@ -16,6 +16,7 @@#include "field.h" #include "inode.h" #include "malloc.h" +#include "xfs_types.h" static int attr_set_f (int argc,char **argv);static int attr_remove_f (int argc,char **argv);
@@ -68,6 +69,7 @@ attr_set_f( {xfs_inode_t *ip =NULL ;char *name, *value, *sp; +struct xfs_name xname;int c, valuelen =0 , flags =0 ;if (cur_typ ==NULL ) {
@@ -146,8 +148,9 @@ attr_set_f( goto out; } -if (libxfs_attr_set (ip, (unsigned char *)name,strlen (name), - (unsigned char *)value, valuelen, flags)) { +xfs_name_init (&xname, name); +if (libxfs_attr_set (ip, &xname, (unsigned char *)value, valuelen, + flags)) {dbprintf (_ ("failed to set attr %s on inode %llu\n" ), name, (unsigned long long )iocur_top->ino); goto out;
@@ -172,6 +175,7 @@ attr_remove_f( {xfs_inode_t *ip =NULL ;char *name; +struct xfs_name xname;int c, flags =0 ;if (cur_typ ==NULL ) {
@@ -222,7 +226,8 @@ attr_remove_f( goto out; } -if (libxfs_attr_remove (ip, (unsigned char *)name,strlen (name), flags)) { +xfs_name_init (&xname, name); +if (libxfs_attr_remove (ip, &xname, flags)) {dbprintf (_ ("failed to remove attr %s from inode %llu\n" ), name, (unsigned long long )iocur_top->ino); goto out;
libxfs/libxfs_priv.h +5 -7
@@ -609,13 +609,11 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr)/* Keep static checkers quiet about nonstatic functions by exporting */ int xfs_inode_hasattr (struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_inode *ip,struct xfs_da_args *args); -int xfs_attr_get (struct xfs_inode *ip,const unsigned char *name, -size_t namelen,unsigned char **value,int *valuelenp, -int flags); -int xfs_attr_set (struct xfs_inode *dp,const unsigned char *name, -size_t namelen,unsigned char *value,int valuelen,int flags); -int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name, -size_t namelen,int flags); +int xfs_attr_get (struct xfs_inode *ip,struct xfs_name *name, +unsigned char **value,int *valuelenp,int flags); +int xfs_attr_set (struct xfs_inode *dp,struct xfs_name *name, +unsigned char *value,int valuelen,int flags); +int xfs_attr_remove (struct xfs_inode *dp,struct xfs_name *name,int flags);int xfs_rtbuf_get (struct xfs_mount *mp,struct xfs_trans *tp,xfs_rtblock_t block,int issum,struct xfs_buf **bpp); int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp,
libxfs/xfs_attr.c +9 -13
@@ -60,8 +60,7 @@ STATIC intxfs_attr_args_init ( struct xfs_da_args *args, struct xfs_inode *dp, - const unsigned char *name, - size_t namelen, + struct xfs_name *name, int flags) {
@@ -73,8 +72,8 @@ xfs_attr_args_init( args->whichfork =XFS_ATTR_FORK ; args->dp = dp; args->flags = flags; - args->name = name; - args->namelen = namelen; + args->name = name->name; + args->namelen = name->len;if (args->namelen >=MAXNAMELEN )return -EFAULT ;/* match IRIX behaviour */
@@ -138,8 +137,7 @@ xfs_attr_get_ilocked(int xfs_attr_get (struct xfs_inode *ip, -const unsigned char *name, -size_t namelen, +struct xfs_name *name,unsigned char **value,int *valuelenp,int flags)
@@ -155,7 +153,7 @@ xfs_attr_get(if (XFS_FORCED_SHUTDOWN (ip->i_mount))return -EIO ; - error =xfs_attr_args_init (&args, ip, name, namelen, flags); + error =xfs_attr_args_init (&args, ip, name, flags);if (error)return error;
@@ -338,8 +336,7 @@ xfs_attr_remove_args(int xfs_attr_set (struct xfs_inode *dp, -const unsigned char *name, -size_t namelen, +struct xfs_name *name,unsigned char *value,int valuelen,int flags)
@@ -355,7 +352,7 @@ xfs_attr_set(if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ; - error =xfs_attr_args_init (&args, dp, name, namelen, flags); + error =xfs_attr_args_init (&args, dp, name, flags);if (error)return error;
@@ -443,8 +440,7 @@ out_trans_cancel:int xfs_attr_remove (struct xfs_inode *dp, -const unsigned char *name, -size_t namelen, +struct xfs_name *name,int flags) {struct xfs_mount *mp = dp->i_mount;
@@ -456,7 +452,7 @@ xfs_attr_remove(if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ; - error =xfs_attr_args_init (&args, dp, name, namelen, flags); + error =xfs_attr_args_init (&args, dp, name, flags);if (error)return error;
libxfs/xfs_attr.h +5 -7
@@ -144,14 +144,12 @@ int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *);int xfs_attr_list_int (struct xfs_attr_list_context *);int xfs_inode_hasattr (struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_inode *ip,struct xfs_da_args *args); -int xfs_attr_get (struct xfs_inode *ip,const unsigned char *name, -size_t namelen,unsigned char **value,int *valuelenp, -int flags); -int xfs_attr_set (struct xfs_inode *dp,const unsigned char *name, -size_t namelen,unsigned char *value,int valuelen,int flags); +int xfs_attr_get (struct xfs_inode *ip,struct xfs_name *name, +unsigned char **value,int *valuelenp,int flags); +int xfs_attr_set (struct xfs_inode *dp,struct xfs_name *name, +unsigned char *value,int valuelen,int flags);int xfs_attr_set_args (struct xfs_da_args *args); -int xfs_attr_remove (struct xfs_inode *dp,const unsigned char *name, -size_t namelen,int flags); +int xfs_attr_remove (struct xfs_inode *dp,struct xfs_name *name,int flags);int xfs_attr_remove_args (struct xfs_da_args *args);int xfs_attr_list (struct xfs_inode *dp,char *buffer,int bufsize,int flags,struct attrlist_cursor_kern *cursor);
libxfs/xfs_types.c +11 -0
@@ -12,6 +12,17 @@#include "xfs_bit.h" #include "xfs_mount.h" +/* Initialize a struct xfs_name with a null terminated string name */ +void +xfs_name_init ( +struct xfs_name *xname, +const char *name) +{ + xname->name = (unsigned char *)name; + xname->len =strlen (name); + xname->type =0 ; +} +/* Find the size of the AG, in blocks. */ xfs_agblock_t xfs_ag_block_count(
libxfs/xfs_types.h +1 -0
@@ -182,6 +182,7 @@ enum xfs_ag_resv_type {*/ struct xfs_mount ; +void xfs_name_init (struct xfs_name *xname,const char *name);xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno);bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno,xfs_agblock_t agbno);
Signature · 1 line
2.7.4
PATCH v6 3/17 xfsprogs: Embed struct xfs_name in xfs_da_args
In reply to Allison CollinsThis patch embeds an xfs_name in xfs_da_args, replacing the name, namelen, and flags members. This helps to clean up the xfs_da_args structure and make it more uniform with the new xfs_name parameter being passed around.
--- libxfs/xfs_attr.c | 39 +++++++++-------- libxfs/xfs_attr_leaf.c | 106 ++++++++++++++++++++++++----------------------- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_da_btree.c | 6 ++- libxfs/xfs_da_btree.h | 4 +- libxfs/xfs_dir2.c | 18 ++++---- libxfs/xfs_dir2_block.c | 6 +-- libxfs/xfs_dir2_leaf.c | 6 +-- libxfs/xfs_dir2_node.c | 8 ++-- libxfs/xfs_dir2_sf.c | 30 +++++++------- 10 files changed, 115 insertions(+), 110 deletions(-)
libxfs/xfs_attr.c +22 -17
@@ -71,13 +71,12 @@ xfs_attr_args_init( args->geo = dp->i_mount->m_attr_geo; args->whichfork =XFS_ATTR_FORK ; args->dp = dp; - args->flags = flags; - args->name = name->name; - args->namelen = name->len; -if (args->namelen >=MAXNAMELEN ) +memcpy (&args->name, name,sizeof (struct xfs_name )); + args->name.type = flags; +if (args->name.len >=MAXNAMELEN )return -EFAULT ;/* match IRIX behaviour */ - args->hashval =xfs_da_hashname (args->name, args->namelen); + args->hashval =xfs_da_hashname (args->name.name, args->name.len);return 0 ; }
@@ -235,7 +234,7 @@ xfs_attr_try_sf_addname(* Commit the shortform mods, and we're done. * NOTE: this is also the error path (EEXIST, etc). */ -if (!error && (args->flags &ATTR_KERNOTIME ) ==0 ) +if (!error && (args->name.type &ATTR_KERNOTIME ) ==0 )xfs_trans_ichgtime (args->trans, dp,XFS_ICHGTIME_CHG );if (mp->m_flags &XFS_MOUNT_WSYNC )
@@ -356,6 +355,9 @@ xfs_attr_set(if (error)return error; +/* Use name now stored in args */ + name = &args.name; + args.value = value; args.valuelen = valuelen; args.op_flags =XFS_DA_OP_ADDNAME |XFS_DA_OP_OKNOENT ;
@@ -371,7 +373,7 @@ xfs_attr_set(*/ if (XFS_IFORK_Q (dp) ==0 ) {int sf_size =sizeof (xfs_attr_sf_hdr_t) + -XFS_ATTR_SF_ENTSIZE_BYNAME (args.namelen, valuelen); +XFS_ATTR_SF_ENTSIZE_BYNAME (name->len, valuelen); error =xfs_bmap_add_attrfork (dp, sf_size, rsvd);if (error)
@@ -456,6 +458,9 @@ xfs_attr_remove(if (error)return error; +/* Use name now stored in args */ + name = &args.name; +/* * we have no control over the attribute names that userspace passes us * to remove, so we have to allow the name lookup prior to attribute
@@ -531,10 +536,10 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)trace_xfs_attr_sf_addname (args); retval =xfs_attr_shortform_lookup (args); -if ((args->flags &ATTR_REPLACE ) && (retval == -ENOATTR )) { +if ((args->name.type &ATTR_REPLACE ) && (retval == -ENOATTR )) {return retval; }else if (retval == -EEXIST ) { -if (args->flags &ATTR_CREATE ) +if (args->name.type &ATTR_CREATE )return retval; retval =xfs_attr_shortform_remove (args);if (retval)
@@ -544,15 +549,15 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)* that the leaf format add routine won't trip over the attr * not being around. */ - args->flags &= ~ATTR_REPLACE ; + args->name.type &= ~ATTR_REPLACE ; } -if (args->namelen >=XFS_ATTR_SF_ENTSIZE_MAX || +if (args->name.len >=XFS_ATTR_SF_ENTSIZE_MAX || args->valuelen >=XFS_ATTR_SF_ENTSIZE_MAX )return -ENOSPC ; newsize =XFS_ATTR_SF_TOTSIZE (args->dp); - newsize +=XFS_ATTR_SF_ENTSIZE_BYNAME (args->namelen, args->valuelen); + newsize +=XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen); forkoff =xfs_attr_shortform_bytesfit (args->dp, newsize);if (!forkoff)
@@ -597,11 +602,11 @@ xfs_attr_leaf_addname(* the given flags produce an error or call for an atomic rename. */ retval =xfs_attr3_leaf_lookup_int (bp, args); -if ((args->flags &ATTR_REPLACE ) && (retval == -ENOATTR )) { +if ((args->name.type &ATTR_REPLACE ) && (retval == -ENOATTR )) {xfs_trans_brelse (args->trans, bp);return retval; }else if (retval == -EEXIST ) { -if (args->flags &ATTR_CREATE ) {/* pure create op */ +if (args->name.type &ATTR_CREATE ) {/* pure create op */ xfs_trans_brelse (args->trans, bp);return retval; }
@@ -871,10 +876,10 @@ restart: goto out; blk = &state->path.blk[ state->path.active-1 ];ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); -if ((args->flags &ATTR_REPLACE ) && (retval == -ENOATTR )) { +if ((args->name.type &ATTR_REPLACE ) && (retval == -ENOATTR )) { goto out; }else if (retval == -EEXIST ) { -if (args->flags &ATTR_CREATE ) +if (args->name.type &ATTR_CREATE ) goto out;trace_xfs_attr_node_replace (args);
@@ -1006,7 +1011,7 @@ restart:* The INCOMPLETE flag means that we will find the "old" * attr, not the "new" one. */ - args->flags |=XFS_ATTR_INCOMPLETE ; + args->name.type |=XFS_ATTR_INCOMPLETE ; state =xfs_da_state_alloc (); state->args = args; state->mp = mp;
libxfs/xfs_attr_leaf.c +55 -51
238 lines not on this page · raw message
libxfs/xfs_attr_remote.c +1 -1
@@ -377,7 +377,7 @@ xfs_attr_rmtval_get(trace_xfs_attr_rmtval_get (args); -ASSERT (!(args->flags &ATTR_KERNOVAL )); +ASSERT (!(args->name.type &ATTR_KERNOVAL ));ASSERT (args->rmtvaluelen == args->valuelen); valuelen = args->rmtvaluelen;
libxfs/xfs_da_btree.c +4 -2
@@ -2037,8 +2037,10 @@ xfs_da_compname( const unsigned char *name, int len) { - return (args->namelen == len && memcmp(args->name, name, len) == 0) ? - XFS_CMP_EXACT : XFS_CMP_DIFFERENT; + if (args->name.len == len && !memcmp(args->name.name, name, len)) + return XFS_CMP_EXACT; + +return XFS_CMP_DIFFERENT ; } static xfs_dahash_t
libxfs/xfs_da_btree.h +1 -3
@@ -47,12 +47,10 @@ enum xfs_dacmp {*/ typedef struct xfs_da_args { struct xfs_da_geometry *geo; /* da block geometry */ - const uint8_t *name; /* string (maybe not NULL terminated) */ - int namelen; /* length of string (maybe no NULL) */ + struct xfs_name name; /* name, length and argument flags*/ uint8_t filetype; /* filetype of inode for directories */ uint8_t *value; /* set of bytes (maybe contain NULLs) */ int valuelen; /* length of value */ - int flags; /* argument flags (eg: ATTR_NOCREATE) */ xfs_dahash_t hashval; /* hash value of name */ xfs_ino_t inumber; /* input/output inode number */ struct xfs_inode *dp; /* directory inode to manipulate */
libxfs/xfs_dir2.c +7 -11
@@ -72,14 +72,14 @@ xfs_ascii_ci_compname(enum xfs_dacmp result;int i; -if (args->namelen != len) +if (args->name.len != len)return XFS_CMP_DIFFERENT ; result =XFS_CMP_EXACT ;for (i =0 ; i < len; i++) { -if (args->name[i] == name[i]) +if (args->name.name[i] == name[i])continue ; -if (tolower (args->name[i]) !=tolower (name[i])) +if (tolower (args->name.name[i]) !=tolower (name[i]))return XFS_CMP_DIFFERENT ; result =XFS_CMP_CASE ; }
@@ -257,8 +257,7 @@ xfs_dir_createname(return -ENOMEM ; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; +memcpy (&args->name, name,sizeof (struct xfs_name )); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname (name); args->inumber = inum;
@@ -353,8 +352,7 @@ xfs_dir_lookup(*/ args =kmem_zalloc (sizeof (*args),KM_NOFS ); args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; +memcpy (&args->name, name,sizeof (struct xfs_name )); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname (name); args->dp = dp;
@@ -425,8 +423,7 @@ xfs_dir_removename(return -ENOMEM ; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; +memcpy (&args->name, name,sizeof (struct xfs_name )); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname (name); args->inumber = ino;
@@ -486,8 +483,7 @@ xfs_dir_replace(return -ENOMEM ; args->geo = dp->i_mount->m_dir_geo; - args->name = name->name; - args->namelen = name->len; +memcpy (&args->name, name,sizeof (struct xfs_name )); args->filetype = name->type; args->hashval = dp->i_mount->m_dirnameops->hashname (name); args->inumber = inum;
libxfs/xfs_dir2_block.c +3 -3
@@ -352,7 +352,7 @@ xfs_dir2_block_addname(if (error)return error; - len = dp->d_ops->data_entsize (args->namelen); + len = dp->d_ops->data_entsize (args->name.len);/* * Set up pointers to parts of the block.
@@ -536,8 +536,8 @@ xfs_dir2_block_addname(* Create the new data entry. */ dep->inumber =cpu_to_be64 (args->inumber); - dep->namelen = args->namelen; -memcpy (dep->name, args->name, args->namelen); + dep->namelen = args->name.len; +memcpy (dep->name, args->name.name, args->name.len); dp->d_ops->data_put_ftype (dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p (dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
libxfs/xfs_dir2_leaf.c +3 -3
@@ -608,7 +608,7 @@ xfs_dir2_leaf_addname( ents = dp->d_ops->leaf_ents_p (leaf); dp->d_ops->leaf_hdr_from_disk (&leafhdr, leaf); bestsp =xfs_dir2_leaf_bests_p (ltp); - length = dp->d_ops->data_entsize (args->namelen); + length = dp->d_ops->data_entsize (args->name.len);/* * See if there are any entries with the same hash value
@@ -811,8 +811,8 @@ xfs_dir2_leaf_addname(*/ dep = (xfs_dir2_data_entry_t *)dup; dep->inumber =cpu_to_be64 (args->inumber); - dep->namelen = args->namelen; -memcpy (dep->name, args->name, dep->namelen); + dep->namelen = args->name.len; +memcpy (dep->name, args->name.name, dep->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p (dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
libxfs/xfs_dir2_node.c +4 -4
@@ -601,7 +601,7 @@ xfs_dir2_leafn_lookup_for_addname(ASSERT (free->hdr.magic ==cpu_to_be32 (XFS_DIR2_FREE_MAGIC ) || free->hdr.magic ==cpu_to_be32 (XFS_DIR3_FREE_MAGIC )); } - length = dp->d_ops->data_entsize (args->namelen); + length = dp->d_ops->data_entsize (args->name.len);/* * Loop over leaf entries with the right hash value. */
@@ -1866,7 +1866,7 @@ xfs_dir2_node_addname_int(__be16 *tagp;/* data entry tag pointer */ __be16 *bests; - length = dp->d_ops->data_entsize (args->namelen); + length = dp->d_ops->data_entsize (args->name.len); error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &findex, length);if (error)
@@ -1921,8 +1921,8 @@ xfs_dir2_node_addname_int(/* Fill in the new entry and log it. */ dep = (xfs_dir2_data_entry_t *)dup; dep->inumber =cpu_to_be64 (args->inumber); - dep->namelen = args->namelen; -memcpy (dep->name, args->name, dep->namelen); + dep->namelen = args->name.len; +memcpy (dep->name, args->name.name, dep->namelen); dp->d_ops->data_put_ftype (dep, args->filetype); tagp = dp->d_ops->data_entry_tag_p (dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
libxfs/xfs_dir2_sf.c +15 -15
@@ -291,7 +291,7 @@ xfs_dir2_sf_addname(/* * Compute entry (and change in) size. */ - incr_isize = dp->d_ops->sf_entsize (sfp, args->namelen); + incr_isize = dp->d_ops->sf_entsize (sfp, args->name.len); objchange =0 ;/*
@@ -375,7 +375,7 @@ xfs_dir2_sf_addname_easy(/* * Grow the in-inode space. */ -xfs_idata_realloc (dp, dp->d_ops->sf_entsize (sfp, args->namelen), +xfs_idata_realloc (dp, dp->d_ops->sf_entsize (sfp, args->name.len),XFS_DATA_FORK );/* * Need to set up again due to realloc of the inode data.
@@ -385,9 +385,9 @@ xfs_dir2_sf_addname_easy(/* * Fill in the new entry. */ - sfep->namelen = args->namelen; + sfep->namelen = args->name.len;xfs_dir2_sf_put_offset (sfep, offset); -memcpy (sfep->name, args->name, sfep->namelen); +memcpy (sfep->name, args->name.name, sfep->namelen); dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype);
@@ -446,7 +446,7 @@ xfs_dir2_sf_addname_hard(*/ for (offset = dp->d_ops->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), - add_datasize = dp->d_ops->data_entsize(args->namelen), + add_datasize = dp->d_ops->data_entsize(args->name.len), eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen),
@@ -476,9 +476,9 @@ xfs_dir2_sf_addname_hard(/* * Fill in the new entry, and update the header counts. */ - sfep->namelen = args->namelen; + sfep->namelen = args->name.len;xfs_dir2_sf_put_offset (sfep, offset); -memcpy (sfep->name, args->name, sfep->namelen); +memcpy (sfep->name, args->name.name, sfep->namelen); dp->d_ops->sf_put_ino (sfp, sfep, args->inumber); dp->d_ops->sf_put_ftype (sfep, args->filetype); sfp->count++;
@@ -522,7 +522,7 @@ xfs_dir2_sf_addname_pick( dp = args->dp; sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size = dp->d_ops->data_entsize (args->namelen); + size = dp->d_ops->data_entsize (args->name.len); offset = dp->d_ops->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;
@@ -807,7 +807,7 @@ xfs_dir2_sf_lookup(/* * Special case for . */ -if (args->namelen ==1 && args->name[0 ] =='.' ) { +if (args->name.len ==1 && args->name.name[0 ] =='.' ) { args->inumber = dp->i_ino; args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;
@@ -816,8 +816,8 @@ xfs_dir2_sf_lookup(/* * Special case for .. */ -if (args->namelen ==2 && - args->name[0 ] =='.' && args->name[1 ] =='.' ) { +if (args->name.len ==2 && + args->name.name[0 ] =='.' && args->name.name[1 ] =='.' ) { args->inumber = dp->d_ops->sf_get_parent_ino (sfp); args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;
@@ -912,7 +912,7 @@ xfs_dir2_sf_removename(* Calculate sizes. */ byteoff = (int )((char *)sfep - (char *)sfp); - entsize = dp->d_ops->sf_entsize (sfp, args->namelen); + entsize = dp->d_ops->sf_entsize (sfp, args->name.len); newsize = oldsize - entsize;/* * Copy the part if any after the removed entry, sliding it down.
@@ -1002,12 +1002,12 @@ xfs_dir2_sf_replace( }else i8elevated =0 ; -ASSERT (args->namelen !=1 || args->name[0 ] !='.' ); +ASSERT (args->name.len !=1 || args->name.name[0 ] !='.' );/* * Replace ..'s entry. */ -if (args->namelen ==2 && - args->name[0 ] =='.' && args->name[1 ] =='.' ) { +if (args->name.len ==2 && + args->name.name[0 ] =='.' && args->name.name[1 ] =='.' ) { ino = dp->d_ops->sf_get_parent_ino (sfp);ASSERT (args->inumber != ino); dp->d_ops->sf_put_parent_ino (sfp, args->inumber);
Signature · 1 line
2.7.4
PATCH v6 4/17 xfsprogs: Add xfs_has_attr and subroutines
In reply to Allison CollinsThis patch adds a new functions to check for the existence of an attribute. Subroutines are also added to handle the cases of leaf blocks, nodes or shortform. Common code that appears in existing attr add and remove functions have been factored out to help reduce the appearance of duplicated code. We will need these routines later for delayed attributes since delayed operations cannot return error codes.
--- libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++++++----------------- libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_leaf.c | 111 ++++++++++++++++++++------------ libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)
libxfs/xfs_attr.c +114 -57
@@ -45,6 +45,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); +STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp);/* * Internal routines when attribute list is more than one block.
@@ -52,6 +53,8 @@ STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, +struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state);
@@ -309,6 +312,37 @@ xfs_attr_set_args( }/* +* Return EEXIST if attr is found, or ENOATTR if not +*/ +int +xfs_has_attr ( +struct xfs_da_args *args) +{ +struct xfs_inode *dp = args->dp; +struct xfs_buf *bp =NULL ; +int error; + +if (!xfs_inode_hasattr (dp)) +return -ENOATTR ; + +if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) { +ASSERT (dp->i_afp->if_flags &XFS_IFINLINE ); +return xfs_attr_sf_findname (args,NULL ,NULL ); + } + +if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { + error =xfs_attr_leaf_hasname (args, &bp); + +if (bp) +xfs_trans_brelse (args->trans, bp); + +return error; + } + +return xfs_attr_node_hasname (args,NULL ); +} + +/* * Remove the attribute specified in @args. */ int
@@ -582,26 +616,20 @@ STATIC intxfs_attr_leaf_addname ( struct xfs_da_args *args) { -struct xfs_inode *dp;struct xfs_buf *bp;int retval, error, forkoff; +struct xfs_inode *dp = args->dp;trace_xfs_attr_leaf_addname (args);/* -* Read the (only) block in the attribute list in. -*/ - dp = args->dp; - args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); -if (error) -return error; - -/* * Look up the given attribute in the leaf block. Figure out if * the given flags produce an error or call for an atomic rename. */ - retval =xfs_attr3_leaf_lookup_int (bp, args); + retval =xfs_attr_leaf_hasname (args, &bp); +if (retval != -ENOATTR && retval != -EEXIST ) +return retval; +if ((args->name.type &ATTR_REPLACE ) && (retval == -ENOATTR )) {xfs_trans_brelse (args->trans, bp);return retval;
@@ -753,6 +781,27 @@ xfs_attr_leaf_addname( }/* +* Return EEXIST if attr is found, or ENOATTR if not +*/ +STATIC int +xfs_attr_leaf_hasname ( +struct xfs_da_args *args, +struct xfs_buf **bp) +{ +int error =0 ; + + error =xfs_attr3_leaf_read (args->trans, args->dp,0 ,-1 , bp); +if (error) +return error; + + error =xfs_attr3_leaf_lookup_int (*bp, args); +if (error != -ENOATTR && error != -EEXIST ) +xfs_trans_brelse (args->trans, *bp); + +return error; +} + +/* * Remove a name from the leaf attribute list structure * * This leaf block cannot have a "remote" value, we only call this routine
@@ -772,12 +821,11 @@ xfs_attr_leaf_removename(* Remove the attribute. */ dp = args->dp; - args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); -if (error) + + error =xfs_attr_leaf_hasname (args, &bp); +if (error != -ENOATTR && error != -EEXIST )return error; - error =xfs_attr3_leaf_lookup_int (bp, args);if (error == -ENOATTR ) {xfs_trans_brelse (args->trans, bp);return error;
@@ -816,12 +864,10 @@ xfs_attr_leaf_get(xfs_da_args_t *args)trace_xfs_attr_leaf_get (args); - args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno,-1 , &bp); -if (error) + error =xfs_attr_leaf_hasname (args, &bp); +if (error != -ENOATTR && error != -EEXIST )return error; - error =xfs_attr3_leaf_lookup_int (bp, args);if (error != -EEXIST ) {xfs_trans_brelse (args->trans, bp);return error;
@@ -831,6 +877,41 @@ xfs_attr_leaf_get(xfs_da_args_t *args)return error; } +/* +* Return EEXIST if attr is found, or ENOATTR if not +* statep: If not null is set to point at the found state. Caller will +* be responsible for freeing the state in this case. +*/ +STATIC int +xfs_attr_node_hasname ( +struct xfs_da_args *args, +struct xfs_da_state **statep) +{ +struct xfs_da_state *state; +int retval, error; + + state =xfs_da_state_alloc (); + state->args = args; + state->mp = args->dp->i_mount; + +if (statep !=NULL ) + *statep =NULL ; + +/* +* Search to see if name exists, and get back a pointer to it. +*/ + error =xfs_da3_node_lookup_int (state, &retval); +if (error ==0 ) { +if (statep !=NULL ) + *statep = state; +return retval; + } + +xfs_da_state_free (state); + +return error; +} +/*======================================================================== * External routines when attribute list size > geo->blksize *========================================================================*/
@@ -863,20 +944,17 @@ xfs_attr_node_addname( dp = args->dp; mp = dp->i_mount; restart: - state =xfs_da_state_alloc (); - state->args = args; - state->mp = mp; -/* * Search to see if name already exists, and get back a pointer * to where it should go. */ - error =xfs_da3_node_lookup_int (state, &retval); -if (error) + retval =xfs_attr_node_hasname (args, &state); +if (retval != -ENOATTR ) goto out; + blk = &state->path.blk[ state->path.active-1 ];ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); -if ((args->name.type &ATTR_REPLACE ) && (retval == -ENOATTR )) { +if (args->name.type &ATTR_REPLACE ) { goto out; }else if (retval == -EEXIST ) {if (args->name.type &ATTR_CREATE )
@@ -1078,29 +1156,15 @@ xfs_attr_node_removename( {struct xfs_da_state *state;struct xfs_da_state_blk *blk; -struct xfs_inode *dp;struct xfs_buf *bp;int retval, error, forkoff; +struct xfs_inode *dp = args->dp;trace_xfs_attr_node_removename (args); -/* -* Tie a string around our finger to remind us where we are. -*/ - dp = args->dp; - state =xfs_da_state_alloc (); - state->args = args; - state->mp = dp->i_mount; - -/* -* Search to see if name exists, and get back a pointer to it. -*/ - error =xfs_da3_node_lookup_int (state, &retval); -if (error || (retval != -EEXIST )) { -if (error ==0 ) - error = retval; + error =xfs_attr_node_hasname (args, &state); +if (error != -EEXIST ) goto out; - }/* * If there is an out-of-line value, de-allocate the blocks.
@@ -1195,7 +1259,8 @@ xfs_attr_node_removename( error =0 ; out: -xfs_da_state_free (state); +if (state) +xfs_da_state_free (state);return error; }
@@ -1317,31 +1382,23 @@ xfs_attr_node_get(xfs_da_args_t *args) {xfs_da_state_t *state;xfs_da_state_blk_t *blk; -int error, retval; +int error;int i;trace_xfs_attr_node_get (args); - state =xfs_da_state_alloc (); - state->args = args; - state->mp = args->dp->i_mount; -/* * Search to see if name exists, and get back a pointer to it. */ - error =xfs_da3_node_lookup_int (state, &retval); -if (error) { - retval = error; - goto out_release; - } -if (retval != -EEXIST ) + error =xfs_attr_node_hasname (args, &state); +if (error != -EEXIST ) goto out_release;/* * Get the value, local or "remote" */ blk = &state->path.blk[state->path.active -1 ]; - retval =xfs_attr3_leaf_getvalue (blk->bp, args); + error =xfs_attr3_leaf_getvalue (blk->bp, args);/* * If not in a transaction, we have to release all the buffers.
@@ -1353,7 +1410,7 @@ out_release: }xfs_da_state_free (state); -return retval; +return error; }/* Returns true if the attribute entry name is valid. */
libxfs/xfs_attr.h +1 -0
@@ -150,6 +150,7 @@ int xfs_attr_set(struct xfs_inode *dp, struct xfs_name *name, unsigned char *value, int valuelen, int flags);int xfs_attr_set_args (struct xfs_da_args *args);int xfs_attr_remove (struct xfs_inode *dp,struct xfs_name *name,int flags); +int xfs_has_attr (struct xfs_da_args *args);int xfs_attr_remove_args (struct xfs_da_args *args);int xfs_attr_list (struct xfs_inode *dp,char *buffer,int bufsize,int flags,struct attrlist_cursor_kern *cursor);
libxfs/xfs_attr_leaf.c +70 -41
141 lines not on this page · raw message
libxfs/xfs_attr_leaf.h +3 -0
@@ -39,6 +39,9 @@ int xfs_attr_shortform_getvalue(struct xfs_da_args *args);int xfs_attr_shortform_to_leaf (struct xfs_da_args *args,struct xfs_buf **leaf_bp);int xfs_attr_shortform_remove (struct xfs_da_args *args); +int xfs_attr_sf_findname (struct xfs_da_args *args, +struct xfs_attr_sf_entry **sfep, +unsigned int *basep);int xfs_attr_shortform_allfit (struct xfs_buf *bp,struct xfs_inode *dp);int xfs_attr_shortform_bytesfit (struct xfs_inode *dp,int bytes);xfs_failaddr_t xfs_attr_shortform_verify (struct xfs_inode *ip);
Signature · 1 line
2.7.4
PATCH v6 5/17 xfsprogs: Factor out new helper functions xfs_attr_rmtval_set
In reply to Allison CollinsBreak xfs_attr_rmtval_set into two helper functions xfs_attr_rmt_find_hole and xfs_attr_rmtval_set_value. xfs_attr_rmtval_set rolls the transaction between the helpers, but delayed operations cannot. We will use the helpers later when constructing new delayed attribute routines.
--- libxfs/xfs_attr_remote.c | 149 +++++++++++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 57 deletions(-)
libxfs/xfs_attr_remote.c +92 -57
@@ -422,32 +422,23 @@ xfs_attr_rmtval_get( }/* -* Write the value associated with an attribute into the out-of-line buffer -* that we have defined for it. +* Find a "hole" in the attribute address space large enough for us to drop the +* new attribute's value into */ -int -xfs_attr_rmtval_set ( +STATIC int +xfs_attr_rmt_find_hole (struct xfs_da_args *args) {struct xfs_inode *dp = args->dp;struct xfs_mount *mp = dp->i_mount; -struct xfs_bmbt_irec map; -xfs_dablk_t lblkno; -xfs_fileoff_t lfileoff =0 ; -uint8_t *src = args->value; -int blkcnt; -int valuelen; -int nmap;int error; -int offset =0 ; - -trace_xfs_attr_rmtval_set (args); +int blkcnt; +xfs_fileoff_t lfileoff =0 ;/* -* Find a "hole" in the attribute address space large enough for -* us to drop the new attribute's value into. Because CRC enable -* attributes have headers, we can't just do a straight byte to FSB -* conversion and have to take the header space into account. +* Because CRC enable attributes have headers, we can't just do a +* straight byte to FSB conversion and have to take the header space +* into account. */ blkcnt =xfs_attr3_rmt_blocks (mp, args->rmtvaluelen); error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff,
@@ -455,48 +446,26 @@ xfs_attr_rmtval_set(if (error)return error; - args->rmtblkno = lblkno = (xfs_dablk_t )lfileoff; + args->rmtblkno = (xfs_dablk_t )lfileoff; args->rmtblkcnt = blkcnt; -/* -* Roll through the "value", allocating blocks on disk as required. -*/ -while (blkcnt >0 ) { -/* -* Allocate a single extent, up to the size of the value. -* -* Note that we have to consider this a data allocation as we -* write the remote attribute without logging the contents. -* Hence we must ensure that we aren't using blocks that are on -* the busy list so that we don't overwrite blocks which have -* recently been freed but their transactions are not yet -* committed to disk. If we overwrite the contents of a busy -* extent and then crash then the block may not contain the -* correct metadata after log recovery occurs. -*/ - nmap =1 ; - error =xfs_bmapi_write (args->trans, dp, (xfs_fileoff_t )lblkno, - blkcnt,XFS_BMAPI_ATTRFORK , args->total, &map, - &nmap); -if (error) -return error; - error =xfs_defer_finish (&args->trans); -if (error) -return error; - -ASSERT (nmap ==1 ); -ASSERT ((map.br_startblock !=DELAYSTARTBLOCK ) && - (map.br_startblock !=HOLESTARTBLOCK )); - lblkno += map.br_blockcount; - blkcnt -= map.br_blockcount; +return 0 ; +} -/* -* Start the next trans in the chain. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) -return error; - } +STATIC int +xfs_attr_rmtval_set_value ( +struct xfs_da_args *args) +{ +struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = dp->i_mount; +struct xfs_bmbt_irec map; +xfs_dablk_t lblkno; +uint8_t *src = args->value; +int blkcnt; +int valuelen; +int nmap; +int error; +int offset =0 ;/* * Roll through the "value", copying the attribute value to the
@@ -550,6 +519,72 @@ xfs_attr_rmtval_set( }/* +* Write the value associated with an attribute into the out-of-line buffer +* that we have defined for it. +*/ +int +xfs_attr_rmtval_set ( +struct xfs_da_args *args) +{ +struct xfs_inode *dp = args->dp; +struct xfs_bmbt_irec map; +xfs_dablk_t lblkno; +int blkcnt; +int nmap; +int error; + +trace_xfs_attr_rmtval_set (args); + + error =xfs_attr_rmt_find_hole (args); +if (error) +return error; + + blkcnt = args->rmtblkcnt; + lblkno = (xfs_dablk_t )args->rmtblkno; +/* +* Roll through the "value", allocating blocks on disk as required. +*/ +while (blkcnt >0 ) { +/* +* Allocate a single extent, up to the size of the value. +* +* Note that we have to consider this a data allocation as we +* write the remote attribute without logging the contents. +* Hence we must ensure that we aren't using blocks that are on +* the busy list so that we don't overwrite blocks which have +* recently been freed but their transactions are not yet +* committed to disk. If we overwrite the contents of a busy +* extent and then crash then the block may not contain the +* correct metadata after log recovery occurs. +*/ + nmap =1 ; + error =xfs_bmapi_write (args->trans, dp, (xfs_fileoff_t )lblkno, + blkcnt,XFS_BMAPI_ATTRFORK , args->total, &map, + &nmap); +if (error) +return error; + error =xfs_defer_finish (&args->trans); +if (error) +return error; + +ASSERT (nmap ==1 ); +ASSERT ((map.br_startblock !=DELAYSTARTBLOCK ) && + (map.br_startblock !=HOLESTARTBLOCK )); + lblkno += map.br_blockcount; + blkcnt -= map.br_blockcount; + +/* +* Start the next trans in the chain. +*/ + error =xfs_trans_roll_inode (&args->trans, dp); +if (error) +return error; + } + +return xfs_attr_rmtval_set_value (args); +} + +/* * Remove the value associated with an attribute by deleting the * out-of-line buffer that it is stored on. */
Signature · 1 line
2.7.4
PATCH v6 6/17 xfsprogs: Factor out trans handling in xfs_attr3_leaf_flipflags
In reply to Allison CollinsSince delayed operations cannot roll transactions, factor up the transaction handling into the calling function
--- libxfs/xfs_attr.c | 14 ++++++++++++++ libxfs/xfs_attr_leaf.c | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-)
libxfs/xfs_attr.c +14 -0
@@ -726,6 +726,13 @@ xfs_attr_leaf_addname( error =xfs_attr3_leaf_flipflags (args);if (error)return error; +/* +* Commit the flag value change and start the next trans in +* series. +*/ + error =xfs_trans_roll_inode (&args->trans, args->dp); +if (error) +return error;/* * Dismantle the "old" attribute/value pair by removing
@@ -1068,6 +1075,13 @@ restart: error =xfs_attr3_leaf_flipflags (args);if (error) goto out; +/* +* Commit the flag value change and start the next trans in +* series +*/ + error =xfs_trans_roll_inode (&args->trans, args->dp); +if (error) + goto out;/* * Dismantle the "old" attribute/value pair by removing
libxfs/xfs_attr_leaf.c +1 -6
@@ -2899,10 +2899,5 @@ xfs_attr3_leaf_flipflags( XFS_DA_LOGRANGE(leaf2, name_rmt, sizeof(*name_rmt))); } -/* -* Commit the flag value change and start the next trans in series. -*/ - error =xfs_trans_roll_inode (&args->trans, args->dp); - -return error; +return 0 ; }
Signature · 1 line
2.7.4
PATCH v6 7/17 xfsprogs: Factor out xfs_attr_leaf_addname helper
In reply to Allison CollinsFactor out new helper function xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve off the parts of xfs_attr_leaf_addname that we can use, and move the commit into the calling function.
--- libxfs/xfs_attr.c | 83 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 34 deletions(-)
libxfs/xfs_attr.c +49 -34
@@ -304,10 +304,30 @@ xfs_attr_set_args( } } -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) +if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { error =xfs_attr_leaf_addname (args); -else - error =xfs_attr_node_addname (args); +if (error != -ENOSPC ) +return error; + +/* +* Commit that transaction so that the node_addname() +* call can manage its own transactions. +*/ + error =xfs_defer_finish (&args->trans); +if (error) +return error; + +/* +* Commit the current trans (including the inode) and +* start a new one. +*/ + error =xfs_trans_roll_inode (&args->trans, dp); +if (error) +return error; + + } + + error =xfs_attr_node_addname (args);return error; }
@@ -606,21 +626,12 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)* External routines when attribute list is one block *========================================================================*/ -/* -* Add a name to the leaf attribute list structure -* -* This leaf block cannot have a "remote" value, we only call this routine -* if bmap_one_block() says there is only one block (ie: no remote blks). -*/ STATIC int -xfs_attr_leaf_addname ( -struct xfs_da_args *args) +xfs_attr_leaf_try_add ( +struct xfs_da_args *args, +struct xfs_buf *bp) { -struct xfs_buf *bp; -int retval, error, forkoff; -struct xfs_inode *dp = args->dp; - -trace_xfs_attr_leaf_addname (args); +int retval, error;/* * Look up the given attribute in the leaf block. Figure out if
@@ -666,31 +677,35 @@ xfs_attr_leaf_addname( retval =xfs_attr3_leaf_add (bp, args);if (retval == -ENOSPC ) {/* -* Promote the attribute list to the Btree format, then -* Commit that transaction so that the node_addname() call -* can manage its own transactions. +* Promote the attribute list to the Btree format. +* Unless an error occurs, retain the -ENOSPC retval */ error =xfs_attr3_leaf_to_node (args);if (error)return error; - error =xfs_defer_finish (&args->trans); -if (error) -return error; + } +return retval; +} -/* -* Commit the current trans (including the inode) and start -* a new one. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) -return error; -/* -* Fob the whole rest of the problem off on the Btree code. -*/ - error =xfs_attr_node_addname (args); +/* +* Add a name to the leaf attribute list structure +* +* This leaf block cannot have a "remote" value, we only call this routine +* if bmap_one_block() says there is only one block (ie: no remote blks). +*/ +STATIC int +xfs_attr_leaf_addname (struct xfs_da_args *args) +{ +int error, forkoff; +struct xfs_buf *bp =NULL ; +struct xfs_inode *dp = args->dp; + +trace_xfs_attr_leaf_addname (args); + + error =xfs_attr_leaf_try_add (args, bp); +if (error)return error; - }/* * Commit the transaction that added the attr name so that
Signature · 1 line
2.7.4
PATCH v6 8/17 xfsprogs: Refactor xfs_attr_try_sf_addname
In reply to Allison CollinsTo help pre-simplify xfs_attr_set_args, we need to hoist transacation handling up, while modularizing the adjacent code down into helpers. In this patch, hoist the commit in xfs_attr_try_sf_addname up into the calling function, and also pull the attr list creation down.
--- libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
libxfs/xfs_attr.c +15 -15
@@ -226,8 +226,13 @@ xfs_attr_try_sf_addname( struct xfs_da_args *args) { -struct xfs_mount *mp = dp->i_mount; -int error, error2; +int error; + +/* +* Build initial attribute list (if required). +*/ +if (dp->i_d.di_aformat ==XFS_DINODE_FMT_EXTENTS ) +xfs_attr_shortform_create (args); error =xfs_attr_shortform_addname (args);if (error == -ENOSPC )
@@ -240,12 +245,10 @@ xfs_attr_try_sf_addname(if (!error && (args->name.type &ATTR_KERNOTIME ) ==0 )xfs_trans_ichgtime (args->trans, dp,XFS_ICHGTIME_CHG ); -if (mp->m_flags &XFS_MOUNT_WSYNC ) +if (dp->i_mount->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (args->trans); - error2 =xfs_trans_commit (args->trans); - args->trans =NULL ; -return error ? error : error2; +return error; }/*
@@ -257,7 +260,7 @@ xfs_attr_set_args( {struct xfs_inode *dp = args->dp;struct xfs_buf *leaf_bp =NULL ; -int error; +int error, error2 =0 ;/* * If the attribute list is non-existent or a shortform list,
@@ -268,17 +271,14 @@ xfs_attr_set_args( dp->i_d.di_anextents == 0)) {/* -* Build initial attribute list (if required). -*/ -if (dp->i_d.di_aformat ==XFS_DINODE_FMT_EXTENTS ) -xfs_attr_shortform_create (args); - -/* * Try to add the attr to the attribute list in the inode. */ error =xfs_attr_try_sf_addname (dp, args); -if (error != -ENOSPC ) -return error; +if (error != -ENOSPC ) { + error2 =xfs_trans_commit (args->trans); + args->trans =NULL ; +return error ? error : error2; + }/* * It won't fit in the shortform, transform to a leaf block.
Signature · 1 line
2.7.4
PATCH v6 9/17 xfsprogs: Factor out trans roll from xfs_attr3_leaf_setflag
In reply to Allison CollinsNew delayed allocation routines cannot be handling transactions so factor them up into the calling functions
--- libxfs/xfs_attr.c | 5 +++++ libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-)
libxfs/xfs_attr.c +5 -0
@@ -1220,6 +1220,11 @@ xfs_attr_node_removename( error =xfs_attr3_leaf_setflag (args);if (error) goto out; + + error =xfs_trans_roll_inode (&args->trans, args->dp); +if (error) + goto out; + error =xfs_attr_rmtval_remove (args);if (error) goto out;
libxfs/xfs_attr_leaf.c +1 -4
@@ -2781,10 +2781,7 @@ xfs_attr3_leaf_setflag( XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); } -/* -* Commit the flag value change and start the next trans in series. -*/ -return xfs_trans_roll_inode (&args->trans, args->dp); +return 0 ; }/*
Signature · 1 line
2.7.4
PATCH v6 10/17 xfsprogs: Factor out xfs_attr_rmtval_invalidate
In reply to Allison CollinsBecause new delayed attribute routines cannot roll transactions, we carve off the parts of xfs_attr_rmtval_remove that we can use. This will help to reduce repetitive code later when we introduce delayed attributes.
--- libxfs/xfs_attr_remote.c | 26 +++++++++++++++++++++----- libxfs/xfs_attr_remote.h | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-)
libxfs/xfs_attr_remote.c +21 -5
@@ -589,16 +589,13 @@ xfs_attr_rmtval_set(* out-of-line buffer that it is stored on. */ int -xfs_attr_rmtval_remove ( +xfs_attr_rmtval_invalidate (struct xfs_da_args *args) {struct xfs_mount *mp = args->dp->i_mount;xfs_dablk_t lblkno;int blkcnt;int error; -int done; - -trace_xfs_attr_rmtval_remove (args);/* * Roll through the "value", invalidating the attribute value's blocks.
@@ -640,13 +637,32 @@ xfs_attr_rmtval_remove( lblkno += map.br_blockcount; blkcnt -= map.br_blockcount; } +return 0 ; +} +/* +* Remove the value associated with an attribute by deleting the +* out-of-line buffer that it is stored on. +*/ +int +xfs_attr_rmtval_remove ( +struct xfs_da_args *args) +{ +xfs_dablk_t lblkno; +int blkcnt; +int error =0 ; +int done =0 ; + +trace_xfs_attr_rmtval_remove (args); + + error =xfs_attr_rmtval_invalidate (args); +if (error) +return error;/* * Keep de-allocating extents until the remote-value region is gone. */ lblkno = args->rmtblkno; blkcnt = args->rmtblkcnt; - done =0 ;while (!done) { error =xfs_bunmapi (args->trans, args->dp, lblkno, blkcnt,XFS_BMAPI_ATTRFORK ,1 , &done);
libxfs/xfs_attr_remote.h +1 -1
@@ -11,5 +11,5 @@ int xfs_attr3_rmt_blocks(struct xfs_mount *mp, int attrlen);int xfs_attr_rmtval_get (struct xfs_da_args *args);int xfs_attr_rmtval_set (struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args); - +int xfs_attr_rmtval_invalidate (struct xfs_da_args *args);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
2.7.4
PATCH v6 11/17 xfsprogs: Factor out trans roll in xfs_attr3_leaf_clearflag
In reply to Allison CollinsNew delayed allocation routines cannot be handling transactions so factor them out into the calling functions
--- libxfs/xfs_attr.c | 16 ++++++++++++++++ libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 17 insertions(+), 4 deletions(-)
libxfs/xfs_attr.c +16 -0
@@ -798,6 +798,14 @@ xfs_attr_leaf_addname(struct xfs_da_args *args)* Added a "remote" value, just clear the incomplete flag. */ error =xfs_attr3_leaf_clearflag (args); +if (error) +return error; + +/* +* Commit the flag value change and start the next trans in +* series. +*/ + error =xfs_trans_roll_inode (&args->trans, args->dp); }return error; }
@@ -1161,6 +1169,14 @@ restart: error =xfs_attr3_leaf_clearflag (args);if (error) goto out; + +/* +* Commit the flag value change and start the next trans in +* series. +*/ + error =xfs_trans_roll_inode (&args->trans, args->dp); +if (error) + goto out; } retval = error =0 ;
libxfs/xfs_attr_leaf.c +1 -4
@@ -2730,10 +2730,7 @@ xfs_attr3_leaf_clearflag( XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); } -/* -* Commit the flag value change and start the next trans in series. -*/ -return xfs_trans_roll_inode (&args->trans, args->dp); +return 0 ; }/*
Signature · 1 line
2.7.4
PATCH v6 12/17 xfsprogs: Check for -ENOATTR or -EEXIST
In reply to Allison CollinsDelayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations
--- libxfs/xfs_attr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
libxfs/xfs_attr.c +12 -0
@@ -456,6 +456,14 @@ xfs_attr_set( goto out_trans_cancel;xfs_trans_ijoin (args.trans, dp,0 ); + + error =xfs_has_attr (&args); +if (error == -EEXIST && (name->type &ATTR_CREATE )) + goto out_trans_cancel; + +if (error == -ENOATTR && (name->type &ATTR_REPLACE )) + goto out_trans_cancel; + error =xfs_attr_set_args (&args);if (error) goto out_trans_cancel;
@@ -544,6 +552,10 @@ xfs_attr_remove(*/ xfs_trans_ijoin (args.trans, dp,0 ); + error =xfs_has_attr (&args); +if (error != -EEXIST ) + goto out; + error =xfs_attr_remove_args (&args);if (error) goto out;
Signature · 1 line
2.7.4
PATCH v6 13/17 xfsprogs: Add helper function xfs_attr_init_unmapstate
In reply to Allison CollinsThis patch helps to pre-simplify xfs_attr_node_removename by modularizing the code around the transactions into helper functions. This will make the function easier to follow when we introduce delayed attributes.
--- libxfs/xfs_attr.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-)
libxfs/xfs_attr.c +31 -14
@@ -1201,6 +1201,36 @@ out: }/* +* Set up the state for unmap and set the incomplete flag +*/ +STATIC int +xfs_attr_init_unmapstate ( +struct xfs_da_args *args, +struct xfs_da_state *state) +{ +int error; + +/* +* Fill in disk block numbers in the state structure +* so that we can get the buffers back after we commit +* several transactions in the following calls. +*/ + error =xfs_attr_fillstate (state); +if (error) +return error; + +/* +* Mark the attribute as INCOMPLETE +*/ + error =xfs_attr3_leaf_setflag (args); +if (error) +return error; + +return 0 ; +} + + +/* * Remove a name from a B-tree attribute list. * * This will involve walking down the Btree, and may involve joining
@@ -1232,20 +1262,7 @@ xfs_attr_node_removename(ASSERT (blk->bp !=NULL );ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC );if (args->rmtblkno >0 ) { -/* -* Fill in disk block numbers in the state structure -* so that we can get the buffers back after we commit -* several transactions in the following calls. -*/ - error =xfs_attr_fillstate (state); -if (error) - goto out; - -/* -* Mark the attribute as INCOMPLETE, then bunmapi() the -* remote value. -*/ - error =xfs_attr3_leaf_setflag (args); + error =xfs_attr_init_unmapstate (args, state);if (error) goto out;
Signature · 1 line
2.7.4
PATCH v6 14/17 xfsprogs: Add helper function xfs_attr_rmtval_unmap
In reply to Allison CollinsThis function is similar to xfs_attr_rmtval_remove, but adapted to return. EAGAIN for new transactions. We will use this later when we introduce delayed attributes
--- libxfs/xfs_attr_remote.c | 27 +++++++++++++++++++++++++++ libxfs/xfs_attr_remote.h | 1 + 2 files changed, 28 insertions(+)
libxfs/xfs_attr_remote.c +27 -0
@@ -681,3 +681,30 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Unmap value blocks for this attr. This is similar to +* xfs_attr_rmtval_remove, but adapted to to return EAGAIN for new transactions +*/ +int +xfs_attr_rmtval_unmap ( +struct xfs_da_args *args) +{ +int error, done; + +/* +* Unmap value blocks for this attr. This is similar to +* xfs_attr_rmtval_remove, but open coded here to return EAGAIN +* for new transactions +*/ + error =xfs_bunmapi (args->trans, args->dp, + args->rmtblkno, args->rmtblkcnt, +XFS_BMAPI_ATTRFORK ,1 , &done); +if (error) +return error; + +if (!done) +return -EAGAIN ; + +return 0 ; +}
libxfs/xfs_attr_remote.h +1 -0
@@ -12,4 +12,5 @@ int xfs_attr_rmtval_get(struct xfs_da_args *args);int xfs_attr_rmtval_set (struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args);int xfs_attr_rmtval_invalidate (struct xfs_da_args *args); +int xfs_attr_rmtval_unmap (struct xfs_da_args *args);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
2.7.4
PATCH v6 15/17 xfsprogs: Simplify xfs_attr_set_args
In reply to Allison CollinsDelayed attribute mechanics make frequent use of goto statements. We can use this to further simplify xfs_attr_set_args. In this patch we introduce one of the gotos now to help pre-simplify the routine. This will help make proceeding patches in this area easier to read.
--- libxfs/xfs_attr.c | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 34 deletions(-)
libxfs/xfs_attr.c +37 -34
@@ -263,47 +263,50 @@ xfs_attr_set_args(int error, error2 =0 ;/* -* If the attribute list is non-existent or a shortform list, -* upgrade it to a single-leaf-block attribute list. +* If the attribute list is non-existent or a shortform list, proceed to +* upgrade it to a single-leaf-block attribute list. Otherwise jump +* straight to leaf handling */ -if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL || +if (!(dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL || (dp->i_d.di_aformat ==XFS_DINODE_FMT_EXTENTS && - dp->i_d.di_anextents ==0 )) { + dp->i_d.di_anextents ==0 ))) + goto sf_to_leaf; -/* -* Try to add the attr to the attribute list in the inode. -*/ - error =xfs_attr_try_sf_addname (dp, args); -if (error != -ENOSPC ) { - error2 =xfs_trans_commit (args->trans); - args->trans =NULL ; -return error ? error : error2; - } +/* +* Try to add the attr to the attribute list in the inode. +*/ + error =xfs_attr_try_sf_addname (dp, args); +if (error != -ENOSPC ) { + error2 =xfs_trans_commit (args->trans); + args->trans =NULL ; +return error ? error : error2; + } -/* -* It won't fit in the shortform, transform to a leaf block. -* GROT: another possible req'mt for a double-split btree op. -*/ - error =xfs_attr_shortform_to_leaf (args, &leaf_bp); -if (error) -return error; +/* +* It won't fit in the shortform, transform to a leaf block. +* GROT: another possible req'mt for a double-split btree op. +*/ + error =xfs_attr_shortform_to_leaf (args, &leaf_bp); +if (error) +return error; -/* -* Prevent the leaf buffer from being unlocked so that a -* concurrent AIL push cannot grab the half-baked leaf -* buffer and run into problems with the write verifier. -* Once we're done rolling the transaction we can release -* the hold and add the attr to the leaf. -*/ -xfs_trans_bhold (args->trans, leaf_bp); - error =xfs_defer_finish (&args->trans); -xfs_trans_bhold_release (args->trans, leaf_bp); -if (error) { -xfs_trans_brelse (args->trans, leaf_bp); -return error; - } +/* +* Prevent the leaf buffer from being unlocked so that a +* concurrent AIL push cannot grab the half-baked leaf +* buffer and run into problems with the write verifier. +* Once we're done rolling the transaction we can release +* the hold and add the attr to the leaf. +*/ +xfs_trans_bhold (args->trans, leaf_bp); + error =xfs_defer_finish (&args->trans); +xfs_trans_bhold_release (args->trans, leaf_bp); +if (error) { +xfs_trans_brelse (args->trans, leaf_bp); +return error; } +sf_to_leaf: +if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { error =xfs_attr_leaf_addname (args);if (error != -ENOSPC )
Signature · 1 line
2.7.4
PATCH v6 16/17 xfsprogs: Add delay ready attr remove routines
In reply to Allison CollinsThis patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_remove_args has become xfs_attr_remove_iter, which uses a sort of state machine like switch to keep track of where it was when EAGAIN was returned. xfs_attr_node_removename has also been modified to use the switch, and a new version of xfs_attr_remove_args consists of a simple loop to refresh the transaction until the operation is completed. A helper function xfs_attr_node_shrink has also been added to help simplify xfs_attr_node_removename and reduce length.
This patch also adds a new struct xfs_delattr_context, which we will use to keep track of the current state of an attribute operation. The new xfs_delattr_state enum is used to track various operations that are in progress so that we know not to repeat them, and resume where we left off before EAGAIN was returned to cycle out the transaction. Other members take the place of local variables that need to retain their values across multiple function recalls.
--- libxfs/xfs_attr.c | 182 ++++++++++++++++++++++++++++++++++++++------------ libxfs/xfs_attr.h | 1 + libxfs/xfs_da_btree.h | 24 +++++++ 3 files changed, 164 insertions(+), 43 deletions(-)
libxfs/xfs_attr.c +139 -43
@@ -370,11 +370,60 @@ xfs_has_attr(*/ int xfs_attr_remove_args ( +struct xfs_da_args *args) +{ +int error =0 ; +int err2 =0 ; + +do { + error =xfs_attr_remove_iter (args); +if (error && error != -EAGAIN ) + goto out; + +if (args->dac.flags &XFS_DAC_FINISH_TRANS ) { + args->dac.flags &= ~XFS_DAC_FINISH_TRANS ; + + err2 =xfs_defer_finish (&args->trans); +if (err2) { + error = err2; + goto out; + } + } + + err2 =xfs_trans_roll_inode (&args->trans, args->dp); +if (err2) { + error = err2; + goto out; + } + + }while (error == -EAGAIN ); +out: +return error; +} + +/* +* Remove the attribute specified in @args. +* This routine is meant to function as a delayed operation, and may return +* -EGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +* returned. +*/ +int +xfs_attr_remove_iter (struct xfs_da_args *args) {struct xfs_inode *dp = args->dp;int error; +/* State machine switch */ +switch (args->dac.dela_state) { +case XFS_DAS_RM_SHRINK : +case XFS_DAS_RM_NODE_BLKS : + goto node; +default : +break ; + } +if (!xfs_inode_hasattr (dp)) { error = -ENOATTR ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {
@@ -383,6 +432,7 @@ xfs_attr_remove_args( }else if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { error =xfs_attr_leaf_removename (args); }else { +node: error =xfs_attr_node_removename (args); }
@@ -886,9 +936,8 @@ xfs_attr_leaf_removename(/* bp is gone due to xfs_da_shrink_inode */ if (error)return error; - error =xfs_defer_finish (&args->trans); -if (error) -return error; + + args->dac.flags |=XFS_DAC_FINISH_TRANS ; }return 0 ; }
@@ -1232,6 +1281,42 @@ xfs_attr_init_unmapstate(return 0 ; } +/* +* Shrink an attribute from leaf to shortform +*/ +STATIC int +xfs_attr_node_shrink ( +struct xfs_da_args *args, +struct xfs_da_state *state) +{ +struct xfs_inode *dp = args->dp; +int error, forkoff; +struct xfs_buf *bp; + +/* +* Have to get rid of the copy of this dabuf in the state. +*/ +ASSERT (state->path.active ==1 ); +ASSERT (state->path.blk[0 ].bp); + state->path.blk[0 ].bp =NULL ; + + error =xfs_attr3_leaf_read (args->trans, args->dp,0 ,-1 , &bp); +if (error) +return error; + + forkoff =xfs_attr_shortform_allfit (bp, dp); +if (forkoff) { + error =xfs_attr3_leaf_to_shortform (bp, args, forkoff); +/* bp is gone due to xfs_da_shrink_inode */ +if (error) +return error; + + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + }else +xfs_trans_brelse (args->trans, bp); + +return 0 ; +}/* * Remove a name from a B-tree attribute list.
@@ -1239,6 +1324,11 @@ xfs_attr_init_unmapstate(* This will involve walking down the Btree, and may involve joining * leaf nodes and even joining intermediate nodes up to and including * the root node (a special case of an intermediate node). +* +* This routine is meant to function as either an inline or delayed operation, +* and may return -EAGAIN when the transaction needs to be rolled. Calling +* functions will need to handle this, and recall the function until a +* successful error code is returned. */ STATIC int xfs_attr_node_removename(
@@ -1246,15 +1336,28 @@ xfs_attr_node_removename( {struct xfs_da_state *state;struct xfs_da_state_blk *blk; -struct xfs_buf *bp; -int retval, error, forkoff; +int retval, error;struct xfs_inode *dp = args->dp;trace_xfs_attr_node_removename (args); + state = args->dac.da_state; + blk = args->dac.blk; + +/* State machine switch */ +switch (args->dac.dela_state) { +case XFS_DAS_RM_NODE_BLKS : + goto rm_node_blks; +case XFS_DAS_RM_SHRINK : + goto rm_shrink; +default : +break ; + } error =xfs_attr_node_hasname (args, &state);if (error != -EEXIST ) goto out; +else + error =0 ;/* * If there is an out-of-line value, de-allocate the blocks.
@@ -1264,18 +1367,36 @@ xfs_attr_node_removename( blk = &state->path.blk[ state->path.active-1 ];ASSERT (blk->bp !=NULL );ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); + +/* +* Store blk and state in the context incase we need to cycle out the +* transaction +*/ + args->dac.blk = blk; + args->dac.da_state = state; +if (args->rmtblkno >0 ) { error =xfs_attr_init_unmapstate (args, state);if (error) goto out; - error =xfs_trans_roll_inode (&args->trans, args->dp); + error =xfs_attr_rmtval_invalidate (args);if (error) goto out; + } - error =xfs_attr_rmtval_remove (args); -if (error) - goto out; +rm_node_blks: + + args->dac.dela_state =XFS_DAS_RM_NODE_BLKS ; + +if (args->rmtblkno >0 ) { + error =xfs_attr_rmtval_unmap (args); + +if (error) { +if (error == -EAGAIN ) + args->dac.dela_state =XFS_DAS_RM_NODE_BLKS ; +return error; + }/* * Refill the state structure with buffers, the prior calls
@@ -1301,45 +1422,20 @@ xfs_attr_node_removename( error =xfs_da3_join (state);if (error) goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out; -/* -* Commit the Btree join operation and start a new trans. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) - goto out; + + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + args->dac.dela_state =XFS_DAS_RM_SHRINK ; +return -EAGAIN ; } +rm_shrink: + args->dac.dela_state =XFS_DAS_RM_SHRINK ; +/* * If the result is small enough, push it all into the inode. */ -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { -/* -* Have to get rid of the copy of this dabuf in the state. -*/ -ASSERT (state->path.active ==1 ); -ASSERT (state->path.blk[0 ].bp); - state->path.blk[0 ].bp =NULL ; - - error =xfs_attr3_leaf_read (args->trans, args->dp,0 ,-1 , &bp); -if (error) - goto out; - -if ((forkoff =xfs_attr_shortform_allfit (bp, dp))) { - error =xfs_attr3_leaf_to_shortform (bp, args, forkoff); -/* bp is gone due to xfs_da_shrink_inode */ -if (error) - goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out; - }else -xfs_trans_brelse (args->trans, bp); - } - error =0 ; - +if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) + error =xfs_attr_node_shrink (args, state); out:if (state)xfs_da_state_free (state);
libxfs/xfs_attr.h +1 -0
@@ -152,6 +152,7 @@ int xfs_attr_set_args(struct xfs_da_args *args);int xfs_attr_remove (struct xfs_inode *dp,struct xfs_name *name,int flags);int xfs_has_attr (struct xfs_da_args *args);int xfs_attr_remove_args (struct xfs_da_args *args); +int xfs_attr_remove_iter (struct xfs_da_args *args);int xfs_attr_list (struct xfs_inode *dp,char *buffer,int bufsize,int flags,struct attrlist_cursor_kern *cursor);bool xfs_attr_namecheck (const void *name,size_t length);
libxfs/xfs_da_btree.h +24 -0
@@ -43,9 +43,33 @@ enum xfs_dacmp { };/* +* Enum values for xfs_delattr_context.da_state +*/ +enum xfs_delattr_state { +XFS_DAS_RM_SHRINK =1 ,/* We are shrinking the tree */ +XFS_DAS_RM_NODE_BLKS =2 ,/* We are removing node blocks */ +}; + +/* +* Defines for xfs_delattr_context.flags +*/ +#define XFS_DAC_FINISH_TRANS 0x1/* indicates to finish the transaction */ + +/* +* Context used for keeping track of delayed attribute operations +*/ +struct xfs_delattr_context { +struct xfs_da_state *da_state; +struct xfs_da_state_blk *blk; +int flags; +enum xfs_delattr_state dela_state; +}; + +/* * Structure to ease passing around component names. */ typedef struct xfs_da_args { + struct xfs_delattr_context dac; /* context used for delay attr ops */ struct xfs_da_geometry *geo; /* da block geometry */ struct xfs_name name; /* name, length and argument flags*/ uint8_t filetype; /* filetype of inode for directories */
Signature · 1 line
2.7.4
PATCH v6 17/17 xfsprogs: Add delay ready attr set routines
In reply to Allison CollinsThis patch modifies the attr set routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_set_args has become xfs_attr_set_iter, which uses a state machine like switch to keep track of where it was when EAGAIN was returned.
Part of xfs_attr_leaf_addname has been factored out into a new helper function xfs_attr_leaf_try_add to allow transaction cycling between the two routines.
Two new helper functions have been added: xfs_attr_rmtval_set_init and xfs_attr_rmtval_set_blk. They provide a subset of logic similar to xfs_attr_rmtval_set, but they store the current block in the delay attr context to allow the caller to roll the transaction between allocations. This helps to simplify and consolidate code used by xfs_attr_leaf_addname and xfs_attr_node_addname
Finally, xfs_attr_set_args has become a simple loop to refresh the transaction until the operation is completed.
--- libxfs/xfs_attr.c | 347 +++++++++++++++++++++++++++++------------------ libxfs/xfs_attr.h | 1 + libxfs/xfs_attr_remote.c | 67 ++++++++- libxfs/xfs_attr_remote.h | 4 + libxfs/xfs_da_btree.h | 13 ++ 5 files changed, 301 insertions(+), 131 deletions(-)
libxfs/xfs_attr.c +218 -129
@@ -57,6 +57,7 @@ STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp);STATIC int
@@ -258,9 +259,86 @@ intxfs_attr_set_args ( struct xfs_da_args *args) { +int error =0 ; +int err2 =0 ; +struct xfs_buf *leaf_bp =NULL ; + +do { + error =xfs_attr_set_iter (args, &leaf_bp); +if (error && error != -EAGAIN ) + goto out; + +if (args->dac.flags &XFS_DAC_FINISH_TRANS ) { + args->dac.flags &= ~XFS_DAC_FINISH_TRANS ; + + err2 =xfs_defer_finish (&args->trans); +if (err2) { + error = err2; + goto out; + } + } + + err2 =xfs_trans_roll_inode (&args->trans, args->dp); +if (err2) { + error = err2; + goto out; + } + +if (leaf_bp) { +xfs_trans_bjoin (args->trans, leaf_bp); +xfs_trans_bhold (args->trans, leaf_bp); + } + + }while (error == -EAGAIN ); + +out: +return error; +} + +/* +* Set the attribute specified in @args. +* This routine is meant to function as a delayed operation, and may return +* -EAGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +* returned. +*/ +int +xfs_attr_set_iter ( +struct xfs_da_args *args, +struct xfs_buf **leaf_bp) +{struct xfs_inode *dp = args->dp; -struct xfs_buf *leaf_bp =NULL ; -int error, error2 =0 ; +int error =0 ; +int sf_size; + +/* State machine switch */ +switch (args->dac.dela_state) { +case XFS_DAS_SF_TO_LEAF : + goto sf_to_leaf; +case XFS_DAS_ALLOC_LEAF : +case XFS_DAS_FLIP_LFLAG : +case XFS_DAS_FOUND_LBLK : + goto leaf; +case XFS_DAS_FOUND_NBLK : +case XFS_DAS_FLIP_NFLAG : +case XFS_DAS_ALLOC_NODE : +case XFS_DAS_LEAF_TO_NODE : + goto node; +default : +break ; + } + +/* +* New inodes may not have an attribute fork yet. So set the attribute +* fork appropriately +*/ +if (XFS_IFORK_Q ((args->dp)) ==0 ) { + sf_size =sizeof (struct xfs_attr_sf_hdr ) + +XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen); +xfs_bmap_set_attrforkoff (args->dp, sf_size,NULL ); + args->dp->i_afp =kmem_zone_zalloc (xfs_ifork_zone,0 ); + args->dp->i_afp->if_flags =XFS_IFEXTENTS ; + }/* * If the attribute list is non-existent or a shortform list, proceed to
@@ -271,22 +349,20 @@ xfs_attr_set_args( (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && dp->i_d.di_anextents == 0))) goto sf_to_leaf; -/* * Try to add the attr to the attribute list in the inode. */ error =xfs_attr_try_sf_addname (dp, args); -if (error != -ENOSPC ) { - error2 =xfs_trans_commit (args->trans); - args->trans =NULL ; -return error ? error : error2; - } + +/* Should only be 0, -EEXIST or ENOSPC */ +if (error != -ENOSPC ) +return error;/* * It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ - error =xfs_attr_shortform_to_leaf (args, &leaf_bp); + error =xfs_attr_shortform_to_leaf (args, leaf_bp);if (error)return error;
@@ -294,42 +370,47 @@ xfs_attr_set_args(* Prevent the leaf buffer from being unlocked so that a * concurrent AIL push cannot grab the half-baked leaf * buffer and run into problems with the write verifier. -* Once we're done rolling the transaction we can release -* the hold and add the attr to the leaf. */ -xfs_trans_bhold (args->trans, leaf_bp); - error =xfs_defer_finish (&args->trans); -xfs_trans_bhold_release (args->trans, leaf_bp); -if (error) { -xfs_trans_brelse (args->trans, leaf_bp); -return error; - } +xfs_trans_bhold (args->trans, *leaf_bp); + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + args->dac.dela_state =XFS_DAS_SF_TO_LEAF ; +return -EAGAIN ; sf_to_leaf: -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { - error =xfs_attr_leaf_addname (args); -if (error != -ENOSPC ) -return error; - -/* -* Commit that transaction so that the node_addname() -* call can manage its own transactions. -*/ - error =xfs_defer_finish (&args->trans); -if (error) -return error; +/* +* After a shortform to leaf conversion, we need to hold the leaf and +* cylce out the transaction. When we get back, we need to release +* the leaf. +*/ +if (*leaf_bp !=NULL ) { +xfs_trans_brelse (args->trans, *leaf_bp); + *leaf_bp =NULL ; + } -/* -* Commit the current trans (including the inode) and -* start a new one. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) +if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { + error =xfs_attr_leaf_try_add (args, *leaf_bp); +switch (error) { +case -ENOSPC : + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + args->dac.dela_state =XFS_DAS_LEAF_TO_NODE ; +return -EAGAIN ; +case 0 : + args->dac.dela_state =XFS_DAS_FOUND_LBLK ; +return -EAGAIN ; +default :return error; - + } +leaf: + error =xfs_attr_leaf_addname (args); +if (error == -ENOSPC ) { + args->dac.dela_state =XFS_DAS_LEAF_TO_NODE ; +return -EAGAIN ; + } +return error; } - + args->dac.dela_state =XFS_DAS_LEAF_TO_NODE ; +node: error =xfs_attr_node_addname (args);return error; }
@@ -758,27 +839,28 @@ xfs_attr_leaf_try_add(* * This leaf block cannot have a "remote" value, we only call this routine * if bmap_one_block() says there is only one block (ie: no remote blks). +* +* This routine is meant to function as a delayed operation, and may return +* -EAGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +* returned. */ STATIC intxfs_attr_leaf_addname (struct xfs_da_args *args) { -int error, forkoff;struct xfs_buf *bp =NULL ; +int error, forkoff;struct xfs_inode *dp = args->dp; -trace_xfs_attr_leaf_addname (args); - - error =xfs_attr_leaf_try_add (args, bp); -if (error) -return error; - -/* -* Commit the transaction that added the attr name so that -* later routines can manage their own transactions. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) -return error; +/* State machine switch */ +switch (args->dac.dela_state) { +case XFS_DAS_FLIP_LFLAG : + goto flip_flag; +case XFS_DAS_ALLOC_LEAF : + goto alloc_leaf; +default : +break ; + }/* * If there was an out-of-line value, allocate the blocks we
@@ -787,7 +869,28 @@ xfs_attr_leaf_addname(struct xfs_da_args *args)* maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno >0 ) { - error =xfs_attr_rmtval_set (args); + +/* Open coded xfs_attr_rmtval_set without trans handling */ + error =xfs_attr_rmtval_set_init (args); +if (error) +return error; + +/* +* Roll through the "value", allocating blocks on disk as +* required. +*/ +alloc_leaf: +while (args->dac.blkcnt >0 ) { + error =xfs_attr_rmtval_set_blk (args); +if (error) +return error; + + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + args->dac.dela_state =XFS_DAS_ALLOC_LEAF ; +return -EAGAIN ; + } + + error =xfs_attr_rmtval_set_value (args);if (error)return error; }
@@ -806,13 +909,10 @@ xfs_attr_leaf_addname(struct xfs_da_args *args) error =xfs_attr3_leaf_flipflags (args);if (error)return error; -/* -* Commit the flag value change and start the next trans in -* series. -*/ - error =xfs_trans_roll_inode (&args->trans, args->dp); -if (error) -return error; + + args->dac.dela_state =XFS_DAS_FLIP_LFLAG ; +return -EAGAIN ; +flip_flag:/* * Dismantle the "old" attribute/value pair by removing
@@ -843,34 +943,17 @@ xfs_attr_leaf_addname(struct xfs_da_args *args)/* * If the result is small enough, shrink it all into the inode. */ -if ((forkoff =xfs_attr_shortform_allfit (bp, dp))) { + forkoff =xfs_attr_shortform_allfit (bp, dp); +if (forkoff) error =xfs_attr3_leaf_to_shortform (bp, args, forkoff); -/* bp is gone due to xfs_da_shrink_inode */ -if (error) -return error; - error =xfs_defer_finish (&args->trans); -if (error) -return error; - } -/* -* Commit the remove and start the next trans in series. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); + args->dac.flags |=XFS_DAC_FINISH_TRANS ; }else if (args->rmtblkno >0 ) {/* * Added a "remote" value, just clear the incomplete flag. */ error =xfs_attr3_leaf_clearflag (args); -if (error) -return error; - -/* -* Commit the flag value change and start the next trans in -* series. -*/ - error =xfs_trans_roll_inode (&args->trans, args->dp); }return error; }
@@ -1019,16 +1102,22 @@ xfs_attr_node_hasname(* * "Remote" attribute values confuse the issue and atomic rename operations * add a whole extra layer of confusion on top of that. +* +* This routine is meant to function as a delayed operation, and may return +* -EAGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +*returned. */ STATIC intxfs_attr_node_addname (struct xfs_da_args *args) { -struct xfs_da_state *state; +struct xfs_da_state *state =NULL ;struct xfs_da_state_blk *blk;struct xfs_inode *dp;struct xfs_mount *mp; -int retval, error; +int retval =0 ; +int error =0 ;trace_xfs_attr_node_addname (args);
@@ -1037,7 +1126,19 @@ xfs_attr_node_addname(*/ dp = args->dp; mp = dp->i_mount; -restart: + +/* State machine switch */ +switch (args->dac.dela_state) { +case XFS_DAS_FLIP_NFLAG : + goto flip_flag; +case XFS_DAS_FOUND_NBLK : + goto found_nblk; +case XFS_DAS_ALLOC_NODE : + goto alloc_node; +default : +break ; + } +/* * Search to see if name already exists, and get back a pointer * to where it should go.
@@ -1087,19 +1188,13 @@ restart: error =xfs_attr3_leaf_to_node (args);if (error) goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out;/* -* Commit the node conversion and start the next -* trans in the chain. +* Restart routine from the top. No need to set the +* state */ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) - goto out; - - goto restart; + args->dac.flags |=XFS_DAC_FINISH_TRANS ; +return -EAGAIN ; }/*
@@ -1111,9 +1206,7 @@ restart: error =xfs_da3_split (state);if (error) goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out; + args->dac.flags |=XFS_DAC_FINISH_TRANS ; }else {/* * Addition succeeded, update Btree hashvals.
@@ -1128,13 +1221,9 @@ restart:xfs_da_state_free (state); state =NULL ; -/* -* Commit the leaf addition or btree split and start the next -* trans in the chain. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) - goto out; + args->dac.dela_state =XFS_DAS_FOUND_NBLK ; +return -EAGAIN ; +found_nblk:/* * If there was an out-of-line value, allocate the blocks we
@@ -1143,7 +1232,27 @@ restart:* maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno >0 ) { - error =xfs_attr_rmtval_set (args); +/* Open coded xfs_attr_rmtval_set without trans handling */ + error =xfs_attr_rmtval_set_init (args); +if (error) +return error; + +/* +* Roll through the "value", allocating blocks on disk as +* required. +*/ +alloc_node: +while (args->dac.blkcnt >0 ) { + error =xfs_attr_rmtval_set_blk (args); +if (error) +return error; + + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + args->dac.dela_state =XFS_DAS_ALLOC_NODE ; +return -EAGAIN ; + } + + error =xfs_attr_rmtval_set_value (args);if (error)return error; }
@@ -1166,10 +1275,9 @@ restart:* Commit the flag value change and start the next trans in * series */ - error =xfs_trans_roll_inode (&args->trans, args->dp); -if (error) - goto out; - + args->dac.dela_state =XFS_DAS_FLIP_NFLAG ; +return -EAGAIN ; +flip_flag:/* * Dismantle the "old" attribute/value pair by removing * a "remote" value (if it exists).
@@ -1198,7 +1306,6 @@ restart: error =xfs_da3_node_lookup_int (state, &retval);if (error) goto out; -/* * Remove the name and update the hashvals in the tree. */
@@ -1206,7 +1313,6 @@ restart:ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); error =xfs_attr3_leaf_remove (blk->bp, args);xfs_da3_fixhashpath (state, &state->path); -/* * Check to see if the tree needs to be collapsed. */
@@ -1214,18 +1320,9 @@ restart: error =xfs_da3_join (state);if (error) goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out; - } - -/* -* Commit and start the next trans in the chain. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) - goto out; + args->dac.flags |=XFS_DAC_FINISH_TRANS ; + } }else if (args->rmtblkno >0 ) {/* * Added a "remote" value, just clear the incomplete flag.
@@ -1233,14 +1330,6 @@ restart: error =xfs_attr3_leaf_clearflag (args);if (error) goto out; - -/* -* Commit the flag value change and start the next trans in -* series. -*/ - error =xfs_trans_roll_inode (&args->trans, args->dp); -if (error) - goto out; } retval = error =0 ;
libxfs/xfs_attr.h +1 -0
@@ -149,6 +149,7 @@ int xfs_attr_get(struct xfs_inode *ip, struct xfs_name *name,int xfs_attr_set (struct xfs_inode *dp,struct xfs_name *name,unsigned char *value,int valuelen,int flags);int xfs_attr_set_args (struct xfs_da_args *args); +int xfs_attr_set_iter (struct xfs_da_args *args,struct xfs_buf **leaf_bp);int xfs_attr_remove (struct xfs_inode *dp,struct xfs_name *name,int flags);int xfs_has_attr (struct xfs_da_args *args);int xfs_attr_remove_args (struct xfs_da_args *args);
libxfs/xfs_attr_remote.c +65 -2
85 lines not on this page · raw message
libxfs/xfs_attr_remote.h +4 -0
@@ -13,4 +13,8 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args);int xfs_attr_rmtval_invalidate (struct xfs_da_args *args);int xfs_attr_rmtval_unmap (struct xfs_da_args *args); +int xfs_attr_rmt_find_hole (struct xfs_da_args *args); +int xfs_attr_rmtval_set_value (struct xfs_da_args *args); +int xfs_attr_rmtval_set_blk (struct xfs_da_args *args); +int xfs_attr_rmtval_set_init (struct xfs_da_args *args);#endif /* __XFS_ATTR_REMOTE_H__ */
libxfs/xfs_da_btree.h +13 -0
@@ -48,6 +48,14 @@ enum xfs_dacmp {enum xfs_delattr_state {XFS_DAS_RM_SHRINK =1 ,/* We are shrinking the tree */ XFS_DAS_RM_NODE_BLKS =2 ,/* We are removing node blocks */ +XFS_DAS_SF_TO_LEAF =3 ,/* Converted short form to leaf */ +XFS_DAS_FOUND_LBLK =4 ,/* We found leaf blk for attr */ +XFS_DAS_LEAF_TO_NODE =5 ,/* Converted leaf to node */ +XFS_DAS_FOUND_NBLK =6 ,/* We found node blk for attr */ +XFS_DAS_ALLOC_LEAF =7 ,/* We are allocating leaf blocks */ +XFS_DAS_FLIP_LFLAG =8 ,/* Flipped leaf INCOMPLETE attr flag */ +XFS_DAS_ALLOC_NODE =9 ,/* We are allocating node blocks */ +XFS_DAS_FLIP_NFLAG =10 ,/* Flipped node INCOMPLETE attr flag */ };/*
@@ -59,8 +67,13 @@ enum xfs_delattr_state {* Context used for keeping track of delayed attribute operations */ struct xfs_delattr_context { +struct xfs_bmbt_irec map; +struct xfs_buf *leaf_bp; +xfs_fileoff_t lfileoff;struct xfs_da_state *da_state;struct xfs_da_state_blk *blk; +xfs_dablk_t lblkno; +int blkcnt;int flags;enum xfs_delattr_state dela_state; };
Signature · 1 line
2.7.4