dd命令一般用于测试磁盘性能,主要测试的是顺序读写性能,但是没有证明过,此次通过ktap来证实dd却为顺序读写
通过下述命令跟踪scsi
./ktap -s scsi:scsi_dispatch_cmd_done
同时运行dd命令,进行写操作
#dd if=/dev/zero of=test bs=1024 count=10
ktap跟踪的输出结果如下:
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=127 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345327616 txlen=1024 protect=0 raw=2a 00 14 95 48 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345328640 txlen=1024 protect=0 raw=2a 00 14 95 4c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345329664 txlen=1024 protect=0 raw=2a 00 14 95 50 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345330688 txlen=1024 protect=0 raw=2a 00 14 95 54 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345331712 txlen=1024 protect=0 raw=2a 00 14 95 58 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345332736 txlen=1024 protect=0 raw=2a 00 14 95 5c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=127 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345333760 txlen=1024 protect=0 raw=2a 00 14 95 60 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345334784 txlen=1024 protect=0 raw=2a 00 14 95 64 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345335808 txlen=1024 protect=0 raw=2a 00 14 95 68 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345336832 txlen=1024 protect=0 raw=2a 00 14 95 6c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345337856 txlen=1024 protect=0 raw=2a 00 14 95 70 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345338880 txlen=1024 protect=0 raw=2a 00 14 95 74 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345339904 txlen=1024 protect=0 raw=2a 00 14 95 78 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345340928 txlen=1024 protect=0 raw=2a 00 14 95 7c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345341952 txlen=1024 protect=0 raw=2a 00 14 95 80 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345342976 txlen=1024 protect=0 raw=2a 00 14 95 84 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345344000 txlen=1024 protect=0 raw=2a 00 14 95 88 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345345024 txlen=1024 protect=0 raw=2a 00 14 95 8c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=116 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345346048 txlen=1024 protect=0 raw=2a 00 14 95 90 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
6 0 swapper/6 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=63 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=345347072 txlen=1024 protect=0 raw=2a 00 14 95 94 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
通过读取lba数值,可以查看到地址是连续的,从而可以得知dd在写数据过程是连续的IO;
在来看看读操作
输入dd命令
#dd iflag=direct,nonblock if=test of=/dev/zero bs=1M count=10
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345327616 txlen=1024 protect=0 raw=28 00 14 95 48 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345328640 txlen=1024 protect=0 raw=28 00 14 95 4c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345329664 txlen=1024 protect=0 raw=28 00 14 95 50 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345330688 txlen=1024 protect=0 raw=28 00 14 95 54 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345331712 txlen=1024 protect=0 raw=28 00 14 95 58 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345332736 txlen=1024 protect=0 raw=28 00 14 95 5c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345333760 txlen=1024 protect=0 raw=28 00 14 95 60 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345334784 txlen=1024 protect=0 raw=28 00 14 95 64 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345335808 txlen=1024 protect=0 raw=28 00 14 95 68 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345336832 txlen=1024 protect=0 raw=28 00 14 95 6c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345337856 txlen=1024 protect=0 raw=28 00 14 95 70 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345338880 txlen=1024 protect=0 raw=28 00 14 95 74 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345339904 txlen=1024 protect=0 raw=28 00 14 95 78 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345340928 txlen=1024 protect=0 raw=28 00 14 95 7c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345341952 txlen=1024 protect=0 raw=28 00 14 95 80 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345342976 txlen=1024 protect=0 raw=28 00 14 95 84 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345344000 txlen=1024 protect=0 raw=28 00 14 95 88 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345345024 txlen=1024 protect=0 raw=28 00 14 95 8c 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=128 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345346048 txlen=1024 protect=0 raw=28 00 14 95 90 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
1 0 swapper/1 scsi_dispatch_cmd_done: host_no=0 channel=1 id=0 lun=0 data_sgl=117 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(READ_10 lba=345347072 txlen=1024 protect=0 raw=28 00 14 95 94 00 00 04 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD)
通过读取lba数值,可以看到dd的读io也是顺序的!
从而证明了dd在默认情况下是进行顺序读写测试的。