From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755026AbbLDC2S (ORCPT ); Thu, 3 Dec 2015 21:28:18 -0500 Received: from smtprelay0040.hostedemail.com ([216.40.44.40]:42453 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754740AbbLDC2Q (ORCPT ); Thu, 3 Dec 2015 21:28:16 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:3872:4321:5007:6119:6261:7688:7903:8660:10004:10400:10848:11026:11232:11473:11658:11783:11914:12043:12048:12296:12438:12517:12519:12740:13148:13161:13229:13230:13894:14037:14659:21080:21212:30046:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: ship79_db14305ab657 X-Filterd-Recvd-Size: 2968 Message-ID: <1449196093.17296.36.camel@perches.com> Subject: Re: [PATCH] storvsc: add more logging for error and warning messages From: Joe Perches To: Long Li , "K. Y. Srinivasan" , Haiyang Zhang , "James E.J. Bottomley" Cc: devel@linuxdriverproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2015 18:28:13 -0800 In-Reply-To: <1449200865-20694-1-git-send-email-longli@microsoft.com> References: <1449200865-20694-1-git-send-email-longli@microsoft.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.2-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-12-03 at 19:47 -0800, Long Li wrote: > 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. [] > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c [] > +static inline bool do_logging(int level) > +{ > + return (logging_level >= level) ? true : false; The ternary is not necessary return logging_level >= level; is enough > +} > + > + >  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", Is it appropriate to make this scsi_normalize_sense call conditional on do_logging here? > @@ -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); It might make some sense to use another macro indirection like #define svc_log_warn(dev, level, fmt, ...) \ do { \ if (do_logging(STORSVC_LOGGING_##level) \ dev_warn(&(dev)->device, fmt, ##__VA_ARGS__); \ } while (0) So a use could be: if (vstore_packet...) svc_log_warn(device, WARN, ...); >