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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/11/10 16:05, Ilya Dryomov wrote:
On Thu, Nov 5, 2020 at 3:37 AM <xiubli@xxxxxxxxxx> wrote:
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.
belongs
Will fix it.

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





[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux