Skip to content

Commit fa93d68

Browse files
Merge pull request ceph#65104 from edwinzrodriguez/ceph-wip-72556
mds: Return ceph.dir.subvolume vxattr Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-ny: Christopher Hoffman <[email protected]> Reviewed-by: Rishabh Dave <[email protected]>
2 parents afdcc22 + 51fb4b6 commit fa93d68

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

qa/tasks/cephfs/test_subvolume.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,28 @@ def test_subvolume_vxattr_removal_without_setting(self):
213213
# cleanup
214214
self.mount_a.run_shell(['rm', '-rf', 'group/subvol3'])
215215

216+
217+
def test_subvolume_vxattr_retrieval(self):
218+
"""
219+
To verify that the ceph.dir.subvolume vxattr can be acquired using getfattr
220+
"""
221+
# create subvolume dir
222+
subvol_dir:str = 'group/subvol5'
223+
self.mount_a.run_shell(['mkdir', subvol_dir])
224+
mkdir_fattr = self.mount_a.getfattr(subvol_dir, 'ceph.dir.subvolume')
225+
self.assertEqual('0', mkdir_fattr)
226+
227+
self.mount_a.setfattr(subvol_dir, 'ceph.dir.subvolume', '1')
228+
new_fattr:str = self.mount_a.getfattr(subvol_dir, 'ceph.dir.subvolume')
229+
self.assertEqual('1', new_fattr)
230+
231+
# clear subvolume flag
232+
self.mount_a.removexattr(subvol_dir, 'ceph.dir.subvolume')
233+
234+
# cleanup
235+
self.mount_a.run_shell(['rm', '-rf', subvol_dir])
236+
237+
216238
class TestSubvolumeReplicated(CephFSTestCase):
217239
CLIENTS_REQUIRED = 1
218240
MDSS_REQUIRED = 2

src/mds/Server.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7284,6 +7284,9 @@ void Server::handle_client_getvxattr(const MDRequestRef& mdr)
72847284
// since we only handle ceph vxattrs here
72857285
r = -ENODATA; // no such attribute
72867286
}
7287+
} else if (xattr_name == "ceph.dir.subvolume"sv) {
7288+
const auto* srnode = cur->get_projected_srnode();
7289+
*css << (srnode && srnode->is_subvolume() ? "1"sv : "0"sv);
72877290
} else {
72887291
// otherwise respond as invalid request
72897292
// since we only handle ceph vxattrs here

src/mds/Server.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -505,21 +505,22 @@ class Server {
505505

506506
static bool is_ceph_dir_vxattr(std::string_view xattr_name) {
507507
return xattr_name == "ceph.dir.layout" ||
508-
xattr_name == "ceph.dir.layout.json" ||
509-
xattr_name == "ceph.dir.layout.object_size" ||
510-
xattr_name == "ceph.dir.layout.stripe_unit" ||
511-
xattr_name == "ceph.dir.layout.stripe_count" ||
512-
xattr_name == "ceph.dir.layout.pool" ||
513-
xattr_name == "ceph.dir.layout.pool_name" ||
514-
xattr_name == "ceph.dir.layout.pool_id" ||
515-
xattr_name == "ceph.dir.layout.pool_namespace" ||
516-
xattr_name == "ceph.dir.pin" ||
517-
xattr_name == "ceph.dir.pin.random" ||
518-
xattr_name == "ceph.dir.pin.distributed" ||
519-
xattr_name == "ceph.dir.charmap"sv ||
520-
xattr_name == "ceph.dir.normalization"sv ||
521-
xattr_name == "ceph.dir.encoding"sv ||
522-
xattr_name == "ceph.dir.casesensitive"sv;
508+
xattr_name == "ceph.dir.layout.json" ||
509+
xattr_name == "ceph.dir.layout.object_size" ||
510+
xattr_name == "ceph.dir.layout.stripe_unit" ||
511+
xattr_name == "ceph.dir.layout.stripe_count" ||
512+
xattr_name == "ceph.dir.layout.pool" ||
513+
xattr_name == "ceph.dir.layout.pool_name" ||
514+
xattr_name == "ceph.dir.layout.pool_id" ||
515+
xattr_name == "ceph.dir.layout.pool_namespace" ||
516+
xattr_name == "ceph.dir.pin" ||
517+
xattr_name == "ceph.dir.pin.random" ||
518+
xattr_name == "ceph.dir.pin.distributed" ||
519+
xattr_name == "ceph.dir.charmap"sv ||
520+
xattr_name == "ceph.dir.normalization"sv ||
521+
xattr_name == "ceph.dir.encoding"sv ||
522+
xattr_name == "ceph.dir.casesensitive"sv ||
523+
xattr_name == "ceph.dir.subvolume"sv;
523524
}
524525

525526
static bool is_ceph_file_vxattr(std::string_view xattr_name) {

0 commit comments

Comments
 (0)