From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752289AbbLIBfA (ORCPT ); Tue, 8 Dec 2015 20:35:00 -0500 Received: from mail-bn1bon0117.outbound.protection.outlook.com ([157.56.111.117]:18560 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751741AbbLIBe6 convert rfc822-to-8bit (ORCPT ); Tue, 8 Dec 2015 20:34:58 -0500 From: KY Srinivasan To: Long Li , Haiyang Zhang , "James E.J. Bottomley" CC: "devel@linuxdriverproject.org" , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Long Li Subject: RE: [PATCH v2] storvsc: add logging for error/warning messages Thread-Topic: [PATCH v2] storvsc: add logging for error/warning messages Thread-Index: AQHRLl3jMewi3pnkKUeyxLqL+fDztZ7B4pKQ Date: Wed, 9 Dec 2015 01:19:44 +0000 Message-ID: References: <1449216444-21553-1-git-send-email-longli@microsoft.com> In-Reply-To: <1449216444-21553-1-git-send-email-longli@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kys@microsoft.com; x-originating-ip: [2001:4898:80e8:9::6f4] x-microsoft-exchange-diagnostics: 1;BY2PR0301MB0775;5:LiVTnkzrQ+kaLpbwPUJ96ZGrws3Fc+90Fh9vlZ1ihL1n3eLFVv/nA1suLna+RM8M84o1GikNLCcJZRGpSTV6FX95Cr2j7aRgD2W8ddoRldFCtO8z1hmgLeWJNLI6rr6sOewyQAYm4zKj7Ix62ZUvWQ==;24:0xY5PsCg+yZWfw1aGyoxM5x/l5Ghomf/8iz5Y3URIj5Uj1B7H7F2we8M40wicCWVdpos54Y+b/+CFLA/fwChKR0/AQC0Sq7Fn6j3Qqxm3Xc= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0775; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046)(61426038)(61427038);SRVR:BY2PR0301MB0775;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0775; x-forefront-prvs: 0785459C39 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(199003)(189002)(13464003)(101416001)(122556002)(106116001)(5002640100001)(5001960100002)(107886002)(10400500002)(5008740100001)(2561002)(40100003)(33656002)(5004730100002)(2950100001)(106356001)(2900100001)(77096005)(1511001)(10290500002)(19580395003)(19580405001)(86612001)(81156007)(97736004)(5001770100001)(54356999)(92566002)(86362001)(76176999)(1096002)(1220700001)(50986999)(5003600100002)(99286002)(5005710100001)(10090500001)(105586002)(2421001)(87936001)(11100500001)(74316001)(76576001)(6116002)(8990500004)(189998001)(102836003)(4001430100002)(586003)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0301MB0775;H:BY2PR0301MB1654.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Dec 2015 01:19:44.8735 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB0775 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Long Li [mailto:longli@microsoft.com] > Sent: Friday, December 4, 2015 12:07 AM > To: KY Srinivasan ; Haiyang Zhang > ; James E.J. Bottomley > Cc: devel@linuxdriverproject.org; linux-scsi@vger.kernel.org; linux- > kernel@vger.kernel.org; Long Li > 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 Reviewed-by : K. Y. Srinivasan Signed-off-by: K. Y. Srinivasan > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: KY Srinivasan Subject: RE: [PATCH v2] storvsc: add logging for error/warning messages Date: Wed, 9 Dec 2015 01:19:44 +0000 Message-ID: References: <1449216444-21553-1-git-send-email-longli@microsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1449216444-21553-1-git-send-email-longli@microsoft.com> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: Long Li , Haiyang Zhang , "James E.J. Bottomley" Cc: "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" List-Id: linux-scsi@vger.kernel.org > -----Original Message----- > From: Long Li [mailto:longli@microsoft.com] > Sent: Friday, December 4, 2015 12:07 AM > To: KY Srinivasan ; Haiyang Zhang > ; James E.J. Bottomley > Cc: devel@linuxdriverproject.org; linux-scsi@vger.kernel.org; linux- > kernel@vger.kernel.org; Long Li > 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 Reviewed-by : K. Y. Srinivasan Signed-off-by: K. Y. Srinivasan > --- > 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