From: Vincent Fu Date: Thu, 8 May 2025 18:58:10 +0000 (-0400) Subject: verify: fix verify_offset when used with pattern_hdr X-Git-Tag: fio-3.40~10 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b683f9ea7ff76677872dc53d8e5162d5f42b5a01;p=fio.git verify: fix verify_offset when used with pattern_hdr When using verify=pattern_hdr with verify_offset, we cannot reuse the data already in a buffer because some of the pattern bytes have been swapped with the verify header. Trying to reuse the buffer contents just results in the header being swapped back and forth between the verify_offset location and the beginning of the verify_interval. Fix this by avoiding reuse of buffer contents. Failing test case example: root@localhost:~/fio-dev/fio-canonical# ./fio --name=verify --filesize=8192 --verify_offset=1024 --verify_pattern=1 --rw=write verify: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1 fio-3.39-38-gf18c Starting 1 process fio: got pattern 'ca', wanted '01'. Bad bits 5 fio: bad pattern block offset 1024 pattern: verify failed at file verify.0.0 offset 4096, length 4096 (requested block: offset=4096, length=4096, flags=88) fio: pid=3624903, err=84/file:io_u.c:2258, func=io_u_sync_complete, error=Invalid or incomplete multibyte or wide character verify: (groupid=0, jobs=1): err=84 (file:io_u.c:2258, func=io_u_sync_complete, error=Invalid or incomplete multibyte or wide character): pid=3624903: Fri Apr 11 22:56:01 2025 read: IOPS=2000, BW=8000KiB/s (8192kB/s)(8192B/1msec) clat (nsec): min=2185, max=15807, avg=8996.00, stdev=9632.21 lat (nsec): min=2280, max=16120, avg=9200.00, stdev=9786.36 clat percentiles (nsec): | 1.00th=[ 2192], 5.00th=[ 2192], 10.00th=[ 2192], 20.00th=[ 2192], | 30.00th=[ 2192], 40.00th=[ 2192], 50.00th=[ 2192], 60.00th=[15808], | 70.00th=[15808], 80.00th=[15808], 90.00th=[15808], 95.00th=[15808], | 99.00th=[15808], 99.50th=[15808], 99.90th=[15808], 99.95th=[15808], | 99.99th=[15808] write: IOPS=2000, BW=8000KiB/s (8192kB/s)(8192B/1msec); 0 zone resets clat (nsec): min=7910, max=82940, avg=45425.00, stdev=53054.22 lat (usec): min=9, max=100, avg=55.03, stdev=64.49 clat percentiles (nsec): | 1.00th=[ 7904], 5.00th=[ 7904], 10.00th=[ 7904], 20.00th=[ 7904], | 30.00th=[ 7904], 40.00th=[ 7904], 50.00th=[ 7904], 60.00th=[82432], | 70.00th=[82432], 80.00th=[82432], 90.00th=[82432], 95.00th=[82432], | 99.00th=[82432], 99.50th=[82432], 99.90th=[82432], 99.95th=[82432], | 99.99th=[82432] lat (usec) : 4=25.00%, 10=25.00%, 20=25.00%, 100=25.00% cpu : usr=0.00%, sys=0.00%, ctx=0, majf=0, minf=19 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=20.0%, 4=80.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued rwts: total=2,2,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=1 Run status group 0 (all jobs): READ: bw=8000KiB/s (8192kB/s), 8000KiB/s-8000KiB/s (8192kB/s-8192kB/s), io=8192B (8192B), run=1-1msec WRITE: bw=8000KiB/s (8192kB/s), 8000KiB/s-8000KiB/s (8192kB/s-8192kB/s), io=8192B (8192B), run=1-1msec Disk stats (read/write): sda: ios=0/0, sectors=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00% Link: https://lore.kernel.org/r/20250508185832.3702-3-vincent.fu@samsung.com Signed-off-by: Vincent Fu --- diff --git a/verify.c b/verify.c index 928bdd54..e7e619d3 100644 --- a/verify.c +++ b/verify.c @@ -65,9 +65,10 @@ void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len, return; } - /* Skip if we were here and we do not need to patch pattern - * with format */ - if (!td->o.verify_fmt_sz && io_u->buf_filled_len >= len) { + /* Skip if we were here and we do not need to patch pattern with + * format. However, we cannot skip if verify_offset is set because we + * have swapped the header with pattern bytes */ + if (!td->o.verify_fmt_sz && io_u->buf_filled_len >= len && !td->o.verify_offset) { dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n", o->verify_pattern_bytes, len); return;