linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Only print SCSI data direction warning once for a command
@ 2008-01-02  6:03 Andi Kleen
  2008-01-12 19:36 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2008-01-02  6:03 UTC (permalink / raw)
  To: linux-scsi; +Cc: linux-kernel


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.

Signed-off-by: Andi Kleen <ak@suse.de>

---
 drivers/scsi/sg.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: linux/drivers/scsi/sg.c
===================================================================
--- linux.orig/drivers/scsi/sg.c
+++ linux/drivers/scsi/sg.c
@@ -602,8 +602,9 @@ sg_write(struct file *filp, const char _
 	 * but is is possible that the app intended SG_DXFER_TO_DEV, because there
 	 * is a non-zero input_size, so emit a warning.
 	 */
-	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
-		if (printk_ratelimit())
+	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
+		static char cmd[TASK_COMM_LEN];
+		if (printk_ratelimit() && strcmp(current->comm, cmd)) {
 			printk(KERN_WARNING
 			       "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
 			       "guessing data in;\n" KERN_WARNING "   "
@@ -611,6 +612,9 @@ sg_write(struct file *filp, const char _
 			       old_hdr.reply_len - (int)SZ_SG_HEADER,
 			       input_size, (unsigned int) cmnd[0],
 			       current->comm);
+			strcpy(cmd, current->comm);
+		}
+	}
 	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
 	return (k < 0) ? k : count;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Only print SCSI data direction warning once for a command
  2008-01-02  6:03 [PATCH] Only print SCSI data direction warning once for a command Andi Kleen
@ 2008-01-12 19:36 ` James Bottomley
  2008-01-13 16:41   ` Andi Kleen
  0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2008-01-12 19:36 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-scsi, linux-kernel, dougg

On Wed, 2008-01-02 at 07:03 +0100, Andi Kleen wrote:
> 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.

My reaction is that the intent of these warnings is to try to get people
to fix broken applications, so I'm not sure any action is appropriate;
however, it's Doug's driver, so I'll defer to him.

Even if he does say yes, though, your patch looks wrong.  It's still
going to spew the 

printk: 1078 messages suppressed.

to the log because they come from printk_ratelimit().  So all you've
done is halved the volume of flow to the logs and left a dangling printk
suppressed message that keeps spewing, so I don't think the patch even
does what you describe it as doing ...  if you reverse the order of the
operands in the if() it will ...

James



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Only print SCSI data direction warning once for a command
  2008-01-12 19:36 ` James Bottomley
@ 2008-01-13 16:41   ` Andi Kleen
  2008-01-15  5:02     ` Douglas Gilbert
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2008-01-13 16:41 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, linux-kernel, dougg


> to the log because they come from printk_ratelimit().  So all you've
> done is halved the volume of flow to the logs and left a dangling printk
> suppressed message that keeps spewing, so I don't think the patch even
> does what you describe it as doing ...  if you reverse the order of the
> operands in the if() it will ...

Here's an updated patch with the reversed order.

-Andi

---

Only print SCSI data direction warning once for a command v2

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 <ak@suse.de>

---
 drivers/scsi/sg.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: linux/drivers/scsi/sg.c
===================================================================
--- linux.orig/drivers/scsi/sg.c
+++ linux/drivers/scsi/sg.c
@@ -602,8 +602,9 @@ sg_write(struct file *filp, const char _
 	 * but is is possible that the app intended SG_DXFER_TO_DEV, because there
 	 * is a non-zero input_size, so emit a warning.
 	 */
-	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
-		if (printk_ratelimit())
+	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
+		static char cmd[TASK_COMM_LEN];
+		if (strcmp(current->comm, cmd) && printk_ratelimit()) {
 			printk(KERN_WARNING
 			       "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
 			       "guessing data in;\n" KERN_WARNING "   "
@@ -611,6 +612,9 @@ sg_write(struct file *filp, const char _
 			       old_hdr.reply_len - (int)SZ_SG_HEADER,
 			       input_size, (unsigned int) cmnd[0],
 			       current->comm);
+			strcpy(cmd, current->comm);
+		}
+	}
 	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
 	return (k < 0) ? k : count;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Only print SCSI data direction warning once for a command
  2008-01-13 16:41   ` Andi Kleen
@ 2008-01-15  5:02     ` Douglas Gilbert
  0 siblings, 0 replies; 4+ messages in thread
From: Douglas Gilbert @ 2008-01-15  5:02 UTC (permalink / raw)
  To: Andi Kleen; +Cc: James Bottomley, linux-scsi, linux-kernel

Andi Kleen wrote:
>> to the log because they come from printk_ratelimit().  So all you've
>> done is halved the volume of flow to the logs and left a dangling printk
>> suppressed message that keeps spewing, so I don't think the patch even
>> does what you describe it as doing ...  if you reverse the order of the
>> operands in the if() it will ...
> 
> Here's an updated patch with the reversed order.
> 
> -Andi
> 
> ---
> 
> Only print SCSI data direction warning once for a command v2
> 
> 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 <ak@suse.de>
> 
> ---
>  drivers/scsi/sg.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> Index: linux/drivers/scsi/sg.c
> ===================================================================
> --- linux.orig/drivers/scsi/sg.c
> +++ linux/drivers/scsi/sg.c
> @@ -602,8 +602,9 @@ sg_write(struct file *filp, const char _
>  	 * but is is possible that the app intended SG_DXFER_TO_DEV, because there
>  	 * is a non-zero input_size, so emit a warning.
>  	 */
> -	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
> -		if (printk_ratelimit())
> +	if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
> +		static char cmd[TASK_COMM_LEN];
> +		if (strcmp(current->comm, cmd) && printk_ratelimit()) {
>  			printk(KERN_WARNING
>  			       "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
>  			       "guessing data in;\n" KERN_WARNING "   "
> @@ -611,6 +612,9 @@ sg_write(struct file *filp, const char _
>  			       old_hdr.reply_len - (int)SZ_SG_HEADER,
>  			       input_size, (unsigned int) cmnd[0],
>  			       current->comm);
> +			strcpy(cmd, current->comm);
> +		}
> +	}
>  	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
>  	return (k < 0) ? k : count;
>  }
> 
> 

Signed-off-by: Douglas Gilbert <dougg@torque.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-15  5:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-02  6:03 [PATCH] Only print SCSI data direction warning once for a command Andi Kleen
2008-01-12 19:36 ` James Bottomley
2008-01-13 16:41   ` Andi Kleen
2008-01-15  5:02     ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).