Merge pull request #1216 from ceph/wip-null-xattr

mds: remove xattr when null value is given to setxattr()

Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2014-02-13 06:59:15 -08:00
commit 39e313fcfa
3 changed files with 11 additions and 5 deletions

View File

@ -7242,6 +7242,9 @@ int Client::_setxattr(Inode *in, const char *name, const void *value,
strncmp(name, "ceph.", 5))
return -EOPNOTSUPP;
if (!value)
flags |= CEPH_XATTR_REMOVE;
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_SETXATTR);
filepath path;
in->make_nosnap_relative_path(path);

View File

@ -354,8 +354,9 @@ extern const char *ceph_mds_op_name(int op);
/*
* Ceph setxattr request flags.
*/
#define CEPH_XATTR_CREATE 1
#define CEPH_XATTR_REPLACE 2
#define CEPH_XATTR_CREATE (1 << 0)
#define CEPH_XATTR_REPLACE (1 << 1)
#define CEPH_XATTR_REMOVE (1 << 31)
union ceph_mds_request_args {
struct {

View File

@ -3809,9 +3809,11 @@ void Server::handle_client_setxattr(MDRequest *mdr)
pi->ctime = ceph_clock_now(g_ceph_context);
pi->xattr_version++;
px->erase(name);
(*px)[name] = buffer::create(len);
if (len)
req->get_data().copy(0, len, (*px)[name].c_str());
if (!(flags & CEPH_XATTR_REMOVE)) {
(*px)[name] = buffer::create(len);
if (len)
req->get_data().copy(0, len, (*px)[name].c_str());
}
// log + wait
mdr->ls = mdlog->get_current_segment();