Re: [PATCH 0/2] target: make location of /var/target configurable

2016-04-02 Thread Nicholas A. Bellinger
On Thu, 2016-03-31 at 11:05 -0700, Lee Duncan wrote:
> These patches make the location of "/var/target" configurable,
> though it still defauls to "/var/target".
> 
> This configuration is accomplished via the configfs
> top-level target attribute "dbroot", i.e. dumping
> out "/sys/kernel/config/target/dbroot" will normally
> return "/var/target". Writing to this attribute
> changes the loation where the kernel looks for the
> target database.
> 
> ** NOTE/QUESTION: no sanity checks are done on the path passed in,
>but it seems like *some* should be done. At least checking that
>it's an abosolute path (i.e. starts with '/')? Opinions?
> 

Wrt to sanity checking db_root at configfs attribute store time, how
about doing a filp_open() + S_DIR(f_inode->imode) + filp_close() of the
requested path to verify it's really a directory..?

Also, it would probably be a good idea to limit when db_root can be
changed.  Eg, only allow db_root to be changed when no active target
fabric drivers have been registered (list_empty(g_tf_list)), and require
userspace to set a different db_root after modprobe target_core_mod
completes, but before any fabric drivers are loaded.




--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: QoS for iSCSI target?

2016-04-02 Thread Nicholas A. Bellinger
On Fri, 2016-04-01 at 12:35 -0600, Chris Friesen wrote:
> On 03/31/2016 01:05 AM, Nicholas A. Bellinger wrote:
> > On Wed, 2016-03-16 at 10:48 -0600, Chris Friesen wrote:
> >> On 03/11/2016 01:45 AM, Nicholas A. Bellinger wrote:
> >>> On Thu, 2016-03-10 at 23:30 -0800, Christoph Hellwig wrote:
>  On Thu, Mar 10, 2016 at 04:24:25PM -0600, Chris Friesen wrote:
> > Hi,
> >
> > I'm looking for information on whether the iSCSI target in the kernel 
> > offers
> > any way to do QoS between traffic driven by different initiators.
> >
> > I'm trying to make sure that one initiator can't do a denial-of-service
> > attack against others.
> >
> > Does the kernel target have this sort of thing built-in, or do I need to
> > look at network traffic-shaping to achieve this?
> 
>  It doesn't right now, but it shouldn't be hard to integrate it with
>  blk cgroups.
> >>>
> >>> For iscsi-target application QoS, the per session command sequence
> >>> number window depth (CmdSN) exists to enforce per InitiatorName limits
> >>> via TPG default_cmdsn_depth + se_node_acl->queue_depth configfs
> >>> attributes.
> >>>
> >>> Note these values can be changed on the fly for iscsi-target using
> >>> explicit se_node_acl->acl_group, but currently require a se_session
> >>> reinstatement event for updated ExpCmdSN + MaxCmdSN to take effect.
> >>
> >> On a slightly different note, is there any way to throttle or limit the 
> >> overall
> >> bandwidth consumed by the iSCSI target in the kernel?  I'd like to ensure 
> >> that
> >> the iSCSI traffic doesn't completely swamp the host accesses to the same 
> >> block
> >> device.
> >>
> >> I suppose I could do networking-based traffic shaping, but are there any
> >> controls in the block IO subsystem?
> >>
> >
> > On a individual block_device backend basis, block cgroups is the
> > preferred method for doing this.
> >
> > Note that any rate limiting imposed by block cgroups is subject to the
> > current se_node_acl->queue_depth enforced across all LUNs within a given
> > iscsi session.
> 
> 
> How would I use cgroups with the kernel iSCSI target?  Is there a set of 
> kernel 
> threads dedicated to the iSCSI target that I can assign to a particular group?
> 

block cgroups can set I/O throttling (bandwidth + IOPs) limits for any
normal struct block_device.

These values are configured via blkio.throttle.* resource class, and the
limits are imposed independently of the block_device's association with
target_core_mod backend driver export.  Namely:

blkio.throttle.write_iops_device
blkio.throttle.read_iops_device
blkio.throttle.write_bps_device
blkio.throttle.read_bdp_device

Some examples using these values, plus more blkio.* info is here:
http://events.linuxfoundation.org/sites/events/files/slides/cgroups_0.pdf.

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision4

2016-04-02 Thread Nicholas A. Bellinger
Hi Laurence,

On Sat, 2016-04-02 at 13:10 -0400, Laurence Oberman wrote:
> 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

Two quick process related comments:

Please avoid top-posting responses, as it makes the thread more
difficult for others to follow.

Also, please send out kernel patches for list review using
git-format-patch + git-send-email tools, instead of responding with new
versions in the original email thread.

> 
> [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.
> 

I don't see how a per tcm_qla2xxx (scsi_qla_host) TPG endpoint attribute
has any noticeable performance impact with TCM_QLA2XXX_DEBUG=y vs. a
global module parameter doing scsi_qla_host->host_no comparison.

Eg, have you tried something like the following..?

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index c1461d2..3b13a89a 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -477,6 +477,17 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, 
struct qla_tgt_c
return -EINVAL;
}
 
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+   {
+   struct se_portal_group *se_tpg = se_sess->se_tpg;
+   struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
+   struct tcm_qla2xxx_tpg, se_tpg);
+
+   if (tpg->tpg_attrib.jam_host)
+   return 0;
+
+   }
+#endif
cmd->vha->tgt_counters.qla_core_sbt_cmd++;
return target_submit_cmd(se_cmd, se_sess, cdb, >sense_buffer[0],
cmd->unpacked_lun, data_length, fcp_task_attr,
@@ -845,12 +856,19 @@ DEF_QLA_TPG_ATTRIB(demo_mode_write_protect);
 DEF_QLA_TPG_ATTRIB(prod_mode_write_protect);
 DEF_QLA_TPG_ATTRIB(demo_mode_login_only);
 
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+DEF_QLA_TPG_ATTRIB(jam_host);
+#endif
+
 static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = {
_qla2xxx_tpg_attrib_attr_generate_node_acls,
_qla2xxx_tpg_attrib_attr_cache_dynamic_acls,
_qla2xxx_tpg_attrib_attr_demo_mode_write_protect,
_qla2xxx_tpg_attrib_attr_prod_mode_write_protect,
_qla2xxx_tpg_attrib_attr_demo_mode_login_only,
+#ifdef CONFIG_TCM_QLA2XXX_DEBUG
+   _qla2xxx_tpg_attrib_attr_jam_host,
+#endif
NULL,
 };
 
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 3bbf4cb..37e026a 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -34,6 +34,7 @@ struct tcm_qla2xxx_tpg_attrib {
int prod_mode_write_protect;
int demo_mode_login_only;
int fabric_prot_type;
+   int jam_host;
 };
 
 struct tcm_qla2xxx_tpg {


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL] target fixes for v4.6-rc2

2016-04-02 Thread Nicholas A. Bellinger
Hello Linus,

Here are outstanding target-pending fixes for v4.6-rc2.

Please go ahead and pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

This includes fixes from HCH for -rc1 configfs default_groups conversion
changes that ended up breaking some iscsi-target default_groups, along
with Sagi's ib_drain_qp() conversion for iser-target to use the common
caller now available to RDMA kernel consumers in v4.6+ code.

Thank you,

--nab

Christoph Hellwig (3):
  target: remove ->fabric_cleanup_nodeacl
  target: initialize the nacl base CIT begfore init_nodeacl
  target: add a new add_wwn_groups fabrics method

Sagi Grimberg (1):
  iser-target: Use ib_drain_qp

 drivers/infiniband/ulp/isert/ib_isert.c  | 39 +++-
 drivers/infiniband/ulp/isert/ib_isert.h  |  2 --
 drivers/target/iscsi/iscsi_target_configfs.c | 28 
 drivers/target/target_core_fabric_configfs.c | 24 +
 include/target/target_core_fabric.h  |  2 +-
 5 files changed, 29 insertions(+), 66 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Greetings from G. Hazrat,>>

2016-04-02 Thread Mr. Gholam Hazrat
Greetings from G. Hazrat,

I'm a banker here in London and i have a business that will benefit us. You 
will get 40% of the fund at the final conclusion.

Please Get Back to me with your full names and phone number for details.

Regards,
Mr. Gholam Hazrat

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision4

2016-04-02 Thread Laurence Oberman
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 

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.txt1969-12-31 
19:00:00.0 -0500
+++ linux-4.5.new/Documentation/scsi/tcm_qla2xxx.txt2016-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.0 
-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.c2016-03-14 
00:28:54.0 -0400
+++ linux-4.5.new/drivers/scsi/qla2xxx/tcm_qla2xxx.c2016-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, 

Re: [PATCH v3 1/2] scsi: Add intermediate STARGET_REMOVE state to scsi_target_state

2016-04-02 Thread James Bottomley
On Thu, 2016-03-31 at 14:53 +0200, Johannes Thumshirn wrote:
> Add intermediate STARGET_REMOVE state to scsi_target_state to avoid
> running
> into the BUG_ON() in scsi_target_reap().
> 
> This intermediate state is only valid in the path from
> scsi_remove_target() to
> scsi_target_destroy() indicating this target is going to be removed.
> 
> Signed-off-by: Johannes Thumshirn 
> Fixes: 40998193560dab6c3ce8d25f4fa58a23e252ef38

The code and ordering is fine with me, so you can add

Reviewed-by: James Bottomley 

However, I'd really appreciate it if the description of what was going
on was clearer for a non-SUSE distro maintainer.  What we're doing is
applying a more comprehensive fix for a previously hack fixed problem
and then reverting the hack.  I think message 1 should say "this
refixes the problem introduced by commit X in a more comprehensive way"

and message 2 "Now that we've done a more comprehensive fix with the
intermediate target state in patch Y, we can remove the previous hack"

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: tcm_qla2xxx Add SCSI command jammer/discard capabilty to the tcm_qla2xxx module - revision4

2016-04-02 Thread Laurence Oberman
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.txt1969-12-31 
19:00:00.0 -0500
+++ linux-4.5.new/Documentation/scsi/tcm_qla2xxx.txt2016-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.0 
-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.c2016-03-14 
00:28:54.0 -0400
+++ linux-4.5.new/drivers/scsi/qla2xxx/tcm_qla2xxx.c2016-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, >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)


Laurence Oberman
Principal Software