Whamcloud - gitweb
ignore generated files
[fs/lustre-release.git] / lustre / tests / fsx.c
index aba33d5..8524c91 100644 (file)
@@ -127,7 +127,6 @@ int         mapped_reads = 1;               /* -R flag disables it */
 int    fsxgoodfd = 0;
 FILE * fsxlogf = NULL;
 int badoff = -1;
-int closeopen = 0;
 
 
 void
@@ -182,8 +181,6 @@ log4(int operation, int arg0, int arg1, int arg2, struct timeval *tv)
        le = &oplog[logptr];
        le->tv = *tv;
        le->operation = operation;
-       if (closeopen)
-               le->operation = ~ le->operation;
        le->args[0] = arg0;
        le->args[1] = arg1;
        le->args[2] = arg2;
@@ -213,14 +210,12 @@ logdump(void)
 
                opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
                lp = &oplog[i];
-               prt("%d(%d mod 256): %lu.%06lu ", opnum, opnum%256,
+               prt("%d: %lu.%06lu ", opnum,
                    lp->tv.tv_sec, lp->tv.tv_usec);
-               if ((closeopen = lp->operation < 0))
-                       lp->operation = ~ lp->operation;
 
                switch (lp->operation) {
                case OP_MAPREAD:
-                       prt("MAPREAD\t0x%x thru 0x%x (0x%x bytes)",
+                       prt("MAPREAD  0x%x thru 0x%x (0x%x bytes)",
                            lp->args[0], lp->args[0] + lp->args[1] - 1,
                            lp->args[1]);
                        if (badoff >= lp->args[0] && badoff <
@@ -236,7 +231,7 @@ logdump(void)
                                prt("\t******WWWW");
                        break;
                case OP_READ:
-                       prt("READ\t0x%x thru 0x%x (0x%x bytes)",
+                       prt("READ     0x%x thru 0x%x (0x%x bytes)",
                            lp->args[0], lp->args[0] + lp->args[1] - 1,
                            lp->args[1]);
                        if (badoff >= lp->args[0] &&
@@ -244,7 +239,7 @@ logdump(void)
                                prt("\t***RRRR***");
                        break;
                case OP_WRITE:
-                       prt("WRITE\t0x%x thru 0x%x (0x%x bytes)",
+                       prt("WRITE    0x%x thru 0x%x (0x%x bytes)",
                            lp->args[0], lp->args[0] + lp->args[1] - 1,
                            lp->args[1]);
                        if (lp->args[0] > lp->args[2])
@@ -263,6 +258,9 @@ logdump(void)
                            badoff < lp->args[!!down])
                                prt("\t******WWWW");
                        break;
+               case OP_CLOSEOPEN:
+                       prt("CLOSE/OPEN");
+                       break;
                case OP_SKIPPED:
                        prt("SKIPPED (no operation)");
                        break;
@@ -270,8 +268,6 @@ logdump(void)
                        prt("BOGUS LOG ENTRY (operation code = %d)!",
                            lp->operation);
                }
-               if (closeopen)
-                       prt("\n\t\tCLOSE/OPEN");
                prt("\n");
                i++;
                if (i == LOGSIZE)
@@ -298,9 +294,10 @@ save_buffer(char *buffer, off_t bufferlength, int fd)
                if (size_by_seek == (off_t)-1)
                        prterr("save_buffer: lseek eof");
                else if (bufferlength > size_by_seek) {
-                       warn("save_buffer: .fsxgood file too short... will
-save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
-                            (unsigned long long)bufferlength);
+                       warn("save_buffer: .fsxgood file too short... will"
+                               "save 0x%llx bytes instead of 0x%llx\n", 
+                               (unsigned long long)size_by_seek,
+                               (unsigned long long)bufferlength);
                        bufferlength = size_by_seek;
                }
        }
@@ -314,8 +311,8 @@ save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
                if (byteswritten == -1)
                        prterr("save_buffer write");
                else
-                       warn("save_buffer: short write, 0x%x bytes instead
-of 0x%llx\n",
+                       warn("save_buffer: short write, 0x%x bytes instead"
+                               "of 0x%llx\n",
                             (unsigned)byteswritten,
                             (unsigned long long)bufferlength);
        }
@@ -376,11 +373,11 @@ check_buffers(unsigned offset, unsigned size)
                if (n) {
                        prt("\t0x%5x\n", n);
                        if (bad)
-                               prt("operation# (mod 256) for the bad data
-may be %u\n", ((unsigned)op & 0xff));
+                               prt("operation# (mod 256) for the bad data"
+                                       "may be %u\n", ((unsigned)op & 0xff));
                        else
-                               prt("operation# (mod 256) for the bad data
-unknown, check HOLE and EXTEND ops\n");
+                               prt("operation# (mod 256) for the bad data"
+                                       "unknown, check HOLE and EXTEND ops\n");
                } else
                        prt("????????????????\n");
                report_failure(110);
@@ -527,11 +524,18 @@ domapread(unsigned offset, unsigned size)
        pg_offset = offset & page_mask;
        map_size  = pg_offset + size;
 
-       if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd,
-                             (off_t)(offset - pg_offset))) == (char *)-1) {
+       if ((p = mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd,
+                     (off_t)(offset - pg_offset))) == MAP_FAILED) {
                prterr("domapread: mmap");
                report_failure(190);
        }
+       if (!quiet && (debug > 1 &&
+                       (monitorstart == -1 ||
+                        (offset + size > monitorstart &&
+                         (monitorend == -1 || offset <= monitorend))))) {
+               gettimeofday(&t, NULL);
+               prt("       %lu.%06lu mmap done\n", t.tv_sec, t.tv_usec);
+       }
        memcpy(temp_buf, p + pg_offset, size);
        if (!quiet && (debug > 1 &&
                        (monitorstart == -1 ||
@@ -683,16 +687,29 @@ domapwrite(unsigned offset, unsigned size)
                        prterr("domapwrite: ftruncate");
                        exit(201);
                }
+               if (!quiet && (debug > 1 &&
+                              (monitorstart == -1 ||
+                               (offset + size > monitorstart &&
+                                (monitorend == -1 || offset <= monitorend))))) {
+                       gettimeofday(&t, NULL);
+                       prt("       %lu.%06lu truncate done\n", t.tv_sec, t.tv_usec);
+       }
        }
        pg_offset = offset & page_mask;
        map_size  = pg_offset + size;
 
-       if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
-                             MAP_FILE | MAP_SHARED, fd,
-                             (off_t)(offset - pg_offset))) == (char *)-1) {
+       if ((p = mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_FILE|MAP_SHARED,
+                     fd, (off_t)(offset - pg_offset))) == MAP_FAILED) {
                prterr("domapwrite: mmap");
                report_failure(202);
        }
+       if (!quiet && (debug > 1 &&
+                       (monitorstart == -1 ||
+                        (offset + size > monitorstart &&
+                         (monitorend == -1 || offset <= monitorend))))) {
+               gettimeofday(&t, NULL);
+               prt("       %lu.%06lu mmap done\n", t.tv_sec, t.tv_usec);
+       }
        memcpy(p + pg_offset, good_buf + offset, size);
        if (!quiet && (debug > 1 &&
                        (monitorstart == -1 ||
@@ -800,9 +817,9 @@ docloseopen(void)
        if (testcalls <= simulatedopcount)
                return;
 
+       gettimeofday(&t, NULL);
        log4(OP_CLOSEOPEN, file_size, (unsigned)file_size, 0, &t);
 
-       gettimeofday(&t, NULL);
        if (debug)
                prt("%06lu %lu.%06lu close/open\n", testcalls, t.tv_sec,
                    t.tv_usec);
@@ -821,7 +838,7 @@ docloseopen(void)
        }
        if (!quiet && debug > 1) {
                gettimeofday(&t, NULL);
-               prt("       %lu.%06lu opendone\n", t.tv_sec, t.tv_usec);
+               prt("       %lu.%06lu open done\n", t.tv_sec, t.tv_usec);
        }
 }
 
@@ -844,9 +861,6 @@ test(void)
 
        testcalls++;
 
-       if (closeprob)
-               closeopen = (rv >> 3) < (1 << 28) / closeprob;
-
        if (debugstart > 0 && testcalls >= debugstart)
                debug = 1;
 
@@ -893,7 +907,7 @@ test(void)
        }
        if (sizechecks && testcalls > simulatedopcount)
                check_size();
-       if (closeopen)
+       if (closeprob && (rv >> 3) < (1 << 28) / closeprob)
                docloseopen();
 }
 
@@ -913,33 +927,33 @@ void
 usage(void)
 {
        fprintf(stdout, "usage: %s",
-               "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m
-start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t
-truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed]
-fname\n\
-       -b opnum: beginning operation number (default 1)\n\
-       -c P: 1 in P chance of file close+open at each op (default infinity)\n\
-       -d: debug output for all operations [-d -d = more debugging]\n\
-       -l flen: the upper bound on file size (default 262144)\n\
-       -m startop:endop: monitor (print debug output) specified byte range
-(default 0:infinity)\n\
-       -n: no verifications of file size\n\
-       -o oplen: the upper bound on operation size (default 65536)\n\
-       -p progressinterval: debug output at specified operation interval\n\
-       -q: quieter operation\n\
-       -r readbdy: 4096 would make reads page aligned (default 1)\n\
-       -s style: 1 gives smaller truncates (default 0)\n\
-       -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
-       -w writebdy: 4096 would make writes page aligned (default 1)\n\
-       -D startingop: debug output starting at specified operation\n\
-       -L: fsxLite - no file creations & no file size changes\n\
-       -N numops: total # operations to do (default infinity)\n\
-       -O: use oplen (see -o flag) for every op (default random)\n\
-       -P: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
-       -S seed: for random # generator (default 1) 0 gets timestamp\n\
-       -W: mapped write operations DISabled\n\
-        -R: read() system calls only (mapped reads disabled)\n\
-       fname: this filename is REQUIRED (no default)\n");
+               "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m "
+"start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t "
+"truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] "
+"fname\n"
+"      -b opnum: beginning operation number (default 1)\n"
+"      -c P: 1 in P chance of file close+open at each op (default infinity)\n"
+"      -d: debug output for all operations [-d -d = more debugging]\n"
+"      -l flen: the upper bound on file size (default 262144)\n"
+"      -m startop:endop: monitor (print debug output) specified byte rang"
+"(default 0:infinity)\n"
+"      -n: no verifications of file size\n"
+"      -o oplen: the upper bound on operation size (default 65536)\n"
+"      -p progressinterval: debug output at specified operation interval\n"
+"      -q: quieter operation\n"
+"      -r readbdy: 4096 would make reads page aligned (default 1)\n"
+"      -s style: 1 gives smaller truncates (default 0)\n"
+"      -t truncbdy: 4096 would make truncates page aligned (default 1)\n"
+"      -w writebdy: 4096 would make writes page aligned (default 1)\n"
+"      -D startingop: debug output starting at specified operation\n"
+"      -L: fsxLite - no file creations & no file size changes\n"
+"      -N numops: total # operations to do (default infinity)\n"
+"      -O: use oplen (see -o flag) for every op (default random)\n"
+"      -P: save .fsxlog and .fsxgood files in dirpath (default ./)\n"
+"      -S seed: for random # generator (default 1) 0 gets timestamp\n"
+"      -W: mapped write operations DISabled\n"
+"        -R: read() system calls only (mapped reads disabled)\n"
+"      fname: this filename is REQUIRED (no default)\n");
        exit(90);
 }
 
@@ -1006,8 +1020,8 @@ main(int argc, char **argv)
                case 'b':
                        simulatedopcount = getnum(optarg, &endp);
                        if (!quiet)
-                               fprintf(stdout, "Will begin at operation
-%ld\n",
+                               fprintf(stdout, "Will begin at operation"
+                                       "%ld\n",
                                        simulatedopcount);
                        if (simulatedopcount == 0)
                                usage();
@@ -1192,8 +1206,8 @@ main(int argc, char **argv)
                                prterr(fname);
                                warn("main: error on write");
                        } else
-                               warn("main: short write, 0x%x bytes instead
-of 0x%x\n",
+                               warn("main: short write, 0x%x bytes instead"
+                                       "of 0x%x\n",
                                     (unsigned)written, maxfilelen);
                        exit(98);
                }