flashbench: add --offset command line argument

This makes it easier to do the --open-au test case
on drives whose erase block is not a power of two.
Note that for those, you have to pass a blocksize
that is also not a power of two, but a fraction
of the erase size, e.g.

flashbench --open-au --random --open-au-nr=6 \
	--erasesize=$[3 * 1024 * 1024] \
	--blocksize=$[24 * 1024] \
	--offset=$[24 * 1024 * 1024] \
	/dev/sde

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/flashbench.c b/flashbench.c
index 9d04a23..aaf4c5d 100644
--- a/flashbench.c
+++ b/flashbench.c
@@ -466,6 +466,7 @@
 	return 0;
 }
 
+#if 0
 static int try_open_au_oob(struct device *dev, unsigned int erasesize,
 			unsigned int blocksize,
 			unsigned int count,
@@ -505,12 +506,18 @@
 
 	return 0;
 }
+#endif
 
 static int try_open_au(struct device *dev, unsigned int erasesize,
 			unsigned int blocksize,
 			unsigned int count,
+			unsigned long long offset,
 			bool random)
 {
+        /* start 16 MB into the device, to skip FAT */
+	if (offset == -1ull)
+		offset = 1024 * 1024 * 16;
+
 	/* find maximum number of open AUs */
 	struct operation program[] = {
             /* loop through power of two multiple of one sector */
@@ -521,8 +528,7 @@
                     {O_PRINTF},
                     {O_FORMAT},
                     {O_LENGTH},
-                /* start 16 MB into the device, to skip FAT */
-                {O_OFF_FIXED, .val = 1024 * 1024 * 16}, {O_DROP},
+                {O_OFF_FIXED, .val = offset}, {O_DROP},
                     /* print one line of aggregated
                         per second results */
                     {O_PRINTF}, {O_FORMAT}, {O_BPS},
@@ -588,6 +594,7 @@
 	printf("    --fat-nr=N	look through first N erase blocks (default: 6)\n");
 	printf("-O, --open-au	find number of open erase blocks\n");
 	printf("    --open-au-nr=N try N open erase blocks\n");
+	printf("    --offset=N  start at position N\n");
 	printf("-r, --random	use pseudorandom access with erase block\n");
 	printf("-v, --verbose	increase verbosity of output\n");
 	printf("-c, --count=N	run each test N times (default: 8\n");
@@ -603,6 +610,7 @@
 	int count;
 	int blocksize;
 	int erasesize;
+	unsigned long long offset;
 	int scatter_order;
 	int scatter_span;
 	int interval_order;
@@ -624,6 +632,7 @@
 		{ "fat-nr", 1, NULL, 'F' },
 		{ "open-au", 0, NULL, 'O' },
 		{ "open-au-nr", 1, NULL, '0' },
+		{ "offset", 1, NULL, 't' },
 		{ "random", 0, NULL, 'r' },
 		{ "verbose", 0, NULL, 'v' },
 		{ "count", 1, NULL, 'c' },
@@ -637,6 +646,7 @@
 	args->scatter_order = 9;
 	args->scatter_span = 1;
 	args->blocksize = 16384;
+	args->offset = -1ull;
 	args->erasesize = 4 * 1024 * 1024;
 	args->fat_nr = 6;
 	args->open_au_nr = 2;
@@ -718,6 +728,10 @@
 			args->erasesize = atoi(optarg);
 			break;
 
+		case 't':
+			args->offset = strtoull(optarg, NULL, 0);
+			break;
+
 		case '?':
 			print_help(argv[0]);
 			return -EINVAL;
@@ -806,7 +820,7 @@
 
 	if (args.open_au) {
 		ret = try_open_au(&dev, args.erasesize, args.blocksize,
-				  args.open_au_nr, args.random);
+				  args.open_au_nr, args.offset, args.random);
 		if (ret < 0) {
 			errno = -ret;
 			perror("find_fat");