xfs: Delayed Ready Attrs
v7 cover xfs: Delayed Ready Attrs
Hi all,
This set is a subset of a larger series for delayed attributes. Which is a subset of an even larger series, parent pointers. Delayed attributes allow attribute operations (set and remove) to be logged and committed in the same way that other delayed operations do. This allows more complex operations (like parent pointers) to be broken up into multiple smaller transactions. To do this, the existing attr operations must be modified to operate as either a delayed operation or a inline operation since older filesystems will not be able to use the new log entries. This means that they cannot roll, commit, or finish transactions. Instead, they return EAGAIN an allow the calling function to handle the transaction. In this series, we focus on only the clean up and refactoring needed to accomplish this. We will introduce delayed attrs and parent pointers in a later set.
At the moment, I would like people to focus their review efforts on just this "delay ready" subseries, as I think that is a more conservative use of peoples review time. I also think the set is a bit much to manage all at once, and we need to get the infrastructure ironed out before we focus too much anything that depends on it. But I do have the extended series for folks that want to see the bigger picture of where this is going.
This series can be viewed on github here:
https://github.com/allisonhenderson/xfs_work/tree/delay_ready_attrs_v7
As well as the extended delayed attribute and parent pointer series:
https://github.com/allisonhenderson/xfs_work/tree/delay_ready_attrs_v7_extended
And the test cases:
https://github.com/allisonhenderson/xfs_work/tree/pptr_xfstests
To run the xfs attributes tests run:
check -g attr
To run as delayed attributes run:
export MKFS_OPTIONS="-n delattr"
check -g attr
To run parent pointer tests:
check -g parent
Changes since v6:
Mostly review just updates. In the last review folks asked for a diagram to make the code flow more visual. They have been added in patches 13 and 14. At the moment, they're in the commit message. I figure people can decide where or if they want them somewhere in the code later, since they are a bit lengthy. Patch 15 is a helper function that used to be part of 14 but I separated it to better organize things. Patches 18 and 19 are new, and are just cleanups that I thought would be helpful.
I've also gone through the set and rearranged the order of some of the patches to make sort of mini sets. I thought it would help reviewers break down the reviewing some. For reviewing purposes, the set could be broken up into 5 different phases:
Clean ups (patches 1-2):
These two patches were actually review suggestions made quiet some time ago in regaurds to commit d29f781 (Remove all strlen ...), which has since been merged. The idea of the cleanups was to collapse down the number of parameters getting passed around the xfs_attr_* routines. It has since drawn both commentary and critisim, so it's a little unclear to me if people want it or not. It could easily be taken as a stand alone clean up. But it's also not a neccassary must have in so far as the delayed operations are concerned. It does however pepper around a lot of change activity up through the set. So it would be helpfull to get a verdict one way or another, depending on how people feel about it.
xfs: Replace attribute parameters with struct xfs_name
xfs: Embed struct xfs_name in xfs_da_args
Error code filtering (patches 3-4):
These two patches are all about finding and catching error codes that need to be sent back up to user space before starting delayed operations. Errors that happen during a delayed operation are treated like interal errors that cause a shutdown. But we wouldnt want that for example: when the user tries to rename a non existent attr. So the idea is that we need to find all such conditions, and take care of them before starting a delayed operation.
xfs: Add xfs_has_attr and subroutines
xfs: Check for -ENOATTR or -EEXIST
Move transactions upwards (patches 5-12):
The goal of this subset is to try and move all the transaction specific code up the call stack much as possible. The idea being that once we get them to the top, we can introduce the statemachine to handle the -EAGAIN logic where ever the transactions used to be.
xfs: Factor out new helper functions xfs_attr_rmtval_set
xfs: Factor out trans handling in xfs_attr3_leaf_flipflags
xfs: Factor out xfs_attr_leaf_addname helper
xfs: Refactor xfs_attr_try_sf_addname
xfs: Factor out trans roll from xfs_attr3_leaf_setflag
xfs: Factor out xfs_attr_rmtval_invalidate
xfs: Factor out trans roll in xfs_attr3_leaf_clearflag
xfs: Add helper function xfs_attr_rmtval_unmap
Introduce statemachine (patches 13-14):
Now that we have re-arranged the code such that we can remove the transaction handleing, we proceed to do so. The behavior of the attr set/remove routines are now also compatible as a .finish_item callback
xfs: Add delay ready attr remove routines
xfs: Add delay ready attr set routines
Modularizing and cleanups (patches 15-19):
Now that we have pulled the transactions up to where we need them, it's time to start breaking down the top level functions into new subfunctions. The goal being to work towards a top level function that deals mostly with the statemachine, and helpers for those states
xfs: Add helper function xfs_attr_node_shrink
xfs: Simplify xfs_attr_set_iter
xfs: Add helper function xfs_attr_leaf_mark_incomplete
xfs: Add remote block helper functions
xfs: Remove xfs_attr_rmtval_remove
I've also made the corresponding updates to the user space side as well.
Questions, comment and feedback appreciated!
Thanks all!
Allison
Allison Collins (18):
xfs: Replace attribute parameters with struct xfs_name
xfs: Embed struct xfs_name in xfs_da_args
xfs: Check for -ENOATTR or -EEXIST
xfs: Factor out new helper functions xfs_attr_rmtval_set
xfs: Factor out trans handling in xfs_attr3_leaf_flipflags
xfs: Factor out xfs_attr_leaf_addname helper
xfs: Refactor xfs_attr_try_sf_addname
xfs: Factor out trans roll from xfs_attr3_leaf_setflag
xfs: Factor out xfs_attr_rmtval_invalidate
xfs: Factor out trans roll in xfs_attr3_leaf_clearflag
xfs: Add helper function xfs_attr_rmtval_unmap
xfs: Add delay ready attr remove routines
xfs: Add delay ready attr set routines
xfs: Add helper function xfs_attr_node_shrink
xfs: Simplify xfs_attr_set_iter
xfs: Add helper function xfs_attr_leaf_mark_incomplete
xfs: Add remote block helper functions
xfs: Remove xfs_attr_rmtval_remove
Allison Henderson (1):
xfs: Add xfs_has_attr and subroutines
fs/xfs/libxfs/xfs_attr.c | 947 ++++++++++++++++++++++++++++------------ fs/xfs/libxfs/xfs_attr.h | 15 +- fs/xfs/libxfs/xfs_attr_leaf.c | 220 +++++----- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + fs/xfs/libxfs/xfs_attr_remote.c | 260 +++++++---- fs/xfs/libxfs/xfs_attr_remote.h | 7 +- fs/xfs/libxfs/xfs_da_btree.c | 6 +- fs/xfs/libxfs/xfs_da_btree.h | 47 +- fs/xfs/libxfs/xfs_dir2.c | 18 +- fs/xfs/libxfs/xfs_dir2_block.c | 6 +- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +- fs/xfs/libxfs/xfs_dir2_node.c | 8 +- fs/xfs/libxfs/xfs_dir2_sf.c | 30 +- fs/xfs/libxfs/xfs_types.c | 11 + fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/scrub/attr.c | 12 +- fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_acl.c | 27 +- fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl.c | 25 +- fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 8 +- fs/xfs/xfs_trace.h | 21 +- fs/xfs/xfs_xattr.c | 29 +- 24 files changed, 1140 insertions(+), 572 deletions(-)
Signature · 1 line
2.7.4
PATCH v7 1/19 xfs: Replace attribute parameters with struct xfs_name
This 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.
--- fs/xfs/libxfs/xfs_attr.c | 22 +++++++++------------- fs/xfs/libxfs/xfs_attr.h | 12 +++++------- fs/xfs/libxfs/xfs_types.c | 11 +++++++++++ fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/xfs_acl.c | 25 +++++++++++-------------- fs/xfs/xfs_ioctl.c | 23 +++++++++++++---------- fs/xfs/xfs_iops.c | 6 +++--- fs/xfs/xfs_xattr.c | 28 ++++++++++++++++------------ 8 files changed, 69 insertions(+), 59 deletions(-)
fs/xfs/libxfs/xfs_attr.c +9 -13
@@ -61,8 +61,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) {
@@ -74,8 +73,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 */
@@ -139,8 +138,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)
@@ -156,7 +154,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;
@@ -339,8 +337,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)
@@ -356,7 +353,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;
@@ -444,8 +441,7 @@ xfs_attr_set(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;
@@ -457,7 +453,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;
fs/xfs/libxfs/xfs_attr.h +5 -7
@@ -147,14 +147,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);
fs/xfs/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(
fs/xfs/libxfs/xfs_types.h +1 -0
@@ -180,6 +180,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);
fs/xfs/xfs_acl.c +11 -14
@@ -123,7 +123,7 @@ xfs_get_acl(struct inode *inode, int type)struct xfs_inode *ip =XFS_I (inode);struct posix_acl *acl =NULL ;struct xfs_acl *xfs_acl =NULL ; -unsigned char *ea_name; +struct xfs_name name;int error;int len;
@@ -131,10 +131,10 @@ xfs_get_acl(struct inode *inode, int type)switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT : - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :BUG ();
@@ -145,9 +145,8 @@ xfs_get_acl(struct inode *inode, int type)* go out to the disk. */ len =XFS_ACL_MAX_SIZE (ip->i_mount); - error =xfs_attr_get (ip, ea_name,strlen (ea_name), - (unsigned char **)&xfs_acl, &len, -ATTR_ALLOC |ATTR_ROOT ); + error =xfs_attr_get (ip, &name, (unsigned char **)&xfs_acl, &len, +ATTR_ALLOC |ATTR_ROOT );if (error) {/* * If the attribute doesn't exist make sure we have a negative
@@ -167,17 +166,17 @@ int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) { struct xfs_inode *ip = XFS_I(inode); -unsigned char *ea_name; +struct xfs_name name;int error;switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT :if (!S_ISDIR (inode->i_mode))return acl ? -EACCES :0 ; - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :return -EINVAL ;
@@ -197,17 +196,15 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) len -=sizeof (struct xfs_acl_entry ) * (XFS_ACL_MAX_ENTRIES (ip->i_mount) - acl->a_count); - error =xfs_attr_set (ip, ea_name,strlen (ea_name), - (unsigned char *)xfs_acl, len,ATTR_ROOT ); + error =xfs_attr_set (ip, &name, (unsigned char *)xfs_acl, len, +ATTR_ROOT );kmem_free (xfs_acl); }else {/* * A NULL ACL argument means we want to remove the ACL. */ - error =xfs_attr_remove (ip, ea_name, -strlen (ea_name), -ATTR_ROOT ); + error =xfs_attr_remove (ip, &name,ATTR_ROOT );/* * If the attribute didn't exist to start with that's fine.
fs/xfs/xfs_ioctl.c +13 -10
@@ -357,7 +357,9 @@ xfs_attrmulti_attr_get( {unsigned char *kbuf;int error = -EFAULT ; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (*len >XFS_XATTR_SIZE_MAX )return -EINVAL ;
@@ -365,9 +367,7 @@ xfs_attrmulti_attr_get(if (!kbuf)return -ENOMEM ; - namelen =strlen (name); - error =xfs_attr_get (XFS_I (inode), name, namelen, &kbuf, (int *)len, - flags); + error =xfs_attr_get (XFS_I (inode), &xname, &kbuf, (int *)len, flags);if (error) goto out_kfree;
@@ -389,7 +389,9 @@ xfs_attrmulti_attr_set( {unsigned char *kbuf;int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;
@@ -400,8 +402,7 @@ xfs_attrmulti_attr_set(if (IS_ERR (kbuf))return PTR_ERR (kbuf); - namelen =strlen (name); - error =xfs_attr_set (XFS_I (inode), name, namelen, kbuf, len, flags); + error =xfs_attr_set (XFS_I (inode), &xname, kbuf, len, flags);if (!error)xfs_forget_acl (inode, name, flags);kfree (kbuf);
@@ -415,12 +416,14 @@ xfs_attrmulti_attr_remove( uint32_t flags) {int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ; - namelen =strlen (name); - error =xfs_attr_remove (XFS_I (inode), name, namelen, flags); + + error =xfs_attr_remove (XFS_I (inode), &xname, flags);if (!error)xfs_forget_acl (inode, name, flags);return error;
fs/xfs/xfs_iops.c +3 -3
@@ -48,11 +48,11 @@ xfs_initxattrs(const struct xattr *xattr;struct xfs_inode *ip =XFS_I (inode);int error =0 ; +struct xfs_name name;for (xattr = xattr_array; xattr->name !=NULL ; xattr++) { - error =xfs_attr_set (ip, xattr->name, -strlen (xattr->name), - xattr->value, xattr->value_len, +xfs_name_init (&name, xattr->name); + error =xfs_attr_set (ip, &name, xattr->value, xattr->value_len,ATTR_SECURE );if (error <0 )break ;
fs/xfs/xfs_xattr.c +16 -12
@@ -21,10 +21,12 @@ static int xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *value, size_t size) { - int xflags = handler->flags; -struct xfs_inode *ip =XFS_I (inode); -int error, asize = size; -size_t namelen =strlen (name); + int xflags = handler->flags; +struct xfs_inode *ip =XFS_I (inode); +int error, asize = size; +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (!size) {
@@ -32,8 +34,8 @@ xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, value =NULL ; } - error =xfs_attr_get (ip, name, namelen, (unsigned char **)&value, - &asize, xflags); + error =xfs_attr_get (ip, &xname, (unsigned char **)&value, &asize, + xflags);if (error)return error;return asize;
@@ -69,7 +71,9 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,int xflags = handler->flags;struct xfs_inode *ip =XFS_I (inode);int error; -size_t namelen =strlen (name); +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (flags &XATTR_CREATE )
@@ -77,11 +81,11 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,if (flags &XATTR_REPLACE ) xflags |=ATTR_REPLACE ; -if (value) - error =xfs_attr_set (ip, name, namelen, (void *)value, size, - xflags); -else - error =xfs_attr_remove (ip, name, namelen, xflags); +if (value) + error =xfs_attr_set (ip, &xname, (void *)value, size, xflags); +else + error =xfs_attr_remove (ip, &xname, xflags); +if (!error)xfs_forget_acl (inode, name, xflags);
Signature · 1 line
2.7.4
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
Quoted 7 lines · Allison Collins
This patch replaces the attribute name and length parameters with a single struct
xfs_nameparameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.Signed-off-by Allison Collins <[email protected]>---
I realize I am joining very late with lots of reviewed-by already applied, so unless I find anything big, please regard my comments and possible future improvements for the extended series rather than objections to this pretty much baked patch set.
[...]
Quoted 55 lines
fs/xfs/xfs_ioctl.c +11
-8@@ -357,7 +357,9 @@ xfs_attrmulti_attr_get( {unsigned char *kbuf;int error = -EFAULT ; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (*len >XFS_XATTR_SIZE_MAX )return -EINVAL ;@@ -365,9 +367,7 @@ xfs_attrmulti_attr_get(if (!kbuf)return -ENOMEM ; - namelen =strlen (name); - error =xfs_attr_get (XFS_I (inode), name, namelen, &kbuf, (int *)len, - flags); + error =xfs_attr_get (XFS_I (inode), &xname, &kbuf, (int *)len, flags);if (error) goto out_kfree;@@ -389,7 +389,9 @@ xfs_attrmulti_attr_set( {unsigned char *kbuf;int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;@@ -400,8 +402,7 @@ xfs_attrmulti_attr_set(if (IS_ERR (kbuf))return PTR_ERR (kbuf); - namelen =strlen (name); - error =xfs_attr_set (XFS_I (inode), name, namelen, kbuf, len, flags); + error =xfs_attr_set (XFS_I (inode), &xname, kbuf, len, flags);if (!error)xfs_forget_acl (inode, name, flags);kfree (kbuf);@@ -415,12 +416,14 @@ xfs_attrmulti_attr_remove( uint32_t flags) {int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);
fs/xfs/xfs_ioctl.c xfs_attrmulti_attr_remove( · line 429
Quoted 10 lines
fs/xfs/xfs_ioctl.c +2
-2if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ; - namelen =strlen (name); - error =xfs_attr_remove (XFS_I (inode), name, namelen, flags); + + error =xfs_attr_remove (XFS_I (inode), &xname, flags);if (!error)xfs_forget_acl (inode, name, flags);return error;
A struct inititializer macro would have been nice, so code like this:
+ struct xfs_name xname;
+
+ xfs_name_init(&xname, name);
Would become:
+ struct xfs_name xname = XFS_NAME_STR_INIT(name);
As a matter of fact, in most of the cases a named local variable is not needed at
all and the code could be written with an anonymous local struct variable macro:
+ error = xfs_attr_remove(XFS_I(inode), XFS_NAME_STR(name), flags);
Thanks,
Amir.
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
Quoted 7 lines · Amir Goldstein
Quoted 5 lines · Allison Collins
This patch replaces the attribute name and length parameters with a single struct
xfs_nameparameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Allison Collins <[email protected]>---
I realize I am joining very late with lots of reviewed-by already applied, so unless I find anything big, please regard my comments and possible future improvements for the extended series rather than objections to this pretty much baked patch set.
Sure, no worries, it has a lot of history to keep track of.
Quoted 76 lines
[...]
Quoted 55 lines
fs/xfs/xfs_ioctl.c +11
-8@@ -357,7 +357,9 @@ xfs_attrmulti_attr_get( {unsigned char *kbuf;int error = -EFAULT ; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (*len >XFS_XATTR_SIZE_MAX )return -EINVAL ;@@ -365,9 +367,7 @@ xfs_attrmulti_attr_get(if (!kbuf)return -ENOMEM ; - namelen =strlen (name); - error =xfs_attr_get (XFS_I (inode), name, namelen, &kbuf, (int *)len, - flags); + error =xfs_attr_get (XFS_I (inode), &xname, &kbuf, (int *)len, flags);if (error) goto out_kfree;@@ -389,7 +389,9 @@ xfs_attrmulti_attr_set( {unsigned char *kbuf;int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;@@ -400,8 +402,7 @@ xfs_attrmulti_attr_set(if (IS_ERR (kbuf))return PTR_ERR (kbuf); - namelen =strlen (name); - error =xfs_attr_set (XFS_I (inode), name, namelen, kbuf, len, flags); + error =xfs_attr_set (XFS_I (inode), &xname, kbuf, len, flags);if (!error)xfs_forget_acl (inode, name, flags);kfree (kbuf);@@ -415,12 +416,14 @@ xfs_attrmulti_attr_remove( uint32_t flags) {int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);fs/xfs/xfs_ioctl.c xfs_attrmulti_attr_remove( · line 429
Quoted 10 lines
fs/xfs/xfs_ioctl.c +2
-2if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ; - namelen =strlen (name); - error =xfs_attr_remove (XFS_I (inode), name, namelen, flags); + + error =xfs_attr_remove (XFS_I (inode), &xname, flags);if (!error)xfs_forget_acl (inode, name, flags);return error;A struct inititializer macro would have been nice, so code like this:
fs/xfs/xfs_ioctl.c +3
-0+struct xfs_name xname; + +xfs_name_init (&xname, name);
Quoted 9 lines
Would become:
+ structxfs_namexname =XFS_NAME_STR_INIT(name);As a matter of fact, in most of the cases a named local variable is not needed at
all and the code could be written with an anonymous local struct variable macro:+ error =
xfs_attr_remove(XFS_I(inode), XFS_NAME_STR(name), flags);
The macro does look nice. I would be the third iteration of initializers that this patch has been through though. Can I get a consensus of how many people like the macro?
Allison
Quoted 3 lines
Thanks,
Amir.
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
Quoted 15 lines · Allison Collins
Quoted 14 lines · Amir Goldstein
On Sun, Feb 23, 2020 at 4:07 AM Allison Collins
A struct inititializer macro would have been nice, so code like this:fs/xfs/xfs_ioctl.c +3
-0+struct xfs_name xname; + +xfs_name_init (&xname, name);Would become:
+ structxfs_namexname =XFS_NAME_STR_INIT(name);As a matter of fact, in most of the cases a named local variable is not needed at
all and the code could be written with an anonymous local struct variable macro:
Quoted 5 lines
Quoted 2 lines
+ error =
xfs_attr_remove(XFS_I(inode), XFS_NAME_STR(name), flags);The macro does look nice. I would be the third iteration of initializers that this patch has been through though. Can I get a consensus of how many people like the macro?
Not me. All it means is that every time I look at this code I have to go look at what that shouty macro does, then have to understand it's being "smart and clever" to save a couple of lines of clear, obviously correct code.
That's not an improvement.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
In reply to Allison CollinsQuoted 4 lines · Allison Collins
This patch replaces the attribute name and length parameters with a single struct
xfs_nameparameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.
I don't see any logical errors.
Quoted 377 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 22 +++++++++------------- fs/xfs/libxfs/xfs_attr.h | 12 +++++------- fs/xfs/libxfs/xfs_types.c | 11 +++++++++++ fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/xfs_acl.c | 25 +++++++++++-------------- fs/xfs/xfs_ioctl.c | 23 +++++++++++++---------- fs/xfs/xfs_iops.c | 6 +++--- fs/xfs/xfs_xattr.c | 28 ++++++++++++++++------------ 8 files changed, 69 insertions(+), 59 deletions(-)fs/xfs/libxfs/xfs_attr.c +9
-13@@ -61,8 +61,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) {@@ -74,8 +73,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 */ @@ -139,8 +138,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)@@ -156,7 +154,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;@@ -339,8 +337,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)@@ -356,7 +353,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;@@ -444,8 +441,7 @@ xfs_attr_set(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;@@ -457,7 +453,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;fs/xfs/libxfs/xfs_attr.h +5
-7@@ -147,14 +147,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);fs/xfs/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(fs/xfs/libxfs/xfs_types.h +1
-0@@ -180,6 +180,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);fs/xfs/xfs_acl.c +11
-14@@ -123,7 +123,7 @@ xfs_get_acl(struct inode *inode, int type)struct xfs_inode *ip =XFS_I (inode);struct posix_acl *acl =NULL ;struct xfs_acl *xfs_acl =NULL ; -unsigned char *ea_name; +struct xfs_name name;int error;int len;@@ -131,10 +131,10 @@ xfs_get_acl(struct inode *inode, int type)switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT : - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :BUG ();@@ -145,9 +145,8 @@ xfs_get_acl(struct inode *inode, int type)* go out to the disk. */ len =XFS_ACL_MAX_SIZE (ip->i_mount); - error =xfs_attr_get (ip, ea_name,strlen (ea_name), - (unsigned char **)&xfs_acl, &len, -ATTR_ALLOC |ATTR_ROOT ); + error =xfs_attr_get (ip, &name, (unsigned char **)&xfs_acl, &len, +ATTR_ALLOC |ATTR_ROOT );if (error) {/* * If the attribute doesn't exist make sure we have a negative @@ -167,17 +166,17 @@ int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) { struct xfs_inode *ip = XFS_I(inode); -unsigned char *ea_name; +struct xfs_name name;int error;switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT :if (!S_ISDIR (inode->i_mode))return acl ? -EACCES :0 ; - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :return -EINVAL ;@@ -197,17 +196,15 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) len -=sizeof (struct xfs_acl_entry ) * (XFS_ACL_MAX_ENTRIES (ip->i_mount) - acl->a_count); - error =xfs_attr_set (ip, ea_name,strlen (ea_name), - (unsigned char *)xfs_acl, len,ATTR_ROOT ); + error =xfs_attr_set (ip, &name, (unsigned char *)xfs_acl, len, +ATTR_ROOT );kmem_free (xfs_acl); }else {/* * A NULL ACL argument means we want to remove the ACL. */ - error =xfs_attr_remove (ip, ea_name, -strlen (ea_name), -ATTR_ROOT ); + error =xfs_attr_remove (ip, &name,ATTR_ROOT );/* * If the attribute didn't exist to start with that's fine. fs/xfs/xfs_ioctl.c +13
-10@@ -357,7 +357,9 @@ xfs_attrmulti_attr_get( {unsigned char *kbuf;int error = -EFAULT ; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (*len >XFS_XATTR_SIZE_MAX )return -EINVAL ;@@ -365,9 +367,7 @@ xfs_attrmulti_attr_get(if (!kbuf)return -ENOMEM ; - namelen =strlen (name); - error =xfs_attr_get (XFS_I (inode), name, namelen, &kbuf, (int *)len, - flags); + error =xfs_attr_get (XFS_I (inode), &xname, &kbuf, (int *)len, flags);if (error) goto out_kfree;@@ -389,7 +389,9 @@ xfs_attrmulti_attr_set( {unsigned char *kbuf;int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;@@ -400,8 +402,7 @@ xfs_attrmulti_attr_set(if (IS_ERR (kbuf))return PTR_ERR (kbuf); - namelen =strlen (name); - error =xfs_attr_set (XFS_I (inode), name, namelen, kbuf, len, flags); + error =xfs_attr_set (XFS_I (inode), &xname, kbuf, len, flags);if (!error)xfs_forget_acl (inode, name, flags);kfree (kbuf);@@ -415,12 +416,14 @@ xfs_attrmulti_attr_remove( uint32_t flags) {int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ; - namelen =strlen (name); - error =xfs_attr_remove (XFS_I (inode), name, namelen, flags); + + error =xfs_attr_remove (XFS_I (inode), &xname, flags);if (!error)xfs_forget_acl (inode, name, flags);return error;fs/xfs/xfs_iops.c +3
-3@@ -48,11 +48,11 @@ xfs_initxattrs(const struct xattr *xattr;struct xfs_inode *ip =XFS_I (inode);int error =0 ; +struct xfs_name name;for (xattr = xattr_array; xattr->name !=NULL ; xattr++) { - error =xfs_attr_set (ip, xattr->name, -strlen (xattr->name), - xattr->value, xattr->value_len, +xfs_name_init (&name, xattr->name); + error =xfs_attr_set (ip, &name, xattr->value, xattr->value_len,ATTR_SECURE );if (error <0 )break ;fs/xfs/xfs_xattr.c +16
-12@@ -21,10 +21,12 @@ static int xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *value, size_t size) { - int xflags = handler->flags; -struct xfs_inode *ip =XFS_I (inode); -int error, asize = size; -size_t namelen =strlen (name); + int xflags = handler->flags; +struct xfs_inode *ip =XFS_I (inode); +int error, asize = size; +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (!size) {@@ -32,8 +34,8 @@ xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, value =NULL ; } - error =xfs_attr_get (ip, name, namelen, (unsigned char **)&value, - &asize, xflags); + error =xfs_attr_get (ip, &xname, (unsigned char **)&value, &asize, + xflags);if (error)return error;return asize;@@ -69,7 +71,9 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,int xflags = handler->flags;struct xfs_inode *ip =XFS_I (inode);int error; -size_t namelen =strlen (name); +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (flags &XATTR_CREATE )@@ -77,11 +81,11 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,if (flags &XATTR_REPLACE ) xflags |=ATTR_REPLACE ; -if (value) - error =xfs_attr_set (ip, name, namelen, (void *)value, size, - xflags); -else - error =xfs_attr_remove (ip, name, namelen, xflags); +if (value) + error =xfs_attr_set (ip, &xname, (void *)value, size, xflags); +else + error =xfs_attr_remove (ip, &xname, xflags); +if (!error)xfs_forget_acl (inode, name, xflags);
Signature · 1 line
chandan
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
Quoted 9 lines · Chandan Rajendra
Quoted 4 lines · Allison Collins
This patch replaces the attribute name and length parameters with a single struct
xfs_nameparameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.I don't see any logical errors.
Reviewed-by Chandan Rajendra <[email protected]>
Alrighty, thank you!
Allison
Quoted 13 lines
Quoted 13 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 22 +++++++++------------- fs/xfs/libxfs/xfs_attr.h | 12 +++++------- fs/xfs/libxfs/xfs_types.c | 11 +++++++++++ fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/xfs_acl.c | 25 +++++++++++-------------- fs/xfs/xfs_ioctl.c | 23 +++++++++++++---------- fs/xfs/xfs_iops.c | 6 +++--- fs/xfs/xfs_xattr.c | 28 ++++++++++++++++------------ 8 files changed, 69 insertions(+), 59 deletions(-)
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
In reply to Allison CollinsQuoted 6 lines · Allison Collins
This patch replaces the attribute name and length parameters with a single struct
xfs_nameparameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.Signed-off-by Allison Collins <[email protected]>---
Looks fine to me:
Quoted 377 lines
fs/xfs/libxfs/xfs_attr.c | 22 +++++++++------------- fs/xfs/libxfs/xfs_attr.h | 12 +++++------- fs/xfs/libxfs/xfs_types.c | 11 +++++++++++ fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/xfs_acl.c | 25 +++++++++++-------------- fs/xfs/xfs_ioctl.c | 23 +++++++++++++---------- fs/xfs/xfs_iops.c | 6 +++--- fs/xfs/xfs_xattr.c | 28 ++++++++++++++++------------ 8 files changed, 69 insertions(+), 59 deletions(-)fs/xfs/libxfs/xfs_attr.c +9
-13@@ -61,8 +61,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) {@@ -74,8 +73,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 */ @@ -139,8 +138,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)@@ -156,7 +154,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;@@ -339,8 +337,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)@@ -356,7 +353,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;@@ -444,8 +441,7 @@ xfs_attr_set(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;@@ -457,7 +453,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;fs/xfs/libxfs/xfs_attr.h +5
-7@@ -147,14 +147,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);fs/xfs/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(fs/xfs/libxfs/xfs_types.h +1
-0@@ -180,6 +180,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);fs/xfs/xfs_acl.c +11
-14@@ -123,7 +123,7 @@ xfs_get_acl(struct inode *inode, int type)struct xfs_inode *ip =XFS_I (inode);struct posix_acl *acl =NULL ;struct xfs_acl *xfs_acl =NULL ; -unsigned char *ea_name; +struct xfs_name name;int error;int len;@@ -131,10 +131,10 @@ xfs_get_acl(struct inode *inode, int type)switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT : - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :BUG ();@@ -145,9 +145,8 @@ xfs_get_acl(struct inode *inode, int type)* go out to the disk. */ len =XFS_ACL_MAX_SIZE (ip->i_mount); - error =xfs_attr_get (ip, ea_name,strlen (ea_name), - (unsigned char **)&xfs_acl, &len, -ATTR_ALLOC |ATTR_ROOT ); + error =xfs_attr_get (ip, &name, (unsigned char **)&xfs_acl, &len, +ATTR_ALLOC |ATTR_ROOT );if (error) {/* * If the attribute doesn't exist make sure we have a negative @@ -167,17 +166,17 @@ int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) { struct xfs_inode *ip = XFS_I(inode); -unsigned char *ea_name; +struct xfs_name name;int error;switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT :if (!S_ISDIR (inode->i_mode))return acl ? -EACCES :0 ; - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :return -EINVAL ;@@ -197,17 +196,15 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) len -=sizeof (struct xfs_acl_entry ) * (XFS_ACL_MAX_ENTRIES (ip->i_mount) - acl->a_count); - error =xfs_attr_set (ip, ea_name,strlen (ea_name), - (unsigned char *)xfs_acl, len,ATTR_ROOT ); + error =xfs_attr_set (ip, &name, (unsigned char *)xfs_acl, len, +ATTR_ROOT );kmem_free (xfs_acl); }else {/* * A NULL ACL argument means we want to remove the ACL. */ - error =xfs_attr_remove (ip, ea_name, -strlen (ea_name), -ATTR_ROOT ); + error =xfs_attr_remove (ip, &name,ATTR_ROOT );/* * If the attribute didn't exist to start with that's fine. fs/xfs/xfs_ioctl.c +13
-10@@ -357,7 +357,9 @@ xfs_attrmulti_attr_get( {unsigned char *kbuf;int error = -EFAULT ; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (*len >XFS_XATTR_SIZE_MAX )return -EINVAL ;@@ -365,9 +367,7 @@ xfs_attrmulti_attr_get(if (!kbuf)return -ENOMEM ; - namelen =strlen (name); - error =xfs_attr_get (XFS_I (inode), name, namelen, &kbuf, (int *)len, - flags); + error =xfs_attr_get (XFS_I (inode), &xname, &kbuf, (int *)len, flags);if (error) goto out_kfree;@@ -389,7 +389,9 @@ xfs_attrmulti_attr_set( {unsigned char *kbuf;int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;@@ -400,8 +402,7 @@ xfs_attrmulti_attr_set(if (IS_ERR (kbuf))return PTR_ERR (kbuf); - namelen =strlen (name); - error =xfs_attr_set (XFS_I (inode), name, namelen, kbuf, len, flags); + error =xfs_attr_set (XFS_I (inode), &xname, kbuf, len, flags);if (!error)xfs_forget_acl (inode, name, flags);kfree (kbuf);@@ -415,12 +416,14 @@ xfs_attrmulti_attr_remove( uint32_t flags) {int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ; - namelen =strlen (name); - error =xfs_attr_remove (XFS_I (inode), name, namelen, flags); + + error =xfs_attr_remove (XFS_I (inode), &xname, flags);if (!error)xfs_forget_acl (inode, name, flags);return error;fs/xfs/xfs_iops.c +3
-3@@ -48,11 +48,11 @@ xfs_initxattrs(const struct xattr *xattr;struct xfs_inode *ip =XFS_I (inode);int error =0 ; +struct xfs_name name;for (xattr = xattr_array; xattr->name !=NULL ; xattr++) { - error =xfs_attr_set (ip, xattr->name, -strlen (xattr->name), - xattr->value, xattr->value_len, +xfs_name_init (&name, xattr->name); + error =xfs_attr_set (ip, &name, xattr->value, xattr->value_len,ATTR_SECURE );if (error <0 )break ;fs/xfs/xfs_xattr.c +16
-12@@ -21,10 +21,12 @@ static int xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *value, size_t size) { - int xflags = handler->flags; -struct xfs_inode *ip =XFS_I (inode); -int error, asize = size; -size_t namelen =strlen (name); + int xflags = handler->flags; +struct xfs_inode *ip =XFS_I (inode); +int error, asize = size; +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (!size) {@@ -32,8 +34,8 @@ xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, value =NULL ; } - error =xfs_attr_get (ip, name, namelen, (unsigned char **)&value, - &asize, xflags); + error =xfs_attr_get (ip, &xname, (unsigned char **)&value, &asize, + xflags);if (error)return error;return asize;@@ -69,7 +71,9 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,int xflags = handler->flags;struct xfs_inode *ip =XFS_I (inode);int error; -size_t namelen =strlen (name); +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (flags &XATTR_CREATE )@@ -77,11 +81,11 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,if (flags &XATTR_REPLACE ) xflags |=ATTR_REPLACE ; -if (value) - error =xfs_attr_set (ip, name, namelen, (void *)value, size, - xflags); -else - error =xfs_attr_remove (ip, name, namelen, xflags); +if (value) + error =xfs_attr_set (ip, &xname, (void *)value, size, xflags); +else + error =xfs_attr_remove (ip, &xname, xflags); +if (!error)xfs_forget_acl (inode, name, xflags);Signature · 1 line
2.7.4
Re: [PATCH v7 01/19] xfs: Replace attribute parameters with struct xfs_name
Quoted 11 lines · Brian Foster
Quoted 6 lines · Allison Collins
This patch replaces the attribute name and length parameters with a single struct
xfs_nameparameter. This helps to clean up the numbers of parameters being passed around and pre-simplifies the code some.Signed-off-by Allison Collins <[email protected]>---
Looks fine to me:
Reviewed-by Brian Foster <[email protected]>
Great! Thanks for the reviews!
Allison
Quoted 379 lines
Quoted 378 lines
fs/xfs/libxfs/xfs_attr.c | 22 +++++++++------------- fs/xfs/libxfs/xfs_attr.h | 12 +++++------- fs/xfs/libxfs/xfs_types.c | 11 +++++++++++ fs/xfs/libxfs/xfs_types.h | 1 + fs/xfs/xfs_acl.c | 25 +++++++++++-------------- fs/xfs/xfs_ioctl.c | 23 +++++++++++++---------- fs/xfs/xfs_iops.c | 6 +++--- fs/xfs/xfs_xattr.c | 28 ++++++++++++++++------------ 8 files changed, 69 insertions(+), 59 deletions(-)fs/xfs/libxfs/xfs_attr.c +9
-13@@ -61,8 +61,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) {@@ -74,8 +73,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 */ @@ -139,8 +138,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)@@ -156,7 +154,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;@@ -339,8 +337,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)@@ -356,7 +353,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;@@ -444,8 +441,7 @@ xfs_attr_set(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;@@ -457,7 +453,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;fs/xfs/libxfs/xfs_attr.h +5
-7@@ -147,14 +147,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);fs/xfs/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(fs/xfs/libxfs/xfs_types.h +1
-0@@ -180,6 +180,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);fs/xfs/xfs_acl.c +11
-14@@ -123,7 +123,7 @@ xfs_get_acl(struct inode *inode, int type)struct xfs_inode *ip =XFS_I (inode);struct posix_acl *acl =NULL ;struct xfs_acl *xfs_acl =NULL ; -unsigned char *ea_name; +struct xfs_name name;int error;int len;@@ -131,10 +131,10 @@ xfs_get_acl(struct inode *inode, int type)switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT : - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :BUG ();@@ -145,9 +145,8 @@ xfs_get_acl(struct inode *inode, int type)* go out to the disk. */ len =XFS_ACL_MAX_SIZE (ip->i_mount); - error =xfs_attr_get (ip, ea_name,strlen (ea_name), - (unsigned char **)&xfs_acl, &len, -ATTR_ALLOC |ATTR_ROOT ); + error =xfs_attr_get (ip, &name, (unsigned char **)&xfs_acl, &len, +ATTR_ALLOC |ATTR_ROOT );if (error) {/* * If the attribute doesn't exist make sure we have a negative @@ -167,17 +166,17 @@ int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) { struct xfs_inode *ip = XFS_I(inode); -unsigned char *ea_name; +struct xfs_name name;int error;switch (type) {case ACL_TYPE_ACCESS : - ea_name =SGI_ACL_FILE ; +xfs_name_init (&name,SGI_ACL_FILE );break ;case ACL_TYPE_DEFAULT :if (!S_ISDIR (inode->i_mode))return acl ? -EACCES :0 ; - ea_name =SGI_ACL_DEFAULT ; +xfs_name_init (&name,SGI_ACL_DEFAULT );break ;default :return -EINVAL ;@@ -197,17 +196,15 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) len -=sizeof (struct xfs_acl_entry ) * (XFS_ACL_MAX_ENTRIES (ip->i_mount) - acl->a_count); - error =xfs_attr_set (ip, ea_name,strlen (ea_name), - (unsigned char *)xfs_acl, len,ATTR_ROOT ); + error =xfs_attr_set (ip, &name, (unsigned char *)xfs_acl, len, +ATTR_ROOT );kmem_free (xfs_acl); }else {/* * A NULL ACL argument means we want to remove the ACL. */ - error =xfs_attr_remove (ip, ea_name, -strlen (ea_name), -ATTR_ROOT ); + error =xfs_attr_remove (ip, &name,ATTR_ROOT );/* * If the attribute didn't exist to start with that's fine. fs/xfs/xfs_ioctl.c +13
-10@@ -357,7 +357,9 @@ xfs_attrmulti_attr_get( {unsigned char *kbuf;int error = -EFAULT ; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (*len >XFS_XATTR_SIZE_MAX )return -EINVAL ;@@ -365,9 +367,7 @@ xfs_attrmulti_attr_get(if (!kbuf)return -ENOMEM ; - namelen =strlen (name); - error =xfs_attr_get (XFS_I (inode), name, namelen, &kbuf, (int *)len, - flags); + error =xfs_attr_get (XFS_I (inode), &xname, &kbuf, (int *)len, flags);if (error) goto out_kfree;@@ -389,7 +389,9 @@ xfs_attrmulti_attr_set( {unsigned char *kbuf;int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ;@@ -400,8 +402,7 @@ xfs_attrmulti_attr_set(if (IS_ERR (kbuf))return PTR_ERR (kbuf); - namelen =strlen (name); - error =xfs_attr_set (XFS_I (inode), name, namelen, kbuf, len, flags); + error =xfs_attr_set (XFS_I (inode), &xname, kbuf, len, flags);if (!error)xfs_forget_acl (inode, name, flags);kfree (kbuf);@@ -415,12 +416,14 @@ xfs_attrmulti_attr_remove( uint32_t flags) {int error; -size_t namelen; +struct xfs_name xname; + +xfs_name_init (&xname, name);if (IS_IMMUTABLE (inode) ||IS_APPEND (inode))return -EPERM ; - namelen =strlen (name); - error =xfs_attr_remove (XFS_I (inode), name, namelen, flags); + + error =xfs_attr_remove (XFS_I (inode), &xname, flags);if (!error)xfs_forget_acl (inode, name, flags);return error;fs/xfs/xfs_iops.c +3
-3@@ -48,11 +48,11 @@ xfs_initxattrs(const struct xattr *xattr;struct xfs_inode *ip =XFS_I (inode);int error =0 ; +struct xfs_name name;for (xattr = xattr_array; xattr->name !=NULL ; xattr++) { - error =xfs_attr_set (ip, xattr->name, -strlen (xattr->name), - xattr->value, xattr->value_len, +xfs_name_init (&name, xattr->name); + error =xfs_attr_set (ip, &name, xattr->value, xattr->value_len,ATTR_SECURE );if (error <0 )break ;fs/xfs/xfs_xattr.c +16
-12@@ -21,10 +21,12 @@ static int xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *value, size_t size) { - int xflags = handler->flags; -struct xfs_inode *ip =XFS_I (inode); -int error, asize = size; -size_t namelen =strlen (name); + int xflags = handler->flags; +struct xfs_inode *ip =XFS_I (inode); +int error, asize = size; +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (!size) {@@ -32,8 +34,8 @@ xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, value =NULL ; } - error =xfs_attr_get (ip, name, namelen, (unsigned char **)&value, - &asize, xflags); + error =xfs_attr_get (ip, &xname, (unsigned char **)&value, &asize, + xflags);if (error)return error;return asize;@@ -69,7 +71,9 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,int xflags = handler->flags;struct xfs_inode *ip =XFS_I (inode);int error; -size_t namelen =strlen (name); +struct xfs_name xname; + +xfs_name_init (&xname, name);/* Convert Linux syscall to XFS internal ATTR flags */ if (flags &XATTR_CREATE )@@ -77,11 +81,11 @@ xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,if (flags &XATTR_REPLACE ) xflags |=ATTR_REPLACE ; -if (value) - error =xfs_attr_set (ip, name, namelen, (void *)value, size, - xflags); -else - error =xfs_attr_remove (ip, name, namelen, xflags); +if (value) + error =xfs_attr_set (ip, &xname, (void *)value, size, xflags); +else + error =xfs_attr_remove (ip, &xname, xflags); +if (!error)xfs_forget_acl (inode, name, xflags);Signature · 1 line
2.7.4
PATCH v7 2/19 xfs: 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.
--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)
fs/xfs/libxfs/xfs_attr.c +21 -16
@@ -72,13 +72,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 ; }
@@ -236,7 +235,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 )
@@ -357,6 +356,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 ;
@@ -372,7 +374,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)
@@ -457,6 +459,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
@@ -532,10 +537,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)
@@ -545,15 +550,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)
@@ -598,11 +603,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; }
@@ -872,10 +877,10 @@ xfs_attr_node_addname( 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);
fs/xfs/libxfs/xfs_attr_leaf.c +54 -50
231 lines not on this page · raw message
fs/xfs/libxfs/xfs_attr_remote.c +1 -1
@@ -397,7 +397,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;
fs/xfs/libxfs/xfs_da_btree.c +4 -2
@@ -2125,8 +2125,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 ; }int
fs/xfs/libxfs/xfs_da_btree.h +1 -3
@@ -54,12 +54,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 */
fs/xfs/libxfs/xfs_dir2.c +7 -11
@@ -74,14 +74,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 ; }
@@ -265,8 +265,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = inum;
@@ -361,8 +360,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 =xfs_dir2_hashname (dp->i_mount, name); args->dp = dp;
@@ -433,8 +431,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = ino;
@@ -494,8 +491,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = inum;
fs/xfs/libxfs/xfs_dir2_block.c +3 -3
@@ -355,7 +355,7 @@ xfs_dir2_block_addname(if (error)return error; - len =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + len =xfs_dir2_data_entsize (dp->i_mount, args->name.len);/* * Set up pointers to parts of the block.
@@ -539,8 +539,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
fs/xfs/libxfs/xfs_dir2_leaf.c +3 -3
@@ -653,7 +653,7 @@ xfs_dir2_leaf_addname(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = leafhdr.ents; bestsp =xfs_dir2_leaf_bests_p (ltp); - length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->name.len);/* * See if there are any entries with the same hash value
@@ -856,8 +856,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
fs/xfs/libxfs/xfs_dir2_node.c +4 -4
@@ -666,7 +666,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 =xfs_dir2_data_entsize (mp, args->namelen); + length =xfs_dir2_data_entsize (mp, args->name.len);/* * Loop over leaf entries with the right hash value. */
@@ -1911,7 +1911,7 @@ xfs_dir2_node_addname_int(int needscan =0 ;/* need to rescan data frees */ __be16 *tagp;/* data entry tag pointer */ - length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->name.len); error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, &findex, length);if (error)
@@ -1966,8 +1966,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
fs/xfs/libxfs/xfs_dir2_sf.c +15 -15
@@ -387,7 +387,7 @@ xfs_dir2_sf_addname(/* * Compute entry (and change in) size. */ - incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->namelen); + incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->name.len); objchange =0 ;/*
@@ -470,7 +470,7 @@ xfs_dir2_sf_addname_easy(/* * Grow the in-inode space. */ -xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->namelen), +xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->name.len),XFS_DATA_FORK );/* * Need to set up again due to realloc of the inode data.
@@ -480,9 +480,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);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber);xfs_dir2_sf_put_ftype (mp, sfep, args->filetype);
@@ -540,7 +540,7 @@ xfs_dir2_sf_addname_hard(*/ for (offset = args->geo->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), - add_datasize = xfs_dir2_data_entsize(mp, args->namelen), + add_datasize = xfs_dir2_data_entsize(mp, args->name.len), eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + xfs_dir2_data_entsize(mp, oldsfep->namelen),
@@ -570,9 +570,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);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber);xfs_dir2_sf_put_ftype (mp, sfep, args->filetype); sfp->count++;
@@ -615,7 +615,7 @@ xfs_dir2_sf_addname_pick(int used;/* data bytes used */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size =xfs_dir2_data_entsize (mp, args->namelen); + size =xfs_dir2_data_entsize (mp, args->name.len); offset = args->geo->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;
@@ -887,7 +887,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 ;
@@ -896,8 +896,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 =xfs_dir2_sf_get_parent_ino (sfp); args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;
@@ -984,7 +984,7 @@ xfs_dir2_sf_removename(* Calculate sizes. */ byteoff = (int )((char *)sfep - (char *)sfp); - entsize =xfs_dir2_sf_entsize (mp, sfp, args->namelen); + entsize =xfs_dir2_sf_entsize (mp, sfp, args->name.len); newsize = oldsize - entsize;/* * Copy the part if any after the removed entry, sliding it down.
@@ -1085,12 +1085,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 =xfs_dir2_sf_get_parent_ino (sfp);ASSERT (args->inumber != ino);xfs_dir2_sf_put_parent_ino (sfp, args->inumber);
fs/xfs/scrub/attr.c +6 -6
@@ -147,17 +147,17 @@ xchk_xattr_listent(return ; } - args.flags =ATTR_KERNOTIME ; + args.name.type =ATTR_KERNOTIME ;if (flags &XFS_ATTR_ROOT ) - args.flags |=ATTR_ROOT ; + args.name.type |=ATTR_ROOT ;else if (flags &XFS_ATTR_SECURE ) - args.flags |=ATTR_SECURE ; + args.name.type |=ATTR_SECURE ; args.geo = context->dp->i_mount->m_attr_geo; args.whichfork =XFS_ATTR_FORK ; args.dp = context->dp; - args.name = name; - args.namelen = namelen; - args.hashval =xfs_da_hashname (args.name, args.namelen); + args.name.name = name; + args.name.len = namelen; + args.hashval =xfs_da_hashname (args.name.name, args.name.len); args.trans = context->tp; args.value =xchk_xattr_valuebuf (sx->sc); args.valuelen = valuelen;
fs/xfs/xfs_trace.h +11 -9
@@ -1633,7 +1633,7 @@ DECLARE_EVENT_CLASS(xfs_da_class,TP_STRUCT__entry (__field (dev_t ,dev )__field (xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len)__field (int, namelen)__field (xfs_dahash_t, hashval) __field(xfs_ino_t, inumber)
@@ -1642,9 +1642,10 @@ DECLARE_EVENT_CLASS(xfs_da_class,TP_fast_assign ( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; -if (args->namelen) -memcpy (__get_str (name), args->name, args->namelen); - __entry->namelen = args->namelen; +if (args->name.len) +memcpy (__get_str (name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->hashval = args->hashval; __entry->inumber = args->inumber; __entry->op_flags = args->op_flags;
@@ -1697,7 +1698,7 @@ DECLARE_EVENT_CLASS(xfs_attr_class,TP_STRUCT__entry (__field (dev_t ,dev )__field (xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len)__field (int, namelen)__field (int, valuelen) __field(xfs_dahash_t, hashval)
@@ -1707,12 +1708,13 @@ DECLARE_EVENT_CLASS(xfs_attr_class,TP_fast_assign ( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; -if (args->namelen) -memcpy (__get_str (name), args->name, args->namelen); - __entry->namelen = args->namelen; +if (args->name.len) +memcpy (__get_str (name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->valuelen = args->valuelen; __entry->hashval = args->hashval; - __entry->flags = args->flags; + __entry->flags = args->name.type; __entry->op_flags = args->op_flags; ), TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d "
Signature · 1 line
2.7.4
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 27 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0
fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 75
Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c +1
-4@@ -72,13 +72,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 ));
Maybe xfs_name_copy and xfs_name_equal are in order?
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 361
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +3
-0+/* Use name now stored in args */ + name = &args.name; +
It seem that the context of these comments be clear in the future.
Quoted 36 lines
fs/xfs/libxfs/xfs_attr.c +6
-3args.value = value; args.valuelen = valuelen; args.op_flags =XFS_DA_OP_ADDNAME |XFS_DA_OP_OKNOENT ;@@ -372,7 +374,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)@@ -457,6 +459,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 @@ -532,10 +537,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)
fs/xfs/libxfs/xfs_attr.c xfs_attr_shortform_addname(xfs_da_args_t *args) · line 553
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1@@ -545,15 +550,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 ;
This doesn't look good it looks like a hack.
Even if want to avoid growing struct xfs_name we can store two shorts instead of overloading int type with flags.
type doesn't even need more than a single byte, because XFS_DIR3_FT_WHT is not used and will never be used on-disk.
Thanks,
Amir.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 24 lines · Amir Goldstein
Quoted 22 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)
Quoted 15 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 75
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c +1
-4@@ -72,13 +72,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 ));Maybe
xfs_name_copyandxfs_name_equalare in order?
You are suggesting to add xfs_name_copy and xfs_name_equal helpers? I'm not sure there's a use case yet for xfs_name_equal, at least not in this set. And I think people indicated that they preferred the memcpy in past reviews rather than handling each member of the xfs_name struct. Unless I misunderstood the question, I'm not sure there is much left for a xfs_name_copy helper to cover that the memcpy does not?
Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 361
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +3
-0+/* Use name now stored in args */ + name = &args.name; +It seem that the context of these comments be clear in the future.
You are asking to add more context to the comment? How about:
/* * Use name now stored in args. Abandon the local name * parameter as it will not be updated in the subroutines */
Does that help some?
Quoted 46 lines
Quoted 37 lines
fs/xfs/libxfs/xfs_attr.c +6
-3args.value = value; args.valuelen = valuelen; args.op_flags =XFS_DA_OP_ADDNAME |XFS_DA_OP_OKNOENT ;@@ -372,7 +374,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)@@ -457,6 +459,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 @@ -532,10 +537,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)fs/xfs/libxfs/xfs_attr.c xfs_attr_shortform_addname(xfs_da_args_t *args) · line 553
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1@@ -545,15 +550,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 ;This doesn't look good it looks like a hack.
Quoted 8 lines
Even if want to avoid growing struct
xfs_namewe can store two shorts instead of overloading int type with flags.
type doesn't even need more than a single byte, becauseXFS_DIR3_FT_WHTis not used and will never be used on-disk.Thanks,
Amir.
The exact use of .type has gone around a few times since this patch started, which was actually all the way back in parent pointers. :-) Initially the xfs_name struct replaced anything that passed all three parameters, and then later we decided that flags should stay separate for top level get/set/remove routines, but become integrated below the *_args routines. I don't recall people being concerned about growing the struct, though a union seems reasonable to resolve the naming weirdness. I would like to have a little more feedback from folks though just to make sure everyones in agreement since this one's gone through quite few reviews already. Thanks all!
Allison
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 43 lines · Allison Collins
Quoted 24 lines · Amir Goldstein
Quoted 22 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)Quoted 15 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 75
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c +1
-4@@ -72,13 +72,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 ));Maybe
xfs_name_copyandxfs_name_equalare in order?
Quoted 7 lines
You are suggesting to add
xfs_name_copyandxfs_name_equalhelpers? I'm not sure there's a use case yet forxfs_name_equal, at least not in this set. And I think people indicated that they preferred the memcpy in past reviews rather than handling each member of thexfs_namestruct. Unless I misunderstood the question, I'm not sure there is much left for axfs_name_copyhelper to cover that the memcpy does not?
It's fine. The choice between xfs_name_copy and memcpy is mostly personal taste. I did not read through past reviews.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +3
-0+/* Use name now stored in args */ + name = &args.name; +
Quoted 8 lines
Quoted 1 line
It seem that the context of these comments be clear in the future.
You are asking to add more context to the comment? How about:
/*
* Use name now stored in args. Abandon the local name
* parameter as it will not be updated in the subroutines */Does that help some?
Can't you just not use local name arg anymore? Instead of re-assigning it and explaining why you do that. Does that gain anything to code readability or anything else?
Thanks,
Amir.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 69 lines · Amir Goldstein
Quoted 43 lines · Allison Collins
Quoted 24 lines · Amir Goldstein
Quoted 22 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)Quoted 15 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 75
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c +1
-4@@ -72,13 +72,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 ));Maybe
xfs_name_copyandxfs_name_equalare in order?Quoted 7 lines
You are suggesting to add
xfs_name_copyandxfs_name_equalhelpers? I'm not sure there's a use case yet forxfs_name_equal, at least not in this set. And I think people indicated that they preferred the memcpy in past reviews rather than handling each member of thexfs_namestruct. Unless I misunderstood the question, I'm not sure there is much left for axfs_name_copyhelper to cover that the memcpy does not?It's fine. The choice between
xfs_name_copyand memcpy is mostly personal taste. I did not read through past reviews.Quoted 13 lines
Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 361
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +3
-0+/* Use name now stored in args */ + name = &args.name; +It seem that the context of these comments be clear in the future.
You are asking to add more context to the comment? How about:
/*
* Use name now stored in args. Abandon the local name
* parameter as it will not be updated in the subroutines */
Quoted 5 lines
Quoted 1 line
Does that help some?
Can't you just not use local name arg anymore? Instead of re-assigning it and explaining why you do that. Does that gain anything to code readability or anything else?
Well, with out the set, you cannot use for example name->type anymore, you need to use args->name->type. In order to use the local name variable again, it needs to be updated. I stumbled across this myself when working with it and thought it would be better to fix it right away rather than let others run across the same mistake. It seems like a subtle and easy thing to overlook otherwise.
I do think it's a bit of a wart that people may not have thought about when we talked about adding this patch. Though I don't know that it's a big enough deal to drop it either. But I did feel some motivation to at least clean it up and make a comment about it.
Allison
Quoted 4 lines
Thanks,
Amir.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 85 lines · Allison Collins
Quoted 69 lines · Amir Goldstein
Quoted 43 lines · Allison Collins
Quoted 24 lines · Amir Goldstein
Quoted 22 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)Quoted 15 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 75
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c +1
-4@@ -72,13 +72,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 ));Maybe
xfs_name_copyandxfs_name_equalare in order?Quoted 7 lines
You are suggesting to add
xfs_name_copyandxfs_name_equalhelpers? I'm not sure there's a use case yet forxfs_name_equal, at least not in this set. And I think people indicated that they preferred the memcpy in past reviews rather than handling each member of thexfs_namestruct. Unless I misunderstood the question, I'm not sure there is much left for axfs_name_copyhelper to cover that the memcpy does not?It's fine. The choice between
xfs_name_copyand memcpy is mostly personal taste. I did not read through past reviews.Quoted 13 lines
Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 361
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +3
-0+/* Use name now stored in args */ + name = &args.name; +It seem that the context of these comments be clear in the future.
You are asking to add more context to the comment? How about:
/*
* Use name now stored in args. Abandon the local name
* parameter as it will not be updated in the subroutines */Quoted 5 lines
Quoted 1 line
Does that help some?
Can't you just not use local name arg anymore? Instead of re-assigning it and explaining why you do that. Does that gain anything to code readability or anything else?
Well, with out the set, you cannot use for example
name->typeanymore, you need to useargs->name->type. In order to use the local name variable again, it needs to be updated. I stumbled across this myself when working with it and thought it would be better to fix it right away rather than let others run across the same mistake. It seems like a subtle and easy thing to overlook otherwise.
Quoted 5 lines
I do think it's a bit of a wart that people may not have thought about when we talked about adding this patch. Though I don't know that it's a big enough deal to drop it either. But I did feel some motivation to at least clean it up and make a comment about it.
Understood. I have no smart suggestion, so withdrawing my comment.
Thanks,
Amir.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
In reply to Allison CollinsQuoted 3 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.
Commit message should wrap at 68-72 columns.
Quoted 23 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0
fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 76
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +2
-4@@ -72,13 +72,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;
This doesn't play well with Christoph's cleanup series which fixes up all the confusion with internal versus API flags. I guess the namespace is part of the attribute name, but I think this would be a much clearer conversion when placed on top of the way Christoph cleaned all this up...
Have you looked at rebasing this on top of that cleanup series?
Cheers,
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 46 lines · Dave Chinner
Quoted 3 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Commit message should wrap at 68-72 columns.
Quoted 23 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 76
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +2
-4@@ -72,13 +72,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;This doesn't play well with Christoph's cleanup series which fixes up all the confusion with internal versus API flags. I guess the namespace is part of the attribute name, but I think this would be a much clearer conversion when placed on top of the way Christoph cleaned all this up...
Quoted 4 lines
Have you looked at rebasing this on top of that cleanup series?
Cheers,
Yes, there is some conflict between the sets here and there, but I think folks wanted to keep them separate for now. Are you referring to "[780d29057781] xfs: fix misuse of the XFS_ATTR_INCOMPLETE flag"? I'm pretty sure this set is already seated on top of that one. This one is based on the latest for-next.
Allison
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 49 lines · Allison Collins
Quoted 46 lines · Dave Chinner
Quoted 3 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Commit message should wrap at 68-72 columns.
Quoted 23 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 76
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +2
-4@@ -72,13 +72,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;This doesn't play well with Christoph's cleanup series which fixes up all the confusion with internal versus API flags. I guess the namespace is part of the attribute name, but I think this would be a much clearer conversion when placed on top of the way Christoph cleaned all this up...
Quoted 6 lines
Quoted 4 lines
Have you looked at rebasing this on top of that cleanup series?
Cheers,
Yes, there is some conflict between the sets here and there, but I think folks wanted to keep them separate for now.
That makes it really hard to form a clear view of what the code looks like after both patchsets have been applied. :(
Quoted 4 lines
Are you referring to
"[780d29057781] xfs: fix misuse of theXFS_ATTR_INCOMPLETEflag"? I'm pretty sure this set is already seated on top of that one. This one is based on the latest for-next.
No, I'm talking about the series that ends up undoing that commit (i.e. the DA_OP_INCOMPLETE flag goes away again) and turns args->flags into args->attr_filter as the namespace filter for lookups. THis also turn adds XFS_ATTR_INCOMPLETE into a lookup filter.
With this separation of ops vs lookup filters, moving the lookup filter into the xfs_name makes a bit more sense (i.e. the namespace filter is passed with the attribute name), but as a standalone movement it creates a bit of an impedence mismatch between the xname and the use of these flags.
I think the end result will be fine, but it's making it hard for me to reconcile the changes in the two patchsets...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 77 lines · Dave Chinner
Quoted 49 lines · Allison Collins
Quoted 46 lines · Dave Chinner
Quoted 3 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Commit message should wrap at 68-72 columns.
Quoted 23 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 76
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +2
-4@@ -72,13 +72,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;This doesn't play well with Christoph's cleanup series which fixes up all the confusion with internal versus API flags. I guess the namespace is part of the attribute name, but I think this would be a much clearer conversion when placed on top of the way Christoph cleaned all this up...
Quoted 6 lines
Quoted 4 lines
Have you looked at rebasing this on top of that cleanup series?
Cheers,
Yes, there is some conflict between the sets here and there, but I think folks wanted to keep them separate for now.
That makes it really hard to form a clear view of what the code looks like after both patchsets have been applied. :(
Quoted 4 lines
Are you referring to
"[780d29057781] xfs: fix misuse of theXFS_ATTR_INCOMPLETEflag"? I'm pretty sure this set is already seated on top of that one. This one is based on the latest for-next.No, I'm talking about the series that ends up undoing that commit (i.e. the
DA_OP_INCOMPLETEflag goes away again) and turnsargs->flagsintoargs->attr_filteras the namespace filter for lookups. THis also turn addsXFS_ATTR_INCOMPLETEinto a lookup filter.With this separation of ops vs lookup filters, moving the lookup filter into the
xfs_namemakes a bit more sense (i.e. the namespace filter is passed with the attribute name), but as a standalone movement it creates a bit of an impedence mismatch between the xname and the use of these flags.
Quoted 4 lines
I think the end result will be fine, but it's making it hard for me to reconcile the changes in the two patchsets...
Cheers,
I'd be happy to go through the sets and find the intersections. Or make a big super set if you like. I got the impression though that Christoph didnt particularly like the delayed attr series or the idea of blending them. But I do think it would be a good idea to take into consideration what the combination of them is going to look like.
Allison
Quoted 3 lines
Dave.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 83 lines · Allison Collins
Quoted 80 lines · Dave Chinner
Quoted 49 lines · Allison Collins
Quoted 46 lines · Dave Chinner
Quoted 3 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Commit message should wrap at 68-72 columns.
Quoted 23 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 76
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +2
-4@@ -72,13 +72,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;This doesn't play well with Christoph's cleanup series which fixes up all the confusion with internal versus API flags. I guess the namespace is part of the attribute name, but I think this would be a much clearer conversion when placed on top of the way Christoph cleaned all this up...
Quoted 6 lines
Quoted 4 lines
Have you looked at rebasing this on top of that cleanup series?
Cheers,
Yes, there is some conflict between the sets here and there, but I think folks wanted to keep them separate for now.
That makes it really hard to form a clear view of what the code looks like after both patchsets have been applied. :(
Quoted 4 lines
Are you referring to
"[780d29057781] xfs: fix misuse of theXFS_ATTR_INCOMPLETEflag"? I'm pretty sure this set is already seated on top of that one. This one is based on the latest for-next.No, I'm talking about the series that ends up undoing that commit (i.e. the
DA_OP_INCOMPLETEflag goes away again) and turnsargs->flagsintoargs->attr_filteras the namespace filter for lookups. THis also turn addsXFS_ATTR_INCOMPLETEinto a lookup filter.With this separation of ops vs lookup filters, moving the lookup filter into the
xfs_namemakes a bit more sense (i.e. the namespace filter is passed with the attribute name), but as a standalone movement it creates a bit of an impedence mismatch between the xname and the use of these flags.I think the end result will be fine, but it's making it hard for me to reconcile the changes in the two patchsets...
Quoted 7 lines
Quoted 1 line
Cheers,
I'd be happy to go through the sets and find the intersections. Or make a big super set if you like. I got the impression though that Christoph didnt particularly like the delayed attr series or the idea of blending them. But I do think it would be a good idea to take into consideration what the combination of them is going to look like.
At this point you might as well wait for me to actually put hch's attr interface refactoring series into for-next (unless this series is already based off of that??) though Christoph might be a bit time constrained this week...
--D
Quoted 7 lines
Allison
Quoted 3 lines
Dave.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 92 lines · Darrick J. Wong
Quoted 83 lines · Allison Collins
Quoted 80 lines · Dave Chinner
Quoted 49 lines · Allison Collins
Quoted 46 lines · Dave Chinner
Quoted 3 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.Commit message should wrap at 68-72 columns.
Quoted 23 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0fs/xfs/libxfs/xfs_attr.c xfs_attr_args_init( · line 76
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +2
-4@@ -72,13 +72,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;This doesn't play well with Christoph's cleanup series which fixes up all the confusion with internal versus API flags. I guess the namespace is part of the attribute name, but I think this would be a much clearer conversion when placed on top of the way Christoph cleaned all this up...
Quoted 6 lines
Quoted 4 lines
Have you looked at rebasing this on top of that cleanup series?
Cheers,
Yes, there is some conflict between the sets here and there, but I think folks wanted to keep them separate for now.
That makes it really hard to form a clear view of what the code looks like after both patchsets have been applied. :(
Quoted 4 lines
Are you referring to
"[780d29057781] xfs: fix misuse of theXFS_ATTR_INCOMPLETEflag"? I'm pretty sure this set is already seated on top of that one. This one is based on the latest for-next.No, I'm talking about the series that ends up undoing that commit (i.e. the
DA_OP_INCOMPLETEflag goes away again) and turnsargs->flagsintoargs->attr_filteras the namespace filter for lookups. THis also turn addsXFS_ATTR_INCOMPLETEinto a lookup filter.With this separation of ops vs lookup filters, moving the lookup filter into the
xfs_namemakes a bit more sense (i.e. the namespace filter is passed with the attribute name), but as a standalone movement it creates a bit of an impedence mismatch between the xname and the use of these flags.I think the end result will be fine, but it's making it hard for me to reconcile the changes in the two patchsets...
Quoted 7 lines
Quoted 1 line
Cheers,
I'd be happy to go through the sets and find the intersections. Or make a big super set if you like. I got the impression though that Christoph didnt particularly like the delayed attr series or the idea of blending them. But I do think it would be a good idea to take into consideration what the combination of them is going to look like.
Quoted 4 lines
At this point you might as well wait for me to actually put hch's attr interface refactoring series into for-next (unless this series is already based off of that??) though Christoph might be a bit time constrained this week...
It's based on for-next at this point. Both these sets are pretty big, so it's a lot to chase if he's not interested in slowing down to work with the combination of them. If folks would like to see the combination set before moving forward, I'd be happy to try and put that together. Otherwise, it can wait too. Let me know. Thanks!
Allison
Quoted 10 lines
--D
Quoted 7 lines
Allison
Quoted 3 lines
Dave.
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 5 lines · Allison Collins
It's based on for-next at this point. Both these sets are pretty big, so it's a lot to chase if he's not interested in slowing down to work with the combination of them. If folks would like to see the combination set before moving forward, I'd be happy to try and put that together. Otherwise, it can wait too. Let me know. Thanks!
I'd simply rebase it on top of christoph's patchset based on the fact it's likely to be merged before this one. Christoph posted a git tree link, just pull that down and use that as the topic branch you rebase onto....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
In reply to Darrick J. WongQuoted 4 lines · Darrick J. Wong
At this point you might as well wait for me to actually put hch's attr interface refactoring series into for-next (unless this series is already based off of that??) though Christoph might be a bit time constrained this week...
I can resend it. The only change from the last version is to drop the da_args move, I've just been waiting for more comments to not spam the list too much..
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
In reply to Allison CollinsQuoted 4 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.
The statement "name = &args.name;" in xfs_attr_set() and xfs_attr_remove() was not apparent to me on first read. However your explaination to Amir's question about name.type being set in xfs_attr_args_init() made it clear.
Quoted 768 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +21
-16@@ -72,13 +72,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 ; }@@ -236,7 +235,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 )@@ -357,6 +356,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 ;@@ -372,7 +374,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)@@ -457,6 +459,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 @@ -532,10 +537,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)@@ -545,15 +550,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)@@ -598,11 +603,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; }@@ -872,10 +877,10 @@ xfs_attr_node_addname( 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);fs/xfs/libxfs/xfs_attr_leaf.c +54
-50@@ -464,7 +464,7 @@ xfs_attr_copy_value(/* * No copy if all we have to do is get the length */ -if (args->flags &ATTR_KERNOVAL ) { +if (args->name.type &ATTR_KERNOVAL ) { args->valuelen = valuelen;return 0 ; }@@ -679,27 +679,27 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) {#ifdef DEBUG -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (args->name, sfe->nameval, args->namelen) !=0 ) +if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ;ASSERT (0 );#endif } offset = (char *)sfe - (char *)sf; - size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->namelen, args->valuelen); + size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen);xfs_idata_realloc (dp, size,XFS_ATTR_FORK ); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); - sfe->namelen = args->namelen; + sfe->namelen = args->name.len; sfe->valuelen = args->valuelen; - sfe->flags =XFS_ATTR_NSP_ARGS_TO_ONDISK (args->flags); -memcpy (sfe->nameval, args->name, args->namelen); -memcpy (&sfe->nameval[args->namelen], args->value, args->valuelen); + sfe->flags =XFS_ATTR_NSP_ARGS_TO_ONDISK (args->name.type); +memcpy (sfe->nameval, args->name.name, args->name.len); +memcpy (&sfe->nameval[args->name.len], args->value, args->valuelen); sf->hdr.count++;be16_add_cpu (&sf->hdr.totsize, size);xfs_trans_log_inode (args->trans, dp,XFS_ILOG_CORE |XFS_ILOG_ADATA );@@ -749,11 +749,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), base += size, i++) { size =XFS_ATTR_SF_ENTSIZE (sfe); -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (sfe->nameval, args->name, args->namelen) !=0 ) +if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ;break ; }@@ -816,11 +816,11 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (args->name, sfe->nameval, args->namelen) !=0 ) +if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ;return -EEXIST ; }@@ -847,13 +847,13 @@ xfs_attr_shortform_getvalue( sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (args->name, sfe->nameval, args->namelen) !=0 ) +if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ; -return xfs_attr_copy_value (args, &sfe->nameval[args->namelen], +return xfs_attr_copy_value (args, &sfe->nameval[args->name.len], sfe->valuelen); }return -ENOATTR ;@@ -912,13 +912,13 @@ xfs_attr_shortform_to_leaf( sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; i++) { - nargs.name = sfe->nameval; - nargs.namelen = sfe->namelen; - nargs.value = &sfe->nameval[nargs.namelen]; + nargs.name.name = sfe->nameval; + nargs.name.len = sfe->namelen; + nargs.value = &sfe->nameval[nargs.name.len]; nargs.valuelen = sfe->valuelen; nargs.hashval =xfs_da_hashname (sfe->nameval, sfe->namelen); - nargs.flags =XFS_ATTR_NSP_ONDISK_TO_ARGS (sfe->flags); + nargs.name.type =XFS_ATTR_NSP_ONDISK_TO_ARGS (sfe->flags); error =xfs_attr3_leaf_lookup_int (bp, &nargs);/* set a->index */ ASSERT (error == -ENOATTR ); error =xfs_attr3_leaf_add (bp, &nargs);@@ -1119,12 +1119,12 @@ xfs_attr3_leaf_to_shortform(continue ;ASSERT (entry->flags &XFS_ATTR_LOCAL ); name_loc =xfs_attr3_leaf_name_local (leaf, i); - nargs.name = name_loc->nameval; - nargs.namelen = name_loc->namelen; - nargs.value = &name_loc->nameval[nargs.namelen]; + nargs.name.name = name_loc->nameval; + nargs.name.len = name_loc->namelen; + nargs.value = &name_loc->nameval[nargs.name.len]; nargs.valuelen =be16_to_cpu (name_loc->valuelen); nargs.hashval =be32_to_cpu (entry->hashval); - nargs.flags =XFS_ATTR_NSP_ONDISK_TO_ARGS (entry->flags); + nargs.name.type =XFS_ATTR_NSP_ONDISK_TO_ARGS (entry->flags);xfs_attr_shortform_add (&nargs, forkoff); } error =0 ;@@ -1450,7 +1450,7 @@ xfs_attr3_leaf_add_work( ichdr->freemap[mapindex].size); entry->hashval =cpu_to_be32 (args->hashval); entry->flags = tmp ?XFS_ATTR_LOCAL :0 ; - entry->flags |=XFS_ATTR_NSP_ARGS_TO_ONDISK (args->flags); + entry->flags |=XFS_ATTR_NSP_ARGS_TO_ONDISK (args->name.type);if (args->op_flags &XFS_DA_OP_RENAME ) { entry->flags |=XFS_ATTR_INCOMPLETE ; if ((args->blkno2 == args->blkno) &&@@ -1474,15 +1474,16 @@ xfs_attr3_leaf_add_work(*/ if (entry->flags &XFS_ATTR_LOCAL ) { name_loc =xfs_attr3_leaf_name_local (leaf, args->index); - name_loc->namelen = args->namelen; + name_loc->namelen = args->name.len; name_loc->valuelen =cpu_to_be16 (args->valuelen); -memcpy ((char *)name_loc->nameval, args->name, args->namelen); -memcpy ((char *)&name_loc->nameval[args->namelen], args->value, +memcpy ((char *)name_loc->nameval, args->name.name, + args->name.len); +memcpy ((char *)&name_loc->nameval[args->name.len], args->value,be16_to_cpu (name_loc->valuelen)); }else { name_rmt =xfs_attr3_leaf_name_remote (leaf, args->index); - name_rmt->namelen = args->namelen; -memcpy ((char *)name_rmt->name, args->name, args->namelen); + name_rmt->namelen = args->name.len; +memcpy ((char *)name_rmt->name, args->name.name, args->name.len); entry->flags |=XFS_ATTR_INCOMPLETE ;/* just in case */ name_rmt->valuelen =0 ;@@ -2409,23 +2410,25 @@ xfs_attr3_leaf_lookup_int( }if (entry->flags &XFS_ATTR_LOCAL ) { name_loc =xfs_attr3_leaf_name_local (leaf, probe); -if (name_loc->namelen != args->namelen) +if (name_loc->namelen != args->name.len)continue ; -if (memcmp (args->name, name_loc->nameval, - args->namelen) !=0 ) +if (memcmp (args->name.name, name_loc->nameval, + args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, entry->flags)) +if (!xfs_attr_namesp_match (args->name.type, + entry->flags))continue ; args->index = probe;return -EEXIST ; }else { name_rmt =xfs_attr3_leaf_name_remote (leaf, probe); -if (name_rmt->namelen != args->namelen) +if (name_rmt->namelen != args->name.len)continue ; -if (memcmp (args->name, name_rmt->name, - args->namelen) !=0 ) +if (memcmp (args->name.name, name_rmt->name, + args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, entry->flags)) +if (!xfs_attr_namesp_match (args->name.type, + entry->flags))continue ; args->index = probe; args->rmtvaluelen =be32_to_cpu (name_rmt->valuelen);@@ -2467,16 +2470,17 @@ xfs_attr3_leaf_getvalue( entry = &xfs_attr3_leaf_entryp (leaf)[args->index];if (entry->flags &XFS_ATTR_LOCAL ) { name_loc =xfs_attr3_leaf_name_local (leaf, args->index); -ASSERT (name_loc->namelen == args->namelen); -ASSERT (memcmp (args->name, name_loc->nameval, args->namelen) ==0 ); +ASSERT (name_loc->namelen == args->name.len); +ASSERT (memcmp (args->name.name, name_loc->nameval, + args->name.len) ==0 );return xfs_attr_copy_value (args, - &name_loc->nameval[args->namelen], + &name_loc->nameval[args->name.len],be16_to_cpu (name_loc->valuelen)); } name_rmt =xfs_attr3_leaf_name_remote (leaf, args->index); -ASSERT (name_rmt->namelen == args->namelen); -ASSERT (memcmp (args->name, name_rmt->name, args->namelen) ==0 ); +ASSERT (name_rmt->namelen == args->name.len); +ASSERT (memcmp (args->name.name, name_rmt->name, args->name.len) ==0 ); args->rmtvaluelen =be32_to_cpu (name_rmt->valuelen); args->rmtblkno =be32_to_cpu (name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount,@@ -2692,7 +2696,7 @@ xfs_attr_leaf_newentsize( {int size; - size =xfs_attr_leaf_entsize_local (args->namelen, args->valuelen); + size =xfs_attr_leaf_entsize_local (args->name.len, args->valuelen);if (size <xfs_attr_leaf_entsize_local_max (args->geo->blksize)) {if (local) *local =1 ;@@ -2700,7 +2704,7 @@ xfs_attr_leaf_newentsize( }if (local) *local =0 ; -return xfs_attr_leaf_entsize_remote (args->namelen); +return xfs_attr_leaf_entsize_remote (args->name.len); }@@ -2754,8 +2758,8 @@ xfs_attr3_leaf_clearflag( name = (char *)name_rmt->name; }ASSERT (be32_to_cpu (entry->hashval) == args->hashval); -ASSERT (namelen == args->namelen); -ASSERT (memcmp (name, args->name, namelen) ==0 ); +ASSERT (namelen == args->name.len); +ASSERT (memcmp (name, args->name.name, namelen) ==0 );#endif /* DEBUG */ entry->flags &= ~XFS_ATTR_INCOMPLETE ;fs/xfs/libxfs/xfs_attr_remote.c +1
-1@@ -397,7 +397,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;fs/xfs/libxfs/xfs_da_btree.c +4
-2@@ -2125,8 +2125,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 ; }int fs/xfs/libxfs/xfs_da_btree.h +1
-3@@ -54,12 +54,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 */fs/xfs/libxfs/xfs_dir2.c +7
-11@@ -74,14 +74,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 ; }@@ -265,8 +265,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = inum;@@ -361,8 +360,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 =xfs_dir2_hashname (dp->i_mount, name); args->dp = dp;@@ -433,8 +431,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = ino;@@ -494,8 +491,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = inum;fs/xfs/libxfs/xfs_dir2_block.c +3
-3@@ -355,7 +355,7 @@ xfs_dir2_block_addname(if (error)return error; - len =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + len =xfs_dir2_data_entsize (dp->i_mount, args->name.len);/* * Set up pointers to parts of the block. @@ -539,8 +539,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_leaf.c +3
-3@@ -653,7 +653,7 @@ xfs_dir2_leaf_addname(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = leafhdr.ents; bestsp =xfs_dir2_leaf_bests_p (ltp); - length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->name.len);/* * See if there are any entries with the same hash value @@ -856,8 +856,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_node.c +4
-4@@ -666,7 +666,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 =xfs_dir2_data_entsize (mp, args->namelen); + length =xfs_dir2_data_entsize (mp, args->name.len);/* * Loop over leaf entries with the right hash value. */ @@ -1911,7 +1911,7 @@ xfs_dir2_node_addname_int(int needscan =0 ;/* need to rescan data frees */ __be16 *tagp;/* data entry tag pointer */ - length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->name.len); error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, &findex, length);if (error)@@ -1966,8 +1966,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_sf.c +15
-15@@ -387,7 +387,7 @@ xfs_dir2_sf_addname(/* * Compute entry (and change in) size. */ - incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->namelen); + incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->name.len); objchange =0 ;/* @@ -470,7 +470,7 @@ xfs_dir2_sf_addname_easy(/* * Grow the in-inode space. */ -xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->namelen), +xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->name.len),XFS_DATA_FORK );/* * Need to set up again due to realloc of the inode data. @@ -480,9 +480,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);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber);xfs_dir2_sf_put_ftype (mp, sfep, args->filetype);@@ -540,7 +540,7 @@ xfs_dir2_sf_addname_hard(*/ for (offset = args->geo->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), - add_datasize = xfs_dir2_data_entsize(mp, args->namelen), + add_datasize = xfs_dir2_data_entsize(mp, args->name.len), eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + xfs_dir2_data_entsize(mp, oldsfep->namelen),@@ -570,9 +570,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);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber);xfs_dir2_sf_put_ftype (mp, sfep, args->filetype); sfp->count++;@@ -615,7 +615,7 @@ xfs_dir2_sf_addname_pick(int used;/* data bytes used */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size =xfs_dir2_data_entsize (mp, args->namelen); + size =xfs_dir2_data_entsize (mp, args->name.len); offset = args->geo->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;@@ -887,7 +887,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 ;@@ -896,8 +896,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 =xfs_dir2_sf_get_parent_ino (sfp); args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;@@ -984,7 +984,7 @@ xfs_dir2_sf_removename(* Calculate sizes. */ byteoff = (int )((char *)sfep - (char *)sfp); - entsize =xfs_dir2_sf_entsize (mp, sfp, args->namelen); + entsize =xfs_dir2_sf_entsize (mp, sfp, args->name.len); newsize = oldsize - entsize;/* * Copy the part if any after the removed entry, sliding it down. @@ -1085,12 +1085,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 =xfs_dir2_sf_get_parent_ino (sfp);ASSERT (args->inumber != ino);xfs_dir2_sf_put_parent_ino (sfp, args->inumber);fs/xfs/scrub/attr.c +6
-6@@ -147,17 +147,17 @@ xchk_xattr_listent(return ; } - args.flags =ATTR_KERNOTIME ; + args.name.type =ATTR_KERNOTIME ;if (flags &XFS_ATTR_ROOT ) - args.flags |=ATTR_ROOT ; + args.name.type |=ATTR_ROOT ;else if (flags &XFS_ATTR_SECURE ) - args.flags |=ATTR_SECURE ; + args.name.type |=ATTR_SECURE ; args.geo = context->dp->i_mount->m_attr_geo; args.whichfork =XFS_ATTR_FORK ; args.dp = context->dp; - args.name = name; - args.namelen = namelen; - args.hashval =xfs_da_hashname (args.name, args.namelen); + args.name.name = name; + args.name.len = namelen; + args.hashval =xfs_da_hashname (args.name.name, args.name.len); args.trans = context->tp; args.value =xchk_xattr_valuebuf (sx->sc); args.valuelen = valuelen;fs/xfs/xfs_trace.h +11
-9@@ -1633,7 +1633,7 @@ DECLARE_EVENT_CLASS(xfs_da_class,TP_STRUCT__entry (__field (dev_t ,dev )__field (xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len)__field (int, namelen)__field (xfs_dahash_t, hashval) __field(xfs_ino_t, inumber)@@ -1642,9 +1642,10 @@ DECLARE_EVENT_CLASS(xfs_da_class,TP_fast_assign ( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; -if (args->namelen) -memcpy (__get_str (name), args->name, args->namelen); - __entry->namelen = args->namelen; +if (args->name.len) +memcpy (__get_str (name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->hashval = args->hashval; __entry->inumber = args->inumber; __entry->op_flags = args->op_flags;@@ -1697,7 +1698,7 @@ DECLARE_EVENT_CLASS(xfs_attr_class,TP_STRUCT__entry (__field (dev_t ,dev )__field (xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len)__field (int, namelen)__field (int, valuelen) __field(xfs_dahash_t, hashval)@@ -1707,12 +1708,13 @@ DECLARE_EVENT_CLASS(xfs_attr_class,TP_fast_assign ( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; -if (args->namelen) -memcpy (__get_str (name), args->name, args->namelen); - __entry->namelen = args->namelen; +if (args->name.len) +memcpy (__get_str (name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->valuelen = args->valuelen; __entry->hashval = args->hashval; - __entry->flags = args->flags; + __entry->flags = args->name.type; __entry->op_flags = args->op_flags; ), TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d "
Signature · 1 line
chandan
Re: [PATCH v7 02/19] xfs: Embed struct xfs_name in xfs_da_args
Quoted 11 lines · Chandan Rajendra
Quoted 4 lines · Allison Collins
This patch embeds an
xfs_nameinxfs_da_args, replacing the name, namelen, and flags members. This helps to clean up thexfs_da_argsstructure and make it more uniform with the newxfs_nameparameter being passed around.The statement "name = &args.name;" in
xfs_attr_set()andxfs_attr_remove()was not apparent to me on first read. However your explaination to Amir's question about name.type being set inxfs_attr_args_init()made it clear.Reviewed-by Chandan Rajendra <[email protected]>
Alrighty, thanks for the review!
Allison
Quoted 771 lines
Quoted 769 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 37 +++++++------- fs/xfs/libxfs/xfs_attr_leaf.c | 104 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 6 ++- fs/xfs/libxfs/xfs_da_btree.h | 4 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++---- fs/xfs/libxfs/xfs_dir2_block.c | 6 +-- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +-- fs/xfs/libxfs/xfs_dir2_node.c | 8 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 30 ++++++------ fs/xfs/scrub/attr.c | 12 ++--- fs/xfs/xfs_trace.h | 20 ++++---- 12 files changed, 130 insertions(+), 123 deletions(-)fs/xfs/libxfs/xfs_attr.c +21
-16@@ -72,13 +72,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 ; }@@ -236,7 +235,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 )@@ -357,6 +356,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 ;@@ -372,7 +374,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)@@ -457,6 +459,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 @@ -532,10 +537,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)@@ -545,15 +550,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)@@ -598,11 +603,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; }@@ -872,10 +877,10 @@ xfs_attr_node_addname( 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);fs/xfs/libxfs/xfs_attr_leaf.c +54
-50@@ -464,7 +464,7 @@ xfs_attr_copy_value(/* * No copy if all we have to do is get the length */ -if (args->flags &ATTR_KERNOVAL ) { +if (args->name.type &ATTR_KERNOVAL ) { args->valuelen = valuelen;return 0 ; }@@ -679,27 +679,27 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) {#ifdef DEBUG -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (args->name, sfe->nameval, args->namelen) !=0 ) +if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ;ASSERT (0 );#endif } offset = (char *)sfe - (char *)sf; - size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->namelen, args->valuelen); + size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen);xfs_idata_realloc (dp, size,XFS_ATTR_FORK ); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); - sfe->namelen = args->namelen; + sfe->namelen = args->name.len; sfe->valuelen = args->valuelen; - sfe->flags =XFS_ATTR_NSP_ARGS_TO_ONDISK (args->flags); -memcpy (sfe->nameval, args->name, args->namelen); -memcpy (&sfe->nameval[args->namelen], args->value, args->valuelen); + sfe->flags =XFS_ATTR_NSP_ARGS_TO_ONDISK (args->name.type); +memcpy (sfe->nameval, args->name.name, args->name.len); +memcpy (&sfe->nameval[args->name.len], args->value, args->valuelen); sf->hdr.count++;be16_add_cpu (&sf->hdr.totsize, size);xfs_trans_log_inode (args->trans, dp,XFS_ILOG_CORE |XFS_ILOG_ADATA );@@ -749,11 +749,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), base += size, i++) { size =XFS_ATTR_SF_ENTSIZE (sfe); -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (sfe->nameval, args->name, args->namelen) !=0 ) +if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ;break ; }@@ -816,11 +816,11 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (args->name, sfe->nameval, args->namelen) !=0 ) +if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ;return -EEXIST ; }@@ -847,13 +847,13 @@ xfs_attr_shortform_getvalue( sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -if (sfe->namelen != args->namelen) +if (sfe->namelen != args->name.len)continue ; -if (memcmp (args->name, sfe->nameval, args->namelen) !=0 ) +if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, sfe->flags)) +if (!xfs_attr_namesp_match (args->name.type, sfe->flags))continue ; -return xfs_attr_copy_value (args, &sfe->nameval[args->namelen], +return xfs_attr_copy_value (args, &sfe->nameval[args->name.len], sfe->valuelen); }return -ENOATTR ;@@ -912,13 +912,13 @@ xfs_attr_shortform_to_leaf( sfe = &sf->list[0 ];for (i =0 ; i < sf->hdr.count; i++) { - nargs.name = sfe->nameval; - nargs.namelen = sfe->namelen; - nargs.value = &sfe->nameval[nargs.namelen]; + nargs.name.name = sfe->nameval; + nargs.name.len = sfe->namelen; + nargs.value = &sfe->nameval[nargs.name.len]; nargs.valuelen = sfe->valuelen; nargs.hashval =xfs_da_hashname (sfe->nameval, sfe->namelen); - nargs.flags =XFS_ATTR_NSP_ONDISK_TO_ARGS (sfe->flags); + nargs.name.type =XFS_ATTR_NSP_ONDISK_TO_ARGS (sfe->flags); error =xfs_attr3_leaf_lookup_int (bp, &nargs);/* set a->index */ ASSERT (error == -ENOATTR ); error =xfs_attr3_leaf_add (bp, &nargs);@@ -1119,12 +1119,12 @@ xfs_attr3_leaf_to_shortform(continue ;ASSERT (entry->flags &XFS_ATTR_LOCAL ); name_loc =xfs_attr3_leaf_name_local (leaf, i); - nargs.name = name_loc->nameval; - nargs.namelen = name_loc->namelen; - nargs.value = &name_loc->nameval[nargs.namelen]; + nargs.name.name = name_loc->nameval; + nargs.name.len = name_loc->namelen; + nargs.value = &name_loc->nameval[nargs.name.len]; nargs.valuelen =be16_to_cpu (name_loc->valuelen); nargs.hashval =be32_to_cpu (entry->hashval); - nargs.flags =XFS_ATTR_NSP_ONDISK_TO_ARGS (entry->flags); + nargs.name.type =XFS_ATTR_NSP_ONDISK_TO_ARGS (entry->flags);xfs_attr_shortform_add (&nargs, forkoff); } error =0 ;@@ -1450,7 +1450,7 @@ xfs_attr3_leaf_add_work( ichdr->freemap[mapindex].size); entry->hashval =cpu_to_be32 (args->hashval); entry->flags = tmp ?XFS_ATTR_LOCAL :0 ; - entry->flags |=XFS_ATTR_NSP_ARGS_TO_ONDISK (args->flags); + entry->flags |=XFS_ATTR_NSP_ARGS_TO_ONDISK (args->name.type);if (args->op_flags &XFS_DA_OP_RENAME ) { entry->flags |=XFS_ATTR_INCOMPLETE ; if ((args->blkno2 == args->blkno) &&@@ -1474,15 +1474,16 @@ xfs_attr3_leaf_add_work(*/ if (entry->flags &XFS_ATTR_LOCAL ) { name_loc =xfs_attr3_leaf_name_local (leaf, args->index); - name_loc->namelen = args->namelen; + name_loc->namelen = args->name.len; name_loc->valuelen =cpu_to_be16 (args->valuelen); -memcpy ((char *)name_loc->nameval, args->name, args->namelen); -memcpy ((char *)&name_loc->nameval[args->namelen], args->value, +memcpy ((char *)name_loc->nameval, args->name.name, + args->name.len); +memcpy ((char *)&name_loc->nameval[args->name.len], args->value,be16_to_cpu (name_loc->valuelen)); }else { name_rmt =xfs_attr3_leaf_name_remote (leaf, args->index); - name_rmt->namelen = args->namelen; -memcpy ((char *)name_rmt->name, args->name, args->namelen); + name_rmt->namelen = args->name.len; +memcpy ((char *)name_rmt->name, args->name.name, args->name.len); entry->flags |=XFS_ATTR_INCOMPLETE ;/* just in case */ name_rmt->valuelen =0 ;@@ -2409,23 +2410,25 @@ xfs_attr3_leaf_lookup_int( }if (entry->flags &XFS_ATTR_LOCAL ) { name_loc =xfs_attr3_leaf_name_local (leaf, probe); -if (name_loc->namelen != args->namelen) +if (name_loc->namelen != args->name.len)continue ; -if (memcmp (args->name, name_loc->nameval, - args->namelen) !=0 ) +if (memcmp (args->name.name, name_loc->nameval, + args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, entry->flags)) +if (!xfs_attr_namesp_match (args->name.type, + entry->flags))continue ; args->index = probe;return -EEXIST ; }else { name_rmt =xfs_attr3_leaf_name_remote (leaf, probe); -if (name_rmt->namelen != args->namelen) +if (name_rmt->namelen != args->name.len)continue ; -if (memcmp (args->name, name_rmt->name, - args->namelen) !=0 ) +if (memcmp (args->name.name, name_rmt->name, + args->name.len) !=0 )continue ; -if (!xfs_attr_namesp_match (args->flags, entry->flags)) +if (!xfs_attr_namesp_match (args->name.type, + entry->flags))continue ; args->index = probe; args->rmtvaluelen =be32_to_cpu (name_rmt->valuelen);@@ -2467,16 +2470,17 @@ xfs_attr3_leaf_getvalue( entry = &xfs_attr3_leaf_entryp (leaf)[args->index];if (entry->flags &XFS_ATTR_LOCAL ) { name_loc =xfs_attr3_leaf_name_local (leaf, args->index); -ASSERT (name_loc->namelen == args->namelen); -ASSERT (memcmp (args->name, name_loc->nameval, args->namelen) ==0 ); +ASSERT (name_loc->namelen == args->name.len); +ASSERT (memcmp (args->name.name, name_loc->nameval, + args->name.len) ==0 );return xfs_attr_copy_value (args, - &name_loc->nameval[args->namelen], + &name_loc->nameval[args->name.len],be16_to_cpu (name_loc->valuelen)); } name_rmt =xfs_attr3_leaf_name_remote (leaf, args->index); -ASSERT (name_rmt->namelen == args->namelen); -ASSERT (memcmp (args->name, name_rmt->name, args->namelen) ==0 ); +ASSERT (name_rmt->namelen == args->name.len); +ASSERT (memcmp (args->name.name, name_rmt->name, args->name.len) ==0 ); args->rmtvaluelen =be32_to_cpu (name_rmt->valuelen); args->rmtblkno =be32_to_cpu (name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount,@@ -2692,7 +2696,7 @@ xfs_attr_leaf_newentsize( {int size; - size =xfs_attr_leaf_entsize_local (args->namelen, args->valuelen); + size =xfs_attr_leaf_entsize_local (args->name.len, args->valuelen);if (size <xfs_attr_leaf_entsize_local_max (args->geo->blksize)) {if (local) *local =1 ;@@ -2700,7 +2704,7 @@ xfs_attr_leaf_newentsize( }if (local) *local =0 ; -return xfs_attr_leaf_entsize_remote (args->namelen); +return xfs_attr_leaf_entsize_remote (args->name.len); }@@ -2754,8 +2758,8 @@ xfs_attr3_leaf_clearflag( name = (char *)name_rmt->name; }ASSERT (be32_to_cpu (entry->hashval) == args->hashval); -ASSERT (namelen == args->namelen); -ASSERT (memcmp (name, args->name, namelen) ==0 ); +ASSERT (namelen == args->name.len); +ASSERT (memcmp (name, args->name.name, namelen) ==0 );#endif /* DEBUG */ entry->flags &= ~XFS_ATTR_INCOMPLETE ;fs/xfs/libxfs/xfs_attr_remote.c +1
-1@@ -397,7 +397,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;fs/xfs/libxfs/xfs_da_btree.c +4
-2@@ -2125,8 +2125,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 ; }int fs/xfs/libxfs/xfs_da_btree.h +1
-3@@ -54,12 +54,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 */fs/xfs/libxfs/xfs_dir2.c +7
-11@@ -74,14 +74,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 ; }@@ -265,8 +265,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = inum;@@ -361,8 +360,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 =xfs_dir2_hashname (dp->i_mount, name); args->dp = dp;@@ -433,8 +431,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = ino;@@ -494,8 +491,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 =xfs_dir2_hashname (dp->i_mount, name); args->inumber = inum;fs/xfs/libxfs/xfs_dir2_block.c +3
-3@@ -355,7 +355,7 @@ xfs_dir2_block_addname(if (error)return error; - len =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + len =xfs_dir2_data_entsize (dp->i_mount, args->name.len);/* * Set up pointers to parts of the block. @@ -539,8 +539,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_leaf.c +3
-3@@ -653,7 +653,7 @@ xfs_dir2_leaf_addname(xfs_dir2_leaf_hdr_from_disk (dp->i_mount, &leafhdr, leaf); ents = leafhdr.ents; bestsp =xfs_dir2_leaf_bests_p (ltp); - length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->name.len);/* * See if there are any entries with the same hash value @@ -856,8 +856,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_node.c +4
-4@@ -666,7 +666,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 =xfs_dir2_data_entsize (mp, args->namelen); + length =xfs_dir2_data_entsize (mp, args->name.len);/* * Loop over leaf entries with the right hash value. */ @@ -1911,7 +1911,7 @@ xfs_dir2_node_addname_int(int needscan =0 ;/* need to rescan data frees */ __be16 *tagp;/* data entry tag pointer */ - length =xfs_dir2_data_entsize (dp->i_mount, args->namelen); + length =xfs_dir2_data_entsize (dp->i_mount, args->name.len); error =xfs_dir2_node_find_freeblk (args, fblk, &dbno, &fbp, &freehdr, &findex, length);if (error)@@ -1966,8 +1966,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);xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_sf.c +15
-15@@ -387,7 +387,7 @@ xfs_dir2_sf_addname(/* * Compute entry (and change in) size. */ - incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->namelen); + incr_isize =xfs_dir2_sf_entsize (dp->i_mount, sfp, args->name.len); objchange =0 ;/* @@ -470,7 +470,7 @@ xfs_dir2_sf_addname_easy(/* * Grow the in-inode space. */ -xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->namelen), +xfs_idata_realloc (dp,xfs_dir2_sf_entsize (mp, sfp, args->name.len),XFS_DATA_FORK );/* * Need to set up again due to realloc of the inode data. @@ -480,9 +480,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);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber);xfs_dir2_sf_put_ftype (mp, sfep, args->filetype);@@ -540,7 +540,7 @@ xfs_dir2_sf_addname_hard(*/ for (offset = args->geo->data_first_offset, oldsfep = xfs_dir2_sf_firstentry(oldsfp), - add_datasize = xfs_dir2_data_entsize(mp, args->namelen), + add_datasize = xfs_dir2_data_entsize(mp, args->name.len), eof = (char *)oldsfep == &buf[old_isize]; !eof; offset = new_offset + xfs_dir2_data_entsize(mp, oldsfep->namelen),@@ -570,9 +570,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);xfs_dir2_sf_put_ino (mp, sfp, sfep, args->inumber);xfs_dir2_sf_put_ftype (mp, sfep, args->filetype); sfp->count++;@@ -615,7 +615,7 @@ xfs_dir2_sf_addname_pick(int used;/* data bytes used */ sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; - size =xfs_dir2_data_entsize (mp, args->namelen); + size =xfs_dir2_data_entsize (mp, args->name.len); offset = args->geo->data_first_offset; sfep =xfs_dir2_sf_firstentry (sfp); holefit =0 ;@@ -887,7 +887,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 ;@@ -896,8 +896,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 =xfs_dir2_sf_get_parent_ino (sfp); args->cmpresult =XFS_CMP_EXACT ; args->filetype =XFS_DIR3_FT_DIR ;@@ -984,7 +984,7 @@ xfs_dir2_sf_removename(* Calculate sizes. */ byteoff = (int )((char *)sfep - (char *)sfp); - entsize =xfs_dir2_sf_entsize (mp, sfp, args->namelen); + entsize =xfs_dir2_sf_entsize (mp, sfp, args->name.len); newsize = oldsize - entsize;/* * Copy the part if any after the removed entry, sliding it down. @@ -1085,12 +1085,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 =xfs_dir2_sf_get_parent_ino (sfp);ASSERT (args->inumber != ino);xfs_dir2_sf_put_parent_ino (sfp, args->inumber);fs/xfs/scrub/attr.c +6
-6@@ -147,17 +147,17 @@ xchk_xattr_listent(return ; } - args.flags =ATTR_KERNOTIME ; + args.name.type =ATTR_KERNOTIME ;if (flags &XFS_ATTR_ROOT ) - args.flags |=ATTR_ROOT ; + args.name.type |=ATTR_ROOT ;else if (flags &XFS_ATTR_SECURE ) - args.flags |=ATTR_SECURE ; + args.name.type |=ATTR_SECURE ; args.geo = context->dp->i_mount->m_attr_geo; args.whichfork =XFS_ATTR_FORK ; args.dp = context->dp; - args.name = name; - args.namelen = namelen; - args.hashval =xfs_da_hashname (args.name, args.namelen); + args.name.name = name; + args.name.len = namelen; + args.hashval =xfs_da_hashname (args.name.name, args.name.len); args.trans = context->tp; args.value =xchk_xattr_valuebuf (sx->sc); args.valuelen = valuelen;fs/xfs/xfs_trace.h +11
-9@@ -1633,7 +1633,7 @@ DECLARE_EVENT_CLASS(xfs_da_class,TP_STRUCT__entry (__field (dev_t ,dev )__field (xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len)__field (int, namelen)__field (xfs_dahash_t, hashval) __field(xfs_ino_t, inumber)@@ -1642,9 +1642,10 @@ DECLARE_EVENT_CLASS(xfs_da_class,TP_fast_assign ( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; -if (args->namelen) -memcpy (__get_str (name), args->name, args->namelen); - __entry->namelen = args->namelen; +if (args->name.len) +memcpy (__get_str (name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->hashval = args->hashval; __entry->inumber = args->inumber; __entry->op_flags = args->op_flags;@@ -1697,7 +1698,7 @@ DECLARE_EVENT_CLASS(xfs_attr_class,TP_STRUCT__entry (__field (dev_t ,dev )__field (xfs_ino_t, ino) - __dynamic_array(char, name, args->namelen) + __dynamic_array(char, name, args->name.len)__field (int, namelen)__field (int, valuelen) __field(xfs_dahash_t, hashval)@@ -1707,12 +1708,13 @@ DECLARE_EVENT_CLASS(xfs_attr_class,TP_fast_assign ( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; __entry->ino = args->dp->i_ino; -if (args->namelen) -memcpy (__get_str (name), args->name, args->namelen); - __entry->namelen = args->namelen; +if (args->name.len) +memcpy (__get_str (name), args->name.name, + args->name.len); + __entry->namelen = args->name.len; __entry->valuelen = args->valuelen; __entry->hashval = args->hashval; - __entry->flags = args->flags; + __entry->flags = args->name.type; __entry->op_flags = args->op_flags; ), TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d "
PATCH v7 3/19 xfs: Add xfs_has_attr and subroutines
In reply to Allison CollinsFrom: Allison Henderson <[email protected]>
This 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.
--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)
fs/xfs/libxfs/xfs_attr.c +114 -57
@@ -46,6 +46,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.
@@ -53,6 +54,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);
@@ -310,6 +313,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
@@ -583,26 +617,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, &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;
@@ -754,6 +782,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 , 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
@@ -773,12 +822,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, &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;
@@ -817,12 +865,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, &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;
@@ -832,6 +878,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 *========================================================================*/
@@ -864,20 +945,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 && retval != -EEXIST ) 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 (retval == -ENOATTR && args->name.type &ATTR_REPLACE ) { goto out; }else if (retval == -EEXIST ) {if (args->name.type &ATTR_CREATE )
@@ -1079,29 +1157,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.
@@ -1196,7 +1260,8 @@ xfs_attr_node_removename( error =0 ; out: -xfs_da_state_free (state); +if (state) +xfs_da_state_free (state);return error; }
@@ -1316,31 +1381,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.
@@ -1352,7 +1409,7 @@ xfs_attr_node_get(xfs_da_args_t *args) }xfs_da_state_free (state); -return retval; +return error; }/* Returns true if the attribute entry name is valid. */
fs/xfs/libxfs/xfs_attr.h +1 -0
@@ -153,6 +153,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);
fs/xfs/libxfs/xfs_attr_leaf.c +70 -41
141 lines not on this page · raw message
fs/xfs/libxfs/xfs_attr_leaf.h +3 -0
@@ -53,6 +53,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
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 40 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +3
-0@@ -46,6 +46,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. @@ -53,6 +54,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);
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 316
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +1
-0@@ -310,6 +313,37 @@ xfs_attr_set_args( }/* +* Return EEXIST if attr is found, or ENOATTR if not
This is a very silly return value for a function named has_attr in my taste. I realize you inherited this interface from xfs_attr3_leaf_lookup_int(), but IMO this change looks like a very good opportunity to change that internal API:
xfs_has_attr?
0: NO
1: YES (or stay with the syscall standard of -ENOATTR) <0: error
Quoted 53 lines
fs/xfs/libxfs/xfs_attr.c +31
-9+*/ +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 @@ -583,26 +617,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, &bp); -if (error) -return error; -
fs/xfs/libxfs/xfs_attr.c STATIC int · line 634
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +4
-2-/* * 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 )) {
Example of how sane code (in my taste) would look like:
retval = xfs_attr_leaf_hasname(args, &bp);
if (retval < 0)
return retval;
if ((args->name.type & ATTR_REPLACE) && !retval) {
xfs_trans_brelse(args->trans, bp);
return -ENOATTR;
} else if (retval) {
if (args->flags & ATTR_CREATE) { /* pure create op */
xfs_trans_brelse(args->trans, bp);
return -EEXIST;
}Thanks,
Amir.
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 52 lines · Amir Goldstein
Quoted 40 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +3
-0@@ -46,6 +46,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. @@ -53,6 +54,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);fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 316
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +1
-0@@ -310,6 +313,37 @@ xfs_attr_set_args( }/* +* Return EEXIST if attr is found, or ENOATTR if not This is a very silly return value for a function named
has_attrin my taste. I realize you inherited this interface fromxfs_attr3_leaf_lookup_int(), but IMO this change looks like a very good opportunity to change that internal API:
Quoted 5 lines
xfs_has_attr?0: NO
1: YES (or stay with the syscall standard of-ENOATTR) <0: error
Darrick had mentioned something like that in the last revision, but I think people wanted to keep everything a straight hoist at this phase. At least as much as possible. Maybe I can add another patch that does this at the end when we're doing clean ups.
Allison
Quoted 83 lines
Quoted 54 lines
fs/xfs/libxfs/xfs_attr.c +31
-9+*/ +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 @@ -583,26 +617,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, &bp); -if (error) -return error; -fs/xfs/libxfs/xfs_attr.c STATIC int · line 634
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +4
-2-/* * 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 )) {Example of how sane code (in my taste) would look like:
retval = xfs_attr_leaf_hasname(args, &bp); if (retval < 0) return retval; if ((args->name.type & ATTR_REPLACE) && !retval) { xfs_trans_brelse(args->trans, bp); return -ENOATTR; } else if (retval) { if (args->flags & ATTR_CREATE) { /* pure create op */ xfs_trans_brelse(args->trans, bp); return -EEXIST; }Thanks,
Amir.
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 58 lines · Allison Collins
Quoted 54 lines · Amir Goldstein
Quoted 40 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +3
-0@@ -46,6 +46,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. @@ -53,6 +54,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);fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 316
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +1
-0@@ -310,6 +313,37 @@ xfs_attr_set_args( }/* +* Return EEXIST if attr is found, or ENOATTR if not This is a very silly return value for a function named
has_attrin my taste. I realize you inherited this interface fromxfs_attr3_leaf_lookup_int(), but IMO this change looks like a very good opportunity to change that internal API:
xfs_has_attr?
Quoted 7 lines
Quoted 3 lines
0: NO
1: YES (or stay with the syscall standard of-ENOATTR) <0: errorDarrick had mentioned something like that in the last revision, but I think people wanted to keep everything a straight hoist at this phase. At least as much as possible. Maybe I can add another patch that does this at the end when we're doing clean ups.
In my opinion, this change is hard enough to follow as is. Making the interface cleaner at this point is not going to make following the change any harder if anything I thing a clean interface that makes sense, will make things easier at this point.
But whether you do it now or later, the interface was very bad IMO before and when attached to a helper named has_attr makes it much worse.
Thanks,
Amir.
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
In reply to Amir GoldsteinQuoted 44 lines · Amir Goldstein
Quoted 42 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +3
-0@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,37 @@ xfs_attr_set_args( }
Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 316
Quoted 2 lines
fs/xfs/libxfs/xfs_attr.c +1
-0/* +* Return EEXIST if attr is found, or ENOATTR if not This is a very silly return value for a function named
has_attrin my taste. I realize you inherited this interface fromxfs_attr3_leaf_lookup_int(), but IMO this change looks like a very good opportunity to change that internal API:
tl;dr Cleaning up this API is work for another patchset.
Quoted 6 lines
xfs_has_attr?0: NO
1: YES (or stay with the syscall standard of-ENOATTR) <0: error
While I agree with your sentiment, Amir, the API you suggest is an anti-pattern. We've been removing ternary return value APIs like this from XFS and replacing them with an explicit error return value and an operational return parameter like so:
error = xfs_has_attr(&exists)
if (error)
return error;
if (!exists && REPLACE) {
error = -ENOATTR;
goto out_error_release;
}
if (exists && CREATE) {
error = -EEXIST;
goto out_error_release;
}
.....out_error_release:
xfs_trans_brelse(args->trans, bp); return error;
This allows us to separate out fatal metadata fetch and parsing errors from the operational logic that is run on the status returned from a successful function call.
IMO, this sort of API change needs to be driven right down into the internal functions that generate ENOATTR/EEXIST in the first place. Otherwise all we are doing here is forcing the new code to translate ENOATTR/EEXIST to some intermediate error code that the higher layer code then has to convert back to ENOATTR/EEXIST so that it's callers function properly.
Hence I don't think chagning this API just for this new function makes the code simpler or easier to maintain. And I don't really think changing the entire API is in the scope of this work. Hence, even though I don't like the API, I think it is fine to be retained for this patchset.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 63 lines · Dave Chinner
Quoted 44 lines · Amir Goldstein
Quoted 42 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +3
-0@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,37 @@ xfs_attr_set_args( }Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 316
Quoted 2 lines
fs/xfs/libxfs/xfs_attr.c +1
-0/* +* Return EEXIST if attr is found, or ENOATTR if not This is a very silly return value for a function named
has_attrin my taste. I realize you inherited this interface fromxfs_attr3_leaf_lookup_int(), but IMO this change looks like a very good opportunity to change that internal API:tl;dr Cleaning up this API is work for another patchset.
Quoted 6 lines
xfs_has_attr?0: NO
1: YES (or stay with the syscall standard of-ENOATTR) <0: error
Quoted 9 lines
While I agree with your sentiment, Amir, the API you suggest is an anti-pattern. We've been removing ternary return value APIs like this from XFS and replacing them with an explicit error return value and an operational return parameter like so:
error =
xfs_has_attr(&exists)
if (error)
return error;
That would be neat and tidy.
One of the outcomes of new reviewers is comments on code unrelated to the changes... I have no problem of keeping API as is for Allison's change, but I did want to point out that the API became worse to read due to the helper name change from _lookup_attr to _has_attr, which really asks for a yes or no answer.
Thanks,
Amir.
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 74 lines · Amir Goldstein
Quoted 63 lines · Dave Chinner
Quoted 44 lines · Amir Goldstein
Quoted 42 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +3
-0@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,37 @@ xfs_attr_set_args( }Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 316
Quoted 2 lines
fs/xfs/libxfs/xfs_attr.c +1
-0/* +* Return EEXIST if attr is found, or ENOATTR if not This is a very silly return value for a function named
has_attrin my taste. I realize you inherited this interface fromxfs_attr3_leaf_lookup_int(), but IMO this change looks like a very good opportunity to change that internal API:tl;dr Cleaning up this API is work for another patchset.
Quoted 6 lines
xfs_has_attr?0: NO
1: YES (or stay with the syscall standard of-ENOATTR) <0: errorQuoted 9 lines
While I agree with your sentiment, Amir, the API you suggest is an anti-pattern. We've been removing ternary return value APIs like this from XFS and replacing them with an explicit error return value and an operational return parameter like so:
error =
xfs_has_attr(&exists)
if (error)
return error;
Quoted 7 lines
That would be neat and tidy.
One of the outcomes of new reviewers is comments on code unrelated to the changes... I have no problem of keeping API as is for Allison's change, but I did want to point out that the API became worse to read due to the helper name change from
_lookup_attrto_has_attr, which really asks for a yes or no answer.
No argument from me on that. :P
But we really need to make progress on the new attribute features rather than get bogged down in completely rewriting the attribute code because it's a bit gross and smelly. The smell can be removed later...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
In reply to Allison CollinsQuoted 21 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0
...
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +6
-0@@ -310,6 +313,37 @@ xfs_attr_set_args( }/* +* Return EEXIST if attr is found, or ENOATTR if not +*/ +int +xfs_has_attr ( +struct xfs_da_args *args) +{
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 331
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +10
-0+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 );
Nit: any reason we use "findname" here and "hasname" for the other two variants?
Just a few other nit level things..
Quoted 18 lines
fs/xfs/libxfs/xfs_attr.c +15
-0+ } + +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
...
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +0
-0@@ -773,12 +822,11 @@ xfs_attr_leaf_removename(* Remove the attribute. */ dp = args->dp;
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_removename( · line 830
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +3
-4- args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &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 ) {
It looks like some of these error checks could be cleaned up where the helper function is used. I.e., something like the following here:
if (error == -ENOATTR) {
xfs_trans_brelse(...);
return error;
} else if (error != -EEXIST)
return error;Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c +0
-1xfs_trans_brelse (args->trans, bp);return error;@@ -817,12 +865,10 @@ xfs_attr_leaf_get(xfs_da_args_t *args)trace_xfs_attr_leaf_get (args); - args->blkno =0 ;
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 874
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +2
-3- error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &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;
Similar thing here, just reordering the checks simplifies the logic.
Quoted 42 lines
fs/xfs/libxfs/xfs_attr.c +35
-0@@ -832,6 +878,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 *========================================================================*/
...
Quoted 37 lines
fs/xfs/libxfs/xfs_attr.c +4
-12@@ -1316,31 +1381,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.
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_get(xfs_da_args_t *args) · line 1411
Quoted 3 lines
fs/xfs/libxfs/xfs_attr.c +0
-0@@ -1352,7 +1409,7 @@ xfs_attr_node_get(xfs_da_args_t *args) }xfs_da_state_free (state);
Do we need an 'if (state)' check here like the other node funcs?
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1-return retval; +return error; }/* Returns true if the attribute entry name is valid. */
...
Quoted 24 lines
fs/xfs/libxfs/xfs_attr_leaf.c +16
-0@@ -654,18 +654,66 @@ xfs_attr_shortform_create(xfs_da_args_t *args) }/* +* Return -EEXIST if attr is found, or -ENOATTR if not +* args: args containing attribute name and namelen +* sfep: If not null, pointer will be set to the last attr entry found on +-EEXIST. On -ENOATTR pointer is left at the last entry in the list +* basep: If not null, pointer is set to the byte offset of the entry in the +* list on -EEXIST. On -ENOATTR, pointer is left at the byte offset of +* the last entry in the list +*/ +int +xfs_attr_sf_findname ( +struct xfs_da_args *args, +struct xfs_attr_sf_entry **sfep, +unsigned int *basep) +{ +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe;
fs/xfs/libxfs/xfs_attr_leaf.c xfs_attr_shortform_create(xfs_da_args_t *args) · line 682
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_leaf.c +10
-0+unsigned int base =sizeof (struct xfs_attr_sf_hdr ); +int size =0 ; +int end; +int i; + + sf = (struct xfs_attr_shortform *)args->dp->i_afp->if_u1.if_data; + sfe = &sf->list[0 ]; + end = sf->hdr.count; +for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), + base += size, i++) {
Slightly more readable to align indendation with the sfe assignment above.
Brian
Quoted 131 lines
fs/xfs/libxfs/xfs_attr_leaf.c +44
-41+ size =XFS_ATTR_SF_ENTSIZE (sfe); +if (sfe->namelen != args->name.len) +continue ; +if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) +continue ; +if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) +continue ; +break ; + } + +if (sfep !=NULL ) + *sfep = sfe; + +if (basep !=NULL ) + *basep = base; + +if (i == end) +return -ENOATTR ; +return -EEXIST ; +} + +/* * Add a name/value pair to the shortform attribute list. * Overflow from the inode has already been checked for. */ void -xfs_attr_shortform_add (xfs_da_args_t *args,int forkoff) +xfs_attr_shortform_add (struct xfs_da_args *args,int forkoff) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int i, offset, size; -xfs_mount_t *mp; -xfs_inode_t *dp; -struct xfs_ifork *ifp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int offset, size, error; +struct xfs_mount *mp; +struct xfs_inode *dp; +struct xfs_ifork *ifp;trace_xfs_attr_sf_add (args);@@ -676,18 +724,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) ifp = dp->i_afp;ASSERT (ifp->if_flags &XFS_IFINLINE ); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; - sfe = &sf->list[0 ]; -for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -#ifdef DEBUG -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -ASSERT (0 ); -#endif - } + error =xfs_attr_sf_findname (args, &sfe,NULL ); +ASSERT (error != -EEXIST ); offset = (char *)sfe - (char *)sf; size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen);@@ -730,35 +768,26 @@ xfs_attr_fork_remove(* Remove an attribute from the shortform attribute list structure. */ int -xfs_attr_shortform_remove (xfs_da_args_t *args) +xfs_attr_shortform_remove (struct xfs_da_args *args) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int base, size=0 , end, totsize, i; -xfs_mount_t *mp; -xfs_inode_t *dp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int size =0 , end, totsize; +unsigned int base; +struct xfs_mount *mp; +struct xfs_inode *dp; +int error;trace_xfs_attr_sf_remove (args); dp = args->dp; mp = dp->i_mount; - base =sizeof (xfs_attr_sf_hdr_t); sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; - sfe = &sf->list[0 ]; - end = sf->hdr.count; -for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), - base += size, i++) { - size =XFS_ATTR_SF_ENTSIZE (sfe); -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -break ; - } -if (i == end) -return -ENOATTR ; + + error =xfs_attr_sf_findname (args, &sfe, &base); +if (error != -EEXIST ) +return error; + size =XFS_ATTR_SF_ENTSIZE (sfe);/* * Fix up the attribute fork data, covering the hole fs/xfs/libxfs/xfs_attr_leaf.h +3
-0@@ -53,6 +53,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
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 38 lines · Brian Foster
Quoted 21 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0...
Quoted 15 lines
fs/xfs/libxfs/xfs_attr.c +11
-0@@ -310,6 +313,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))
Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 331
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +5
-0+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 );Nit: any reason we use "findname" here and "hasname" for the other two variants?
It was asked for in the v4 review. Reason being we also return the location of the sf entry and byte offset.
Quoted 40 lines
Just a few other nit level things..
Quoted 18 lines
fs/xfs/libxfs/xfs_attr.c +15
-0+ } + +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 ...
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +0
-0@@ -773,12 +822,11 @@ xfs_attr_leaf_removename(* Remove the attribute. */ dp = args->dp;fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_removename( · line 830
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +3
-4- args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &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 ) {It looks like some of these error checks could be cleaned up where the helper function is used. I.e., something like the following here:
Quoted 5 lines
if (error == -ENOATTR) {
xfs_trans_brelse(...);
return error;
} else if (error != -EEXIST)
return error;Sure, I'm starting to get more pressure in other reviews to change this api to a boolean return type though (1: y, 0: no, <0: error). I think we talked about this in v3, but decided to stick with this original api for now. I'm thinking maybe adding a patch at the end to shift the api might be a good compromise? Thoughts?
Quoted 14 lines
Quoted 14 lines
fs/xfs/libxfs/xfs_attr.c +2
-3xfs_trans_brelse (args->trans, bp);return error;@@ -817,12 +865,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, &bp); -if (error) + error =xfs_attr_leaf_hasname (args, &bp); +if (error != -ENOATTR && error != -EEXIST )return error;
Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 874
Quoted 4 lines
fs/xfs/libxfs/xfs_attr.c +0
-1- error =xfs_attr3_leaf_lookup_int (bp, args);if (error != -EEXIST ) {xfs_trans_brelse (args->trans, bp);return error;Similar thing here, just reordering the checks simplifies the logic.
Sure, will do.
Quoted 78 lines
Quoted 43 lines
fs/xfs/libxfs/xfs_attr.c +35
-0@@ -832,6 +878,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 *========================================================================*/ ...
Quoted 34 lines
fs/xfs/libxfs/xfs_attr.c +4
-12@@ -1316,31 +1381,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);
Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_get(xfs_da_args_t *args) · line 1411
Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +0
-0/* * If not in a transaction, we have to release all the buffers. @@ -1352,7 +1409,7 @@ xfs_attr_node_get(xfs_da_args_t *args) }xfs_da_state_free (state);Do we need an 'if (state)' check here like the other node funcs?
I think so, because if xfs_attr_node_hasname errors out it releases the state. Will add.
Quoted 36 lines
Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +1
-1-return retval; +return error; }/* Returns true if the attribute entry name is valid. */ ...
Quoted 29 lines
fs/xfs/libxfs/xfs_attr_leaf.c +21
-0@@ -654,18 +654,66 @@ xfs_attr_shortform_create(xfs_da_args_t *args) }/* +* Return -EEXIST if attr is found, or -ENOATTR if not +* args: args containing attribute name and namelen +* sfep: If not null, pointer will be set to the last attr entry found on +-EEXIST. On -ENOATTR pointer is left at the last entry in the list +* basep: If not null, pointer is set to the byte offset of the entry in the +* list on -EEXIST. On -ENOATTR, pointer is left at the byte offset of +* the last entry in the list +*/ +int +xfs_attr_sf_findname ( +struct xfs_da_args *args, +struct xfs_attr_sf_entry **sfep, +unsigned int *basep) +{ +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +unsigned int base =sizeof (struct xfs_attr_sf_hdr ); +int size =0 ; +int end; +int i; +
Quoted 8 lines
fs/xfs/libxfs/xfs_attr_leaf.c xfs_attr_shortform_create(xfs_da_args_t *args) · line 682
Quoted 5 lines
fs/xfs/libxfs/xfs_attr_leaf.c +5
-0+ sf = (struct xfs_attr_shortform *)args->dp->i_afp->if_u1.if_data; + sfe = &sf->list[0 ]; + end = sf->hdr.count; +for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), + base += size, i++) {Slightly more readable to align indendation with the sfe assignment above.
Sure, will fix. Thanks!
Allison
Quoted 135 lines
Brian
Quoted 131 lines
fs/xfs/libxfs/xfs_attr_leaf.c +44
-41+ size =XFS_ATTR_SF_ENTSIZE (sfe); +if (sfe->namelen != args->name.len) +continue ; +if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) +continue ; +if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) +continue ; +break ; + } + +if (sfep !=NULL ) + *sfep = sfe; + +if (basep !=NULL ) + *basep = base; + +if (i == end) +return -ENOATTR ; +return -EEXIST ; +} + +/* * Add a name/value pair to the shortform attribute list. * Overflow from the inode has already been checked for. */ void -xfs_attr_shortform_add (xfs_da_args_t *args,int forkoff) +xfs_attr_shortform_add (struct xfs_da_args *args,int forkoff) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int i, offset, size; -xfs_mount_t *mp; -xfs_inode_t *dp; -struct xfs_ifork *ifp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int offset, size, error; +struct xfs_mount *mp; +struct xfs_inode *dp; +struct xfs_ifork *ifp;trace_xfs_attr_sf_add (args);@@ -676,18 +724,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) ifp = dp->i_afp;ASSERT (ifp->if_flags &XFS_IFINLINE ); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; - sfe = &sf->list[0 ]; -for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -#ifdef DEBUG -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -ASSERT (0 ); -#endif - } + error =xfs_attr_sf_findname (args, &sfe,NULL ); +ASSERT (error != -EEXIST ); offset = (char *)sfe - (char *)sf; size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen);@@ -730,35 +768,26 @@ xfs_attr_fork_remove(* Remove an attribute from the shortform attribute list structure. */ int -xfs_attr_shortform_remove (xfs_da_args_t *args) +xfs_attr_shortform_remove (struct xfs_da_args *args) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int base, size=0 , end, totsize, i; -xfs_mount_t *mp; -xfs_inode_t *dp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int size =0 , end, totsize; +unsigned int base; +struct xfs_mount *mp; +struct xfs_inode *dp; +int error;trace_xfs_attr_sf_remove (args); dp = args->dp; mp = dp->i_mount; - base =sizeof (xfs_attr_sf_hdr_t); sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; - sfe = &sf->list[0 ]; - end = sf->hdr.count; -for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), - base += size, i++) { - size =XFS_ATTR_SF_ENTSIZE (sfe); -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -break ; - } -if (i == end) -return -ENOATTR ; + + error =xfs_attr_sf_findname (args, &sfe, &base); +if (error != -EEXIST ) +return error; + size =XFS_ATTR_SF_ENTSIZE (sfe);/* * Fix up the attribute fork data, covering the hole fs/xfs/libxfs/xfs_attr_leaf.h +3
-0@@ -53,6 +53,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
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 48 lines · Allison Collins
Quoted 37 lines · Brian Foster
Quoted 21 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0...
Quoted 14 lines
fs/xfs/libxfs/xfs_attr.c +11
-0@@ -310,6 +313,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))Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 331
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +5
-0+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 );Nit: any reason we use "findname" here and "hasname" for the other two variants?
Quoted 3 lines
It was asked for in the v4 review. Reason being we also return the location of the sf entry and byte offset.
Ok.
Quoted 44 lines
Quoted 39 lines
Just a few other nit level things..
Quoted 18 lines
fs/xfs/libxfs/xfs_attr.c +15
-0+ } + +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 ...
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_removename( · line 829
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c +3
-4@@ -773,12 +822,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, &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 ) {It looks like some of these error checks could be cleaned up where the helper function is used. I.e., something like the following here:
Quoted 5 lines
if (error == -ENOATTR) { xfs_trans_brelse(...); return error; } else if (error != -EEXIST) return error;
Quoted 6 lines
Sure, I'm starting to get more pressure in other reviews to change this api to a boolean return type though (1: y, 0: no, <0: error). I think we talked about this in v3, but decided to stick with this original api for now. I'm thinking maybe adding a patch at the end to shift the api might be a good compromise? Thoughts?
I think Dave commented on this earlier with regard to some of these API cleanups being orthogonal to this work. The big challenge with this series is really taking apart this big tangle of xattr code such that it has smaller components and is thus mostly reusable between dfops context for parent pointers etc. and the traditional codepath. I can see the appeal of such API cleanups (so it's good feedback overall), but I agree that it's probably wiser to allow this series to work with the interface style we have in the existing code and consider that type of thing as a follow on cleanup when the subsystem itself is more stabilized.
Brian
Quoted 278 lines
Quoted 17 lines
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +0
-0xfs_trans_brelse (args->trans, bp);return error;@@ -817,12 +865,10 @@ xfs_attr_leaf_get(xfs_da_args_t *args)trace_xfs_attr_leaf_get (args);fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 871
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +2
-4- args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &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;Similar thing here, just reordering the checks simplifies the logic.
Sure, will do.
Quoted 72 lines
Quoted 42 lines
fs/xfs/libxfs/xfs_attr.c +35
-0@@ -832,6 +878,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 *========================================================================*/ ...
Quoted 29 lines
fs/xfs/libxfs/xfs_attr.c +3
-12@@ -1316,31 +1381,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);Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_get(xfs_da_args_t *args) · line 1410
Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +1
-0+ error =xfs_attr3_leaf_getvalue (blk->bp, args);/* * If not in a transaction, we have to release all the buffers. @@ -1352,7 +1409,7 @@ xfs_attr_node_get(xfs_da_args_t *args) }xfs_da_state_free (state);Do we need an 'if (state)' check here like the other node funcs?
I think so, because if
xfs_attr_node_hasnameerrors out it releases the state. Will add.Quoted 34 lines
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1-return retval; +return error; }/* Returns true if the attribute entry name is valid. */ ...
Quoted 28 lines
fs/xfs/libxfs/xfs_attr_leaf.c +21
-0@@ -654,18 +654,66 @@ xfs_attr_shortform_create(xfs_da_args_t *args) }/* +* Return -EEXIST if attr is found, or -ENOATTR if not +* args: args containing attribute name and namelen +* sfep: If not null, pointer will be set to the last attr entry found on +-EEXIST. On -ENOATTR pointer is left at the last entry in the list +* basep: If not null, pointer is set to the byte offset of the entry in the +* list on -EEXIST. On -ENOATTR, pointer is left at the byte offset of +* the last entry in the list +*/ +int +xfs_attr_sf_findname ( +struct xfs_da_args *args, +struct xfs_attr_sf_entry **sfep, +unsigned int *basep) +{ +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +unsigned int base =sizeof (struct xfs_attr_sf_hdr ); +int size =0 ; +int end; +int i; +Quoted 8 lines
fs/xfs/libxfs/xfs_attr_leaf.c xfs_attr_shortform_create(xfs_da_args_t *args) · line 682
Quoted 5 lines
fs/xfs/libxfs/xfs_attr_leaf.c +5
-0+ sf = (struct xfs_attr_shortform *)args->dp->i_afp->if_u1.if_data; + sfe = &sf->list[0 ]; + end = sf->hdr.count; +for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), + base += size, i++) {Slightly more readable to align indendation with the sfe assignment above.
Sure, will fix. Thanks!
Allison
Quoted 129 lines
Brian
Quoted 125 lines
fs/xfs/libxfs/xfs_attr_leaf.c +44
-41+ size =XFS_ATTR_SF_ENTSIZE (sfe); +if (sfe->namelen != args->name.len) +continue ; +if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) +continue ; +if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) +continue ; +break ; + } + +if (sfep !=NULL ) + *sfep = sfe; + +if (basep !=NULL ) + *basep = base; + +if (i == end) +return -ENOATTR ; +return -EEXIST ; +} + +/* * Add a name/value pair to the shortform attribute list. * Overflow from the inode has already been checked for. */ void -xfs_attr_shortform_add (xfs_da_args_t *args,int forkoff) +xfs_attr_shortform_add (struct xfs_da_args *args,int forkoff) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int i, offset, size; -xfs_mount_t *mp; -xfs_inode_t *dp; -struct xfs_ifork *ifp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int offset, size, error; +struct xfs_mount *mp; +struct xfs_inode *dp; +struct xfs_ifork *ifp;trace_xfs_attr_sf_add (args);@@ -676,18 +724,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) ifp = dp->i_afp;ASSERT (ifp->if_flags &XFS_IFINLINE ); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; - sfe = &sf->list[0 ]; -for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -#ifdef DEBUG -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -ASSERT (0 ); -#endif - } + error =xfs_attr_sf_findname (args, &sfe,NULL ); +ASSERT (error != -EEXIST ); offset = (char *)sfe - (char *)sf; size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen);@@ -730,35 +768,26 @@ xfs_attr_fork_remove(* Remove an attribute from the shortform attribute list structure. */ int -xfs_attr_shortform_remove (xfs_da_args_t *args) +xfs_attr_shortform_remove (struct xfs_da_args *args) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int base, size=0 , end, totsize, i; -xfs_mount_t *mp; -xfs_inode_t *dp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int size =0 , end, totsize; +unsigned int base; +struct xfs_mount *mp; +struct xfs_inode *dp; +int error;trace_xfs_attr_sf_remove (args); dp = args->dp; mp = dp->i_mount; - base =sizeof (xfs_attr_sf_hdr_t); sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; - sfe = &sf->list[0 ]; - end = sf->hdr.count; -for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), - base += size, i++) { - size =XFS_ATTR_SF_ENTSIZE (sfe); -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -break ; - } -if (i == end) -return -ENOATTR ; + + error =xfs_attr_sf_findname (args, &sfe, &base); +if (error != -EEXIST ) +return error; + size =XFS_ATTR_SF_ENTSIZE (sfe);/* * Fix up the attribute fork data, covering the hole fs/xfs/libxfs/xfs_attr_leaf.h +3
-0@@ -53,6 +53,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
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 116 lines · Brian Foster
Quoted 48 lines · Allison Collins
Quoted 37 lines · Brian Foster
Quoted 21 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0...
Quoted 14 lines
fs/xfs/libxfs/xfs_attr.c +11
-0@@ -310,6 +313,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))Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 331
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +5
-0+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 );Nit: any reason we use "findname" here and "hasname" for the other two variants?
Quoted 3 lines
It was asked for in the v4 review. Reason being we also return the location of the sf entry and byte offset.
Ok.
Quoted 44 lines
Quoted 39 lines
Just a few other nit level things..
Quoted 18 lines
fs/xfs/libxfs/xfs_attr.c +15
-0+ } + +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 ...
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_removename( · line 829
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c +3
-4@@ -773,12 +822,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, &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 ) {It looks like some of these error checks could be cleaned up where the helper function is used. I.e., something like the following here:
Quoted 5 lines
if (error == -ENOATTR) { xfs_trans_brelse(...); return error; } else if (error != -EEXIST) return error;Quoted 6 lines
Sure, I'm starting to get more pressure in other reviews to change this api to a boolean return type though (1: y, 0: no, <0: error). I think we talked about this in v3, but decided to stick with this original api for now. I'm thinking maybe adding a patch at the end to shift the api might be a good compromise? Thoughts?
I think Dave commented on this earlier with regard to some of these API cleanups being orthogonal to this work. The big challenge with this series is really taking apart this big tangle of xattr code such that it has smaller components and is thus mostly reusable between dfops context for parent pointers etc. and the traditional codepath. I can see the appeal of such API cleanups (so it's good feedback overall), but I agree that it's probably wiser to allow this series to work with the interface style we have in the existing code and consider that type of thing as a follow on cleanup when the subsystem itself is more stabilized.
Quoted 1 line
Brian
Alrighty, sounds good for now. We'll come back and touch on it at a later time once we get through all the bigger stuff
Allison
Quoted 280 lines
Quoted 279 lines
Quoted 18 lines
Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +0
-0xfs_trans_brelse (args->trans, bp);return error;@@ -817,12 +865,10 @@ xfs_attr_leaf_get(xfs_da_args_t *args)trace_xfs_attr_leaf_get (args);fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 871
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +2
-4- args->blkno =0 ; - error =xfs_attr3_leaf_read (args->trans, args->dp, args->blkno, &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;Similar thing here, just reordering the checks simplifies the logic.
Sure, will do.
Quoted 72 lines
Quoted 42 lines
fs/xfs/libxfs/xfs_attr.c +35
-0@@ -832,6 +878,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 *========================================================================*/ ...
Quoted 29 lines
fs/xfs/libxfs/xfs_attr.c +3
-12@@ -1316,31 +1381,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);Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_get(xfs_da_args_t *args) · line 1410
Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +1
-0+ error =xfs_attr3_leaf_getvalue (blk->bp, args);/* * If not in a transaction, we have to release all the buffers. @@ -1352,7 +1409,7 @@ xfs_attr_node_get(xfs_da_args_t *args) }xfs_da_state_free (state);Do we need an 'if (state)' check here like the other node funcs?
I think so, because if
xfs_attr_node_hasnameerrors out it releases the state. Will add.Quoted 34 lines
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1-return retval; +return error; }/* Returns true if the attribute entry name is valid. */ ...
Quoted 28 lines
fs/xfs/libxfs/xfs_attr_leaf.c +21
-0@@ -654,18 +654,66 @@ xfs_attr_shortform_create(xfs_da_args_t *args) }/* +* Return -EEXIST if attr is found, or -ENOATTR if not +* args: args containing attribute name and namelen +* sfep: If not null, pointer will be set to the last attr entry found on +-EEXIST. On -ENOATTR pointer is left at the last entry in the list +* basep: If not null, pointer is set to the byte offset of the entry in the +* list on -EEXIST. On -ENOATTR, pointer is left at the byte offset of +* the last entry in the list +*/ +int +xfs_attr_sf_findname ( +struct xfs_da_args *args, +struct xfs_attr_sf_entry **sfep, +unsigned int *basep) +{ +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +unsigned int base =sizeof (struct xfs_attr_sf_hdr ); +int size =0 ; +int end; +int i; +Quoted 8 lines
fs/xfs/libxfs/xfs_attr_leaf.c xfs_attr_shortform_create(xfs_da_args_t *args) · line 682
Quoted 5 lines
fs/xfs/libxfs/xfs_attr_leaf.c +5
-0+ sf = (struct xfs_attr_shortform *)args->dp->i_afp->if_u1.if_data; + sfe = &sf->list[0 ]; + end = sf->hdr.count; +for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), + base += size, i++) {Slightly more readable to align indendation with the sfe assignment above.
Sure, will fix. Thanks!
Allison
Quoted 129 lines
Brian
Quoted 125 lines
fs/xfs/libxfs/xfs_attr_leaf.c +44
-41+ size =XFS_ATTR_SF_ENTSIZE (sfe); +if (sfe->namelen != args->name.len) +continue ; +if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) +continue ; +if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) +continue ; +break ; + } + +if (sfep !=NULL ) + *sfep = sfe; + +if (basep !=NULL ) + *basep = base; + +if (i == end) +return -ENOATTR ; +return -EEXIST ; +} + +/* * Add a name/value pair to the shortform attribute list. * Overflow from the inode has already been checked for. */ void -xfs_attr_shortform_add (xfs_da_args_t *args,int forkoff) +xfs_attr_shortform_add (struct xfs_da_args *args,int forkoff) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int i, offset, size; -xfs_mount_t *mp; -xfs_inode_t *dp; -struct xfs_ifork *ifp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int offset, size, error; +struct xfs_mount *mp; +struct xfs_inode *dp; +struct xfs_ifork *ifp;trace_xfs_attr_sf_add (args);@@ -676,18 +724,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) ifp = dp->i_afp;ASSERT (ifp->if_flags &XFS_IFINLINE ); sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; - sfe = &sf->list[0 ]; -for (i =0 ; i < sf->hdr.count; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), i++) { -#ifdef DEBUG -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (args->name.name, sfe->nameval, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -ASSERT (0 ); -#endif - } + error =xfs_attr_sf_findname (args, &sfe,NULL ); +ASSERT (error != -EEXIST ); offset = (char *)sfe - (char *)sf; size =XFS_ATTR_SF_ENTSIZE_BYNAME (args->name.len, args->valuelen);@@ -730,35 +768,26 @@ xfs_attr_fork_remove(* Remove an attribute from the shortform attribute list structure. */ int -xfs_attr_shortform_remove (xfs_da_args_t *args) +xfs_attr_shortform_remove (struct xfs_da_args *args) { -xfs_attr_shortform_t *sf; -xfs_attr_sf_entry_t *sfe; -int base, size=0 , end, totsize, i; -xfs_mount_t *mp; -xfs_inode_t *dp; +struct xfs_attr_shortform *sf; +struct xfs_attr_sf_entry *sfe; +int size =0 , end, totsize; +unsigned int base; +struct xfs_mount *mp; +struct xfs_inode *dp; +int error;trace_xfs_attr_sf_remove (args); dp = args->dp; mp = dp->i_mount; - base =sizeof (xfs_attr_sf_hdr_t); sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; - sfe = &sf->list[0 ]; - end = sf->hdr.count; -for (i =0 ; i < end; sfe =XFS_ATTR_SF_NEXTENTRY (sfe), - base += size, i++) { - size =XFS_ATTR_SF_ENTSIZE (sfe); -if (sfe->namelen != args->name.len) -continue ; -if (memcmp (sfe->nameval, args->name.name, args->name.len) !=0 ) -continue ; -if (!xfs_attr_namesp_match (args->name.type, sfe->flags)) -continue ; -break ; - } -if (i == end) -return -ENOATTR ; + + error =xfs_attr_sf_findname (args, &sfe, &base); +if (error != -EEXIST ) +return error; + size =XFS_ATTR_SF_ENTSIZE (sfe);/* * Fix up the attribute fork data, covering the hole fs/xfs/libxfs/xfs_attr_leaf.h +3
-0@@ -53,6 +53,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
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
In reply to Allison CollinsQuoted 190 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +84
-19@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,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 @@ -583,26 +617,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, &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;@@ -754,6 +782,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 , 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 @@ -773,12 +822,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, &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;@@ -817,12 +865,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, &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;@@ -832,6 +878,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 ;
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 909
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +10
-0+ +/* +* 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; + }
If 'statep' were NULL, then this would leak the memory pointed to by 'state' right?
Signature · 1 line
chandan
Chandan Rajendra
Reviewed-byRe: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 196 lines · Chandan Rajendra
Quoted 195 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +89
-19@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,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 @@ -583,26 +617,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, &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;@@ -754,6 +782,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 , 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 @@ -773,12 +822,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, &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;@@ -817,12 +865,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, &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;@@ -832,6 +878,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);
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 909
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +5
-0+if (error ==0 ) { +if (statep !=NULL ) + *statep = state; +return retval; + }If 'statep' were NULL, then this would leak the memory pointed to by 'state' right?
Apart from the above, the remaining changes look good to me.
Signature · 1 line
chandan
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
Quoted 206 lines · Chandan Rajendra
Quoted 196 lines · Chandan Rajendra
Quoted 195 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +89
-19@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,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 @@ -583,26 +617,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, &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;@@ -754,6 +782,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 , 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 @@ -773,12 +822,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, &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;@@ -817,12 +865,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, &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;@@ -832,6 +878,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);Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 909
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +5
-0+if (error ==0 ) { +if (statep !=NULL ) + *statep = state; +return retval; + }If 'statep' were NULL, then this would leak the memory pointed to by 'state' right?
Quoted 4 lines
Apart from the above, the remaining changes look good to me.
Reviewed-by Chandan Rajendra <[email protected]>
Alrighty, will fix. Thanks!
Allison
Re: [PATCH v7 03/19] xfs: Add xfs_has_attr and subroutines
In reply to Chandan RajendraQuoted 196 lines · Chandan Rajendra
Quoted 195 lines · Allison Collins
From: Allison Henderson <[email protected]>
This 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.
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 171 ++++++++++++++++++++++++++++-------------- fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_attr_leaf.c | 111 +++++++++++++++++---------- fs/xfs/libxfs/xfs_attr_leaf.h | 3 + 4 files changed, 188 insertions(+), 98 deletions(-)fs/xfs/libxfs/xfs_attr.c +89
-19@@ -46,6 +46,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. @@ -53,6 +54,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);@@ -310,6 +313,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 @@ -583,26 +617,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, &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;@@ -754,6 +782,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 , 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 @@ -773,12 +822,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, &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;@@ -817,12 +865,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, &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;@@ -832,6 +878,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);
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_get(xfs_da_args_t *args) · line 909
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +5
-0+if (error ==0 ) { +if (statep !=NULL ) + *statep = state; +return retval; + }If 'statep' were NULL, then this would leak the memory pointed to by 'state' right?
Another reviewer caught this too. Will update! :-)
Thanks!
Allison
PATCH v7 4/19 xfs: 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
--- fs/xfs/libxfs/xfs_attr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/xfs/libxfs/xfs_attr.c +12 -0
@@ -437,6 +437,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;
@@ -525,6 +533,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
Re: [PATCH v7 04/19] xfs: Check for -ENOATTR or -EEXIST
Quoted 16 lines · Allison Collins
Delayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0@@ -437,6 +437,14 @@ xfs_attr_set( goto out_trans_cancel;
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 447
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +8
-0xfs_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; +
And we do care about other errors?
Thanks,
Amir.
Re: [PATCH v7 04/19] xfs: Check for -ENOATTR or -EEXIST
Quoted 19 lines · Amir Goldstein
Quoted 17 lines · Allison Collins
Delayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0@@ -437,6 +437,14 @@ xfs_attr_set( goto out_trans_cancel;
Quoted 11 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 447
Quoted 9 lines
fs/xfs/libxfs/xfs_attr.c +8
-0xfs_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; +And we do care about other errors?
I guess they would surface during the set operation as they do now, though it's probably better to catch it here. Will add! Thanks!
Allison
Quoted 4 lines
Thanks,
Amir.
Re: [PATCH v7 04/19] xfs: Check for -ENOATTR or -EEXIST
In reply to Allison CollinsQuoted 15 lines · Allison Collins
Delayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0@@ -437,6 +437,14 @@ xfs_attr_set( goto out_trans_cancel;
fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 447
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +8
-0xfs_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; +
So xfs_has_attr() calls the format-specific variant for the attr fork. If it's node format, xfs_attr_node_hasname() allocs a state and only frees it if the lookup happens to fail. That looks like a potential memory leak... Perhaps that helper should free the state in any case the caller doesn't ask for a pointer?
Brian
Quoted 17 lines
fs/xfs/libxfs/xfs_attr.c +4
-0error =xfs_attr_set_args (&args);if (error) goto out_trans_cancel;@@ -525,6 +533,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
Re: [PATCH v7 04/19] xfs: Check for -ENOATTR or -EEXIST
Quoted 33 lines · Brian Foster
Quoted 15 lines · Allison Collins
Delayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0@@ -437,6 +437,14 @@ xfs_attr_set( goto out_trans_cancel;fs/xfs/libxfs/xfs_attr.c xfs_attr_set( · line 447
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +8
-0xfs_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; +So
xfs_has_attr()calls the format-specific variant for the attr fork. If it's node format,xfs_attr_node_hasname()allocs a state and only frees it if the lookup happens to fail. That looks like a potential memory leak... Perhaps that helper should free the state in any case the caller doesn't ask for a pointer?
Quoted 1 line
Brian
Ok, I see it. Will fix. Thanks!
Allison
Quoted 19 lines
Quoted 18 lines
fs/xfs/libxfs/xfs_attr.c +4
-0error =xfs_attr_set_args (&args);if (error) goto out_trans_cancel;@@ -525,6 +533,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 v7 5/19 xfs: 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.
--- fs/xfs/libxfs/xfs_attr_remote.c | 149 +++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 57 deletions(-)
fs/xfs/libxfs/xfs_attr_remote.c +92 -57
@@ -440,32 +440,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,
@@ -473,48 +464,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
@@ -595,6 +564,72 @@ xfs_attr_rmtval_stale( }/* +* 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
Re: [PATCH v7 05/19] xfs: Factor out new helper functions xfs_attr_rmtval_set
Quoted 4 lines · Allison Collins
Break
xfs_attr_rmtval_setinto two helper functionsxfs_attr_rmt_find_holeandxfs_attr_rmtval_set_value.xfs_attr_rmtval_setrolls the transaction between the helpers, but delayed operations cannot. We will use the helpers later when constructing new delayed attribute routines.
I don't see any logical errors.
Quoted 194 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 149 +++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 57 deletions(-)fs/xfs/libxfs/xfs_attr_remote.c +92
-57@@ -440,32 +440,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,@@ -473,48 +464,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 @@ -595,6 +564,72 @@ xfs_attr_rmtval_stale( }/* +* 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
chandan
Re: [PATCH v7 05/19] xfs: Factor out new helper functions xfs_attr_rmtval_set
Quoted 9 lines · Chandan Rajendra
Quoted 4 lines · Allison Collins
Break
xfs_attr_rmtval_setinto two helper functionsxfs_attr_rmt_find_holeandxfs_attr_rmtval_set_value.xfs_attr_rmtval_setrolls the transaction between the helpers, but delayed operations cannot. We will use the helpers later when constructing new delayed attribute routines.I don't see any logical errors.
Reviewed-by Chandan Rajendra <[email protected]>
Great! Thank you!
Allison
Quoted 197 lines
Quoted 195 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 149 +++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 57 deletions(-)fs/xfs/libxfs/xfs_attr_remote.c +92
-57@@ -440,32 +440,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,@@ -473,48 +464,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 @@ -595,6 +564,72 @@ xfs_attr_rmtval_stale( }/* +* 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. */
PATCH v7 6/19 xfs: 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
--- fs/xfs/libxfs/xfs_attr.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-)
fs/xfs/libxfs/xfs_attr.c +14 -0
@@ -739,6 +739,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
@@ -1081,6 +1088,13 @@ xfs_attr_node_addname( 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
fs/xfs/libxfs/xfs_attr_leaf.c +1 -6
@@ -2973,10 +2973,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
Re: [PATCH v7 06/19] xfs: Factor out trans handling in xfs_attr3_leaf_flipflags
Quoted 3 lines · Allison Collins
Since delayed operations cannot roll transactions, factor up the transaction handling into the calling function
I am not a native English speaker, so not sure what the correct phrase is, but I'm pretty sure its not factor up, nor factor out???
Quoted 60 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-0@@ -739,6 +739,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 @@ -1081,6 +1088,13 @@ xfs_attr_node_addname( 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 fs/xfs/libxfs/xfs_attr_leaf.c +1
-7@@ -2973,10 +2973,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 ; } --2.7.4
Re: [PATCH v7 06/19] xfs: Factor out trans handling in xfs_attr3_leaf_flipflags
Quoted 8 lines · Amir Goldstein
Quoted 3 lines · Allison Collins
Since delayed operations cannot roll transactions, factor up the transaction handling into the calling function
I am not a native English speaker, so not sure what the correct phrase is, but I'm pretty sure its not factor up, nor factor out???
Sorry, I got used to this usage on another team though only recently have people mention they thought it odd. I meant to clean them out and must of missed this one. Will remove.
Allison
Quoted 61 lines
Quoted 61 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-0@@ -739,6 +739,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 @@ -1081,6 +1088,13 @@ xfs_attr_node_addname( 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 fs/xfs/libxfs/xfs_attr_leaf.c +1
-7@@ -2973,10 +2973,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 ; } --2.7.4
Re: [PATCH v7 06/19] xfs: Factor out trans handling in xfs_attr3_leaf_flipflags
In reply to Allison CollinsQuoted 3 lines · Allison Collins
Since delayed operations cannot roll transactions, factor up the transaction handling into the calling function
I don't see any logical errors.
Quoted 57 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 14 ++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-0@@ -739,6 +739,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 @@ -1081,6 +1088,13 @@ xfs_attr_node_addname( 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 fs/xfs/libxfs/xfs_attr_leaf.c +1
-6@@ -2973,10 +2973,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
chandan
PATCH v7 7/19 xfs: 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.
--- fs/xfs/libxfs/xfs_attr.c | 88 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-)
fs/xfs/libxfs/xfs_attr.c +57 -31
@@ -305,10 +305,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; }
@@ -620,20 +640,21 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)*========================================================================*/ /* -* Add a name to the leaf attribute list structure +* Tries to add an attribute to an inode in leaf form * -* 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 function is meant to execute as part of a delayed operation and leaves +* the transaction handling to the caller. On success the attribute is added +* and the inode and transaction are left dirty. If there is not enough space, +* the attr data is converted to node format and -ENOSPC is returned. Caller is +* responsible for handling the dirty inode and transaction or adding the attr +* in node format. */ 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
@@ -679,31 +700,36 @@ 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
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
Quoted 2 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add.
Right. This should be the subject.
Not factor out xfs_attr_leaf_addname helper.
Quoted 3 lines
Because new delayed attribute
routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.
And that is a different change.
It is hard enough to review a pure factor out of a helper. Adding changed inside a pure re-factor is not good.
Belongs to another change - move transaction commit to caller.
Thanks,
Amir.
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
Quoted 12 lines · Amir Goldstein
Quoted 2 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add.Right. This should be the subject.
Not factor outxfs_attr_leaf_addnamehelper.Quoted 3 lines
Because new delayed attribute
routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.
Quoted 5 lines
And that is a different change.
It is hard enough to review a pure factor out of a helper. Adding changed inside a pure re-factor is not good.Belongs to another change - move transaction commit to caller.
Yes, this came up in the last review, but the reason I avoid it is because I think the transaction looks weird in either helper. The reason the roll is here is because there is no room to add the attr as a leaf, and so we need to hand it off to the node subroutines. But that seems like something that should be managed by the caller, not leaf helpers. So I was concerned that separating the split and the hoist would generate more weird looks from people trying to understand the split until the see the hoist in the next patch. If people really think it looks better that way, I can split them up. But I know folks have a tough enough time trying to recall the discussion history, so I'm trying to avoid confusion of another type :-)
Thoughts?
Allison
Quoted 4 lines
Thanks,
Amir.
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
Quoted 32 lines · Allison Collins
Quoted 12 lines · Amir Goldstein
Quoted 2 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add.Right. This should be the subject.
Not factor outxfs_attr_leaf_addnamehelper.Quoted 3 lines
Because new delayed attribute
routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.Quoted 5 lines
And that is a different change.
It is hard enough to review a pure factor out of a helper. Adding changed inside a pure re-factor is not good.Belongs to another change - move transaction commit to caller.
Yes, this came up in the last review, but the reason I avoid it is because I think the transaction looks weird in either helper. The reason the roll is here is because there is no room to add the attr as a leaf, and so we need to hand it off to the node subroutines. But that seems like something that should be managed by the caller, not leaf helpers. So I was concerned that separating the split and the hoist would generate more weird looks from people trying to understand the split until the see the hoist in the next patch. If people really think it looks better that way, I can split them up. But I know folks have a tough enough time trying to recall the discussion history, so I'm trying to avoid confusion of another type :-)
Quoted 2 lines
Thoughts?
It's fine, so long as you document it properly in commit message. See, we are so bad in this review process, that we rely on humans to verify that logic preserving re-factoring patches are indeed logic preserving. This is so lame to begin with, because there are static checker bots out there that would gladly do that work for us :) ... if we only annotated the logic preserving patches as such. In the mean while, while we are substituting the review robots, the least a developer could do is not call out a patch "re-factoring" and sneak in a logic change without due notice to reviewers.
Thanks,
Amir.
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
Quoted 34 lines · Amir Goldstein
Quoted 32 lines · Allison Collins
Quoted 12 lines · Amir Goldstein
Quoted 2 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add.Right. This should be the subject.
Not factor outxfs_attr_leaf_addnamehelper.Quoted 3 lines
Because new delayed attribute
routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.Quoted 5 lines
And that is a different change.
It is hard enough to review a pure factor out of a helper. Adding changed inside a pure re-factor is not good.Belongs to another change - move transaction commit to caller.
Yes, this came up in the last review, but the reason I avoid it is because I think the transaction looks weird in either helper. The reason the roll is here is because there is no room to add the attr as a leaf, and so we need to hand it off to the node subroutines. But that seems like something that should be managed by the caller, not leaf helpers. So I was concerned that separating the split and the hoist would generate more weird looks from people trying to understand the split until the see the hoist in the next patch. If people really think it looks better that way, I can split them up. But I know folks have a tough enough time trying to recall the discussion history, so I'm trying to avoid confusion of another type :-)
Quoted 8 lines
Quoted 2 lines
Thoughts?
It's fine, so long as you document it properly in commit message. See, we are so bad in this review process, that we rely on humans to verify that logic preserving re-factoring patches are indeed logic preserving. This is so lame to begin with, because there are static checker bots out there that would gladly do that work for us :) ...
I didnt know there were tools out there that did that. They sound helpful though!
Quoted 4 lines
if we only annotated the logic preserving patches as such. In the mean while, while we are substituting the review robots, the least a developer could do is not call out a patch "re-factoring" and sneak in a logic change without due notice to reviewers.
Ok, what if the title were to say something like:
xfs: Split out node handling from xfs_attr_leaf_addname
Or maybe just "Split apart xfs_attr_leaf_addname"? Does that sound like it would be a better description here?
Thanks!
Allison
Quoted 4 lines
Thanks,
Amir.
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
Quoted 53 lines · Allison Collins
Quoted 34 lines · Amir Goldstein
Quoted 32 lines · Allison Collins
Quoted 12 lines · Amir Goldstein
Quoted 2 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add.Right. This should be the subject.
Not factor outxfs_attr_leaf_addnamehelper.Quoted 3 lines
Because new delayed attribute
routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.Quoted 5 lines
And that is a different change.
It is hard enough to review a pure factor out of a helper. Adding changed inside a pure re-factor is not good.Belongs to another change - move transaction commit to caller.
Yes, this came up in the last review, but the reason I avoid it is because I think the transaction looks weird in either helper. The reason the roll is here is because there is no room to add the attr as a leaf, and so we need to hand it off to the node subroutines. But that seems like something that should be managed by the caller, not leaf helpers. So I was concerned that separating the split and the hoist would generate more weird looks from people trying to understand the split until the see the hoist in the next patch. If people really think it looks better that way, I can split them up. But I know folks have a tough enough time trying to recall the discussion history, so I'm trying to avoid confusion of another type :-)
Quoted 8 lines
Quoted 2 lines
Thoughts?
It's fine, so long as you document it properly in commit message. See, we are so bad in this review process, that we rely on humans to verify that logic preserving re-factoring patches are indeed logic preserving. This is so lame to begin with, because there are static checker bots out there that would gladly do that work for us :) ...
I didnt know there were tools out there that did that. They sound helpful though!
Quoted 4 lines
if we only annotated the logic preserving patches as such. In the mean while, while we are substituting the review robots, the least a developer could do is not call out a patch "re-factoring" and sneak in a logic change without due notice to reviewers.
Quoted 6 lines
Ok, what if the title were to say something like:
xfs: Split out node handling fromxfs_attr_leaf_addnameOr maybe just "Split apart
xfs_attr_leaf_addname"? Does that sound like it would be a better description here?
Sure, both are fine.
All I'm saying is that "factor out" is a well established keyword that shouldn't be abused.
Thanks,
Amir.
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
In reply to Allison CollinsQuoted 3 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.
68-72 columns :P
Quoted 33 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 88 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-3@@ -305,10 +305,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
fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 332
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +9
-0+* start a new one. +*/ + error =xfs_trans_roll_inode (&args->trans, dp); +if (error) +return error; + + } + + error =xfs_attr_node_addname (args);return error;
return xfs_attr_node_addname(args);
better yet:
if (!xfs_bmap_one_block(dp, XFS_ATTR_FORK)) return xfs_attr_node_addname(args); error = xfs_attr_leaf_addname(args); if (error != -ENOSPC) return error; .....
BTW, I think I see the pattern now - isolate all the metadata changes from the mechanism of rolling the transactions, which means it can be converted to a set of operations connected by a generic transaction rolling mechanism. It's all starting to make more sense now :P
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_addname( · line 705
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +2
-3@@ -679,31 +700,36 @@ 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 */
Comments should use all 80 columns...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
Quoted 63 lines · Dave Chinner
Quoted 3 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.68-72 columns :P
Quoted 33 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 88 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-3@@ -305,10 +305,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 fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 332
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +9
-0+* start a new one. +*/ + error =xfs_trans_roll_inode (&args->trans, dp); +if (error) +return error; + + } + + error =xfs_attr_node_addname (args);return error;return xfs_attr_node_addname(args);better yet:
if (!xfs_bmap_one_block(dp, XFS_ATTR_FORK)) return xfs_attr_node_addname(args); error = xfs_attr_leaf_addname(args); if (error != -ENOSPC) return error; .....
Quoted 6 lines
BTW, I think I see the pattern now - isolate all the metadata changes from the mechanism of rolling the transactions, which means it can be converted to a set of operations connected by a generic transaction rolling mechanism. It's all starting to make more sense now :P
Yeah.. IIRC the initial attempt at this was going down the path of creating an entire separate xattr codepath for xattr intents. The existing codepath has the issue of rolling transactions all over the place, which makes it difficult to execute from dfops context. The goal is then to try and take this thing apart such that it works in dfops context for intents and at the same time can be driven by a high level transaction rolling loop to support the traditional xattr codepath for backwards compatibility.
The whole state/context thing fell out of that. I think most agree that it's ugly, but it's a useful intermediate step for breaking down this hunk of code into components that can be further evaluated for simplification and reduction (while making functional progress as well). E.g., perhaps the top-level states can be eliminated in favor of simply looking at current xattr fork format. This gets hairier deeper down in the set path, but I think we may eventually see some similar patterns emerge when you consider that leaf and node adds follow a very similar flow and make many of the same function calls with regard to handling remote values, renames, etc. etc. All in all, I think it will be interesting if we could come up with some abstractions that ultimately facilitate removal of the state stuff. That's certainly not clear enough to me at least right now, but something to keep in mind when working through this code..
Brian
Quoted 20 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_addname( · line 705
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +2
-3@@ -679,31 +700,36 @@ 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 */ Comments should use all 80 columns...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
In reply to Dave ChinnerQuoted 6 lines · Dave Chinner
Quoted 3 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.68-72 columns :P
Yes, I had adjusted the configs on the editor and thought I had it fixed. Will fix
Quoted 49 lines
Quoted 34 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 88 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-3@@ -305,10 +305,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 fs/xfs/libxfs/xfs_attr.c xfs_attr_set_args( · line 332
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +9
-0+* start a new one. +*/ + error =xfs_trans_roll_inode (&args->trans, dp); +if (error) +return error; + + } + + error =xfs_attr_node_addname (args);return error;return xfs_attr_node_addname(args);better yet:
Quoted 7 lines
if (!xfs_bmap_one_block(dp, XFS_ATTR_FORK)) return xfs_attr_node_addname(args); error = xfs_attr_leaf_addname(args); if (error != -ENOSPC) return error; .....
Sure, let me dig around first though, because that's going to move around where the states appear in patch 14. The set is admittedly a bit of a balancing act :-)
Quoted 6 lines
BTW, I think I see the pattern now - isolate all the metadata changes from the mechanism of rolling the transactions, which means it can be converted to a set of operations connected by a generic transaction rolling mechanism. It's all starting to make more sense now :P
Alrighty, I'm glad it's coming together. :-)
Quoted 13 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_leaf_addname( · line 705
Quoted 11 lines
fs/xfs/libxfs/xfs_attr.c +2
-3@@ -679,31 +700,36 @@ 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 */ Comments should use all 80 columns...
Will fix
Thanks for the reviews!
Allison
Quoted 5 lines
Cheers,
Dave.
Re: [PATCH v7 07/19] xfs: Factor out xfs_attr_leaf_addname helper
In reply to Allison CollinsQuoted 4 lines · Allison Collins
Factor out new helper function
xfs_attr_leaf_try_add. Because new delayed attribute routines cannot roll transactions, we carve off the parts ofxfs_attr_leaf_addnamethat we can use, and move the commit into the calling function.
I don't see any logical errors.
Quoted 132 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 88 +++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 31 deletions(-)fs/xfs/libxfs/xfs_attr.c +57
-31@@ -305,10 +305,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; }@@ -620,20 +640,21 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)*========================================================================*/ /* -* Add a name to the leaf attribute list structure +* Tries to add an attribute to an inode in leaf form * -* 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 function is meant to execute as part of a delayed operation and leaves +* the transaction handling to the caller. On success the attribute is added +* and the inode and transaction are left dirty. If there is not enough space, +* the attr data is converted to node format and -ENOSPC is returned. Caller is +* responsible for handling the dirty inode and transaction or adding the attr +* in node format. */ 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 @@ -679,31 +700,36 @@ 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
chandan
PATCH v7 8/19 xfs: 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.
--- fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
fs/xfs/libxfs/xfs_attr.c +15 -15
@@ -227,8 +227,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 )
@@ -241,12 +246,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; }/*
@@ -258,7 +261,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,
@@ -269,17 +272,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
Re: [PATCH v7 08/19] xfs: Refactor xfs_attr_try_sf_addname
Quoted 2 lines · Allison Collins
To help pre-simplify
xfs_attr_set_args, we need to hoist transacation handling up,
typo: transacation
Quoted 7 lines
while modularizing the adjacent code down into helpers. In this patch, hoist the commit in
xfs_attr_try_sf_addnameup into the calling function, and also pull the attr list creation down.Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>---
And I don't think the subject (Refactoring) is a reliable description of this change,
but if nobody else cares, I don't mind what you call it.
As far as not changing logic, you may add:
Thanks,
Amir.
Re: [PATCH v7 08/19] xfs: Refactor xfs_attr_try_sf_addname
Quoted 6 lines · Amir Goldstein
Quoted 2 lines · Allison Collins
To help pre-simplify
xfs_attr_set_args, we need to hoist transacation handling up,typo: transacation
Will fix :-)
Quoted 6 lines
Quoted 6 lines
while modularizing the adjacent code down into helpers. In this patch, hoist the commit in
xfs_attr_try_sf_addnameup into the calling function, and also pull the attr list creation down.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>---
And I don't think the subject (Refactoring) is a reliable description of this change,
but if nobody else cares, I don't mind what you call it.
Yes, I struggled with that a bit since things are just generally being re-arranged, but if there's a more descriptive term folks prefer, please call it out.
Quoted 4 lines
As far as not changing logic, you may add:
Reviewed-by Amir Goldstein <[email protected]>
Thanks!
Allison
Quoted 5 lines
Thanks,
Amir.
Re: [PATCH v7 08/19] xfs: Refactor xfs_attr_try_sf_addname
In reply to Allison CollinsQuoted 8 lines · Allison Collins
To 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 inxfs_attr_try_sf_addnameup into the calling function, and also pull the attr list creation down.Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>---
Quoted 73 lines
fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)fs/xfs/libxfs/xfs_attr.c +15
-15@@ -227,8 +227,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 )@@ -241,12 +246,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; }/* @@ -258,7 +261,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, @@ -269,17 +272,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
Re: [PATCH v7 08/19] xfs: Refactor xfs_attr_try_sf_addname
Quoted 11 lines · Brian Foster
Quoted 8 lines · Allison Collins
To 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 inxfs_attr_try_sf_addnameup into the calling function, and also pull the attr list creation down.Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>---
Reviewed-by Brian Foster <[email protected]>
Alrighty, thank you!
Allison
Quoted 75 lines
Quoted 74 lines
fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)fs/xfs/libxfs/xfs_attr.c +15
-15@@ -227,8 +227,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 )@@ -241,12 +246,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; }/* @@ -258,7 +261,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, @@ -269,17 +272,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
Re: [PATCH v7 08/19] xfs: Refactor xfs_attr_try_sf_addname
In reply to Allison CollinsQuoted 5 lines · Allison Collins
To 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 inxfs_attr_try_sf_addnameup into the calling function, and also pull the attr list creation down.
I don't see any logical errors.
Quoted 74 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)fs/xfs/libxfs/xfs_attr.c +15
-15@@ -227,8 +227,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 )@@ -241,12 +246,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; }/* @@ -258,7 +261,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, @@ -269,17 +272,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
chandan
Re: [PATCH v7 08/19] xfs: Refactor xfs_attr_try_sf_addname
Quoted 10 lines · Chandan Rajendra
Quoted 5 lines · Allison Collins
To 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 inxfs_attr_try_sf_addnameup into the calling function, and also pull the attr list creation down.I don't see any logical errors.
Reviewed-by Chandan Rajendra <[email protected]>
Alrighty, thank you!
Allison
Quoted 77 lines
Quoted 75 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)fs/xfs/libxfs/xfs_attr.c +15
-15@@ -227,8 +227,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 )@@ -241,12 +246,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; }/* @@ -258,7 +261,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, @@ -269,17 +272,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.
PATCH v7 9/19 xfs: 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
--- fs/xfs/libxfs/xfs_attr.c | 5 +++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_attr.c +5 -0
@@ -1244,6 +1244,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;
fs/xfs/libxfs/xfs_attr_leaf.c +1 -4
@@ -2855,10 +2855,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
Re: [PATCH v7 09/19] xfs: Factor out trans roll from xfs_attr3_leaf_setflag
Quoted 3 lines · Allison Collins
New delayed allocation routines cannot be handling transactions so factor them up into the calling functions
I don't see any logical errors.
Quoted 41 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>Reviewed-by Brian Foster <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 5 +++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-)fs/xfs/libxfs/xfs_attr.c +5
-0@@ -1244,6 +1244,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;fs/xfs/libxfs/xfs_attr_leaf.c +1
-4@@ -2855,10 +2855,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
chandan
PATCH v7 10/19 xfs: 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.
--- fs/xfs/libxfs/xfs_attr_remote.c | 26 +++++++++++++++++++++----- fs/xfs/libxfs/xfs_attr_remote.h | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-)
fs/xfs/libxfs/xfs_attr_remote.c +21 -5
@@ -634,15 +634,12 @@ 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) {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.
@@ -670,13 +667,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);
fs/xfs/libxfs/xfs_attr_remote.h +1 -1
@@ -13,5 +13,5 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags); - +int xfs_attr_rmtval_invalidate (struct xfs_da_args *args);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
2.7.4
Re: [PATCH v7 10/19] xfs: Factor out xfs_attr_rmtval_invalidate
Quoted 4 lines · Allison Collins
Because new delayed attribute routines cannot roll transactions, we carve off the parts of
xfs_attr_rmtval_removethat we can use. This will help to reduce repetitive code later when we introduce delayed attributes.
I don't see any logical errors.
Quoted 75 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 26 +++++++++++++++++++++----- fs/xfs/libxfs/xfs_attr_remote.h | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-)fs/xfs/libxfs/xfs_attr_remote.c +21
-5@@ -634,15 +634,12 @@ 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) {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. @@ -670,13 +667,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);fs/xfs/libxfs/xfs_attr_remote.h +1
-1@@ -13,5 +13,5 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);int xfs_attr_rmtval_remove (struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags); - +int xfs_attr_rmtval_invalidate (struct xfs_da_args *args);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
chandan
PATCH v7 11/19 xfs: 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
--- fs/xfs/libxfs/xfs_attr.c | 16 ++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 17 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_attr.c +16 -0
@@ -822,6 +822,14 @@ xfs_attr_leaf_addname(* 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; }
@@ -1185,6 +1193,14 @@ xfs_attr_node_addname( 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 ;
fs/xfs/libxfs/xfs_attr_leaf.c +1 -4
@@ -2804,10 +2804,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
Re: [PATCH v7 11/19] xfs: Factor out trans roll in xfs_attr3_leaf_clearflag
Quoted 3 lines · Allison Collins
New delayed allocation routines cannot be handling transactions so factor them out into the calling functions
I don't see any logical errors.
Quoted 59 lines
Signed-off-by Allison Collins <[email protected]>Reviewed-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 16 ++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 5 +---- 2 files changed, 17 insertions(+), 4 deletions(-)fs/xfs/libxfs/xfs_attr.c +16
-0@@ -822,6 +822,14 @@ xfs_attr_leaf_addname(* 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; }@@ -1185,6 +1193,14 @@ xfs_attr_node_addname( 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 ;fs/xfs/libxfs/xfs_attr_leaf.c +1
-4@@ -2804,10 +2804,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
chandan
PATCH v7 12/19 xfs: 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
--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)
fs/xfs/libxfs/xfs_attr_remote.c +28 -0
@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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 ; +}
fs/xfs/libxfs/xfs_attr_remote.h +1 -0
@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
Quoted 35 lines · Allison Collins
This 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 attributesSigned-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +18
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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,
fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 741
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+ args->rmtblkno, args->rmtblkcnt, + XFS_BMAPI_ATTRFORK, 1, &done); +if (error) +return error; + +if (!done) +return -EAGAIN ; + +return 0 ; +}
Hmm.. any reason this isn't a refactor of the existing remove function? Just skipping to the end of the series, I see we leave the reference to xfs_attr_rmtval_remove() (which no longer exists and so is not very useful) in this comment as well as a stale function declaration in xfs_attr_remote.h.
I haven't grokked how this is used yet, but it seems like it would be more appropriate to lift out the transaction handling from the original function as we have throughout the rest of the code. That could also mean creating a temporary wrapper (i.e., rmtval_remove() calls rmtval_unmap()) for the loop/transaction code that could be removed later if it ends up unused. Either way is much easier to follow than creating a (currently unused) replacement..
Brian
Quoted 13 lines
fs/xfs/libxfs/xfs_attr_remote.h +1
-0@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
Quoted 53 lines · Brian Foster
Quoted 35 lines · Allison Collins
This 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 attributesSigned-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +18
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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,fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 741
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+ args->rmtblkno, args->rmtblkcnt, + XFS_BMAPI_ATTRFORK, 1, &done); +if (error) +return error; + +if (!done) +return -EAGAIN ; + +return 0 ; +}Hmm.. any reason this isn't a refactor of the existing remove function? Just skipping to the end of the series, I see we leave the reference to
xfs_attr_rmtval_remove()(which no longer exists and so is not very useful) in this comment as well as a stale function declaration inxfs_attr_remote.h.
Quoted 7 lines
I haven't grokked how this is used yet, but it seems like it would be more appropriate to lift out the transaction handling from the original function as we have throughout the rest of the code. That could also mean creating a temporary wrapper (i.e.,
rmtval_remove()callsrmtval_unmap()) for the loop/transaction code that could be removed later if it ends up unused. Either way is much easier to follow than creating a (currently unused) replacement..
Yes, this came up in one of the other reviews. I thought about it, but then decided against it. xfs_attr_rmtval_remove disappears across patches 13 and 14. The use of xfs_attr_rmtval_remove is replaced with xfs_attr_rmtval_unmap when we finally yank out all the transaction code.
The reason I dont want to do it all at once is because that would mean
patches 12, 13, 14 and 19 would lump together to make the swap instantaneous in once patch.
I've been getting feedback that the set is really complicated, so I've been trying to find a way to organize it to help make it easier to review. So I thought isolating 13 and 14 to just the state machine would help. Thus I decided to keep patch 12 separate to take as much craziness out of 13 and 14 as possible. Patches 12 and 19 seem like otherwise easy things for people to look at. Let me know your thoughts on this. :-)
You are right about the stale comment though, I missed it while going back over the commentary at the top. Will fix.
Allison
Quoted 17 lines
Brian
Quoted 13 lines
fs/xfs/libxfs/xfs_attr_remote.h +1
-0@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
Quoted 63 lines · Allison Collins
Quoted 53 lines · Brian Foster
Quoted 35 lines · Allison Collins
This 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 attributesSigned-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +18
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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,fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 741
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+ args->rmtblkno, args->rmtblkcnt, + XFS_BMAPI_ATTRFORK, 1, &done); +if (error) +return error; + +if (!done) +return -EAGAIN ; + +return 0 ; +}Hmm.. any reason this isn't a refactor of the existing remove function? Just skipping to the end of the series, I see we leave the reference to
xfs_attr_rmtval_remove()(which no longer exists and so is not very useful) in this comment as well as a stale function declaration inxfs_attr_remote.h.Quoted 7 lines
I haven't grokked how this is used yet, but it seems like it would be more appropriate to lift out the transaction handling from the original function as we have throughout the rest of the code. That could also mean creating a temporary wrapper (i.e.,
rmtval_remove()callsrmtval_unmap()) for the loop/transaction code that could be removed later if it ends up unused. Either way is much easier to follow than creating a (currently unused) replacement..
Quoted 8 lines
Yes, this came up in one of the other reviews. I thought about it, but then decided against it.
xfs_attr_rmtval_removedisappears across patches 13 and
14. The use ofxfs_attr_rmtval_removeis replaced withxfs_attr_rmtval_unmapwhen we finally yank out all the transaction code. The reason I dont want to do it all at once is because that would mean patches 12, 13, 14 and 19 would lump together to make the swap instantaneous in once patch.
Hmm.. I don't think we're talking about the same thing. If xfs_attr_rmtval_remove() was broken down into two functions such that one of the two looks exactly like the _unmap() variant, can't we just remove the other half when it becomes unused and allow the _remove() variant to exist with the implementation of _unmap() proposed here? This seems fairly mechanical to me..
Quoted 7 lines
I've been getting feedback that the set is really complicated, so I've been trying to find a way to organize it to help make it easier to review. So I thought isolating 13 and 14 to just the state machine would help. Thus I decided to keep patch 12 separate to take as much craziness out of 13 and 14 as possible. Patches 12 and 19 seem like otherwise easy things for people to look at. Let me know your thoughts on this. :-)
I think doing as much refactoring of existing code as early as possible will go a long way towards simplifying the complexity around the introduction of the state bits.
Brian
Quoted 23 lines
You are right about the stale comment though, I missed it while going back over the commentary at the top. Will fix.
Allison
Quoted 17 lines
Brian
Quoted 13 lines
fs/xfs/libxfs/xfs_attr_remote.h +1
-0@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
Quoted 73 lines · Brian Foster
Quoted 63 lines · Allison Collins
Quoted 53 lines · Brian Foster
Quoted 35 lines · Allison Collins
This 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 attributesSigned-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +18
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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,fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 741
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+ args->rmtblkno, args->rmtblkcnt, + XFS_BMAPI_ATTRFORK, 1, &done); +if (error) +return error; + +if (!done) +return -EAGAIN ; + +return 0 ; +}Hmm.. any reason this isn't a refactor of the existing remove function? Just skipping to the end of the series, I see we leave the reference to
xfs_attr_rmtval_remove()(which no longer exists and so is not very useful) in this comment as well as a stale function declaration inxfs_attr_remote.h.Quoted 7 lines
I haven't grokked how this is used yet, but it seems like it would be more appropriate to lift out the transaction handling from the original function as we have throughout the rest of the code. That could also mean creating a temporary wrapper (i.e.,
rmtval_remove()callsrmtval_unmap()) for the loop/transaction code that could be removed later if it ends up unused. Either way is much easier to follow than creating a (currently unused) replacement..Quoted 8 lines
Yes, this came up in one of the other reviews. I thought about it, but then decided against it.
xfs_attr_rmtval_removedisappears across patches 13 and
14. The use ofxfs_attr_rmtval_removeis replaced withxfs_attr_rmtval_unmapwhen we finally yank out all the transaction code. The reason I dont want to do it all at once is because that would mean patches 12, 13, 14 and 19 would lump together to make the swap instantaneous in once patch.
Quoted 6 lines
Hmm.. I don't think we're talking about the same thing. If
xfs_attr_rmtval_remove()was broken down into two functions such that one of the two looks exactly like the_unmap()variant, can't we just remove the other half when it becomes unused and allow the_remove()variant to exist with the implementation of_unmap()proposed here? This seems fairly mechanical to me..
Oh, I see what you mean. No, I had done a review of the uses of xfs_attr_rmtval_remove and realized that it appears in both the set and remove paths. We use it in the set path when we're doing a rename, and need to remove the old attr.
So in patch 13, we replace xfs_attr_rmtval_remove with xfs_attr_rmtval_unmap for the remove routines. But it's still in the set routines. So we cant take it away yet. Once we get through patch 14, it is no longer used and we can remove it. Did that make sense?
Quoted 9 lines
Quoted 8 lines
I've been getting feedback that the set is really complicated, so I've been trying to find a way to organize it to help make it easier to review. So I thought isolating 13 and 14 to just the state machine would help. Thus I decided to keep patch 12 separate to take as much craziness out of 13 and 14 as possible. Patches 12 and 19 seem like otherwise easy things for people to look at. Let me know your thoughts on this. :-)
Quoted 3 lines
I think doing as much refactoring of existing code as early as possible will go a long way towards simplifying the complexity around the introduction of the state bits.
Alrighty, I was thinking that if I reordered things such that modularizing appeared at the end of the set, that it would help people to see it in context with the states. But it sounds like people like it the other way around, it's easy enough to put back. Though I think we may still be stuck with 12 and 19 being apart unless 13 and 14 come together. :-(
Allison
Quoted 27 lines
Brian
Quoted 23 lines
You are right about the stale comment though, I missed it while going back over the commentary at the top. Will fix.
Allison
Quoted 17 lines
Brian
Quoted 13 lines
fs/xfs/libxfs/xfs_attr_remote.h +1
-0@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
Quoted 87 lines · Allison Collins
Quoted 73 lines · Brian Foster
Quoted 63 lines · Allison Collins
Quoted 53 lines · Brian Foster
Quoted 35 lines · Allison Collins
This 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 attributesSigned-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +18
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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,fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 741
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+ args->rmtblkno, args->rmtblkcnt, + XFS_BMAPI_ATTRFORK, 1, &done); +if (error) +return error; + +if (!done) +return -EAGAIN ; + +return 0 ; +}Hmm.. any reason this isn't a refactor of the existing remove function? Just skipping to the end of the series, I see we leave the reference to
xfs_attr_rmtval_remove()(which no longer exists and so is not very useful) in this comment as well as a stale function declaration inxfs_attr_remote.h.Quoted 7 lines
I haven't grokked how this is used yet, but it seems like it would be more appropriate to lift out the transaction handling from the original function as we have throughout the rest of the code. That could also mean creating a temporary wrapper (i.e.,
rmtval_remove()callsrmtval_unmap()) for the loop/transaction code that could be removed later if it ends up unused. Either way is much easier to follow than creating a (currently unused) replacement..Quoted 8 lines
Yes, this came up in one of the other reviews. I thought about it, but then decided against it.
xfs_attr_rmtval_removedisappears across patches 13 and
14. The use ofxfs_attr_rmtval_removeis replaced withxfs_attr_rmtval_unmapwhen we finally yank out all the transaction code. The reason I dont want to do it all at once is because that would mean patches 12, 13, 14 and 19 would lump together to make the swap instantaneous in once patch.Quoted 6 lines
Hmm.. I don't think we're talking about the same thing. If
xfs_attr_rmtval_remove()was broken down into two functions such that one of the two looks exactly like the_unmap()variant, can't we just remove the other half when it becomes unused and allow the_remove()variant to exist with the implementation of_unmap()proposed here? This seems fairly mechanical to me..Oh, I see what you mean. No, I had done a review of the uses of
xfs_attr_rmtval_removeand realized that it appears in both the set and remove paths. We use it in the set path when we're doing a rename, and need to remove the old attr.
Quoted 5 lines
So in patch 13, we replace
xfs_attr_rmtval_removewithxfs_attr_rmtval_unmapfor the remove routines. But it's still in the set routines. So we cant take it away yet. Once we get through patch 14, it is no longer used and we can remove it. Did that make sense?
I don't think you need to take it away in this patch. What I'm suggesting is breaking existing code into something like this:
int__xfs_attr_rmtval_remove()
{
...
error = xfs_bunmapi(...);
...
if (!done)
return -EAGAIN;
...
}intxfs_attr_rmtval_remove()
{
error = xfs_attr_rmtval_invalidate();
do {
error = __xfs_attr_rmtval_remove();
...
xfs_defer_finish();
...
xfs_trans_roll_inode(...);
} while (-EAGAIN);
...
}So we can continue to use both as needed without duplication and remove the bits that become unused as the series progresses. Eventually we could rename __xfs_attr_rmtval_remove() back to xfs_attr_rmtval_remove() to maintain that it's essentially the same function and only the transaction rolling bits are being factored out and eventually removed.
Brian
Quoted 49 lines
Quoted 9 lines
Quoted 8 lines
I've been getting feedback that the set is really complicated, so I've been trying to find a way to organize it to help make it easier to review. So I thought isolating 13 and 14 to just the state machine would help. Thus I decided to keep patch 12 separate to take as much craziness out of 13 and 14 as possible. Patches 12 and 19 seem like otherwise easy things for people to look at. Let me know your thoughts on this. :-)
Quoted 3 lines
I think doing as much refactoring of existing code as early as possible will go a long way towards simplifying the complexity around the introduction of the state bits.
Alrighty, I was thinking that if I reordered things such that modularizing appeared at the end of the set, that it would help people to see it in context with the states. But it sounds like people like it the other way around, it's easy enough to put back. Though I think we may still be stuck with 12 and 19 being apart unless 13 and 14 come together. :-(
Allison
Quoted 27 lines
Brian
Quoted 23 lines
You are right about the stale comment though, I missed it while going back over the commentary at the top. Will fix.
Allison
Quoted 17 lines
Brian
Quoted 13 lines
fs/xfs/libxfs/xfs_attr_remote.h +1
-0@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
In reply to Allison CollinsQuoted 2 lines · Allison Collins
This 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
68-72 columns...
Quoted 16 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +1
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } +
fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 724
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +int +xfs_attr_rmtval_unmap ( +struct xfs_da_args *args) +{ +int error, done;
Best to initialise done to zero here.
fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 733
Quoted 9 lines
fs/xfs/libxfs/xfs_attr_remote.c +9
-0+ +/* +* 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);
Got 80 columns for code, please use them all :)
fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 738
Quoted 5 lines
fs/xfs/libxfs/xfs_attr_remote.c +5
-0+if (error) +return error; + +if (!done) +return -EAGAIN ;
Hmmm, I guess I'm missing the context at this point: why not just pass the done variable all the way back to the caller that will be looping on this function call?
That turns this function into:
int
xfs_attr_rmtval_unmap(
struct xfs_da_args *args,
bool *done)
{
return xfs_bunmapi(args->trans, args->dp, args->rmtblkno,
args->rmtblkcnt, XFS_BMAPI_ATTRFORK, 1, done);
}Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
Quoted 59 lines · Dave Chinner
Quoted 2 lines · Allison Collins
This 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 attributes68-72 columns...
Quoted 16 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +1
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } +fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 724
Quoted 10 lines
fs/xfs/libxfs/xfs_attr_remote.c +10
-0+/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +int +xfs_attr_rmtval_unmap ( +struct xfs_da_args *args) +{ +int error, done;Best to initialise done to zero here.
fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 733
Quoted 9 lines
fs/xfs/libxfs/xfs_attr_remote.c +9
-0+ +/* +* 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);Got 80 columns for code, please use them all :)
fs/xfs/libxfs/xfs_attr_remote.c xfs_attr_rmtval_remove( · line 738
Quoted 5 lines
fs/xfs/libxfs/xfs_attr_remote.c +5
-0+if (error) +return error; + +if (!done) +return -EAGAIN ;Hmmm, I guess I'm missing the context at this point: why not just pass the done variable all the way back to the caller that will be looping on this function call?
That turns this function into:
Quoted 8 lines
int
xfs_attr_rmtval_unmap(struct xfs_da_args *args, bool *donec { return xfs_bunmapi(args->trans, args->dp, args->rmtblkno, args->rmtblkcnt, XFS_BMAPI_ATTRFORK, 1, done); }
Well, this is a helper we talked about adding in the v5 review ([PATCH v5 13/14] xfs: Add delay ready attr remove routines) In v5, I did not have this helper function, and just open coded xfs_attr_rmtval_remove in the middle of the calling function (xfs_attr_remove_iter), except with out the transaction. Then later we identified it as an area we could modularize. It's kind of hard to see the bigger picture with out the states being here yet. But really what we're trying to do is modularize everything that shows up between the states later in the set.
Hope that helps a bit!
Allison
Quoted 5 lines
Cheers,
Dave.
Re: [PATCH v7 12/19] xfs: Add helper function xfs_attr_rmtval_unmap
In reply to Allison CollinsQuoted 3 lines · Allison Collins
This 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
I don't see any logical errors.
Quoted 53 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 28 ++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_remote.h | 1 + 2 files changed, 29 insertions(+)fs/xfs/libxfs/xfs_attr_remote.c +28
-0@@ -711,3 +711,31 @@ xfs_attr_rmtval_remove( }return 0 ; } + +/* +* Remove the value associated with an attribute by deleting the out-of-line +* buffer that it is stored on. Returns EAGAIN for the caller to refresh the +* transaction and recall the function +*/ +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 ; +}fs/xfs/libxfs/xfs_attr_remote.h +1
-0@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);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
chandan
PATCH v7 13/19 xfs: 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.
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.
Below is a state machine diagram for attr remove operations. The XFS_DAS_* states indicate places where the function would return -EAGAIN, and then immediately resume from after being recalled by the calling function. States marked as a "subroutine state" indicate that they belong to a subroutine, and so the calling function needs to pass them back to that subroutine to allow it to finish where it left off. But they otherwise do not have a role in the calling function other than just passing through.
xfs_attr_remove_iter()
XFS_DAS_RM_SHRINK ─┐
(subroutine state) │
│
XFS_DAS_RMTVAL_REMOVE ─┤
(subroutine state) │
└─>xfs_attr_node_removename()
│ v
need to remove
┌─n── rmt blocks?
│ │
│ y
│ │
│ v
│ ┌─>XFS_DAS_RMTVAL_REMOVE
│ │ │
│ │ v
│ └──y── more blks
│ to remove?
│ │
│ n
│ │
│ v
│ need to
└─────> shrink tree? ─n─┐
│ │
y │
│ │
v │
XFS_DAS_RM_SHRINK │
│ │
v │
done <─────┘
--- fs/xfs/libxfs/xfs_attr.c | 114 +++++++++++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_da_btree.h | 30 ++++++++++++ fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_acl.c | 2 + fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl.c | 2 + fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 2 + fs/xfs/xfs_xattr.c | 1 + 10 files changed, 141 insertions(+), 16 deletions(-)
fs/xfs/libxfs/xfs_attr.c +98 -16
@@ -368,11 +368,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 function may return -EAGAIN to signal that the transaction needs to be +* rolled. Callers should continue calling this function until they receive a +* return value other than -EAGAIN. +*/ +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_RMTVAL_REMOVE : + goto node; +default : +break ; + } +if (!xfs_inode_hasattr (dp)) { error = -ENOATTR ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {
@@ -381,6 +430,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); }
@@ -895,9 +945,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 ; }
@@ -1218,6 +1267,11 @@ xfs_attr_node_addname(* 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(
@@ -1230,10 +1284,24 @@ xfs_attr_node_removename(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_RMTVAL_REMOVE : + 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.
@@ -1243,6 +1311,14 @@ 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 ) {/* * Fill in disk block numbers in the state structure
@@ -1261,13 +1337,21 @@ xfs_attr_node_removename(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: + +if (args->rmtblkno >0 ) { + error =xfs_attr_rmtval_unmap (args); + +if (error) { +if (error == -EAGAIN ) + args->dac.dela_state =XFS_DAS_RMTVAL_REMOVE ; +return error; + }/* * Refill the state structure with buffers, the prior calls
@@ -1293,17 +1377,15 @@ 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. */
fs/xfs/libxfs/xfs_attr.h +1 -0
@@ -155,6 +155,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);
fs/xfs/libxfs/xfs_da_btree.h +30 -0
@@ -50,9 +50,39 @@ enum xfs_dacmp { };/* +* Enum values for xfs_delattr_context.da_state +* +* These values are used by delayed attribute operations to keep track of where +* they were before they returned -EAGAIN. A return code of -EAGAIN signals the +* calling function to roll the transaction, and then recall the subroutine to +* finish the operation. The enum is then used by the subroutine to jump back +* to where it was and resume executing where it left off. +*/ +enum xfs_delattr_state { +XFS_DAS_RM_SHRINK ,/* We are shrinking the tree */ +XFS_DAS_RMTVAL_REMOVE ,/* We are removing remote value 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; +unsigned 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 */
fs/xfs/scrub/common.c +2 -0
@@ -24,6 +24,8 @@#include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "scrub/scrub.h"
fs/xfs/xfs_acl.c +2 -0
@@ -10,6 +10,8 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trace.h" #include "xfs_error.h"
fs/xfs/xfs_attr_list.c +1 -0
@@ -12,6 +12,7 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h"
fs/xfs/xfs_ioctl.c +2 -0
@@ -15,6 +15,8 @@#include "xfs_iwalk.h" #include "xfs_itable.h" #include "xfs_error.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_bmap.h" #include "xfs_bmap_util.h"
fs/xfs/xfs_ioctl32.c +2 -0
@@ -17,6 +17,8 @@#include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h"
fs/xfs/xfs_iops.c +2 -0
@@ -13,6 +13,8 @@#include "xfs_inode.h" #include "xfs_acl.h" #include "xfs_quota.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" #include "xfs_trace.h"
fs/xfs/xfs_xattr.c +1 -0
@@ -10,6 +10,7 @@#include "xfs_log_format.h" #include "xfs_da_format.h" #include "xfs_inode.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_acl.h"
Signature · 1 line
2.7.4
Re: [PATCH v7 13/19] xfs: Add delay ready attr remove routines
Quoted 50 lines · Allison Collins
This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return
-EAGAINto have the calling routine roll and refresh the transaction. In this series,xfs_attr_remove_argshas becomexfs_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_removenamehas also been modified to use the switch, and a new version ofxfs_attr_remove_argsconsists of a simple loop to refresh the transaction until the operation is completed.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 newxfs_delattr_stateenum 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.Below is a state machine diagram for attr remove operations. The XFS_DAS_* states indicate places where the function would return
-EAGAIN, and then immediately resume from after being recalled by the calling function. States marked as a "subroutine state" indicate that they belong to a subroutine, and so the calling function needs to pass them back to that subroutine to allow it to finish where it left off. But they otherwise do not have a role in the calling function other than just passing through.
xfs_attr_remove_iter()XFS_DAS_RM_SHRINK ─┐ (subroutine state) │ │ XFS_DAS_RMTVAL_REMOVE ─┤ (subroutine state) │ └─>xfs_attr_node_removename() │v
need to remove
┌─n── rmt blocks?
│ │
│ y
│ │
│ v
│ ┌─>XFS_DAS_RMTVAL_REMOVE
│ │ │
│ │ v
│ └──y── more blks
│ to remove?
│ │
│ n
│ │
│ v
│ need to
└─────> shrink tree? ─n─┐
Quoted 9 lines
│ │
y │
│ │
v │
XFS_DAS_RM_SHRINK│
│ │
v │
done <─────┘
Wow. :P I guess I have nothing against verbose commit logs, but I wonder how useful this level of documentation is for a patch that shouldn't really change the existing flow of the operation.
Quoted 22 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 114 +++++++++++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_da_btree.h | 30 ++++++++++++ fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_acl.c | 2 + fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl.c | 2 + fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 2 + fs/xfs/xfs_xattr.c | 1 + 10 files changed, 141 insertions(+), 16 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0@@ -368,11 +368,60 @@ xfs_has_attr(*/ int xfs_attr_remove_args(
fs/xfs/libxfs/xfs_attr.c xfs_has_attr( · line 380
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +10
-0+ struct xfs_da_args *args) +{ +int error =0 ; +int err2 =0 ; + + do { + error = xfs_attr_remove_iter(args); + if (error && error != -EAGAIN) + goto out; +
I'm a little confused on the logic of this loop given that the only caller commits the transaction (which also finishes dfops). IOW, it seems we shouldn't ever need to finish/roll when error != -EAGAIN. If that is the case, this can be simplified to something like:
int
xfs_attr_remove_args(
struct xfs_da_args *args)
{
int error;
do {
error = xfs_attr_remove_iter(args);
if (error != -EAGAIN)
break;
if (args->dac.flags & XFS_DAC_FINISH_TRANS) {
args->dac.flags &= ~XFS_DAC_FINISH_TRANS;
error = xfs_defer_finish(&args->trans);
if (error)
break;
}
error = xfs_trans_roll_inode(&args->trans, args->dp);
if (error)
break;
} while (true);
return error;
}That has the added benefit of eliminating the whole err2 pattern, which always strikes me as a landmine.
fs/xfs/libxfs/xfs_attr.c xfs_has_attr( · line 381
Quoted 1 line
fs/xfs/libxfs/xfs_attr.c +1
-0+if (args->dac.flags &XFS_DAC_FINISH_TRANS ) {
BTW, _FINISH_TRANS also seems misnamed given that we finish deferred operations, not necessarily the transaction. XFS_DAC_DEFER_FINISH?
Quoted 90 lines
fs/xfs/libxfs/xfs_attr.c +54
-3+ 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 function may return -EAGAIN to signal that the transaction needs to be +* rolled. Callers should continue calling this function until they receive a +* return value other than -EAGAIN. +*/ +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_RMTVAL_REMOVE : + goto node; +default : +break ; + } +if (!xfs_inode_hasattr (dp)) { error = -ENOATTR ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {@@ -381,6 +430,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); }@@ -895,9 +945,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 ; }@@ -1218,6 +1267,11 @@ xfs_attr_node_addname(* 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(@@ -1230,10 +1284,24 @@ xfs_attr_node_removename(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_RMTVAL_REMOVE : + goto rm_node_blks; +case XFS_DAS_RM_SHRINK :
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1304
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +6
-0+ goto rm_shrink; +default : +break ; + } error =xfs_attr_node_hasname (args, &state);if (error != -EEXIST ) goto out; +else + error =0 ;
This doesn't look necessary.
Quoted 19 lines
fs/xfs/libxfs/xfs_attr.c +8
-0/* * If there is an out-of-line value, de-allocate the blocks. @@ -1243,6 +1311,14 @@ 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 ) {/* * Fill in disk block numbers in the state structure
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1340
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1@@ -1261,13 +1337,21 @@ xfs_attr_node_removename(if (error) goto out; - error =xfs_trans_roll_inode (&args->trans, args->dp); + error =xfs_attr_rmtval_invalidate (args);
Remind me why we lose the above trans roll? I vaguely recall that this was intentional, but I could be mistaken...
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1if (error) goto out; + } - error =xfs_attr_rmtval_remove (args);
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1352
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +8
-2-if (error) - goto out; +rm_node_blks: + +if (args->rmtblkno >0 ) { + error =xfs_attr_rmtval_unmap (args); + +if (error) { +if (error == -EAGAIN ) + args->dac.dela_state =XFS_DAS_RMTVAL_REMOVE ;
Might be helpful for the code labels to match the state names. I.e., usedas_rmtval_remove: for the label above.
Quoted 17 lines
fs/xfs/libxfs/xfs_attr.c +2
-8+return error; + }/* * Refill the state structure with buffers, the prior calls @@ -1293,17 +1377,15 @@ 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)
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1388
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +7
-1- 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 ; +
There's an xfs_defer_finish() call further down this function. Should that be replaced with the flag?
Finally, I mentioned in a previous review that this function should probably be further broken down before fitting in the state management stuff. It doesn't look like that happened so I've attached a diff that is just intended to give an idea of what I mean by sectioning off the hunks that might be able to break down into helpers. The helpers wouldn't contain any state management, so we create a clear separation between the state code and functional components. I think this initial refactoring would make the introduction of state much more simple (and perhaps alleviate the need for the huge diagram). It might also be interesting to see how much of the result could be folded up further into _removename_iter()...
Brian
Quoted 151 lines
fs/xfs/libxfs/xfs_attr.c +0
-0/* * If the result is small enough, push it all into the inode. */ fs/xfs/libxfs/xfs_attr.h +1
-0@@ -155,6 +155,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);fs/xfs/libxfs/xfs_da_btree.h +30
-0@@ -50,9 +50,39 @@ enum xfs_dacmp { };/* +* Enum values for xfs_delattr_context.da_state +* +* These values are used by delayed attribute operations to keep track of where +* they were before they returned -EAGAIN. A return code of -EAGAIN signals the +* calling function to roll the transaction, and then recall the subroutine to +* finish the operation. The enum is then used by the subroutine to jump back +* to where it was and resume executing where it left off. +*/ +enum xfs_delattr_state { +XFS_DAS_RM_SHRINK ,/* We are shrinking the tree */ +XFS_DAS_RMTVAL_REMOVE ,/* We are removing remote value 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; +unsigned 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 */fs/xfs/scrub/common.c +2
-0@@ -24,6 +24,8 @@#include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "scrub/scrub.h" fs/xfs/xfs_acl.c +2
-0@@ -10,6 +10,8 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trace.h" #include "xfs_error.h" fs/xfs/xfs_attr_list.c +1
-0@@ -12,6 +12,7 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" fs/xfs/xfs_ioctl.c +2
-0@@ -15,6 +15,8 @@#include "xfs_iwalk.h" #include "xfs_itable.h" #include "xfs_error.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_bmap.h" #include "xfs_bmap_util.h" fs/xfs/xfs_ioctl32.c +2
-0@@ -17,6 +17,8 @@#include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" fs/xfs/xfs_iops.c +2
-0@@ -13,6 +13,8 @@#include "xfs_inode.h" #include "xfs_acl.h" #include "xfs_quota.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" #include "xfs_trace.h" fs/xfs/xfs_xattr.c +1
-0@@ -10,6 +10,7 @@#include "xfs_log_format.h" #include "xfs_da_format.h" #include "xfs_inode.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_acl.h" Signature · 1 line
2.7.4
Re: [PATCH v7 13/19] xfs: Add delay ready attr remove routines
Quoted 318 lines · Brian Foster
Quoted 50 lines · Allison Collins
This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return
-EAGAINto have the calling routine roll and refresh the transaction. In this series,xfs_attr_remove_argshas becomexfs_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_removenamehas also been modified to use the switch, and a new version ofxfs_attr_remove_argsconsists of a simple loop to refresh the transaction until the operation is completed.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 newxfs_delattr_stateenum 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.Below is a state machine diagram for attr remove operations. The XFS_DAS_* states indicate places where the function would return
-EAGAIN, and then immediately resume from after being recalled by the calling function. States marked as a "subroutine state" indicate that they belong to a subroutine, and so the calling function needs to pass them back to that subroutine to allow it to finish where it left off. But they otherwise do not have a role in the calling function other than just passing through.
xfs_attr_remove_iter()XFS_DAS_RM_SHRINK ─┐ (subroutine state) │ │ XFS_DAS_RMTVAL_REMOVE ─┤ (subroutine state) │ └─>xfs_attr_node_removename() │v
need to remove
┌─n── rmt blocks?
│ │
│ y
│ │
│ v
│ ┌─>XFS_DAS_RMTVAL_REMOVE
│ │ │
│ │ v
│ └──y── more blks
│ to remove?
│ │
│ n
│ │
│ v
│ need to
└─────> shrink tree? ─n─┐Quoted 9 lines
│ │
y │
│ │
v │
XFS_DAS_RM_SHRINK│
│ │
v │
done <─────┘Wow. :P I guess I have nothing against verbose commit logs, but I wonder how useful this level of documentation is for a patch that shouldn't really change the existing flow of the operation.
Quoted 22 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 114 +++++++++++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_da_btree.h | 30 ++++++++++++ fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_acl.c | 2 + fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl.c | 2 + fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 2 + fs/xfs/xfs_xattr.c | 1 + 10 files changed, 141 insertions(+), 16 deletions(-)fs/xfs/libxfs/xfs_attr.c +0
-0@@ -368,11 +368,60 @@ xfs_has_attr(*/ int xfs_attr_remove_args(fs/xfs/libxfs/xfs_attr.c xfs_has_attr( · line 380
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +10
-0+ struct xfs_da_args *args) +{ +int error =0 ; +int err2 =0 ; + + do { + error = xfs_attr_remove_iter(args); + if (error && error != -EAGAIN) + goto out; +I'm a little confused on the logic of this loop given that the only caller commits the transaction (which also finishes dfops). IOW, it seems we shouldn't ever need to finish/roll when error !=
-EAGAIN. If that is the case, this can be simplified to something like:int
xfs_attr_remove_args(
structxfs_da_args*args){ int error; do { error = xfs_attr_remove_iter(args); if (error != -EAGAIN) break; if (args->dac.flags & XFS_DAC_FINISH_TRANS) { args->dac.flags &= ~XFS_DAC_FINISH_TRANS; error = xfs_defer_finish(&args->trans); if (error) break; } error = xfs_trans_roll_inode(&args->trans, args->dp); if (error) break; } while (true); return error; }That has the added benefit of eliminating the whole err2 pattern, which always strikes me as a landmine.
fs/xfs/libxfs/xfs_attr.c xfs_has_attr( · line 381
Quoted 1 line
fs/xfs/libxfs/xfs_attr.c +1
-0+if (args->dac.flags &XFS_DAC_FINISH_TRANS ) {BTW,
_FINISH_TRANSalso seems misnamed given that we finish deferred operations, not necessarily the transaction.XFS_DAC_DEFER_FINISH?Quoted 90 lines
fs/xfs/libxfs/xfs_attr.c +54
-3+ 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 function may return -EAGAIN to signal that the transaction needs to be +* rolled. Callers should continue calling this function until they receive a +* return value other than -EAGAIN. +*/ +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_RMTVAL_REMOVE : + goto node; +default : +break ; + } +if (!xfs_inode_hasattr (dp)) { error = -ENOATTR ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {@@ -381,6 +430,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); }@@ -895,9 +945,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 ; }@@ -1218,6 +1267,11 @@ xfs_attr_node_addname(* 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(@@ -1230,10 +1284,24 @@ xfs_attr_node_removename(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_RMTVAL_REMOVE : + goto rm_node_blks; +case XFS_DAS_RM_SHRINK :fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1304
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +6
-0+ goto rm_shrink; +default : +break ; + } error =xfs_attr_node_hasname (args, &state);if (error != -EEXIST ) goto out; +else + error =0 ;This doesn't look necessary.
Quoted 19 lines
fs/xfs/libxfs/xfs_attr.c +8
-0/* * If there is an out-of-line value, de-allocate the blocks. @@ -1243,6 +1311,14 @@ 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 ) {/* * Fill in disk block numbers in the state structure fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1340
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1@@ -1261,13 +1337,21 @@ xfs_attr_node_removename(if (error) goto out; - error =xfs_trans_roll_inode (&args->trans, args->dp); + error =xfs_attr_rmtval_invalidate (args);Remind me why we lose the above trans roll? I vaguely recall that this was intentional, but I could be mistaken...
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-1if (error) goto out; + } - error =xfs_attr_rmtval_remove (args);fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1352
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +8
-2-if (error) - goto out; +rm_node_blks: + +if (args->rmtblkno >0 ) { + error =xfs_attr_rmtval_unmap (args); + +if (error) { +if (error == -EAGAIN ) + args->dac.dela_state =XFS_DAS_RMTVAL_REMOVE ;Might be helpful for the code labels to match the state names. I.e., use
das_rmtval_remove: for the label above.Quoted 17 lines
fs/xfs/libxfs/xfs_attr.c +2
-8+return error; + }/* * Refill the state structure with buffers, the prior calls @@ -1293,17 +1377,15 @@ 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)fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1388
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +7
-1- 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 ; +There's an
xfs_defer_finish()call further down this function. Should that be replaced with the flag?
Quoted 12 lines
Finally, I mentioned in a previous review that this function should probably be further broken down before fitting in the state management stuff. It doesn't look like that happened so I've attached a diff that is just intended to give an idea of what I mean by sectioning off the hunks that might be able to break down into helpers. The helpers wouldn't contain any state management, so we create a clear separation between the state code and functional components. I think this initial refactoring would make the introduction of state much more simple (and perhaps alleviate the need for the huge diagram). It might also be interesting to see how much of the result could be folded up further into
_removename_iter()...
Gah.. attached for real this time.
Brian
Quoted 150 lines
Brian
Quoted 148 lines
fs/xfs/libxfs/xfs_attr.c +0
-0/* * If the result is small enough, push it all into the inode. */ fs/xfs/libxfs/xfs_attr.h +1
-0@@ -155,6 +155,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);fs/xfs/libxfs/xfs_da_btree.h +30
-0@@ -50,9 +50,39 @@ enum xfs_dacmp { };/* +* Enum values for xfs_delattr_context.da_state +* +* These values are used by delayed attribute operations to keep track of where +* they were before they returned -EAGAIN. A return code of -EAGAIN signals the +* calling function to roll the transaction, and then recall the subroutine to +* finish the operation. The enum is then used by the subroutine to jump back +* to where it was and resume executing where it left off. +*/ +enum xfs_delattr_state { +XFS_DAS_RM_SHRINK ,/* We are shrinking the tree */ +XFS_DAS_RMTVAL_REMOVE ,/* We are removing remote value 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; +unsigned 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 */fs/xfs/scrub/common.c +2
-0@@ -24,6 +24,8 @@#include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "scrub/scrub.h" fs/xfs/xfs_acl.c +2
-0@@ -10,6 +10,8 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trace.h" #include "xfs_error.h" fs/xfs/xfs_attr_list.c +1
-0@@ -12,6 +12,7 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" fs/xfs/xfs_ioctl.c +2
-0@@ -15,6 +15,8 @@#include "xfs_iwalk.h" #include "xfs_itable.h" #include "xfs_error.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_bmap.h" #include "xfs_bmap_util.h" fs/xfs/xfs_ioctl32.c +2
-0@@ -17,6 +17,8 @@#include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" fs/xfs/xfs_iops.c +2
-0@@ -13,6 +13,8 @@#include "xfs_inode.h" #include "xfs_acl.h" #include "xfs_quota.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" #include "xfs_trace.h" fs/xfs/xfs_xattr.c +1
-0@@ -10,6 +10,7 @@#include "xfs_log_format.h" #include "xfs_da_format.h" #include "xfs_inode.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_acl.h"
Quoted 4 lines
Quoted 3 lines
Signature · 1 line
2.7.4
fs/xfs/libxfs/xfs_attr.c +17 -0
@@ -1297,6 +1297,7 @@ xfs_attr_node_removename(break ; } +#if 0 error =xfs_attr_node_hasname (args, &state);if (error != -EEXIST ) goto out;
@@ -1341,9 +1342,13 @@ xfs_attr_node_removename(if (error) goto out; } +#else + error =xfs_attr_node_removename_setup (); +#endif rm_node_blks: +#if 0 if (args->rmtblkno >0 ) { error =xfs_attr_rmtval_unmap (args);
@@ -1361,6 +1366,11 @@ xfs_attr_node_removename(if (error) goto out; } +#else + args->dac.dela_state =XFS_DAS_RMTVAL_REMOVE ; + error =xfs_attr_node_removename_rmt (); +/* -EAGAIN */ +#endif /* * Remove the name and update the hashvals in the tree.
@@ -1370,6 +1380,7 @@ xfs_attr_node_removename( retval =xfs_attr3_leaf_remove (blk->bp, args);xfs_da3_fixhashpath (state, &state->path); +#if 0 /* * Check to see if the tree needs to be collapsed. */
@@ -1413,6 +1424,12 @@ xfs_attr_node_removename( xfs_trans_brelse(args->trans, bp); } error =0 ; +#else +rm_shrink: + args->dac.dela_state =XFS_DAS_RM_SHRINK ; + error =xfs_attr_node_removename_shrink (); +/* -EAGAIN */ +#endif out:if (state)
Re: [PATCH v7 13/19] xfs: Add delay ready attr remove routines
In reply to Brian FosterQuoted 61 lines · Brian Foster
Quoted 50 lines · Allison Collins
This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return
-EAGAINto have the calling routine roll and refresh the transaction. In this series,xfs_attr_remove_argshas becomexfs_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_removenamehas also been modified to use the switch, and a new version ofxfs_attr_remove_argsconsists of a simple loop to refresh the transaction until the operation is completed.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 newxfs_delattr_stateenum 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.Below is a state machine diagram for attr remove operations. The XFS_DAS_* states indicate places where the function would return
-EAGAIN, and then immediately resume from after being recalled by the calling function. States marked as a "subroutine state" indicate that they belong to a subroutine, and so the calling function needs to pass them back to that subroutine to allow it to finish where it left off. But they otherwise do not have a role in the calling function other than just passing through.
xfs_attr_remove_iter()XFS_DAS_RM_SHRINK ─┐ (subroutine state) │ │ XFS_DAS_RMTVAL_REMOVE ─┤ (subroutine state) │ └─>xfs_attr_node_removename() │v
need to remove
┌─n── rmt blocks?
│ │
│ y
│ │
│ v
│ ┌─>XFS_DAS_RMTVAL_REMOVE
│ │ │
│ │ v
│ └──y── more blks
│ to remove?
│ │
│ n
│ │
│ v
│ need to
└─────> shrink tree? ─n─┐Quoted 9 lines
│ │
y │
│ │
v │
XFS_DAS_RM_SHRINK│
│ │
v │
done <─────┘
Quoted 3 lines
Wow. :P I guess I have nothing against verbose commit logs, but I wonder how useful this level of documentation is for a patch that shouldn't really change the existing flow of the operation.
Yes Darrick had requested a diagram in the last review, so I had put this together. I wasnt sure where the best place to put it even was, so I put it here at least for now. I have no idea if there is a limit on commit message length, but if there is, I'm pretty sure I blew right past it in this patch and the next. Maybe if anything it can just be here for now while we work through things?
Quoted 30 lines
Quoted 30 lines
Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 114 +++++++++++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_attr.h | 1 + fs/xfs/libxfs/xfs_da_btree.h | 30 ++++++++++++ fs/xfs/scrub/common.c | 2 + fs/xfs/xfs_acl.c | 2 + fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_ioctl.c | 2 + fs/xfs/xfs_ioctl32.c | 2 + fs/xfs/xfs_iops.c | 2 + fs/xfs/xfs_xattr.c | 1 + 10 files changed, 141 insertions(+), 16 deletions(-)fs/xfs/libxfs/xfs_attr.c +7
-0@@ -368,11 +368,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);
Quoted 8 lines
fs/xfs/libxfs/xfs_attr.c xfs_has_attr( · line 380
Quoted 3 lines
fs/xfs/libxfs/xfs_attr.c +3
-0+if (error && error != -EAGAIN ) + goto out; +I'm a little confused on the logic of this loop given that the only caller commits the transaction (which also finishes dfops). IOW, it seems we shouldn't ever need to finish/roll when error !=
-EAGAIN. If that is the case, this can be simplified to something like:
Well, we need to do it when error == -EAGAIN or 0, right? Which I think better imitates the defer_finish routines. That's why a lot of the existing code that just finishes off with a transaction just sort of gets sawed off at the end. Otherwise they would need one more state just to return -EAGAIN as the last thing they have to do. Did that make sense?
Quoted 27 lines
int
xfs_attr_remove_args(
structxfs_da_args*args){ int error; do { error = xfs_attr_remove_iter(args); if (error != -EAGAIN) break; if (args->dac.flags & XFS_DAC_FINISH_TRANS) { args->dac.flags &= ~XFS_DAC_FINISH_TRANS; error = xfs_defer_finish(&args->trans); if (error) break; } error = xfs_trans_roll_inode(&args->trans, args->dp); if (error) break; } while (true); return error; }
Quoted 7 lines
That has the added benefit of eliminating the whole err2 pattern, which always strikes me as a landmine.
fs/xfs/libxfs/xfs_attr.c xfs_has_attr( · line 381
Quoted 1 line
fs/xfs/libxfs/xfs_attr.c +1
-0+if (args->dac.flags &XFS_DAC_FINISH_TRANS ) {BTW,
_FINISH_TRANSalso seems misnamed given that we finish deferred operations, not necessarily the transaction.XFS_DAC_DEFER_FINISH?
Sure, will update
Quoted 96 lines
Quoted 96 lines
fs/xfs/libxfs/xfs_attr.c +58
-3+ 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 function may return -EAGAIN to signal that the transaction needs to be +* rolled. Callers should continue calling this function until they receive a +* return value other than -EAGAIN. +*/ +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_RMTVAL_REMOVE : + goto node; +default : +break ; + } +if (!xfs_inode_hasattr (dp)) { error = -ENOATTR ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {@@ -381,6 +430,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); }@@ -895,9 +945,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 ; }@@ -1218,6 +1267,11 @@ xfs_attr_node_addname(* 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(@@ -1230,10 +1284,24 @@ xfs_attr_node_removename(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_RMTVAL_REMOVE : + goto rm_node_blks; +case XFS_DAS_RM_SHRINK : + goto rm_shrink; +default : +break ; + }
Quoted 7 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1304
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +2
-0error =xfs_attr_node_hasname (args, &state);if (error != -EEXIST ) goto out; +else + error =0 ;This doesn't look necessary.
Well, at this point error has to be -EEXIST. Which is great because we need the attr to exist, but we dont want to return that as error for this function. Which can happen if error is not otherwise set.
Quoted 23 lines
Quoted 23 lines
fs/xfs/libxfs/xfs_attr.c +8
-0/* * If there is an out-of-line value, de-allocate the blocks. @@ -1243,6 +1311,14 @@ 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 ) {/* * Fill in disk block numbers in the state structure @@ -1261,13 +1337,21 @@ xfs_attr_node_removename(if (error) goto out;
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1340
Quoted 2 lines
fs/xfs/libxfs/xfs_attr.c +1
-1- error =xfs_trans_roll_inode (&args->trans, args->dp); + error =xfs_attr_rmtval_invalidate (args);Remind me why we lose the above trans roll? I vaguely recall that this was intentional, but I could be mistaken...
I think we removed it in v5. We used to have a XFS_DAS_RM_INVALIDATE state, but then we reasoned that because these are just in-core changes, we didnt need it, so we eliminated this state entirely.
Maybe i just add a comment here? Just as a reminder
Quoted 5 lines
Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +1
-0if (error) goto out; + }
Quoted 14 lines
fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1352
Quoted 11 lines
fs/xfs/libxfs/xfs_attr.c +8
-3- error =xfs_attr_rmtval_remove (args); -if (error) - goto out; +rm_node_blks: + +if (args->rmtblkno >0 ) { + error =xfs_attr_rmtval_unmap (args); + +if (error) { +if (error == -EAGAIN ) + args->dac.dela_state =XFS_DAS_RMTVAL_REMOVE ;Might be helpful for the code labels to match the state names. I.e., use
das_rmtval_remove: for the label above.
Sure, I can update add the das prefix.
Quoted 32 lines
Quoted 18 lines
fs/xfs/libxfs/xfs_attr.c +2
-8+return error; + }/* * Refill the state structure with buffers, the prior calls @@ -1293,17 +1377,15 @@ 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)fs/xfs/libxfs/xfs_attr.c xfs_attr_node_removename( · line 1388
Quoted 10 lines
fs/xfs/libxfs/xfs_attr.c +7
-1- 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 ; +There's an
xfs_defer_finish()call further down this function. Should that be replaced with the flag?
Quoted 7 lines
Finally, I mentioned in a previous review that this function should probably be further broken down before fitting in the state management stuff. It doesn't look like that happened so I've attached a diff that is just intended to give an idea of what I mean by sectioning off the hunks that might be able to break down into helpers. The helpers wouldn't contain any state management, so we create a clear separation between the state code and functional components.
Yes, it's xfs_attr_node_shrink in patch 15. I moved it to another patch to try and keep the activity in this one to a minimum. Apologies if it surprised you! And then i mistakenly had taken the XFS_DAC_FINISH_TRANS flag with it. I meant to keep all the state machine stuff here. Will fix!
I think this initial
Quoted 1 line
refactoring would make the introduction of state much more simple
I guess I didn't think people would be partial to introducing helpers before or after the state logic. I put them after in this set because the states are visible now, so I though it would make the goal of modularizing code between the states more clear to folks. Do you think I should move it back behind the state machine patches?
(and
Quoted 1 line
perhaps alleviate the need for the huge diagram).
Well, I get the impression that people find the series sort of scary and maybe the diagrams help them a bit. Maybe we can take them out later after people feel like they are comfortable with things?
It might also be
Quoted 2 lines
interesting to see how much of the result could be folded up further into
_removename_iter()...
Yes, I think that is the goal we're reaching for. I will add the other helpers I see in your diff too.
Thanks for the reviews!
Allison
Quoted 155 lines
Brian
Quoted 151 lines
fs/xfs/libxfs/xfs_attr.c +0
-0/* * If the result is small enough, push it all into the inode. */ fs/xfs/libxfs/xfs_attr.h +1
-0@@ -155,6 +155,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);fs/xfs/libxfs/xfs_da_btree.h +30
-0@@ -50,9 +50,39 @@ enum xfs_dacmp { };/* +* Enum values for xfs_delattr_context.da_state +* +* These values are used by delayed attribute operations to keep track of where +* they were before they returned -EAGAIN. A return code of -EAGAIN signals the +* calling function to roll the transaction, and then recall the subroutine to +* finish the operation. The enum is then used by the subroutine to jump back +* to where it was and resume executing where it left off. +*/ +enum xfs_delattr_state { +XFS_DAS_RM_SHRINK ,/* We are shrinking the tree */ +XFS_DAS_RMTVAL_REMOVE ,/* We are removing remote value 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; +unsigned 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 */fs/xfs/scrub/common.c +2
-0@@ -24,6 +24,8 @@#include "xfs_rmap_btree.h" #include "xfs_log.h" #include "xfs_trans_priv.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_reflink.h" #include "scrub/scrub.h" fs/xfs/xfs_acl.c +2
-0@@ -10,6 +10,8 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trace.h" #include "xfs_error.h" fs/xfs/xfs_attr_list.c +1
-0@@ -12,6 +12,7 @@#include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_inode.h" #include "xfs_trans.h" #include "xfs_bmap.h" fs/xfs/xfs_ioctl.c +2
-0@@ -15,6 +15,8 @@#include "xfs_iwalk.h" #include "xfs_itable.h" #include "xfs_error.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_bmap.h" #include "xfs_bmap_util.h" fs/xfs/xfs_ioctl32.c +2
-0@@ -17,6 +17,8 @@#include "xfs_itable.h" #include "xfs_fsops.h" #include "xfs_rtalloc.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_ioctl.h" #include "xfs_ioctl32.h" fs/xfs/xfs_iops.c +2
-0@@ -13,6 +13,8 @@#include "xfs_inode.h" #include "xfs_acl.h" #include "xfs_quota.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" #include "xfs_trace.h" fs/xfs/xfs_xattr.c +1
-0@@ -10,6 +10,7 @@#include "xfs_log_format.h" #include "xfs_da_format.h" #include "xfs_inode.h" +#include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_acl.h" Signature · 1 line
2.7.4