Use specified compression/pattern for verify buffers too

Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/lib/rand.c b/lib/rand.c
index e5332bf..618a2f0 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -117,12 +117,11 @@
 	}
 }
 
-unsigned long fill_random_buf_percentage(struct frand_state *fs, void *buf,
-					 unsigned int percentage,
-					 unsigned int segment, unsigned int len,
-					 char *pattern, unsigned int pbytes)
+void __fill_random_buf_percentage(unsigned long seed, void *buf,
+				  unsigned int percentage,
+				  unsigned int segment, unsigned int len,
+				  char *pattern, unsigned int pbytes)
 {
-	unsigned long r = __rand(fs);
 	unsigned int this_len;
 
 	if (percentage == 100) {
@@ -130,15 +129,12 @@
 			fill_pattern(buf, len, pattern, pbytes);
 		else
 			memset(buf, 0, len);
-		return 0;
+		return;
 	}
 
 	if (segment > len)
 		segment = len;
 
-	if (sizeof(int) != sizeof(long *))
-		r *= (unsigned long) __rand(fs);
-
 	while (len) {
 		/*
 		 * Fill random chunk
@@ -147,7 +143,7 @@
 		if (this_len > len)
 			this_len = len;
 
-		__fill_random_buf(buf, this_len, r);
+		__fill_random_buf(buf, this_len, seed);
 
 		len -= this_len;
 		buf += this_len;
@@ -159,9 +155,23 @@
 			fill_pattern(buf, this_len, pattern, pbytes);
 		else
 			memset(buf, 0, this_len);
+
 		len -= this_len;
 		buf += this_len;
 	}
+}
 
+unsigned long fill_random_buf_percentage(struct frand_state *fs, void *buf,
+					 unsigned int percentage,
+					 unsigned int segment, unsigned int len,
+					 char *pattern, unsigned int pbytes)
+{
+	unsigned long r = __rand(fs);
+
+	if (sizeof(int) != sizeof(long *))
+		r *= (unsigned long) __rand(fs);
+
+	__fill_random_buf_percentage(r, buf, percentage, segment, len,
+					pattern, pbytes);
 	return r;
 }
diff --git a/lib/rand.h b/lib/rand.h
index 803bea4..089837d 100644
--- a/lib/rand.h
+++ b/lib/rand.h
@@ -30,6 +30,7 @@
 extern void init_rand_seed(struct frand_state *, unsigned int seed);
 extern void __fill_random_buf(void *buf, unsigned int len, unsigned long seed);
 extern unsigned long fill_random_buf(struct frand_state *, void *buf, unsigned int len);
+extern void __fill_random_buf_percentage(unsigned long, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
 extern unsigned long fill_random_buf_percentage(struct frand_state *, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
 extern void fill_pattern(void *p, unsigned int len, char *pattern, unsigned int pattern_bytes);
 
diff --git a/verify.c b/verify.c
index c1791fc..6a3f028 100644
--- a/verify.c
+++ b/verify.c
@@ -37,24 +37,28 @@
 void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,
 			 struct io_u *io_u, unsigned long seed, int use_seed)
 {
-	if (!td->o.verify_pattern_bytes) {
+	struct thread_options *o = &td->o;
+
+	if (!o->verify_pattern_bytes) {
 		dprint(FD_VERIFY, "fill random bytes len=%u\n", len);
 
 		if (use_seed)
-			__fill_random_buf(p, len, seed);
-		else
-			io_u->rand_seed = fill_random_buf(&td->verify_state, p, len);
+			__fill_random_buf_percentage(seed, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
+		else {
+			struct frand_state *fs = &td->verify_state;
+
+			io_u->rand_seed = fill_random_buf_percentage(fs, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
+		}
 		return;
 	}
 
 	if (io_u->buf_filled_len >= len) {
 		dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n",
-			td->o.verify_pattern_bytes, len);
+			o->verify_pattern_bytes, len);
 		return;
 	}
 
-	fill_pattern(p, len, td->o.verify_pattern, td->o.verify_pattern_bytes);
-
+	fill_pattern(p, len, o->verify_pattern, o->verify_pattern_bytes);
 	io_u->buf_filled_len = len;
 }