1、TF卡异常问题情况
目前市场盒子64G以上的金士顿TF卡在使用过程中出现写文件失败导致监控视频进程启动失败,目前已经发现有6台盒子出现这个问题,从市场拿回2张TF卡,分别是金士顿64G和128G,通过做实验和测试分析结果如下:
2、出现问题的TF卡现象和打印
现象:
盒子启动后挂载TF卡成功,但是会一直报Buffer I/O error错误,导致写文件失败。
打印:
Scsi中读写指令:
#define READ_10 0x28
#define WRITE_10 0x2a
Scsi中读写状态:
#define NEEDS_RETRY 0x2001 表示失败需要重试
#define SUCCESS 0x2002 表示成功
#define FAILED 0x2003 重试达到7次就彻底失败
1)主动往TF卡挂载目录写文件异常打印:
sd 1:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
sd 1:0:0:0: [sda] Sense Key : 0xb [current]
sd 1:0:0:0: [sda] ASC=0x30 ASCQ=0x0
sd 1:0:0:0: [sda] CDB: opcode=0x2a 2a 00 00 a9 c2 00 00 02 00 00
blk_update_request: I/O error, dev sda, sector 11125248
EXT4-fs warning (device sda1): ext4_end_bio:332: I/O error -5 writing to inode 14392 (offset 0 size 4194304 starting block 1390720)
buffer_io_error: 54 callbacks suppressed
Buffer I/O error on device sda1, logical block 1386560
Buffer I/O error on device sda1, logical block 1386561
Buffer I/O error on device sda1, logical block 1386562
Buffer I/O error on device sda1, logical block 1386563
Buffer I/O error on device sda1, logical block 1386564
Buffer I/O error on device sda1, logical block 1386565
Buffer I/O error on device sda1, logical block 1386566
Buffer I/O error on device sda1, logical block 1386567
Buffer I/O error on device sda1, logical block 1386568
Buffer I/O error on device sda1, logical block 1386569
2)重启后没有往TF卡挂载目录写文件异常打印:
sd 1:0:0:0: [sdb] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
sd 1:0:0:0: [sdb] Sense Key : 0xb [current]
sd 1:0:0:0: [sdb] ASC=0x30 ASCQ=0x0
sd 1:0:0:0: [sdb] CDB: opcode=0x2a 2a 00 04 00 8e c0 00 00 28 00
blk_update_request: I/O error, dev sdb, sector 67145408
Buffer I/O error on dev sdb1, logical block 8389080, lost async page write
Buffer I/O error on dev sdb1, logical block 8389081, lost async page write
Buffer I/O error on dev sdb1, logical block 8389082, lost async page write
Buffer I/O error on dev sdb1, logical block 8389083, lost async page write
Buffer I/O error on dev sdb1, logical block 8389084, lost async page write
3)少量的读失败状态:
sd 1:0:0:0: [sda] Done: UNKNOWN(0x2001) Result: hostbyte=0x00 driverbyte=0x00
sd 1:0:0:0: [sda] CCDB: opcode=0x28 28 00 05 80 01 40 00 00 80 00
sd 1:0:0:0: [sda] Sense Key : 0xb [current]
sd 1:0:0:0: [sda] ASC=0x30 ASCQ=0x0
sd 1:0:0:0: [sda] scsi host busy 1 failed 0
sd 1:0:0:0: [sda] Inserting command ffffffc03162d6c0 into mlqueue
sd 1:0:0:0: unblocking device at zero depth
sd 1:0:0:0: [sda] Send: scmd 0xffffffc03162d6c0
4)少量的写成功状态:
sd 1:0:0:0: [sda] Done: UNKNOWN(0x2002) Result: hostbyte=0x00 driverbyte=0x00
sd 1:0:0:0: [sda] CCDB: opcode=0x2a 2a 00 01 c0 80 48 00 00 08 00
sd 1:0:0:0: [sda] scsi host busy 1 failed 0
sd 1:0:0:0: Notifying upper driver of completion (result 0)
sd 1:0:0:0: [sda] sd_done: completed 4096 of 4096 bytes
sd 1:0:0:0: [sda] CCDB: opcode=0x2a 2a 00 01 c0 80 48 00 00 08 00
sd 1:0:0:0: [sda] 8 sectors total, 4096 bytes done.
sd 1:0:0:0: [sda] Send: scmd 0xffffffc033e93c80
sd 1:0:0:0: [sda] CCDB: opcode=0x2a 2a 00 01 c0 80 a0 00 00 08 00
sd 1:0:0:0: [sda] sd_setup_read_write_cmnd: block=29393152, count=8
sd 1:0:0:0: [sda] block=29393152
sd 1:0:0:0: [sda] writing 8/8 512 byte blocks.
3、做过的测试和结论
1)目前出问题的TF卡都是SDXC类型,走的是USB3.0高速通道,硬件上把3.0功能去掉后TF卡在2.0 ehci快速通道模式也出现I/O error;说明USB3.0和2.0都会出问题。
2)把报I/O error的TF卡装入2.0读卡器后再插上二代机USB3.0接口,开机启动挂载后没有报I/O error问题并且读写正常,再把TF卡插回卡槽很长一段时间没有报I/O error,但是在后面测试过程中又出现I/O error。
3)使用dd命令直接写TF卡设备文件,没有触发I/O error,但dd写的物理块暂无法与文件系统的逻辑块对应,所以此测试不能说明dd写没有问题。
4)在scsi中添加打印看出,dd直接写TF卡设备文件和cp拷贝文件到TF卡挂载目录使用的指令集是一样的,都是用的WRITE_10(0x2a),说明如果dd命令写到出问题的logical block应该也会出问题。
5)打开内核中CONFIG_SCSI_LOGGING宏,可发现写TF卡挂载目录文件会有少量的写成功状态,同时也会有少量的读失败状态,由于写的文件没有完全写入导致不完整,重启后文件丢失;