diff mbox series

[v2,3/4] ceph: delay parsing of source after all options

Message ID OSZP286MB20611ACB739BBEAF3B26E851C02AA@OSZP286MB2061.JPNP286.PROD.OUTLOOK.COM
State New
Headers show
Series ceph: account for name and fsid in new device spec | expand

Commit Message

胡玮文 June 30, 2023, 4:31 a.m. UTC
Ensure the name, fsid, and mds_namespace in source are consistent with
these in options.

Signed-off-by: Hu Weiwen <huww98@outlook.com>
---
 fs/ceph/super.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 3d36ee4543ed..e66867efd811 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -149,7 +149,6 @@  enum {
 	Opt_snapdirname,
 	Opt_mds_namespace,
 	Opt_recover_session,
-	Opt_source,
 	Opt_mon_addr,
 	/* string args above */
 	Opt_dirstat,
@@ -202,7 +201,6 @@  static const struct fs_parameter_spec ceph_mount_parameters[] = {
 	fsparam_flag_no ("require_active_mds",		Opt_require_active_mds),
 	fsparam_u32	("rsize",			Opt_rsize),
 	fsparam_string	("snapdirname",			Opt_snapdirname),
-	fsparam_string	("source",			Opt_source),
 	fsparam_string	("mon_addr",			Opt_mon_addr),
 	fsparam_u32	("wsize",			Opt_wsize),
 	fsparam_flag_no	("wsync",			Opt_wsync),
@@ -337,11 +335,11 @@  static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end,
  *     <server_spec> is <ip>[:<port>]
  *     <path> is optional, but if present must begin with '/'
  */
-static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
+static int ceph_parse_source(struct fs_context *fc)
 {
 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
 	struct ceph_mount_options *fsopt = pctx->opts;
-	char *dev_name = param->string, *dev_name_end;
+	const char *dev_name = fc->source, *dev_name_end;
 	int ret;
 
 	dout("%s '%s'\n", __func__, dev_name);
@@ -383,8 +381,6 @@  static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
 			return ret;
 	}
 
-	fc->source = param->string;
-	param->string = NULL;
 	return 0;
 }
 
@@ -443,10 +439,6 @@  static int ceph_parse_mount_param(struct fs_context *fc,
 		else
 			BUG();
 		break;
-	case Opt_source:
-		if (fc->source)
-			return invalfc(fc, "Multiple sources specified");
-		return ceph_parse_source(param, fc);
 	case Opt_mon_addr:
 		return ceph_parse_mon_addr(param, fc);
 	case Opt_wsize:
@@ -1220,6 +1212,10 @@  static int ceph_get_tree(struct fs_context *fc)
 
 	if (!fc->source)
 		return invalfc(fc, "No source");
+	err = ceph_parse_source(fc);
+	if (err < 0)
+		return err;
+
 	if (fsopt->new_dev_syntax && !fsopt->mon_addr)
 		return invalfc(fc, "No monitor address");
 
@@ -1301,6 +1297,12 @@  static int ceph_reconfigure_fc(struct fs_context *fc)
 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
 	struct ceph_mount_options *fsopt = pctx->opts;
 	struct ceph_fs_client *fsc = ceph_sb_to_client(fc->root->d_sb);
+	int err;
+
+	/* validate source and options are still consistent */
+	err = ceph_parse_source(fc);
+	if (err < 0)
+		return err;
 
 	if (fsopt->flags & CEPH_MOUNT_OPT_ASYNC_DIROPS)
 		ceph_set_mount_opt(fsc, ASYNC_DIROPS);