All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] storvsc: add logging for error/warning messages
@ 2015-12-04  8:07 ` Long Li
  0 siblings, 0 replies; 6+ messages in thread
From: Long Li @ 2015-12-04  8:07 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, James E.J. Bottomley
  Cc: devel, linux-scsi, linux-kernel, Long Li

Introduce a logging level for storvsc to log certain error/warning messages. Those messages are helpful in some environments, e.g. Microsoft Azure, for customer support and troubleshooting purposes.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/scsi/storvsc_drv.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 40c43ae..f46ed2c 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -164,6 +164,26 @@ static int sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
 */
 static int vmstor_proto_version;
 
+#define STORVSC_LOGGING_NONE	0
+#define STORVSC_LOGGING_ERROR	1
+#define STORVSC_LOGGING_WARN	2
+
+static int logging_level = STORVSC_LOGGING_ERROR;
+module_param(logging_level, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(logging_level,
+	"Logging level, 0 - None, 1 - Error (default), 2 - Warning.");
+
+static inline bool do_logging(int level)
+{
+	return logging_level >= level;
+}
+
+#define storvsc_log(dev, level, fmt, ...)			\
+do {								\
+	if (do_logging(level))					\
+		dev_warn(&(dev)->device, fmt, ##__VA_ARGS__);	\
+} while (0)
+
 struct vmscsi_win8_extension {
 	/*
 	 * The following were added in Windows 8
@@ -1185,7 +1205,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
 
 	if (scmnd->result) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
-				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
+				SCSI_SENSE_BUFFERSIZE, &sense_hdr) &&
+		    do_logging(STORVSC_LOGGING_ERROR))
 			scsi_print_sense_hdr(scmnd->device, "storvsc",
 					     &sense_hdr);
 	}
@@ -1239,6 +1260,13 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	stor_pkt->vm_srb.sense_info_length =
 	vstor_packet->vm_srb.sense_info_length;
 
+	if (vstor_packet->vm_srb.scsi_status != 0 ||
+	    vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS)
+		storvsc_log(device, STORVSC_LOGGING_WARN,
+			"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
+			stor_pkt->vm_srb.cdb[0],
+			vstor_packet->vm_srb.scsi_status,
+			vstor_packet->vm_srb.srb_status);
 
 	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
 		/* CHECK_CONDITION */
@@ -1246,6 +1274,10 @@ static void storvsc_on_io_completion(struct hv_device *device,
 			SRB_STATUS_AUTOSENSE_VALID) {
 			/* autosense data available */
 
+			storvsc_log(device, STORVSC_LOGGING_WARN,
+				"stor pkt %p autosense data valid - len %d\n",
+				request, vstor_packet->vm_srb.sense_info_length);
+
 			memcpy(request->cmd->sense_buffer,
 			       vstor_packet->vm_srb.sense_data,
 			       vstor_packet->vm_srb.sense_info_length);
-- 
1.8.5.6


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

* [PATCH v2] storvsc: add logging for error/warning messages
@ 2015-12-04  8:07 ` Long Li
  0 siblings, 0 replies; 6+ messages in thread
From: Long Li @ 2015-12-04  8:07 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, James E.J. Bottomley
  Cc: devel, linux-kernel, linux-scsi

Introduce a logging level for storvsc to log certain error/warning messages. Those messages are helpful in some environments, e.g. Microsoft Azure, for customer support and troubleshooting purposes.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/scsi/storvsc_drv.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 40c43ae..f46ed2c 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -164,6 +164,26 @@ static int sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
 */
 static int vmstor_proto_version;
 
+#define STORVSC_LOGGING_NONE	0
+#define STORVSC_LOGGING_ERROR	1
+#define STORVSC_LOGGING_WARN	2
+
+static int logging_level = STORVSC_LOGGING_ERROR;
+module_param(logging_level, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(logging_level,
+	"Logging level, 0 - None, 1 - Error (default), 2 - Warning.");
+
+static inline bool do_logging(int level)
+{
+	return logging_level >= level;
+}
+
+#define storvsc_log(dev, level, fmt, ...)			\
+do {								\
+	if (do_logging(level))					\
+		dev_warn(&(dev)->device, fmt, ##__VA_ARGS__);	\
+} while (0)
+
 struct vmscsi_win8_extension {
 	/*
 	 * The following were added in Windows 8
@@ -1185,7 +1205,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
 
 	if (scmnd->result) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
-				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
+				SCSI_SENSE_BUFFERSIZE, &sense_hdr) &&
+		    do_logging(STORVSC_LOGGING_ERROR))
 			scsi_print_sense_hdr(scmnd->device, "storvsc",
 					     &sense_hdr);
 	}
@@ -1239,6 +1260,13 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	stor_pkt->vm_srb.sense_info_length =
 	vstor_packet->vm_srb.sense_info_length;
 
+	if (vstor_packet->vm_srb.scsi_status != 0 ||
+	    vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS)
+		storvsc_log(device, STORVSC_LOGGING_WARN,
+			"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
+			stor_pkt->vm_srb.cdb[0],
+			vstor_packet->vm_srb.scsi_status,
+			vstor_packet->vm_srb.srb_status);
 
 	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
 		/* CHECK_CONDITION */
@@ -1246,6 +1274,10 @@ static void storvsc_on_io_completion(struct hv_device *device,
 			SRB_STATUS_AUTOSENSE_VALID) {
 			/* autosense data available */
 
+			storvsc_log(device, STORVSC_LOGGING_WARN,
+				"stor pkt %p autosense data valid - len %d\n",
+				request, vstor_packet->vm_srb.sense_info_length);
+
 			memcpy(request->cmd->sense_buffer,
 			       vstor_packet->vm_srb.sense_data,
 			       vstor_packet->vm_srb.sense_info_length);
-- 
1.8.5.6

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

* RE: [PATCH v2] storvsc: add logging for error/warning messages
  2015-12-04  8:07 ` Long Li
@ 2015-12-09  1:19   ` KY Srinivasan
  -1 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2015-12-09  1:19 UTC (permalink / raw)
  To: Long Li, Haiyang Zhang, James E.J. Bottomley
  Cc: devel, linux-scsi, linux-kernel, Long Li



> -----Original Message-----
> From: Long Li [mailto:longli@microsoft.com]
> Sent: Friday, December 4, 2015 12:07 AM
> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; James E.J. Bottomley <JBottomley@odin.com>
> Cc: devel@linuxdriverproject.org; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org; Long Li <longli@microsoft.com>
> Subject: [PATCH v2] storvsc: add logging for error/warning messages
> 
> Introduce a logging level for storvsc to log certain error/warning messages.
> Those messages are helpful in some environments, e.g. Microsoft Azure, for
> customer support and troubleshooting purposes.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by : K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

> ---
>  drivers/scsi/storvsc_drv.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 40c43ae..f46ed2c 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -164,6 +164,26 @@ static int sense_buffer_size =
> PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
>  */
>  static int vmstor_proto_version;
> 
> +#define STORVSC_LOGGING_NONE	0
> +#define STORVSC_LOGGING_ERROR	1
> +#define STORVSC_LOGGING_WARN	2
> +
> +static int logging_level = STORVSC_LOGGING_ERROR;
> +module_param(logging_level, int, S_IRUGO|S_IWUSR);
> +MODULE_PARM_DESC(logging_level,
> +	"Logging level, 0 - None, 1 - Error (default), 2 - Warning.");
> +
> +static inline bool do_logging(int level)
> +{
> +	return logging_level >= level;
> +}
> +
> +#define storvsc_log(dev, level, fmt, ...)			\
> +do {								\
> +	if (do_logging(level))					\
> +		dev_warn(&(dev)->device, fmt, ##__VA_ARGS__);	\
> +} while (0)
> +
>  struct vmscsi_win8_extension {
>  	/*
>  	 * The following were added in Windows 8
> @@ -1185,7 +1205,8 @@ static void storvsc_command_completion(struct
> storvsc_cmd_request *cmd_request)
> 
>  	if (scmnd->result) {
>  		if (scsi_normalize_sense(scmnd->sense_buffer,
> -				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
> +				SCSI_SENSE_BUFFERSIZE, &sense_hdr) &&
> +		    do_logging(STORVSC_LOGGING_ERROR))
>  			scsi_print_sense_hdr(scmnd->device, "storvsc",
>  					     &sense_hdr);
>  	}
> @@ -1239,6 +1260,13 @@ static void storvsc_on_io_completion(struct
> hv_device *device,
>  	stor_pkt->vm_srb.sense_info_length =
>  	vstor_packet->vm_srb.sense_info_length;
> 
> +	if (vstor_packet->vm_srb.scsi_status != 0 ||
> +	    vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS)
> +		storvsc_log(device, STORVSC_LOGGING_WARN,
> +			"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
> +			stor_pkt->vm_srb.cdb[0],
> +			vstor_packet->vm_srb.scsi_status,
> +			vstor_packet->vm_srb.srb_status);
> 
>  	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
>  		/* CHECK_CONDITION */
> @@ -1246,6 +1274,10 @@ static void storvsc_on_io_completion(struct
> hv_device *device,
>  			SRB_STATUS_AUTOSENSE_VALID) {
>  			/* autosense data available */
> 
> +			storvsc_log(device, STORVSC_LOGGING_WARN,
> +				"stor pkt %p autosense data valid - len
> %d\n",
> +				request, vstor_packet-
> >vm_srb.sense_info_length);
> +
>  			memcpy(request->cmd->sense_buffer,
>  			       vstor_packet->vm_srb.sense_data,
>  			       vstor_packet->vm_srb.sense_info_length);
> --
> 1.8.5.6


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

* RE: [PATCH v2] storvsc: add logging for error/warning messages
@ 2015-12-09  1:19   ` KY Srinivasan
  0 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2015-12-09  1:19 UTC (permalink / raw)
  To: Long Li, Haiyang Zhang, James E.J. Bottomley
  Cc: devel, linux-kernel, linux-scsi



> -----Original Message-----
> From: Long Li [mailto:longli@microsoft.com]
> Sent: Friday, December 4, 2015 12:07 AM
> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; James E.J. Bottomley <JBottomley@odin.com>
> Cc: devel@linuxdriverproject.org; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org; Long Li <longli@microsoft.com>
> Subject: [PATCH v2] storvsc: add logging for error/warning messages
> 
> Introduce a logging level for storvsc to log certain error/warning messages.
> Those messages are helpful in some environments, e.g. Microsoft Azure, for
> customer support and troubleshooting purposes.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by : K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

> ---
>  drivers/scsi/storvsc_drv.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 40c43ae..f46ed2c 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -164,6 +164,26 @@ static int sense_buffer_size =
> PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
>  */
>  static int vmstor_proto_version;
> 
> +#define STORVSC_LOGGING_NONE	0
> +#define STORVSC_LOGGING_ERROR	1
> +#define STORVSC_LOGGING_WARN	2
> +
> +static int logging_level = STORVSC_LOGGING_ERROR;
> +module_param(logging_level, int, S_IRUGO|S_IWUSR);
> +MODULE_PARM_DESC(logging_level,
> +	"Logging level, 0 - None, 1 - Error (default), 2 - Warning.");
> +
> +static inline bool do_logging(int level)
> +{
> +	return logging_level >= level;
> +}
> +
> +#define storvsc_log(dev, level, fmt, ...)			\
> +do {								\
> +	if (do_logging(level))					\
> +		dev_warn(&(dev)->device, fmt, ##__VA_ARGS__);	\
> +} while (0)
> +
>  struct vmscsi_win8_extension {
>  	/*
>  	 * The following were added in Windows 8
> @@ -1185,7 +1205,8 @@ static void storvsc_command_completion(struct
> storvsc_cmd_request *cmd_request)
> 
>  	if (scmnd->result) {
>  		if (scsi_normalize_sense(scmnd->sense_buffer,
> -				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
> +				SCSI_SENSE_BUFFERSIZE, &sense_hdr) &&
> +		    do_logging(STORVSC_LOGGING_ERROR))
>  			scsi_print_sense_hdr(scmnd->device, "storvsc",
>  					     &sense_hdr);
>  	}
> @@ -1239,6 +1260,13 @@ static void storvsc_on_io_completion(struct
> hv_device *device,
>  	stor_pkt->vm_srb.sense_info_length =
>  	vstor_packet->vm_srb.sense_info_length;
> 
> +	if (vstor_packet->vm_srb.scsi_status != 0 ||
> +	    vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS)
> +		storvsc_log(device, STORVSC_LOGGING_WARN,
> +			"cmd 0x%x scsi status 0x%x srb status 0x%x\n",
> +			stor_pkt->vm_srb.cdb[0],
> +			vstor_packet->vm_srb.scsi_status,
> +			vstor_packet->vm_srb.srb_status);
> 
>  	if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
>  		/* CHECK_CONDITION */
> @@ -1246,6 +1274,10 @@ static void storvsc_on_io_completion(struct
> hv_device *device,
>  			SRB_STATUS_AUTOSENSE_VALID) {
>  			/* autosense data available */
> 
> +			storvsc_log(device, STORVSC_LOGGING_WARN,
> +				"stor pkt %p autosense data valid - len
> %d\n",
> +				request, vstor_packet-
> >vm_srb.sense_info_length);
> +
>  			memcpy(request->cmd->sense_buffer,
>  			       vstor_packet->vm_srb.sense_data,
>  			       vstor_packet->vm_srb.sense_info_length);
> --
> 1.8.5.6

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

* Re: [PATCH v2] storvsc: add logging for error/warning messages
  2015-12-04  8:07 ` Long Li
@ 2015-12-10 18:12   ` Martin K. Petersen
  -1 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2015-12-10 18:12 UTC (permalink / raw)
  To: Long Li
  Cc: K. Y. Srinivasan, Haiyang Zhang, James E.J. Bottomley, devel,
	linux-scsi, linux-kernel

>>>>> "Long" == Long Li <longli@microsoft.com> writes:

Long> Introduce a logging level for storvsc to log certain error/warning
Long> messages. Those messages are helpful in some environments,
Long> e.g. Microsoft Azure, for customer support and troubleshooting
Long> purposes.

Applied to 4.5/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v2] storvsc: add logging for error/warning messages
@ 2015-12-10 18:12   ` Martin K. Petersen
  0 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2015-12-10 18:12 UTC (permalink / raw)
  To: Long Li
  Cc: linux-scsi, Haiyang Zhang, James E.J. Bottomley, linux-kernel, devel

>>>>> "Long" == Long Li <longli@microsoft.com> writes:

Long> Introduce a logging level for storvsc to log certain error/warning
Long> messages. Those messages are helpful in some environments,
Long> e.g. Microsoft Azure, for customer support and troubleshooting
Long> purposes.

Applied to 4.5/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2015-12-10 18:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04  8:07 [PATCH v2] storvsc: add logging for error/warning messages Long Li
2015-12-04  8:07 ` Long Li
2015-12-09  1:19 ` KY Srinivasan
2015-12-09  1:19   ` KY Srinivasan
2015-12-10 18:12 ` Martin K. Petersen
2015-12-10 18:12   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.