Skip to content

Commit

Permalink
Merge PR ceph#29339 into master
Browse files Browse the repository at this point in the history
* refs/pull/29339/head:
	client: don't report any vxattrs to listxattr

Reviewed-by: Patrick Donnelly <[email protected]>
Reviewed-by: David Disseldorp <[email protected]>
  • Loading branch information
batrick committed Jul 29, 2019
2 parents 7cec285 + bc0f7e1 commit ecf49c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 57 deletions.
1 change: 1 addition & 0 deletions .githubmap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cbodley Casey Bodley <[email protected]>
chardan Jesse Williamson <[email protected]>
chhabaramesh Ramesh Chander <[email protected]>
Devp00l Stephan Müller <[email protected]>
ddiss David Disseldorp <[email protected]>
dmick Dan Mick <[email protected]>
dragonylffly Li Wang <[email protected]>
dvanders Dan van der Ster <[email protected]>
Expand Down
33 changes: 0 additions & 33 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11357,29 +11357,6 @@ int Client::_listxattr(Inode *in, char *name, size_t size,
name += this_len;
size -= this_len;
}

const VXattr *vxattr;
for (vxattr = _get_vxattrs(in); vxattr && !vxattr->name.empty(); vxattr++) {
if (vxattr->hidden)
continue;
// call pointer-to-member function
if (vxattr->exists_cb && !(this->*(vxattr->exists_cb))(in))
continue;

size_t this_len = vxattr->name.length() + 1;
r += this_len;
if (len_only)
continue;

if (this_len > size) {
r = -ERANGE;
goto out;
}

memcpy(name, vxattr->name.c_str(), this_len);
name += this_len;
size -= this_len;
}
out:
ldout(cct, 8) << __func__ << "(" << in->ino << ", " << size << ") = " << r << dendl;
return r;
Expand Down Expand Up @@ -11812,7 +11789,6 @@ size_t Client::_vxattrcb_snap_btime(Inode *in, char *val, size_t size)
name: CEPH_XATTR_NAME(_type, _name), \
getxattr_cb: &Client::_vxattrcb_ ## _type ## _ ## _name, \
readonly: true, \
hidden: false, \
exists_cb: NULL, \
flags: 0, \
}
Expand All @@ -11821,7 +11797,6 @@ size_t Client::_vxattrcb_snap_btime(Inode *in, char *val, size_t size)
name: CEPH_XATTR_NAME(_type, _name), \
getxattr_cb: &Client::_vxattrcb_ ## _type ## _ ## _name, \
readonly: true, \
hidden: false, \
exists_cb: NULL, \
flags: _flags, \
}
Expand All @@ -11830,7 +11805,6 @@ size_t Client::_vxattrcb_snap_btime(Inode *in, char *val, size_t size)
name: CEPH_XATTR_NAME2(_type, _name, _field), \
getxattr_cb: &Client::_vxattrcb_ ## _name ## _ ## _field, \
readonly: false, \
hidden: true, \
exists_cb: &Client::_vxattrcb_layout_exists, \
flags: 0, \
}
Expand All @@ -11839,7 +11813,6 @@ size_t Client::_vxattrcb_snap_btime(Inode *in, char *val, size_t size)
name: CEPH_XATTR_NAME(_type, _name), \
getxattr_cb: &Client::_vxattrcb_ ## _type ## _ ## _name, \
readonly: false, \
hidden: true, \
exists_cb: &Client::_vxattrcb_quota_exists, \
flags: 0, \
}
Expand All @@ -11849,7 +11822,6 @@ const Client::VXattr Client::_dir_vxattrs[] = {
name: "ceph.dir.layout",
getxattr_cb: &Client::_vxattrcb_layout,
readonly: false,
hidden: true,
exists_cb: &Client::_vxattrcb_layout_exists,
flags: 0,
},
Expand All @@ -11870,7 +11842,6 @@ const Client::VXattr Client::_dir_vxattrs[] = {
name: "ceph.quota",
getxattr_cb: &Client::_vxattrcb_quota,
readonly: false,
hidden: true,
exists_cb: &Client::_vxattrcb_quota_exists,
flags: 0,
},
Expand All @@ -11880,15 +11851,13 @@ const Client::VXattr Client::_dir_vxattrs[] = {
name: "ceph.dir.pin",
getxattr_cb: &Client::_vxattrcb_dir_pin,
readonly: false,
hidden: true,
exists_cb: &Client::_vxattrcb_dir_pin_exists,
flags: 0,
},
{
name: "ceph.snap.btime",
getxattr_cb: &Client::_vxattrcb_snap_btime,
readonly: true,
hidden: false,
exists_cb: &Client::_vxattrcb_snap_btime_exists,
flags: 0,
},
Expand All @@ -11900,7 +11869,6 @@ const Client::VXattr Client::_file_vxattrs[] = {
name: "ceph.file.layout",
getxattr_cb: &Client::_vxattrcb_layout,
readonly: false,
hidden: true,
exists_cb: &Client::_vxattrcb_layout_exists,
flags: 0,
},
Expand All @@ -11913,7 +11881,6 @@ const Client::VXattr Client::_file_vxattrs[] = {
name: "ceph.snap.btime",
getxattr_cb: &Client::_vxattrcb_snap_btime,
readonly: true,
hidden: false,
exists_cb: &Client::_vxattrcb_snap_btime_exists,
flags: 0,
},
Expand Down
2 changes: 1 addition & 1 deletion src/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ class Client : public Dispatcher, public md_config_obs_t {
struct VXattr {
const string name;
size_t (Client::*getxattr_cb)(Inode *in, char *val, size_t size);
bool readonly, hidden;
bool readonly;
bool (Client::*exists_cb)(Inode *in);
unsigned int flags;
};
Expand Down
27 changes: 4 additions & 23 deletions src/test/libcephfs/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,8 @@ TEST(LibCephFS, Xattrs) {
char *n;
i = 'a';
while (len > 0) {
// skip/ignore the dir layout
if (strcmp(p, "ceph.dir.layout") == 0 ||
strcmp(p, "ceph.file.layout") == 0) {
len -= strlen(p) + 1;
p += strlen(p) + 1;
continue;
}
// ceph.* xattrs should not be listed
ASSERT_NE(strncmp(p, "ceph.", 5), 0);

sprintf(xattrk, "user.test_xattr_%c", i);
ASSERT_STREQ(p, xattrk);
Expand Down Expand Up @@ -2257,10 +2252,9 @@ TEST(LibCephFS, SnapXattrs) {
utime_t new_btime = utime_t(strtoull(gxattrv2, NULL, 10), strtoull(s + 1, NULL, 10));
ASSERT_LT(btime, new_btime);

// check that the snap.btime vxattr appears in listxattr()
// listxattr() shouldn't return snap.btime vxattr
char xattrlist[512];
int len = ceph_listxattr(cmount, c_temp, xattrlist, sizeof(xattrlist));
ASSERT_GT(len, 0);
int len = ceph_listxattr(cmount, test_snap_xattr_file, xattrlist, sizeof(xattrlist));
ASSERT_GE(sizeof(xattrlist), (size_t)len);
char *p = xattrlist;
int found = 0;
Expand All @@ -2270,19 +2264,6 @@ TEST(LibCephFS, SnapXattrs) {
len -= strlen(p) + 1;
p += strlen(p) + 1;
}
ASSERT_EQ(found, 1);

// listxattr() shouldn't return snap.btime vxattr for non-snaps
len = ceph_listxattr(cmount, test_snap_xattr_file, xattrlist, sizeof(xattrlist));
ASSERT_GE(sizeof(xattrlist), (size_t)len);
p = xattrlist;
found = 0;
while (len > 0) {
if (strcmp(p, "ceph.snap.btime") == 0)
found++;
len -= strlen(p) + 1;
p += strlen(p) + 1;
}
ASSERT_EQ(found, 0);

ceph_shutdown(cmount);
Expand Down

0 comments on commit ecf49c0

Please sign in to comment.