ceph: use CEPH_MDS_OP_RMXATTR request to remove xattr
Setxattr with NULL value and XATTR_REPLACE flag should be equivalent to removexattr. But current MDS does not support deleting vxattrs through MDS_OP_SETXATTR request. The workaround is sending MDS_OP_RMXATTR request if setxattr actually removs xattr. Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
Родитель
3f38495409
Коммит
04303d8ad0
|
@ -886,6 +886,7 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
|
||||||
struct ceph_mds_request *req;
|
struct ceph_mds_request *req;
|
||||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
||||||
struct ceph_pagelist *pagelist = NULL;
|
struct ceph_pagelist *pagelist = NULL;
|
||||||
|
int op = CEPH_MDS_OP_SETXATTR;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
|
@ -899,20 +900,21 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
} else if (!value) {
|
} else if (!value) {
|
||||||
flags |= CEPH_XATTR_REMOVE;
|
if (flags & CEPH_XATTR_REPLACE)
|
||||||
|
op = CEPH_MDS_OP_RMXATTR;
|
||||||
|
else
|
||||||
|
flags |= CEPH_XATTR_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dout("setxattr value=%.*s\n", (int)size, value);
|
dout("setxattr value=%.*s\n", (int)size, value);
|
||||||
|
|
||||||
/* do request */
|
/* do request */
|
||||||
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR,
|
req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
|
||||||
USE_AUTH_MDS);
|
|
||||||
if (IS_ERR(req)) {
|
if (IS_ERR(req)) {
|
||||||
err = PTR_ERR(req);
|
err = PTR_ERR(req);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->r_args.setxattr.flags = cpu_to_le32(flags);
|
|
||||||
req->r_path2 = kstrdup(name, GFP_NOFS);
|
req->r_path2 = kstrdup(name, GFP_NOFS);
|
||||||
if (!req->r_path2) {
|
if (!req->r_path2) {
|
||||||
ceph_mdsc_put_request(req);
|
ceph_mdsc_put_request(req);
|
||||||
|
@ -920,8 +922,11 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->r_pagelist = pagelist;
|
if (op == CEPH_MDS_OP_SETXATTR) {
|
||||||
pagelist = NULL;
|
req->r_args.setxattr.flags = cpu_to_le32(flags);
|
||||||
|
req->r_pagelist = pagelist;
|
||||||
|
pagelist = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
req->r_inode = inode;
|
req->r_inode = inode;
|
||||||
ihold(inode);
|
ihold(inode);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче