Fix filling verify pattern for byte sizes of 3, 5, 7, ...
authorJens Axboe <axboe@kernel.dk>
Thu, 25 Apr 2013 05:07:17 +0000 (23:07 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 25 Apr 2013 05:07:17 +0000 (23:07 -0600)
If we can't double up to the max pattern size, we leave unfilled
space. This causes verification failures. Fix this by properly
filling up to the max.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
options.c

index 3b04ffae8c129a6828add9cd75a28a22f451b96c..1219803a73a1e9880698aa8ecf387f1426e7bdba 100644 (file)
--- a/options.c
+++ b/options.c
@@ -805,7 +805,7 @@ static int str_verify_pattern_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
        long off;
 {
        struct thread_data *td = data;
        long off;
-       int i = 0, j = 0, len, k, base = 10;
+       int i = 0, j = 0, len, k, base = 10, pattern_length;
        char *loc1, *loc2;
 
        loc1 = strstr(input, "0x");
        char *loc1, *loc2;
 
        loc1 = strstr(input, "0x");
@@ -844,10 +844,23 @@ static int str_verify_pattern_cb(void *data, const char *input)
         * Fill the pattern all the way to the end. This greatly reduces
         * the number of memcpy's we have to do when verifying the IO.
         */
         * Fill the pattern all the way to the end. This greatly reduces
         * the number of memcpy's we have to do when verifying the IO.
         */
+       pattern_length = i;
        while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
                memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
                i *= 2;
        }
        while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
                memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
                i *= 2;
        }
+
+       /*
+        * Fill remainder, if the pattern multiple ends up not being
+        * MAX_PATTERN_SIZE.
+        */
+       while (i > 1 && i < MAX_PATTERN_SIZE) {
+               unsigned int b = min(pattern_length, MAX_PATTERN_SIZE - i);
+
+               memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], b);
+               i += b;
+       }
+
        if (i == 1) {
                /*
                 * The code in verify_io_u_pattern assumes a single byte pattern
        if (i == 1) {
                /*
                 * The code in verify_io_u_pattern assumes a single byte pattern