md5校验

fio --direct=1 --rw=write --verify=md5 --do_verify=1 --bs=4k --size=4k --numjobs=1 --ioengine=libaio --iodepth=128  --group_reporting --name=file1 --filename=/dev/sdp --verify_pattern=0x12345678

然后从sdp用dd读取数据

dd if=/dev/sdp of=1.bin bs=4k count=1 iflag=direct

查看1.bin中的数据

[root@ ~]# hexdump -C 1.bin
00000000  ca ac 02 00 00 10 00 00  00 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  01 00 00 00 2d fd 52 0d  08 19 95 0a 73 ff 03 0b  |....-.R.....s...|
00000030  c1 73 be 56 a8 ba 27 4e  12 34 56 78 12 34 56 78  |.s.V..'N.4Vx.4Vx|
00000040  12 34 56 78 12 34 56 78  12 34 56 78 12 34 56 78  |.4Vx.4Vx.4Vx.4Vx|
*
00001000
[root@ ~]#

用下面的命令只校验

[root@216 ~]# fio --direct=1 --rw=read --verify=md5 --bs=4k --size=4k --numjobs=1 --ioengine=libaio --i
odepth=128  --group_reporting --name=file1 --filename=/dev/sdp --verify_pattern=0x12345678 --verify_onl
y
file1: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
28
fio-3.1
Starting 1 process

file1: (groupid=0, jobs=1): err= 0: pid=4170: Fri Mar 29 00:48:08 2019
   read: IOPS=1000, BW=4000KiB/s (4096kB/s)(4096B/1msec)
    slat (nsec): min=43050, max=43050, avg=43050.00, stdev= 0.00
    clat (nsec): min=135090, max=135090, avg=135090.00, stdev= 0.00
     lat (nsec): min=186718, max=186718, avg=186718.00, stdev= 0.00
    clat percentiles (usec):
     |  1.00th=[  135],  5.00th=[  135], 10.00th=[  135], 20.00th=[  135],
     | 30.00th=[  135], 40.00th=[  135], 50.00th=[  135], 60.00th=[  135],
     | 70.00th=[  135], 80.00th=[  135], 90.00th=[  135], 95.00th=[  135],
     | 99.00th=[  135], 99.50th=[  135], 99.90th=[  135], 99.95th=[  135],
     | 99.99th=[  135]
  lat (usec)   : 250=100.00%
  cpu          : usr=0.00%, sys=0.00%, ctx=2, majf=0, minf=42
  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=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwt: total=1,0,0, short=0,0,0, dropped=0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=128

Run status group 0 (all jobs):
   READ: bw=4000KiB/s (4096kB/s), 4000KiB/s-4000KiB/s (4096kB/s-4096kB/s), io=4096B (4096B), run=1-1mse
c

Disk stats (read/write):
  sdp: ios=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00%

然后把刚才的sdp磁盘的开头清理掉一个扇区

dd if=/dev/zero of=/dev/sdp bs=512 count=1 oflag=direct

读取出来查看内容

[root@216 ~]# dd if=/dev/sdp of=2.bin bs=4k count=1 iflag=direct
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.000540766 s, 7.6 MB/s
[root@216 ~]# hexdump -C 2.bin
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200  12 34 56 78 12 34 56 78  12 34 56 78 12 34 56 78  |.4Vx.4Vx.4Vx.4Vx|
*
00001000
[root@216 ~]#

看到开头的512个字节全为0了.

然后用fio进行只校验.

[root@216 ~]# fio --direct=1 --rw=read --verify=md5 --bs=4k --size=4k --numjobs=1 --ioengine=libaio --i
odepth=128  --group_reporting --name=file1 --filename=/dev/sdp --verify_pattern=0x12345678 --verify_onl
y
file1: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
28
fio-3.1
Starting 1 process
verify: bad magic header 0, wanted acca at file /dev/sdp offset 0, length 4096
file1: No I/O performed by libaio, perhaps try --debug=io option for details?
fio: pid=4232, err=84/file:io_u.c:2030, func=io_u_queued_complete, error=Invalid or incomplete multibyt
e or wide character

file1: (groupid=0, jobs=1): err=84 (file:io_u.c:2030, func=io_u_queued_complete, error=Invalid or incom
plete multibyte or wide character): pid=4232: Fri Mar 29 00:51:04 2019
   read: IOPS=1000, BW=4000KiB/s (4096kB/s)(4096B/1msec)
    slat (nsec): min=36055, max=36055, avg=36055.00, stdev= 0.00
    clat (nsec): min=150621, max=150621, avg=150621.00, stdev= 0.00
     lat (nsec): min=194556, max=194556, avg=194556.00, stdev= 0.00
    clat percentiles (usec):
     |  1.00th=[  151],  5.00th=[  151], 10.00th=[  151], 20.00th=[  151],
     | 30.00th=[  151], 40.00th=[  151], 50.00th=[  151], 60.00th=[  151],
     | 70.00th=[  151], 80.00th=[  151], 90.00th=[  151], 95.00th=[  151],
     | 99.00th=[  151], 99.50th=[  151], 99.90th=[  151], 99.95th=[  151],
     | 99.99th=[  151]
  lat (usec)   : 250=100.00%
  cpu          : usr=0.00%, sys=0.00%, ctx=6, majf=0, minf=66
  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=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwt: total=1,0,0, short=0,0,0, dropped=0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=128

Run status group 0 (all jobs):
   READ: bw=4000KiB/s (4096kB/s), 4000KiB/s-4000KiB/s (4096kB/s-4096kB/s), io=4096B (4096B), run=1-1msec

Disk stats (read/write):
  sdp: ios=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00%

从上面的对比中已经发现了数据错误.

关闭多余的输出

不是每次fio都需要打印大量的统计信息,可以用--stats=0来关闭

[root@ ~]# fio --cmdhelp=stats
               stats: Enable collection of stats
                type: boolean value (opt=1)
             default: 1
               range: min=0, max=1