public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	James Bottomley <jbottomley@parallels.com>,
	Ewan Milne <emilne@redhat.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 16/20] scsi: separate out scsi_retval_string()
Date: Fri, 05 Sep 2014 08:14:19 +0200	[thread overview]
Message-ID: <540954BB.6080500@suse.de> (raw)
In-Reply-To: <54091A22.1070900@hitachi.com>

On 09/05/2014 04:04 AM, Yoshihiro YUNOMAE wrote:
> (2014/09/03 19:06), Hannes Reinecke wrote:
>> Implement scsi_retval_string() to simplify logging.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>>   drivers/scsi/constants.c | 28 ++++++++++++++++++++++++++++
>>   drivers/scsi/scsi.c      | 34 ++++++----------------------------
>>   include/scsi/scsi_dbg.h  |  1 +
>>   3 files changed, 35 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
>> index 5486816..85d2da0 100644
>> --- a/drivers/scsi/constants.c
>> +++ b/drivers/scsi/constants.c
>> @@ -1426,6 +1426,34 @@ void scsi_print_sense(struct scsi_cmnd *cmd)
>>   EXPORT_SYMBOL(scsi_print_sense);
>>   
>>   #ifdef CONFIG_SCSI_CONSTANTS
>> +static const struct error_info internal_retval_table[] =
>> +{
>> +	{ NEEDS_RETRY, "NEEDS_RETRY " },
>> +	{ SUCCESS, "SUCCESS " },
>> +	{ FAILED, "FAILED " },
>> +	{ QUEUED, "QUEUED " },
>> +	{ SOFT_ERROR, "SOFT_ERROR " },
>> +	{ ADD_TO_MLQUEUE, "ADD_TO_MLQUEUE " },
>> +	{ TIMEOUT_ERROR, "TIMEOUT " },
>> +	{ SCSI_RETURN_NOT_HANDLED, "NOT_HANDLED " },
>> +	{ FAST_IO_FAIL, "FAST_IO_FAIL " },
> 
> We don't need to add space in the last of strings, I think.
> In scsi_log_completion(), the messages inserts line feeds after the
> strings.
> 
>> +};
>> +#endif
>> +
>> +const char *
>> +scsi_retval_string(unsigned int ret)
>> +{
>> +#ifdef CONFIG_SCSI_CONSTANTS
>> +	int i;
>> +
>> +	for (i = 0; internal_retval_table[i].text; i++)
>> +		if (internal_retval_table[i].code12 == ret)
>> +			return internal_retval_table[i].text;
>> +#endif
>> +	return NULL;
>> +}
>> +
>> +#ifdef CONFIG_SCSI_CONSTANTS
>>   
>>   static const char * const hostbyte_table[]={
>>   "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
>> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
>> index 8954036..a1944c8 100644
>> --- a/drivers/scsi/scsi.c
>> +++ b/drivers/scsi/scsi.c
>> @@ -566,35 +566,13 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
>>   				       SCSI_LOG_MLCOMPLETE_BITS);
>>   		if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
>>   		    (level > 1)) {
>> -			scmd_printk(KERN_INFO, cmd, "Done: ");
>>   			if (level > 2)
>> -				printk("0x%p ", cmd);
>> -			/*
>> -			 * Dump truncated values, so we usually fit within
>> -			 * 80 chars.
>> -			 */
>> -			switch (disposition) {
>> -			case SUCCESS:
>> -				printk("SUCCESS\n");
>> -				break;
>> -			case NEEDS_RETRY:
>> -				printk("RETRY\n");
>> -				break;
>> -			case ADD_TO_MLQUEUE:
>> -				printk("MLQUEUE\n");
>> -				break;
>> -			case FAILED:
>> -				printk("FAILED\n");
>> -				break;
>> -			case TIMEOUT_ERROR:
>> -				/*
>> -				 * If called via scsi_times_out.
>> -				 */
>> -				printk("TIMEOUT\n");
>> -				break;
>> -			default:
>> -				printk("UNKNOWN\n");
>> -			}
>> +				scmd_printk(KERN_INFO, cmd,
>> +					    "Done: 0x%p %s\n", cmd,
>> +					    scsi_retval_string(disposition));
>> +			else
>> +				scmd_printk(KERN_INFO, cmd, "Done: %s",
> 
> We had better add "\n" in this last strings to indicate the end of line.
> Structured printk automatically outputs the message in atomic,
> but adding "\n" becomes more readable.
> 
True, we should be adding the newline.
Although the reasoning is wrong; a newline instructs printk() to
actually ship out the message. Without a newline printk assumes
it'll be line continuation.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-09-05  6:14 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
2014-09-06  0:02   ` Christoph Hellwig
2014-09-03 10:05 ` [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
2014-09-06  0:03   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 05/20] scsi: Use sdev as argument for sense code printing Hannes Reinecke
2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
2014-09-06  0:04   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
2014-09-06  0:04   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
2014-09-05  0:51   ` Yoshihiro YUNOMAE
2014-09-05  6:07     ` Hannes Reinecke
2014-09-06  0:09   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
2014-09-06  0:10   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 10/20] Implement scsi_opcode_sa_name Hannes Reinecke
2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
2014-09-06  0:11   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 12/20] scsi: merge print_opcode_name() Hannes Reinecke
2014-09-05  1:24   ` Yoshihiro YUNOMAE
2014-09-06  0:12     ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
2014-09-06  0:46   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
2014-09-05  2:02   ` Yoshihiro YUNOMAE
2014-09-07 16:10   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 15/20] libata: use __scsi_print_command() Hannes Reinecke
2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
2014-09-05  2:04   ` Yoshihiro YUNOMAE
2014-09-05  6:14     ` Hannes Reinecke [this message]
2014-09-07 16:11   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
2014-09-05  4:19   ` Yoshihiro YUNOMAE
2014-09-07 16:12   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
2014-09-05  4:22   ` Yoshihiro YUNOMAE
2014-09-07 16:17   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
2014-09-07 16:17   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
2014-09-05  4:23   ` Yoshihiro YUNOMAE
2014-09-06  0:33   ` Christoph Hellwig
2014-09-13  1:07     ` Elliott, Robert (Server Storage)
2014-09-14 10:49       ` Hannes Reinecke
2014-09-14 16:40       ` Christoph Hellwig
2014-09-06  0:51 ` [PATCHv2 00/20] scsi logging update Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=540954BB.6080500@suse.de \
    --to=hare@suse.de \
    --cc=emilne@redhat.com \
    --cc=hch@infradead.org \
    --cc=jbottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=yoshihiro.yunomae.ez@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox