]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: enhancement for subvol creation and mounting
authorMilind Changire <mchangir@redhat.com>
Wed, 2 Aug 2023 05:48:45 +0000 (11:18 +0530)
committerMilind Changire <mchangir@redhat.com>
Wed, 2 Aug 2023 05:48:45 +0000 (11:18 +0530)
Fixes: https://tracker.ceph.com/issues/54317
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit bf83eaa4e75516a6937e4097b8708c48856a9473)

qa/tasks/ceph.py
qa/tasks/ceph_fuse.py
qa/tasks/cephadm.py
qa/tasks/cephfs/filesystem.py
qa/tasks/cephfs/fuse_mount.py
qa/tasks/cephfs/kernel_mount.py
qa/tasks/cephfs/mount.py

index c9d361969c88639bc1b6e6400c3b242abb75d118..836e6ec704a2cf0fbc2067a358e858161d8564e9 100644 (file)
@@ -445,6 +445,9 @@ def cephfs_setup(ctx, config):
             name = fs_config.pop('name')
             temp = deepcopy(cephfs_config)
             teuthology.deep_merge(temp, fs_config)
+            subvols = config.get('subvols', None)
+            if subvols:
+                teuthology.deep_merge(temp, {'subvols': subvols})
             fs = Filesystem(ctx, fs_config=temp, name=name, create=True)
             if set_allow_multifs:
                 fs.set_allow_multifs()
index 2712229f97231cf5ef469b2b2757a8758ad75ae6..b443516230c07744b197a5ee219ccd5eec60cf7c 100644 (file)
@@ -72,6 +72,20 @@ def task(ctx, config):
               mount_timeout: 120 # default is 30, give up if /sys/ is not populated
         - interactive:
 
+    Example that creates and mounts a subvol:
+
+        overrides:
+          ceph:
+            subvols:
+              create: 2
+              subvol_options: "--namespace-isolated --size 25000000000"
+          ceph-fuse:
+            client.0:
+              mount_subvol_num: 0
+          kclient:
+            client.1:
+              mount_subvol_num: 1
+
     :param ctx: Context
     :param config: Configuration
     """
index 07105c53d863f4847b7e49ed30ff8c4184b9b8d7..342c0d6416c6aa74f6cff9a291f036f95d1eb735 100644 (file)
@@ -818,7 +818,6 @@ def ceph_mdss(ctx, config):
 
     yield
 
-
 @contextlib.contextmanager
 def ceph_monitoring(daemon_type, ctx, config):
     """
index d2b5885fa147b9d4f848165bc741b3a6d851f062..b2f762d39c1806315f91116f4b7f8e5fe8ff89fc 100644 (file)
@@ -751,6 +751,7 @@ class Filesystem(MDSCluster):
                 raise
 
         if self.fs_config is not None:
+            log.debug(f"fs_config: {self.fs_config}")
             max_mds = self.fs_config.get('max_mds', 1)
             if max_mds > 1:
                 self.set_max_mds(max_mds)
@@ -763,6 +764,34 @@ class Filesystem(MDSCluster):
             if session_timeout != 60:
                 self.set_session_timeout(session_timeout)
 
+            if self.fs_config.get('subvols', None) is not None:
+                log.debug(f"Creating {self.fs_config.get('subvols')} subvols "
+                          f"for filesystem '{self.name}'")
+                if not hasattr(self._ctx, "created_subvols"):
+                    self._ctx.created_subvols = dict()
+
+                subvols = self.fs_config.get('subvols')
+                assert(isinstance(subvols, dict))
+                assert(isinstance(subvols['create'], int))
+                assert(subvols['create'] > 0)
+
+                for sv in range(0, subvols['create']):
+                    sv_name = f'sv_{sv}'
+                    self.mon_manager.raw_cluster_cmd(
+                        'fs', 'subvolume', 'create', self.name, sv_name,
+                        self.fs_config.get('subvol_options', ''))
+
+                    if self.name not in self._ctx.created_subvols:
+                        self._ctx.created_subvols[self.name] = []
+
+                    subvol_path = self.mon_manager.raw_cluster_cmd(
+                        'fs', 'subvolume', 'getpath', self.name, sv_name)
+                    subvol_path = subvol_path.strip()
+                    self._ctx.created_subvols[self.name].append(subvol_path)
+            else:
+                log.debug(f"Not Creating any subvols for filesystem '{self.name}'")
+
+
         self.getinfo(refresh = True)
 
         # wait pgs to be clean
index 3bd759da82e5fce976be5f1a461549afaed1ad20..982a5553496f7cfaaf28f42c466a2472133016bd 100644 (file)
@@ -85,6 +85,7 @@ class FuseMount(CephFSMount):
             fuse_cmd += ['--id', self.client_id]
         if self.client_keyring_path and self.client_id is not None:
             fuse_cmd += ['-k', self.client_keyring_path]
+        self.validate_subvol_options()
         if self.cephfs_mntpt is not None:
             fuse_cmd += ["--client_mountpoint=" + self.cephfs_mntpt]
         if self.cephfs_name is not None:
index 21be0c28710ab866a2edce1ad86b23374b54e893..37c0f62109883ba3c226147bc81f6e9af1884464 100644 (file)
@@ -42,6 +42,8 @@ class KernelMount(CephFSMount):
 
         if not self.cephfs_mntpt:
             self.cephfs_mntpt = '/'
+        if not self.cephfs_name:
+            self.cephfs_name = 'cephfs'
 
         stderr = StringIO()
         try:
index 9e733512418742c90bd98af2974ed2ce5c208b0e..eb9fdfd2ec173f66f75d054bc32c7016c6f21aaf 100644 (file)
@@ -1387,3 +1387,22 @@ class CephFSMount(object):
         checksum_text = self.run_shell(cmd).stdout.getvalue().strip()
         checksum_sorted = sorted(checksum_text.split('\n'), key=lambda v: v.split()[1])
         return hashlib.md5(('\n'.join(checksum_sorted)).encode('utf-8')).hexdigest()
+
+    def validate_subvol_options(self):
+        mount_subvol_num = self.client_config.get('mount_subvol_num', None)
+        if self.cephfs_mntpt and mount_subvol_num is not None:
+            log.warning("You cannot specify both: cephfs_mntpt and mount_subvol_num")
+            log.info(f"Mounting subvol {mount_subvol_num} for now")
+
+        if mount_subvol_num is not None:
+            # mount_subvol must be an index into the subvol path array for the fs
+            if not self.cephfs_name:
+                self.cephfs_name = 'cephfs'
+            assert(hasattr(self.ctx, "created_subvols"))
+            # mount_subvol must be specified under client.[0-9] yaml section
+            subvol_paths = self.ctx.created_subvols[self.cephfs_name]
+            path_to_mount = subvol_paths[mount_subvol_num]
+            self.cephfs_mntpt = path_to_mount
+        elif not self.cephfs_mntpt:
+            # default to the "/" path
+            self.cephfs_mntpt = "/"