Skip to content

Commit

Permalink
ceph: fix setting empty extended attribute
Browse files Browse the repository at this point in the history
make sure 'value' is not null. otherwise __ceph_setxattr will remove
the extended attribute.

Signed-off-by: Yan, Zheng <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
ukernel authored and idryomov committed Dec 17, 2014
1 parent 275dd19 commit 0aeff37
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/ceph/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
struct ceph_pagelist *pagelist = NULL;
int err;

if (value) {
if (size > 0) {
/* copy value into pagelist */
pagelist = kmalloc(sizeof(*pagelist), GFP_NOFS);
if (!pagelist)
Expand All @@ -864,7 +864,7 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
err = ceph_pagelist_append(pagelist, value, size);
if (err)
goto out;
} else {
} else if (!value) {
flags |= CEPH_XATTR_REMOVE;
}

Expand Down Expand Up @@ -1001,6 +1001,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
return generic_setxattr(dentry, name, value, size, flags);

if (size == 0)
value = ""; /* empty EA, do not remove */

return __ceph_setxattr(dentry, name, value, size, flags);
}

Expand Down

0 comments on commit 0aeff37

Please sign in to comment.