diff options
author | Chris Mason <clm@fb.com> | 2020-06-19 13:45:36 -0700 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2020-06-19 13:45:36 -0700 |
commit | 0471899dcff01ca1957777adb7ae0088cdd35a9e (patch) | |
tree | 5d3219d3cc24b3831b3fb4f5654969f1aed7f3e5 | |
parent | ba41b5ecb5afc4bb1ece729343b7e5d8d672abdd (diff) | |
download | simoop-0471899dcff01ca1957777adb7ae0088cdd35a9e.tar.gz |
simoop: shove sub-page writes under --unalignedwrites (-u)
simoop was originally looking for filesystem correctness bugs, so it
intentionally did subpage writes to find more problems. Put this under
-u instead of making it the default
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r-- | simoop.c | 60 |
1 files changed, 35 insertions, 25 deletions
@@ -118,6 +118,9 @@ static int zallocate = 0; /* should we delete the .tmp and .results files? */ static int nocleanup = 0; +/* take extra steps to be a jerk to the filesystem */ +static int unaligned_stress = 0; + static uint64_t global_rand_seed = 0x89ABCEF; /* @@ -467,7 +470,7 @@ unsigned long long parse_size(char *s) return ret; } -char *option_string = "t:s:C:c:r:n:f:FR:T:m:W:M:w:i:D:oaOVzNIevU"; +char *option_string = "t:s:C:c:r:n:f:FR:T:m:W:M:w:i:D:oaOVzNIevUu"; static struct option long_options[] = { {"appendmode", required_argument, 0, 'a'}, {"mmapsize", required_argument, 0, 'M'}, @@ -491,6 +494,7 @@ static struct option long_options[] = { {"odirect", no_argument, 0, 'O'}, {"verify-writes", no_argument, 0, 'v'}, {"verify-startup", no_argument, 0, 'V'}, + {"unalignedstress", no_argument, 0, 'u'}, {"zallocate", no_argument, 0, 'z'}, {"nocleanup", no_argument, 0, 'N'}, {"erase", no_argument, 0, 'e'}, @@ -526,6 +530,7 @@ static void print_usage(void) "\t-N (--nocleanup): don't cleanup temp files from the last run\n" "\t-e (--erase): delete the data files at the start of the run\n" "\t-U (--writethrough): sync_file_range every write\n" + "\t-u (--unalignedstress): take extra steps to be mean to the FS\n" "\t dir1 [dir2 ... dirN]\n" "\nall sizes are in bytes k,m,g,t modifiers can be used\n" ); @@ -617,6 +622,9 @@ static void parse_options(int ac, char **av) case 'U': writethrough = 1; break; + case 'u': + unaligned_stress = 1; + break; case 'v': verify_writes = 1; break; @@ -1102,34 +1110,36 @@ static void send_pwrite(int fd, char *buf, loff_t start, ssize_t bytes) int ret; int i; - for (i = 0; i < 3; i++) { - maybe_toggle_odirect(fd, start, this_write); - /* - * the goal here is to break up our huge IO into - * something that isn't completely page aligned. - */ - this_write = VERIFY_ALIGNMENT; - while (this_write > 0) { + if (unaligned_stress) { + for (i = 0; i < 3; i++) { + maybe_toggle_odirect(fd, start, this_write); + /* + * the goal here is to break up our huge IO into + * something that isn't completely page aligned. + */ + this_write = VERIFY_ALIGNMENT; + while (this_write > 0) { - if (this_write > bytes) - break; + if (this_write > bytes) + break; - ret = pwrite(fd, buf, this_write, start); - if (ret <= 0) { - perror("pwrite"); - exit(1); - } + ret = pwrite(fd, buf, this_write, start); + if (ret <= 0) { + perror("pwrite"); + exit(1); + } - maybe_write_through(fd, start, this_write); + maybe_write_through(fd, start, this_write); - start += ret; - this_write -= ret; - buf += ret; - bytes -= ret; + start += ret; + this_write -= ret; + buf += ret; + bytes -= ret; + } + maybe_fsync(fd); + if (bytes <= 0) + break; } - maybe_fsync(fd); - if (bytes <= 0) - break; } while (bytes > 0) { @@ -1437,7 +1447,7 @@ static void write_to_file(char *path, int seq, char *buf) exit(1); } - write_pattern(fd, xxhash_state, buf, write_size, offset, write_bytes * 4, st.st_ino); + write_pattern(fd, xxhash_state, buf, write_size, offset, write_bytes, st.st_ino); XXH32_digest(xxhash_state); |