Skip to contentSkip to conversation

ceph: add _IDS ioctl cmd and status debug file support

PATCH Superseded [email protected] 2 participants 7 messages Nov 5, 2020 – Nov 10, 2020 Ceph client

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover ceph: add _IDS ioctl cmd and status debug file support

From: Xiubo Li <[email protected]>

Xiubo Li (2):
ceph: add status debug file support
ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support

 fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
 fs/ceph/ioctl.c   | 22 ++++++++++++++++++++++
 fs/ceph/ioctl.h   | 15 +++++++++++++++
 fs/ceph/super.h   |  1 +
 4 files changed, 60 insertions(+)
Signature · 1 line
2.18.4
#1 lore raw

PATCH 1/2 ceph: add status debug file support

From: Xiubo Li <[email protected]>

This will help list some useful client side info, like the client entity address/name and bloclisted status, etc.

URL: https://tracker.ceph.com/issues/48057

---
 fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
 fs/ceph/super.h   |  1 +
 2 files changed, 23 insertions(+)
fs/ceph/debugfs.c +22 -0
index 7a8fbe3e4751..8b6db73c94ad 100644
@@ -14,6 +14,7 @@
 #include <linux/ceph/mon_client.h>
 #include <linux/ceph/auth.h>
 #include <linux/ceph/debugfs.h>
+#include <linux/ceph/messenger.h>
 
 #include "super.h"
 
@@ -127,6 +128,20 @@ static int mdsc_show(struct seq_file *s, void *p)
 	return 0;
 }
 
+static int status_show(struct seq_file *s, void *p)
+{
+	struct ceph_fs_client *fsc = s->private;
+	struct ceph_messenger *msgr = &fsc->client->msgr;
+	struct ceph_entity_inst *inst = &msgr->inst;
+
+	seq_printf(s, "status:\n\n"),
+	seq_printf(s, "\tinst_str:\t%s.%lld  %s/%u\n", ENTITY_NAME(inst->name),
+		   ceph_pr_addr(&inst->addr), le32_to_cpu(inst->addr.nonce));
+	seq_printf(s, "\tblocklisted:\t%s\n", fsc->blocklisted ? "true" : "false");
+
+	return 0;
+}
+
 #define CEPH_METRIC_SHOW(name, total, avg, min, max, sq) {		\
 	s64 _total, _avg, _min, _max, _sq, _st;				\
 	_avg = ktime_to_us(avg);					\
@@ -309,6 +324,7 @@ DEFINE_SHOW_ATTRIBUTE(mdsc);
 DEFINE_SHOW_ATTRIBUTE(caps);
 DEFINE_SHOW_ATTRIBUTE(mds_sessions);
 DEFINE_SHOW_ATTRIBUTE(metric);
+DEFINE_SHOW_ATTRIBUTE(status);
 
 
 /*
@@ -394,6 +410,12 @@ void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
 						fsc->client->debugfs_dir,
 						fsc,
 						&caps_fops);
+
+	fsc->debugfs_status = debugfs_create_file("status",
+						  0400,
+						  fsc->client->debugfs_dir,
+						  fsc,
+						  &status_fops);
 }
 
 
fs/ceph/super.h +1 -0
index f097237a5ad3..5138b75923f9 100644
@@ -128,6 +128,7 @@ struct ceph_fs_client {
 	struct dentry *debugfs_bdi;
 	struct dentry *debugfs_mdsc, *debugfs_mdsmap;
 	struct dentry *debugfs_metric;
+	struct dentry *debugfs_status;
 	struct dentry *debugfs_mds_sessions;
 #endif
 
Signature · 1 line
2.18.4
maintainer
#2 lore raw

Re: [PATCH 1/2] ceph: add status debug file support

Quoted 26 lines · On Thu, Nov 5, 2020 at 3:37 AM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

This will help list some useful client side info, like the client entity address/name and bloclisted status, etc.

URL: https://tracker.ceph.com/issues/48057

---
 fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
 fs/ceph/super.h   |  1 +
 2 files changed, 23 insertions(+)
fs/ceph/debugfs.c +1 -0
index 7a8fbe3e4751..8b6db73c94ad 100644
@@ -14,6 +14,7 @@
 #include <linux/ceph/mon_client.h>
 #include <linux/ceph/auth.h>
 #include <linux/ceph/debugfs.h>
+#include <linux/ceph/messenger.h>
 
 #include "super.h"
 

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 137

Quoted 10 lines
fs/ceph/debugfs.c +7 -0
@@ -127,6 +128,20 @@ static int mdsc_show(struct seq_file *s, void *p)
        return 0;
 }
 
+static int status_show(struct seq_file *s, void *p)
+{
+       struct ceph_fs_client *fsc = s->private;
+       struct ceph_messenger *msgr = &fsc->client->msgr;
+       struct ceph_entity_inst *inst = &msgr->inst;
+
+       seq_printf(s, "status:\n\n"),

Hi Xiubo,

This header and leading tabs seem rather useless to me.

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 138

Quoted 1 line
fs/ceph/debugfs.c +1 -0
+       seq_printf(s, "\tinst_str:\t%s.%lld  %s/%u\n", ENTITY_NAME(inst->name),

^^ two spaces?

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 140

Quoted 2 lines
fs/ceph/debugfs.c +2 -0
+                  ceph_pr_addr(&inst->addr), le32_to_cpu(inst->addr.nonce));
+       seq_printf(s, "\tblocklisted:\t%s\n", fsc->blocklisted ? "true" : "false");

This line is too long.

Thanks,

Ilya

author
#3 lore raw

Re: [PATCH 1/2] ceph: add status debug file support

Quoted 38 lines · Ilya Dryomov
Quoted 25 lines · On Thu, Nov 5, 2020 at 3:37 AM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

This will help list some useful client side info, like the client entity address/name and bloclisted status, etc.

URL: https://tracker.ceph.com/issues/48057

---
  fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
  fs/ceph/super.h   |  1 +
  2 files changed, 23 insertions(+)
fs/ceph/debugfs.c +1 -0
index 7a8fbe3e4751..8b6db73c94ad 100644
@@ -14,6 +14,7 @@
  #include <linux/ceph/mon_client.h>
  #include <linux/ceph/auth.h>
  #include <linux/ceph/debugfs.h>
+#include <linux/ceph/messenger.h>
 
  #include "super.h"
 

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 137

Quoted 10 lines
fs/ceph/debugfs.c +7 -0
@@ -127,6 +128,20 @@ static int mdsc_show(struct seq_file *s, void *p)
         return 0;
  }
 
+static int status_show(struct seq_file *s, void *p)
+{
+       struct ceph_fs_client *fsc = s->private;
+       struct ceph_messenger *msgr = &fsc->client->msgr;
+       struct ceph_entity_inst *inst = &msgr->inst;
+
+       seq_printf(s, "status:\n\n"),

Hi Xiubo,

Quoted 1 line

This header and leading tabs seem rather useless to me.

Sure, will remove them.

Quoted 6 lines

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 138

Quoted 1 line
fs/ceph/debugfs.c +1 -0
+       seq_printf(s, "\tinst_str:\t%s.%lld  %s/%u\n", ENTITY_NAME(inst->name),

^^ two spaces?

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 140

Quoted 2 lines
fs/ceph/debugfs.c +2 -0
+                  ceph_pr_addr(&inst->addr), le32_to_cpu(inst->addr.nonce));
+       seq_printf(s, "\tblocklisted:\t%s\n", fsc->blocklisted ? "true" : "false");

This line is too long.

Will fix it.

Thank Ilya.

Quoted 4 lines

Thanks,

Ilya

#4 lore raw

PATCH 2/2 ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support

In reply to [email protected]

From: Xiubo Li <[email protected]>

This ioctl will return the dedicated fs and client IDs back to userspace. With this we can easily know which mountpoint the file blongs to and also they can help locate the debugfs path quickly.

URL: https://tracker.ceph.com/issues/48124

---
 fs/ceph/ioctl.c | 22 ++++++++++++++++++++++
 fs/ceph/ioctl.h | 15 +++++++++++++++
 2 files changed, 37 insertions(+)
fs/ceph/ioctl.c +22 -0
index 6e061bf62ad4..2498a1df132e 100644
@@ -268,6 +268,25 @@ static long ceph_ioctl_syncio(struct file *file)
 	return 0;
 }
 
+static long ceph_ioctl_get_client_id(struct file *file, void __user *arg)
+{
+	struct inode *inode = file_inode(file);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
+	struct fs_client_ids ids;
+	char fsid[40];
+
+	snprintf(fsid, sizeof(fsid), "%pU", &fsc->client->fsid);
+	memcpy(ids.fsid, fsid, sizeof(fsid));
+
+	ids.global_id = fsc->client->monc.auth->global_id;
+
+	/* send result back to user */
+	if (copy_to_user(arg, &ids, sizeof(ids)))
+		return -EFAULT;
+
+	return 0;
+}
+
 long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
@@ -289,6 +308,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	case CEPH_IOC_SYNCIO:
 		return ceph_ioctl_syncio(file);
+
+	case CEPH_IOC_GET_FS_CLIENT_IDS:
+		return ceph_ioctl_get_client_id(file, (void __user *)arg);
 	}
 
 	return -ENOTTY;
fs/ceph/ioctl.h +15 -0
index 51f7f1d39a94..59c7479e77b2 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
  */
 #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
+/*
+ * CEPH_IOC_GET_FS_CLIENT_IDS - get the fs and client ids
+ *
+ * This ioctl will return the dedicated fs and client IDs back to
+ * userspace. With this we can easily know which mountpoint the file
+ * blongs to and also they can help locate the debugfs path quickly.
+ */
+
+struct fs_client_ids {
+	char fsid[40];
+	__u64 global_id;
+};
+#define CEPH_IOC_GET_FS_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct fs_client_ids)
+
 #endif
Signature · 1 line
2.18.4
maintainer
#5 lore raw

Re: [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support

Quoted 6 lines · On Thu, Nov 5, 2020 at 3:37 AM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the dedicated fs and client IDs back to userspace. With this we can easily know which mountpoint the file blongs to and also they can help locate the debugfs path quickly.

belongs

Quoted 17 lines

URL: https://tracker.ceph.com/issues/48124

---
 fs/ceph/ioctl.c | 22 ++++++++++++++++++++++
 fs/ceph/ioctl.h | 15 +++++++++++++++
 2 files changed, 37 insertions(+)
fs/ceph/ioctl.c +1 -0
index 6e061bf62ad4..2498a1df132e 100644
@@ -268,6 +268,25 @@ static long ceph_ioctl_syncio(struct file *file)
        return 0;
 }
 
+static long ceph_ioctl_get_client_id(struct file *file, void __user *arg)

fs/ceph/ioctl.c static long ceph_ioctl_syncio(struct file *file) · line 281

Quoted 10 lines
fs/ceph/ioctl.c +10 -0
+{
+       struct inode *inode = file_inode(file);
+       struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
+       struct fs_client_ids ids;
+       char fsid[40];
+
+       snprintf(fsid, sizeof(fsid), "%pU", &fsc->client->fsid);
+       memcpy(ids.fsid, fsid, sizeof(fsid));
+
+       ids.global_id = fsc->client->monc.auth->global_id;

Why is fsid returned in text and global_id in binary? I get that the initial use case is constructing "<fsid>.client<global_id>" string, but it's probably better to stick to binary.

Use ceph_client_gid() for getting global_id.

Quoted 26 lines
fs/ceph/ioctl.c +11 -0
+
+       /* send result back to user */
+       if (copy_to_user(arg, &ids, sizeof(ids)))
+               return -EFAULT;
+
+       return 0;
+}
+
 long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
@@ -289,6 +308,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        case CEPH_IOC_SYNCIO:
                return ceph_ioctl_syncio(file);
+
+       case CEPH_IOC_GET_FS_CLIENT_IDS:
+               return ceph_ioctl_get_client_id(file, (void __user *)arg);
        }
 
        return -ENOTTY;
fs/ceph/ioctl.h +0 -0
index 51f7f1d39a94..59c7479e77b2 100644

fs/ceph/ioctl.h struct ceph_ioctl_dataloc { · line 104

Quoted 7 lines
fs/ceph/ioctl.h +4 -0
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
  */
 #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
+/*
+ * CEPH_IOC_GET_FS_CLIENT_IDS - get the fs and client ids
+ *
+ * This ioctl will return the dedicated fs and client IDs back to

The "fsid" you are capturing is really a cluster id, which may be home to multiple CephFS filesystems. Referring to it as a "dedicated fs ID" is misleading.

Thanks,

Ilya

author
#6 lore raw

Re: [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support

Quoted 7 lines · Ilya Dryomov
Quoted 5 lines · On Thu, Nov 5, 2020 at 3:37 AM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the dedicated fs and client IDs back to userspace. With this we can easily know which mountpoint the file blongs to and also they can help locate the debugfs path quickly.

belongs

Will fix it.

Quoted 16 lines
Quoted 16 lines

URL: https://tracker.ceph.com/issues/48124

---
  fs/ceph/ioctl.c | 22 ++++++++++++++++++++++
  fs/ceph/ioctl.h | 15 +++++++++++++++
  2 files changed, 37 insertions(+)
fs/ceph/ioctl.c +0 -0
index 6e061bf62ad4..2498a1df132e 100644
@@ -268,6 +268,25 @@ static long ceph_ioctl_syncio(struct file *file)
         return 0;
  }
 
Quoted 14 lines

fs/ceph/ioctl.c static long ceph_ioctl_syncio(struct file *file) · line 281

Quoted 11 lines
fs/ceph/ioctl.c +11 -0
+static long ceph_ioctl_get_client_id(struct file *file, void __user *arg)
+{
+       struct inode *inode = file_inode(file);
+       struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
+       struct fs_client_ids ids;
+       char fsid[40];
+
+       snprintf(fsid, sizeof(fsid), "%pU", &fsc->client->fsid);
+       memcpy(ids.fsid, fsid, sizeof(fsid));
+
+       ids.global_id = fsc->client->monc.auth->global_id;

Why is fsid returned in text and global_id in binary? I get that the initial use case is constructing "<fsid>.client<global_id>" string, but it's probably better to stick to binary.

Checked the ceph_debugfs_client_init() and rbd.c, they are both returning in text like this:

snprintf(name, sizeof(name), "%pU.client%lld", &client->fsid, client->monc.auth->global_id);

So let's make it the same with the rbd.c.

Quoted 31 lines

Use ceph_client_gid() for getting global_id.

Quoted 29 lines
fs/ceph/ioctl.c +11 -0
+
+       /* send result back to user */
+       if (copy_to_user(arg, &ids, sizeof(ids)))
+               return -EFAULT;
+
+       return 0;
+}
+
  long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  {
         dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
@@ -289,6 +308,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
         case CEPH_IOC_SYNCIO:
                 return ceph_ioctl_syncio(file);
+
+       case CEPH_IOC_GET_FS_CLIENT_IDS:
+               return ceph_ioctl_get_client_id(file, (void __user *)arg);
         }
 
         return -ENOTTY;
fs/ceph/ioctl.h +0 -0
index 51f7f1d39a94..59c7479e77b2 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
   */
  #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
Quoted 7 lines

fs/ceph/ioctl.h struct ceph_ioctl_dataloc { · line 104

Quoted 4 lines
fs/ceph/ioctl.h +4 -0
+/*
+ * CEPH_IOC_GET_FS_CLIENT_IDS - get the fs and client ids
+ *
+ * This ioctl will return the dedicated fs and client IDs back to

The "fsid" you are capturing is really a cluster id, which may be home to multiple CephFS filesystems. Referring to it as a "dedicated fs ID" is misleading.

Yeah, it is, will fix it.

Thanks.

Quoted 5 lines

Thanks,

Ilya