[sheepdog] [PATCH v2 10/11] change copy type from uint32_t to uint8_t

Liu Yuan namei.unix at gmail.com
Thu Sep 26 09:25:47 CEST 2013


We can't add more field into sd_req.obj. But we can make use of 'uint32_t copies'
which effectively we only use its first 8 bytes. By squeezing copy_policy into
this room, we won't change the layout of sd_req.

For now copy_policy is just used by sheep and dog, so no need to change the QEMU
code at all.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 include/sheepdog_proto.h |   21 ++++++++++++++-------
 sheep/sheep_priv.h       |    2 +-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 3dd6936..04399bc 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -125,29 +125,34 @@ struct sd_req {
 		struct {
 			uint64_t	oid;
 			uint64_t	cow_oid;
-			uint32_t	copies;
+			uint8_t		copies;
+			uint8_t		copy_policy;
+			uint8_t		reserved[2];
 			uint32_t	tgt_epoch;
 			uint64_t	offset;
 		} obj;
 		struct {
 			uint64_t	vdi_size;
 			uint32_t	base_vdi_id;
-			uint32_t	copies;
-			uint32_t	snapid;
+			uint8_t		copies;
 			uint8_t		copy_policy;
+			uint8_t		reserved[2];
+			uint32_t	snapid;
 		} vdi;
 
 		/* sheepdog-internal */
 		struct {
 			uint64_t	oid;
 			uint64_t	ctime;
-			uint32_t	copies;
+			uint8_t		copies;
+			uint8_t		copy_policy;
+			uint8_t		reserved[2];
 			uint32_t	tag;
 		} cluster;
 		struct {
 			uint32_t	old_vid;
 			uint32_t	new_vid;
-			uint32_t	copies;
+			uint8_t		copies;
 			uint8_t		set_bitmap; /* 0 means false */
 						    /* others mean true */
 			uint8_t		copy_policy;
@@ -168,7 +173,8 @@ struct sd_rsp {
 		uint32_t        result;
 		struct {
 			uint32_t	__pad;
-			uint32_t	copies;
+			uint8_t		copies;
+			uint8_t		reserved[3];
 			uint64_t	offset;
 		} obj;
 		struct {
@@ -176,7 +182,8 @@ struct sd_rsp {
 			uint32_t	rsvd;
 			uint32_t	vdi_id;
 			uint32_t	attr_id;
-			uint32_t	copies;
+			uint8_t		copies;
+			uint8_t		reserved[3];
 		} vdi;
 
 		/* sheepdog-internal */
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index d1d2209..3c543dc 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -175,7 +175,7 @@ struct vdi_iocb {
 	uint32_t snapid;
 	bool create_snapshot;
 	uint8_t copy_policy;
-	int nr_copies;
+	uint8_t nr_copies;
 	uint64_t time;
 };
 
-- 
1.7.9.5




More information about the sheepdog mailing list