bool verboseflag = false;
bool skip_mtab_flag = false;
bool v2_addrs = false;
+bool no_fallback = false;
static const char * const EMPTY_STRING = "";
/* TODO duplicates logic from kernel */
#define CEPH_AUTH_NAME_DEFAULT "guest"
+/* path to sysfs for ceph */
+#define CEPH_SYS_FS_PATH "/sys/module/ceph/"
+#define CEPH_SYS_FS_PARAM_PATH CEPH_SYS_FS_PATH"/parameters"
+
+/*
+ * mount support hint from kernel -- we only need to check
+ * v2 support for catching bugs.
+ */
+#define CEPH_V2_MOUNT_SUPPORT_PATH CEPH_SYS_FS_PARAM_PATH"/mount_syntax_v2"
+
#include "mtab.c"
enum mount_dev_format {
}
data = "mds_namespace";
skip = false;
+ } else if (strcmp(data, "nofallback") == 0) {
+ no_fallback = true;
} else if (strcmp(data, "secretfile") == 0) {
int ret;
return -EINVAL;
}
*opts = argv[i];
- }
- else {
+ } else {
fprintf(stderr, "Can't understand option: '%s'\n\n", argv[i]);
return -EINVAL;
}
return r;
}
+/*
+ * check whether to fall-back to using old-style mount syntax (called
+ * when new-style mount syntax fails). this is mostly to catch any
+ * new-style (v2) implementation bugs in the kernel and is primarly
+ * used in teuthology tests.
+ */
+static bool should_fallback()
+{
+ int ret;
+ struct stat stbuf;
+
+ if (!no_fallback)
+ return true;
+
+ ret = stat(CEPH_V2_MOUNT_SUPPORT_PATH, &stbuf);
+ if (ret) {
+ mount_ceph_debug("mount.ceph: v2 mount support check returned %d\n",
+ errno);
+ if (errno == ENOENT)
+ mount_ceph_debug("mount.ceph: kernel does not support v2"
+ " syntax\n");
+ /* fallback on *all* errors */
+ return true;
+ }
+
+ fprintf(stderr, "mount.ceph: kernel BUG!\n");
+ return false;
+}
+
static int do_mount(const char *dev, const char *node,
struct ceph_mount_info *cmi) {
int retval= -EINVAL;
if (cmi->format == MOUNT_DEV_FORMAT_NEW) {
retval = mount_new_device_format(node, cmi);
if (retval)
- fallback = (retval == -EINVAL && cmi->cmi_fsid);
+ fallback = (should_fallback() && retval == -EINVAL && cmi->cmi_fsid);
}
/* pass-through or fallback to old-style mount device */
if (retval && fallback)