diff options
author | Alex Elder <elder@dreamhost.com> | 2012-01-23 16:49:27 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:46 -0400 |
commit | 06476a69d8954f36a15ff5ddbfd47bdfcff22791 (patch) | |
tree | 3fc48b0e9610b498b41eacbd1b23cce40ab456ec /fs/ceph | |
parent | b829c1954dbeb42a1277a8cb05943050ee70be94 (diff) |
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: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/xattr.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index bfff735091f5..3418615c53ea 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -126,14 +126,19 @@ static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode) | |||
126 | return NULL; | 126 | return NULL; |
127 | } | 127 | } |
128 | 128 | ||
129 | static struct ceph_vxattr_cb *ceph_match_vxattr(struct ceph_vxattr_cb *vxattr, | 129 | static struct ceph_vxattr_cb *ceph_match_vxattr(struct inode *inode, |
130 | const char *name) | 130 | const char *name) |
131 | { | 131 | { |
132 | do { | 132 | struct ceph_vxattr_cb *vxattr = ceph_inode_vxattrs(inode); |
133 | if (strcmp(vxattr->name, name) == 0) | 133 | |
134 | return vxattr; | 134 | if (vxattr) { |
135 | vxattr++; | 135 | while (vxattr->name) { |
136 | } while (vxattr->name); | 136 | if (!strcmp(vxattr->name, name)) |
137 | return vxattr; | ||
138 | vxattr++; | ||
139 | } | ||
140 | } | ||
141 | |||
137 | return NULL; | 142 | return NULL; |
138 | } | 143 | } |
139 | 144 | ||
@@ -502,7 +507,6 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, | |||
502 | { | 507 | { |
503 | struct inode *inode = dentry->d_inode; | 508 | struct inode *inode = dentry->d_inode; |
504 | struct ceph_inode_info *ci = ceph_inode(inode); | 509 | struct ceph_inode_info *ci = ceph_inode(inode); |
505 | struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); | ||
506 | int err; | 510 | int err; |
507 | struct ceph_inode_xattr *xattr; | 511 | struct ceph_inode_xattr *xattr; |
508 | struct ceph_vxattr_cb *vxattr = NULL; | 512 | struct ceph_vxattr_cb *vxattr = NULL; |
@@ -511,8 +515,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, | |||
511 | return -ENODATA; | 515 | return -ENODATA; |
512 | 516 | ||
513 | /* let's see if a virtual xattr was requested */ | 517 | /* let's see if a virtual xattr was requested */ |
514 | if (vxattrs) | 518 | vxattr = ceph_match_vxattr(inode, name); |
515 | vxattr = ceph_match_vxattr(vxattrs, name); | ||
516 | 519 | ||
517 | spin_lock(&ci->i_ceph_lock); | 520 | spin_lock(&ci->i_ceph_lock); |
518 | dout("getxattr %p ver=%lld index_ver=%lld\n", inode, | 521 | dout("getxattr %p ver=%lld index_ver=%lld\n", inode, |
@@ -698,8 +701,8 @@ int ceph_setxattr(struct dentry *dentry, const char *name, | |||
698 | const void *value, size_t size, int flags) | 701 | const void *value, size_t size, int flags) |
699 | { | 702 | { |
700 | struct inode *inode = dentry->d_inode; | 703 | struct inode *inode = dentry->d_inode; |
704 | struct ceph_vxattr_cb *vxattr; | ||
701 | struct ceph_inode_info *ci = ceph_inode(inode); | 705 | struct ceph_inode_info *ci = ceph_inode(inode); |
702 | struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); | ||
703 | int err; | 706 | int err; |
704 | int name_len = strlen(name); | 707 | int name_len = strlen(name); |
705 | int val_len = size; | 708 | int val_len = size; |
@@ -716,12 +719,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name, | |||
716 | if (!ceph_is_valid_xattr(name)) | 719 | if (!ceph_is_valid_xattr(name)) |
717 | return -EOPNOTSUPP; | 720 | return -EOPNOTSUPP; |
718 | 721 | ||
719 | if (vxattrs) { | 722 | vxattr = ceph_match_vxattr(inode, name); |
720 | struct ceph_vxattr_cb *vxattr = | 723 | if (vxattr && vxattr->readonly) |
721 | ceph_match_vxattr(vxattrs, name); | 724 | return -EOPNOTSUPP; |
722 | if (vxattr && vxattr->readonly) | ||
723 | return -EOPNOTSUPP; | ||
724 | } | ||
725 | 725 | ||
726 | /* preallocate memory for xattr name, value, index node */ | 726 | /* preallocate memory for xattr name, value, index node */ |
727 | err = -ENOMEM; | 727 | err = -ENOMEM; |
@@ -814,8 +814,8 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name) | |||
814 | int ceph_removexattr(struct dentry *dentry, const char *name) | 814 | int ceph_removexattr(struct dentry *dentry, const char *name) |
815 | { | 815 | { |
816 | struct inode *inode = dentry->d_inode; | 816 | struct inode *inode = dentry->d_inode; |
817 | struct ceph_vxattr_cb *vxattr; | ||
817 | struct ceph_inode_info *ci = ceph_inode(inode); | 818 | struct ceph_inode_info *ci = ceph_inode(inode); |
818 | struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); | ||
819 | int issued; | 819 | int issued; |
820 | int err; | 820 | int err; |
821 | int required_blob_size; | 821 | int required_blob_size; |
@@ -827,12 +827,9 @@ int ceph_removexattr(struct dentry *dentry, const char *name) | |||
827 | if (!ceph_is_valid_xattr(name)) | 827 | if (!ceph_is_valid_xattr(name)) |
828 | return -EOPNOTSUPP; | 828 | return -EOPNOTSUPP; |
829 | 829 | ||
830 | if (vxattrs) { | 830 | vxattr = ceph_match_vxattr(inode, name); |
831 | struct ceph_vxattr_cb *vxattr = | 831 | if (vxattr && vxattr->readonly) |
832 | ceph_match_vxattr(vxattrs, name); | 832 | return -EOPNOTSUPP; |
833 | if (vxattr && vxattr->readonly) | ||
834 | return -EOPNOTSUPP; | ||
835 | } | ||
836 | 833 | ||
837 | err = -ENOMEM; | 834 | err = -ENOMEM; |
838 | spin_lock(&ci->i_ceph_lock); | 835 | spin_lock(&ci->i_ceph_lock); |