diff options
author | Omar Sandoval <osandov@fb.com> | 2018-04-11 22:07:28 -0700 |
---|---|---|
committer | Eryu Guan <guaneryu@gmail.com> | 2018-04-22 18:44:17 +0800 |
commit | fdd096c9499ae91e10dab6e6444c560ca25d0a8f (patch) | |
tree | 4c8d28998377b9378cf14e4a0aa9055b5ea6cdc1 | |
parent | 7ed53b9342ae89d0a9edb0105d6723840d7f40a5 (diff) | |
download | xfstests-dev-fdd096c9499ae91e10dab6e6444c560ca25d0a8f.tar.gz |
src/aio-dio-eof-race: handle aio pwrite errors and short reads
generic/427 fails on Btrfs with a cryptic "pread: Success" message. This
is because an aio pwrite fails with ENOSPC, so the file isn't as long as
we expect it to be. Make sure we check the result of the aio writes and
also print a more explicit message for short reads (which are
technically valid but in practice shouldn't happen for this test case).
Now the test fails with a much more informative "pwrite: No space left
on device".
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r-- | src/aio-dio-regress/aio-dio-eof-race.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/aio-dio-regress/aio-dio-eof-race.c b/src/aio-dio-regress/aio-dio-eof-race.c index bb1890b536..044790358a 100644 --- a/src/aio-dio-regress/aio-dio-eof-race.c +++ b/src/aio-dio-regress/aio-dio-eof-race.c @@ -154,6 +154,9 @@ int main(int argc, char *argv[]) /* Keep extending until size_MB */ while (eof < size_MB * 1024 * 1024) { + ssize_t sret; + int i; + memset(buf, IO_PATTERN, buf_size); fstat(fd, &statbuf); eof = statbuf.st_size; @@ -186,15 +189,32 @@ int main(int argc, char *argv[]) return 1; } + for (i = 0; i < err; i++) { + /* + * res is unsigned for some reason, so this is the best + * way to detect that it contains a negative errno. + */ + if (evs[i].res > buf_size / 4) { + fprintf(stderr, "pwrite: %s\n", + strerror(-evs[i].res)); + return 1; + } + } + /* * And then read it back. * * Using pread to keep it simple, but AIO has the same effect. * eof is the prior eof; we just wrote buf_size more. */ - if (pread(fd, buf, buf_size, eof) != buf_size) { + sret = pread(fd, buf, buf_size, eof); + if (sret == -1) { perror("pread"); return 1; + } else if (sret != buf_size) { + fprintf(stderr, "short read %zd was less than %zu\n", + sret, buf_size); + return 1; } /* |