* [PATCH v2 0/2] ceph: add _IDS ioctl cmd and status debug file support
@ 2020-11-10 10:57 xiubli
2020-11-10 10:57 ` [PATCH v2 1/2] ceph: add " xiubli
2020-11-10 10:57 ` [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support xiubli
0 siblings, 2 replies; 10+ messages in thread
From: xiubli @ 2020-11-10 10:57 UTC (permalink / raw)
To: jlayton, idryomov; +Cc: zyan, pdonnell, ceph-devel, Xiubo Li
From: Xiubo Li <xiubli@redhat.com>
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(+)
--
2.27.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] ceph: add status debug file support
2020-11-10 10:57 [PATCH v2 0/2] ceph: add _IDS ioctl cmd and status debug file support xiubli
@ 2020-11-10 10:57 ` xiubli
2020-11-10 10:57 ` [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support xiubli
1 sibling, 0 replies; 10+ messages in thread
From: xiubli @ 2020-11-10 10:57 UTC (permalink / raw)
To: jlayton, idryomov; +Cc: 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 | 20 ++++++++++++++++++++
fs/ceph/super.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index 7a8fbe3e4751..4e498a492de4 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -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);
}
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.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 10:57 [PATCH v2 0/2] ceph: add _IDS ioctl cmd and status debug file support xiubli
2020-11-10 10:57 ` [PATCH v2 1/2] ceph: add " xiubli
@ 2020-11-10 10:57 ` xiubli
2020-11-10 12:24 ` Jeff Layton
1 sibling, 1 reply; 10+ messages in thread
From: xiubli @ 2020-11-10 10:57 UTC (permalink / raw)
To: jlayton, idryomov; +Cc: zyan, pdonnell, ceph-devel, Xiubo Li
From: Xiubo Li <xiubli@redhat.com>
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
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
fs/ceph/ioctl.c | 23 +++++++++++++++++++++++
fs/ceph/ioctl.h | 15 +++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 6e061bf62ad4..a4b69c1026ce 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -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;
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
index 51f7f1d39a94..9879d58854fb 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_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
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 10:57 ` [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support xiubli
@ 2020-11-10 12:24 ` Jeff Layton
2020-11-10 12:34 ` Xiubo Li
2020-11-10 13:25 ` Xiubo Li
0 siblings, 2 replies; 10+ messages in thread
From: Jeff Layton @ 2020-11-10 12:24 UTC (permalink / raw)
To: xiubli, idryomov; +Cc: zyan, pdonnell, ceph-devel
On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
>
> 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
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
> 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.
> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
> index 6e061bf62ad4..a4b69c1026ce 100644
> --- a/fs/ceph/ioctl.c
> +++ b/fs/ceph/ioctl.c
> @@ -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;
> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
> index 51f7f1d39a94..9879d58854fb 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_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
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 12:24 ` Jeff Layton
@ 2020-11-10 12:34 ` Xiubo Li
2020-11-10 13:25 ` Xiubo Li
1 sibling, 0 replies; 10+ messages in thread
From: Xiubo Li @ 2020-11-10 12:34 UTC (permalink / raw)
To: Jeff Layton, idryomov; +Cc: zyan, pdonnell, ceph-devel
On 2020/11/10 20:24, Jeff Layton wrote:
> On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> 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
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>> 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
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
> ...or you could even make one that gives you the same format as the
> dirnames in /sys/kernel/debug/ceph.
>
>> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
>> index 6e061bf62ad4..a4b69c1026ce 100644
>> --- a/fs/ceph/ioctl.c
>> +++ b/fs/ceph/ioctl.c
>> @@ -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;
>> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
>> index 51f7f1d39a94..9879d58854fb 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_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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 12:24 ` Jeff Layton
2020-11-10 12:34 ` Xiubo Li
@ 2020-11-10 13:25 ` Xiubo Li
2020-11-10 13:32 ` Jeff Layton
1 sibling, 1 reply; 10+ messages in thread
From: Xiubo Li @ 2020-11-10 13:25 UTC (permalink / raw)
To: Jeff Layton, idryomov; +Cc: zyan, pdonnell, ceph-devel
On 2020/11/10 20:24, Jeff Layton wrote:
> On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> 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
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>> 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
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"
??
> ...or you could even make one that gives you the same format as the
> dirnames in /sys/kernel/debug/ceph.
>
>> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
>> index 6e061bf62ad4..a4b69c1026ce 100644
>> --- a/fs/ceph/ioctl.c
>> +++ b/fs/ceph/ioctl.c
>> @@ -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;
>> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
>> index 51f7f1d39a94..9879d58854fb 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_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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 13:25 ` Xiubo Li
@ 2020-11-10 13:32 ` Jeff Layton
2020-11-10 13:34 ` Xiubo Li
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Layton @ 2020-11-10 13:32 UTC (permalink / raw)
To: Xiubo Li, idryomov; +Cc: zyan, pdonnell, ceph-devel
On Tue, 2020-11-10 at 21:25 +0800, Xiubo Li wrote:
> On 2020/11/10 20:24, Jeff Layton wrote:
> > On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
> > > From: Xiubo Li <xiubli@redhat.com>
> > >
> > > 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
> > > Signed-off-by: Xiubo Li <xiubli@redhat.com>
> > > ---
> > > 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
>
> 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"
>
> ??
>
What does "local" signify in these names?
>
>
> > ...or you could even make one that gives you the same format as the
> > dirnames in /sys/kernel/debug/ceph.
> >
> > > diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
> > > index 6e061bf62ad4..a4b69c1026ce 100644
> > > --- a/fs/ceph/ioctl.c
> > > +++ b/fs/ceph/ioctl.c
> > > @@ -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;
> > > diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
> > > index 51f7f1d39a94..9879d58854fb 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_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
>
>
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 13:32 ` Jeff Layton
@ 2020-11-10 13:34 ` Xiubo Li
2020-11-10 13:43 ` Jeff Layton
0 siblings, 1 reply; 10+ messages in thread
From: Xiubo Li @ 2020-11-10 13:34 UTC (permalink / raw)
To: Jeff Layton, idryomov; +Cc: zyan, pdonnell, ceph-devel
On 2020/11/10 21:32, Jeff Layton wrote:
> On Tue, 2020-11-10 at 21:25 +0800, Xiubo Li wrote:
>> On 2020/11/10 20:24, Jeff Layton wrote:
>>> On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>
>>>> 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
>>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>>>> ---
>>>> 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
>> 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"
>>
>> ??
>>
> 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
>>
>>> ...or you could even make one that gives you the same format as the
>>> dirnames in /sys/kernel/debug/ceph.
>>>
>>>> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
>>>> index 6e061bf62ad4..a4b69c1026ce 100644
>>>> --- a/fs/ceph/ioctl.c
>>>> +++ b/fs/ceph/ioctl.c
>>>> @@ -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;
>>>> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
>>>> index 51f7f1d39a94..9879d58854fb 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_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
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 13:34 ` Xiubo Li
@ 2020-11-10 13:43 ` Jeff Layton
2020-11-10 13:48 ` Xiubo Li
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Layton @ 2020-11-10 13:43 UTC (permalink / raw)
To: Xiubo Li, idryomov; +Cc: zyan, pdonnell, ceph-devel
On Tue, 2020-11-10 at 21:34 +0800, Xiubo Li wrote:
> On 2020/11/10 21:32, Jeff Layton wrote:
> > On Tue, 2020-11-10 at 21:25 +0800, Xiubo Li wrote:
> > > On 2020/11/10 20:24, Jeff Layton wrote:
> > > > On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
> > > > > From: Xiubo Li <xiubli@redhat.com>
> > > > >
> > > > > 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
> > > > > Signed-off-by: Xiubo Li <xiubli@redhat.com>
> > > > > ---
> > > > > 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
> > > 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"
> > >
> > > ??
> > >
> > 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
> > >
> > > > ...or you could even make one that gives you the same format as the
> > > > dirnames in /sys/kernel/debug/ceph.
> > > >
> > > > > diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
> > > > > index 6e061bf62ad4..a4b69c1026ce 100644
> > > > > --- a/fs/ceph/ioctl.c
> > > > > +++ b/fs/ceph/ioctl.c
> > > > > @@ -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;
> > > > > diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
> > > > > index 51f7f1d39a94..9879d58854fb 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_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
> > >
>
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support
2020-11-10 13:43 ` Jeff Layton
@ 2020-11-10 13:48 ` Xiubo Li
0 siblings, 0 replies; 10+ messages in thread
From: Xiubo Li @ 2020-11-10 13:48 UTC (permalink / raw)
To: Jeff Layton, idryomov; +Cc: zyan, pdonnell, ceph-devel
On 2020/11/10 21:43, Jeff Layton wrote:
> On Tue, 2020-11-10 at 21:34 +0800, Xiubo Li wrote:
>> On 2020/11/10 21:32, Jeff Layton wrote:
>>> On Tue, 2020-11-10 at 21:25 +0800, Xiubo Li wrote:
>>>> On 2020/11/10 20:24, Jeff Layton wrote:
>>>>> On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote:
>>>>>> From: Xiubo Li <xiubli@redhat.com>
>>>>>>
>>>>>> 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
>>>>>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>>>>>> ---
>>>>>> 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
>>>> 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"
>>>>
>>>> ??
>>>>
>>> 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.
Sure, will do.
BRs
> Thanks,
> Jeff
>
>>>>> ...or you could even make one that gives you the same format as the
>>>>> dirnames in /sys/kernel/debug/ceph.
>>>>>
>>>>>> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
>>>>>> index 6e061bf62ad4..a4b69c1026ce 100644
>>>>>> --- a/fs/ceph/ioctl.c
>>>>>> +++ b/fs/ceph/ioctl.c
>>>>>> @@ -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;
>>>>>> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
>>>>>> index 51f7f1d39a94..9879d58854fb 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_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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-11-10 13:48 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 10:57 [PATCH v2 0/2] ceph: add _IDS ioctl cmd and status debug file support xiubli
2020-11-10 10:57 ` [PATCH v2 1/2] ceph: add " xiubli
2020-11-10 10:57 ` [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support xiubli
2020-11-10 12:24 ` Jeff Layton
2020-11-10 12:34 ` Xiubo Li
2020-11-10 13:25 ` Xiubo Li
2020-11-10 13:32 ` Jeff Layton
2020-11-10 13:34 ` Xiubo Li
2020-11-10 13:43 ` Jeff Layton
2020-11-10 13:48 ` Xiubo Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.