From 6cdee5a458e16daabd0b3537062b096514e4f4e1 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 15 Jan 2014 13:49:36 +0000 Subject: [PATCH] Add call to VL_ListAttribute() to test program and fix stuff Fix the following things: (1) Calculation of iovecs for filling the reply data circular buffer from recvmsg(). (2) Set the circular buffer tail pointer correctly when discarding extraneous data in the final reply decode phase when waiting for MSG_EOR. Signed-off-by: David Howells --- af_rxrpc.c | 32 +++++++++++++++++++++++++++----- rxgen/emit_c_sync_funcs.pm | 2 +- rxgen/emit_py_sync_funcs.pm | 1 + vl-test.py | 19 +++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/af_rxrpc.c b/af_rxrpc.c index a65cf63..a8280c3 100644 --- a/af_rxrpc.c +++ b/af_rxrpc.c @@ -402,6 +402,7 @@ int rxrpc_send_request(struct rx_connection *z_conn, struct msghdr msg; size_t ctrllen; unsigned char control[128]; + int ret; /* request an operation */ ctrllen = 0; @@ -428,7 +429,7 @@ int rxrpc_send_request(struct rx_connection *z_conn, printf("]\n"); for (j = 0; j < msg.msg_iovlen; j++) { - printf("IOV[%02u] %04zu [", i, msg.msg_iov[j].iov_len); + printf("IOV[%02u] %04zu [", j, msg.msg_iov[j].iov_len); p = (const void *)msg.msg_iov[j].iov_base; for (i = 0; i < msg.msg_iov[j].iov_len; i++) printf("%02x", *p++); @@ -444,7 +445,11 @@ int rxrpc_send_request(struct rx_connection *z_conn, printf("FLAGS %x\n", msg.msg_flags); } - return sendmsg(z_conn->fd, &msg, 0) == -1 ? -1 : 0; + ret = sendmsg(z_conn->fd, &msg, 0) == -1 ? -1 : 0; + if (0) { + printf("SENDMSG: %d\n", ret); + } + return ret; } /* @@ -460,6 +465,12 @@ int rxrpc_wait_for_sync_reply(struct rx_connection *z_conn, unsigned char control[128]; int ret; + if (0) { + printf("%s(,{%u,%s,%u/%u})\n", + __func__, call->phase, call->got_eor ? "EOR" : "-", + CIRC_CNT(call->head, call->tail, call->size), call->size); + } + /* wait for a reply */ while (!call->got_eor && CIRC_CNT(call->head, call->tail, call->size) < call->need_size @@ -474,8 +485,10 @@ int rxrpc_wait_for_sync_reply(struct rx_connection *z_conn, if (head >= tail) { piov->iov_base = (void *)call->reply + head; piov->iov_len = size - head; + if (piov->iov_len > space) + piov->iov_len = space; + space -= piov->iov_len; piov++; - space -= size - (head & mask); if (space > 0) { piov->iov_base = (void *)call->reply; piov->iov_len = space; @@ -497,9 +510,20 @@ int rxrpc_wait_for_sync_reply(struct rx_connection *z_conn, msg.msg_controllen = sizeof(control); msg.msg_flags = 0; + if (0) { + unsigned i; + for (i = 0; i < msg.msg_iovlen; i++) + printf("RECV IOV[%02u] %04zu\n", i, msg.msg_iov[i].iov_len); + } + ret = recvmsg(z_conn->fd, &msg, 0); + if (0) { + printf("RECVMSG: %d\n", ret); + } if (ret == -1) return -1; + if (ret > 0) + call->head += ret; //printf("RECV: %d [fl:%d]\n", ret, msg.msg_flags); //printf("CMSG: %zu\n", msg.msg_controllen); @@ -547,8 +571,6 @@ int rxrpc_wait_for_sync_reply(struct rx_connection *z_conn, break; } } - - call->head += ret; } return 0; diff --git a/rxgen/emit_c_sync_funcs.pm b/rxgen/emit_c_sync_funcs.pm index ba21fd0..ff6068d 100644 --- a/rxgen/emit_c_sync_funcs.pm +++ b/rxgen/emit_c_sync_funcs.pm @@ -522,7 +522,7 @@ sub emit_func_decode_reply($) print RXOUT "\t\treturn -1;\n"; print RXOUT "\t}\n"; print RXOUT "need_more_data_2:\n"; - print RXOUT "\tcall->tail = tail;\n"; + print RXOUT "\tcall->tail = tail * 4;\n"; print RXOUT "\treturn 1;\n"; print RXOUT "}\n"; diff --git a/rxgen/emit_py_sync_funcs.pm b/rxgen/emit_py_sync_funcs.pm index cdf4814..636f1b2 100644 --- a/rxgen/emit_py_sync_funcs.pm +++ b/rxgen/emit_py_sync_funcs.pm @@ -301,6 +301,7 @@ sub emit_py_func_simple_sync_call($) $set_null = 1; } elsif ($p->{class} eq "bulk") { # All done in the helper func + next; } else { die $p->{where}, ": Unsupported class \"", $p->{class}, "\""; } diff --git a/vl-test.py b/vl-test.py index eb0ffb6..afa575f 100755 --- a/vl-test.py +++ b/vl-test.py @@ -83,9 +83,28 @@ for vol in volumes: if ret: raise RuntimeError("Abort occurred {:d}".format(ret)); + servers = set(); + for i in vldblist: print("[", i.name, "]"); print("\tnum\t", i.nServers); print("\ttype\t", i.volumeType); print("\tvid\t", i.volumeId); print("\tflags\t {:x}".format(i.flags)); + for j in i.serverNumber: + if j: + servers.add(j); + + # Pick an arbitrary server serving that volume and find out what volumes + # that server serves + attributes = kafs.new_VldbListByAttributes(); + attributes.Mask = kafs.VLLIST_SERVER; + attributes.server = servers.pop(); + nentries = []; + blkentries = []; + ret = kafs.VL_ListAttributes(z_conn, attributes, nentries, blkentries) + if ret: + raise RuntimeError("Abort occurred {:d}".format(ret)); + + for i in blkentries: + print("->", i.name); -- 2.49.0