From 5d2b8a45020aa50e0acebfa06ea810c5707d151f Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sat, 29 Mar 2025 21:57:51 +0530 Subject: [PATCH] mgr/vol: support clone operation on subvol v3 Signed-off-by: Rishabh Dave --- .../fs/operations/versions/subvolume_v3.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py index 4d4a8dea66c..eadd6c32ded 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py @@ -257,3 +257,28 @@ class SubvolumeV3(SubvolumeV2): MetadataManager.GLOBAL_META_KEY_STATE, SubvolumeStates.STATE_RETAINED.value) self.metadata_mgr.flush() + + # Following methods help clone operation - + + + def snapshot_data_path(self, snap_name): + snap_path = join(self.snapshot_path(snap_name), b'mnt') + + # v2 raises exception if the snapshot path do not exist so do the same + # to prevent any bugs due to difference in behaviour. + # + # not raising exception indeed leads to a bug: the volumes plugin fails + # when exception is not raised by this method when it is called by + # do_clone() method of async_cloner.py. this is made to happen by a + # test by deleting snapshot after running the snapshot clone command + # but before the clone operation actually begins. this is done by + # adding a delay using mgr/volumes/snapshot_clone_delay config option. + try: + self.fs.stat(snap_path) + except cephfs.Error as e: + if e.errno == errno.ENOENT: + raise VolumeException(-errno.ENOENT, + f'snapshot \'{snap_name}\' does not exist') + raise VolumeException(-e.args[0], e.args[1]) + + return snap_path -- 2.47.3