All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hu Weiwen <huww98@outlook.com>
To: ceph-devel@vger.kernel.org, Xiubo Li <xiubli@redhat.com>,
	Ilya Dryomov <idryomov@gmail.com>
Cc: Venky Shankar <vshankar@redhat.com>,
	Milind Changire <mchangir@redhat.com>,
	Hu Weiwen <huww98@outlook.com>
Subject: [PATCH v2 2/4] ceph: save name and fsid in mount source
Date: Fri, 30 Jun 2023 12:31:15 +0800	[thread overview]
Message-ID: <OSZP286MB206153D62F11413F199948A8C02AA@OSZP286MB2061.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <OSZP286MB2061AF068B5B9462B1A8E461C02AA@OSZP286MB2061.JPNP286.PROD.OUTLOOK.COM>

We have name and fsid in the new device syntax.  It is confusing that
the kernel accept these info but do not take them into account when
connecting to the cluster.

Although the mount.ceph helper program will extract the name from device
spec and pass it as name options, these changes are still useful if we
don't have that program installed, or if we want to call `mount()'
directly.

Signed-off-by: Hu Weiwen <huww98@outlook.com>
---
 fs/ceph/super.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 9185ff00bb61..3d36ee4543ed 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -267,6 +267,7 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end,
 	struct ceph_fsid fsid;
 	struct ceph_parse_opts_ctx *pctx = fc->fs_private;
 	struct ceph_mount_options *fsopt = pctx->opts;
+	struct ceph_options *copts = pctx->copts;
 	char *fsid_start, *fs_name_start;
 
 	if (*dev_name_end != '=') {
@@ -285,6 +286,12 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end,
 
 	if (ceph_parse_fsid(fsid_start, &fsid))
 		return invalfc(fc, "Invalid FSID");
+	if (!(copts->flags & CEPH_OPT_FSID)) {
+		copts->fsid = fsid;
+		copts->flags |= CEPH_OPT_FSID;
+	} else if (ceph_fsid_compare(&fsid, &copts->fsid)) {
+		return invalfc(fc, "Mismatching cluster FSID between mount source and options");
+	}
 
 	++fs_name_start; /* start of file system name */
 	len = dev_name_end - fs_name_start;
@@ -294,10 +301,20 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end,
 		if (!fsopt->mds_namespace)
 			return -ENOMEM;
 	} else if (!strstrn_equals(fsopt->mds_namespace, fs_name_start, len)) {
-		return invalfc(fc, "Mismatching mds_namespace");
+		return invalfc(fc, "Mismatching mds_namespace between mount source and options");
 	}
 	dout("file system (mds namespace) '%s'\n", fsopt->mds_namespace);
 
+	len = fsid_start - dev_name - 1;
+	if (!copts->name) {
+		copts->name = kstrndup(dev_name, len, GFP_KERNEL);
+		if (!copts->name)
+			return -ENOMEM;
+	} else if (!strstrn_equals(copts->name, dev_name, len)) {
+		return invalfc(fc, "Mismatching cephx name between mount source and options");
+	}
+	dout("cephx name '%s'\n", copts->name);
+
 	fsopt->new_dev_syntax = true;
 	return 0;
 }
-- 
2.25.1


  parent reply	other threads:[~2023-06-30  4:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-07 17:53 [PATCH 0/3] ceph: account for name and fsid in new device spec Hu Weiwen
2023-05-07 17:55 ` [PATCH 1/3] ceph: refactor mds_namespace comparing Hu Weiwen
2023-05-09  1:04   ` Xiubo Li
2023-05-09  1:40     ` Xiubo Li
2023-06-05 11:03       ` Milind Changire
2023-05-07 17:55 ` [PATCH 2/3] ceph: save name and fsid in mount source Hu Weiwen
2023-05-09  1:36   ` Xiubo Li
2023-05-09 13:55     ` 胡玮文
2023-05-10  0:42       ` Xiubo Li
2023-05-10  1:50         ` 胡玮文
2023-05-10  2:00           ` Xiubo Li
2023-05-07 17:55 ` [PATCH 3/3] libceph: reject mismatching name and fsid Hu Weiwen
2023-05-10  7:02   ` Xiubo Li
2023-05-10  8:44     ` 胡玮文
2023-05-10 10:44       ` Xiubo Li
2023-05-10 11:46         ` 胡玮文
2023-06-27 11:47   ` Ilya Dryomov
2023-06-30  4:44     ` 胡玮文
2023-05-17  0:40 ` [PATCH 0/3] ceph: account for name and fsid in new device spec Xiubo Li
2023-06-30  4:26 ` [PATCH v2 0/4] " Hu Weiwen
2023-06-30  4:31   ` [PATCH v2 1/4] ceph: refactor mds_namespace comparing Hu Weiwen
2023-06-30  4:31   ` Hu Weiwen [this message]
2023-06-30  4:31   ` [PATCH v2 3/4] ceph: delay parsing of source after all options Hu Weiwen
2023-06-30  4:31   ` [PATCH v2 4/4] ceph: allow mds_namespace to appear multiple times Hu Weiwen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OSZP286MB206153D62F11413F199948A8C02AA@OSZP286MB2061.JPNP286.PROD.OUTLOOK.COM \
    --to=huww98@outlook.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=mchangir@redhat.com \
    --cc=vshankar@redhat.com \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.