Skip to content

Commit 18fa8b3

Browse files
author
Alex Elder
committed
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>
1 parent 3ce6cd1 commit 18fa8b3

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎fs/ceph/xattr.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,15 +765,15 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
765765
struct inode *inode = dentry->d_inode;
766766
struct ceph_vxattr *vxattr;
767767
struct ceph_inode_info *ci = ceph_inode(inode);
768+
int issued;
768769
int err;
770+
int dirty;
769771
int name_len = strlen(name);
770772
int val_len = size;
771773
char *newname = NULL;
772774
char *newval = NULL;
773775
struct ceph_inode_xattr *xattr = NULL;
774-
int issued;
775776
int required_blob_size;
776-
int dirty;
777777

778778
if (ceph_snap(inode) != CEPH_NOSNAP)
779779
return -EROFS;
@@ -804,6 +804,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
804804
spin_lock(&ci->i_ceph_lock);
805805
retry:
806806
issued = __ceph_caps_issued(ci, NULL);
807+
dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued));
807808
if (!(issued & CEPH_CAP_XATTR_EXCL))
808809
goto do_sync;
809810
__build_xattrs(inode);
@@ -812,7 +813,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
812813

813814
if (!ci->i_xattrs.prealloc_blob ||
814815
required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) {
815-
struct ceph_buffer *blob = NULL;
816+
struct ceph_buffer *blob;
816817

817818
spin_unlock(&ci->i_ceph_lock);
818819
dout(" preaallocating new blob size=%d\n", required_blob_size);
@@ -826,12 +827,13 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
826827
goto retry;
827828
}
828829

829-
dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued));
830830
err = __set_xattr(ci, newname, name_len, newval,
831831
val_len, 1, 1, 1, &xattr);
832+
832833
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
833834
ci->i_xattrs.dirty = true;
834835
inode->i_ctime = CURRENT_TIME;
836+
835837
spin_unlock(&ci->i_ceph_lock);
836838
if (dirty)
837839
__mark_inode_dirty(inode, dirty);
@@ -895,13 +897,13 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
895897

896898
err = -ENOMEM;
897899
spin_lock(&ci->i_ceph_lock);
898-
__build_xattrs(inode);
899900
retry:
900901
issued = __ceph_caps_issued(ci, NULL);
901902
dout("removexattr %p issued %s\n", inode, ceph_cap_string(issued));
902903

903904
if (!(issued & CEPH_CAP_XATTR_EXCL))
904905
goto do_sync;
906+
__build_xattrs(inode);
905907

906908
required_blob_size = __get_required_blob_size(ci, 0, 0);
907909

@@ -922,10 +924,10 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
922924
}
923925

924926
err = __remove_xattr_by_name(ceph_inode(inode), name);
927+
925928
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
926929
ci->i_xattrs.dirty = true;
927930
inode->i_ctime = CURRENT_TIME;
928-
929931
spin_unlock(&ci->i_ceph_lock);
930932
if (dirty)
931933
__mark_inode_dirty(inode, dirty);

0 commit comments

Comments
 (0)