提交 eaa3e22e 编写于 作者: A Andi Kleen 提交者: James Bottomley

[SCSI] sg: Only print SCSI data direction warning once for a command

When I use cdparanoia my logs get spammed a lot by

printk: 464 messages suppressed.
sg_write: data in/out 30576/30576 bytes for SCSI command 0xbe--guessing data in;
   program cdparanoia not setting count and/or reply_len properly
printk: 1078 messages suppressed.

and many more of those. With this patch the message is only printed once
for a command in a row.

v1->v2: Prevent rate limit messages too (pointed out by jejb)
Signed-off-by: NAndi Kleen <ak@suse.de>
Acked-by: NDouglas Gilbert <dougg@torque.net>
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 d496f94d
...@@ -602,8 +602,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -602,8 +602,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
* but is is possible that the app intended SG_DXFER_TO_DEV, because there * but is is possible that the app intended SG_DXFER_TO_DEV, because there
* is a non-zero input_size, so emit a warning. * is a non-zero input_size, so emit a warning.
*/ */
if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
if (printk_ratelimit()) static char cmd[TASK_COMM_LEN];
if (strcmp(current->comm, cmd) && printk_ratelimit()) {
printk(KERN_WARNING printk(KERN_WARNING
"sg_write: data in/out %d/%d bytes for SCSI command 0x%x--" "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
"guessing data in;\n" KERN_WARNING " " "guessing data in;\n" KERN_WARNING " "
...@@ -611,6 +612,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -611,6 +612,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
old_hdr.reply_len - (int)SZ_SG_HEADER, old_hdr.reply_len - (int)SZ_SG_HEADER,
input_size, (unsigned int) cmnd[0], input_size, (unsigned int) cmnd[0],
current->comm); current->comm);
strcpy(cmd, current->comm);
}
}
k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
return (k < 0) ? k : count; return (k < 0) ? k : count;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册