diff options
author | Alex Elder <elder@dreamhost.com> | 2012-01-23 16:49:28 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:46 -0400 |
commit | 18fa8b3feaac772925263b04b1429d80e2dfd779 (patch) | |
tree | e9f6070faf16baf17bec93caa476afffeaa903b7 /fs/ceph | |
parent | 3ce6cd1233046eb97d6d2bd5d80c1cd40528ea2f (diff) |
ceph: make ceph_setxattr() and ceph_removexattr() more alike
This patch just rearranges a few bits of code to make more
portions of ceph_setxattr() and ceph_removexattr() identical.
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 | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 88eaedf78fa9..8294f461ecd1 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -765,15 +765,15 @@ int ceph_setxattr(struct dentry *dentry, const char *name, | |||
765 | struct inode *inode = dentry->d_inode; | 765 | struct inode *inode = dentry->d_inode; |
766 | struct ceph_vxattr *vxattr; | 766 | struct ceph_vxattr *vxattr; |
767 | struct ceph_inode_info *ci = ceph_inode(inode); | 767 | struct ceph_inode_info *ci = ceph_inode(inode); |
768 | int issued; | ||
768 | int err; | 769 | int err; |
770 | int dirty; | ||
769 | int name_len = strlen(name); | 771 | int name_len = strlen(name); |
770 | int val_len = size; | 772 | int val_len = size; |
771 | char *newname = NULL; | 773 | char *newname = NULL; |
772 | char *newval = NULL; | 774 | char *newval = NULL; |
773 | struct ceph_inode_xattr *xattr = NULL; | 775 | struct ceph_inode_xattr *xattr = NULL; |
774 | int issued; | ||
775 | int required_blob_size; | 776 | int required_blob_size; |
776 | int dirty; | ||
777 | 777 | ||
778 | if (ceph_snap(inode) != CEPH_NOSNAP) | 778 | if (ceph_snap(inode) != CEPH_NOSNAP) |
779 | return -EROFS; | 779 | return -EROFS; |
@@ -804,6 +804,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name, | |||
804 | spin_lock(&ci->i_ceph_lock); | 804 | spin_lock(&ci->i_ceph_lock); |
805 | retry: | 805 | retry: |
806 | issued = __ceph_caps_issued(ci, NULL); | 806 | issued = __ceph_caps_issued(ci, NULL); |
807 | dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued)); | ||
807 | if (!(issued & CEPH_CAP_XATTR_EXCL)) | 808 | if (!(issued & CEPH_CAP_XATTR_EXCL)) |
808 | goto do_sync; | 809 | goto do_sync; |
809 | __build_xattrs(inode); | 810 | __build_xattrs(inode); |
@@ -812,7 +813,7 @@ retry: | |||
812 | 813 | ||
813 | if (!ci->i_xattrs.prealloc_blob || | 814 | if (!ci->i_xattrs.prealloc_blob || |
814 | required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) { | 815 | required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) { |
815 | struct ceph_buffer *blob = NULL; | 816 | struct ceph_buffer *blob; |
816 | 817 | ||
817 | spin_unlock(&ci->i_ceph_lock); | 818 | spin_unlock(&ci->i_ceph_lock); |
818 | dout(" preaallocating new blob size=%d\n", required_blob_size); | 819 | dout(" preaallocating new blob size=%d\n", required_blob_size); |
@@ -826,12 +827,13 @@ retry: | |||
826 | goto retry; | 827 | goto retry; |
827 | } | 828 | } |
828 | 829 | ||
829 | dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued)); | ||
830 | err = __set_xattr(ci, newname, name_len, newval, | 830 | err = __set_xattr(ci, newname, name_len, newval, |
831 | val_len, 1, 1, 1, &xattr); | 831 | val_len, 1, 1, 1, &xattr); |
832 | |||
832 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); | 833 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); |
833 | ci->i_xattrs.dirty = true; | 834 | ci->i_xattrs.dirty = true; |
834 | inode->i_ctime = CURRENT_TIME; | 835 | inode->i_ctime = CURRENT_TIME; |
836 | |||
835 | spin_unlock(&ci->i_ceph_lock); | 837 | spin_unlock(&ci->i_ceph_lock); |
836 | if (dirty) | 838 | if (dirty) |
837 | __mark_inode_dirty(inode, dirty); | 839 | __mark_inode_dirty(inode, dirty); |
@@ -895,13 +897,13 @@ int ceph_removexattr(struct dentry *dentry, const char *name) | |||
895 | 897 | ||
896 | err = -ENOMEM; | 898 | err = -ENOMEM; |
897 | spin_lock(&ci->i_ceph_lock); | 899 | spin_lock(&ci->i_ceph_lock); |
898 | __build_xattrs(inode); | ||
899 | retry: | 900 | retry: |
900 | issued = __ceph_caps_issued(ci, NULL); | 901 | issued = __ceph_caps_issued(ci, NULL); |
901 | dout("removexattr %p issued %s\n", inode, ceph_cap_string(issued)); | 902 | dout("removexattr %p issued %s\n", inode, ceph_cap_string(issued)); |
902 | 903 | ||
903 | if (!(issued & CEPH_CAP_XATTR_EXCL)) | 904 | if (!(issued & CEPH_CAP_XATTR_EXCL)) |
904 | goto do_sync; | 905 | goto do_sync; |
906 | __build_xattrs(inode); | ||
905 | 907 | ||
906 | required_blob_size = __get_required_blob_size(ci, 0, 0); | 908 | required_blob_size = __get_required_blob_size(ci, 0, 0); |
907 | 909 | ||
@@ -922,10 +924,10 @@ retry: | |||
922 | } | 924 | } |
923 | 925 | ||
924 | err = __remove_xattr_by_name(ceph_inode(inode), name); | 926 | err = __remove_xattr_by_name(ceph_inode(inode), name); |
927 | |||
925 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); | 928 | dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); |
926 | ci->i_xattrs.dirty = true; | 929 | ci->i_xattrs.dirty = true; |
927 | inode->i_ctime = CURRENT_TIME; | 930 | inode->i_ctime = CURRENT_TIME; |
928 | |||
929 | spin_unlock(&ci->i_ceph_lock); | 931 | spin_unlock(&ci->i_ceph_lock); |
930 | if (dirty) | 932 | if (dirty) |
931 | __mark_inode_dirty(inode, dirty); | 933 | __mark_inode_dirty(inode, dirty); |