ceph: return -ENODATA when xattr doesn't exist for removexattr
Subsystems (2)
PATCH 1/1 ceph: return -ENODATA when xattr doesn't exist for removexattr
From: Xiubo Li <[email protected]>
The POSIX says we should return -ENODATA when the corresponding attribute doesn't exist when removing it. While there is one exception for the acl ones in the local filesystems, for exmaple for xfs, which will treat it as success.
While in the MDS side there have two ways to remove the xattr:
sending a CEPH_MDS_OP_SETXATTR request by setting the 'flags' with CEPH_XATTR_REMOVE and just issued a CEPH_MDS_OP_RMXATTR request directly.
For the first one it will always return 0 when the corresponding xattr doesn't exist, while for the later one it will return -ENODATA instead, this should be fixed in MDS to make them to be consistent.
URL: https://tracker.ceph.com/issues/64679
--- fs/ceph/acl.c | 9 ++++++++- fs/ceph/xattr.c | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-)
fs/ceph/acl.c +8 -1
@@ -158,7 +158,14 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, goto out_free; } -ceph_set_cached_acl (inode, type, acl); +/* +* If the attribute didn't exist to start with that's fine. +*/ +if (!acl && ret == -ENODATA ) + ret =0 ; + +if (!ret) +ceph_set_cached_acl (inode, type, acl); out_free:kfree (value);
fs/ceph/xattr.c +2 -3
@@ -613,11 +613,10 @@ static int __set_xattr(struct ceph_inode_info *ci,return err; }if (update_xattr <0 ) { -if (xattr) -__remove_xattr (ci, xattr); + err =__remove_xattr (ci, xattr);kfree (name);kfree (*newxattr); -return 0 ; +return err; } }
Signature · 1 line
2.43.0