make peers use macros for reading args. also remove some peer compilation warnings
authorFilippos Giannakos <philipgian@grnet.gr>
Wed, 12 Dec 2012 12:17:26 +0000 (14:17 +0200)
committerFilippos Giannakos <philipgian@grnet.gr>
Wed, 12 Dec 2012 12:17:26 +0000 (14:17 +0200)
xseg/peers/user/filed.c
xseg/peers/user/mt-mapperd.c
xseg/peers/user/mt-pfiled.c
xseg/peers/user/mt-sosd.c
xseg/peers/user/mt-vlmcd.c
xseg/peers/user/pfiled.c
xseg/peers/user/vlmc-tool.c

index 8cfbe2b..077966a 100644 (file)
@@ -196,10 +196,12 @@ static void fail(struct store *store, struct io *io)
        }
 }
 
+/*
 static void pending(struct store *store, struct io *io)
 {
        io->req->state = XS_PENDING;
 }
+*/
 
 static void handle_unknown(struct store *store, struct io *io)
 {
@@ -636,6 +638,7 @@ static int filed_loop(struct store *store)
 
        for (;;) {
                io = wake_up_next_iothread(store);
+               (void)io;
                xseg_prepare_wait(xseg, portno);
                xseg_wait_signal(xseg, 1000000UL);
        }
index a6b9b26..075d710 100644 (file)
@@ -48,6 +48,7 @@
 #include <sched.h>
 #include <sys/syscall.h>
 #include <openssl/sha.h>
+#include <ctype.h>
 
 /* general mapper flags */
 #define MF_LOAD        (1 << 0)
@@ -1799,7 +1800,7 @@ static int do_mapw(struct peer_req *pr, struct map *map)
 static int do_clone(struct peer_req *pr, struct map *map)
 {
        int r;
-       char buf[XSEG_MAX_TARGETLEN];
+//     char buf[XSEG_MAX_TARGETLEN];
        struct peerd *peer = pr->peer;
        struct mapperd *mapper = __get_mapperd(peer);
        char *target = xseg_get_target(peer->xseg, pr->req);
@@ -2249,7 +2250,7 @@ int wait_reply(struct peerd *peer, struct xseg_request *expected_req)
        struct peer_req *pr;
        xport i;
        int  r, c = 0;
-       struct xseg_request *req, *received;
+       struct xseg_request *received;
        xseg_prepare_wait(xseg, portno_start);
        while(1) {
                XSEGLOG2(&lc, D, "Attempting to check for reply");
@@ -2291,7 +2292,6 @@ void custom_peer_finalize(struct peerd *peer)
                XSEGLOG2(&lc, E, "Cannot get peer request");
                return;
        }
-       int r;
        struct map *map;
        struct xseg_request *req;
        xhash_iter_t it;
index 0a59727..eeb776d 100644 (file)
@@ -762,6 +762,7 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
        pfiled->path_len = strlen(pfiled->path);
        if (!pfiled->path_len){
                XSEGLOG2(&lc, E, "Pithos path was not provided");
+               usage(argv[0]);
                return -1;
        }
        if (pfiled->path[pfiled->path_len -1] != '/'){
@@ -772,6 +773,7 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
        pfiled->vpath_len = strlen(pfiled->vpath);
        if (!pfiled->vpath_len){
                XSEGLOG2(&lc, E, "Archipelagos path was not provided");
+               usage(argv[0]);
                return -1;
        }
        if (pfiled->vpath[pfiled->vpath_len -1] != '/'){
@@ -794,6 +796,7 @@ void custom_peer_finalize(struct peerd *peer)
        return;
 }
 
+/*
 static int safe_atoi(char *s)
 {
        long l;
@@ -805,3 +808,4 @@ static int safe_atoi(char *s)
        else
                return -1;
 }
+*/
index c30a6e2..31b1147 100644 (file)
@@ -612,17 +612,15 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
                return -1;
        }
        rados->pool[0] = 0;
-       for (i = 0; i < argc; i++) {
-               if (!strcmp(argv[i], "--pool") && (i+1) < argc){
-                       strncpy(rados->pool, argv[i+1], MAX_POOL_NAME);
-                       rados->pool[MAX_POOL_NAME] = 0;
-                       i += 1;
-                       continue;
-               }
-       }
+
+       BEGIN_READ_ARGS(argc, argv);
+       READ_ARG_STRING("--pool", rados->pool, MAX_POOL_NAME);
+       END_READ_ARGS();
+
        if (!rados->pool[0]){
                XSEGLOG2(&lc, E , "Pool must be provided");
                free(rados);
+               usage(argv[0]);
                return -1;
        }
 
index 30c75be..eb855d4 100644 (file)
@@ -37,7 +37,7 @@
 #include <unistd.h>
 #include <xseg/xseg.h>
 #include <xseg/protocol.h>
-#include <speer.h>
+#include <peer.h>
 #include <sched.h>
 #include <sys/syscall.h>
 
@@ -181,13 +181,16 @@ static int handle_mapping(struct peerd *peer, struct peer_req *pr,
        
        //assert vio>mreq == req 
        if (vio->mreq != req){
-               printf("vio->mreq %lx, req: %lx state: %d breq[0]: %lx\n", vio->mreq, req, vio->state, vio->breqs[0]);
+               printf("vio->mreq %lx, req: %lx state: %d breq[0]: %lx\n",
+                               (unsigned long)vio->mreq, (unsigned long)req,
+                               vio->state, (unsigned long)vio->breqs[0]);
                r = *(volatile int *)0;
                return -1;
        }
        /* FIXME shouldn's XS_FAILED be sufficient ?? */
        if (vio->mreq->state & XS_FAILED && !(vio->mreq->state & XS_SERVED)){
-               fprintf(stderr, "req %lx (op: %d) failed\n", vio->mreq, vio->mreq->op);
+               fprintf(stderr, "req %lx (op: %d) failed\n",
+                               (unsigned long)vio->mreq, vio->mreq->op);
                xseg_put_request(peer->xseg, vio->mreq, pr->portno);
                vio->mreq = NULL;
                __set_vio_state(vio, CONCLUDED);
@@ -301,10 +304,13 @@ static int handle_serving(struct peerd *peer, struct peer_req *pr,
 {
        struct vlmc_io *vio = __get_vlmcio(pr);
        struct vlmcd *vlmc = __get_vlmcd(peer);
+       (void)vlmc;
        struct xseg_request *breq = req;
 
        if (breq->state & XS_FAILED && !(breq->state & XS_SERVED)) {
-               fprintf(stderr, "req %lx (op: %d) failed at offset \n", req, req->op, req->offset);
+               fprintf(stderr, "req %lx (op: %d) failed at offset %llu\n",
+                               (unsigned long)req, req->op,
+                               (unsigned long long)req->offset);
                vio->err = 1;
        } else {
                //assert breq->serviced == breq->size
@@ -331,6 +337,7 @@ int dispatch(struct peerd *peer, struct peer_req *pr, struct xseg_request *req,
 {
        struct vlmc_io *vio = __get_vlmcio(pr);
        struct vlmcd *vlmc = __get_vlmcd(peer);
+       (void)vlmc;
 
        xlock_acquire(&vio->lock,1);
        if (pr->req == req)
@@ -371,6 +378,25 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
        }
        peer->priv = (void *) vlmc;
 
+       vlmc->mportno = NoPort;
+       vlmc->bportno = NoPort;
+
+        BEGIN_READ_ARGS(argc, argv);
+       READ_ARG_ULONG("-mp", vlmc->mportno);
+       READ_ARG_ULONG("-bp", vlmc->bportno);
+       END_READ_ARGS();
+
+       if (vlmc->bportno == NoPort) {
+               XSEGLOG2(&lc, E, "bportno must be provided");
+               usage(argv[0]);
+               return -1;
+       }
+       if (vlmc->mportno == NoPort) {
+               XSEGLOG2(&lc, E, "mportno must be provided");
+               usage(argv[0]);
+               return -1;
+       }
+
        for (i = 0; i < peer->nr_ops; i++) {
                vio = malloc(sizeof(struct vlmc_io));
                if (!vio) {
@@ -390,18 +416,6 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
                return -1;
        }
 
-       for (i = 0; i < argc; i++) {
-               if (!strcmp(argv[i], "-mp") && (i+1) < argc){
-                       vlmc->mportno = atoi(argv[i+1]);
-                       i += 1;
-                       continue;
-               }
-               if (!strcmp(argv[i], "-bp") && (i+1) < argc){
-                       vlmc->bportno = atoi(argv[i+1]);
-                       i += 1;
-                       continue;
-               }
-       }
 
        const struct sched_param param = { .sched_priority = 99 };
        sched_setscheduler(syscall(SYS_gettid), SCHED_FIFO, &param);
index 9b76921..ef6d22e 100644 (file)
@@ -212,7 +212,7 @@ static void log_io(char *msg, struct io *io)
        data[dend] = 0;
 
        fprintf(stderr,
-                       "%s: fd:%u, op:%u offset: %llu size: %lu retval: %lu, reqstate: %u, serviced: %u\n"
+                       "%s: fd:%u, op:%u offset: %llu size: %lu retval: %lu, reqstate: %u, serviced: %lu\n"
                        "target[%u]: '%s', data[%llu]:\n%s------------------\n\n",
                        msg,
                        (unsigned int)io->fdcacheidx, /* this is cacheidx not fd */
@@ -806,6 +806,7 @@ static int pfiled_loop(struct pfiled *pfiled)
        uint32_t portno = pfiled->portno;
        /* GCC + pthreads glitch? */
        struct io *io;
+       (void)io;
 
        for (;!(isTerminate() && xq_count(&pfiled->free_ops) == pfiled->nr_ops);) {
                io = wake_up_next_iothread(pfiled);
index c60f4d4..fcd4c13 100644 (file)
@@ -323,7 +323,7 @@ int main(int argc, char *argv[])
        char *snap = NULL;
        uint64_t size = -1;
        //char *pool = NULL;
-       char *config = NULL;
+//     char *config = NULL;
 
        for (i = 3; i < argc; i++) {
                if ((!strcmp(argv[i], "-s") || !strcmp(argv[i], "--size")) && i+1 < argc){
@@ -333,6 +333,7 @@ int main(int argc, char *argv[])
                                size = atol(argv[i+1]);
                                i++;
                        }
+/*
                }else if ((!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config")) && i+1 < argc){
                        if (!validate_alphanumeric(argv[i+1])){
                                err_in_arg(i, argv[i]);
@@ -340,6 +341,7 @@ int main(int argc, char *argv[])
                                config = argv[i+1];
                                i++;
                        }
+*/
                } else if (!strcmp(argv[i], "--snap") && i+1 < argc){
                        if (!validate_alphanumeric(argv[i+1])){
                                err_in_arg(i, argv[i]);