From patchwork Fri Dec 4 03:47:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 7765051 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 54EE3BEEE1 for ; Fri, 4 Dec 2015 02:16:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B38A204F6 for ; Fri, 4 Dec 2015 02:16:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CBF2204E7 for ; Fri, 4 Dec 2015 02:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754728AbbLDCPr (ORCPT ); Thu, 3 Dec 2015 21:15:47 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:44999 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754648AbbLDCPr (ORCPT ); Thu, 3 Dec 2015 21:15:47 -0500 Received: from linuxonhyperv.com ([72.167.245.219]) by : HOSTING RELAY : with SMTP id 4fuUavTnZGozP4fuUafAaY; Thu, 03 Dec 2015 19:15:46 -0700 x-originating-ip: 72.167.245.219 Received: by linuxonhyperv.com (Postfix, from userid 511) id EFD9F190342; Thu, 3 Dec 2015 19:48:41 -0800 (PST) From: Long Li To: "K. Y. 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] storvsc: add more logging for error and warning messages Date: Thu, 3 Dec 2015 19:47:45 -0800 Message-Id: <1449200865-20694-1-git-send-email-longli@microsoft.com> X-Mailer: git-send-email 1.7.4.1 X-CMAE-Envelope: MS4wfHRHslP68vkEVghAk/SwsjY52AY24eYmU06QUIuQuHD+d8BLD3kZl/YfAMx8MPeDP0D8xQxgWYYn9SlxnX5WDrWmtDrnzhXrkwNVB5dlP164CtpOzFwu Tvi2lKAJOZQFkmpHSvuZfYlbPkKJjP0tCTTnHHW7/83TBrauixbxC9/dT6kPWXxkyrA3iLpNPPiW/1DmJjjxFAQKI2fHg9L6nmXaXkvN33qfohpRkQOQg8No 1jR9mLKMSYVbrF4isSSTw4pstUK9XJJg0Hc/+OaZ32D6FQBeprQBNU6htUEgOyuLiIqxUiSWCFwVla85mGHyLDBvBXT4zWpmxFTwmyNWm/sEunMtxH3pUGKG PCE7AMnJ2Fnsqv/RwZ6UTRK4vSQcWVDbFjoYGbxfY5f8Zp6bbh4= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/scsi/storvsc_drv.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 40c43ae..afa1647 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -164,6 +164,21 @@ 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) ? true : false; +} + + struct vmscsi_win8_extension { /* * The following were added in Windows 8 @@ -1183,7 +1198,7 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request) scmnd->result = vm_srb->scsi_status; - if (scmnd->result) { + if (scmnd->result && do_logging(STORVSC_LOGGING_ERROR)) { if (scsi_normalize_sense(scmnd->sense_buffer, SCSI_SENSE_BUFFERSIZE, &sense_hdr)) scsi_print_sense_hdr(scmnd->device, "storvsc", @@ -1239,12 +1254,25 @@ 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) + if (do_logging(STORVSC_LOGGING_WARN)) + dev_warn(&device->device, + "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 */ if (vstor_packet->vm_srb.srb_status & SRB_STATUS_AUTOSENSE_VALID) { /* autosense data available */ + if (do_logging(STORVSC_LOGGING_WARN)) + dev_warn(&device->device, + "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,