From bc680e7a1e07b0e33f04bc2020467e02c36b5b1a Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 6 Nov 2016 22:01:00 +0000 Subject: [PATCH] tasks/cephfs: support multi-fs in kernel client Change the Mount interface to take it as an argument to mount() instead of setting it out of band in a config file as we used to for the fuse client. Signed-off-by: John Spray --- tasks/cephfs/fuse_mount.py | 5 ++++- tasks/cephfs/kernel_mount.py | 11 ++++++++--- tasks/cephfs/mount.py | 2 +- tasks/cephfs/test_failover.py | 12 ++---------- tasks/vstart_runner.py | 5 ++++- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tasks/cephfs/fuse_mount.py b/tasks/cephfs/fuse_mount.py index df2b820852287..896ca5c67fd55 100644 --- a/tasks/cephfs/fuse_mount.py +++ b/tasks/cephfs/fuse_mount.py @@ -22,7 +22,7 @@ class FuseMount(CephFSMount): self.fuse_daemon = None self._fuse_conn = None - def mount(self, mount_path=None): + def mount(self, mount_path=None, mount_fs_name=None): log.info("Client client.%s config is %s" % (self.client_id, self.client_config)) daemon_signal = 'kill' @@ -54,6 +54,9 @@ class FuseMount(CephFSMount): if mount_path is not None: fuse_cmd += ["--client_mountpoint={0}".format(mount_path)] + if mount_fs_name is not None: + fuse_cmd += ["--client_mds_namespace={0}".format(mount_fs_name)] + fuse_cmd += [ '--name', 'client.{id}'.format(id=self.client_id), # TODO ceph-fuse doesn't understand dash dash '--', diff --git a/tasks/cephfs/kernel_mount.py b/tasks/cephfs/kernel_mount.py index 41091ef1da2cf..9ea3edecdd8d8 100644 --- a/tasks/cephfs/kernel_mount.py +++ b/tasks/cephfs/kernel_mount.py @@ -41,7 +41,7 @@ class KernelMount(CephFSMount): ], ) - def mount(self, mount_path=None): + def mount(self, mount_path=None, mount_fs_name=None): log.info('Mounting kclient client.{id} at {remote} {mnt}...'.format( id=self.client_id, remote=self.client_remote, mnt=self.mountpoint)) @@ -61,6 +61,12 @@ class KernelMount(CephFSMount): if mount_path is None: mount_path = "/" + opts = 'name={id},secretfile={secret}'.format(id=self.client_id, + secret=secret) + + if mount_fs_name is not None: + opts += ",mds_namespace={0}".format(mount_fs_name) + self.client_remote.run( args=[ 'sudo', @@ -72,8 +78,7 @@ class KernelMount(CephFSMount): self.mountpoint, '-v', '-o', - 'name={id},secretfile={secret}'.format(id=self.client_id, - secret=secret), + opts ], ) diff --git a/tasks/cephfs/mount.py b/tasks/cephfs/mount.py index 7b9c22342b994..dc76ad500b958 100644 --- a/tasks/cephfs/mount.py +++ b/tasks/cephfs/mount.py @@ -37,7 +37,7 @@ class CephFSMount(object): def is_mounted(self): raise NotImplementedError() - def mount(self, mount_path=None): + def mount(self, mount_path=None, mount_fs_name=None): raise NotImplementedError() def umount(self): diff --git a/tasks/cephfs/test_failover.py b/tasks/cephfs/test_failover.py index f91822eb7ffa1..b9dd582f261f2 100644 --- a/tasks/cephfs/test_failover.py +++ b/tasks/cephfs/test_failover.py @@ -286,22 +286,14 @@ class TestMultiFilesystems(CephFSTestCase): fs_a, fs_b = self._setup_two() # Mount a client on fs_a - fs_a.set_ceph_conf( - "client.{0}".format(self.mount_a.client_id), - "client_mds_namespace", fs_a.name - ) - self.mount_a.mount() + self.mount_a.mount(mount_fs_name=fs_a.name) self.mount_a.write_n_mb("pad.bin", 1) self.mount_a.write_n_mb("test.bin", 2) a_created_ino = self.mount_a.path_to_ino("test.bin") self.mount_a.create_files() # Mount a client on fs_b - fs_b.set_ceph_conf( - "client.{0}".format(self.mount_b.client_id), - "client_mds_namespace", fs_b.name - ) - self.mount_b.mount() + self.mount_b.mount(mount_fs_name=fs_b.name) self.mount_b.write_n_mb("test.bin", 1) b_created_ino = self.mount_b.path_to_ino("test.bin") self.mount_b.create_files() diff --git a/tasks/vstart_runner.py b/tasks/vstart_runner.py index c17dc14a91eb5..67da66a62d8a5 100644 --- a/tasks/vstart_runner.py +++ b/tasks/vstart_runner.py @@ -400,7 +400,7 @@ class LocalFuseMount(FuseMount): if self.is_mounted(): super(LocalFuseMount, self).umount() - def mount(self, mount_path=None): + def mount(self, mount_path=None, mount_fs_name=None): self.client_remote.run( args=[ 'mkdir', @@ -440,6 +440,9 @@ class LocalFuseMount(FuseMount): if mount_path is not None: prefix += ["--client_mountpoint={0}".format(mount_path)] + if mount_fs_name is not None: + prefix += ["--client_mds_namespace={0}".format(mount_fs_name)] + self.fuse_daemon = self.client_remote.run(args= prefix + [ "-f", -- 2.39.5