2 * Copyright (C) 1991, NeXT Computer, Inc. All Rights Reserverd.
5 * Author: Avadis Tevanian, Jr.
7 * File system exerciser.
9 * Rewritten 8/98 by Conrad Minshall.
11 * Small changes to work under Linux -- davej.
13 * Checks for mmap last-page zero fill.
42 #define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */
46 enum opflags { FL_NONE = 0, FL_SKIPPED = 1, FL_CLOSE_OPEN = 2, FL_KEEP_SIZE = 4 };
49 * A log entry is an operation and a bunch of arguments.
60 struct log_entry oplog[LOGSIZE]; /* the log */
61 int logptr = 0; /* current position in log */
62 int logcount = 0; /* total ops */
65 * The operation matrix is complex due to conditional execution of different
66 * features. Hence when we come to deciding what operation to run, we need to
67 * be careful in how we select the different operations. The active operations
68 * are mapped to numbers as follows:
70 * lite !lite integrity
79 * COLLAPSE RANGE: - 8 8
82 * When mapped read/writes are disabled, they are simply converted to normal
83 * reads and writes. When fallocate/fpunch calls are disabled, they are
86 * Because of the "lite" version, we also need to have different "maximum
87 * operation" defines to allow the ops to be selected correctly based on the
91 /* common operations */
98 /* !lite operations */
100 #define OP_FALLOCATE 5
101 #define OP_PUNCH_HOLE 6
102 #define OP_ZERO_RANGE 7
103 #define OP_COLLAPSE_RANGE 8
104 #define OP_INSERT_RANGE 9
105 #define OP_MAX_FULL 10
107 /* integrity operations */
109 #define OP_MAX_INTEGRITY 11
112 #define PAGE_SIZE getpagesize()
114 #define PAGE_MASK (PAGE_SIZE - 1)
116 char *original_buf; /* a pointer to the original data */
117 char *good_buf; /* a pointer to the correct data */
118 char *temp_buf; /* a pointer to the current data */
119 char *fname; /* name of our test file */
120 char *bname; /* basename of our test file */
121 char *logdev; /* -i flag */
122 char *logid; /* -j flag */
123 char dname[1024]; /* -P flag */
124 int dirpath = 0; /* -P flag */
125 int fd; /* fd for our test file */
127 blksize_t block_size = 0;
130 unsigned long testcalls = 0; /* calls to function "test" */
132 unsigned long simulatedopcount = 0; /* -b flag */
133 int closeprob = 0; /* -c flag */
134 int debug = 0; /* -d flag */
135 unsigned long debugstart = 0; /* -D flag */
136 char filldata = 0; /* -g flag */
137 int flush = 0; /* -f flag */
138 int do_fsync = 0; /* -y flag */
139 unsigned long maxfilelen = 256 * 1024; /* -l flag */
140 int sizechecks = 1; /* -n flag disables them */
141 int maxoplen = 64 * 1024; /* -o flag */
142 int quiet = 0; /* -q flag */
143 unsigned long progressinterval = 0; /* -p flag */
144 int readbdy = 1; /* -r flag */
145 int style = 0; /* -s flag */
146 int prealloc = 0; /* -x flag */
147 int truncbdy = 1; /* -t flag */
148 int writebdy = 1; /* -w flag */
149 long monitorstart = -1; /* -m flag */
150 long monitorend = -1; /* -m flag */
151 int lite = 0; /* -L flag */
152 long numops = -1; /* -N flag */
153 int randomoplen = 1; /* -O flag disables it */
154 int seed = 1; /* -S flag */
155 int mapped_writes = 1; /* -W flag disables */
156 int fallocate_calls = 1; /* -F flag disables */
157 int keep_size_calls = 1; /* -K flag disables */
158 int punch_hole_calls = 1; /* -H flag disables */
159 int zero_range_calls = 1; /* -z flag disables */
160 int collapse_range_calls = 1; /* -C flag disables */
161 int insert_range_calls = 1; /* -I flag disables */
162 int mapped_reads = 1; /* -R flag disables it */
163 int integrity = 0; /* -i flag */
165 int o_direct; /* -Z */
173 int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset);
176 #define fsxread(a,b,c,d) aio_rw(READ, a,b,c,d)
177 #define fsxwrite(a,b,c,d) aio_rw(WRITE, a,b,c,d)
179 #define fsxread(a,b,c,d) read(a,b,c)
180 #define fsxwrite(a,b,c,d) write(a,b,c)
183 const char *replayops = NULL;
184 const char *recordops = NULL;
185 FILE * fsxlogf = NULL;
186 FILE * replayopsf = NULL;
191 static void *round_ptr_up(void *ptr, unsigned long align, unsigned long offset)
193 unsigned long ret = (unsigned long)ptr;
195 ret = ((ret + align - 1) & ~(align - 1));
201 vwarnc(int code, const char *fmt, va_list ap)
204 fprintf(stderr, "%s: ", logid);
205 fprintf(stderr, "fsx: ");
207 vfprintf(stderr, fmt, ap);
208 fprintf(stderr, ": ");
210 fprintf(stderr, "%s\n", strerror(code));
214 warn(const char * fmt, ...) {
217 vwarnc(errno, fmt, ap);
222 prt(const char *fmt, ...)
227 fprintf(stdout, "%s: ", logid);
229 vfprintf(stdout, fmt, args);
233 vfprintf(fsxlogf, fmt, args);
239 prterr(const char *prefix)
241 prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
245 static const char *op_names[] = {
247 [OP_WRITE] = "write",
248 [OP_MAPREAD] = "mapread",
249 [OP_MAPWRITE] = "mapwrite",
250 [OP_TRUNCATE] = "truncate",
251 [OP_FALLOCATE] = "fallocate",
252 [OP_PUNCH_HOLE] = "punch_hole",
253 [OP_ZERO_RANGE] = "zero_range",
254 [OP_COLLAPSE_RANGE] = "collapse_range",
255 [OP_INSERT_RANGE] = "insert_range",
256 [OP_FSYNC] = "fsync",
259 static const char *op_name(int operation)
261 if (operation >= 0 &&
262 operation < sizeof(op_names) / sizeof(op_names[0]))
263 return op_names[operation];
267 static int op_code(const char *name)
271 for (i = 0; i < sizeof(op_names) / sizeof(op_names[0]); i++)
272 if (op_names[i] && strcmp(name, op_names[i]) == 0)
278 log4(int operation, int arg0, int arg1, enum opflags flags)
280 struct log_entry *le;
283 le->operation = operation;
285 flags |= FL_CLOSE_OPEN;
288 le->args[2] = file_size;
292 if (logptr >= LOGSIZE)
302 struct log_entry *lp;
304 prt("LOG DUMP (%d total operations):\n", logcount);
306 logopsf = fopen(opsfile, "w");
310 if (logcount < LOGSIZE) {
317 for ( ; count > 0; count--) {
321 opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
322 prt("%d(%3d mod 256): ", opnum, opnum%256);
325 overlap = badoff >= lp->args[0] &&
326 badoff < lp->args[0] + lp->args[1];
328 if (lp->flags & FL_SKIPPED) {
329 prt("SKIPPED (no operation)");
333 switch (lp->operation) {
335 prt("MAPREAD 0x%x thru 0x%x\t(0x%x bytes)",
336 lp->args[0], lp->args[0] + lp->args[1] - 1,
342 prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
343 lp->args[0], lp->args[0] + lp->args[1] - 1,
349 prt("READ 0x%x thru 0x%x\t(0x%x bytes)",
350 lp->args[0], lp->args[0] + lp->args[1] - 1,
356 prt("WRITE 0x%x thru 0x%x\t(0x%x bytes)",
357 lp->args[0], lp->args[0] + lp->args[1] - 1,
359 if (lp->args[0] > lp->args[2])
361 else if (lp->args[0] + lp->args[1] > lp->args[2])
363 overlap = (badoff >= lp->args[0] ||
364 badoff >=lp->args[2]) &&
365 badoff < lp->args[0] + lp->args[1];
370 down = lp->args[1] < lp->args[2];
371 prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
372 down ? "DOWN" : "UP", lp->args[2], lp->args[1]);
373 overlap = badoff >= lp->args[1 + !down] &&
374 badoff < lp->args[1 + !!down];
379 /* 0: offset 1: length 2: where alloced */
380 prt("FALLOC 0x%x thru 0x%x\t(0x%x bytes) ",
381 lp->args[0], lp->args[0] + lp->args[1],
383 if (lp->args[0] + lp->args[1] <= lp->args[2])
385 else if (lp->flags & FL_KEEP_SIZE)
393 prt("PUNCH 0x%x thru 0x%x\t(0x%x bytes)",
394 lp->args[0], lp->args[0] + lp->args[1] - 1,
400 prt("ZERO 0x%x thru 0x%x\t(0x%x bytes)",
401 lp->args[0], lp->args[0] + lp->args[1] - 1,
406 case OP_COLLAPSE_RANGE:
407 prt("COLLAPSE 0x%x thru 0x%x\t(0x%x bytes)",
408 lp->args[0], lp->args[0] + lp->args[1] - 1,
413 case OP_INSERT_RANGE:
414 prt("INSERT 0x%x thru 0x%x\t(0x%x bytes)",
415 lp->args[0], lp->args[0] + lp->args[1] - 1,
424 prt("BOGUS LOG ENTRY (operation code = %d)!",
430 if (lp->flags & FL_CLOSE_OPEN)
431 prt("\n\t\tCLOSE/OPEN");
438 if (lp->flags & FL_SKIPPED)
439 fprintf(logopsf, "skip ");
440 fprintf(logopsf, "%s 0x%x 0x%x 0x%x",
441 op_name(lp->operation),
442 lp->args[0], lp->args[1], lp->args[2]);
443 if (lp->flags & FL_KEEP_SIZE)
444 fprintf(logopsf, " keep_size");
445 if (lp->flags & FL_CLOSE_OPEN)
446 fprintf(logopsf, " close_open");
448 fprintf(logopsf, " *");
449 fprintf(logopsf, "\n");
454 if (fclose(logopsf) != 0)
457 prt("Log of operations saved to \"%s\"; "
458 "replay with --replay-ops\n",
465 save_buffer(char *buffer, off_t bufferlength, int fd)
468 ssize_t byteswritten;
470 if (fd <= 0 || bufferlength == 0)
473 if (bufferlength > SSIZE_MAX) {
474 prt("fsx flaw: overflow in save_buffer\n");
478 off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END);
479 if (size_by_seek == (off_t)-1)
480 prterr("save_buffer: lseek eof");
481 else if (bufferlength > size_by_seek) {
482 warn("save_buffer: .fsxgood file too short... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
483 (unsigned long long)bufferlength);
484 bufferlength = size_by_seek;
488 ret = lseek(fd, (off_t)0, SEEK_SET);
489 if (ret == (off_t)-1)
490 prterr("save_buffer: lseek 0");
492 byteswritten = write(fd, buffer, (size_t)bufferlength);
493 if (byteswritten != bufferlength) {
494 if (byteswritten == -1)
495 prterr("save_buffer write");
497 warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n",
498 (unsigned)byteswritten,
499 (unsigned long long)bufferlength);
505 report_failure(int status)
511 save_buffer(good_buf, file_size, fsxgoodfd);
512 prt("Correct content saved for comparison\n");
513 prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
522 #define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
523 *(((unsigned char *)(cp)) + 1)))
531 snprintf(command, 256, "dmsetup message %s 0 mark %s.mark%d", logdev,
533 ret = system(command);
535 prterr("dmsetup mark failed");
541 dump_fsync_buffer(void)
543 char fname_buffer[1024];
549 snprintf(fname_buffer, 1024, "%s%s.mark%d", dname,
551 good_fd = open(fname_buffer, O_WRONLY|O_CREAT|O_TRUNC, 0666);
553 prterr(fname_buffer);
557 save_buffer(good_buf, file_size, good_fd);
559 prt("Dumped fsync buffer to %s\n", fname_buffer + dirpath);
563 check_buffers(unsigned offset, unsigned size)
571 if (memcmp(good_buf + offset, temp_buf, size) != 0) {
572 prt("READ BAD DATA: offset = 0x%x, size = 0x%x, fname = %s\n",
573 offset, size, fname);
574 prt("OFFSET\tGOOD\tBAD\tRANGE\n");
576 c = good_buf[offset];
580 bad = short_at(&temp_buf[i]);
581 prt("0x%05x\t0x%04x\t0x%04x", offset,
582 short_at(&good_buf[offset]), bad);
583 op = temp_buf[offset & 1 ? i+1 : i];
584 prt("\t0x%05x\n", n);
586 prt("operation# (mod 256) for "
587 "the bad data may be %u\n",
588 ((unsigned)op & 0xff));
590 prt("operation# (mod 256) for "
591 "the bad data unknown, check"
592 " HOLE and EXTEND ops\n");
612 if (fstat(fd, &statbuf)) {
613 prterr("check_size: fstat");
614 statbuf.st_size = -1;
616 size_by_seek = lseek(fd, (off_t)0, SEEK_END);
617 if (file_size != statbuf.st_size || file_size != size_by_seek) {
618 prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
619 (unsigned long long)file_size,
620 (unsigned long long)statbuf.st_size,
621 (unsigned long long)size_by_seek);
628 check_trunc_hack(void)
632 if (ftruncate(fd, (off_t)0))
634 if (ftruncate(fd, (off_t)100000))
637 if (statbuf.st_size != (off_t)100000) {
638 prt("no extend on truncate! not posix!\n");
641 if (ftruncate(fd, 0)) {
643 prterr("check_trunc_hack: ftruncate");
649 doflush(unsigned offset, unsigned size)
655 if (o_direct == O_DIRECT)
658 pg_offset = offset & mmap_mask;
659 map_size = pg_offset + size;
661 if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
662 MAP_FILE | MAP_SHARED, fd,
663 (off_t)(offset - pg_offset))) == (char *)-1) {
664 prterr("doflush: mmap");
667 if (msync(p, map_size, MS_INVALIDATE) != 0) {
668 prterr("doflush: msync");
671 if (munmap(p, map_size) != 0) {
672 prterr("doflush: munmap");
678 doread(unsigned offset, unsigned size)
683 offset -= offset % readbdy;
685 size -= size % readbdy;
687 if (!quiet && testcalls > simulatedopcount && !o_direct)
688 prt("skipping zero size read\n");
689 log4(OP_READ, offset, size, FL_SKIPPED);
692 if (size + offset > file_size) {
693 if (!quiet && testcalls > simulatedopcount)
694 prt("skipping seek/read past end of file\n");
695 log4(OP_READ, offset, size, FL_SKIPPED);
699 log4(OP_READ, offset, size, FL_NONE);
701 if (testcalls <= simulatedopcount)
705 ((progressinterval && testcalls % progressinterval == 0) ||
707 (monitorstart == -1 ||
708 (offset + size > monitorstart &&
709 (monitorend == -1 || offset <= monitorend))))))
710 prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
711 offset, offset + size - 1, size);
712 ret = lseek(fd, (off_t)offset, SEEK_SET);
713 if (ret == (off_t)-1) {
714 prterr("doread: lseek");
717 iret = fsxread(fd, temp_buf, size, offset);
720 prterr("doread: read");
722 prt("short read: 0x%x bytes instead of 0x%x\n",
726 check_buffers(offset, size);
731 check_eofpage(char *s, unsigned offset, char *p, int size)
733 unsigned long last_page, should_be_zero;
735 if (offset + size <= (file_size & ~page_mask))
738 * we landed in the last page of the file
739 * test to make sure the VM system provided 0's
740 * beyond the true end of the file mapping
741 * (as required by mmap def in 1996 posix 1003.1)
743 last_page = ((unsigned long)p + (offset & page_mask) + size) & ~page_mask;
745 for (should_be_zero = last_page + (file_size & page_mask);
746 should_be_zero < last_page + page_size;
748 if (*(char *)should_be_zero) {
749 prt("Mapped %s: non-zero data past EOF (0x%llx) page offset 0x%x is 0x%04x\n",
750 s, file_size - 1, should_be_zero & page_mask,
751 short_at(should_be_zero));
758 domapread(unsigned offset, unsigned size)
764 offset -= offset % readbdy;
766 if (!quiet && testcalls > simulatedopcount)
767 prt("skipping zero size read\n");
768 log4(OP_MAPREAD, offset, size, FL_SKIPPED);
771 if (size + offset > file_size) {
772 if (!quiet && testcalls > simulatedopcount)
773 prt("skipping seek/read past end of file\n");
774 log4(OP_MAPREAD, offset, size, FL_SKIPPED);
778 log4(OP_MAPREAD, offset, size, FL_NONE);
780 if (testcalls <= simulatedopcount)
784 ((progressinterval && testcalls % progressinterval == 0) ||
786 (monitorstart == -1 ||
787 (offset + size > monitorstart &&
788 (monitorend == -1 || offset <= monitorend))))))
789 prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
790 offset, offset + size - 1, size);
792 pg_offset = offset & PAGE_MASK;
793 map_size = pg_offset + size;
795 if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_SHARED, fd,
796 (off_t)(offset - pg_offset))) == (char *)-1) {
797 prterr("domapread: mmap");
800 memcpy(temp_buf, p + pg_offset, size);
802 check_eofpage("Read", offset, p, size);
804 if (munmap(p, map_size) != 0) {
805 prterr("domapread: munmap");
809 check_buffers(offset, size);
814 gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
818 good_buf[offset] = filldata;
820 good_buf[offset] = testcalls % 256;
822 good_buf[offset] += original_buf[offset];
830 dowrite(unsigned offset, unsigned size)
835 offset -= offset % writebdy;
837 size -= size % writebdy;
839 if (!quiet && testcalls > simulatedopcount && !o_direct)
840 prt("skipping zero size write\n");
841 log4(OP_WRITE, offset, size, FL_SKIPPED);
845 log4(OP_WRITE, offset, size, FL_NONE);
847 gendata(original_buf, good_buf, offset, size);
848 if (file_size < offset + size) {
849 if (file_size < offset)
850 memset(good_buf + file_size, '\0', offset - file_size);
851 file_size = offset + size;
853 warn("Lite file size bug in fsx!");
858 if (testcalls <= simulatedopcount)
862 ((progressinterval && testcalls % progressinterval == 0) ||
864 (monitorstart == -1 ||
865 (offset + size > monitorstart &&
866 (monitorend == -1 || offset <= monitorend))))))
867 prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
868 offset, offset + size - 1, size);
869 ret = lseek(fd, (off_t)offset, SEEK_SET);
870 if (ret == (off_t)-1) {
871 prterr("dowrite: lseek");
874 iret = fsxwrite(fd, good_buf + offset, size, offset);
877 prterr("dowrite: write");
879 prt("short write: 0x%x bytes instead of 0x%x\n",
885 prt("fsync() failed: %s\n", strerror(errno));
890 doflush(offset, size);
896 domapwrite(unsigned offset, unsigned size)
903 offset -= offset % writebdy;
905 if (!quiet && testcalls > simulatedopcount)
906 prt("skipping zero size write\n");
907 log4(OP_MAPWRITE, offset, size, FL_SKIPPED);
910 cur_filesize = file_size;
912 log4(OP_MAPWRITE, offset, size, FL_NONE);
914 gendata(original_buf, good_buf, offset, size);
915 if (file_size < offset + size) {
916 if (file_size < offset)
917 memset(good_buf + file_size, '\0', offset - file_size);
918 file_size = offset + size;
920 warn("Lite file size bug in fsx!");
925 if (testcalls <= simulatedopcount)
929 ((progressinterval && testcalls % progressinterval == 0) ||
931 (monitorstart == -1 ||
932 (offset + size > monitorstart &&
933 (monitorend == -1 || offset <= monitorend))))))
934 prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
935 offset, offset + size - 1, size);
937 if (file_size > cur_filesize) {
938 if (ftruncate(fd, file_size) == -1) {
939 prterr("domapwrite: ftruncate");
943 pg_offset = offset & PAGE_MASK;
944 map_size = pg_offset + size;
946 if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
947 MAP_FILE | MAP_SHARED, fd,
948 (off_t)(offset - pg_offset))) == (char *)-1) {
949 prterr("domapwrite: mmap");
952 memcpy(p + pg_offset, good_buf + offset, size);
953 if (msync(p, map_size, MS_SYNC) != 0) {
954 prterr("domapwrite: msync");
958 check_eofpage("Write", offset, p, size);
960 if (munmap(p, map_size) != 0) {
961 prterr("domapwrite: munmap");
968 dotruncate(unsigned size)
970 int oldsize = file_size;
972 size -= size % truncbdy;
973 if (size > biggest) {
975 if (!quiet && testcalls > simulatedopcount)
976 prt("truncating to largest ever: 0x%x\n", size);
979 log4(OP_TRUNCATE, 0, size, FL_NONE);
981 if (size > file_size)
982 memset(good_buf + file_size, '\0', size - file_size);
985 if (testcalls <= simulatedopcount)
988 if ((progressinterval && testcalls % progressinterval == 0) ||
989 (debug && (monitorstart == -1 || monitorend == -1 ||
990 size <= monitorend)))
991 prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
992 if (ftruncate(fd, (off_t)size) == -1) {
993 prt("ftruncate1: %x\n", size);
994 prterr("dotruncate: ftruncate");
999 #ifdef FALLOC_FL_PUNCH_HOLE
1001 do_punch_hole(unsigned offset, unsigned length)
1003 unsigned end_offset;
1006 int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
1009 if (!quiet && testcalls > simulatedopcount)
1010 prt("skipping zero length punch hole\n");
1011 log4(OP_PUNCH_HOLE, offset, length, FL_SKIPPED);
1015 if (file_size <= (loff_t)offset) {
1016 if (!quiet && testcalls > simulatedopcount)
1017 prt("skipping hole punch off the end of the file\n");
1018 log4(OP_PUNCH_HOLE, offset, length, FL_SKIPPED);
1022 end_offset = offset + length;
1024 log4(OP_PUNCH_HOLE, offset, length, FL_NONE);
1026 if (testcalls <= simulatedopcount)
1029 if ((progressinterval && testcalls % progressinterval == 0) ||
1030 (debug && (monitorstart == -1 || monitorend == -1 ||
1031 end_offset <= monitorend))) {
1032 prt("%lu punch\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
1033 offset, offset+length, length);
1035 if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
1036 prt("punch hole: 0x%x to 0x%x\n", offset, offset + length);
1037 prterr("do_punch_hole: fallocate");
1038 report_failure(161);
1042 max_offset = offset < file_size ? offset : file_size;
1043 max_len = max_offset + length <= file_size ? length :
1044 file_size - max_offset;
1045 memset(good_buf + max_offset, '\0', max_len);
1050 do_punch_hole(unsigned offset, unsigned length)
1056 #ifdef FALLOC_FL_ZERO_RANGE
1058 do_zero_range(unsigned offset, unsigned length, int keep_size)
1060 unsigned end_offset;
1061 int mode = FALLOC_FL_ZERO_RANGE;
1064 if (!quiet && testcalls > simulatedopcount)
1065 prt("skipping zero length zero range\n");
1066 log4(OP_ZERO_RANGE, offset, length, FL_SKIPPED |
1067 (keep_size ? FL_KEEP_SIZE : FL_NONE));
1071 end_offset = keep_size ? 0 : offset + length;
1073 if (end_offset > biggest) {
1074 biggest = end_offset;
1075 if (!quiet && testcalls > simulatedopcount)
1076 prt("zero_range to largest ever: 0x%x\n", end_offset);
1080 * last arg matches fallocate string array index in logdump:
1081 * 0: allocate past EOF
1082 * 1: extending prealloc
1083 * 2: interior prealloc
1085 log4(OP_ZERO_RANGE, offset, length,
1086 keep_size ? FL_KEEP_SIZE : FL_NONE);
1088 if (testcalls <= simulatedopcount)
1091 if ((progressinterval && testcalls % progressinterval == 0) ||
1092 (debug && (monitorstart == -1 || monitorend == -1 ||
1093 end_offset <= monitorend))) {
1094 prt("%lu zero\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
1095 offset, offset+length, length);
1097 if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
1098 prt("zero range: 0x%x to 0x%x\n", offset, offset + length);
1099 prterr("do_zero_range: fallocate");
1100 report_failure(161);
1103 memset(good_buf + offset, '\0', length);
1108 do_zero_range(unsigned offset, unsigned length, int keep_size)
1114 #ifdef FALLOC_FL_COLLAPSE_RANGE
1116 do_collapse_range(unsigned offset, unsigned length)
1118 unsigned end_offset;
1119 int mode = FALLOC_FL_COLLAPSE_RANGE;
1122 if (!quiet && testcalls > simulatedopcount)
1123 prt("skipping zero length collapse range\n");
1124 log4(OP_COLLAPSE_RANGE, offset, length, FL_SKIPPED);
1128 end_offset = offset + length;
1129 if ((loff_t)end_offset >= file_size) {
1130 if (!quiet && testcalls > simulatedopcount)
1131 prt("skipping collapse range behind EOF\n");
1132 log4(OP_COLLAPSE_RANGE, offset, length, FL_SKIPPED);
1136 log4(OP_COLLAPSE_RANGE, offset, length, FL_NONE);
1138 if (testcalls <= simulatedopcount)
1141 if ((progressinterval && testcalls % progressinterval == 0) ||
1142 (debug && (monitorstart == -1 || monitorend == -1 ||
1143 end_offset <= monitorend))) {
1144 prt("%lu collapse\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
1145 offset, offset+length, length);
1147 if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
1148 prt("collapse range: 0x%x to 0x%x\n", offset, offset + length);
1149 prterr("do_collapse_range: fallocate");
1150 report_failure(161);
1153 memmove(good_buf + offset, good_buf + end_offset,
1154 file_size - end_offset);
1155 file_size -= length;
1160 do_collapse_range(unsigned offset, unsigned length)
1166 #ifdef FALLOC_FL_INSERT_RANGE
1168 do_insert_range(unsigned offset, unsigned length)
1170 unsigned end_offset;
1171 int mode = FALLOC_FL_INSERT_RANGE;
1174 if (!quiet && testcalls > simulatedopcount)
1175 prt("skipping zero length insert range\n");
1176 log4(OP_INSERT_RANGE, offset, length, FL_SKIPPED);
1180 if ((loff_t)offset >= file_size) {
1181 if (!quiet && testcalls > simulatedopcount)
1182 prt("skipping insert range behind EOF\n");
1183 log4(OP_INSERT_RANGE, offset, length, FL_SKIPPED);
1187 log4(OP_INSERT_RANGE, offset, length, FL_NONE);
1189 if (testcalls <= simulatedopcount)
1192 end_offset = offset + length;
1193 if ((progressinterval && testcalls % progressinterval == 0) ||
1194 (debug && (monitorstart == -1 || monitorend == -1 ||
1195 end_offset <= monitorend))) {
1196 prt("%lu insert\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
1197 offset, offset+length, length);
1199 if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
1200 prt("insert range: 0x%x to 0x%x\n", offset, offset + length);
1201 prterr("do_insert_range: fallocate");
1202 report_failure(161);
1205 memmove(good_buf + end_offset, good_buf + offset,
1206 file_size - offset);
1207 memset(good_buf + offset, '\0', length);
1208 file_size += length;
1213 do_insert_range(unsigned offset, unsigned length)
1219 #ifdef HAVE_LINUX_FALLOC_H
1220 /* fallocate is basically a no-op unless extending, then a lot like a truncate */
1222 do_preallocate(unsigned offset, unsigned length, int keep_size)
1224 unsigned end_offset;
1227 if (!quiet && testcalls > simulatedopcount)
1228 prt("skipping zero length fallocate\n");
1229 log4(OP_FALLOCATE, offset, length, FL_SKIPPED |
1230 (keep_size ? FL_KEEP_SIZE : FL_NONE));
1234 end_offset = keep_size ? 0 : offset + length;
1236 if (end_offset > biggest) {
1237 biggest = end_offset;
1238 if (!quiet && testcalls > simulatedopcount)
1239 prt("fallocating to largest ever: 0x%x\n", end_offset);
1243 * last arg matches fallocate string array index in logdump:
1244 * 0: allocate past EOF
1245 * 1: extending prealloc
1246 * 2: interior prealloc
1248 log4(OP_FALLOCATE, offset, length,
1249 keep_size ? FL_KEEP_SIZE : FL_NONE);
1251 if (end_offset > file_size) {
1252 memset(good_buf + file_size, '\0', end_offset - file_size);
1253 file_size = end_offset;
1256 if (testcalls <= simulatedopcount)
1259 if ((progressinterval && testcalls % progressinterval == 0) ||
1260 (debug && (monitorstart == -1 || monitorend == -1 ||
1261 end_offset <= monitorend)))
1262 prt("%lu falloc\tfrom 0x%x to 0x%x (0x%x bytes)\n", testcalls,
1263 offset, offset + length, length);
1264 if (fallocate(fd, keep_size ? FALLOC_FL_KEEP_SIZE : 0, (loff_t)offset, (loff_t)length) == -1) {
1265 prt("fallocate: 0x%x to 0x%x\n", offset, offset + length);
1266 prterr("do_preallocate: fallocate");
1267 report_failure(161);
1272 do_preallocate(unsigned offset, unsigned length, int keep_size)
1283 if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
1284 prterr("writefileimage: lseek");
1285 report_failure(171);
1287 iret = write(fd, good_buf, file_size);
1288 if ((off_t)iret != file_size) {
1290 prterr("writefileimage: write");
1292 prt("short write: 0x%x bytes instead of 0x%llx\n",
1293 iret, (unsigned long long)file_size);
1294 report_failure(172);
1296 if (lite ? 0 : ftruncate(fd, file_size) == -1) {
1297 prt("ftruncate2: %llx\n", (unsigned long long)file_size);
1298 prterr("writefileimage: ftruncate");
1299 report_failure(173);
1307 if (testcalls <= simulatedopcount)
1311 prt("%lu close/open\n", testcalls);
1313 prterr("docloseopen: close");
1314 report_failure(180);
1316 fd = open(fname, O_RDWR|o_direct, 0);
1318 prterr("docloseopen: open");
1319 report_failure(181);
1328 if (testcalls <= simulatedopcount)
1331 prt("%lu fsync\n", testcalls);
1332 log4(OP_FSYNC, 0, 0, 0);
1336 report_failure(210);
1339 dump_fsync_buffer();
1343 #define TRIM_OFF(off, size) \
1351 #define TRIM_LEN(off, len, size) \
1353 if ((off) + (len) > (size)) \
1354 (len) = (size) - (off); \
1357 #define TRIM_OFF_LEN(off, len, size) \
1359 TRIM_OFF(off, size); \
1360 TRIM_LEN(off, len, size); \
1367 prt("signal %d\n", sig);
1368 prt("testcalls = %lu\n", testcalls);
1373 read_op(struct log_entry *log_entry)
1377 memset(log_entry, 0, sizeof(*log_entry));
1378 log_entry->operation = -1;
1380 while (log_entry->operation == -1) {
1385 if (!fgets(line, sizeof(line), replayopsf)) {
1386 if (feof(replayopsf)) {
1392 str = strtok(line, " \t\n");
1395 if (strcmp(str, "skip") == 0) {
1396 log_entry->flags |= FL_SKIPPED;
1397 str = strtok(NULL, " \t\n");
1401 log_entry->operation = op_code(str);
1402 if (log_entry->operation == -1)
1404 for (i = 0; i < 3; i++) {
1407 str = strtok(NULL, " \t\n");
1410 log_entry->args[i] = strtoul(str, &end, 0);
1414 while ((str = strtok(NULL, " \t\n"))) {
1415 if (strcmp(str, "keep_size") == 0)
1416 log_entry->flags |= FL_KEEP_SIZE;
1417 else if (strcmp(str, "close_open") == 0)
1418 log_entry->flags |= FL_CLOSE_OPEN;
1419 else if (strcmp(str, "*") == 0)
1420 ; /* overlap marker; ignore */
1428 fprintf(stderr, "%s: parse error\n", replayops);
1431 cleanup(100); /* doesn't return */
1439 unsigned long offset;
1445 if (simulatedopcount > 0 && testcalls == simulatedopcount)
1450 if (debugstart > 0 && testcalls >= debugstart)
1453 if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
1454 prt("%lu...\n", testcalls);
1457 struct log_entry log_entry;
1459 while (read_op(&log_entry)) {
1460 if (log_entry.flags & FL_SKIPPED) {
1461 log4(log_entry.operation,
1462 log_entry.args[0], log_entry.args[1],
1467 op = log_entry.operation;
1468 offset = log_entry.args[0];
1469 size = log_entry.args[1];
1470 closeopen = !!(log_entry.flags & FL_CLOSE_OPEN);
1471 keep_size = !!(log_entry.flags & FL_KEEP_SIZE);
1479 closeopen = (rv >> 3) < (1 << 28) / closeprob;
1484 size = random() % (maxoplen + 1);
1486 /* calculate appropriate op to run */
1488 op = rv % OP_MAX_LITE;
1489 else if (!integrity)
1490 op = rv % OP_MAX_FULL;
1492 op = rv % OP_MAX_INTEGRITY;
1497 size = random() % maxfilelen;
1500 if (fallocate_calls && size && keep_size_calls)
1501 keep_size = random() % 2;
1504 if (zero_range_calls && size && keep_size_calls)
1505 keep_size = random() % 2;
1521 if (!fallocate_calls) {
1522 log4(OP_FALLOCATE, offset, size, FL_SKIPPED);
1527 if (!punch_hole_calls) {
1528 log4(OP_PUNCH_HOLE, offset, size, FL_SKIPPED);
1533 if (!zero_range_calls) {
1534 log4(OP_ZERO_RANGE, offset, size, FL_SKIPPED);
1538 case OP_COLLAPSE_RANGE:
1539 if (!collapse_range_calls) {
1540 log4(OP_COLLAPSE_RANGE, offset, size, FL_SKIPPED);
1544 case OP_INSERT_RANGE:
1545 if (!insert_range_calls) {
1546 log4(OP_INSERT_RANGE, offset, size, FL_SKIPPED);
1554 TRIM_OFF_LEN(offset, size, file_size);
1555 doread(offset, size);
1559 TRIM_OFF_LEN(offset, size, maxfilelen);
1560 dowrite(offset, size);
1564 TRIM_OFF_LEN(offset, size, file_size);
1565 domapread(offset, size);
1569 TRIM_OFF_LEN(offset, size, maxfilelen);
1570 domapwrite(offset, size);
1578 TRIM_OFF_LEN(offset, size, maxfilelen);
1579 do_preallocate(offset, size, keep_size);
1583 TRIM_OFF_LEN(offset, size, file_size);
1584 do_punch_hole(offset, size);
1587 TRIM_OFF_LEN(offset, size, file_size);
1588 do_zero_range(offset, size, keep_size);
1590 case OP_COLLAPSE_RANGE:
1591 TRIM_OFF_LEN(offset, size, file_size - 1);
1592 offset = offset & ~(block_size - 1);
1593 size = size & ~(block_size - 1);
1595 log4(OP_COLLAPSE_RANGE, offset, size, FL_SKIPPED);
1598 do_collapse_range(offset, size);
1600 case OP_INSERT_RANGE:
1601 TRIM_OFF(offset, file_size);
1602 TRIM_LEN(file_size, size, maxfilelen);
1603 offset = offset & ~(block_size - 1);
1604 size = size & ~(block_size - 1);
1606 log4(OP_INSERT_RANGE, offset, size, FL_SKIPPED);
1609 if (file_size + size > maxfilelen) {
1610 log4(OP_INSERT_RANGE, offset, size, FL_SKIPPED);
1614 do_insert_range(offset, size);
1620 prterr("test: unknown operation");
1626 if (sizechecks && testcalls > simulatedopcount)
1637 fprintf(stdout, "usage: %s",
1638 "fsx [-dnqxAFLOWZ] [-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\
1639 -b opnum: beginning operation number (default 1)\n\
1640 -c P: 1 in P chance of file close+open at each op (default infinity)\n\
1641 -d: debug output for all operations\n\
1642 -f flush and invalidate cache after I/O\n\
1643 -g X: write character X instead of random generated data\n\
1644 -i logdev: do integrity testing, logdev is the dm log writes device\n\
1645 -j logid: prefix debug log messsages with this id\n\
1646 -l flen: the upper bound on file size (default 262144)\n\
1647 -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
1648 -n: no verifications of file size\n\
1649 -o oplen: the upper bound on operation size (default 65536)\n\
1650 -p progressinterval: debug output at specified operation interval\n\
1651 -q: quieter operation\n\
1652 -r readbdy: 4096 would make reads page aligned (default 1)\n\
1653 -s style: 1 gives smaller truncates (default 0)\n\
1654 -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
1655 -w writebdy: 4096 would make writes page aligned (default 1)\n\
1656 -x: preallocate file space before starting, XFS only (default 0)\n\
1657 -y synchronize changes to a file\n"
1660 " -A: Use the AIO system calls\n"
1662 " -D startingop: debug output starting at specified operation\n"
1663 #ifdef HAVE_LINUX_FALLOC_H
1664 " -F: Do not use fallocate (preallocation) calls\n"
1666 #ifdef FALLOC_FL_PUNCH_HOLE
1667 " -H: Do not use punch hole calls\n"
1669 #ifdef FALLOC_FL_ZERO_RANGE
1670 " -z: Do not use zero range calls\n"
1672 #ifdef FALLOC_FL_COLLAPSE_RANGE
1673 " -C: Do not use collapse range calls\n"
1675 #ifdef FALLOC_FL_INSERT_RANGE
1676 " -I: Do not use insert range calls\n"
1678 " -L: fsxLite - no file creations & no file size changes\n\
1679 -N numops: total # operations to do (default infinity)\n\
1680 -O: use oplen (see -o flag) for every op (default random)\n\
1681 -P: save .fsxlog .fsxops and .fsxgood files in dirpath (default ./)\n\
1682 -S seed: for random # generator (default 1) 0 gets timestamp\n\
1683 -W: mapped write operations DISabled\n\
1684 -R: read() system calls only (mapped reads disabled)\n\
1685 -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
1686 --replay-ops opsfile: replay ops from recorded .fsxops file\n\
1687 --record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
1688 fname: this filename is REQUIRED (no default)\n");
1694 getnum(char *s, char **e)
1699 ret = strtol(s, e, 0);
1729 io_context_t io_ctx;
1735 ret = io_queue_init(QSZ, &io_ctx);
1737 fprintf(stderr, "aio_setup: io_queue_init failed: %s\n",
1745 __aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
1747 struct io_event event;
1748 static struct timespec ts;
1749 struct iocb *iocbs[] = { &iocb };
1754 io_prep_pread(&iocb, fd, buf, len, offset);
1756 io_prep_pwrite(&iocb, fd, buf, len, offset);
1761 ret = io_submit(io_ctx, 1, iocbs);
1763 fprintf(stderr, "errcode=%d\n", ret);
1764 fprintf(stderr, "aio_rw: io_submit failed: %s\n",
1769 ret = io_getevents(io_ctx, 1, 1, &event, &ts);
1772 fprintf(stderr, "aio_rw: no events available\n");
1774 fprintf(stderr, "errcode=%d\n", -ret);
1775 fprintf(stderr, "aio_rw: io_getevents failed: %s\n",
1780 if (len != event.res) {
1782 * The b0rked libaio defines event.res as unsigned.
1783 * However the kernel strucuture has it signed,
1784 * and it's used to pass negated error value.
1785 * Till the library is fixed use the temp var.
1787 res = (long)event.res;
1789 fprintf(stderr, "bad io length: %lu instead of %u\n",
1792 fprintf(stderr, "errcode=%ld\n", -res);
1793 fprintf(stderr, "aio_rw: async io failed: %s\n",
1804 * The caller expects error return in traditional libc
1805 * convention, i.e. -1 and the errno set to error.
1811 int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
1816 ret = __aio_rw(rw, fd, buf, len, offset);
1819 ret = read(fd, buf, len);
1821 ret = write(fd, buf, len);
1828 #define test_fallocate(mode) __test_fallocate(mode, #mode)
1831 __test_fallocate(int mode, const char *mode_str)
1833 #ifdef HAVE_LINUX_FALLOC_H
1836 if (fallocate(fd, mode, 0, 1) && errno == EOPNOTSUPP) {
1839 "main: filesystem does not support "
1840 "fallocate mode %s, disabling!\n",
1844 if (ftruncate(fd, 0)) {
1845 warn("main: ftruncate");
1854 static struct option longopts[] = {
1855 {"replay-ops", required_argument, 0, 256},
1856 {"record-ops", optional_argument, 0, 255},
1861 main(int argc, char **argv)
1865 char goodfile[1024];
1867 struct stat statbuf;
1873 page_size = getpagesize();
1874 page_mask = page_size - 1;
1875 mmap_mask = page_mask;
1878 setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
1880 while ((ch = getopt_long(argc, argv,
1881 "b:c:dfg:i:j:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
1882 longopts, NULL)) != EOF)
1885 simulatedopcount = getnum(optarg, &endp);
1887 prt("Will begin at operation %ld\n", simulatedopcount);
1888 if (simulatedopcount == 0)
1890 simulatedopcount -= 1;
1893 closeprob = getnum(optarg, &endp);
1895 prt("Chance of close/open is 1 in %d\n", closeprob);
1910 logdev = strdup(optarg);
1917 logid = strdup(optarg);
1924 maxfilelen = getnum(optarg, &endp);
1925 if (maxfilelen <= 0)
1929 monitorstart = getnum(optarg, &endp);
1930 if (monitorstart < 0)
1932 if (!endp || *endp++ != ':')
1934 monitorend = getnum(endp, &endp);
1937 if (monitorend == 0)
1938 monitorend = -1; /* aka infinity */
1944 maxoplen = getnum(optarg, &endp);
1949 progressinterval = getnum(optarg, &endp);
1950 if (progressinterval == 0)
1957 readbdy = getnum(optarg, &endp);
1962 style = getnum(optarg, &endp);
1963 if (style < 0 || style > 1)
1967 truncbdy = getnum(optarg, &endp);
1972 writebdy = getnum(optarg, &endp);
1986 debugstart = getnum(optarg, &endp);
1991 fallocate_calls = 0;
1994 keep_size_calls = 0;
1997 punch_hole_calls = 0;
2000 zero_range_calls = 0;
2003 collapse_range_calls = 0;
2006 insert_range_calls = 0;
2012 numops = getnum(optarg, &endp);
2020 strncpy(dname, optarg, sizeof(dname));
2022 dirpath = strlen(dname);
2024 strncpy(goodfile, dname, sizeof(goodfile));
2025 strncpy(logfile, dname, sizeof(logfile));
2026 strncpy(opsfile, dname, sizeof(logfile));
2032 seed = getnum(optarg, &endp);
2034 seed = time(0) % 10000;
2035 seed += (int)getpid();
2038 prt("Seed set to %d\n", seed);
2045 prt("mapped writes DISABLED\n");
2048 o_direct = O_DIRECT;
2050 case 255: /* --record-ops */
2052 strncpy(opsfile, optarg, sizeof(opsfile));
2053 recordops = opsfile;
2055 case 256: /* --replay-ops */
2067 if (integrity && !dirpath) {
2068 fprintf(stderr, "option -i <logdev> requires -P <dirpath>\n");
2073 tmp = strdup(fname);
2078 bname = basename(tmp);
2080 signal(SIGHUP, cleanup);
2081 signal(SIGINT, cleanup);
2082 signal(SIGPIPE, cleanup);
2083 signal(SIGALRM, cleanup);
2084 signal(SIGTERM, cleanup);
2085 signal(SIGXCPU, cleanup);
2086 signal(SIGXFSZ, cleanup);
2087 signal(SIGVTALRM, cleanup);
2088 signal(SIGUSR1, cleanup);
2089 signal(SIGUSR2, cleanup);
2093 O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC)|o_direct, 0666);
2098 if (fstat(fd, &statbuf)) {
2099 prterr("check_size: fstat");
2102 block_size = statbuf.st_blksize;
2105 xfs_flock64_t resv = { 0 };
2106 #ifdef HAVE_XFS_PLATFORM_DEFS_H
2107 if (!platform_test_xfs_fd(fd)) {
2109 fprintf(stderr, "main: cannot prealloc, non XFS\n");
2113 resv.l_len = maxfilelen;
2114 if ((xfsctl(fname, fd, XFS_IOC_RESVSP, &resv)) < 0) {
2120 strncat(goodfile, dirpath ? bname : fname, 256);
2121 strcat (goodfile, ".fsxgood");
2122 fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
2123 if (fsxgoodfd < 0) {
2127 strncat(logfile, dirpath ? bname : fname, 256);
2128 strcat (logfile, ".fsxlog");
2129 fsxlogf = fopen(logfile, "w");
2130 if (fsxlogf == NULL) {
2135 strncat(opsfile, dirpath ? bname : fname, 256);
2136 strcat(opsfile, ".fsxops");
2141 replayopsf = fopen(replayops, "r");
2155 file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END);
2156 if (file_size == (off_t)-1) {
2158 warn("main: lseek eof");
2161 ret = lseek(fd, (off_t)0, SEEK_SET);
2162 if (ret == (off_t)-1) {
2164 warn("main: lseek 0");
2168 original_buf = (char *) malloc(maxfilelen);
2169 for (i = 0; i < maxfilelen; i++)
2170 original_buf[i] = random() % 256;
2171 good_buf = (char *) malloc(maxfilelen + writebdy);
2172 good_buf = round_ptr_up(good_buf, writebdy, 0);
2173 memset(good_buf, '\0', maxfilelen);
2174 temp_buf = (char *) malloc(maxoplen + readbdy);
2175 temp_buf = round_ptr_up(temp_buf, readbdy, 0);
2176 memset(temp_buf, '\0', maxoplen);
2177 if (lite) { /* zero entire existing file */
2180 written = write(fd, good_buf, (size_t)maxfilelen);
2181 if (written != maxfilelen) {
2182 if (written == -1) {
2184 warn("main: error on write");
2186 warn("main: short write, 0x%x bytes instead "
2195 if (fallocate_calls)
2196 fallocate_calls = test_fallocate(0);
2197 if (keep_size_calls)
2198 keep_size_calls = test_fallocate(FALLOC_FL_KEEP_SIZE);
2199 if (punch_hole_calls)
2200 punch_hole_calls = test_fallocate(FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE);
2201 if (zero_range_calls)
2202 zero_range_calls = test_fallocate(FALLOC_FL_ZERO_RANGE);
2203 if (collapse_range_calls)
2204 collapse_range_calls = test_fallocate(FALLOC_FL_COLLAPSE_RANGE);
2205 if (insert_range_calls)
2206 insert_range_calls = test_fallocate(FALLOC_FL_INSERT_RANGE);
2208 while (numops == -1 || numops--)
2217 prt("All %lu operations completed A-OK!\n", testcalls);