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 */
*/
#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 {
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;
}
/* 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) {
cmi->cmi_mons = strdup(value);
if (!cmi->cmi_mons)
return -ENOMEM;
+ mon_addr_specified = true;
} else {
/* unrecognized mount options, passing to kernel */
skip = false;
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);
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();