Skip to content

Commit eaa3e22

Browse files
Andi KleenJames Bottomley
authored andcommitted
[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: Andi Kleen <[email protected]> Acked-by: Douglas Gilbert <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent d496f94 commit eaa3e22

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/scsi/sg.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,19 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
602602
* but is is possible that the app intended SG_DXFER_TO_DEV, because there
603603
* is a non-zero input_size, so emit a warning.
604604
*/
605-
if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
606-
if (printk_ratelimit())
605+
if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
606+
static char cmd[TASK_COMM_LEN];
607+
if (strcmp(current->comm, cmd) && printk_ratelimit()) {
607608
printk(KERN_WARNING
608609
"sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
609610
"guessing data in;\n" KERN_WARNING " "
610611
"program %s not setting count and/or reply_len properly\n",
611612
old_hdr.reply_len - (int)SZ_SG_HEADER,
612613
input_size, (unsigned int) cmnd[0],
613614
current->comm);
615+
strcpy(cmd, current->comm);
616+
}
617+
}
614618
k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
615619
return (k < 0) ? k : count;
616620
}

0 commit comments

Comments
 (0)