mirror of
https://github.com/ceph/ceph
synced 2025-01-30 23:13:44 +00:00
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:
commit
39e313fcfa
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user