target updates for scsi-post-merge .39 (round one)
Subsystems (2)
cover target updates for scsi-post-merge .39 (round one)
From: Nicholas Bellinger <[email protected]>
Hi James and Co,
The following is the first round of target patches intended for .39 scsi-post-merge tree that introduces new target functionality and the first mainline TCM fabric module (TCM_Loop).
Patches #1 -> #4 involve the addition of new ConfigFS context based statistics groups in target_core_stat.c following RFC-4455 to address the removal of the legacy ProcFS based target_core_mib.c in .38 code.
Patch #5 adds the TCM_Loop virtual SCSI LLD module that was originally reviewed and intended for .38 code. This module currently supports high level port emulation for SAS, FC and iSCSI ProtoIdents.
Please be sure to apply this series on top the critical 'for-38-urgent' fix posted here:
[PATCH-FOR-38] target: Fix t_transport_aborted handling in LUN_RESET + active I/O shutdown
http://marc.info/?l=linux-scsi&m=129859551620778&w=2
as well as the 14 patch series for-39-misc-v2 posted recently here:
[PATCH 00/14] target patches for .39 scsi-misc (v2)
http://marc.info/?l=linux-scsi&m=129866341626173&w=2
This full series is also available directly from git here:
git://git.kernel.org/pub/scm/linux/kernel/git/nab/scsi-post-merge-2.6.git for-39-post-merge
Please review and apply,
Thanks!
Nicholas Bellinger (5):
target: add initial device backend context target_core_stat.c code
target: add initial fabric port context target_core_stat.c code
target: add initial fabric MappedLUN context target_core_stat.c code
target: Add fabric_stat_group for fabric module statistics
default_group
tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module
drivers/target/Kconfig | 2 + drivers/target/Makefile | 6 +- drivers/target/target_core_configfs.c | 76 +- drivers/target/target_core_fabric_configfs.c | 209 +++- drivers/target/target_core_stat.c | 1810 ++++++++++++++++++++++++ drivers/target/target_core_stat.h | 8 + drivers/target/tcm_loop/Kconfig | 11 + drivers/target/tcm_loop/Makefile | 11 + drivers/target/tcm_loop/tcm_loop_configfs.c | 647 +++++++++ drivers/target/tcm_loop/tcm_loop_configfs.h | 2 + drivers/target/tcm_loop/tcm_loop_core.h | 77 + drivers/target/tcm_loop/tcm_loop_fabric.c | 476 +++++++ drivers/target/tcm_loop/tcm_loop_fabric.h | 40 + drivers/target/tcm_loop/tcm_loop_fabric_scsi.c | 605 ++++++++ drivers/target/tcm_loop/tcm_loop_fabric_scsi.h | 10 + include/target/target_core_base.h | 35 +- include/target/target_core_configfs.h | 4 + 17 files changed, 4011 insertions(+), 18 deletions(-) create mode 100644 drivers/target/target_core_stat.c create mode 100644 drivers/target/target_core_stat.h create mode 100644 drivers/target/tcm_loop/Kconfig create mode 100644 drivers/target/tcm_loop/Makefile create mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.c create mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.h create mode 100644 drivers/target/tcm_loop/tcm_loop_core.h create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.c create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.h create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.h
Signature · 1 line
1.7.4.1
PATCH 1/5 target: add initial device backend context target_core_stat.c code
From: Nicholas Bellinger <[email protected]>
This patch adds a target_core_mib.c statistics conversion for backend context struct se_subsystem_dev + struct se_device config_group based statistics in target_core_device.c using CONFIGFS_EATTR() based struct config_item_types from target_core_stat.c code.
The conversion from backend /proc/scsi_target/mib/ context output to configfs default groups+attributes include scsi_dev, scsi_lu, and scsi_tgt_dev output from within individual:
/sys/kernel/config/target/core/$HBA/DEV/
The legacy procfs output now appear as individual configfs attributes under:
*) $HBA/$DEV/statistics/scsi_dev:
|-- indx |-- inst |-- ports
`-- role
*) $HBA/$DEV/statistics/scsi_lu:
|-- creation_time |-- dev |-- dev_type |-- full_stat |-- hs_num_cmds |-- indx |-- inst |-- lu_name |-- lun |-- num_cmds |-- prod |-- read_mbytes |-- resets |-- rev |-- state_bit |-- status |-- vend
`-- write_mbytes
*) $HBA/$DEV/statistics/scsi_tgt_dev:
|-- indx |-- inst |-- non_access_lus |-- num_lus |-- resets
`-- status
--- drivers/target/Makefile | 3 +- drivers/target/target_core_configfs.c | 76 ++++- drivers/target/target_core_stat.c | 684 +++++++++++++++++++++++++++++++++ drivers/target/target_core_stat.h | 6 + include/target/target_core_base.h | 10 + 5 files changed, 768 insertions(+), 11 deletions(-) create mode 100644 drivers/target/target_core_stat.c create mode 100644 drivers/target/target_core_stat.h
drivers/target/Makefile +2 -1
@@ -12,7 +12,8 @@ target_core_mod-y := target_core_configfs.o \ target_core_transport.o \ target_core_cdb.o \ target_core_ua.o \ - target_core_rd.o + target_core_rd.o \ + target_core_stat.o obj-$(CONFIG_TARGET_CORE) += target_core_mod.o
drivers/target/target_core_configfs.c +66 -10
148 lines not on this page · raw message
drivers/target/target_core_stat.c new file +684 -0
684 lines not on this page · raw message
drivers/target/target_core_stat.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef TARGET_CORE_STAT_H +#define TARGET_CORE_STAT_H + +extern void target_stat_setup_dev_default_groups (struct se_subsystem_dev *); + +#endif /*** TARGET_CORE_STAT_H ***/
include/target/target_core_base.h +10 -0
@@ -693,6 +693,13 @@ struct se_dev_attrib {struct config_group da_group; }____cacheline_aligned ; +struct se_dev_stat_grps { +struct config_group stat_group; +struct config_group scsi_dev_group; +struct config_group scsi_tgt_dev_group; +struct config_group scsi_lu_group; +}; +struct se_subsystem_dev {/* Used for struct se_subsystem_dev-->se_dev_alias, must be less than PAGE_SIZE */ #define SE_DEV_ALIAS_LEN 512
@@ -716,11 +723,14 @@ struct se_subsystem_dev {struct config_group se_dev_group;/* For T10 Reservations */ struct config_group se_dev_pr_group; +/* For target_core_stat.c groups */ +struct se_dev_stat_grps dev_stat_grps; }____cacheline_aligned ;#define T10_ALUA (su_dev) (&(su_dev)->t10_alua)#define T10_RES (su_dev) (&(su_dev)->t10_reservation)#define T10_PR_OPS (su_dev) (&(su_dev)->t10_reservation.pr_ops) +#define DEV_STAT_GRP (dev) (&(dev)->dev_stat_grps)struct se_device {/* Set to 1 if thread is NOT sleeping on thread_sem */
Signature · 1 line
1.7.4.1
PATCH 2/5 target: add initial fabric port context target_core_stat.c code
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch adds a target_core_mib.c statistics conversion for TCM fabric port/LUN context struct se_lun + struct se_port config_group based statistics in target_core_fabric_configfs.c using CONFIGFS_EATTR() based struct config_item_types from existing generic target fabric TF_CIT_SETUP() wrapper code in target_core_fabric_configfs.c.
The conversion from backend /proc/scsi_target/mib/ context output to configfs default groups+attributes include scsi_port, scsi_tgt_port and scsi_transport output from within individual:
/sys/kernel/config/target/fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/
The legacy procfs output now appear as individual configfs attributes under:
*) fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/scsi_port
|-- busy_count |-- dev |-- indx |-- inst
`-- role
*) fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/scsi_tgt_port
|-- dev |-- hs_in_cmds |-- in_cmds |-- indx |-- inst |-- name |-- port_index |-- read_mbytes
`-- write_mbytes
*) fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/scsi_transport
|-- dev_name |-- device |-- indx
`-- inst
--- drivers/target/target_core_fabric_configfs.c | 83 ++++- drivers/target/target_core_stat.c | 544 ++++++++++++++++++++++++++ drivers/target/target_core_stat.h | 1 + include/target/target_core_base.h | 11 +- include/target/target_core_configfs.h | 1 + 5 files changed, 636 insertions(+), 4 deletions(-)
drivers/target/target_core_fabric_configfs.c +80 -3
@@ -4,10 +4,10 @@* This file contains generic fabric module configfs infrastructure for * TCM v4.x code * -* Copyright (c) 2010 Rising Tide Systems -* Copyright (c) 2010 Linux-iSCSI.org +* Copyright (c) 2010,2011 Rising Tide Systems +* Copyright (c) 2010,2011 Linux-iSCSI.org * -* Copyright (c) 2010 Nicholas A. Bellinger <[email protected]> +* Copyright (c) Nicholas A. Bellinger <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -48,6 +48,7 @@#include "target_core_alua.h" #include "target_core_hba.h" #include "target_core_pr.h" +#include "target_core_stat.h" #define TF_CIT_SETUP (_name, _item_ops, _group_ops, _attrs) \ static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \
@@ -758,6 +759,31 @@ TF_CIT_SETUP(tpg_port, &target_fabric_port_item_ops, NULL, target_fabric_port_at/* End of tfc_tpg_port_cit */ +/* Start of tfc_tpg_port_stat_cit */ + +static struct config_group *target_core_port_stat_mkdir ( +struct config_group *group, +const char *name) +{ +return ERR_PTR (-ENOSYS ); +} + +static void target_core_port_stat_rmdir ( +struct config_group *group, +struct config_item *item) +{ +return ; +} + +static struct configfs_group_operations target_fabric_port_stat_group_ops = { + .make_group = target_core_port_stat_mkdir, + .drop_item = target_core_port_stat_rmdir, +}; + +TF_CIT_SETUP (tpg_port_stat,NULL , &target_fabric_port_stat_group_ops,NULL ); + +/* End of tfc_tpg_port_stat_cit */ +/* Start of tfc_tpg_lun_cit */ static struct config_group *target_fabric_make_lun(
@@ -768,7 +794,9 @@ static struct config_group *target_fabric_make_lun(struct se_portal_group *se_tpg =container_of (group, struct se_portal_group, tpg_lun_group);struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; +struct config_group *lun_cg =NULL , *port_stat_grp =NULL ;unsigned long unpacked_lun; +int errno;if (strstr (name,"lun_" ) != name) { printk(KERN_ERR "Unable to locate \'_\" in"
@@ -782,16 +810,64 @@ static struct config_group *target_fabric_make_lun(if (!(lun))return ERR_PTR (-EINVAL ); + lun_cg = &lun->lun_group; + lun_cg->default_groups =kzalloc (sizeof (struct config_group ) *2 , +GFP_KERNEL ); +if (!lun_cg->default_groups) { +printk (KERN_ERR "Unable to allocate lun_cg->default_groups\n" ); +return ERR_PTR (-ENOMEM ); + } +config_group_init_type_name (&lun->lun_group, name, &TF_CIT_TMPL (tf)->tfc_tpg_port_cit); +config_group_init_type_name (&lun->port_stat_grps.stat_group, +"statistics" , &TF_CIT_TMPL (tf)->tfc_tpg_port_stat_cit); + lun_cg->default_groups[0 ] = &lun->port_stat_grps.stat_group; + lun_cg->default_groups[1 ] =NULL ; + + port_stat_grp = &PORT_STAT_GRP (lun)->stat_group; + port_stat_grp->default_groups =kzalloc (sizeof (struct config_group ) *3 , +GFP_KERNEL ); +if (!port_stat_grp->default_groups) { +printk (KERN_ERR "Unable to allocate port_stat_grp->default_groups\n" ); + errno = -ENOMEM ; + goto out; + } +target_stat_setup_port_default_groups (lun);return &lun->lun_group; +out: +if (lun_cg) +kfree (lun_cg->default_groups); +return ERR_PTR (errno); }static void target_fabric_drop_lun (struct config_group *group,struct config_item *item) { +struct se_lun *lun =container_of (to_config_group (item), + struct se_lun, lun_group); +struct config_item *df_item; +struct config_group *lun_cg, *port_stat_grp; +int i; + + port_stat_grp = &PORT_STAT_GRP (lun)->stat_group; +for (i =0 ; port_stat_grp->default_groups[i]; i++) { + df_item = &port_stat_grp->default_groups[i]->cg_item; + port_stat_grp->default_groups[i] =NULL ; +config_item_put (df_item); + } +kfree (port_stat_grp->default_groups); + + lun_cg = &lun->lun_group; +for (i =0 ; lun_cg->default_groups[i]; i++) { + df_item = &lun_cg->default_groups[i]->cg_item; + lun_cg->default_groups[i] =NULL ; +config_item_put (df_item); + } +kfree (lun_cg->default_groups); +config_item_put (item); }
@@ -1018,6 +1094,7 @@ int target_fabric_setup_cits(struct target_fabric_configfs *tf)target_fabric_setup_tpg_cit (tf);target_fabric_setup_tpg_base_cit (tf);target_fabric_setup_tpg_port_cit (tf); +target_fabric_setup_tpg_port_stat_cit (tf);target_fabric_setup_tpg_lun_cit (tf);target_fabric_setup_tpg_np_cit (tf);target_fabric_setup_tpg_np_base_cit (tf);
drivers/target/target_core_stat.c +544 -0
547 lines not on this page · raw message
drivers/target/target_core_stat.h +1 -0
@@ -2,5 +2,6 @@#define TARGET_CORE_STAT_H extern void target_stat_setup_dev_default_groups (struct se_subsystem_dev *); +extern void target_stat_setup_port_default_groups (struct se_lun *);#endif /*** TARGET_CORE_STAT_H ***/
include/target/target_core_base.h +10 -1
@@ -844,6 +844,13 @@ struct se_hba {#define SE_HBA (dev) ((dev)->se_hba) +struct se_port_stat_grps { +struct config_group stat_group; +struct config_group scsi_port_group; +struct config_group scsi_tgt_port_group; +struct config_group scsi_transport_group; +}; +struct se_lun {/* See transport_lun_status_table */ enum transport_lun_status_table lun_status;
@@ -858,11 +865,13 @@ struct se_lun {struct list_head lun_cmd_list;struct list_head lun_acl_list;struct se_device *lun_se_dev; +struct se_port *lun_sep;struct config_group lun_group; -struct se_port *lun_sep; +struct se_port_stat_grps port_stat_grps; }____cacheline_aligned ;#define SE_LUN (cmd) ((cmd)->se_lun) +#define PORT_STAT_GRP (lun) (&(lun)->port_stat_grps)struct scsi_port_stats {u64 cmd_pdus;
include/target/target_core_configfs.h +1 -0
@@ -18,6 +18,7 @@ struct target_fabric_configfs_template {struct config_item_type tfc_tpg_base_cit;struct config_item_type tfc_tpg_lun_cit;struct config_item_type tfc_tpg_port_cit; +struct config_item_type tfc_tpg_port_stat_cit;struct config_item_type tfc_tpg_np_cit;struct config_item_type tfc_tpg_np_base_cit;struct config_item_type tfc_tpg_attrib_cit;
Signature · 1 line
1.7.4.1
PATCH 3/5 target: add initial fabric MappedLUN context target_core_stat.c code
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch adds a target_core_mib.c statistics conversion for TCM MappedLUN/LunACL context struct se_lun_acl + struct se_dev_entry config_group based statistics in target_core_fabric_configfs.c using CONFIGFS_EATTR() based struct config_item_types from existing generic target fabric TF_CIT_SETUP() wrapper code in target_core_fabric_configfs.c.
The conversion from backend /proc/scsi_target/mib/ context output to configfs default groups+attributes include scsi_att_intr_port and scsi_auth_intr output from within individual:
/sys/kernel/config/target/fabric/$WWN/tpgt_$TPGT/acls/$INITIATOR_WWN/lun_$LUN_ID/statistics/
The legacy procfs output now appear as individual configfs attributes under:
*) acls/$INITIATOR_WWN/lun_$LUN_ID/statistics/scsi_att_intr_port
|-- dev |-- indx |-- inst |-- port |-- port_auth_indx
`-- port_ident
*) acls/$INITIATOR_WWN/lun_$LUN_ID/statistics/scsi_auth_intr
|-- att_count |-- creation_time |-- dev |-- dev_or_port |-- hs_num_cmds |-- indx |-- inst |-- intr_name |-- map_indx |-- num_cmds |-- port |-- read_mbytes |-- row_status
`-- write_mbytes
--- drivers/target/target_core_fabric_configfs.c | 79 ++++- drivers/target/target_core_stat.c | 582 ++++++++++++++++++++++++++ drivers/target/target_core_stat.h | 1 + include/target/target_core_base.h | 9 + include/target/target_core_configfs.h | 1 + 5 files changed, 671 insertions(+), 1 deletions(-)
drivers/target/target_core_fabric_configfs.c +78 -1
@@ -242,6 +242,32 @@ TF_CIT_SETUP(tpg_mappedlun, &target_fabric_mappedlun_item_ops, NULL,/* End of tfc_tpg_mappedlun_cit */ +/* Start of tfc_tpg_mappedlun_port_cit */ + +static struct config_group *target_core_mappedlun_stat_mkdir ( +struct config_group *group, +const char *name) +{ +return ERR_PTR (-ENOSYS ); +} + +static void target_core_mappedlun_stat_rmdir ( +struct config_group *group, +struct config_item *item) +{ +return ; +} + +static struct configfs_group_operations target_fabric_mappedlun_stat_group_ops = { + .make_group = target_core_mappedlun_stat_mkdir, + .drop_item = target_core_mappedlun_stat_rmdir, +}; + +TF_CIT_SETUP (tpg_mappedlun_stat,NULL , &target_fabric_mappedlun_stat_group_ops, +NULL ); + +/* End of tfc_tpg_mappedlun_port_cit */ +/* Start of tfc_tpg_nacl_attrib_cit */ CONFIGFS_EATTR_OPS (target_fabric_nacl_attrib, se_node_acl, acl_attrib_group);
@@ -295,6 +321,7 @@ static struct config_group *target_fabric_make_mappedlun(struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;struct se_lun_acl *lacl;struct config_item *acl_ci; +struct config_group *lacl_cg =NULL , *ml_stat_grp =NULL ;char *buf;unsigned long mapped_lun;int ret =0 ;
@@ -331,15 +358,42 @@ static struct config_group *target_fabric_make_mappedlun( lacl =core_dev_init_initiator_node_lun_acl (se_tpg, mapped_lun,config_item_name (acl_ci), &ret); -if (!(lacl)) +if (!(lacl)) { + ret = -EINVAL ; goto out; + } + + lacl_cg = &lacl->se_lun_group; + lacl_cg->default_groups =kzalloc (sizeof (struct config_group ) *2 , +GFP_KERNEL ); +if (!lacl_cg->default_groups) { +printk (KERN_ERR "Unable to allocate lacl_cg->default_groups\n" ); + ret = -ENOMEM ; + goto out; + }config_group_init_type_name (&lacl->se_lun_group, name, &TF_CIT_TMPL (tf)->tfc_tpg_mappedlun_cit); +config_group_init_type_name (&lacl->ml_stat_grps.stat_group, +"statistics" , &TF_CIT_TMPL (tf)->tfc_tpg_mappedlun_stat_cit); + lacl_cg->default_groups[0 ] = &lacl->ml_stat_grps.stat_group; + lacl_cg->default_groups[1 ] =NULL ; + + ml_stat_grp = &ML_STAT_GRPS (lacl)->stat_group; + ml_stat_grp->default_groups =kzalloc (sizeof (struct config_group ) *3 , +GFP_KERNEL ); +if (!ml_stat_grp->default_groups) { +printk (KERN_ERR "Unable to allocate ml_stat_grp->default_groups\n" ); + ret = -ENOMEM ; + goto out; + } +target_stat_setup_mappedlun_default_groups (lacl);kfree (buf);return &lacl->se_lun_group; out: +if (lacl_cg) +kfree (lacl_cg->default_groups);kfree (buf);return ERR_PTR (ret); }
@@ -348,6 +402,28 @@ static void target_fabric_drop_mappedlun(struct config_group *group, struct config_item *item) { + struct se_lun_acl *lacl = container_of(to_config_group(item), + struct se_lun_acl, se_lun_group); +struct config_item *df_item; +struct config_group *lacl_cg =NULL , *ml_stat_grp =NULL ; +int i; + + ml_stat_grp = &ML_STAT_GRPS (lacl)->stat_group; +for (i =0 ; ml_stat_grp->default_groups[i]; i++) { + df_item = &ml_stat_grp->default_groups[i]->cg_item; + ml_stat_grp->default_groups[i] =NULL ; +config_item_put (df_item); + } +kfree (ml_stat_grp->default_groups); + + lacl_cg = &lacl->se_lun_group; +for (i =0 ; lacl_cg->default_groups[i]; i++) { + df_item = &lacl_cg->default_groups[i]->cg_item; + lacl_cg->default_groups[i] =NULL ; +config_item_put (df_item); + } +kfree (lacl_cg->default_groups); +config_item_put (item); }
@@ -1106,6 +1182,7 @@ int target_fabric_setup_cits(struct target_fabric_configfs *tf)target_fabric_setup_tpg_nacl_auth_cit (tf);target_fabric_setup_tpg_nacl_param_cit (tf);target_fabric_setup_tpg_mappedlun_cit (tf); +target_fabric_setup_tpg_mappedlun_stat_cit (tf);return 0 ; }
drivers/target/target_core_stat.c +582 -0
585 lines not on this page · raw message
drivers/target/target_core_stat.h +1 -0
@@ -3,5 +3,6 @@extern void target_stat_setup_dev_default_groups (struct se_subsystem_dev *);extern void target_stat_setup_port_default_groups (struct se_lun *); +extern void target_stat_setup_mappedlun_default_groups (struct se_lun_acl *);#endif /*** TARGET_CORE_STAT_H ***/
include/target/target_core_base.h +9 -0
@@ -622,6 +622,12 @@ struct se_device;struct se_transform_info ;struct scatterlist ; +struct se_ml_stat_grps { +struct config_group stat_group; +struct config_group scsi_auth_intr_group; +struct config_group scsi_att_intr_port_group; +}; +struct se_lun_acl {char initiatorname[TRANSPORT_IQN_LEN ];u32 mapped_lun;
@@ -629,8 +635,11 @@ struct se_lun_acl {struct se_lun *se_lun;struct list_head lacl_list;struct config_group se_lun_group; +struct se_ml_stat_grps ml_stat_grps; }____cacheline_aligned ; +#define ML_STAT_GRPS (lacl) (&(lacl)->ml_stat_grps) +struct se_dev_entry {bool def_pr_registered;/* See transport_lunflags_table */
include/target/target_core_configfs.h +1 -0
@@ -29,6 +29,7 @@ struct target_fabric_configfs_template {struct config_item_type tfc_tpg_nacl_auth_cit;struct config_item_type tfc_tpg_nacl_param_cit;struct config_item_type tfc_tpg_mappedlun_cit; +struct config_item_type tfc_tpg_mappedlun_stat_cit; };struct target_fabric_configfs {
Signature · 1 line
1.7.4.1
PATCH 5/5 tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch adds the TCM_Loop Linux/SCSI LLD fabric module for accessing TCM device backstores as locally accessable SCSI LUNs in virtual SAS, FC, and iSCSI Target ports using the generic fabric TransportID and Target Port WWN naming handlers from TCM's target_core_fabric_lib.c The TCM_Loop module uses the generic fabric configfs infratructure provided by target_core_fabric_configfs.c and adds a module dependent attribute for the creation/release of the virtual I_T Nexus connected the TCM_Loop Target and Initiator Ports.
TCM_Loop can also be used with the scsi-generic driver so that STGT userspace fabric modules, QEMU-KVM and other hypervisor SCSI passthrough support can access TCM device backstore and control CDB emulation.
For more information please see:
http://linux-iscsi.org/wiki/Tcm_loop
--- drivers/target/Kconfig | 2 + drivers/target/Makefile | 3 + drivers/target/tcm_loop/Kconfig | 11 + drivers/target/tcm_loop/Makefile | 11 + drivers/target/tcm_loop/tcm_loop_configfs.c | 647 ++++++++++++++++++++++++ drivers/target/tcm_loop/tcm_loop_configfs.h | 2 + drivers/target/tcm_loop/tcm_loop_core.h | 77 +++ drivers/target/tcm_loop/tcm_loop_fabric.c | 476 +++++++++++++++++ drivers/target/tcm_loop/tcm_loop_fabric.h | 40 ++ drivers/target/tcm_loop/tcm_loop_fabric_scsi.c | 605 ++++++++++++++++++++++ drivers/target/tcm_loop/tcm_loop_fabric_scsi.h | 10 + 11 files changed, 1884 insertions(+), 0 deletions(-) create mode 100644 drivers/target/tcm_loop/Kconfig create mode 100644 drivers/target/tcm_loop/Makefile create mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.c create mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.h create mode 100644 drivers/target/tcm_loop/tcm_loop_core.h create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.c create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.h create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.h
drivers/target/Kconfig +2 -0
@@ -29,4 +29,6 @@ config TCM_PSCSI Say Y here to enable the TCM/pSCSI subsystem plugin for non-buffered passthrough access to Linux/SCSI device +source "drivers/target/tcm_loop/Kconfig" + endif
drivers/target/Makefile +3 -0
@@ -21,3 +21,6 @@ obj-$(CONFIG_TARGET_CORE) += target_core_mod.o obj-$(CONFIG_TCM_IBLOCK) += target_core_iblock.o obj-$(CONFIG_TCM_FILEIO) += target_core_file.o obj-$(CONFIG_TCM_PSCSI) += target_core_pscsi.o + +# Fabric modules +obj-$(CONFIG_TCM_LOOP_FABRIC) += tcm_loop/
drivers/target/tcm_loop/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +config TCM_LOOP_FABRIC + tristate "TCM Virtual SAS target and Linux/SCSI LDD fabric loopback module" + help + Say Y here to enable the TCM Virtual SAS target and Linux/SCSI LLD + fabric loopback module. + +config TCM_LOOP_CDB_DEBUG + bool "TCM loopback fabric module CDB debug code" + depends on TCM_LOOP_FABRIC + help + Say Y here to enable the TCM loopback fabric module CDB debug code
drivers/target/tcm_loop/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_loop/ + +tcm_loop-y := tcm_loop_fabric.o \ + tcm_loop_fabric_scsi.o \ + tcm_loop_configfs.o \ + +obj-$(CONFIG_TCM_LOOP_FABRIC) += tcm_loop.o + +ifdef CONFIG_TCM_LOOP_CDB_DEBUG +EXTRA_CFLAGS += -DTCM_LOOP_CDB_DEBUG +endif
drivers/target/tcm_loop/tcm_loop_configfs.c new file +647 -0
647 lines not on this page · raw message
drivers/target/tcm_loop/tcm_loop_configfs.h new file +2 -0
@@ -0,0 +1,2 @@ +extern int tcm_loop_register_configfs (void ); +extern void tcm_loop_deregister_configfs (void );
drivers/target/tcm_loop/tcm_loop_core.h new file +77 -0
77 lines not on this page · raw message
drivers/target/tcm_loop/tcm_loop_fabric.c new file +476 -0
476 lines not on this page · raw message
drivers/target/tcm_loop/tcm_loop_fabric.h new file +40 -0
@@ -0,0 +1,40 @@ +extern char *tcm_loop_get_fabric_name (void ); +extern u8 tcm_loop_get_fabric_proto_ident (struct se_portal_group *); +extern char *tcm_loop_get_endpoint_wwn (struct se_portal_group *); +extern u16 tcm_loop_get_tag (struct se_portal_group *); +extern u32 tcm_loop_get_default_depth (struct se_portal_group *); +extern u32 tcm_loop_get_pr_transport_id (struct se_portal_group *,struct se_node_acl *, +struct t10_pr_registration *,int *, +unsigned char *); +extern u32 tcm_loop_get_pr_transport_id_len (struct se_portal_group *, +struct se_node_acl *,struct t10_pr_registration *, +int *); +extern char *tcm_loop_parse_pr_out_transport_id (struct se_portal_group *, +const char *,u32 *,char **); +extern int tcm_loop_check_demo_mode (struct se_portal_group *); +extern int tcm_loop_check_demo_mode_cache (struct se_portal_group *); +extern int tcm_loop_check_demo_mode_write_protect (struct se_portal_group *); +extern int tcm_loop_check_prod_mode_write_protect (struct se_portal_group *); +extern struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl ( +struct se_portal_group *); +void tcm_loop_tpg_release_fabric_acl (struct se_portal_group *,struct se_node_acl *); +extern u32 tcm_loop_get_inst_index (struct se_portal_group *); +extern void tcm_loop_new_cmd_failure (struct se_cmd *); +extern int tcm_loop_is_state_remove (struct se_cmd *); +extern int tcm_loop_sess_logged_in (struct se_session *); +extern u32 tcm_loop_sess_get_index (struct se_session *); +extern void tcm_loop_set_default_node_attributes (struct se_node_acl *); +extern u32 tcm_loop_get_task_tag (struct se_cmd *); +extern int tcm_loop_get_cmd_state (struct se_cmd *); +extern int tcm_loop_shutdown_session (struct se_session *); +extern void tcm_loop_close_session (struct se_session *); +extern void tcm_loop_stop_session (struct se_session *,int ,int ); +extern void tcm_loop_fall_back_to_erl0 (struct se_session *); +extern int tcm_loop_write_pending (struct se_cmd *); +extern int tcm_loop_write_pending_status (struct se_cmd *); +extern int tcm_loop_queue_data_in (struct se_cmd *); +extern int tcm_loop_queue_status (struct se_cmd *); +extern int tcm_loop_queue_tm_rsp (struct se_cmd *); +extern u16 tcm_loop_set_fabric_sense_len (struct se_cmd *,u32 ); +extern u16 tcm_loop_get_fabric_sense_len (void ); +extern u64 tcm_loop_pack_lun (unsigned int );
drivers/target/tcm_loop/tcm_loop_fabric_scsi.c new file +605 -0
605 lines not on this page · raw message
drivers/target/tcm_loop/tcm_loop_fabric_scsi.h new file +10 -0
@@ -0,0 +1,10 @@ +extern struct kmem_cache *tcm_loop_cmd_cache; + +extern int tcm_loop_new_cmd_map (struct se_cmd *); +extern void tcm_loop_check_stop_free (struct se_cmd *); +extern void tcm_loop_deallocate_core_cmd (struct se_cmd *); +extern void tcm_loop_scsi_forget_host (struct Scsi_Host *); +extern void tcm_loop_deallocate_core_cmd (struct se_cmd *); +extern int tcm_loop_setup_hba_bus (struct tcm_loop_hba *,int ); +extern int tcm_loop_alloc_core_bus (void ); +extern void tcm_loop_release_core_bus (void );
Signature · 1 line
1.7.4.1
PATCH 4/5 target: Add fabric_stat_group for fabric module statistics default_group
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch adds support for struct se_wwn->fabric_stat_group in target_fabric_make_wwn() and target_fabric_drop_wwn() to allow fabric modules to access fabric_stat_group->default_groups[] for dependent /sys/kernel/config/target/$FABRIC_WWN/fabric_statistics groups.
It also adds support for struct se_node_acl->acl_fabric_stat_group in target_fabric_make_nodeacl() to allow fabric modules to access acl_fabric_stat_group->default_groups[] for fabric dependent fabric groups as well.
ALso, this includes adding struct target_fabric_configfs_template-> tfc_wwn_fabric_stats_cit and ->tfc_tpg_nacl_stat_cit respectively for use during target_core_fabric_configfs.c:target_fabric_setup_cits()
--- drivers/target/target_core_fabric_configfs.c | 47 +++++++++++++++++++++++++- include/target/target_core_base.h | 5 ++- include/target/target_core_configfs.h | 2 + 3 files changed, 52 insertions(+), 2 deletions(-)
drivers/target/target_core_fabric_configfs.c +46 -1
@@ -453,6 +453,15 @@ TF_CIT_SETUP(tpg_nacl_base, &target_fabric_nacl_base_item_ops,/* End of tfc_tpg_nacl_base_cit */ +/* Start of tfc_node_fabric_stats_cit */ +/* +* This is used as a placeholder for struct se_node_acl->acl_fabric_stat_group +* to allow fabrics access to ->acl_fabric_stat_group->default_groups[] +*/ +TF_CIT_SETUP (tpg_nacl_stat,NULL ,NULL ,NULL ); + +/* End of tfc_wwn_fabric_stats_cit */ +/* Start of tfc_tpg_nacl_cit */ static struct config_group *target_fabric_make_nodeacl(
@@ -479,7 +488,8 @@ static struct config_group *target_fabric_make_nodeacl( nacl_cg->default_groups[0 ] = &se_nacl->acl_attrib_group; nacl_cg->default_groups[1 ] = &se_nacl->acl_auth_group; nacl_cg->default_groups[2 ] = &se_nacl->acl_param_group; - nacl_cg->default_groups[3 ] =NULL ; + nacl_cg->default_groups[3 ] = &se_nacl->acl_fabric_stat_group; + nacl_cg->default_groups[4 ] =NULL ;config_group_init_type_name (&se_nacl->acl_group, name, &TF_CIT_TMPL (tf)->tfc_tpg_nacl_base_cit);
@@ -489,6 +499,9 @@ static struct config_group *target_fabric_make_nodeacl( &TF_CIT_TMPL(tf)->tfc_tpg_nacl_auth_cit);config_group_init_type_name (&se_nacl->acl_param_group,"param" , &TF_CIT_TMPL (tf)->tfc_tpg_nacl_param_cit); +config_group_init_type_name (&se_nacl->acl_fabric_stat_group, +"fabric_statistics" , + &TF_CIT_TMPL (tf)->tfc_tpg_nacl_stat_cit);return &se_nacl->acl_group; }
@@ -1098,6 +1111,15 @@ TF_CIT_SETUP(tpg, &target_fabric_tpg_item_ops, &target_fabric_tpg_group_ops,/* End of tfc_tpg_cit */ +/* Start of tfc_wwn_fabric_stats_cit */ +/* +* This is used as a placeholder for struct se_wwn->fabric_stat_group +* to allow fabrics access to ->fabric_stat_group->default_groups[] +*/ +TF_CIT_SETUP (wwn_fabric_stats,NULL ,NULL ,NULL ); + +/* End of tfc_wwn_fabric_stats_cit */ +/* Start of tfc_wwn_cit */ static struct config_group *target_fabric_make_wwn(
@@ -1118,8 +1140,17 @@ static struct config_group *target_fabric_make_wwn(return ERR_PTR (-EINVAL ); wwn->wwn_tf = tf; +/* +* Setup default groups from pre-allocated wwn->wwn_default_groups +*/ + wwn->wwn_group.default_groups = wwn->wwn_default_groups; + wwn->wwn_group.default_groups[0 ] = &wwn->fabric_stat_group; + wwn->wwn_group.default_groups[1 ] =NULL ; +config_group_init_type_name (&wwn->wwn_group, name, &TF_CIT_TMPL (tf)->tfc_tpg_cit); +config_group_init_type_name (&wwn->fabric_stat_group,"fabric_statistics" , + &TF_CIT_TMPL (tf)->tfc_wwn_fabric_stats_cit);return &wwn->wwn_group; }
@@ -1128,6 +1159,18 @@ static void target_fabric_drop_wwn(struct config_group *group, struct config_item *item) { + struct se_wwn *wwn = container_of(to_config_group(item), + struct se_wwn, wwn_group); +struct config_item *df_item; +struct config_group *cg = &wwn->wwn_group; +int i; + +for (i =0 ; cg->default_groups[i]; i++) { + df_item = &cg->default_groups[i]->cg_item; + cg->default_groups[i] =NULL ; +config_item_put (df_item); + } +config_item_put (item); }
@@ -1167,6 +1210,7 @@ int target_fabric_setup_cits(struct target_fabric_configfs *tf) {target_fabric_setup_discovery_cit (tf);target_fabric_setup_wwn_cit (tf); +target_fabric_setup_wwn_fabric_stats_cit (tf);target_fabric_setup_tpg_cit (tf);target_fabric_setup_tpg_base_cit (tf);target_fabric_setup_tpg_port_cit (tf);
@@ -1181,6 +1225,7 @@ int target_fabric_setup_cits(struct target_fabric_configfs *tf)target_fabric_setup_tpg_nacl_attrib_cit (tf);target_fabric_setup_tpg_nacl_auth_cit (tf);target_fabric_setup_tpg_nacl_param_cit (tf); +target_fabric_setup_tpg_nacl_stat_cit (tf);target_fabric_setup_tpg_mappedlun_cit (tf);target_fabric_setup_tpg_mappedlun_stat_cit (tf);
include/target/target_core_base.h +4 -1
@@ -601,7 +601,8 @@ struct se_node_acl {struct config_group acl_attrib_group;struct config_group acl_auth_group;struct config_group acl_param_group; -struct config_group *acl_default_groups[4 ]; +struct config_group acl_fabric_stat_group; +struct config_group *acl_default_groups[5 ];struct list_head acl_list;struct list_head acl_sess_list; }____cacheline_aligned ;
@@ -952,6 +953,8 @@ struct se_portal_group {struct se_wwn {struct target_fabric_configfs *wwn_tf;struct config_group wwn_group; +struct config_group *wwn_default_groups[2 ]; +struct config_group fabric_stat_group; }____cacheline_aligned ;struct se_global {
include/target/target_core_configfs.h +2 -0
@@ -14,6 +14,7 @@ extern void target_fabric_configfs_deregister(struct target_fabric_configfs *);struct target_fabric_configfs_template {struct config_item_type tfc_discovery_cit;struct config_item_type tfc_wwn_cit; +struct config_item_type tfc_wwn_fabric_stats_cit;struct config_item_type tfc_tpg_cit;struct config_item_type tfc_tpg_base_cit;struct config_item_type tfc_tpg_lun_cit;
@@ -28,6 +29,7 @@ struct target_fabric_configfs_template {struct config_item_type tfc_tpg_nacl_attrib_cit;struct config_item_type tfc_tpg_nacl_auth_cit;struct config_item_type tfc_tpg_nacl_param_cit; +struct config_item_type tfc_tpg_nacl_stat_cit;struct config_item_type tfc_tpg_mappedlun_cit;struct config_item_type tfc_tpg_mappedlun_stat_cit; };
Signature · 1 line
1.7.4.1
Re: [PATCH 5/5] tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module
In reply to Nicholas A. Bellingerdrivers/target/tcm_loop/Makefile line 1
Quoted 4 lines
drivers/target/tcm_loop/Makefile new file +1
-0@@ -0,0 +1,11 @@ +EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_loop/
This should not be needed.
drivers/target/tcm_loop/Makefile line 11
Quoted 10 lines
drivers/target/tcm_loop/Makefile new file +10
-0+ +tcm_loop-y := tcm_loop_fabric.o \ + tcm_loop_fabric_scsi.o \ + tcm_loop_configfs.o \ + +obj-$(CONFIG_TCM_LOOP_FABRIC) += tcm_loop.o + +ifdef CONFIG_TCM_LOOP_CDB_DEBUG +EXTRA_CFLAGS += -DTCM_LOOP_CDB_DEBUG +endif
Please just test for CONFIG_TCM_LOOP_CDB_DEBUG directly in the code.
drivers/target/tcm_loop/Makefile
Quoted 3 lines
drivers/target/tcm_loop/Makefile new file +3
-0+#include <linux/version.h> +#include <generated/utsrelease.h> +#include <linux/utsname.h>
These should not be needed.
drivers/target/tcm_loop/Makefile
Quoted 3 lines
drivers/target/tcm_loop/Makefile new file +3
-0+#include <linux/init.h> +#include <linux/slab.h> +#include <linux/kthread.h>
You don't use kthreads in this file, so it shouldn't be needed either.
drivers/target/tcm_loop/Makefile
Quoted 4 lines
drivers/target/tcm_loop/Makefile new file +4
-0+#include <tcm_loop_core.h> +#include <tcm_loop_configfs.h> +#include <tcm_loop_fabric.h> +#include <tcm_loop_fabric_scsi.h>
Theseshould be ""-style includes.
drivers/target/tcm_loop/Makefile
Quoted 2 lines
drivers/target/tcm_loop/Makefile new file +2
-0+ tl_nexus = kzalloc(sizeof(struct tcm_loop_nexus), GFP_KERNEL); + if (!(tl_nexus)) {
Please remove all these totally pointless braces inside negations.
drivers/target/tcm_loop/tcm_loop_configfs.h line 2
Quoted 8 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +2
-0@@ -0,0 +1,2 @@ +extern int tcm_loop_register_configfs (void ); +extern void tcm_loop_deregister_configfs (void );
I think just having one header for this module instead of mini-headers like this is a lot easier to read/maintain.
Quoted 1 line
+#include <
linux/kthread.h>
Again, this should not be needed.
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 12 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +12
-0+int tcm_loop_queue_data_in (struct se_cmd *se_cmd) +{ +struct tcm_loop_cmd *tl_cmd =container_of (se_cmd, + struct tcm_loop_cmd, tl_se_cmd); +struct scsi_cmnd *sc = tl_cmd->sc; + +TL_CDB_DEBUG ("tcm_loop_queue_data_in() called for scsi_cmnd: %p" +" cdb: 0x%02x\n" , sc, sc->cmnd[0 ]); + + sc->result =SAM_STAT_GOOD ; +set_host_byte (sc,DID_OK ); + (*sc->scsi_done)(sc);
This can be written simpler as sc->scsi_done(sc);
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 3 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +3
-0+#include <linux/version.h> +#include <generated/utsrelease.h> +#include <linux/utsname.h>
not needed.
Quoted 1 line
+#include <
scsi/libsas.h> /* For TASK_ATTR_* */
I thought that got fixed for the next merge window?
Quoted 3 lines
+ * Copied from drivers/scsi/libfc/fc_fcp.c:fc_change_queue_depth() and
+ * drivers/scsi/libiscsi.c:iscsi_change_queue_depth()
+ */
Sounds like we should move it to generic code instead of adding a third duplicate.
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 4 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +4
-0+static inline struct tcm_loop_hba *tcm_loop_get_hba (struct scsi_cmnd *sc) +{ +return (struct tcm_loop_hba *)sc->device->host->hostdata[0 ]; +}
You probably want to use shost_priv instead.
Quoted 9 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +9
-0+struct se_portal_group *se_tpg; +struct tcm_loop_hba *tl_hba; +struct tcm_loop_tpg *tl_tpg; + +TL_CDB_DEBUG ("tcm_loop_queuecommand() %d:%d:%d:%d got CDB: 0x%02x" +" scsi_buf_len: %u\n" , sc->device->host->host_no, + sc->device->id, sc->device->channel, sc->device->lun, + sc->cmnd[0 ],scsi_bufflen (sc)); +/*
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 10 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +10
-0+* Locate the tcm_loop_hba_t pointer +*/ + tl_hba =tcm_loop_get_hba (sc); +if (!(tl_hba)) { +printk (KERN_ERR "Unable to locate struct tcm_loop_hba from" +" struct scsi_cmnd\n" ); +set_host_byte (sc,DID_ERROR ); + sc->scsi_done (sc); +return 0 ; + }
This can't ever be null.
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 9 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +9
-0+static struct scsi_host_template tcm_loop_driver_template = { + .proc_info = tcm_loop_proc_info, + .proc_name ="tcm_loopback" , + .name ="TCM_Loopback" , + .info =NULL , + .slave_alloc =NULL , + .slave_configure =NULL , + .slave_destroy =NULL , + .ioctl =NULL ,
There is no need to fill unused methods with NULLs.
Quoted 3 lines · Nicholas A. Bellinger
Patches #1 -> #4 involve the addition of new ConfigFS context based statistics groups in
target_core_stat.cfollowing RFC-4455 to address the removal of the legacy ProcFS basedtarget_core_mib.cin .38 code.
Hot-pluggable InfiniBand HCAs are available since some time. As I wrote before, exporting RFC-4455 data via configfs instead of sysfs makes implementing RFC 4455 in a (user space) SNMP agent overly complex.
Bart.
Re: [PATCH 5/5] tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
drivers/target/tcm_loop/Makefile line 1
Quoted 4 lines
drivers/target/tcm_loop/Makefile new file +1
-0@@ -0,0 +1,11 @@ +EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_loop/This should not be needed.
Ugh, forgot to fix up the Makefile bits..
Removed EXTRA_CFLAGS.
Quoted 4 lines
Quoted 4 lines
drivers/target/tcm_loop/Makefile new file +4
-0+ +tcm_loop-y := tcm_loop_fabric.o \ + tcm_loop_fabric_scsi.o \ + tcm_loop_configfs.o \
Quoted 9 lines
drivers/target/tcm_loop/Makefile line 11
Quoted 6 lines
drivers/target/tcm_loop/Makefile new file +6
-0+ +obj-$(CONFIG_TCM_LOOP_FABRIC) += tcm_loop.o + +ifdef CONFIG_TCM_LOOP_CDB_DEBUG +EXTRA_CFLAGS += -DTCM_LOOP_CDB_DEBUG +endifPlease just test for
CONFIG_TCM_LOOP_CDB_DEBUGdirectly in the code.
Fixed
Quoted 6 lines
drivers/target/tcm_loop/Makefile
Quoted 3 lines
drivers/target/tcm_loop/Makefile new file +3
-0+#include <linux/version.h> +#include <generated/utsrelease.h> +#include <linux/utsname.h>These should not be needed.
Removed from tcm_loop_fabric_scsi.c, but these are still required for tcm_loop_configfs.c:tcm_loop_wwn_show_attr_version()
Quoted 6 lines
drivers/target/tcm_loop/Makefile
Quoted 3 lines
drivers/target/tcm_loop/Makefile new file +3
-0+#include <linux/init.h> +#include <linux/slab.h> +#include <linux/kthread.h>You don't use kthreads in this file, so it shouldn't be needed either.
<nod>, dropping unnecessary kthread.h includes..
Quoted 7 lines
drivers/target/tcm_loop/Makefile
Quoted 4 lines
drivers/target/tcm_loop/Makefile new file +4
-0+#include <tcm_loop_core.h> +#include <tcm_loop_configfs.h> +#include <tcm_loop_fabric.h> +#include <tcm_loop_fabric_scsi.h>Theseshould be ""-style includes.
Fixed
Quoted 5 lines
drivers/target/tcm_loop/Makefile
Quoted 2 lines
drivers/target/tcm_loop/Makefile new file +2
-0+ tl_nexus = kzalloc(sizeof(struct tcm_loop_nexus), GFP_KERNEL); + if (!(tl_nexus)) {Please remove all these totally pointless braces inside negations.
Fixed in all code
Quoted 12 lines
drivers/target/tcm_loop/tcm_loop_configfs.h line 2
Quoted 8 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +2
-0@@ -0,0 +1,2 @@ +extern int tcm_loop_register_configfs (void ); +extern void tcm_loop_deregister_configfs (void );I think just having one header for this module instead of mini-headers like this is a lot easier to read/maintain.
Fair point. Merging tcm_loop_configfs.h, tcm_loop_fabric.h and tcm_loop_fabric_scsi.h into tcm_loop_core.h
Quoted 4 lines
Quoted 1 line
+#include <
linux/kthread.h>Again, this should not be needed.
Removed
Quoted 6 lines
Quoted 6 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +6
-0+int tcm_loop_queue_data_in (struct se_cmd *se_cmd) +{ +struct tcm_loop_cmd *tl_cmd =container_of (se_cmd, + struct tcm_loop_cmd, tl_se_cmd); +struct scsi_cmnd *sc = tl_cmd->sc; +
Quoted 9 lines
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 6 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +6
-0+TL_CDB_DEBUG ("tcm_loop_queue_data_in() called for scsi_cmnd: %p" +" cdb: 0x%02x\n" , sc, sc->cmnd[0 ]); + + sc->result =SAM_STAT_GOOD ; +set_host_byte (sc,DID_OK ); + (*sc->scsi_done)(sc);This can be written simpler as
sc->scsi_done(sc);
Changed here and in tcm_loop_queue_status()
Quoted 6 lines
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 3 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +3
-0+#include <linux/version.h> +#include <generated/utsrelease.h> +#include <linux/utsname.h> not needed.
<nod>, these includes are now only included for tcm_loop_configfs.c
Quoted 4 lines
Quoted 1 line
+#include <
scsi/libsas.h> /* For TASK_ATTR_* */I thought that got fixed for the next merge window?
The TMR definitions did get fixed, but the conversion to use scsi_tcq.h for SAM Task Attributes has not happened yet..
Quoted 7 lines
Quoted 3 lines
+ * Copied from drivers/scsi/libfc/fc_fcp.c:fc_change_queue_depth() and
+ * drivers/scsi/libiscsi.c:iscsi_change_queue_depth()
+ */Sounds like we should move it to generic code instead of adding a third duplicate.
Indeed, this type of generic SCSI code should be moved into scsi_lib.c so we can drop this LLD duplicate code.. While this does not address all drivers that need to preform LLD specific ops while changing the struct scsi_device->queue_depth, a generic caller would work fine for these cases..
Quoted 7 lines
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 4 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +4
-0+static inline struct tcm_loop_hba *tcm_loop_get_hba (struct scsi_cmnd *sc) +{ +return (struct tcm_loop_hba *)sc->device->host->hostdata[0 ]; +}You probably want to use
shost_privinstead.
Ok, converted tcm_loop_queuecommand() and tcm_loop_device_reset() to use shost_priv(). Thanks for pointing this one out..
Quoted 13 lines
Quoted 13 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +13
-0+struct se_portal_group *se_tpg; +struct tcm_loop_hba *tl_hba; +struct tcm_loop_tpg *tl_tpg; + +TL_CDB_DEBUG ("tcm_loop_queuecommand() %d:%d:%d:%d got CDB: 0x%02x" +" scsi_buf_len: %u\n" , sc->device->host->host_no, + sc->device->id, sc->device->channel, sc->device->lun, + sc->cmnd[0 ],scsi_bufflen (sc)); +/* +* Locate the tcm_loop_hba_t pointer +*/ + tl_hba =tcm_loop_get_hba (sc); +if (!(tl_hba)) {
Quoted 9 lines
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 6 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +6
-0+printk (KERN_ERR "Unable to locate struct tcm_loop_hba from" +" struct scsi_cmnd\n" ); +set_host_byte (sc,DID_ERROR ); + sc->scsi_done (sc); +return 0 ; + }This can't ever be null.
Unnecessary check(s) removed..
Quoted 11 lines
drivers/target/tcm_loop/tcm_loop_configfs.h
Quoted 9 lines
drivers/target/tcm_loop/tcm_loop_configfs.h new file +9
-0+static struct scsi_host_template tcm_loop_driver_template = { + .proc_info = tcm_loop_proc_info, + .proc_name ="tcm_loopback" , + .name ="TCM_Loopback" , + .info =NULL , + .slave_alloc =NULL , + .slave_configure =NULL , + .slave_destroy =NULL , + .ioctl =NULL ,There is no need to fill unused methods with NULLs.
Removed the NULL assignments from tcm_loop_driver_template..
Thanks for your review. The tcm_loop changes have been committed and
pushed into lio-4.1 here, and I will get patch #5 of the mainline series updated shortly..
commit 07bc6603d7ff5f0abf5fc0e3d546b17d0d32cafe
Author: Nicholas Bellinger <[email protected]> Date: Mon Feb 28 15:40:13 2011 -0800
tcm_loop: Cleanups for mainline
This patch contains the following changes to TCM_Loop from Christoph's comments:
*) Remove EXTRA_FLAGS from Makefile
*) Change TCM_LOOP_CDB_DEBUG -> CONFIG_TCM_LOOP_CDB_DEBUG1
*) Remove unncessary kthread.h and version.h/utsrelease.h/utsname.h includes *) Convert .c code to use "" style includes for local includes *) Change 'if (!(foo)) {}' usage to 'if (!foo) {}' and (*sc->scsi_done)() ->
sc->scsi_done(sc)
*) Merge tcm_loop_configfs.h, tcm_loop_fabric.h, and tcm_loop_fabric_scsi.h
into tcm_loop_core.h
*) Convert tcm_loop_driver_probe() to setup sh->hostdata for the tl_hba
pointer, and update tcm_loop_queuecommand() + tcm_loop_device_reset() to use include/scsi/scsi_host.h:shost_priv()
drivers/target/tcm_loop/Makefile | 6 -- drivers/target/tcm_loop/tcm_loop_configfs.c | 38 ++++++-------- drivers/target/tcm_loop/tcm_loop_configfs.h | 2 - drivers/target/tcm_loop/tcm_loop_core.h | 66 +++++++++++++++++++++++- drivers/target/tcm_loop/tcm_loop_fabric.c | 21 +++---- drivers/target/tcm_loop/tcm_loop_fabric.h | 40 -------------- drivers/target/tcm_loop/tcm_loop_fabric_scsi.c | 63 ++++++----------------- drivers/target/tcm_loop/tcm_loop_fabric_scsi.h | 10 ---- 8 files changed, 107 insertions(+), 139 deletions(-) delete mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.h delete mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.h delete mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.h
Thanks!
--nab