Skip to contentSkip to conversation

ceph: Add pg_name filed in struct ceph_ioctl_dataloc.

PATCH In review majianpeng 2 participants 3 messages Aug 5, 2013 Ceph client

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 2/2 ceph: Add pg_name filed in struct ceph_ioctl_dataloc.

As the 'ceph help' print, it will print pgs.But now it can't. So we add this.There are two type name of pg, temp and stable. Because the command 'ceph pg dump' print temp name,so we also print the temp name of pg.

---
 fs/ceph/ioctl.c | 10 +++++++++-
 fs/ceph/ioctl.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
fs/ceph/ioctl.c +9 -1
index e0b4ef3..1d0f24c 100644
@@ -209,9 +209,17 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
 	snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
 		 ceph_ino(inode), dl.object_no);
 
+	r = ceph_calc_ceph_temp_pg(&pgid, dl.object_name, osdc->osdmap,
+					ceph_file_layout_pg_pool(ci->i_layout));
+	if (r < 0) {
+		down_read(&osdc->map_sem);
+		return r;
+	}
+	snprintf(dl.pg_name, sizeof(dl.pg_name), "%llx.%08x",
+		 pgid.pool, pgid.seed);
+
 	ceph_calc_ceph_pg(&pgid, dl.object_name, osdc->osdmap,
 		ceph_file_layout_pg_pool(ci->i_layout));
-
 	dl.osd = ceph_calc_pg_primary(osdc->osdmap, pgid);
 	if (dl.osd >= 0) {
 		struct ceph_entity_addr *a =
fs/ceph/ioctl.h +1 -0
index c77028a..618eef2 100644
@@ -58,6 +58,7 @@ struct ceph_ioctl_dataloc {
 	__u64 object_no;             /* out: object # */
 	__u64 object_size;           /* out: object size */
 	char object_name[64];        /* out: object name */
+	char pg_name[32];	     /* out: pg name*/
 	__u64 block_offset;          /* out: offset in block */
 	__u64 block_size;            /* out: block length */
 	__s64 osd;                   /* out: osd # */
Signature · 5 lines
1.8.3.rc1.44.gb387c77


Thanks!
Jianpeng Ma
#1 lore raw
Quoted 4 lines · majianpeng

As the 'ceph help' print, it will print pgs.But now it can't. So we add this.There are two type name of pg, temp and stable. Because the command 'ceph pg dump' print temp name,so we also print the temp name of pg.

Unfortunately we can't modify the ioctl structure like this without breaking the kernel/userspace ABI (a big no-no). The usual way around that is to make a new ioctl (like CEPH_IOC_GET_DATALOC2) and a new structure (struct ceph_ioctl_dataloc2) with the additional fields.

What is this going to be used for? You can get the full info from the montior with the 'ceph osd map <pool name> <object name> --format=json'. Does it need to come from the kernel this way?

Assuming we do want to go down this path, I would change a few things:

Quoted 13 lines
---
 fs/ceph/ioctl.c | 10 +++++++++-
 fs/ceph/ioctl.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
fs/ceph/ioctl.c +0 -0
index e0b4ef3..1d0f24c 100644
@@ -209,9 +209,17 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
 	snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",

fs/ceph/ioctl.c static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) · line 219

Quoted 10 lines
fs/ceph/ioctl.c +8 -0
 		 ceph_ino(inode), dl.object_no);
 
+	r = ceph_calc_ceph_temp_pg(&pgid, dl.object_name, osdc->osdmap,
+					ceph_file_layout_pg_pool(ci->i_layout));
+	if (r < 0) {
+		down_read(&osdc->map_sem);
+		return r;
+	}
+	snprintf(dl.pg_name, sizeof(dl.pg_name), "%llx.%08x",
+		 pgid.pool, pgid.seed);

The pg name formatting is "%lld.%x", if we want this to match with the pg names used throughout the rest of the code. But it sounds like you're actually after the raw hash seed, though, in which case I would drop the string and instead do

fs/ceph/ioctl.c struct ceph_ioctl_dataloc { · line 61

Quoted 5 lines
fs/ceph/ioctl.c +1 -0
@@ -58,6 +58,7 @@ struct ceph_ioctl_dataloc {
 	__u64 object_no;             /* out: object # */
 	__u64 object_size;           /* out: object size */
 	char object_name[64];        /* out: object name */
+	char pg_name[32];	     /* out: pg name*/
	__u64 pg_raw_seed;           /* out: placement seed */
	__u64 pg_num;                /* out: pg number */
	__u64 pg_pool;               /* out: pool id */

so that you get the raw value (which e.g. goes in the request) as well as which pg that maps to and the pool id.

sage

Quoted 9 lines
fs/ceph/ioctl.c +0 -0
 	__u64 block_offset;          /* out: offset in block */
 	__u64 block_size;            /* out: block length */
 	__s64 osd;                   /* out: osd # */
Signature · 5 lines
1.8.3.rc1.44.gb387c77


Thanks!
Jianpeng MaN????y????b?????v?????{.n??????z??ay????????j???f????????????????:+v??????????zZ+??????"?!?
author
#2 lore raw
Quoted 6 lines · majianpeng
Quoted 4 lines

As the 'ceph help' print, it will print pgs.But now it can't. So we add this.There are two type name of pg, temp and stable. Because the command 'ceph pg dump' print temp name,so we also print the temp name of pg.

Quoted 9 lines

Unfortunately we can't modify the ioctl structure like this without breaking the kernel/userspace ABI (a big no-no). The usual way around that is to make a new ioctl (like CEPH_IOC_GET_DATALOC2) and a new structure (struct ceph_ioctl_dataloc2) with the additional fields.

What is this going to be used for? You can get the full info from the montior with the 'ceph osd map <pool name> <object name> --format=json'. Does it need to come from the kernel this way?

I only want to print the pgid when print other infos using cephfs map or sho_location. I'll dig into the implementation of 'ceph osd map <pool name> <object name> --format=json'.

Thanks!
Jianpeng Ma