From: Xiubo Li <xiubli@xxxxxxxxxx> 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@xxxxxxxxxx> --- 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