mbox series

[0/2] ceph: add debugfs entries signifying new mount syntax support

Message ID 20210819060701.25486-1-vshankar@redhat.com
Headers show
Series ceph: add debugfs entries signifying new mount syntax support | expand

Message

Venky Shankar Aug. 19, 2021, 6:06 a.m. UTC
[This is based on top of new mount syntax series]

Patrick proposed the idea of having debugfs entries to signify if
kernel supports the new (v2) mount syntax. The primary use of this
information is to catch any bugs in the new syntax implementation.

This would be done as follows::

The userspace mount helper tries to mount using the new mount syntax
and fallsback to using old syntax if the mount using new syntax fails.
However, a bug in the new mount syntax implementation can silently
result in the mount helper switching to old syntax.

So, the debugfs entries can be relied upon by the mount helper to
check if the kernel supports the new mount syntax. Cases when the
mount using the new syntax fails, but the kernel does support the
new mount syntax, the mount helper could probably log before switching
to the old syntax (or fail the mount altogether when run in test mode).

Debugfs entries are as follows::

    /sys/kernel/debug/ceph/
    ....
    ....
    /sys/kernel/debug/ceph/dev_support
    /sys/kernel/debug/ceph/dev_support/v2
    ....
    ....

Note that there is no entry signifying v1 mount syntax. That's because
the kernel still supports mounting with old syntax and older kernels do
not have debug entries for the same.

Venky Shankar (2):
  ceph: add helpers to create/cleanup debugfs sub-directories under
    "ceph" directory
  ceph: add debugfs entries for v2 (new) mount syntax support

 fs/ceph/debugfs.c            | 28 ++++++++++++++++++++++++++++
 fs/ceph/super.c              |  3 +++
 fs/ceph/super.h              |  2 ++
 include/linux/ceph/debugfs.h |  3 +++
 net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--
 5 files changed, 61 insertions(+), 2 deletions(-)

Comments

Jeff Layton Aug. 19, 2021, 5:16 p.m. UTC | #1
On Thu, 2021-08-19 at 11:37 +0530, Venky Shankar wrote:
> Callers can use this helper to create a subdirectory under
> "ceph" directory in debugfs to place custom files for exporting
> information to userspace.
> 
> Signed-off-by: Venky Shankar <vshankar@redhat.com>
> ---
>  include/linux/ceph/debugfs.h |  3 +++
>  net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--
>  2 files changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/ceph/debugfs.h b/include/linux/ceph/debugfs.h
> index 8b3a1a7a953a..c372e6cb8aae 100644
> --- a/include/linux/ceph/debugfs.h
> +++ b/include/linux/ceph/debugfs.h
> @@ -10,5 +10,8 @@ extern void ceph_debugfs_cleanup(void);
>  extern void ceph_debugfs_client_init(struct ceph_client *client);
>  extern void ceph_debugfs_client_cleanup(struct ceph_client *client);
>  
> +extern struct dentry *ceph_debugfs_create_subdir(const char *subdir);
> +extern void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry);
> +
>  #endif
>  
> diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
> index 2110439f8a24..cd6f69dd97fa 100644
> --- a/net/ceph/debugfs.c
> +++ b/net/ceph/debugfs.c
> @@ -404,6 +404,18 @@ void ceph_debugfs_cleanup(void)
>  	debugfs_remove(ceph_debugfs_dir);
>  }
>  
> +struct dentry *ceph_debugfs_create_subdir(const char *subdir)
> +{
> +	return debugfs_create_dir(subdir, ceph_debugfs_dir);
> +}
> +EXPORT_SYMBOL(ceph_debugfs_create_subdir);
> +
> +void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry)
> +{
> +	debugfs_remove(subdir_dentry);
> +}
> +EXPORT_SYMBOL(ceph_debugfs_cleanup_subdir);
> +

Rather than these specialized helpers, I think it'd be cleaner/more
evident to just export the ceph_debugfs_dir symbol and then use normal
debugfs commands in ceph.ko.

>  void ceph_debugfs_client_init(struct ceph_client *client)
>  {
>  	char name[80];
> @@ -413,7 +425,7 @@ void ceph_debugfs_client_init(struct ceph_client *client)
>  
>  	dout("ceph_debugfs_client_init %p %s\n", client, name);
>  
> -	client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir);
> +	client->debugfs_dir = ceph_debugfs_create_subdir(name);
>  
>  	client->monc.debugfs_file = debugfs_create_file("monc",
>  						      0400,
> @@ -454,7 +466,7 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)
>  	debugfs_remove(client->debugfs_monmap);
>  	debugfs_remove(client->osdc.debugfs_file);
>  	debugfs_remove(client->monc.debugfs_file);
> -	debugfs_remove(client->debugfs_dir);
> +	ceph_debugfs_cleanup_subdir(client->debugfs_dir);
>  }
>  
>  #else  /* CONFIG_DEBUG_FS */
> @@ -475,4 +487,15 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)
>  {
>  }
>  
> +struct dentry *ceph_debugfs_create_subdir(const char *subdir)
> +{
> +	return NULL;
> +}
> +EXPORT_SYMBOL(ceph_debugfs_create_subdir);
> +
> +void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry)
> +{
> +}
> +EXPORT_SYMBOL(ceph_debugfs_cleanup_subdir);
> +
>  #endif  /* CONFIG_DEBUG_FS */
Venky Shankar Aug. 23, 2021, 4:55 a.m. UTC | #2
On Thu, Aug 19, 2021 at 10:46 PM Jeff Layton <jlayton@redhat.com> wrote:
>

> On Thu, 2021-08-19 at 11:37 +0530, Venky Shankar wrote:

> > Callers can use this helper to create a subdirectory under

> > "ceph" directory in debugfs to place custom files for exporting

> > information to userspace.

> >

> > Signed-off-by: Venky Shankar <vshankar@redhat.com>

> > ---

> >  include/linux/ceph/debugfs.h |  3 +++

> >  net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--

> >  2 files changed, 28 insertions(+), 2 deletions(-)

> >

> > diff --git a/include/linux/ceph/debugfs.h b/include/linux/ceph/debugfs.h

> > index 8b3a1a7a953a..c372e6cb8aae 100644

> > --- a/include/linux/ceph/debugfs.h

> > +++ b/include/linux/ceph/debugfs.h

> > @@ -10,5 +10,8 @@ extern void ceph_debugfs_cleanup(void);

> >  extern void ceph_debugfs_client_init(struct ceph_client *client);

> >  extern void ceph_debugfs_client_cleanup(struct ceph_client *client);

> >

> > +extern struct dentry *ceph_debugfs_create_subdir(const char *subdir);

> > +extern void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry);

> > +

> >  #endif

> >

> > diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c

> > index 2110439f8a24..cd6f69dd97fa 100644

> > --- a/net/ceph/debugfs.c

> > +++ b/net/ceph/debugfs.c

> > @@ -404,6 +404,18 @@ void ceph_debugfs_cleanup(void)

> >       debugfs_remove(ceph_debugfs_dir);

> >  }

> >

> > +struct dentry *ceph_debugfs_create_subdir(const char *subdir)

> > +{

> > +     return debugfs_create_dir(subdir, ceph_debugfs_dir);

> > +}

> > +EXPORT_SYMBOL(ceph_debugfs_create_subdir);

> > +

> > +void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry)

> > +{

> > +     debugfs_remove(subdir_dentry);

> > +}

> > +EXPORT_SYMBOL(ceph_debugfs_cleanup_subdir);

> > +

>

> Rather than these specialized helpers, I think it'd be cleaner/more

> evident to just export the ceph_debugfs_dir symbol and then use normal

> debugfs commands in ceph.ko.


I had initially thought of doing that, but was concerned about putting
ceph_debugfs_dir to abuse once exported.

>

> >  void ceph_debugfs_client_init(struct ceph_client *client)

> >  {

> >       char name[80];

> > @@ -413,7 +425,7 @@ void ceph_debugfs_client_init(struct ceph_client *client)

> >

> >       dout("ceph_debugfs_client_init %p %s\n", client, name);

> >

> > -     client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir);

> > +     client->debugfs_dir = ceph_debugfs_create_subdir(name);

> >

> >       client->monc.debugfs_file = debugfs_create_file("monc",

> >                                                     0400,

> > @@ -454,7 +466,7 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)

> >       debugfs_remove(client->debugfs_monmap);

> >       debugfs_remove(client->osdc.debugfs_file);

> >       debugfs_remove(client->monc.debugfs_file);

> > -     debugfs_remove(client->debugfs_dir);

> > +     ceph_debugfs_cleanup_subdir(client->debugfs_dir);

> >  }

> >

> >  #else  /* CONFIG_DEBUG_FS */

> > @@ -475,4 +487,15 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)

> >  {

> >  }

> >

> > +struct dentry *ceph_debugfs_create_subdir(const char *subdir)

> > +{

> > +     return NULL;

> > +}

> > +EXPORT_SYMBOL(ceph_debugfs_create_subdir);

> > +

> > +void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry)

> > +{

> > +}

> > +EXPORT_SYMBOL(ceph_debugfs_cleanup_subdir);

> > +

> >  #endif  /* CONFIG_DEBUG_FS */

>

> --

> Jeff Layton <jlayton@redhat.com>

>



-- 
Cheers,
Venky
Jeff Layton Aug. 23, 2021, 10:30 a.m. UTC | #3
On Mon, 2021-08-23 at 10:25 +0530, Venky Shankar wrote:
> On Thu, Aug 19, 2021 at 10:46 PM Jeff Layton <jlayton@redhat.com> wrote:

> > 

> > On Thu, 2021-08-19 at 11:37 +0530, Venky Shankar wrote:

> > > Callers can use this helper to create a subdirectory under

> > > "ceph" directory in debugfs to place custom files for exporting

> > > information to userspace.

> > > 

> > > Signed-off-by: Venky Shankar <vshankar@redhat.com>

> > > ---

> > >  include/linux/ceph/debugfs.h |  3 +++

> > >  net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--

> > >  2 files changed, 28 insertions(+), 2 deletions(-)

> > > 

> > > diff --git a/include/linux/ceph/debugfs.h b/include/linux/ceph/debugfs.h

> > > index 8b3a1a7a953a..c372e6cb8aae 100644

> > > --- a/include/linux/ceph/debugfs.h

> > > +++ b/include/linux/ceph/debugfs.h

> > > @@ -10,5 +10,8 @@ extern void ceph_debugfs_cleanup(void);

> > >  extern void ceph_debugfs_client_init(struct ceph_client *client);

> > >  extern void ceph_debugfs_client_cleanup(struct ceph_client *client);

> > > 

> > > +extern struct dentry *ceph_debugfs_create_subdir(const char *subdir);

> > > +extern void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry);

> > > +

> > >  #endif

> > > 

> > > diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c

> > > index 2110439f8a24..cd6f69dd97fa 100644

> > > --- a/net/ceph/debugfs.c

> > > +++ b/net/ceph/debugfs.c

> > > @@ -404,6 +404,18 @@ void ceph_debugfs_cleanup(void)

> > >       debugfs_remove(ceph_debugfs_dir);

> > >  }

> > > 

> > > +struct dentry *ceph_debugfs_create_subdir(const char *subdir)

> > > +{

> > > +     return debugfs_create_dir(subdir, ceph_debugfs_dir);

> > > +}

> > > +EXPORT_SYMBOL(ceph_debugfs_create_subdir);

> > > +

> > > +void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry)

> > > +{

> > > +     debugfs_remove(subdir_dentry);

> > > +}

> > > +EXPORT_SYMBOL(ceph_debugfs_cleanup_subdir);

> > > +

> > 

> > Rather than these specialized helpers, I think it'd be cleaner/more

> > evident to just export the ceph_debugfs_dir symbol and then use normal

> > debugfs commands in ceph.ko.

> 

> I had initially thought of doing that, but was concerned about putting

> ceph_debugfs_dir to abuse once exported.

> 


I wouldn't worry about that. The only external user of this symbol will
be in ceph.ko and we'll vet any code that goes in there.

> > 

> > >  void ceph_debugfs_client_init(struct ceph_client *client)

> > >  {

> > >       char name[80];

> > > @@ -413,7 +425,7 @@ void ceph_debugfs_client_init(struct ceph_client *client)

> > > 

> > >       dout("ceph_debugfs_client_init %p %s\n", client, name);

> > > 

> > > -     client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir);

> > > +     client->debugfs_dir = ceph_debugfs_create_subdir(name);

> > > 

> > >       client->monc.debugfs_file = debugfs_create_file("monc",

> > >                                                     0400,

> > > @@ -454,7 +466,7 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)

> > >       debugfs_remove(client->debugfs_monmap);

> > >       debugfs_remove(client->osdc.debugfs_file);

> > >       debugfs_remove(client->monc.debugfs_file);

> > > -     debugfs_remove(client->debugfs_dir);

> > > +     ceph_debugfs_cleanup_subdir(client->debugfs_dir);

> > >  }

> > > 

> > >  #else  /* CONFIG_DEBUG_FS */

> > > @@ -475,4 +487,15 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)

> > >  {

> > >  }

> > > 

> > > +struct dentry *ceph_debugfs_create_subdir(const char *subdir)

> > > +{

> > > +     return NULL;

> > > +}

> > > +EXPORT_SYMBOL(ceph_debugfs_create_subdir);

> > > +

> > > +void ceph_debugfs_cleanup_subdir(struct dentry *subdir_dentry)

> > > +{

> > > +}

> > > +EXPORT_SYMBOL(ceph_debugfs_cleanup_subdir);

> > > +

> > >  #endif  /* CONFIG_DEBUG_FS */

> > 

> > --

> > Jeff Layton <jlayton@redhat.com>

> > 

> 

> 


-- 
Jeff Layton <jlayton@redhat.com>