]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: conditionalize subvolume upgrade
authorMilind Changire <mchangir@redhat.com>
Thu, 7 Dec 2023 08:31:42 +0000 (14:01 +0530)
committerMilind Changire <mchangir@redhat.com>
Thu, 14 Mar 2024 06:20:03 +0000 (11:50 +0530)
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit 0c5804ab4e5eb284d127044c5e51fbc870f5727a)

src/pybind/mgr/volumes/fs/operations/versions/__init__.py
src/pybind/mgr/volumes/fs/operations/versions/metadata_manager.py

index 544afa165f975c6d77d6c7d524986d7ebc6b2227..2b419e196a54f9b0c7fe2d56254bc0cd8b3ff834 100644 (file)
@@ -49,6 +49,18 @@ class SubvolumeLoader(object):
     def get_subvolume_object_max(self, mgr, fs, vol_spec, group, subvolname):
         return self._get_subvolume_version(self.max_version)(mgr, fs, vol_spec, group, subvolname)
 
+    def allow_subvolume_upgrade(self, subvolume):
+        asu = True
+        try:
+            opt = subvolume.metadata_mgr.get_global_option(MetadataManager.GLOBAL_META_KEY_ALLOW_SUBVOLUME_UPGRADE)
+            asu = False if opt == "0" else True
+        except MetadataMgrException:
+            # this key is injected for QA testing and will not be available in
+            # production
+            pass
+
+        return asu
+
     def upgrade_to_v2_subvolume(self, subvolume):
         # legacy mode subvolumes cannot be upgraded to v2
         if subvolume.legacy_mode:
@@ -58,6 +70,9 @@ class SubvolumeLoader(object):
         if version >= SubvolumeV2.version():
             return
 
+        if not self.allow_subvolume_upgrade(subvolume):
+            return
+
         v1_subvolume = self._get_subvolume_version(version)(subvolume.mgr, subvolume.fs, subvolume.vol_spec, subvolume.group, subvolume.subvolname)
         try:
             v1_subvolume.open(SubvolumeOpType.SNAP_LIST)
index 718735d91b131a323a40e0382da4396b543c52c0..d2e1c54f11086954729e1ead8c15481e85c833f3 100644 (file)
@@ -59,6 +59,7 @@ class MetadataManager(object):
     GLOBAL_META_KEY_TYPE    = "type"
     GLOBAL_META_KEY_PATH    = "path"
     GLOBAL_META_KEY_STATE   = "state"
+    GLOBAL_META_KEY_ALLOW_SUBVOLUME_UPGRADE   = "allow_subvolume_upgrade"
 
     CLONE_FAILURE_SECTION = "CLONE_FAILURE"
     CLONE_FAILURE_META_KEY_ERRNO = "errno"