Skip to contentSkip to conversation

ceph: add debugfs entries signifying new mount syntax support

PATCH Superseded Venky Shankar 2 participants 7 messages Aug 19, 2021 – Aug 23, 2021

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover ceph: add debugfs entries signifying new mount syntax support

[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(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 ceph: add helpers to create/cleanup debugfs sub-directories under "ceph" directory

Callers can use this helper to create a subdirectory under "ceph" directory in debugfs to place custom files for exporting information to userspace.

---
 include/linux/ceph/debugfs.h |  3 +++
 net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
include/linux/ceph/debugfs.h +3 -0
index 8b3a1a7a953a..c372e6cb8aae 100644
@@ -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
 
net/ceph/debugfs.c +25 -2
index 2110439f8a24..cd6f69dd97fa 100644
@@ -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);
+
 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 */
Signature · 1 line
2.27.0
#2 lore raw

Re: [PATCH 1/2] ceph: add helpers to create/cleanup debugfs sub-directories under "ceph" directory

Quoted 33 lines · Venky Shankar

Callers can use this helper to create a subdirectory under "ceph" directory in debugfs to place custom files for exporting information to userspace.

---
 include/linux/ceph/debugfs.h |  3 +++
 net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
include/linux/ceph/debugfs.h +3 -0
index 8b3a1a7a953a..c372e6cb8aae 100644
@@ -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
 
net/ceph/debugfs.c +2 -0
index 2110439f8a24..cd6f69dd97fa 100644
@@ -404,6 +404,18 @@ void ceph_debugfs_cleanup(void)
 	debugfs_remove(ceph_debugfs_dir);
 }
 
+struct dentry *ceph_debugfs_create_subdir(const char *subdir)
+{

net/ceph/debugfs.c void ceph_debugfs_cleanup(void) · line 418

Quoted 10 lines
net/ceph/debugfs.c +10 -0
+	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.

Quoted 37 lines
net/ceph/debugfs.c +13 -2
 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 */
Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw

Re: [PATCH 1/2] ceph: add helpers to create/cleanup debugfs sub-directories under "ceph" directory

Quoted 33 lines · Jeff Layton
Quoted 31 lines · Venky Shankar

Callers can use this helper to create a subdirectory under "ceph" directory in debugfs to place custom files for exporting information to userspace.

---
 include/linux/ceph/debugfs.h |  3 +++
 net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
include/linux/ceph/debugfs.h +3 -0
index 8b3a1a7a953a..c372e6cb8aae 100644
@@ -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
 
net/ceph/debugfs.c +0 -0
index 2110439f8a24..cd6f69dd97fa 100644
@@ -404,6 +404,18 @@ void ceph_debugfs_cleanup(void)
      debugfs_remove(ceph_debugfs_dir);
 }
 
Quoted 16 lines

net/ceph/debugfs.c void ceph_debugfs_cleanup(void) · line 418

Quoted 12 lines
net/ceph/debugfs.c +12 -0
+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.

Quoted 42 lines
Quoted 28 lines
net/ceph/debugfs.c +4 -2
 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)
+{

net/ceph/debugfs.c void ceph_debugfs_client_cleanup(struct ceph_client *client) · line 501

Quoted 10 lines
net/ceph/debugfs.c +9 -0
+     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 <[email protected]>

Signature · 2 lines
Cheers,
Venky
#4 lore raw

Re: [PATCH 1/2] ceph: add helpers to create/cleanup debugfs sub-directories under "ceph" directory

Quoted 51 lines · Venky Shankar
Quoted 33 lines · Jeff Layton
Quoted 31 lines · Venky Shankar

Callers can use this helper to create a subdirectory under "ceph" directory in debugfs to place custom files for exporting information to userspace.

---
 include/linux/ceph/debugfs.h |  3 +++
 net/ceph/debugfs.c           | 27 +++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
include/linux/ceph/debugfs.h +3 -0
index 8b3a1a7a953a..c372e6cb8aae 100644
@@ -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
 
net/ceph/debugfs.c +0 -0
index 2110439f8a24..cd6f69dd97fa 100644
@@ -404,6 +404,18 @@ void ceph_debugfs_cleanup(void)
      debugfs_remove(ceph_debugfs_dir);
 }
 
Quoted 16 lines

net/ceph/debugfs.c void ceph_debugfs_cleanup(void) · line 418

Quoted 12 lines
net/ceph/debugfs.c +12 -0
+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.

Quoted 3 lines

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.

Quoted 44 lines
Quoted 42 lines
Quoted 28 lines
net/ceph/debugfs.c +4 -2
 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)
+{

net/ceph/debugfs.c void ceph_debugfs_client_cleanup(struct ceph_client *client) · line 501

Quoted 10 lines
net/ceph/debugfs.c +9 -0
+     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 <[email protected]>

Signature · 1 line
Jeff Layton <[email protected]>
#5 lore raw

PATCH 2/2 ceph: add debugfs entries for v2 (new) mount syntax support

In reply to Venky Shankar
---
 fs/ceph/debugfs.c | 28 ++++++++++++++++++++++++++++
 fs/ceph/super.c   |  3 +++
 fs/ceph/super.h   |  2 ++
 3 files changed, 33 insertions(+)
fs/ceph/debugfs.c +28 -0
index 66989c880adb..d19f15ace781 100644
@@ -22,6 +22,12 @@
 #include "mds_client.h"
 #include "metric.h"
 
+#define MNT_DEV_SUPPORT_DIR   "dev_support"
+#define MNT_DEV_V2_FILE  "v2"
+
+static struct dentry *ceph_mnt_dev_support_dir;
+static struct dentry *ceph_mnt_dev_v2_file;
+
 static int mdsmap_show(struct seq_file *s, void *p)
 {
 	int i;
@@ -416,6 +422,20 @@ void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
 						  &status_fops);
 }
 
+void ceph_fs_debugfs_mnt_dev_init(void)
+{
+	ceph_mnt_dev_support_dir = ceph_debugfs_create_subdir(MNT_DEV_SUPPORT_DIR);
+	ceph_mnt_dev_v2_file = debugfs_create_file(MNT_DEV_V2_FILE,
+						   0400,
+						   ceph_mnt_dev_support_dir,
+						   NULL, NULL);
+}
+
+void ceph_fs_debugfs_mnt_dev_cleanup(void)
+{
+	debugfs_remove(ceph_mnt_dev_v2_file);
+	ceph_debugfs_cleanup_subdir(ceph_mnt_dev_support_dir);
+}
 
 #else  /* CONFIG_DEBUG_FS */
 
@@ -427,4 +447,12 @@ void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
 {
 }
 
+void ceph_fs_debugfs_mnt_dev_init(void)
+{
+}
+
+void ceph_fs_debugfs_mnt_dev_cleanup(void)
+{
+}
+
 #endif  /* CONFIG_DEBUG_FS */
fs/ceph/super.c +3 -0
index 609ffc8c2d78..21e4a8249afd 100644
@@ -1404,6 +1404,8 @@ static int __init init_ceph(void)
 	if (ret)
 		goto out_caches;
 
+	ceph_fs_debugfs_mnt_dev_init();
+
 	pr_info("loaded (mds proto %d)\n", CEPH_MDSC_PROTOCOL);
 
 	return 0;
@@ -1417,6 +1419,7 @@ static int __init init_ceph(void)
 static void __exit exit_ceph(void)
 {
 	dout("exit_ceph\n");
+	ceph_fs_debugfs_mnt_dev_cleanup();
 	unregister_filesystem(&ceph_fs_type);
 	destroy_caches();
 }
fs/ceph/super.h +2 -0
index 8f71184b7c85..3c63c1adcfaa 100644
@@ -1231,6 +1231,8 @@ extern int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
 /* debugfs.c */
 extern void ceph_fs_debugfs_init(struct ceph_fs_client *client);
 extern void ceph_fs_debugfs_cleanup(struct ceph_fs_client *client);
+extern void ceph_fs_debugfs_mnt_dev_init(void);
+extern void ceph_fs_debugfs_mnt_dev_cleanup(void);
 
 /* quota.c */
 static inline bool __ceph_has_any_quota(struct ceph_inode_info *ci)
Signature · 1 line
2.27.0
#6 lore raw
In reply to Venky Shankar
Quoted 21 lines · Venky Shankar

[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::

Quoted 8 lines
    /sys/kernel/debug/ceph/
    ....
    ....
    /sys/kernel/debug/ceph/dev_support
    /sys/kernel/debug/ceph/dev_support/v2
    ....
    ....

Hmm I'm not sure I like the idea of adding a directory _just_ to indicate whether v2-style mounts are supported. I think we might want to add something more generic here to indicate what sort of client-side features the kernel supports.

That's useful for teuthology, and also potentially for support in general. How about we rename this dir as:

/sys/kernel/debug/ceph/client_features

...and then we can have a file in there for "v2_mount_device" or something.

Quoted 4 lines

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.

I think we probably _should_ add a v1_mount_device file too. Eventually we may want to drop support for v1 style mounts, once older releases roll off the support matrix. If we drop the file at that time, then that could be a handy way to indicate that the kernel no longer supports them.

Quoted 12 lines

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(-)
Signature · 1 line
Jeff Layton <[email protected]>