diff options
author | Antonio Russo <[email protected]> | 2023-01-05 13:50:30 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2023-01-09 17:15:22 -0800 |
commit | a75af541cf180a221cca41b61888f2b4beb4a79a (patch) | |
tree | 5471d36149690fa5889944cc1640e0e7c9518e57 /tests | |
parent | 75fbe7eb99c3d20403c79c7e24a97997c424313a (diff) |
ZTS: limit mmapwrite file size
commit ee6bf97c7727c118f7bbb8be4bb0eedcaca2ad35 upstream
mmapwrite spawns several threads, all of which perform writes on a file
for the purpose of testing the behavior of mmap(2)-ed files. One
thread performs an mmap and a write to the beginning of that region,
while the others perform regular writes after lseek(2)-ing the end of
the file.
Because these regular writes are set in a while (1) loop, they will
write an unbounded amount of data to disk. The mmap_write_001_pos test
script SIGKILLs them after 30 seconds, but on fast testbeds, this may
be enough time to exhaust the available space in the filesystem,
leading to spurious test failures.
Instead, limit the total file size by checking that the lseek return
value is no greater than 250 * 1024*1024 bytes, which is less than the
default minimum vdev size defined in includes/default.cfg .
This also includes part of 2a493a4c7127258b14c39e8c71a9d6f01167c5cd,
which checks the return value of lseek.
Signed-off-by: Antonio Russo <[email protected]>
Closes #14277
Closes #14345
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/cmd/mmapwrite/mmapwrite.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c b/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c index 152f5ba90..baf9788ed 100644 --- a/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c +++ b/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c @@ -52,6 +52,7 @@ */ #define NORMAL_WRITE_TH_NUM 2 +#define MAX_WRITE_BYTES 262144000 static void * normal_writer(void *filename) @@ -67,18 +68,25 @@ normal_writer(void *filename) } char *buf = malloc(1); - while (1) { + off_t bytes_written = 0; + + while (bytes_written < MAX_WRITE_BYTES) { write_num = write(fd, buf, 1); if (write_num == 0) { err(1, "write failed!"); break; } - lseek(fd, page_size, SEEK_CUR); + if ((bytes_written = lseek(fd, page_size, SEEK_CUR)) == -1) { + err(1, "lseek failed on %s: %s", file_path, + strerror(errno)); + break; + } } if (buf) { free(buf); } + return (NULL); } static void * |