bench: Fix issuing of read/write requests
authorAlex Pyrgiotis <apyrgio@grnet.gr>
Thu, 18 Apr 2013 15:34:17 +0000 (18:34 +0300)
committerAlex Pyrgiotis <apyrgio@grnet.gr>
Thu, 18 Apr 2013 15:39:40 +0000 (18:39 +0300)
Due to no initialization of struct bench, some "ifs" in the code would
show different behavior depending on the junk values they would check.
Now however, there is proper initialization of struct bench.

xseg/peers/user/bench-utils.c
xseg/peers/user/bench-xseg.c

index d857269..d3dbb3d 100644 (file)
@@ -73,7 +73,7 @@ static inline uint64_t __get_object_from_name(char *name)
 
 static inline uint64_t __get_object(struct bench *prefs, uint64_t new)
 {
-       if (prefs->to < 0)
+       if (prefs->ts > 0)
                new = new / (prefs->os / prefs->bs);
        return new;
 }
@@ -402,7 +402,7 @@ uint64_t determine_next(struct bench *prefs)
 
 uint64_t calculate_offset(struct bench *prefs, uint64_t new)
 {
-       if (prefs->to < 0)
+       if (prefs->ts > 0)
                return (new * prefs->bs) % prefs->os;
        else
                return 0;
index f78059e..365b681 100644 (file)
@@ -140,13 +140,14 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
                perror("malloc");
                return -1;
        }
-       prefs->flags = 0;
+       memset(prefs, 0, sizeof(struct bench));
 
        prefs->status = malloc(sizeof(struct req_status));
        if (!prefs->status) {
                perror("malloc");
                return -1;
        }
+
        memset(prefs->status, 0, sizeof(struct req_status));
 
        //Begin reading the benchmark-specific arguments
@@ -267,7 +268,7 @@ int custom_peer_init(struct peerd *peer, int argc, char *argv[])
        } else if (total_size[0]) {
                if (prefs->op != X_READ && prefs->op != X_WRITE) {
                        XSEGLOG2(&lc, E,
-                                       "Total objects must be supplied (required by op %s)\n", op);
+                                       "Total objects must be supplied (required by -op %s)\n", op);
                        goto arg_fail;
                }
                prefs->ts = str2num(total_size);