[sheepdog] [PATCH v2 1/7] sheep: change a prototype of process_main() for obtaining sender information

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Wed Jul 30 09:24:36 CEST 2014


This patch changes a prototype of process_main() for obtaining sender
information. It is useful for detecting which node issued operations.

Cc: Fabian Zimmermann <dev.faz at gmail.com>
Cc: Valerio Pachera <sirio81 at gmail.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/group.c      |  5 ++--
 sheep/ops.c        | 75 +++++++++++++++++++++++++++++-------------------------
 sheep/request.c    |  3 ++-
 sheep/sheep_priv.h |  5 ++--
 4 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index f53ad0f..f162026 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -188,7 +188,7 @@ int get_nodes_epoch(uint32_t epoch, struct vnode_info *cur_vinfo,
 }
 
 int local_get_node_list(const struct sd_req *req, struct sd_rsp *rsp,
-			void *data)
+			void *data, const struct sd_node *sender)
 {
 	int nr_nodes;
 	struct vnode_info *cur_vinfo = get_vnode_info();
@@ -775,7 +775,8 @@ main_fn void sd_notify_handler(const struct sd_node *sender, void *data,
 	}
 
 	if (ret == SD_RES_SUCCESS && has_process_main(op))
-		ret = do_process_main(op, &msg->req, &msg->rsp, msg->data);
+		ret = do_process_main(op, &msg->req, &msg->rsp, msg->data,
+				      sender);
 
 	if (req) {
 		msg->rsp.result = ret;
diff --git a/sheep/ops.c b/sheep/ops.c
index 3d20c7d..58ff397 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -49,7 +49,8 @@ struct sd_op_template {
 	 * will be called on the local node.
 	 */
 	int (*process_work)(struct request *req);
-	int (*process_main)(const struct sd_req *req, struct sd_rsp *rsp, void *data);
+	int (*process_main)(const struct sd_req *req, struct sd_rsp *rsp,
+			    void *data, const struct sd_node *sender);
 };
 
 /*
@@ -119,7 +120,7 @@ static int cluster_new_vdi(struct request *req)
 }
 
 static int post_cluster_new_vdi(const struct sd_req *req, struct sd_rsp *rsp,
-				void *data)
+				void *data, const struct sd_node *sender)
 {
 	unsigned long nr = rsp->vdi.vdi_id;
 	int ret = rsp->result;
@@ -181,7 +182,7 @@ static void cache_delete_done(struct work *work)
 }
 
 static int post_cluster_del_vdi(const struct sd_req *req, struct sd_rsp *rsp,
-				void *data)
+				void *data, const struct sd_node *sender)
 {
 	unsigned long vid = rsp->vdi.vdi_id;
 	struct cache_deletion_work *dw;
@@ -251,7 +252,7 @@ static int remove_epoch(uint32_t epoch)
 }
 
 static int cluster_make_fs(const struct sd_req *req, struct sd_rsp *rsp,
-			   void *data)
+			   void *data, const struct sd_node *sender)
 {
 	int i, ret;
 	uint32_t latest_epoch;
@@ -301,7 +302,7 @@ static int cluster_make_fs(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 static int cluster_shutdown(const struct sd_req *req, struct sd_rsp *rsp,
-			    void *data)
+			    void *data, const struct sd_node *sender)
 {
 	sys->cinfo.status = SD_STATUS_SHUTDOWN;
 	if (!node_in_recovery()) {
@@ -318,16 +319,16 @@ static int cluster_shutdown(const struct sd_req *req, struct sd_rsp *rsp,
 	return SD_RES_SUCCESS;
 }
 
-static int cluster_enable_recover(const struct sd_req *req,
-				    struct sd_rsp *rsp, void *data)
+static int cluster_enable_recover(const struct sd_req *req, struct sd_rsp *rsp,
+				  void *data, const struct sd_node *sender)
 {
 	sys->cinfo.disable_recovery = false;
 	resume_suspended_recovery();
 	return SD_RES_SUCCESS;
 }
 
-static int cluster_disable_recover(const struct sd_req *req,
-				   struct sd_rsp *rsp, void *data)
+static int cluster_disable_recover(const struct sd_req *req, struct sd_rsp *rsp,
+				   void *data, const struct sd_node *sender)
 {
 	sys->cinfo.disable_recovery = true;
 	return SD_RES_SUCCESS;
@@ -404,13 +405,13 @@ static int local_get_store_list(struct request *req)
 }
 
 static int local_read_vdis(const struct sd_req *req, struct sd_rsp *rsp,
-			   void *data)
+			   void *data, const struct sd_node *sender)
 {
 	return read_vdis(data, req->data_length, &rsp->data_length);
 }
 
 static int local_get_vdi_copies(const struct sd_req *req, struct sd_rsp *rsp,
-			   void *data)
+				void *data, const struct sd_node *sender)
 {
 	return fill_vdi_state_list(req, rsp, data);
 }
@@ -424,7 +425,7 @@ static int local_stat_sheep(struct request *req)
 }
 
 static int local_stat_recovery(const struct sd_req *req, struct sd_rsp *rsp,
-					void *data)
+			       void *data, const struct sd_node *sender)
 {
 	get_recovery_state(data);
 	rsp->data_length = sizeof(struct recovery_state);
@@ -564,7 +565,7 @@ static int cluster_force_recover_work(struct request *req)
 
 static int cluster_force_recover_main(const struct sd_req *req,
 				      struct sd_rsp *rsp,
-				      void *data)
+				      void *data, const struct sd_node *sender)
 {
 	struct vnode_info *old_vnode_info, *vnode_info;
 	int ret = SD_RES_SUCCESS;
@@ -603,7 +604,7 @@ err:
 }
 
 static int cluster_cleanup(const struct sd_req *req, struct sd_rsp *rsp,
-				void *data)
+			   void *data, const struct sd_node *sender)
 {
 	int ret;
 
@@ -622,7 +623,7 @@ static int cluster_cleanup(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 static int cluster_notify_vdi_add(const struct sd_req *req, struct sd_rsp *rsp,
-				  void *data)
+				  void *data, const struct sd_node *sender)
 {
 	if (req->vdi_state.old_vid)
 		/* make the previous working vdi a snapshot */
@@ -640,7 +641,7 @@ static int cluster_notify_vdi_add(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 static int cluster_notify_vdi_del(const struct sd_req *req, struct sd_rsp *rsp,
-				  void *data)
+				  void *data, const struct sd_node *sender)
 {
 	uint32_t vid = *(uint32_t *)data;
 
@@ -648,7 +649,7 @@ static int cluster_notify_vdi_del(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 static int cluster_delete_cache(const struct sd_req *req, struct sd_rsp *rsp,
-				void *data)
+				void *data, const struct sd_node *sender)
 {
 	uint32_t vid = oid_to_vid(req->obj.oid);
 
@@ -660,7 +661,7 @@ static int cluster_delete_cache(const struct sd_req *req, struct sd_rsp *rsp,
 
 static int cluster_recovery_completion(const struct sd_req *req,
 				       struct sd_rsp *rsp,
-				       void *data)
+				       void *data, const struct sd_node *sender)
 {
 	static struct sd_node recovereds[SD_MAX_NODES], *node;
 	static size_t nr_recovereds;
@@ -714,7 +715,8 @@ static int cluster_recovery_completion(const struct sd_req *req,
 }
 
 static int cluster_alter_cluster_copy(const struct sd_req *req,
-			struct sd_rsp *rsp, void *data)
+				      struct sd_rsp *rsp, void *data,
+				      const struct sd_node *sender)
 {
 	if (req->cluster.copy_policy != 0)
 		return SD_RES_INVALID_PARMS;
@@ -723,8 +725,8 @@ static int cluster_alter_cluster_copy(const struct sd_req *req,
 	return set_cluster_config(&sys->cinfo);
 }
 
-static int cluster_alter_vdi_copy(const struct sd_req *req,
-			struct sd_rsp *rsp, void *data)
+static int cluster_alter_vdi_copy(const struct sd_req *req, struct sd_rsp *rsp,
+				  void *data, const struct sd_node *sender)
 {
 	if (req->cluster.copy_policy != 0)
 		return SD_RES_INVALID_PARMS;
@@ -772,7 +774,7 @@ static bool node_size_varied(void)
 }
 
 static int cluster_reweight(const struct sd_req *req, struct sd_rsp *rsp,
-			    void *data)
+			    void *data, const struct sd_node *sender)
 {
 	if (node_size_varied())
 		return sys->cdrv->update_node(&sys->this_node);
@@ -791,7 +793,7 @@ static int local_md_info(struct request *request)
 }
 
 static int local_md_plug(const struct sd_req *req, struct sd_rsp *rsp,
-			 void *data)
+			 void *data, const struct sd_node *sender)
 {
 	char *disks = (char *)data;
 
@@ -799,7 +801,7 @@ static int local_md_plug(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 static int local_md_unplug(const struct sd_req *req, struct sd_rsp *rsp,
-			   void *data)
+			   void *data, const struct sd_node *sender)
 {
 	char *disks = (char *)data;
 
@@ -844,7 +846,7 @@ out:
 }
 
 static int local_sd_stat(const struct sd_req *req, struct sd_rsp *rsp,
-			 void *data)
+			 void *data, const struct sd_node *sender)
 {
 	memcpy(data, &sys->stat, sizeof(struct sd_stat));
 	rsp->data_length = sizeof(struct sd_stat);
@@ -904,19 +906,19 @@ static int local_flush_and_del(struct request *req)
 }
 
 static int local_trace_enable(const struct sd_req *req, struct sd_rsp *rsp,
-			      void *data)
+			      void *data, const struct sd_node *sender)
 {
 	return trace_enable(data);
 }
 
 static int local_trace_disable(const struct sd_req *req, struct sd_rsp *rsp,
-			       void *data)
+			       void *data, const struct sd_node *sender)
 {
 	return trace_disable(data);
 }
 
 static int local_trace_status(const struct sd_req *req, struct sd_rsp *rsp,
-			      void *data)
+			      void *data, const struct sd_node *sender)
 {
 	rsp->data_length = trace_status(data);
 
@@ -939,7 +941,7 @@ static int local_trace_read_buf(struct request *request)
 }
 
 static int local_kill_node(const struct sd_req *req, struct sd_rsp *rsp,
-			   void *data)
+			   void *data, const struct sd_node *sender)
 {
 	sys->cinfo.status = SD_STATUS_KILLED;
 	unregister_listening_fds();
@@ -1057,7 +1059,7 @@ static int local_oid_exist(struct request *req)
 }
 
 static int local_oids_exist(const struct sd_req *req, struct sd_rsp *rsp,
-			      void *data)
+			    void *data, const struct sd_node *sender)
 {
 	struct request *r = container_of(req, struct request, rq);
 	uint64_t *oids = (uint64_t *) data;
@@ -1081,7 +1083,7 @@ static int local_oids_exist(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 static int local_cluster_info(const struct sd_req *req, struct sd_rsp *rsp,
-			      void *data)
+			      void *data, const struct sd_node *sender)
 {
 	memcpy(data, &sys->cinfo, sizeof(sys->cinfo));
 	rsp->data_length = sizeof(sys->cinfo);
@@ -1221,7 +1223,8 @@ out:
 }
 
 static int local_prevent_inode_update(const struct sd_req *req,
-				      struct sd_rsp *rsp, void *data)
+				      struct sd_rsp *rsp,
+				      void *data, const struct sd_node *sender)
 {
 	/* FIXME: change type of process_main() */
 	struct request *rq = container_of(req, struct request, rq);
@@ -1241,7 +1244,8 @@ static int local_prevent_inode_update(const struct sd_req *req,
 }
 
 static int local_allow_inode_update(const struct sd_req *req,
-				    struct sd_rsp *rsp, void *data)
+				    struct sd_rsp *rsp,
+				    void *data, const struct sd_node *sender)
 {
 	struct request *rq;
 
@@ -1805,9 +1809,10 @@ void do_process_work(struct work *work)
 }
 
 int do_process_main(const struct sd_op_template *op, const struct sd_req *req,
-		    struct sd_rsp *rsp, void *data)
+		    struct sd_rsp *rsp, void *data,
+		    const struct sd_node *sender)
 {
-	return op->process_main(req, rsp, data);
+	return op->process_main(req, rsp, data, sender);
 }
 
 static int map_table[] = {
diff --git a/sheep/request.c b/sheep/request.c
index 2a24b93..8a68ff8 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -155,7 +155,8 @@ static void local_op_done(struct work *work)
 
 	if (has_process_main(req->op)) {
 		req->rp.result = do_process_main(req->op, &req->rq,
-						 &req->rp, req->data);
+						 &req->rp, req->data,
+						 &sys->this_node);
 	}
 
 	put_request(req);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 4402bb7..b0156ee 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -354,7 +354,7 @@ int get_vdi_attr(struct sheepdog_vdi_attr *vattr, int data_len, uint32_t vid,
 		bool excl, bool delete);
 
 int local_get_node_list(const struct sd_req *req, struct sd_rsp *rsp,
-		void *data);
+			void *data, const struct sd_node *sender);
 
 struct vnode_info *grab_vnode_info(struct vnode_info *vnode_info);
 struct vnode_info *get_vnode_info(void);
@@ -457,7 +457,8 @@ bool has_process_work(const struct sd_op_template *op);
 bool has_process_main(const struct sd_op_template *op);
 void do_process_work(struct work *work);
 int do_process_main(const struct sd_op_template *op, const struct sd_req *req,
-		    struct sd_rsp *rsp, void *data);
+		    struct sd_rsp *rsp, void *data,
+		    const struct sd_node *sender);
 int gateway_to_peer_opcode(int opcode);
 
 extern uint32_t last_gathered_epoch;
-- 
1.8.3.2




More information about the sheepdog mailing list