From: Jens Axboe Date: Thu, 25 Apr 2013 05:07:17 +0000 (-0600) Subject: Fix filling verify pattern for byte sizes of 3, 5, 7, ... X-Git-Tag: fio-2.1~14 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=e078de4a1c4e27f1938db4656e4d7cb6f98a8e1c Fix filling verify pattern for byte sizes of 3, 5, 7, ... 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 --- diff --git a/options.c b/options.c index 3b04ffae..1219803a 100644 --- 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; - 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"); @@ -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. */ + 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; } + + /* + * 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