X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Ffsx.c;h=f645b088bc2c536c19acc43f066842b8014778da;hp=dc97fd9d21538e5933a82f1f04c6c4d0de348e18;hb=e44a6b616764810093a3c6f3d15254793865ffb7;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c diff --git a/lustre/tests/fsx.c b/lustre/tests/fsx.c index dc97fd9..f645b08 100644 --- a/lustre/tests/fsx.c +++ b/lustre/tests/fsx.c @@ -69,7 +69,7 @@ struct log_entry { int args[3]; }; -#define LOGSIZE 1000 +#define LOGSIZE 100000 struct log_entry oplog[LOGSIZE]; /* the log */ int logptr = 0; /* current position in log */ @@ -299,7 +299,7 @@ save_buffer(char *buffer, off_t bufferlength, int fd) 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", + "save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek, (unsigned long long)bufferlength); bufferlength = size_by_seek; @@ -402,7 +402,7 @@ enum fd_iteration_policy { int fd_policy = FD_RANDOM; int fd_last = 0; -struct test_file * +struct test_file * get_tf(void) { unsigned index = 0; @@ -471,7 +471,7 @@ open_test_files(char **argv, int argc) for (i = 0, tf = test_files; i < num_test_files; i++, tf++) { tf->path = argv[i]; - tf->fd = open(tf->path, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), + tf->fd = open(tf->path, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666); if (tf->fd < 0) { prterr(tf->path); @@ -529,8 +529,15 @@ check_trunc_hack(void) struct stat statbuf; int fd = get_fd(); - ftruncate(fd, (off_t)0); - ftruncate(fd, (off_t)100000); + /* should not ignore ftruncate(2)'s return value */ + if (ftruncate(fd, (off_t)0) < 0) { + prterr("trunc_hack: ftruncate(0)"); + exit(1); + } + if (ftruncate(fd, (off_t)100000) < 0) { + prterr("trunc_hack: ftruncate(100000)"); + exit(1); + } if (fstat(fd, &statbuf)) { prterr("trunc_hack: fstat"); statbuf.st_size = -1; @@ -539,7 +546,10 @@ check_trunc_hack(void) prt("no extend on truncate! not posix!\n"); exit(130); } - ftruncate(fd, 0); + if (ftruncate(fd, 0) < 0) { + prterr("trunc_hack: ftruncate(0) (2nd call)"); + exit(1); + } } static char *tf_buf = NULL; @@ -575,7 +585,7 @@ alloc_tf_buf(void) } } -char * +char * fill_tf_buf(struct test_file *tf) { if (tf_buf == NULL) @@ -586,7 +596,7 @@ fill_tf_buf(struct test_file *tf) } void -output_line(struct test_file *tf, int op, unsigned offset, +output_line(struct test_file *tf, int op, unsigned offset, unsigned size, struct timeval *tv) { char *tf_num = ""; @@ -613,7 +623,7 @@ output_line(struct test_file *tf, int op, unsigned offset, prt("%06lu %lu.%06lu %.*s%-10s %#08x %s %#08x\t(0x%x bytes)\n", testcalls, tv->tv_sec, tv->tv_usec, max_tf_len, - tf_num, ops[op], + tf_num, ops[op], offset, op == OP_TRUNCATE ? " to " : "thru", offset + size - 1, size); } @@ -972,7 +982,7 @@ writefileimage() prterr("writefileimage: write"); else prt("short write: 0x%lx bytes instead of 0x%llx\n", - (unsigned long)iret, + (unsigned long)iret, (unsigned long long)file_size); report_failure(172); } @@ -1185,7 +1195,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ - while ((ch = getopt(argc, argv, + while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:I:LN:OP:RS:W")) != EOF) switch (ch) {