11 #include <linux/list.h>
15 #include "../zcache.h"
18 #define RAMSTER_TESTING
20 #define RMSTR_KEY 0x77347734
33 #define RMSTR_R2NET_MAX_LEN \
34 (R2NET_MAX_PAYLOAD_BYTES - sizeof(struct tmem_xhandle))
38 static struct r2nm_node *r2net_target_node;
39 static int r2net_target_nodenum;
46 if (r2net_target_node !=
NULL) {
47 r2net_target_nodenum = node_num;
57 static int ramster_remote_async_get_request_handler(
struct r2net_msg *
msg,
58 u32 len,
void *
data,
void **ret_data)
61 struct tmem_xhandle xh;
68 xh = *(
struct tmem_xhandle *)msg->
buf;
71 pdata = ramster_async_get_buf;
72 *(
struct tmem_xhandle *)pdata = xh;
73 pdata +=
sizeof(
struct tmem_xhandle);
76 pdata, &size,
true, get_and_free ? 1 : -1);
84 *ret_data = pdata -
sizeof(
struct tmem_xhandle);
87 return size +
sizeof(
struct tmem_xhandle);
90 static int ramster_remote_async_get_reply_handler(
struct r2net_msg *msg,
91 u32 len,
void *data,
void **ret_data)
93 char *
in = (
char *)msg->
buf;
96 struct tmem_xhandle *xh = (
struct tmem_xhandle *)in;
98 in +=
sizeof(
struct tmem_xhandle);
99 datalen -=
sizeof(
struct tmem_xhandle);
103 #ifdef RAMSTER_TESTING
105 pr_err(
"TESTING ArrgREP, aborted overwrite on racy put\n");
111 u32 len,
void *data,
void **ret_data)
113 struct tmem_xhandle *xh;
114 char *
p = (
char *)msg->
buf;
116 sizeof(
struct tmem_xhandle);
122 xh = (
struct tmem_xhandle *)p;
123 p +=
sizeof(
struct tmem_xhandle);
133 u32 len,
void *data,
void **ret_data)
135 struct tmem_xhandle *xh;
136 char *
p = (
char *)msg->
buf;
138 xh = (
struct tmem_xhandle *)
p;
139 p +=
sizeof(
struct tmem_xhandle);
141 &xh->oid, xh->index);
146 u32 len,
void *data,
void **ret_data)
148 struct tmem_xhandle *xh;
149 char *
p = (
char *)msg->
buf;
151 xh = (
struct tmem_xhandle *)
p;
152 p +=
sizeof(
struct tmem_xhandle);
158 size_t expect_size,
uint8_t expect_cksum,
161 int nodenum, ret = -1,
status;
172 xh->xh_data_cksum = expect_cksum;
173 xh->xh_data_size = expect_size;
178 node = r2net_target_node;
182 nodenum = r2net_target_nodenum;
197 vec, veclen, remotenode, &
status);
205 pr_err(
"UNTESTED ret<0 in ramster_remote_async_get: ret=%d\n",
213 #ifdef RAMSTER_TESTING
215 static void ramster_check_irq_counts(
void)
217 static int last_hardirq_cnt, last_softirq_cnt, last_preempt_cnt;
218 int cur_hardirq_cnt, cur_softirq_cnt, cur_preempt_cnt;
221 if (cur_hardirq_cnt > last_hardirq_cnt) {
222 last_hardirq_cnt = cur_hardirq_cnt;
223 if (!(last_hardirq_cnt&(last_hardirq_cnt-1)))
224 pr_err(
"RAMSTER TESTING RRP hardirq_count=%d\n",
228 if (cur_softirq_cnt > last_softirq_cnt) {
229 last_softirq_cnt = cur_softirq_cnt;
230 if (!(last_softirq_cnt&(last_softirq_cnt-1)))
231 pr_err(
"RAMSTER TESTING RRP softirq_count=%d\n",
235 if (cur_preempt_cnt > last_preempt_cnt) {
236 last_preempt_cnt = cur_preempt_cnt;
237 if (!(last_preempt_cnt&(last_preempt_cnt-1)))
238 pr_err(
"RAMSTER TESTING RRP preempt_count=%d\n",
245 bool ephemeral,
int *remotenode)
247 int nodenum, ret = -1,
status;
261 node = r2net_target_node;
265 nodenum = r2net_target_nodenum;
280 #ifdef RAMSTER_TESTING
282 ramster_check_irq_counts();
291 *remotenode = nodenum;
314 vec, veclen, remotenode, &
status);
332 vec, veclen, remotenode, &
status);
343 static void r2net_unregister_handlers(
void)
368 ramster_remote_async_get_request_handler,
376 ramster_remote_async_get_request_handler,
384 ramster_remote_async_get_reply_handler,
406 pr_info(
"ramster: r2net handlers registered\n");
410 r2net_unregister_handlers();
411 pr_err(
"ramster: couldn't register r2net handlers\n");