Skip to contentSkip to conversation

libceph: Allocate larger oid buffer in request msgs

PATCH In review Stratos Psomadakis 2 participants 2 messages Nov 10, 2011 – Nov 11, 2011 Ceph common code (libceph)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libceph: Allocate larger oid buffer in request msgs

ceph_osd_request struct allocates a 40-byte buffer for object names. RBD image names can be up to 96 chars long (100 with the .rbd suffix), which results in the object name for the image being truncated, and a subsequent map failure.

Increase the oid buffer in request messages, in order to avoid the truncation.

---

This is a quick fix, until #1701 is sorted out. I'm not sure if this is the best way to do it.

 include/linux/ceph/osd_client.h |    8 +++++++-
 net/ceph/osd_client.c           |    2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
include/linux/ceph/osd_client.h +7 -1
index f88eacb..7c05ac2 100644
@@ -10,6 +10,12 @@
 #include "osdmap.h"
 #include "messenger.h"
 
+/* 
+ * Maximum object name size 
+ * (must be at least as big as RBD_MAX_MD_NAME_LEN -- currently 100) 
+ */
+#define MAX_OBJ_NAME_SIZE 100
+
 struct ceph_msg;
 struct ceph_snap_context;
 struct ceph_osd_request;
@@ -75,7 +81,7 @@ struct ceph_osd_request {
 	struct inode *r_inode;         	      /* for use by callbacks */
 	void *r_priv;			      /* ditto */
 
-	char              r_oid[40];          /* object name */
+	char              r_oid[MAX_OBJ_NAME_SIZE];          /* object name */
 	int               r_oid_len;
 	unsigned long     r_stamp;            /* send OR check time */
 
net/ceph/osd_client.c +1 -1
index 733e4600..f4f3f58 100644
@@ -244,7 +244,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
 		ceph_pagelist_init(req->r_trail);
 	}
 	/* create request message; allow space for oid */
-	msg_size += 40;
+	msg_size += MAX_OBJ_NAME_SIZE;
 	if (snapc)
 		msg_size += sizeof(u64) * snapc->num_snaps;
 	if (use_mempool)
Signature · 1 line
1.7.2.5
#1 lore raw

Hmm, I wish we could just make r_oid a char * and dynamically allocate the name. Unfortunately that would significantly complicate things because we need to allocate osd requests in the writeback path during reclaim and that'd involve a fallback memory pool or something similar.

A larger fixed-sized buffer seems like the way to go for now.

I'll stick this in the queue, tho it'll probably get adjusted when the rbd constants get cleaned up.

Thanks!
sage

Quoted 66 lines · Stratos Psomadakis

ceph_osd_request struct allocates a 40-byte buffer for object names. RBD image names can be up to 96 chars long (100 with the .rbd suffix), which results in the object name for the image being truncated, and a subsequent map failure.

Increase the oid buffer in request messages, in order to avoid the truncation.

---

This is a quick fix, until #1701 is sorted out. I'm not sure if this is the best way to do it.

 include/linux/ceph/osd_client.h |    8 +++++++-
 net/ceph/osd_client.c           |    2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
include/linux/ceph/osd_client.h +7 -1
index f88eacb..7c05ac2 100644
@@ -10,6 +10,12 @@
 #include "osdmap.h"
 #include "messenger.h"
 
+/* 
+ * Maximum object name size 
+ * (must be at least as big as RBD_MAX_MD_NAME_LEN -- currently 100) 
+ */
+#define MAX_OBJ_NAME_SIZE 100
+
 struct ceph_msg;
 struct ceph_snap_context;
 struct ceph_osd_request;
@@ -75,7 +81,7 @@ struct ceph_osd_request {
 	struct inode *r_inode;         	      /* for use by callbacks */
 	void *r_priv;			      /* ditto */
 
-	char              r_oid[40];          /* object name */
+	char              r_oid[MAX_OBJ_NAME_SIZE];          /* object name */
 	int               r_oid_len;
 	unsigned long     r_stamp;            /* send OR check time */
 
net/ceph/osd_client.c +1 -1
index 733e4600..f4f3f58 100644
@@ -244,7 +244,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
 		ceph_pagelist_init(req->r_trail);
 	}
 	/* create request message; allow space for oid */
-	msg_size += 40;
+	msg_size += MAX_OBJ_NAME_SIZE;
 	if (snapc)
 		msg_size += sizeof(u64) * snapc->num_snaps;
 	if (use_mempool)
Signature · 5 lines
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html