aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/cluster
diff options
context:
space:
mode:
authorKurt Hackel <kurt.hackel@oracle.com>2007-01-17 20:04:25 -0500
committerMark Fasheh <mark.fasheh@oracle.com>2007-02-07 15:06:56 -0500
commitd74c9803a90d733f5fb7270475aa6d14b45796c6 (patch)
tree7f402437667103773cfe7d76b56a621183e84094 /fs/ocfs2/cluster
parent74aa25856c693d20a886cdb31a004aaca411d135 (diff)
ocfs2: Added post handler callable function in o2net message handler
Currently o2net allows one handler function per message type. This patch adds the ability to call another function to be called after the handler has returned the message to the other node. Handlers are now given the option of returning a context (in the form of a void **) which will be passed back into the post message handler function. Signed-off-by: Kurt Hackel <kurt.hackel@oracle.com> Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/cluster')
-rw-r--r--fs/ocfs2/cluster/tcp.c12
-rw-r--r--fs/ocfs2/cluster/tcp.h6
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h2
3 files changed, 18 insertions, 2 deletions
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index ae4ff4a6636b..7700418d25ec 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -688,6 +688,7 @@ static void o2net_handler_put(struct o2net_msg_handler *nmh)
688 * be given to the handler if their payload is longer than the max. */ 688 * be given to the handler if their payload is longer than the max. */
689int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, 689int o2net_register_handler(u32 msg_type, u32 key, u32 max_len,
690 o2net_msg_handler_func *func, void *data, 690 o2net_msg_handler_func *func, void *data,
691 o2net_post_msg_handler_func *post_func,
691 struct list_head *unreg_list) 692 struct list_head *unreg_list)
692{ 693{
693 struct o2net_msg_handler *nmh = NULL; 694 struct o2net_msg_handler *nmh = NULL;
@@ -722,6 +723,7 @@ int o2net_register_handler(u32 msg_type, u32 key, u32 max_len,
722 723
723 nmh->nh_func = func; 724 nmh->nh_func = func;
724 nmh->nh_func_data = data; 725 nmh->nh_func_data = data;
726 nmh->nh_post_func = post_func;
725 nmh->nh_msg_type = msg_type; 727 nmh->nh_msg_type = msg_type;
726 nmh->nh_max_len = max_len; 728 nmh->nh_max_len = max_len;
727 nmh->nh_key = key; 729 nmh->nh_key = key;
@@ -1049,6 +1051,7 @@ static int o2net_process_message(struct o2net_sock_container *sc,
1049 int ret = 0, handler_status; 1051 int ret = 0, handler_status;
1050 enum o2net_system_error syserr; 1052 enum o2net_system_error syserr;
1051 struct o2net_msg_handler *nmh = NULL; 1053 struct o2net_msg_handler *nmh = NULL;
1054 void *ret_data = NULL;
1052 1055
1053 msglog(hdr, "processing message\n"); 1056 msglog(hdr, "processing message\n");
1054 1057
@@ -1101,7 +1104,7 @@ static int o2net_process_message(struct o2net_sock_container *sc,
1101 sc->sc_msg_type = be16_to_cpu(hdr->msg_type); 1104 sc->sc_msg_type = be16_to_cpu(hdr->msg_type);
1102 handler_status = (nmh->nh_func)(hdr, sizeof(struct o2net_msg) + 1105 handler_status = (nmh->nh_func)(hdr, sizeof(struct o2net_msg) +
1103 be16_to_cpu(hdr->data_len), 1106 be16_to_cpu(hdr->data_len),
1104 nmh->nh_func_data); 1107 nmh->nh_func_data, &ret_data);
1105 do_gettimeofday(&sc->sc_tv_func_stop); 1108 do_gettimeofday(&sc->sc_tv_func_stop);
1106 1109
1107out_respond: 1110out_respond:
@@ -1112,6 +1115,13 @@ out_respond:
1112 mlog(0, "sending handler status %d, syserr %d returned %d\n", 1115 mlog(0, "sending handler status %d, syserr %d returned %d\n",
1113 handler_status, syserr, ret); 1116 handler_status, syserr, ret);
1114 1117
1118 if (nmh) {
1119 BUG_ON(ret_data != NULL && nmh->nh_post_func == NULL);
1120 if (nmh->nh_post_func)
1121 (nmh->nh_post_func)(handler_status, nmh->nh_func_data,
1122 ret_data);
1123 }
1124
1115out: 1125out:
1116 if (nmh) 1126 if (nmh)
1117 o2net_handler_put(nmh); 1127 o2net_handler_put(nmh);
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h
index 21a4e43df836..da880fc215f0 100644
--- a/fs/ocfs2/cluster/tcp.h
+++ b/fs/ocfs2/cluster/tcp.h
@@ -50,7 +50,10 @@ struct o2net_msg
50 __u8 buf[0]; 50 __u8 buf[0];
51}; 51};
52 52
53typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data); 53typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data,
54 void **ret_data);
55typedef void (o2net_post_msg_handler_func)(int status, void *data,
56 void *ret_data);
54 57
55#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg)) 58#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg))
56 59
@@ -99,6 +102,7 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *vec,
99 102
100int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, 103int o2net_register_handler(u32 msg_type, u32 key, u32 max_len,
101 o2net_msg_handler_func *func, void *data, 104 o2net_msg_handler_func *func, void *data,
105 o2net_post_msg_handler_func *post_func,
102 struct list_head *unreg_list); 106 struct list_head *unreg_list);
103void o2net_unregister_handler_list(struct list_head *list); 107void o2net_unregister_handler_list(struct list_head *list);
104 108
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index 775c911342f4..d74040fac343 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -161,6 +161,8 @@ struct o2net_msg_handler {
161 u32 nh_key; 161 u32 nh_key;
162 o2net_msg_handler_func *nh_func; 162 o2net_msg_handler_func *nh_func;
163 o2net_msg_handler_func *nh_func_data; 163 o2net_msg_handler_func *nh_func_data;
164 o2net_post_msg_handler_func
165 *nh_post_func;
164 struct kref nh_kref; 166 struct kref nh_kref;
165 struct list_head nh_unregister_item; 167 struct list_head nh_unregister_item;
166}; 168};