[sheepdog] [PATCH 10/11] sheep: allow process_work to set response data when SD_FLAG_CMD_WRITE is not set

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Apr 16 09:24:38 CEST 2013


Currently, we assume that process_main sets the response data when
SD_FLAG_CMD_WRITE is not set.  This also allows process_work to set
the data and notify it to all the nodes.

This prepares for the next patch.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/group.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index 60e2860..e70389f 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -236,9 +236,11 @@ static struct vdi_op_message *prepare_cluster_msg(struct request *req,
 	size_t size;
 
 	if (has_process_main(req->op) && req->rq.flags & SD_FLAG_CMD_WRITE)
+		/* notify data that was received from the sender */
 		size = sizeof(*msg) + req->rq.data_length;
 	else
-		size = sizeof(*msg);
+		/* notify data that was set in process_work */
+		size = sizeof(*msg) + req->rp.data_length;
 
 	assert(size <= SD_MAX_EVENT_BUF_SIZE);
 
@@ -246,8 +248,8 @@ static struct vdi_op_message *prepare_cluster_msg(struct request *req,
 	memcpy(&msg->req, &req->rq, sizeof(struct sd_req));
 	memcpy(&msg->rsp, &req->rp, sizeof(struct sd_rsp));
 
-	if (has_process_main(req->op) && req->rq.flags & SD_FLAG_CMD_WRITE)
-		memcpy(msg->data, req->data, req->rq.data_length);
+	if (has_process_main(req->op) && size > sizeof(*msg))
+		memcpy(msg->data, req->data, size - sizeof(*msg));
 
 	*sizep = size;
 	return msg;
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list