Commit 06476a69 authored by Alex Elder's avatar Alex Elder

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).
Signed-off-by: default avatarAlex Elder <elder@dreamhost.com>
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent b829c195
...@@ -126,14 +126,19 @@ static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode) ...@@ -126,14 +126,19 @@ static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode)
return NULL; 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) const char *name)
{ {
do { struct ceph_vxattr_cb *vxattr = ceph_inode_vxattrs(inode);
if (strcmp(vxattr->name, name) == 0)
return vxattr; if (vxattr) {
vxattr++; while (vxattr->name) {
} while (vxattr->name); if (!strcmp(vxattr->name, name))
return vxattr;
vxattr++;
}
}
return NULL; return NULL;
} }
...@@ -502,7 +507,6 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, ...@@ -502,7 +507,6 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
int err; int err;
struct ceph_inode_xattr *xattr; struct ceph_inode_xattr *xattr;
struct ceph_vxattr_cb *vxattr = NULL; struct ceph_vxattr_cb *vxattr = NULL;
...@@ -511,8 +515,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, ...@@ -511,8 +515,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
return -ENODATA; return -ENODATA;
/* let's see if a virtual xattr was requested */ /* let's see if a virtual xattr was requested */
if (vxattrs) vxattr = ceph_match_vxattr(inode, name);
vxattr = ceph_match_vxattr(vxattrs, name);
spin_lock(&ci->i_ceph_lock); spin_lock(&ci->i_ceph_lock);
dout("getxattr %p ver=%lld index_ver=%lld\n", inode, dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
...@@ -698,8 +701,8 @@ int ceph_setxattr(struct dentry *dentry, const char *name, ...@@ -698,8 +701,8 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags) const void *value, size_t size, int flags)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct ceph_vxattr_cb *vxattr;
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
int err; int err;
int name_len = strlen(name); int name_len = strlen(name);
int val_len = size; int val_len = size;
...@@ -716,12 +719,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name, ...@@ -716,12 +719,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
if (!ceph_is_valid_xattr(name)) if (!ceph_is_valid_xattr(name))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (vxattrs) { vxattr = ceph_match_vxattr(inode, name);
struct ceph_vxattr_cb *vxattr = if (vxattr && vxattr->readonly)
ceph_match_vxattr(vxattrs, name); return -EOPNOTSUPP;
if (vxattr && vxattr->readonly)
return -EOPNOTSUPP;
}
/* preallocate memory for xattr name, value, index node */ /* preallocate memory for xattr name, value, index node */
err = -ENOMEM; err = -ENOMEM;
...@@ -814,8 +814,8 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name) ...@@ -814,8 +814,8 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name)
int ceph_removexattr(struct dentry *dentry, const char *name) int ceph_removexattr(struct dentry *dentry, const char *name)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct ceph_vxattr_cb *vxattr;
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
int issued; int issued;
int err; int err;
int required_blob_size; int required_blob_size;
...@@ -827,12 +827,9 @@ int ceph_removexattr(struct dentry *dentry, const char *name) ...@@ -827,12 +827,9 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
if (!ceph_is_valid_xattr(name)) if (!ceph_is_valid_xattr(name))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (vxattrs) { vxattr = ceph_match_vxattr(inode, name);
struct ceph_vxattr_cb *vxattr = if (vxattr && vxattr->readonly)
ceph_match_vxattr(vxattrs, name); return -EOPNOTSUPP;
if (vxattr && vxattr->readonly)
return -EOPNOTSUPP;
}
err = -ENOMEM; err = -ENOMEM;
spin_lock(&ci->i_ceph_lock); spin_lock(&ci->i_ceph_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment