Project

General

Profile

Actions

Bug #46084

closed

client: supplying ceph_fsetxattr with no value unsets xattr

Added by John Mulligan almost 4 years ago. Updated almost 4 years ago.

Status:
Resolved
Priority:
Normal
Category:
Correctness/Safety
Target version:
% Done:

0%

Source:
Development
Tags:
Backport:
octopus,nautilus
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(FS):
Client, libcephfs
Labels (FS):
Pull request ID:
Crash signature (v1):
Crash signature (v2):

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.

[1] - https://github.com/ceph/go-ceph/issues/247


Related issues 2 (0 open2 closed)

Copied to CephFS - Backport #46409: nautilus: client: supplying ceph_fsetxattr with no value unsets xattrResolvedNathan CutlerActions
Copied to CephFS - Backport #46410: octopus: client: supplying ceph_fsetxattr with no value unsets xattrResolvedNathan CutlerActions
Actions

Also available in: Atom PDF