The new device syntax requires the cluster FSID as part of the device string. Use this FSID to verify if it matches the cluster FSID we get back from the monitor, failing the mount on mismatch. Also, rename parse_fsid() to ceph_parse_fsid() as it is too generic. Signed-off-by: Venky Shankar <vshankar@xxxxxxxxxx> --- fs/ceph/super.c | 9 +++++++++ fs/ceph/super.h | 1 + include/linux/ceph/libceph.h | 1 + net/ceph/ceph_common.c | 5 +++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 0b324e43c9f4..03e5f4bb2b6f 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -268,6 +268,9 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end, if (!fs_name_start) return invalfc(fc, "missing file system name"); + if (ceph_parse_fsid(fsid_start, &fsopt->fsid)) + return invalfc(fc, "invalid fsid format"); + ++fs_name_start; /* start of file system name */ fsopt->mds_namespace = kstrndup(fs_name_start, dev_name_end - fs_name_start, GFP_KERNEL); @@ -750,6 +753,12 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt, } opt = NULL; /* fsc->client now owns this */ + /* help learn fsid */ + if (fsopt->new_dev_syntax) { + ceph_check_fsid(fsc->client, &fsopt->fsid); + fsc->client->have_fsid = true; + } + fsc->client->extra_mon_dispatch = extra_mon_dispatch; ceph_set_opt(fsc->client, ABORT_ON_FULL); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 8f71184b7c85..ce5fb90a01a4 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -99,6 +99,7 @@ struct ceph_mount_options { char *server_path; /* default NULL (means "/") */ char *fscache_uniq; /* default NULL */ char *mon_addr; + struct ceph_fsid fsid; }; struct ceph_fs_client { diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 409d8c29bc4f..75d059b79d90 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h @@ -296,6 +296,7 @@ extern bool libceph_compatible(void *data); extern const char *ceph_msg_type_name(int type); extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid); extern void *ceph_kvmalloc(size_t size, gfp_t flags); +extern int ceph_parse_fsid(const char *str, struct ceph_fsid *fsid); struct fs_parameter; struct fc_log; diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 97d6ea763e32..da480757fcca 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -217,7 +217,7 @@ void *ceph_kvmalloc(size_t size, gfp_t flags) return p; } -static int parse_fsid(const char *str, struct ceph_fsid *fsid) +int ceph_parse_fsid(const char *str, struct ceph_fsid *fsid) { int i = 0; char tmp[3]; @@ -247,6 +247,7 @@ static int parse_fsid(const char *str, struct ceph_fsid *fsid) dout("parse_fsid ret %d got fsid %pU\n", err, fsid); return err; } +EXPORT_SYMBOL(ceph_parse_fsid); /* * ceph options @@ -465,7 +466,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, break; case Opt_fsid: - err = parse_fsid(param->string, &opt->fsid); + err = ceph_parse_fsid(param->string, &opt->fsid); if (err) { error_plog(&log, "Failed to parse fsid: %d", err); return err; -- 2.27.0