Skip to content

Commit 51fb4b6

Browse files
mds: add ceph.dir.subvolume get vxattr
This introduces handling for the "ceph.dir.subvolume" virtual xattr on directories. - Returns ASCII "1" when the directory is a subvolume root, "0" otherwise. QA: - Extend CephFS subvolume tests to validate vxattr retrieval and behavior around setting/removal. Fixes: https://tracker.ceph.com/issues/72556 Signed-off-by: Edwin Rodriguez <[email protected]>
1 parent bafdbd6 commit 51fb4b6

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)