From: Venky Shankar <vshankar@redhat.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: idryomov@gmail.com, ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 2/4] ceph: validate cluster FSID for new device syntax
Date: Tue, 29 Jun 2021 10:12:20 +0530 [thread overview]
Message-ID: <CACPzV1=BmxmQUCwM1P-hLcY0RcZAXLPTxF=Kj8c3Jgn8Xn8kvA@mail.gmail.com> (raw)
In-Reply-To: <77c1bc3093a7f74c92a1deb35c0e80291c4d9b52.camel@redhat.com>
On Mon, Jun 28, 2021 at 8:34 PM Jeff Layton <jlayton@redhat.com> wrote:
>
> On Mon, 2021-06-28 at 13:25 +0530, Venky Shankar wrote:
> > 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.
> >
> > Signed-off-by: Venky Shankar <vshankar@redhat.com>
> > ---
> > fs/ceph/super.c | 9 +++++++++
> > fs/ceph/super.h | 1 +
> > include/linux/ceph/libceph.h | 1 +
> > net/ceph/ceph_common.c | 3 ++-
> > 4 files changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> > index 950a28ad9c59..84bc06e51680 100644
> > --- a/fs/ceph/super.c
> > +++ b/fs/ceph/super.c
> > @@ -266,6 +266,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 (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);
> > @@ -748,6 +751,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 557348ff3203..cfd8ec25a9a8 100644
> > --- a/fs/ceph/super.h
> > +++ b/fs/ceph/super.h
> > @@ -100,6 +100,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..24c1f4e9144d 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 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..db21734462a4 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 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(parse_fsid);
>
> This function name is too generic. Maybe rename it to "ceph_parse_fsid"?
Makes sense. ACK.
>
> >
> > /*
> > * ceph options
>
> --
> Jeff Layton <jlayton@redhat.com>
>
--
Cheers,
Venky
next prev parent reply other threads:[~2021-06-29 4:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 7:55 [PATCH 0/4] ceph: new mount device syntax Venky Shankar
2021-06-28 7:55 ` [PATCH 1/4] ceph: new device mount syntax Venky Shankar
2021-06-29 11:32 ` Luis Henriques
2021-06-29 13:54 ` Venky Shankar
2021-06-29 15:10 ` Jeff Layton
2021-06-29 15:42 ` Luis Henriques
2021-06-28 7:55 ` [PATCH 2/4] ceph: validate cluster FSID for new device syntax Venky Shankar
2021-06-28 15:04 ` Jeff Layton
2021-06-29 4:42 ` Venky Shankar [this message]
2021-06-28 7:55 ` [PATCH 3/4] ceph: record updated mon_addr on remount Venky Shankar
2021-06-28 15:19 ` Jeff Layton
2021-06-28 7:55 ` [PATCH 4/4] doc: document new CephFS mount device syntax Venky Shankar
2021-06-28 15:26 ` Jeff Layton
2021-06-29 6:18 ` Venky Shankar
2021-06-28 15:32 ` [PATCH 0/4] ceph: new " Jeff Layton
2021-06-29 11:22 ` Luis Henriques
2021-06-29 12:13 ` Venky Shankar
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='CACPzV1=BmxmQUCwM1P-hLcY0RcZAXLPTxF=Kj8c3Jgn8Xn8kvA@mail.gmail.com' \
--to=vshankar@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=jlayton@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).