Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757910AbYABGDT (ORCPT ); Wed, 2 Jan 2008 01:03:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755097AbYABGDI (ORCPT ); Wed, 2 Jan 2008 01:03:08 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45602 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754773AbYABGDF (ORCPT ); Wed, 2 Jan 2008 01:03:05 -0500 From: Andi Kleen Organization: SUSE Linux Products GmbH, Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg) To: linux-scsi@vger.kernel.org Subject: [PATCH] Only print SCSI data direction warning once for a command Date: Wed, 2 Jan 2008 07:03:01 +0100 User-Agent: KMail/1.9.6 Cc: linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801020703.01180.ak@suse.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1788 Lines: 48 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 --- 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/