[sheepdog] [PATCH 1/2] proto: move addr and port to common header

Ruoyu liangry at ucweb.com
Thu Jul 3 09:59:56 CEST 2014


It is worth to do it because these two attributes are not specific
to every request type.

recovery.c and object_list_cache.c are also updated because of the
change. Later patch will apply it, too.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 include/sheepdog_proto.h  | 20 ++++++++++----------
 sheep/object_list_cache.c |  4 ++--
 sheep/recovery.c          |  5 ++---
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 76fad51..79035ae 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -122,16 +122,18 @@
 
 #define STORE_LEN 16
 
-#define SD_REQ_SIZE 48
-#define SD_RSP_SIZE 48
+#define SD_REQ_SIZE 72
+#define SD_RSP_SIZE 72
 
 struct sd_req {
 	uint8_t		proto_ver;
 	uint8_t		opcode;
 	uint16_t	flags;
 	uint32_t	epoch;
-	uint32_t        id;
-	uint32_t        data_length;
+	uint32_t	id;
+	uint32_t	data_length;
+	uint8_t		addr[16];
+	uint16_t	port;
 	union {
 		struct {
 			uint64_t	oid;
@@ -176,10 +178,6 @@ struct sd_req {
 			uint32_t	generation;
 			uint32_t	count;
 		} ref;
-		struct {
-			uint8_t		addr[16];
-			uint16_t	port;
-		} node_addr;
 
 		uint32_t		__pad[8];
 	};
@@ -190,8 +188,10 @@ struct sd_rsp {
 	uint8_t		opcode;
 	uint16_t	flags;
 	uint32_t	epoch;
-	uint32_t        id;
-	uint32_t        data_length;
+	uint32_t	id;
+	uint32_t	data_length;
+	uint8_t		addr[16];
+	uint16_t	port;
 	union {
 		uint32_t        result;
 		struct {
diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index 9a7073d..cd594c2 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -106,8 +106,8 @@ int get_obj_list(const struct sd_req *hdr, struct sd_rsp *rsp, void *data)
 	int last = 0, end = 4096;
 	uint64_t *oids = xmalloc(end * sizeof(uint64_t));
 
-	memcpy(peer_nid.addr, hdr->node_addr.addr, sizeof(peer_nid.addr));
-	peer_nid.port = hdr->node_addr.port;
+	memcpy(peer_nid.addr, hdr->addr, sizeof(peer_nid.addr));
+	peer_nid.port = hdr->port;
 
 	/* first try getting the cached buffer with only a read lock held */
 	sd_read_lock(&obj_list_cache.lock);
diff --git a/sheep/recovery.c b/sheep/recovery.c
index ea67b5f..8eda732 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -978,9 +978,8 @@ retry:
 	sd_init_req(&hdr, SD_OP_GET_OBJ_LIST);
 	hdr.data_length = buf_size;
 	hdr.epoch = epoch;
-	memcpy(hdr.node_addr.addr, sys->this_node.nid.addr,
-			sizeof(hdr.node_addr.addr));
-	hdr.node_addr.port = sys->this_node.nid.port;
+	memcpy(hdr.addr, sys->this_node.nid.addr, sizeof(hdr.addr));
+	hdr.port = sys->this_node.nid.port;
 	ret = sheep_exec_req(&e->nid, &hdr, buf);
 
 	switch (ret) {
-- 
1.8.3.2





More information about the sheepdog mailing list