From: Venky Shankar Date: Wed, 10 Nov 2021 10:02:51 +0000 (-0500) Subject: mount: use mds_mode=prefer-crc with new-style mount syntax if possible X-Git-Tag: v17.1.0~339^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9663f8aaec97de928ac286cdaf35b7c5f7afb69a;p=ceph.git mount: use mds_mode=prefer-crc with new-style mount syntax if possible Signed-off-by: Venky Shankar --- diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 5c8985e48362..14b979e12b12 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -21,6 +21,8 @@ bool verboseflag = false; bool skip_mtab_flag = false; bool v2_addrs = false; bool no_fallback = false; +bool ms_mode_specified = false; +bool mon_addr_specified = false; static const char * const EMPTY_STRING = ""; /* TODO duplicates logic from kernel */ @@ -36,6 +38,8 @@ static const char * const EMPTY_STRING = ""; */ #define CEPH_V2_MOUNT_SUPPORT_PATH CEPH_SYS_FS_PARAM_PATH"/mount_syntax_v2" +#define CEPH_DEFAULT_V2_MS_MODE "prefer-crc" + #include "mtab.c" enum mount_dev_format { @@ -292,6 +296,13 @@ static int parse_new_dev(const char *dev_str, struct ceph_mount_info *cmi, return -ENOMEM; } + /* new-style dev - force using v2 addrs first */ + if (!ms_mode_specified && !mon_addr_specified) { + v2_addrs = true; + append_opt("ms_mode", CEPH_DEFAULT_V2_MS_MODE, cmi, + opt_pos); + } + cmi->format = MOUNT_DEV_FORMAT_NEW; return 0; } @@ -563,6 +574,7 @@ static int parse_options(const char *data, struct ceph_mount_info *cmi, /* Only legacy ms_mode needs v1 addrs */ v2_addrs = strcmp(value, "legacy"); skip = false; + ms_mode_specified = true; } else if (strcmp(data, "mon_addr") == 0) { /* monitor address to use for mounting */ if (!value || !*value) { @@ -572,6 +584,7 @@ static int parse_options(const char *data, struct ceph_mount_info *cmi, cmi->cmi_mons = strdup(value); if (!cmi->cmi_mons) return -ENOMEM; + mon_addr_specified = true; } else { /* unrecognized mount options, passing to kernel */ skip = false; @@ -789,14 +802,40 @@ static bool should_fallback() static int do_mount(const char *dev, const char *node, struct ceph_mount_info *cmi) { + int pos = 0; int retval= -EINVAL; bool fallback = true; + /* no v2 addresses available via config - try v1 addresses */ + if (!cmi->cmi_mons && + !ms_mode_specified && + !mon_addr_specified && + cmi->format == MOUNT_DEV_FORMAT_NEW) { + mount_ceph_debug("mount.ceph: switching to using v1 address\n"); + v2_addrs = false; + fetch_config_info(cmi); + remove_opt(cmi, "ms_mode", NULL); + } + + if (!cmi->cmi_mons) { + fprintf(stderr, "unable to determine mon addresses\n"); + return -EINVAL; + } + + pos = strlen(cmi->cmi_opts); + retval = finalize_src(cmi, &pos); + if (retval) { + fprintf(stderr, "failed to resolve source\n"); + return -EINVAL; + } + + retval = -1; if (cmi->format == MOUNT_DEV_FORMAT_NEW) { retval = mount_new_device_format(node, cmi); if (retval) fallback = (should_fallback() && retval == -EINVAL && cmi->cmi_fsid); } + /* pass-through or fallback to old-style mount device */ if (retval && fallback) retval = mount_old_device_format(node, cmi); @@ -885,22 +924,13 @@ int main(int argc, char *argv[]) goto out; } - /* We don't care if this errors out, since this is best-effort */ + /* + * We don't care if this errors out, since this is best-effort. + * note that this fetches v1 or v2 addr depending on @v2_addr + * flag. + */ fetch_config_info(&cmi); - if (!cmi.cmi_mons) { - fprintf(stderr, "unable to determine mon addresses\n"); - retval = EX_USAGE; - goto out; - } - - retval = finalize_src(&cmi, &opt_pos); - if (retval) { - fprintf(stderr, "failed to resolve source\n"); - retval = EX_USAGE; - goto out; - } - /* Ensure the ceph key_type is available */ modprobe();