From patchwork Sat Apr 2 17:10:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurence Oberman X-Patchwork-Id: 8732161 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0C7049F38C for ; Sat, 2 Apr 2016 17:10:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C4D3202DD for ; Sat, 2 Apr 2016 17:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9095A2025A for ; Sat, 2 Apr 2016 17:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753089AbcDBRKR (ORCPT ); Sat, 2 Apr 2016 13:10:17 -0400 Received: from mx5-phx2.redhat.com ([209.132.183.37]:40802 "EHLO mx5-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751991AbcDBRKP convert rfc822-to-8bit (ORCPT ); Sat, 2 Apr 2016 13:10:15 -0400 Received: from zmail22.collab.prod.int.phx2.redhat.com (zmail22.collab.prod.int.phx2.redhat.com [10.5.83.26]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u32HA9K2046119; Sat, 2 Apr 2016 13:10:09 -0400 Date: Sat, 2 Apr 2016 13:10:08 -0400 (EDT) From: Laurence Oberman To: Himanshu Madhani Cc: "Nicholas A. Bellinger" , Bart Van Assche , linux-scsi , target-devel , Quinn Tran Message-ID: <363538615.26701710.1459617008813.JavaMail.zimbra@redhat.com> In-Reply-To: <1615130599.26684873.1459613094650.JavaMail.zimbra@redhat.com> References: <2025450295.25603731.1459262558755.JavaMail.zimbra@redhat.com> <56FB5E98.9010103@sandisk.com> <1459402453.31390.45.camel@haakon3.risingtidesystems.com> <3F517A19-EDA5-4B16-B103-C3F38242F8D8@qlogic.com> <1049122887.26432420.1459534525185.JavaMail.zimbra@redhat.com> <1615130599.26684873.1459613094650.JavaMail.zimbra@redhat.com> Subject: Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision4 MIME-Version: 1.0 X-Originating-IP: [10.36.6.77] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF38 (Linux)/8.0.6_GA_5922) Thread-Topic: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision3 Thread-Index: ijRl2r2idYjwugcXD6icxp9GJCosIrpIzhEAgAGaXoCAAMVzgEINHo9NRGG01G1J5bhxvg== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Hello Himanshu I noticed a typo in the patch I submitted here is the corrected patch. Please ignore the prior patch I was missing the full CONFIG name in the #ifdef check Corrected Patch [root@localhost home]# linux-4.5/scripts/checkpatch.pl jammer_patch.v4 total: 0 errors, 0 warnings, 81 lines checked jammer_patch.v4 has no obvious style problems and is ready for submission. This patch was reworked to only include the jammer code if the parameter TCM_QLA2XXX_DEBUG=Y is set. The default is to not provide this functionality at all. I looked at using attributes but this code is in the fastpath and the overhead or fetching the attribute each time is not a good idea. Control of this needs to be dynamic and the module parameter allows a simple compare in the fastpath. Patch notes ------------ I use target LIO for all my storage array test targets and customer problem resolution here at Red Hat. This patch resulted from a requirement to mimic behavior of an expensive hardware jammer for a customer. I have used this for some time with good success to simulate and reproduce latency and slow drain fabric issues and for testing and validating error handling behavior in the Emulex, Qlogic and other F/C drivers. Works by checking new parameter jam_host if its >= 0 and matches vha->host_no , jamming is enabled when jam_host >=0 If parameter set to -1 (default) no jamming is enabled. Tested by: Laurence Oberman Signed-off-by: Laurence Oberman Laurence Oberman Principal Software Maintenance Engineer Red Hat Global Support Services ----- Original Message ----- From: "Laurence Oberman" To: "Himanshu Madhani" Cc: "Nicholas A. Bellinger" , "Bart Van Assche" , "linux-scsi" , "target-devel" , "Quinn Tran" Sent: Friday, April 1, 2016 2:15:25 PM Subject: Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision3 Himanshu I looked at using the attribute for this but because of where I have to discard the command I dont want to have to go fetch the attribute each time in the same code path. Its significant overhead to have to go fetch the attribute value each time as I allow for a dynamic on off via the module parameter so I have to check it each command. With the module parameter its a simple compare and by having this as a module parameter its globally accessible and imposes virtually no overhead. Are you OK with me using #ifdef on the CONFIG_TCM_QLA2XXX_DEBUG .config parameter I will add here to include the module parameter and code only if set to "yes" The default unless expicitly set will be no change. Thanks Laurence Oberman Principal Software Maintenance Engineer Red Hat Global Support Services ----- Original Message ----- From: "Himanshu Madhani" To: "Nicholas A. Bellinger" , "Bart Van Assche" Cc: "Laurence Oberman" , "linux-scsi" , "target-devel" , "Quinn Tran" Sent: Thursday, March 31, 2016 8:20:56 PM Subject: Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision3 Hi Nic, Laurence, On 3/30/16, 10:34 PM, "Nicholas A. Bellinger" wrote: >(Adding target-devel + Qlogic target folks) > >On Tue, 2016-03-29 at 22:05 -0700, Bart Van Assche wrote: >> On 03/29/16 07:42, Laurence Oberman wrote: >> > I have been using this jammer functionality to continue testing the SCSI F/C drivers and recovery for over a year now. >> > Any chance you would agree to ack this so I can get it in now. >> > I last posted to the list last March and it was not picked up. >> > >> > I did look into moving this to upper layers but I find I use it primarily for fiber channel target testing. >> > Attempting to add this functionality to upper layers led to complexities and this is very solid. >> > >> > This Patch diff against 4.5 >> > >> > I use target LIO for all my storage array test targets and customer problem resolution here at Red Hat. >> > This patch resulted from a requirement to mimic behavior of an expensive hardware jammer for a customer. >> > I have used this for some time with good success to simulate and reproduce latency and slow drain fabric issues and >> > for testing and validating error handling behavior >> > in the Emulex, Qlogic and other F/C drivers. >> > >> > Works by checking new parameter jam_host if its >= 0 and matches vha->host_no , jamming is enabled when jam_host >=0 >> > If parameter set to -1 (default) no jamming is enabled. >> >> Hello Laurence, >> >> Nic Bellinger is the maintainer of LIO so my recommendation is to ask >> Nic first about his opinion (I have CC'd Nic). I'm not sure what Nic >> thinks about this but in my opinion such functionality belongs in the >> target core instead of in a target driver. But please wait until Nic has >> provided his opinion before spending more time on this. The mailing list >> for SCSI target patches is target-devel@vger.kernel.org. >> > >So really it's Himanshu's + Quinn's call if they would like to include >something like this in mainline. > >If so, then I'd prefer to do it with a per tcm_qla2xxx_tpg endpoint >attribute instead a new module parameter, and add a new kernel config >option (CONFIG_TCM_QLA2XXX_DEBUG) to disable (by default) so end users >don't inadvertently play with it via targetcli + friends. > I agree here with Nic. The patch does provides benefit and is good addition, but we don’t want to enable it by default. Laurence, Would you be kind to rework patch with suggested changes from Nic and post it. Thanks, Himanshu N?????r??y???b?X???v?^?)?{.n?+????{???"?{ay????,j??f???h???z??w??????j:+v???w?j?m????????zZ+???j"?? --- 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 -- 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 diff -Nurp linux-4.5/Documentation/scsi/tcm_qla2xxx.txt linux-4.5.new/Documentation/scsi/tcm_qla2xxx.txt --- linux-4.5/Documentation/scsi/tcm_qla2xxx.txt 1969-12-31 19:00:00.000000000 -0500 +++ linux-4.5.new/Documentation/scsi/tcm_qla2xxx.txt 2016-04-02 11:36:42.693081232 -0400 @@ -0,0 +1,34 @@ +tcm_qla2xxx jammer parameter usage +---------------------------------- +There is now a new module parameter added to the tcm_qla2xx module +parm: jam_host:Host to jam >=0 Enable jammer (int) +This parameter and accompanying code is only included if the +Kconfig parameter TCM_QLA2XXX_DEBUG is set to Y +By default this jammer code and functionality is disabled + +Use this parameter to control the discarding of SCSI commands to a selected +host. +This may be useful for testing error handling and simulating slow drain +and other fabric issues. + +Any value >=0 that matches a fc_host # will discard the commands for that host. +Reset back to -1 to stop the jamming. + +Enable host 6 to be jammed +echo 6 > /sys/module/tcm_qla2xxx/parameters/jam_host + +Disable jamming on host 6 +echo -1 > /sys/module/tcm_qla2xxx/parameters/jam_host + +Usage example script: + +#!/bin/bash +sleep_time=120 ### Time to jam for +echo 6 > /sys/module/tcm_qla2xxx/parameters/jam_host +host=`cat /sys/module/tcm_qla2xxx/parameters/jam_host` +echo "We start to discard commands on SCSI host $host" +logger "Jammer started" +sleep $sleep_time +echo -1 > /sys/module/tcm_qla2xxx/parameters/jam_host +echo "We stopped the jammer" +logger "Jammer stopped" diff -Nurp linux-4.5/drivers/scsi/qla2xxx/Kconfig linux-4.5.new/drivers/scsi/qla2xxx/Kconfig --- linux-4.5/drivers/scsi/qla2xxx/Kconfig 2016-03-14 00:28:54.000000000 -0400 +++ linux-4.5.new/drivers/scsi/qla2xxx/Kconfig 2016-04-02 11:31:15.302516676 -0400 @@ -36,3 +36,13 @@ config TCM_QLA2XXX default n ---help--- Say Y here to enable the TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs + +config TCM_QLA2XXX_DEBUG + bool "TCM_QLA2XXX fabric module DEBUG mode for QLogic 24xx+ series target mode HBAs" + depends on SCSI_QLA_FC && TARGET_CORE + depends on LIBFC + select BTREE + default n + ---help--- + Say Y here to enable the TCM_QLA2XXX fabric module DEBUG for QLogic 24xx+ series target mode HBAs + This will include code to enable the SCSI command jammer diff -Nurp linux-4.5/drivers/scsi/qla2xxx/tcm_qla2xxx.c linux-4.5.new/drivers/scsi/qla2xxx/tcm_qla2xxx.c --- linux-4.5/drivers/scsi/qla2xxx/tcm_qla2xxx.c 2016-03-14 00:28:54.000000000 -0400 +++ linux-4.5.new/drivers/scsi/qla2xxx/tcm_qla2xxx.c 2016-04-02 11:32:35.317410249 -0400 @@ -48,6 +48,12 @@ #include "qla_target.h" #include "tcm_qla2xxx.h" +#ifdef CONFIG_TCM_QLA2XXX_DEBUG +int jam_host = -1; +module_param(jam_host, int, 0644); +MODULE_PARM_DESC(jam_host, "Host to jam >=0 Enable jammer"); +#endif + static struct workqueue_struct *tcm_qla2xxx_free_wq; static struct workqueue_struct *tcm_qla2xxx_cmd_wq; @@ -477,6 +483,13 @@ static int tcm_qla2xxx_handle_cmd(scsi_q return -EINVAL; } +#ifdef CONFIG_TCM_QLA2XXX_DEBUG + if (unlikely(vha->host_no == jam_host)) { + /* return, and dont run target_submit_cmd,discarding command */ + return 0; + } +#endif + cmd->vha->tgt_counters.qla_core_sbt_cmd++; return target_submit_cmd(se_cmd, se_sess, cdb, &cmd->sense_buffer[0], cmd->unpacked_lun, data_length, fcp_task_attr, @@ -1967,6 +1980,9 @@ static void tcm_qla2xxx_deregister_confi static int __init tcm_qla2xxx_init(void) { int ret; +#ifdef CONFIG_TCM_QLA2XXX_DEBUG + jam_host = -1; +#endif ret = tcm_qla2xxx_register_configfs(); if (ret < 0) ----- Original Message ----- From: "Laurence Oberman" To: "Himanshu Madhani" Cc: "Nicholas A. Bellinger" , "Bart Van Assche" , "linux-scsi" , "target-devel" , "Quinn Tran" Sent: Saturday, April 2, 2016 12:04:54 PM Subject: Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision4 Hello Himanshu This patch was reworked to only include the jammer code if the parameter TCM_QLA2XXX_DEBUG=Y is set. The default is to not provide this functionality at all. I looked at using attributes but this code is in the fastpath and the overhead or fetching the attribute each time is not a good idea. Control of this needs to be dynamic and the module parameter allows a simple compare in the fastpath. Patch notes ------------ I use target LIO for all my storage array test targets and customer problem resolution here at Red Hat. This patch resulted from a requirement to mimic behavior of an expensive hardware jammer for a customer. I have used this for some time with good success to simulate and reproduce latency and slow drain fabric issues and for testing and validating error handling behavior in the Emulex, Qlogic and other F/C drivers. Works by checking new parameter jam_host if its >= 0 and matches vha->host_no , jamming is enabled when jam_host >=0 If parameter set to -1 (default) no jamming is enabled. Tested by: Laurence Oberman Signed-off-by: Laurence Oberman diff -Nurp linux-4.5/Documentation/scsi/tcm_qla2xxx.txt linux-4.5.new/Documentation/scsi/tcm_qla2xxx.txt --- linux-4.5/Documentation/scsi/tcm_qla2xxx.txt 1969-12-31 19:00:00.000000000 -0500 +++ linux-4.5.new/Documentation/scsi/tcm_qla2xxx.txt 2016-04-02 11:36:42.693081232 -0400 @@ -0,0 +1,34 @@ +tcm_qla2xxx jammer parameter usage +---------------------------------- +There is now a new module parameter added to the tcm_qla2xx module +parm: jam_host:Host to jam >=0 Enable jammer (int) +This parameter and accompanying code is only included if the +Kconfig parameter TCM_QLA2XXX_DEBUG is set to Y +By default this jammer code and functionality is disabled + +Use this parameter to control the discarding of SCSI commands to a selected +host. +This may be useful for testing error handling and simulating slow drain +and other fabric issues. + +Any value >=0 that matches a fc_host # will discard the commands for that host. +Reset back to -1 to stop the jamming. + +Enable host 6 to be jammed +echo 6 > /sys/module/tcm_qla2xxx/parameters/jam_host + +Disable jamming on host 6 +echo -1 > /sys/module/tcm_qla2xxx/parameters/jam_host + +Usage example script: + +#!/bin/bash +sleep_time=120 ### Time to jam for +echo 6 > /sys/module/tcm_qla2xxx/parameters/jam_host +host=`cat /sys/module/tcm_qla2xxx/parameters/jam_host` +echo "We start to discard commands on SCSI host $host" +logger "Jammer started" +sleep $sleep_time +echo -1 > /sys/module/tcm_qla2xxx/parameters/jam_host +echo "We stopped the jammer" +logger "Jammer stopped" diff -Nurp linux-4.5/drivers/scsi/qla2xxx/Kconfig linux-4.5.new/drivers/scsi/qla2xxx/Kconfig --- linux-4.5/drivers/scsi/qla2xxx/Kconfig 2016-03-14 00:28:54.000000000 -0400 +++ linux-4.5.new/drivers/scsi/qla2xxx/Kconfig 2016-04-02 11:31:15.302516676 -0400 @@ -36,3 +36,13 @@ config TCM_QLA2XXX default n ---help--- Say Y here to enable the TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs + +config TCM_QLA2XXX_DEBUG + bool "TCM_QLA2XXX fabric module DEBUG mode for QLogic 24xx+ series target mode HBAs" + depends on SCSI_QLA_FC && TARGET_CORE + depends on LIBFC + select BTREE + default n + ---help--- + Say Y here to enable the TCM_QLA2XXX fabric module DEBUG for QLogic 24xx+ series target mode HBAs + This will include code to enable the SCSI command jammer diff -Nurp linux-4.5/drivers/scsi/qla2xxx/tcm_qla2xxx.c linux-4.5.new/drivers/scsi/qla2xxx/tcm_qla2xxx.c --- linux-4.5/drivers/scsi/qla2xxx/tcm_qla2xxx.c 2016-03-14 00:28:54.000000000 -0400 +++ linux-4.5.new/drivers/scsi/qla2xxx/tcm_qla2xxx.c 2016-04-02 11:32:35.317410249 -0400 @@ -48,6 +48,12 @@ #include "qla_target.h" #include "tcm_qla2xxx.h" +#ifdef TCM_QLA2XXX_DEBUG +int jam_host = -1; +module_param(jam_host, int, 0644); +MODULE_PARM_DESC(jam_host, "Host to jam >=0 Enable jammer"); +#endif + static struct workqueue_struct *tcm_qla2xxx_free_wq; static struct workqueue_struct *tcm_qla2xxx_cmd_wq; @@ -477,6 +483,13 @@ static int tcm_qla2xxx_handle_cmd(scsi_q return -EINVAL; } +#ifdef TCM_QLA2XXX_DEBUG + if (unlikely(vha->host_no == jam_host)) { + /* return, and dont run target_submit_cmd,discarding command */ + return 0; + } +#endif + cmd->vha->tgt_counters.qla_core_sbt_cmd++; return target_submit_cmd(se_cmd, se_sess, cdb, &cmd->sense_buffer[0], cmd->unpacked_lun, data_length, fcp_task_attr, @@ -1967,6 +1980,9 @@ static void tcm_qla2xxx_deregister_confi static int __init tcm_qla2xxx_init(void) { int ret; +#ifdef TCM_QLA2XXX_DEBUG + jam_host = -1; +#endif ret = tcm_qla2xxx_register_configfs(); if (ret < 0)