Skip to contentSkip to conversation

ceph: add _IDS ioctl cmd and status debug file support

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

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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

From: Xiubo Li <[email protected]>

V2:
- some typo fixings
- switch to use ceph_client_gid() and ceph_client_addr() helpers
- for ioctl cmd will return in text for cluster/client ids

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

 fs/ceph/debugfs.c | 20 ++++++++++++++++++++
 fs/ceph/ioctl.c   | 23 +++++++++++++++++++++++
 fs/ceph/ioctl.h   | 15 +++++++++++++++
 fs/ceph/super.h   |  1 +
 4 files changed, 59 insertions(+)
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 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 | 20 ++++++++++++++++++++
 fs/ceph/super.h   |  1 +
 2 files changed, 21 insertions(+)
fs/ceph/debugfs.c +20 -0
index 7a8fbe3e4751..4e498a492de4 100644
@@ -304,11 +304,25 @@ static int mds_sessions_show(struct seq_file *s, void *ptr)
 	return 0;
 }
 
+static int status_show(struct seq_file *s, void *p)
+{
+	struct ceph_fs_client *fsc = s->private;
+	struct ceph_entity_inst *inst = &fsc->client->msgr.inst;
+	struct ceph_entity_addr *client_addr = ceph_client_addr(fsc->client);
+
+	seq_printf(s, "inst_str: %s.%lld %s/%u\n", ENTITY_NAME(inst->name),
+		   ceph_pr_addr(client_addr), le32_to_cpu(client_addr->nonce));
+	seq_printf(s, "blocklisted: %s\n", fsc->blocklisted ? "true" : "false");
+
+	return 0;
+}
+
 DEFINE_SHOW_ATTRIBUTE(mdsmap);
 DEFINE_SHOW_ATTRIBUTE(mdsc);
 DEFINE_SHOW_ATTRIBUTE(caps);
 DEFINE_SHOW_ATTRIBUTE(mds_sessions);
 DEFINE_SHOW_ATTRIBUTE(metric);
+DEFINE_SHOW_ATTRIBUTE(status);
 
 
 /*
@@ -394,6 +408,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.27.0
#2 lore raw

PATCH v2 2/2 ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support

In reply to [email protected]

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

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

---
 fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
 fs/ceph/ioctl.h | 15 +++++++++++++++
 2 files changed, 38 insertions(+)
fs/ceph/ioctl.c +23 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
 	return 0;
 }
 
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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 +310,8 @@ 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_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);
 	}
 
 	return -ENOTTY;
fs/ceph/ioctl.h +15 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
  */
 #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+
 #endif
Signature · 1 line
2.27.0
#3 lore raw

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

Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
 fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
 fs/ceph/ioctl.h | 15 +++++++++++++++

 2 files changed, 38 insertions(+)

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

ceph.clusterid
ceph.clientid

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 74 lines
fs/ceph/ioctl.c +0 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
  	return 0;
  }

fs/ceph/ioctl.c +21 -0
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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);

fs/ceph/ioctl.c +0 -0
@@ -289,6 +310,8 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

  case CEPH_IOC_SYNCIO:
  return ceph_ioctl_syncio(file);

fs/ceph/ioctl.c +2 -0
+	case CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);

  }

  return -ENOTTY;

fs/ceph/ioctl.h +0 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
   */
  #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)

fs/ceph/ioctl.h +15 -0
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+

 #endif

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

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

Quoted 14 lines · Jeff Layton
Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
  fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
  fs/ceph/ioctl.h | 15 +++++++++++++++
  2 files changed, 38 insertions(+)
Quoted 7 lines

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

ceph.clusterid
ceph.clientid

Yeah, it is. I was trying to call the ioctl in python which is a little complicated than the vxattrs method.

The vxattrs one sounds a best approach for me, let's try this one.

Thanks

BRs

Quoted 77 lines

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 74 lines
fs/ceph/ioctl.c +23 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
  	return 0;
  }
 
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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 +310,8 @@ 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_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);

  }

  return -ENOTTY;

fs/ceph/ioctl.h +15 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
   */
  #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
 
 
 
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+
  #endif
author
#5 lore raw

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

In reply to Jeff Layton
Quoted 14 lines · Jeff Layton
Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
  fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
  fs/ceph/ioctl.h | 15 +++++++++++++++
  2 files changed, 38 insertions(+)
Quoted 7 lines

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

ceph.clusterid
ceph.clientid

How about :

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clusterid file # file: file ceph.local.clusterid="6ff21dc9-36b0-45a9-bec2-75aeaf0414cf"

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clientid file # file: file
ceph.local.clientid="client4360"

??

Quoted 77 lines

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 74 lines
fs/ceph/ioctl.c +23 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
  	return 0;
  }
 
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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 +310,8 @@ 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_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);

  }

  return -ENOTTY;

fs/ceph/ioctl.h +15 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
   */
  #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
 
 
 
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+
  #endif
#6 lore raw

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

Quoted 29 lines · Xiubo Li
Quoted 14 lines · Jeff Layton
Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
  fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
  fs/ceph/ioctl.h | 15 +++++++++++++++

  2 files changed, 38 insertions(+)
Quoted 7 lines

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

     ceph.clusterid
     ceph.clientid

How about :

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clusterid file # file: file ceph.local.clusterid="6ff21dc9-36b0-45a9-bec2-75aeaf0414cf"

Quoted 6 lines

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clientid file # file: file
ceph.local.clientid="client4360"

??

What does "local" signify in these names?

Quoted 93 lines
Quoted 91 lines

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 86 lines
fs/ceph/ioctl.c +0 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
   	return 0;
   }

fs/ceph/ioctl.c +21 -0
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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);

fs/ceph/ioctl.c +0 -0
@@ -289,6 +310,8 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

   case CEPH_IOC_SYNCIO:
   return ceph_ioctl_syncio(file);

fs/ceph/ioctl.c +2 -0
+	case CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);

   }

   return -ENOTTY;

fs/ceph/ioctl.h +0 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
    */
   #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)

fs/ceph/ioctl.h +15 -0
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+

  #endif

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

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

Quoted 29 lines · Jeff Layton
Quoted 28 lines · Xiubo Li
Quoted 14 lines · Jeff Layton
Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
   fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
   fs/ceph/ioctl.h | 15 +++++++++++++++
   2 files changed, 38 insertions(+)
Quoted 7 lines

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

     ceph.clusterid
     ceph.clientid

How about :

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clusterid file # file: file ceph.local.clusterid="6ff21dc9-36b0-45a9-bec2-75aeaf0414cf"

Quoted 7 lines
Quoted 6 lines

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clientid file # file: file
ceph.local.clientid="client4360"

??

What does "local" signify in these names?

Which means only existing in local client side. If this make no sense I will remove them.

Thanks

BRs

Quoted 91 lines
Quoted 91 lines
Quoted 90 lines

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 86 lines
fs/ceph/ioctl.c +21 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
   	return 0;
   }
 
 
 
 
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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);

fs/ceph/ioctl.c +2 -0
@@ -289,6 +310,8 @@ 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_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);
   	}
 
 
 
 
 
 
 
   	return -ENOTTY;
fs/ceph/ioctl.h +15 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
    */
   #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
 
 
 
 
 
 
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+
   #endif
#8 lore raw

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

Quoted 36 lines · Xiubo Li
Quoted 35 lines · Jeff Layton
Quoted 34 lines · Xiubo Li
Quoted 14 lines · Jeff Layton
Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
   fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
   fs/ceph/ioctl.h | 15 +++++++++++++++

   2 files changed, 38 insertions(+)
Quoted 7 lines

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

      ceph.clusterid
      ceph.clientid

How about :

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clusterid file # file: file ceph.local.clusterid="6ff21dc9-36b0-45a9-bec2-75aeaf0414cf"

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clientid file # file: file
ceph.local.clientid="client4360"

??

Quoted 9 lines
Quoted 1 line

What does "local" signify in these names?

Which means only existing in local client side. If this make no sense I will remove them.

Thanks

BRs

Yeah, I don't think it helps anything. I'd just remove that.

Thanks,
Jeff

Quoted 104 lines
Quoted 103 lines
Quoted 103 lines
Quoted 102 lines

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 98 lines
fs/ceph/ioctl.c +0 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
    	return 0;
    }

fs/ceph/ioctl.c +21 -0
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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);

fs/ceph/ioctl.c +0 -0
@@ -289,6 +310,8 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

    case CEPH_IOC_SYNCIO:
    return ceph_ioctl_syncio(file);

fs/ceph/ioctl.c +2 -0
+	case CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);

    }

    return -ENOTTY;

fs/ceph/ioctl.h +0 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
     */
    #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)

fs/ceph/ioctl.h +15 -0
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+

   #endif

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

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

Quoted 38 lines · Jeff Layton
Quoted 37 lines · Xiubo Li
Quoted 36 lines · Jeff Layton
Quoted 28 lines · Xiubo Li
Quoted 14 lines · Jeff Layton
Quoted 6 lines · On Tue, 2020-11-10 at 18:57 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

This ioctl will return the cluster and client ids back to userspace. With this we can easily know which mountpoint the file belongs to and also they can help locate the debugfs path quickly.

Quoted 7 lines

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

---
    fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
    fs/ceph/ioctl.h | 15 +++++++++++++++
    2 files changed, 38 insertions(+)
Quoted 7 lines

I know I opened this bug and suggested an ioctl for this, but I think that this may be better presented as new vxattrs. Driving ioctls from scripts is difficult (in particular). An xattr is easier for them to deal with. Maybe:

      ceph.clusterid
      ceph.clientid

How about :

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clusterid file # file: file ceph.local.clusterid="6ff21dc9-36b0-45a9-bec2-75aeaf0414cf"

Quoted 6 lines

[root@lxbceph1 kcephfs]# getfattr -n ceph.local.clientid file # file: file
ceph.local.clientid="client4360"

??

What does "local" signify in these names?

Quoted 8 lines
Quoted 7 lines

Which means only existing in local client side. If this make no sense I will remove them.

Thanks

BRs

Yeah, I don't think it helps anything. I'd just remove that.

Sure, will do.

BRs

Quoted 104 lines

Thanks,
Jeff

Quoted 101 lines
Quoted 101 lines
Quoted 101 lines
Quoted 101 lines

...or you could even make one that gives you the same format as the dirnames in /sys/kernel/debug/ceph.

Quoted 98 lines
fs/ceph/ioctl.c +23 -0
index 6e061bf62ad4..a4b69c1026ce 100644
@@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file)
    	return 0;
    }
 
 
 
 
 
 
 
+/*
+ * Return the cluster and client ids
+ */
+static long ceph_ioctl_get_fs_ids(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 cluster_client_ids ids;
+
+	snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU",
+		 &fsc->client->fsid);
+	snprintf(ids.client_id, sizeof(ids.client_id), "client%lld",
+		 ceph_client_gid(fsc->client));
+
+	/* 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 +310,8 @@ 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_CLUSTER_AND_CLIENT_IDS:
+		return ceph_ioctl_get_fs_ids(file, (void __user *)arg);
    	}
 
 
 
 
 
 
 
 
 
 
    	return -ENOTTY;
fs/ceph/ioctl.h +15 -0
index 51f7f1d39a94..9879d58854fb 100644
@@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc {
     */
    #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
 
 
 
 
 
 
 
 
 
 
+/*
+ * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids
+ *
+ * This ioctl will return the cluster and client ids back to user space.
+ * With this we can easily know which mountpoint the file belongs to and
+ * also they can help locate the debugfs path quickly.
+ */
+
+struct cluster_client_ids {
+	char cluster_id[40];
+	char client_id[24];
+};
+#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \
+					struct cluster_client_ids)
+
    #endif