[sheepdog] [PATCH] fix error command flag SD_FLAG_CMD_FILTER

Ruoyu liangry at ucweb.com
Tue Jul 29 08:56:34 CEST 2014


All the macros are mutually exclusive in the SD_FLAG_CMD_XXX group,
so the new added flag cannot be set as 0x11 because
SD_FLAG_CMD_WRITE is already 0x01.

Secondly, the new added flag is renamed to SD_FLAG_CMD_PIGGYBACK
which stands for returning something back while sending something
to sheep.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 dog/vdi.c                | 2 +-
 include/sheepdog_proto.h | 4 +++-
 lib/net.c                | 8 ++++----
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index 93ae763..2e3f7b3 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -1065,7 +1065,7 @@ static int do_vdi_check_exist(const struct sd_inode *inode)
 	rb_for_each_entry(entry, &oid_tree, rb) {
 		sd_init_req(&hdr, SD_OP_OIDS_EXIST);
 		hdr.data_length = sizeof(uint64_t) * entry->last;
-		hdr.flags = SD_FLAG_CMD_FILTER;
+		hdr.flags = SD_FLAG_CMD_WRITE | SD_FLAG_CMD_PIGGYBACK;
 		int ret = dog_exec_req(&entry->node->nid, &hdr, entry->oids);
 		if (ret < 0)
 			panic("dog_exec_req() failure.");
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index b4e1e13..7cfdccb 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -46,11 +46,13 @@
 #define SD_OP_FLUSH_VDI      0x16
 #define SD_OP_DEL_VDI        0x17
 
+/* macros in the SD_FLAG_CMD_XXX group are mutually exclusive */
 #define SD_FLAG_CMD_WRITE    0x01
 #define SD_FLAG_CMD_COW      0x02
 #define SD_FLAG_CMD_CACHE    0x04
 #define SD_FLAG_CMD_DIRECT   0x08 /* don't use object cache */
-#define SD_FLAG_CMD_FILTER   0x11 /* write & read, output is subset of input */
+/* return something back while sending something to sheep */
+#define SD_FLAG_CMD_PIGGYBACK   0x10
 /* flags above 0x80 are sheepdog-internal */
 
 #define SD_RES_SUCCESS       0x00 /* Success */
diff --git a/lib/net.c b/lib/net.c
index 552e945..02b328e 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -333,10 +333,10 @@ int exec_req(int sockfd, struct sd_req *hdr, void *data,
 
 	if (hdr->flags & SD_FLAG_CMD_WRITE) {
 		wlen = hdr->data_length;
-		rlen = 0;
-	} else if (hdr->flags & SD_FLAG_CMD_FILTER) {
-		wlen = hdr->data_length;
-		rlen = hdr->data_length;
+		if (hdr->flags & SD_FLAG_CMD_PIGGYBACK)
+			rlen = hdr->data_length;
+		else
+			rlen = 0;
 	} else {
 		wlen = 0;
 		rlen = hdr->data_length;
-- 
1.8.3.2





More information about the sheepdog mailing list