From: Venky Shankar Date: Thu, 20 May 2021 12:11:05 +0000 (-0400) Subject: mount: record cluster fsid when reading ceph config file X-Git-Tag: v17.1.0~339^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63ac4f9e48ea60e30f66c9e03e3ad20dc96983ce;p=ceph.git mount: record cluster fsid when reading ceph config file This will be required when switching to new mount device syntax when cluster fsid will be passed to kernel as mount option. Signed-off-by: Venky Shankar --- diff --git a/src/mount/conf.cc b/src/mount/conf.cc index 2eae2b04c16..df95912c1f3 100644 --- a/src/mount/conf.cc +++ b/src/mount/conf.cc @@ -46,6 +46,9 @@ extern "C" void mount_ceph_get_config_info(const char *config_file, conf.parse_env(cct->get_module_type()); // environment variables override conf.apply_changes(nullptr); + auto fsid = conf.get_val("fsid"); + fsid.print(cci->cci_fsid); + ceph::async::io_context_pool ioc(1); MonClient monc = MonClient(cct.get(), ioc); err = monc.build_initial_monmap(); diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 061d5107190..8672920bc74 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -133,7 +133,7 @@ static int fetch_config_info(struct ceph_mount_info *cmi) struct ceph_config_info *cci; /* Don't do anything if we already have requisite info */ - if (cmi->cmi_secret[0] && cmi->cmi_mons) + if (cmi->cmi_secret[0] && cmi->cmi_mons && cmi->cmi_fsid) return 0; cci = mmap((void *)0, sizeof(*cci), PROT_READ | PROT_WRITE, @@ -192,6 +192,11 @@ static int fetch_config_info(struct ceph_mount_info *cmi) if (len < MON_LIST_BUFSIZE) cmi->cmi_mons = strndup(cci->cci_mons, len + 1); } + if (!cmi->cmi_fsid) { + len = strnlen(cci->cci_fsid, CLUSTER_FSID_LEN); + if (len < CLUSTER_FSID_LEN) + cmi->cmi_fsid = strndup(cci->cci_fsid, len + 1); + } } out: munmap(cci, sizeof(*cci)); diff --git a/src/mount/mount.ceph.h b/src/mount/mount.ceph.h index 673175db5a8..9bd6bbfcc07 100644 --- a/src/mount/mount.ceph.h +++ b/src/mount/mount.ceph.h @@ -24,11 +24,14 @@ extern "C" { /* 2k should be enough for anyone? */ #define MON_LIST_BUFSIZE 2048 +#define CLUSTER_FSID_LEN 37 + void mount_ceph_debug(const char *fmt, ...); struct ceph_config_info { char cci_secret[SECRET_BUFSIZE]; // auth secret char cci_mons[MON_LIST_BUFSIZE]; // monitor addrs + char cci_fsid[CLUSTER_FSID_LEN]; // cluster fsid }; void mount_ceph_get_config_info(const char *config_file, const char *name,