概述
环境
内核版本:linux-4.1.27
打印
sd 1:0:0:0: [sda] sd_setup_read_write_cmnd: block=0, count=32
sd 1:0:0:0: [sda] sd_setup_read_write_cmnd: block=32, count=64
分析
sd_setup_read_write_cmnd
SCSI_LOG_HLQUEUE(1,
scmd_printk(KERN_INFO, SCpnt,
"%s: block=%llu, count=%dn",
__func__, (unsigned long long)block, this_count));
drivers/scsi/scsi_logging.h
extern unsigned int scsi_logging_level;
scsi_logging_level被定义为unsigned int使用32位表示,每3个bit位表示一个打印等级,3个bit位使用偏移表示。
#define SCSI_LOG_HLQUEUE_SHIFT 21
#define SCSI_LOG_HLQUEUE_BITS 3
#define SCSI_LOG_HLQUEUE(LEVEL,CMD)
SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
#define SCSI_LOG_LEVEL(SHIFT, BITS)
((scsi_logging_level >> (SHIFT)) & ((1 << (BITS)) - 1))
#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
do {
if (unlikely((SCSI_LOG_LEVEL(SHIFT, BITS)) > (LEVEL)))
do {
CMD;
} while (0);
} while (0)
SCSI_LOG_HLQUEUE 占用bit[23:21],这3bit值大于LEVEL就会打印,设置 bit[23:21]=2
scsi_logging_level == 0x400000 == 4194304
echo 4194304 > /proc/sys/dev/scsi/logging_level 开打印
echo 0 > /proc/sys/dev/scsi/logging_level 关打印
配置
内核代码依赖配置宏:#define CONFIG_SCSI_LOGGING 1
CONFIG_SCSI_LOGGING=y
打印
写U盘打印:
sd 1:0:0:0: [sda] Send: scmd 0xffffffc033e93080
sd 1:0:0:0: [sda] CCDB: opcode=0x2a 2a 00 01 c0 81 00 00 00 08 00
sd 1:0:0:0: [sda] sd_setup_read_write_cmnd: block=29393424, count=8
sd 1:0:0:0: [sda] block=29393424
sd 1:0:0:0: [sda] writing 8/8 512 byte blocks.
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 81 00 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 81 00 00 00 08 00
sd 1:0:0:0: [sda] 8 sectors total, 4096 bytes done.
读U盘打印:
sd 1:0:0:0: [sda] sd_setup_read_write_cmnd: block=29392960, count=8
sd 1:0:0:0: [sda] block=29392960
sd 1:0:0:0: [sda] reading 8/8 512 byte blocks.
sd 1:0:0:0: [sda] Send: scmd 0xffffffc033e93680
sd 1:0:0:0: [sda] CCDB: opcode=0x28 28 00 01 c0 80 40 00 00 08 00
sd 1:0:0:0: [sda] Done: UNKNOWN(0x2002) Result: hostbyte=0x00 driverbyte=0x00
sd 1:0:0:0: [sda] CCDB: opcode=0x28 28 00 01 c0 80 40 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=0x28 28 00 01 c0 80 40 00 00 08 00
sd 1:0:0:0: [sda] 8 sectors total, 4096 bytes done.
最后
以上就是俏皮曲奇为你收集整理的Linux SCSI LOG打印等级环境打印分析配置打印的全部内容,希望文章能够帮你解决Linux SCSI LOG打印等级环境打印分析配置打印所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复