aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/xattr.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2014-02-11 00:04:19 -0500
committerSage Weil <sage@inktank.com>2014-02-17 15:37:09 -0500
commitbcdfeb2eb4e42b811950b9cd226109291051732a (patch)
treee84702e81ccca42d63e4e6ad8eece9e60bf5b8cd /fs/ceph/xattr.c
parentfbc0b970ddfab4b35dad27ebaae712af680bdc7e (diff)
ceph: remove xattr when null value is given to setxattr()
For the setxattr request, introduce a new flag CEPH_XATTR_REMOVE to distinguish null value case from the zero-length value case. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Diffstat (limited to 'fs/ceph/xattr.c')
-rw-r--r--fs/ceph/xattr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 28f9793b9167..231c02b16c0c 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -12,6 +12,9 @@
12#define XATTR_CEPH_PREFIX "ceph." 12#define XATTR_CEPH_PREFIX "ceph."
13#define XATTR_CEPH_PREFIX_LEN (sizeof (XATTR_CEPH_PREFIX) - 1) 13#define XATTR_CEPH_PREFIX_LEN (sizeof (XATTR_CEPH_PREFIX) - 1)
14 14
15static int __remove_xattr(struct ceph_inode_info *ci,
16 struct ceph_inode_xattr *xattr);
17
15/* 18/*
16 * List of handlers for synthetic system.* attributes. Other 19 * List of handlers for synthetic system.* attributes. Other
17 * attributes are handled directly. 20 * attributes are handled directly.
@@ -359,6 +362,12 @@ static int __set_xattr(struct ceph_inode_info *ci,
359 kfree(val); 362 kfree(val);
360 return err; 363 return err;
361 } 364 }
365 if (update_xattr < 0) {
366 if (xattr)
367 __remove_xattr(ci, xattr);
368 kfree(name);
369 return 0;
370 }
362 } 371 }
363 372
364 if (!xattr) { 373 if (!xattr) {
@@ -862,6 +871,9 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
862 871
863 dout("setxattr value=%.*s\n", (int)size, value); 872 dout("setxattr value=%.*s\n", (int)size, value);
864 873
874 if (!value)
875 flags |= CEPH_XATTR_REMOVE;
876
865 /* do request */ 877 /* do request */
866 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR, 878 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR,
867 USE_AUTH_MDS); 879 USE_AUTH_MDS);
@@ -965,8 +977,8 @@ retry:
965 goto retry; 977 goto retry;
966 } 978 }
967 979
968 err = __set_xattr(ci, newname, name_len, newval, 980 err = __set_xattr(ci, newname, name_len, newval, val_len,
969 val_len, flags, 1, &xattr); 981 flags, value ? 1 : -1, &xattr);
970 982
971 if (!err) { 983 if (!err) {
972 dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); 984 dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);