cephfs: add a pointer in the docs for no-value issue

Add a section to the doc comment for SetXattr that notes the behavior
I observed while working on the tests: that passing an empty value
(or null on the C side) causes the xattr to be removed rather than
set with an "empty" value. This issue has been reported in the
ceph tracker (see link in comment).

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-06-18 15:39:54 -04:00 committed by John Mulligan
parent 5f41e2d8d2
commit 1bbd6edb4b
2 changed files with 15 additions and 7 deletions

View File

@ -34,6 +34,9 @@ const (
// SetXattr sets an extended attribute on the open file.
//
// NOTE: Attempting to set an xattr value with an empty value may cause
// the xattr to be unset. Please refer to https://tracker.ceph.com/issues/46084
//
// Implements:
// int ceph_fsetxattr(struct ceph_mount_info *cmount, int fd, const char *name,
// const void *value, size_t size, int flags);

View File

@ -24,10 +24,15 @@ var samples = []struct {
name: "user.x2kZeros",
value: make([]byte, 2048),
},
{
name: "user.xEmpty",
value: []byte(""),
},
// Ceph's behavior when an empty value is supplied may be considered
// to have a bug in some versions. Using an empty value may cause
// the xattr to be unset. Please refer to:
// https://tracker.ceph.com/issues/46084
// So we avoid testing for that case explicitly here.
//{
// name: "user.xEmpty",
// value: []byte(""),
//},
}
func TestGetSetXattr(t *testing.T) {
@ -42,7 +47,7 @@ func TestGetSetXattr(t *testing.T) {
assert.NoError(t, mount.Unlink(fname))
}()
for _, s := range samples[:3] {
for _, s := range samples {
t.Run("roundTrip-"+s.name, func(t *testing.T) {
err := f.SetXattr(s.name, s.value, XattrDefault)
assert.NoError(t, err)
@ -53,7 +58,7 @@ func TestGetSetXattr(t *testing.T) {
}
t.Run("missingXattrOnGet", func(t *testing.T) {
_, err := f.GetXattr(samples[3].name)
_, err := f.GetXattr("user.never-set")
assert.Error(t, err)
})
@ -100,7 +105,7 @@ func TestListXattr(t *testing.T) {
})
t.Run("listXattrs2", func(t *testing.T) {
for _, s := range samples[:3] {
for _, s := range samples {
err := f.SetXattr(s.name, s.value, XattrDefault)
assert.NoError(t, err)
}