Skip to contentSkip to conversation

ceph: add vxattrs to get ids and status debug file support

PATCH In review [email protected] 4 participants 7 messages Nov 11, 2020 – Nov 14, 2020 Ceph client

lore
Share & tools
lore
#0 lore raw

v4 cover ceph: add vxattrs to get ids and status debug file support

From: Xiubo Li <[email protected]>

V4:
- s/bloclisted/blocklisted/
- rename clientid to client_id
- rename clusterid to cluster_fsid
- rename "inst_str" to "instance"
- rename ceph_vxattrs to ceph_common_vxattrs

V3:
- switch ioctl to vxattr.

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.{cluster_fsid/client_id} vxattrs suppport

 fs/ceph/debugfs.c | 20 ++++++++++++++++++++
 fs/ceph/super.h   |  1 +
 fs/ceph/xattr.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)
Signature · 1 line
2.27.0
#1 lore raw

PATCH v4 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 blocklisted 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..66989c880adb 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, "instance: %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 v4 2/2 ceph: add ceph.{cluster_fsid/client_id} vxattrs suppport

In reply to [email protected]

From: Xiubo Li <[email protected]>

These two vxattrs will only exist in local client side, with which 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/48057

---
 fs/ceph/xattr.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
fs/ceph/xattr.c +42 -0
index 0fd05d3d4399..e89750a1f039 100644
@@ -304,6 +304,23 @@ static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
 				ci->i_snap_btime.tv_nsec);
 }
 
+static ssize_t ceph_vxattrcb_cluster_fsid(struct ceph_inode_info *ci,
+					  char *val, size_t size)
+{
+	struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+
+	return ceph_fmt_xattr(val, size, "%pU", &fsc->client->fsid);
+}
+
+static ssize_t ceph_vxattrcb_client_id(struct ceph_inode_info *ci,
+				       char *val, size_t size)
+{
+	struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+
+	return ceph_fmt_xattr(val, size, "client%lld",
+			      ceph_client_gid(fsc->client));
+}
+
 #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
 	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -407,6 +424,24 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {
 	{ .name = NULL, 0 }	/* Required table terminator */
 };
 
+static struct ceph_vxattr ceph_common_vxattrs[] = {
+	{
+		.name = "ceph.cluster_fsid",
+		.name_size = sizeof("ceph.cluster_fsid"),
+		.getxattr_cb = ceph_vxattrcb_cluster_fsid,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
+	{
+		.name = "ceph.client_id",
+		.name_size = sizeof("ceph.client_id"),
+		.getxattr_cb = ceph_vxattrcb_client_id,
+		.exists_cb = NULL,
+		.flags = VXATTR_FLAG_READONLY,
+	},
+	{ .name = NULL, 0 }	/* Required table terminator */
+};
+
 static struct ceph_vxattr *ceph_inode_vxattrs(struct inode *inode)
 {
 	if (S_ISDIR(inode->i_mode))
@@ -429,6 +464,13 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
 		}
 	}
 
+	vxattr = ceph_common_vxattrs;
+	while (vxattr->name) {
+		if (!strcmp(vxattr->name, name))
+			return vxattr;
+		vxattr++;
+	}
+
 	return NULL;
 }
 
Signature · 1 line
2.27.0
#3 lore raw

Re: [PATCH v4 2/2] ceph: add ceph.{cluster_fsid/client_id} vxattrs suppport

Quoted 27 lines · On Tue, Nov 10, 2020 at 5:29 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

These two vxattrs will only exist in local client side, with which 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/48057

---
 fs/ceph/xattr.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
fs/ceph/xattr.c +6 -0
index 0fd05d3d4399..e89750a1f039 100644
@@ -304,6 +304,23 @@ static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
                                ci->i_snap_btime.tv_nsec);
 }
 
+static ssize_t ceph_vxattrcb_cluster_fsid(struct ceph_inode_info *ci,
+                                         char *val, size_t size)
+{
+       struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+
+       return ceph_fmt_xattr(val, size, "%pU", &fsc->client->fsid);

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val, · line 322

Quoted 10 lines
fs/ceph/xattr.c +10 -0
+}
+
+static ssize_t ceph_vxattrcb_client_id(struct ceph_inode_info *ci,
+                                      char *val, size_t size)
+{
+       struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+
+       return ceph_fmt_xattr(val, size, "client%lld",
+                             ceph_client_gid(fsc->client));
+}

Let's just have this return the id number. The caller can concatenate that with "client" however they require. Otherwise, parsing it out is needlessly troublesome.

Quoted 5 lines
fs/ceph/xattr.c +0 -0
 #define CEPH_XATTR_NAME(_type, _name)  XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2) \
        XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -407,6 +424,24 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {
        { .name = NULL, 0 }     /* Required table terminator */

fs/ceph/xattr.c static struct ceph_vxattr ceph_file_vxattrs[] = { · line 434

Quoted 10 lines
fs/ceph/xattr.c +8 -0
 };
 
+static struct ceph_vxattr ceph_common_vxattrs[] = {
+       {
+               .name = "ceph.cluster_fsid",
+               .name_size = sizeof("ceph.cluster_fsid"),
+               .getxattr_cb = ceph_vxattrcb_cluster_fsid,
+               .exists_cb = NULL,
+               .flags = VXATTR_FLAG_READONLY,
+       },

I would prefer just "ceph.fsid".

Quoted 16 lines
fs/ceph/xattr.c +10 -0
+       {
+               .name = "ceph.client_id",
+               .name_size = sizeof("ceph.client_id"),
+               .getxattr_cb = ceph_vxattrcb_client_id,
+               .exists_cb = NULL,
+               .flags = VXATTR_FLAG_READONLY,
+       },
+       { .name = NULL, 0 }     /* Required table terminator */
+};
+
 static struct ceph_vxattr *ceph_inode_vxattrs(struct inode *inode)
 {
        if (S_ISDIR(inode->i_mode))
@@ -429,6 +464,13 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
                }
        }

fs/ceph/xattr.c static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode, · line 475

Quoted 10 lines
fs/ceph/xattr.c +7 -0
 
+       vxattr = ceph_common_vxattrs;
+       while (vxattr->name) {
+               if (!strcmp(vxattr->name, name))
+                       return vxattr;
+               vxattr++;
+       }
+
        return NULL;
 }

Please also be sure to wire up the same vxattrs in the userspace Client.

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Principal Software Engineer
Red Hat Sunnyvale, CA
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#4 lore raw

Re: [PATCH v4 2/2] ceph: add ceph.{cluster_fsid/client_id} vxattrs suppport

Quoted 34 lines · Patrick Donnelly
Quoted 33 lines · On Tue, Nov 10, 2020 at 5:29 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

These two vxattrs will only exist in local client side, with which 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/48057

---
 fs/ceph/xattr.c | 42 ++++++++++++++++++++++++++++++++++++++++++

 1 file changed, 42 insertions(+)
fs/ceph/xattr.c +12 -0
index 0fd05d3d4399..e89750a1f039 100644
@@ -304,6 +304,23 @@ static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
                                 ci->i_snap_btime.tv_nsec);
  }
 
+static ssize_t ceph_vxattrcb_cluster_fsid(struct ceph_inode_info *ci,
+                                         char *val, size_t size)
+{
+       struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+
+       return ceph_fmt_xattr(val, size, "%pU", &fsc->client->fsid);
+}
+
+static ssize_t ceph_vxattrcb_client_id(struct ceph_inode_info *ci,
+                                      char *val, size_t size)
+{
+       struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
Quoted 9 lines

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val, · line 322

Quoted 4 lines
fs/ceph/xattr.c +4 -0
+
+       return ceph_fmt_xattr(val, size, "client%lld",
+                             ceph_client_gid(fsc->client));
+}

Let's just have this return the id number. The caller can concatenate that with "client" however they require. Otherwise, parsing it out is needlessly troublesome.

That does seem nicer, but it would be inconsistent with the existing rbd attributes. Ilya, would you object?

Quoted 7 lines
Quoted 7 lines
fs/ceph/xattr.c +0 -0
  #define CEPH_XATTR_NAME(_type, _name)  XATTR_CEPH_PREFIX #_type "." #_name
  #define CEPH_XATTR_NAME2(_type, _name, _name2) \

        XATTR_CEPH_PREFIX #_type "." #_name "." #_name2

fs/ceph/xattr.c +0 -0
@@ -407,6 +424,24 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {

        { .name = NULL, 0 } /* Required table terminator */
 };

Quoted 11 lines

fs/ceph/xattr.c static struct ceph_vxattr ceph_file_vxattrs[] = { · line 434

Quoted 8 lines
fs/ceph/xattr.c +8 -0
+static struct ceph_vxattr ceph_common_vxattrs[] = {
+       {
+               .name = "ceph.cluster_fsid",
+               .name_size = sizeof("ceph.cluster_fsid"),
+               .getxattr_cb = ceph_vxattrcb_cluster_fsid,
+               .exists_cb = NULL,
+               .flags = VXATTR_FLAG_READONLY,
+       },

I would prefer just "ceph.fsid".

Ilya suggested this name to match existing rbd attributes.

Quoted 30 lines
Quoted 16 lines
fs/ceph/xattr.c +10 -0
+       {
+               .name = "ceph.client_id",
+               .name_size = sizeof("ceph.client_id"),
+               .getxattr_cb = ceph_vxattrcb_client_id,
+               .exists_cb = NULL,
+               .flags = VXATTR_FLAG_READONLY,
+       },
+       { .name = NULL, 0 }     /* Required table terminator */
+};
+

 static struct ceph_vxattr *ceph_inode_vxattrs(struct inode *inode) {
        if (S_ISDIR(inode->i_mode))

fs/ceph/xattr.c +0 -0
@@ -429,6 +464,13 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
                 }
         }

fs/ceph/xattr.c static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode, · line 475

Quoted 10 lines
fs/ceph/xattr.c +7 -0
 
+       vxattr = ceph_common_vxattrs;
+       while (vxattr->name) {
+               if (!strcmp(vxattr->name, name))
+                       return vxattr;
+               vxattr++;
+       }
+
         return NULL;
  }

Please also be sure to wire up the same vxattrs in the userspace Client.

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

Re: [PATCH v4 2/2] ceph: add ceph.{cluster_fsid/client_id} vxattrs suppport

Quoted 46 lines · Jeff Layton
Quoted 34 lines · Patrick Donnelly
Quoted 33 lines · On Tue, Nov 10, 2020 at 5:29 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

These two vxattrs will only exist in local client side, with which 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/48057

---
 fs/ceph/xattr.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
fs/ceph/xattr.c +12 -0
index 0fd05d3d4399..e89750a1f039 100644
@@ -304,6 +304,23 @@ static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
                                ci->i_snap_btime.tv_nsec);
 }
 
+static ssize_t ceph_vxattrcb_cluster_fsid(struct ceph_inode_info *ci,
+                                         char *val, size_t size)
+{
+       struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+
+       return ceph_fmt_xattr(val, size, "%pU", &fsc->client->fsid);
+}
+
+static ssize_t ceph_vxattrcb_client_id(struct ceph_inode_info *ci,
+                                      char *val, size_t size)
+{
+       struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
Quoted 9 lines

fs/ceph/xattr.c static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val, · line 322

Quoted 4 lines
fs/ceph/xattr.c +4 -0
+
+       return ceph_fmt_xattr(val, size, "client%lld",
+                             ceph_client_gid(fsc->client));
+}

Let's just have this return the id number. The caller can concatenate that with "client" however they require. Otherwise, parsing it out is needlessly troublesome.

Quoted 2 lines

That does seem nicer, but it would be inconsistent with the existing rbd attributes. Ilya, would you object?

I'm not married to it, but staying consistent would be good. Yes, it concatenates with "client" and yes, without a dot, but the kernel client has been doing that for a very long time. This behaviour actually predates the rbd attributes I mentioned.

Quoted 20 lines
Quoted 8 lines
Quoted 8 lines
fs/ceph/xattr.c +0 -0
 #define CEPH_XATTR_NAME(_type, _name)  XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2) \
        XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -407,6 +424,24 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {
        { .name = NULL, 0 }     /* Required table terminator */
 };
 
Quoted 11 lines

fs/ceph/xattr.c static struct ceph_vxattr ceph_file_vxattrs[] = { · line 434

Quoted 8 lines
fs/ceph/xattr.c +8 -0
+static struct ceph_vxattr ceph_common_vxattrs[] = {
+       {
+               .name = "ceph.cluster_fsid",
+               .name_size = sizeof("ceph.cluster_fsid"),
+               .getxattr_cb = ceph_vxattrcb_cluster_fsid,
+               .exists_cb = NULL,
+               .flags = VXATTR_FLAG_READONLY,
+       },

I would prefer just "ceph.fsid".

Quoted 1 line

Ilya suggested this name to match existing rbd attributes.

I think "cluster" is particularly important here because people might mistake it for a filesystem identifier.

Thanks,

Ilya

author
#6 lore raw

Re: [PATCH v4 2/2] ceph: add ceph.{cluster_fsid/client_id} vxattrs suppport

In reply to Patrick Donnelly
Quoted 1 line · Patrick Donnelly

On Tue, Nov 10, 2020 at 5:29 PM <[email protected]> wrote:

[...]

Quoted 7 lines
Quoted 7 lines
  static struct ceph_vxattr *ceph_inode_vxattrs(struct inode *inode)
  {
         if (S_ISDIR(inode->i_mode))
(quoted diff) +0 -0
@@ -429,6 +464,13 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
                 }
         }
 
Quoted 12 lines

fs/ceph/xattr.c static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode, · line 475

Quoted 9 lines
fs/ceph/xattr.c +7 -0
+       vxattr = ceph_common_vxattrs;
+       while (vxattr->name) {
+               if (!strcmp(vxattr->name, name))
+                       return vxattr;
+               vxattr++;
+       }
+
         return NULL;
  }

Please also be sure to wire up the same vxattrs in the userspace Client.

Sure, will do.

Thanks.