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>
diff --git a/simoop.c b/simoop.c
index 557c701..dab9457 100644
--- a/simoop.c
+++ b/simoop.c
@@ -118,6 +118,9 @@
 /* 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 @@
 	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 @@
 	{"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 @@
 		"\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 @@
 		case 'U':
 			writethrough = 1;
 			break;
+		case 'u':
+			unaligned_stress = 1;
+			break;
 		case 'v':
 			verify_writes = 1;
 			break;
@@ -1102,34 +1110,36 @@
 	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);
+
+				start += ret;
+				this_write -= ret;
+				buf += ret;
+				bytes -= ret;
 			}
-
-			maybe_write_through(fd, start, this_write);
-
-			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 @@
 		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);