Merge PR #40158 into master

* refs/pull/40158/head:
	test: add test for removing non-existent xattr
	mds: fix removexattr logic when there aren't any

Reviewed-by: Sidharth Anupkrishnan <sanupkri@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
This commit is contained in:
Patrick Donnelly 2021-03-22 20:04:35 -07:00
commit 222ce06bfa
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
2 changed files with 4 additions and 1 deletions

View File

@ -5903,7 +5903,7 @@ int Server::xattr_validate(CInode *cur, const InodeStoreBase::xattr_map_const_pt
}
if (op == CEPH_MDS_OP_RMXATTR) {
if (xattrs && xattrs->count(mempool::mds_co::string(xattr_name)) == 0) {
if (!xattrs || xattrs->count(mempool::mds_co::string(xattr_name)) == 0) {
dout(10) << "removexattr '" << xattr_name << "' and CEPHFS_ENODATA on " << *cur << dendl;
return -CEPHFS_ENODATA;
}

View File

@ -540,6 +540,9 @@ TEST(LibCephFS, Xattrs) {
int fd = ceph_open(cmount, test_xattr_file, O_CREAT, 0666);
ASSERT_GT(fd, 0);
// test removing non-existent xattr
ASSERT_EQ(-ENODATA, ceph_removexattr(cmount, test_xattr_file, "user.nosuchxattr"));
char i = 'a';
char xattrk[128];
char xattrv[128];