fsx: fix infinite/too long loops when generating ranges for clone operations
[xfstests-dev.git] / ltp / fsx.c
index e7a88c042df7579f18fc59c26f5b275d5009708a..ab64b50ac2132e4d2fb4d7d81f3265495f29b3de 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -34,6 +34,7 @@
 #ifdef AIO
 #include <libaio.h>
 #endif
+#include <sys/syscall.h>
 
 #ifndef MAP_FILE
 # define MAP_FILE 0
@@ -106,6 +107,7 @@ enum {
        OP_INSERT_RANGE,
        OP_CLONE_RANGE,
        OP_DEDUPE_RANGE,
+       OP_COPY_RANGE,
        OP_MAX_FULL,
 
        /* integrity operations */
@@ -133,12 +135,12 @@ int       fd;                             /* fd for our test file */
 blksize_t      block_size = 0;
 off_t          file_size = 0;
 off_t          biggest = 0;
-unsigned long  testcalls = 0;          /* calls to function "test" */
+long long      testcalls = 0;          /* calls to function "test" */
 
-unsigned long  simulatedopcount = 0;   /* -b flag */
+long long      simulatedopcount = 0;   /* -b flag */
 int    closeprob = 0;                  /* -c flag */
 int    debug = 0;                      /* -d flag */
-unsigned long  debugstart = 0;         /* -D flag */
+long long      debugstart = 0;         /* -D flag */
 char   filldata = 0;                   /* -g flag */
 int    flush = 0;                      /* -f flag */
 int    do_fsync = 0;                   /* -y flag */
@@ -146,7 +148,7 @@ unsigned long       maxfilelen = 256 * 1024;        /* -l flag */
 int    sizechecks = 1;                 /* -n flag disables them */
 int    maxoplen = 64 * 1024;           /* -o flag */
 int    quiet = 0;                      /* -q flag */
-unsigned long progressinterval = 0;    /* -p flag */
+long long      progressinterval = 0;   /* -p flag */
 int    readbdy = 1;                    /* -r flag */
 int    style = 0;                      /* -s flag */
 int    prealloc = 0;                   /* -x flag */
@@ -155,7 +157,7 @@ int writebdy = 1;                   /* -w flag */
 long   monitorstart = -1;              /* -m flag */
 long   monitorend = -1;                /* -m flag */
 int    lite = 0;                       /* -L flag */
-long   numops = -1;                    /* -N flag */
+long long numops = -1;                 /* -N flag */
 int    randomoplen = 1;                /* -O flag disables it */
 int    seed = 1;                       /* -S flag */
 int     mapped_writes = 1;              /* -W flag disables */
@@ -169,6 +171,7 @@ int mapped_reads = 1;               /* -R flag disables it */
 int    check_file = 0;                 /* -X flag enables */
 int    clone_range_calls = 1;          /* -J flag disables */
 int    dedupe_range_calls = 1;         /* -B flag disables */
+int    copy_range_calls = 1;           /* -E flag disables */
 int    integrity = 0;                  /* -i flag */
 int    fsxgoodfd = 0;
 int    o_direct;                       /* -Z */
@@ -264,6 +267,7 @@ static const char *op_names[] = {
        [OP_INSERT_RANGE] = "insert_range",
        [OP_CLONE_RANGE] = "clone_range",
        [OP_DEDUPE_RANGE] = "dedupe_range",
+       [OP_COPY_RANGE] = "copy_range",
        [OP_FSYNC] = "fsync",
 };
 
@@ -477,6 +481,20 @@ logdump(void)
                        else if (overlap2)
                                prt("\t******BBBB");
                        break;
+               case OP_COPY_RANGE:
+                       prt("COPY 0x%x thru 0x%x\t(0x%x bytes) to 0x%x thru 0x%x",
+                           lp->args[0], lp->args[0] + lp->args[1] - 1,
+                           lp->args[1],
+                           lp->args[2], lp->args[2] + lp->args[1] - 1);
+                       overlap2 = badoff >= lp->args[2] &&
+                                 badoff < lp->args[2] + lp->args[1];
+                       if (overlap && overlap2)
+                               prt("\tEEEE**EEEE");
+                       else if (overlap)
+                               prt("\tEEEE******");
+                       else if (overlap2)
+                               prt("\t******EEEE");
+                       break;
                case OP_FSYNC:
                        prt("FSYNC");
                        break;
@@ -770,7 +788,7 @@ doread(unsigned offset, unsigned size)
                       (monitorstart == -1 ||
                        (offset + size > monitorstart &&
                        (monitorend == -1 || offset <= monitorend))))))
-               prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+               prt("%lld read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
                    offset, offset + size - 1, size);
        ret = lseek(fd, (off_t)offset, SEEK_SET);
        if (ret == (off_t)-1) {
@@ -907,7 +925,7 @@ domapread(unsigned offset, unsigned size)
                       (monitorstart == -1 ||
                        (offset + size > monitorstart &&
                        (monitorend == -1 || offset <= monitorend))))))
-               prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+               prt("%lld mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
                    offset, offset + size - 1, size);
 
        pg_offset = offset & PAGE_MASK;
@@ -985,7 +1003,7 @@ dowrite(unsigned offset, unsigned size)
                       (monitorstart == -1 ||
                        (offset + size > monitorstart &&
                        (monitorend == -1 || offset <= monitorend))))))
-               prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+               prt("%lld write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
                    offset, offset + size - 1, size);
        ret = lseek(fd, (off_t)offset, SEEK_SET);
        if (ret == (off_t)-1) {
@@ -1052,7 +1070,7 @@ domapwrite(unsigned offset, unsigned size)
                       (monitorstart == -1 ||
                        (offset + size > monitorstart &&
                        (monitorend == -1 || offset <= monitorend))))))
-               prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+               prt("%lld mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
                    offset, offset + size - 1, size);
 
        if (file_size > cur_filesize) {
@@ -1105,11 +1123,12 @@ dotruncate(unsigned size)
 
        if (testcalls <= simulatedopcount)
                return;
-       
+
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                      size <= monitorend)))
-               prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
+               prt("%lld trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize,
+                               size);
        if (ftruncate(fd, (off_t)size) == -1) {
                prt("ftruncate1: %x\n", size);
                prterr("dotruncate: ftruncate");
@@ -1150,7 +1169,7 @@ do_punch_hole(unsigned offset, unsigned length)
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                      end_offset <= monitorend))) {
-               prt("%lu punch\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+               prt("%lld punch\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
                        offset, offset+length, length);
        }
        if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
@@ -1181,6 +1200,9 @@ do_zero_range(unsigned offset, unsigned length, int keep_size)
        unsigned end_offset;
        int mode = FALLOC_FL_ZERO_RANGE;
 
+       if (keep_size)
+               mode |= FALLOC_FL_KEEP_SIZE;
+
        if (length == 0) {
                if (!quiet && testcalls > simulatedopcount)
                        prt("skipping zero length zero range\n");
@@ -1212,7 +1234,7 @@ do_zero_range(unsigned offset, unsigned length, int keep_size)
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                      end_offset <= monitorend))) {
-               prt("%lu zero\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+               prt("%lld zero\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
                        offset, offset+length, length);
        }
        if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
@@ -1222,6 +1244,17 @@ do_zero_range(unsigned offset, unsigned length, int keep_size)
        }
 
        memset(good_buf + offset, '\0', length);
+
+       if (!keep_size && end_offset > file_size) {
+               /*
+                * If there's a gap between the old file size and the offset of
+                * the zero range operation, fill the gap with zeroes.
+                */
+               if (offset > file_size)
+                       memset(good_buf + file_size, '\0', offset - file_size);
+
+               file_size = end_offset;
+       }
 }
 
 #else
@@ -1262,8 +1295,8 @@ do_collapse_range(unsigned offset, unsigned length)
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                      end_offset <= monitorend))) {
-               prt("%lu collapse\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
-                       offset, offset+length, length);
+               prt("%lld collapse\tfrom 0x%x to 0x%x, (0x%x bytes)\n",
+                               testcalls, offset, offset+length, length);
        }
        if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
                prt("collapse range: 0x%x to 0x%x\n", offset, offset + length);
@@ -1314,7 +1347,7 @@ do_insert_range(unsigned offset, unsigned length)
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                      end_offset <= monitorend))) {
-               prt("%lu insert\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+               prt("%lld insert\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
                        offset, offset+length, length);
        }
        if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
@@ -1346,7 +1379,7 @@ test_clone_range(void)
        };
 
        if (ioctl(fd, FICLONERANGE, &fcr) &&
-           (errno = EOPNOTSUPP || errno == ENOTTY)) {
+           (errno == EOPNOTSUPP || errno == ENOTTY)) {
                if (!quiet)
                        fprintf(stderr,
                                "main: filesystem does not support "
@@ -1464,7 +1497,8 @@ test_dedupe_range(void)
        else
                error = 0;
 
-       if (error == EOPNOTSUPP || error == ENOTTY) {
+       /* Older kernels may return EINVAL... */
+       if (error == EOPNOTSUPP || error == ENOTTY || error == EINVAL) {
                if (!quiet)
                        fprintf(stderr,
                                "main: filesystem does not support "
@@ -1558,6 +1592,110 @@ do_dedupe_range(unsigned offset, unsigned length, unsigned dest)
 }
 #endif
 
+#ifdef HAVE_COPY_FILE_RANGE
+int
+test_copy_range(void)
+{
+       loff_t o1 = 0, o2 = 1;
+
+       if (syscall(__NR_copy_file_range, fd, &o1, fd, &o2, 1, 0) == -1 &&
+           (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTTY)) {
+               if (!quiet)
+                       fprintf(stderr,
+                               "main: filesystem does not support "
+                               "copy range, disabling!\n");
+               return 0;
+       }
+
+       return 1;
+}
+
+void
+do_copy_range(unsigned offset, unsigned length, unsigned dest)
+{
+       loff_t o1, o2;
+       size_t olen;
+       ssize_t nr;
+       int tries = 0;
+
+       if (length == 0) {
+               if (!quiet && testcalls > simulatedopcount)
+                       prt("skipping zero length copy range\n");
+               log5(OP_COPY_RANGE, offset, length, dest, FL_SKIPPED);
+               return;
+       }
+
+       if ((loff_t)offset >= file_size) {
+               if (!quiet && testcalls > simulatedopcount)
+                       prt("skipping copy range behind EOF\n");
+               log5(OP_COPY_RANGE, offset, length, dest, FL_SKIPPED);
+               return;
+       }
+
+       if (dest + length > biggest) {
+               biggest = dest + length;
+               if (!quiet && testcalls > simulatedopcount)
+                       prt("copying to largest ever: 0x%x\n", dest + length);
+       }
+
+       log5(OP_COPY_RANGE, offset, length, dest, FL_NONE);
+
+       if (testcalls <= simulatedopcount)
+               return;
+
+       if ((progressinterval && testcalls % progressinterval == 0) ||
+           (debug && (monitorstart == -1 || monitorend == -1 ||
+                      dest <= monitorstart || dest + length <= monitorend))) {
+               prt("%lu copy\tfrom 0x%x to 0x%x, (0x%x bytes) at 0x%x\n",
+                       testcalls, offset, offset+length, length, dest);
+       }
+
+       o1 = offset;
+       o2 = dest;
+       olen = length;
+
+       while (olen > 0) {
+               nr = syscall(__NR_copy_file_range, fd, &o1, fd, &o2, olen, 0);
+               if (nr < 0) {
+                       if (errno != EAGAIN || tries++ >= 300)
+                               break;
+               } else if (nr > olen) {
+                       prt("copy range: 0x%x to 0x%x at 0x%x\n", offset,
+                                       offset + length, dest);
+                       prt("do_copy_range: asked %u, copied %u??\n",
+                                       nr, olen);
+                       report_failure(161);
+               } else if (nr > 0)
+                       olen -= nr;
+       }
+       if (nr < 0) {
+               prt("copy range: 0x%x to 0x%x at 0x%x\n", offset,
+                               offset + length, dest);
+               prterr("do_copy_range:");
+               report_failure(161);
+       }
+
+       memcpy(good_buf + dest, good_buf + offset, length);
+       if (dest > file_size)
+               memset(good_buf + file_size, '\0', dest - file_size);
+       if (dest + length > file_size)
+               file_size = dest + length;
+}
+
+#else
+int
+test_copy_range(void)
+{
+       return 0;
+}
+
+void
+do_copy_range(unsigned offset, unsigned length, unsigned dest)
+{
+       return;
+}
+#endif
+
 #ifdef HAVE_LINUX_FALLOC_H
 /* fallocate is basically a no-op unless extending, then a lot like a truncate */
 void
@@ -1601,7 +1739,7 @@ do_preallocate(unsigned offset, unsigned length, int keep_size)
        if ((progressinterval && testcalls % progressinterval == 0) ||
            (debug && (monitorstart == -1 || monitorend == -1 ||
                      end_offset <= monitorend)))
-               prt("%lu falloc\tfrom 0x%x to 0x%x (0x%x bytes)\n", testcalls,
+               prt("%lld falloc\tfrom 0x%x to 0x%x (0x%x bytes)\n", testcalls,
                                offset, offset + length, length);
        if (fallocate(fd, keep_size ? FALLOC_FL_KEEP_SIZE : 0, (loff_t)offset, (loff_t)length) == -1) {
                prt("fallocate: 0x%x to 0x%x\n", offset, offset + length);
@@ -1650,15 +1788,19 @@ docloseopen(void)
                return;
 
        if (debug)
-               prt("%lu close/open\n", testcalls);
+               prt("%lld close/open\n", testcalls);
        if (close(fd)) {
                prterr("docloseopen: close");
                report_failure(180);
        }
+       if (system("echo 3 > /proc/sys/vm/drop_caches")) {
+               prterr("docloseopen: drop_caches");
+               report_failure(181);
+       }
        fd = open(fname, O_RDWR|o_direct, 0);
        if (fd < 0) {
                prterr("docloseopen: open");
-               report_failure(181);
+               report_failure(182);
        }
 }
 
@@ -1670,7 +1812,7 @@ dofsync(void)
        if (testcalls <= simulatedopcount)
                return;
        if (debug)
-               prt("%lu fsync\n", testcalls);
+               prt("%lld fsync\n", testcalls);
        log4(OP_FSYNC, 0, 0, 0);
        ret = fsync(fd);
        if (ret < 0) {
@@ -1707,7 +1849,7 @@ cleanup(int sig)
 {
        if (sig)
                prt("signal %d\n", sig);
-       prt("testcalls = %lu\n", testcalls);
+       prt("testcalls = %lld\n", testcalls);
        exit(sig);
 }
 
@@ -1717,6 +1859,7 @@ op_args_count(int operation)
        switch (operation) {
        case OP_CLONE_RANGE:
        case OP_DEDUPE_RANGE:
+       case OP_COPY_RANGE:
                return 4;
        default:
                return 3;
@@ -1787,6 +1930,14 @@ fail:
        return 0;
 }
 
+static inline bool
+range_overlaps(
+       unsigned long   off0,
+       unsigned long   off1,
+       unsigned long   size)
+{
+       return llabs((unsigned long long)off1 - off0) < size;
+}
 
 int
 test(void)
@@ -1806,7 +1957,7 @@ test(void)
                debug = 1;
 
        if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
-               prt("%lu...\n", testcalls);
+               prt("%lld...\n", testcalls);
 
        if (replayopsf) {
                struct log_entry log_entry;
@@ -1862,16 +2013,24 @@ test(void)
                        keep_size = random() % 2;
                break;
        case OP_CLONE_RANGE:
-               TRIM_OFF_LEN(offset, size, file_size);
-               offset = offset & ~(block_size - 1);
-               size = size & ~(block_size - 1);
-               do {
-                       offset2 = random();
-                       TRIM_OFF(offset2, maxfilelen);
-                       offset2 = offset2 & ~(block_size - 1);
-               } while (llabs(offset2 - offset) < size ||
-                        offset2 + size > maxfilelen);
-               break;
+               {
+                       int tries = 0;
+
+                       TRIM_OFF_LEN(offset, size, file_size);
+                       offset = offset & ~(block_size - 1);
+                       size = size & ~(block_size - 1);
+                       do {
+                               if (tries++ >= 30) {
+                                       size = 0;
+                                       break;
+                               }
+                               offset2 = random();
+                               TRIM_OFF(offset2, maxfilelen);
+                               offset2 = offset2 & ~(block_size - 1);
+                       } while (range_overlaps(offset, offset2, size) ||
+                                offset2 + size > maxfilelen);
+                       break;
+               }
        case OP_DEDUPE_RANGE:
                {
                        int tries = 0;
@@ -1887,10 +2046,22 @@ test(void)
                                offset2 = random();
                                TRIM_OFF(offset2, file_size);
                                offset2 = offset2 & ~(block_size - 1);
-                       } while (llabs(offset2 - offset) < size ||
+                       } while (range_overlaps(offset, offset2, size) ||
                                 offset2 + size > file_size);
                        break;
                }
+       case OP_COPY_RANGE:
+               TRIM_OFF_LEN(offset, size, file_size);
+               offset -= offset % readbdy;
+               if (o_direct)
+                       size -= size % readbdy;
+               do {
+                       offset2 = random();
+                       TRIM_OFF(offset2, maxfilelen);
+                       offset2 -= offset2 % writebdy;
+               } while (range_overlaps(offset, offset2, size) ||
+                        offset2 + size > maxfilelen);
+               break;
        }
 
 have_op:
@@ -1946,6 +2117,12 @@ have_op:
                        goto out;
                }
                break;
+       case OP_COPY_RANGE:
+               if (!copy_range_calls) {
+                       log5(op, offset, size, offset2, FL_SKIPPED);
+                       goto out;
+               }
+               break;
        }
 
        switch (op) {
@@ -1983,7 +2160,7 @@ have_op:
                do_punch_hole(offset, size);
                break;
        case OP_ZERO_RANGE:
-               TRIM_OFF_LEN(offset, size, file_size);
+               TRIM_OFF_LEN(offset, size, maxfilelen);
                do_zero_range(offset, size, keep_size);
                break;
        case OP_COLLAPSE_RANGE:
@@ -2036,6 +2213,18 @@ have_op:
 
                do_dedupe_range(offset, size, offset2);
                break;
+       case OP_COPY_RANGE:
+               if (size == 0) {
+                       log5(OP_COPY_RANGE, offset, size, offset2, FL_SKIPPED);
+                       goto out;
+               }
+               if (offset2 + size > maxfilelen) {
+                       log5(OP_COPY_RANGE, offset, size, offset2, FL_SKIPPED);
+                       goto out;
+               }
+
+               do_copy_range(offset, size, offset2);
+               break;
        case OP_FSYNC:
                dofsync();
                break;
@@ -2049,10 +2238,10 @@ have_op:
                check_contents();
 
 out:
-       if (sizechecks && testcalls > simulatedopcount)
-               check_size();
        if (closeopen)
                docloseopen();
+       if (sizechecks && testcalls > simulatedopcount)
+               check_size();
        return 1;
 }
 
@@ -2061,7 +2250,7 @@ void
 usage(void)
 {
        fprintf(stdout, "usage: %s",
-               "fsx [-dknqxABFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-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\
+               "fsx [-dknqxABEFJLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-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\n\
@@ -2108,6 +2297,9 @@ usage(void)
 #ifdef FIDEDUPERANGE
 "      -B: Do not use dedupe range calls\n"
 #endif
+#ifdef HAVE_COPY_FILE_RANGE
+"      -E: Do not use copy range calls\n"
+#endif
 "      -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\
@@ -2124,13 +2316,13 @@ usage(void)
 }
 
 
-int
+long long
 getnum(char *s, char **e)
 {
-       int ret;
+       long long ret;
 
        *e = (char *) 0;
-       ret = strtol(s, e, 0);
+       ret = strtoll(s, e, 0);
        if (*e)
                switch (**e) {
                case 'b':
@@ -2267,7 +2459,8 @@ __test_fallocate(int mode, const char *mode_str)
 #ifdef HAVE_LINUX_FALLOC_H
        int ret = 0;
        if (!lite) {
-               if (fallocate(fd, mode, file_size, 1) && errno == EOPNOTSUPP) {
+               if (fallocate(fd, mode, file_size, 1) &&
+                   (errno == ENOSYS || errno == EOPNOTSUPP)) {
                        if(!quiet)
                                fprintf(stderr,
                                        "main: filesystem does not support "
@@ -2311,13 +2504,14 @@ main(int argc, char **argv)
        setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
        while ((ch = getopt_long(argc, argv,
-                                "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyABD:FJKHzCILN:OP:RS:WXZ",
+                                "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyABD:EFJKHzCILN:OP:RS:WXZ",
                                 longopts, NULL)) != EOF)
                switch (ch) {
                case 'b':
                        simulatedopcount = getnum(optarg, &endp);
                        if (!quiet)
-                               prt("Will begin at operation %ld\n", simulatedopcount);
+                               prt("Will begin at operation %lld\n",
+                                               simulatedopcount);
                        if (simulatedopcount == 0)
                                usage();
                        simulatedopcount -= 1;
@@ -2447,6 +2641,9 @@ main(int argc, char **argv)
                case 'B':
                        dedupe_range_calls = 0;
                        break;
+               case 'E':
+                       copy_range_calls = 0;
+                       break;
                case 'L':
                        lite = 1;
                        o_flags &= ~(O_CREAT|O_TRUNC);
@@ -2669,6 +2866,8 @@ main(int argc, char **argv)
                clone_range_calls = test_clone_range();
        if (dedupe_range_calls)
                dedupe_range_calls = test_dedupe_range();
+       if (copy_range_calls)
+               copy_range_calls = test_copy_range();
 
        while (numops == -1 || numops--)
                if (!test())
@@ -2679,7 +2878,7 @@ main(int argc, char **argv)
                prterr("close");
                report_failure(99);
        }
-       prt("All %lu operations completed A-OK!\n", testcalls);
+       prt("All %lld operations completed A-OK!\n", testcalls);
        if (recordops)
                logdump();