ceph: pass inode rather than table to ceph_match_vxattr()
PATCH 1/1 ceph: pass inode rather than table to ceph_match_vxattr()
All callers of ceph_match_vxattr() determine what to pass as the first argument by calling ceph_inode_vxattrs(inode). Just do that inside ceph_match_vxattr() itself, changing it to take an inode rather than the vxattr pointer as its first argument.
Also ensure the function works correctly for an empty table (i.e., containing only a terminating null entry).
--- fs/ceph/xattr.c | 42 +++++++++++++++++++----------------------- 1 files changed, 19 insertions(+), 23 deletions(-)
fs/ceph/xattr.c +19 -23
@@ -126,14 +126,18 @@ static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode)return NULL ; } -static struct ceph_vxattr_cb *ceph_match_vxattr (struct ceph_vxattr_cb *vxattr, +static struct ceph_vxattr_cb *ceph_match_vxattr (struct inode *inode,const char *name) { -do { -if (strcmp (vxattr->name, name) ==0 ) -return vxattr; - vxattr++; - }while (vxattr->name); +struct ceph_vxattr_cb *vxattr =ceph_inode_vxattrs (inode); + +if (vxattr) +while (vxattr->name) { +if (!strcmp (vxattr->name, name)) +return vxattr; + vxattr++; + } +return NULL ; }
@@ -502,7 +506,6 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, {struct inode *inode = dentry->d_inode;struct ceph_inode_info *ci =ceph_inode (inode); -struct ceph_vxattr_cb *vxattrs =ceph_inode_vxattrs (inode);int err;struct ceph_inode_xattr *xattr;struct ceph_vxattr_cb *vxattr =NULL ;
@@ -511,8 +514,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,return -ENODATA ;/* let's see if a virtual xattr was requested */ -if (vxattrs) - vxattr =ceph_match_vxattr (vxattrs, name); + vxattr =ceph_match_vxattr (inode, name);spin_lock (&ci->i_ceph_lock); dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
@@ -698,8 +700,8 @@ int ceph_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { struct inode *inode = dentry->d_inode; +struct ceph_vxattr_cb *vxattr;struct ceph_inode_info *ci =ceph_inode (inode); -struct ceph_vxattr_cb *vxattrs =ceph_inode_vxattrs (inode);int err;int name_len =strlen (name);int val_len = size;
@@ -716,12 +718,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name,if (!ceph_is_valid_xattr (name))return -EOPNOTSUPP ; -if (vxattrs) { -struct ceph_vxattr_cb *vxattr = -ceph_match_vxattr (vxattrs, name); -if (vxattr && vxattr->readonly) -return -EOPNOTSUPP ; - } + vxattr =ceph_match_vxattr (inode, name); +if (vxattr && vxattr->readonly) +return -EOPNOTSUPP ;/* preallocate memory for xattr name, value, index node */ err = -ENOMEM ;
@@ -814,8 +813,8 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name)int ceph_removexattr (struct dentry *dentry,const char *name) {struct inode *inode = dentry->d_inode; +struct ceph_vxattr_cb *vxattr;struct ceph_inode_info *ci =ceph_inode (inode); -struct ceph_vxattr_cb *vxattrs =ceph_inode_vxattrs (inode);int issued;int err;int dirty;
@@ -826,12 +825,9 @@ int ceph_removexattr(struct dentry *dentry, const char *name)if (!ceph_is_valid_xattr (name))return -EOPNOTSUPP ; -if (vxattrs) { -struct ceph_vxattr_cb *vxattr = -ceph_match_vxattr (vxattrs, name); -if (vxattr && vxattr->readonly) -return -EOPNOTSUPP ; - } + vxattr =ceph_match_vxattr (inode, name); +if (vxattr && vxattr->readonly) +return -EOPNOTSUPP ;spin_lock (&ci->i_ceph_lock);__build_xattrs (inode);
Signature · 1 line
1.7.5.4
Quoted 26 lines · Alex Elder
All callers of
ceph_match_vxattr()determine what to pass as the first argument by callingceph_inode_vxattrs(inode). Just do that insideceph_match_vxattr()itself, changing it to take an inode rather than the vxattr pointer as its first argument.Also ensure the function works correctly for an empty table (i.e., containing only a terminating null entry).
Signed-off-by Alex Elder <[email protected]>---
fs/ceph/xattr.c | 42 +++++++++++++++++++-----------------------1 files changed, 19 insertions(+), 23 deletions(-)fs/ceph/xattr.c +1
-1@@ -126,14 +126,18 @@ static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode) return NULL; } -static struct ceph_vxattr_cb *ceph_match_vxattr(struct ceph_vxattr_cb *vxattr, +static struct ceph_vxattr_cb *ceph_match_vxattr(struct inode *inode,
fs/ceph/xattr.c static struct ceph_vxattr_cb · line 136
Quoted 10 lines
fs/ceph/xattr.c +3
-5const char *name) { - do { - if (strcmp(vxattr->name, name) == 0) - return vxattr; - vxattr++; - } while (vxattr->name); + struct ceph_vxattr_cb *vxattr = ceph_inode_vxattrs(inode); + + if (vxattr)
if (vxattr) {
fs/ceph/xattr.c static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode) · line 140
Quoted 6 lines
fs/ceph/xattr.c +6
-0+ while (vxattr->name) { + if (!strcmp(vxattr->name, name)) + return vxattr; + vxattr++; + } +
}
Quoted 82 lines
fs/ceph/xattr.c +0
-0return NULL;}
fs/ceph/xattr.c +0
-1@@ -502,7 +506,6 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, { struct inode *inode = dentry->d_inode; struct ceph_inode_info *ci = ceph_inode(inode); - struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); int err; struct ceph_inode_xattr *xattr;struct
ceph_vxattr_cb*vxattr = NULL;fs/ceph/xattr.c +1
-2@@ -511,8 +514,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, return -ENODATA; /* let's see if a virtual xattr was requested */ - if (vxattrs) - vxattr = ceph_match_vxattr(vxattrs, name); + vxattr = ceph_match_vxattr(inode, name); spin_lock(&ci->i_ceph_lock);dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
fs/ceph/xattr.c +1
-1@@ -698,8 +700,8 @@ int ceph_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { struct inode *inode = dentry->d_inode; + struct ceph_vxattr_cb *vxattr; struct ceph_inode_info *ci = ceph_inode(inode); - struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); int err; int name_len = strlen(name);int
val_len= size;fs/ceph/xattr.c +3
-6@@ -716,12 +718,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name, if (!ceph_is_valid_xattr(name)) return -EOPNOTSUPP; - if (vxattrs) { - struct ceph_vxattr_cb *vxattr = - ceph_match_vxattr(vxattrs, name); - if (vxattr && vxattr->readonly) - return -EOPNOTSUPP; - } + vxattr = ceph_match_vxattr(inode, name); + if (vxattr && vxattr->readonly) + return -EOPNOTSUPP; /* preallocate memory for xattr name, value, index node */err =
-ENOMEM;fs/ceph/xattr.c +1
-1@@ -814,8 +813,8 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name) int ceph_removexattr(struct dentry *dentry, const char *name) { struct inode *inode = dentry->d_inode; + struct ceph_vxattr_cb *vxattr; struct ceph_inode_info *ci = ceph_inode(inode); - struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); int issued; int err;int dirty;
fs/ceph/xattr.c +3
-6@@ -826,12 +825,9 @@ int ceph_removexattr(struct dentry *dentry, const char *name) if (!ceph_is_valid_xattr(name)) return -EOPNOTSUPP; - if (vxattrs) { - struct ceph_vxattr_cb *vxattr = - ceph_match_vxattr(vxattrs, name); - if (vxattr && vxattr->readonly) - return -EOPNOTSUPP; - } + vxattr = ceph_match_vxattr(inode, name); + if (vxattr && vxattr->readonly) + return -EOPNOTSUPP; spin_lock(&ci->i_ceph_lock);__build_xattrs(inode);
--
1.7.5.4
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 128 lines · Alex Elder
All callers of
ceph_match_vxattr()determine what to pass as the first argument by callingceph_inode_vxattrs(inode). Just do that insideceph_match_vxattr()itself, changing it to take an inode rather than the vxattr pointer as its first argument.Also ensure the function works correctly for an empty table (i.e., containing only a terminating null entry).
Signed-off-by Alex Elder <[email protected]>--- fs/ceph/xattr.c | 42 +++++++++++++++++++----------------------- 1 files changed, 19 insertions(+), 23 deletions(-)fs/ceph/xattr.c +10
-6@@ -126,14 +126,18 @@ static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode)return NULL ; } -static struct ceph_vxattr_cb *ceph_match_vxattr (struct ceph_vxattr_cb *vxattr, +static struct ceph_vxattr_cb *ceph_match_vxattr(struct inode *inode,const char *name) { -do { -if (strcmp (vxattr->name, name) ==0 ) -return vxattr; - vxattr++; - }while (vxattr->name); +struct ceph_vxattr_cb *vxattr =ceph_inode_vxattrs (inode); + +if (vxattr) +while (vxattr->name) { +if (!strcmp (vxattr->name, name)) +return vxattr; + vxattr++; + } +return NULL ;}
fs/ceph/xattr.c +0
-1@@ -502,7 +506,6 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, {struct inode *inode = dentry->d_inode;struct ceph_inode_info *ci =ceph_inode (inode); -struct ceph_vxattr_cb *vxattrs =ceph_inode_vxattrs (inode);int err;struct ceph_inode_xattr *xattr;fs/ceph/xattr.c +1
-2struct ceph_vxattr_cb *vxattr =NULL ;@@ -511,8 +514,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, return -ENODATA ;/* let's see if a virtual xattr was requested */ -if (vxattrs) - vxattr =ceph_match_vxattr (vxattrs, name); + vxattr =ceph_match_vxattr (inode, name);spin_lock (&ci->i_ceph_lock);fs/ceph/xattr.c +4
-7dout("getxattr %p ver=%lld index_ver=%lld\n", inode,@@ -698,8 +700,8 @@ int ceph_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { struct inode *inode = dentry->d_inode; +struct ceph_vxattr_cb *vxattr;struct ceph_inode_info *ci =ceph_inode (inode); -struct ceph_vxattr_cb *vxattrs =ceph_inode_vxattrs (inode);int err;int name_len =strlen (name);int val_len = size;@@ -716,12 +718,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name, if (!ceph_is_valid_xattr(name)) return -EOPNOTSUPP; -if (vxattrs) { -struct ceph_vxattr_cb *vxattr = -ceph_match_vxattr (vxattrs, name); -if (vxattr && vxattr->readonly) -return -EOPNOTSUPP ; - } + vxattr =ceph_match_vxattr (inode, name); +if (vxattr && vxattr->readonly) +return -EOPNOTSUPP ;/* preallocate memory for xattr name, value, index node */ fs/ceph/xattr.c +1
-1err = -ENOMEM ;@@ -814,8 +813,8 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name) int ceph_removexattr(struct dentry *dentry, const char *name) {struct inode *inode = dentry->d_inode; +struct ceph_vxattr_cb *vxattr;struct ceph_inode_info *ci =ceph_inode (inode); -struct ceph_vxattr_cb *vxattrs =ceph_inode_vxattrs (inode);int issued;int err;fs/ceph/xattr.c +3
-6int dirty;@@ -826,12 +825,9 @@ int ceph_removexattr(struct dentry *dentry, const char *name)if (!ceph_is_valid_xattr (name))return -EOPNOTSUPP ; -if (vxattrs) { -struct ceph_vxattr_cb *vxattr = -ceph_match_vxattr (vxattrs, name); -if (vxattr && vxattr->readonly) -return -EOPNOTSUPP ; - } + vxattr =ceph_match_vxattr (inode, name); +if (vxattr && vxattr->readonly) +return -EOPNOTSUPP ;spin_lock (&ci->i_ceph_lock);
__build_xattrs(inode);Signature · 6 lines
1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html