Bug #46084
closedclient: supplying ceph_fsetxattr with no value unsets xattr
0%
Description
While working on [1] I noticed an unexpected behavior when trying to use ceph_fsetxattr with an empty (null) value. I expected it to set an xattr with a name only. However, the call appears to remove the xattr entirely rather than clearing the value.
I tested this with `setfattr -n user.foo <file>` on the same fs mounted via fuse and it behaves as expected.
I saw the following line in the source that looked suspicious:
int Client::_do_setxattr(Inode *in, const char *name, const void *value,
size_t size, int flags, const UserPerm& perms)
{
int xattr_flags = 0;
if (!value)
xattr_flags |= CEPH_XATTR_REMOVE; // <------
Of course, I'm no expert on the ceph internals.
While the use case for a value-less xattr isn't great, I could argue that having just the name can be used a boolean for some cases. Plus, it seems inconsistent with the way VFS xattr support works. Since removexattr appears to have it's own code path it seems a bit odd to me that there's a need to unset the xattr via a ceph_*setxattr path.