Skip to contentSkip to conversation

libceph: improve packing in struct ceph_osd_req_op

PATCH In review Alex Elder 2 participants 2 messages Feb 16, 2013 Ceph common code (libceph)

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 libceph: improve packing in struct ceph_osd_req_op

The layout of struct ceph_osd_req_op leaves lots of holes. Rearranging things a little for better field alignment reduces the size by a third.

---
 include/linux/ceph/osd_client.h |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/include/linux/ceph/osd_client.h
index 69287cc..82bf633 100644

include/linux/ceph/osd_client.h +8 -7
@@ -157,6 +157,7 @@ struct ceph_osd_client {
 
 struct ceph_osd_req_op {
 	u16 op;           /* CEPH_OSD_OP_* */
+	u32 payload_len;
 	union {
 		struct {
 			u64 offset, length;
@@ -165,23 +166,24 @@ struct ceph_osd_req_op {
 		} extent;
 		struct {
 			const char *name;
-			u32 name_len;
 			const char  *val;
+			u32 name_len;
 			u32 value_len;
 			__u8 cmp_op;       /* CEPH_OSD_CMPXATTR_OP_* */
 			__u8 cmp_mode;     /* CEPH_OSD_CMPXATTR_MODE_* */
 		} xattr;
 		struct {
 			const char *class_name;
-			__u8 class_len;
 			const char *method_name;
-			__u8 method_len;
-			__u8 argc;
 			const char *indata;
 			u32 indata_len;
+			__u8 class_len;
+			__u8 method_len;
+			__u8 argc;
 		} cls;
 		struct {
-			u64 cookie, count;
+			u64 cookie;
+			u64 count;
 		} pgls;
 	        struct {
 		        u64 snapid;
@@ -189,12 +191,11 @@ struct ceph_osd_req_op {
 		struct {
 			u64 cookie;
 			u64 ver;
-			__u8 flag;
 			u32 prot_ver;
 			u32 timeout;
+			__u8 flag;
 		} watch;
 	};
-	u32 payload_len;
 };
 
 extern int ceph_osdc_init(struct ceph_osd_client *osdc,
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 67 lines · Alex Elder

The layout of struct ceph_osd_req_op leaves lots of holes. Rearranging things a little for better field alignment reduces the size by a third.

---
  include/linux/ceph/osd_client.h |   15 ++++++++-------
  1 file changed, 8 insertions(+), 7 deletions(-)
include/linux/ceph/osd_client.h +8 -7
index 69287cc..82bf633 100644
@@ -157,6 +157,7 @@ struct ceph_osd_client {
 
  struct ceph_osd_req_op {
  	u16 op;           /* CEPH_OSD_OP_* */
+	u32 payload_len;
  	union {
  		struct {
  			u64 offset, length;
@@ -165,23 +166,24 @@ struct ceph_osd_req_op {
  		} extent;
  		struct {
  			const char *name;
-			u32 name_len;
  			const char  *val;
+			u32 name_len;
  			u32 value_len;
  			__u8 cmp_op;       /* CEPH_OSD_CMPXATTR_OP_* */
  			__u8 cmp_mode;     /* CEPH_OSD_CMPXATTR_MODE_* */
  		} xattr;
  		struct {
  			const char *class_name;
-			__u8 class_len;
  			const char *method_name;
-			__u8 method_len;
-			__u8 argc;
  			const char *indata;
  			u32 indata_len;
+			__u8 class_len;
+			__u8 method_len;
+			__u8 argc;
  		} cls;
  		struct {
-			u64 cookie, count;
+			u64 cookie;
+			u64 count;
  		} pgls;
  	        struct {
  		        u64 snapid;
@@ -189,12 +191,11 @@ struct ceph_osd_req_op {
  		struct {
  			u64 cookie;
  			u64 ver;
-			__u8 flag;
  			u32 prot_ver;
  			u32 timeout;
+			__u8 flag;
  		} watch;
  	};
-	u32 payload_len;
  };
 
  extern int ceph_osdc_init(struct ceph_osd_client *osdc,