]> www.infradead.org Git - users/dhowells/kafs-utils.git/commitdiff
Add call to VL_ListAttribute() to test program and fix stuff
authorDavid Howells <dhowells@redhat.com>
Wed, 15 Jan 2014 13:49:36 +0000 (13:49 +0000)
committerDavid Howells <dhowells@redhat.com>
Wed, 15 Jan 2014 13:49:36 +0000 (13:49 +0000)
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 <dhowells@redhat.com>
af_rxrpc.c
rxgen/emit_c_sync_funcs.pm
rxgen/emit_py_sync_funcs.pm
vl-test.py

index a65cf63245dde579a71c84f9dc4ce35b4858e174..a8280c364e8d03732338d73c0543b657f8d16ab7 100644 (file)
@@ -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;
index ba21fd03cca8fa82ecedd6a12e606c6f243e63f4..ff6068da36796fd6ae64406578d1436128b8ca9e 100644 (file)
@@ -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";
index cdf48143ee5e703119f795202f8d13fc545e46b6..636f1b2fa10a16d88372be84db8c6349db4f27f3 100644 (file)
@@ -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}, "\"";
            }
index eb0ffb6b04ed277b8950615206abf437c1dbaaad..afa575f388928afd5e2ea6caa95b1e86ebfbae25 100755 (executable)
@@ -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);