ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2]  ceph: add _IDS ioctl cmd and status debug file support
@ 2020-11-05  2:37 xiubli
  2020-11-05  2:37 ` [PATCH 1/2] ceph: add " xiubli
  2020-11-05  2:37 ` [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support xiubli
  0 siblings, 2 replies; 7+ messages in thread
From: xiubli @ 2020-11-05  2:37 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, zyan, pdonnell, ceph-devel, Xiubo Li

From: Xiubo Li <xiubli@redhat.com>

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(+)

-- 
2.18.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] ceph: add status debug file support
  2020-11-05  2:37 [PATCH 0/2] ceph: add _IDS ioctl cmd and status debug file support xiubli
@ 2020-11-05  2:37 ` xiubli
  2020-11-10  7:51   ` Ilya Dryomov
  2020-11-05  2:37 ` [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support xiubli
  1 sibling, 1 reply; 7+ messages in thread
From: xiubli @ 2020-11-05  2:37 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, zyan, pdonnell, ceph-devel, Xiubo Li

From: Xiubo Li <xiubli@redhat.com>

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
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
 fs/ceph/super.h   |  1 +
 2 files changed, 23 insertions(+)

diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index 7a8fbe3e4751..8b6db73c94ad 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -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);
 }
 
 
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index f097237a5ad3..5138b75923f9 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -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
 
-- 
2.18.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support
  2020-11-05  2:37 [PATCH 0/2] ceph: add _IDS ioctl cmd and status debug file support xiubli
  2020-11-05  2:37 ` [PATCH 1/2] ceph: add " xiubli
@ 2020-11-05  2:37 ` xiubli
  2020-11-10  8:05   ` Ilya Dryomov
  1 sibling, 1 reply; 7+ messages in thread
From: xiubli @ 2020-11-05  2:37 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, zyan, pdonnell, ceph-devel, Xiubo Li

From: Xiubo Li <xiubli@redhat.com>

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
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/ioctl.c | 22 ++++++++++++++++++++++
 fs/ceph/ioctl.h | 15 +++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 6e061bf62ad4..2498a1df132e 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -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;
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
index 51f7f1d39a94..59c7479e77b2 100644
--- a/fs/ceph/ioctl.h
+++ b/fs/ceph/ioctl.h
@@ -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
-- 
2.18.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ceph: add status debug file support
  2020-11-05  2:37 ` [PATCH 1/2] ceph: add " xiubli
@ 2020-11-10  7:51   ` Ilya Dryomov
  2020-11-10  8:03     ` Xiubo Li
  0 siblings, 1 reply; 7+ messages in thread
From: Ilya Dryomov @ 2020-11-10  7:51 UTC (permalink / raw)
  To: Xiubo Li; +Cc: Jeff Layton, Yan, Zheng, Patrick Donnelly, Ceph Development

On Thu, Nov 5, 2020 at 3:37 AM <xiubli@redhat.com> wrote:
>
> From: Xiubo Li <xiubli@redhat.com>
>
> 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
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
>  fs/ceph/super.h   |  1 +
>  2 files changed, 23 insertions(+)
>
> diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
> index 7a8fbe3e4751..8b6db73c94ad 100644
> --- a/fs/ceph/debugfs.c
> +++ b/fs/ceph/debugfs.c
> @@ -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"),

Hi Xiubo,

This header and leading tabs seem rather useless to me.

> +       seq_printf(s, "\tinst_str:\t%s.%lld  %s/%u\n", ENTITY_NAME(inst->name),

                                             ^^ two spaces?

> +                  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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ceph: add status debug file support
  2020-11-10  7:51   ` Ilya Dryomov
@ 2020-11-10  8:03     ` Xiubo Li
  0 siblings, 0 replies; 7+ messages in thread
From: Xiubo Li @ 2020-11-10  8:03 UTC (permalink / raw)
  To: Ilya Dryomov; +Cc: Jeff Layton, Yan, Zheng, Patrick Donnelly, Ceph Development

On 2020/11/10 15:51, Ilya Dryomov wrote:
> On Thu, Nov 5, 2020 at 3:37 AM <xiubli@redhat.com> wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> 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
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>   fs/ceph/debugfs.c | 22 ++++++++++++++++++++++
>>   fs/ceph/super.h   |  1 +
>>   2 files changed, 23 insertions(+)
>>
>> diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
>> index 7a8fbe3e4751..8b6db73c94ad 100644
>> --- a/fs/ceph/debugfs.c
>> +++ b/fs/ceph/debugfs.c
>> @@ -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"),
> Hi Xiubo,
>
> This header and leading tabs seem rather useless to me.

Sure, will remove them.


>> +       seq_printf(s, "\tinst_str:\t%s.%lld  %s/%u\n", ENTITY_NAME(inst->name),
>                                               ^^ two spaces?
>
>> +                  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.


> Thanks,
>
>                  Ilya
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support
  2020-11-05  2:37 ` [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support xiubli
@ 2020-11-10  8:05   ` Ilya Dryomov
  2020-11-10  8:54     ` Xiubo Li
  0 siblings, 1 reply; 7+ messages in thread
From: Ilya Dryomov @ 2020-11-10  8:05 UTC (permalink / raw)
  To: Xiubo Li; +Cc: Jeff Layton, Yan, Zheng, Patrick Donnelly, Ceph Development

On Thu, Nov 5, 2020 at 3:37 AM <xiubli@redhat.com> wrote:
>
> From: Xiubo Li <xiubli@redhat.com>
>
> 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

>
> URL: https://tracker.ceph.com/issues/48124
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  fs/ceph/ioctl.c | 22 ++++++++++++++++++++++
>  fs/ceph/ioctl.h | 15 +++++++++++++++
>  2 files changed, 37 insertions(+)
>
> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
> index 6e061bf62ad4..2498a1df132e 100644
> --- a/fs/ceph/ioctl.c
> +++ b/fs/ceph/ioctl.c
> @@ -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;

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.

> +
> +       /* 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;
> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
> index 51f7f1d39a94..59c7479e77b2 100644
> --- a/fs/ceph/ioctl.h
> +++ b/fs/ceph/ioctl.h
> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support
  2020-11-10  8:05   ` Ilya Dryomov
@ 2020-11-10  8:54     ` Xiubo Li
  0 siblings, 0 replies; 7+ messages in thread
From: Xiubo Li @ 2020-11-10  8:54 UTC (permalink / raw)
  To: Ilya Dryomov; +Cc: Jeff Layton, Yan, Zheng, Patrick Donnelly, Ceph Development

On 2020/11/10 16:05, Ilya Dryomov wrote:
> On Thu, Nov 5, 2020 at 3:37 AM <xiubli@redhat.com> wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> 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.
>
>> URL: https://tracker.ceph.com/issues/48124
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>   fs/ceph/ioctl.c | 22 ++++++++++++++++++++++
>>   fs/ceph/ioctl.h | 15 +++++++++++++++
>>   2 files changed, 37 insertions(+)
>>
>> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
>> index 6e061bf62ad4..2498a1df132e 100644
>> --- a/fs/ceph/ioctl.c
>> +++ b/fs/ceph/ioctl.c
>> @@ -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;
> 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.


> Use ceph_client_gid() for getting 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;
>> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
>> index 51f7f1d39a94..59c7479e77b2 100644
>> --- a/fs/ceph/ioctl.h
>> +++ b/fs/ceph/ioctl.h
>> @@ -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.

Yeah, it is, will fix it.

Thanks.

>
> Thanks,
>
>                  Ilya
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-10  8:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  2:37 [PATCH 0/2] ceph: add _IDS ioctl cmd and status debug file support xiubli
2020-11-05  2:37 ` [PATCH 1/2] ceph: add " xiubli
2020-11-10  7:51   ` Ilya Dryomov
2020-11-10  8:03     ` Xiubo Li
2020-11-05  2:37 ` [PATCH 2/2] ceph: add CEPH_IOC_GET_FS_CLIENT_IDS ioctl cmd support xiubli
2020-11-10  8:05   ` Ilya Dryomov
2020-11-10  8:54     ` Xiubo Li

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).