tcm_loop updates
Subsystems (2)
cover tcm_loop updates
Hi Nic,
As tcm_loop claims to be a SAS HBA I thought it a good idea to hook it into the SAS transport class, so that we have the entire (virtual) SAS topology in sysfs now.
And even lsscsi is happy:
# lsscsi -H -t [10] tcm_loopback sas:0x6001405cc9332c5a # lsscsi -t [10:0:0:0] disk sas:0x6001405e41925ad3 /dev/sdf [10:0:1:0] disk sas:0x6001405e41925ad3 /dev/sdg
I've also included some pending fixes / updates I did for LIO target, mostly done to reproduce issues I've been facing:
- Disallow READ CAPACITY in standby
This is a long-standing issue with the linux SCSI stack and multipathing, both assuming that READ CAPACITY will always succeed. With that patch we can finally debug and fix this.
- Export the 'write_protect' attribute for demo-mode LUNs
- Some more UAs to be issued
As usual, reviews and comments are welcome.
Hannes Reinecke (8):
tcm_loop: Hook into SAS transport class
tcm_loop: Add SAS transport topology
tcm_loop: Remove SAS vestigies
tcm_loop: Send I_T_NEXUS_LOSS_OCCURRED UA
tcm_loop: Rescan SCSI target on transport online
target: Issue Power-On/Reset UA upon LUN instantiation
target_core_alua: disallow READ_CAPACITY when in standby
target: display 'write_protect' attribute for demo-mode LUNs
drivers/target/loopback/tcm_loop.c | 186 +++++++++++++++++++++++---- drivers/target/loopback/tcm_loop.h | 3 + drivers/target/target_core_alua.c | 9 -- drivers/target/target_core_device.c | 43 ++++++- drivers/target/target_core_fabric_configfs.c | 42 ++++++ drivers/target/target_core_internal.h | 1 + drivers/target/target_core_tpg.c | 17 +++ include/target/target_core_fabric.h | 1 + 8 files changed, 261 insertions(+), 41 deletions(-)
Signature · 1 line
1.8.5.2
PATCH 1/8 tcm_loop: Hook into SAS transport class
If tcm_loop emulates a SAS HBA it should hook into the SAS transport class, too.
--- drivers/target/loopback/tcm_loop.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/target/loopback/tcm_loop.c +15 -1
@@ -31,6 +31,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi_device.h> #include <scsi/scsi_cmnd.h> +#include <scsi/scsi_transport_sas.h> #include <target/target_core_base.h> #include <target/target_core_fabric.h>
@@ -42,7 +43,7 @@static struct workqueue_struct *tcm_loop_workqueue;static struct kmem_cache *tcm_loop_cmd_cache; - +static struct scsi_transport_template *tcm_loop_sas_transport_template;static int tcm_loop_hba_no_cnt;static int tcm_loop_queue_status (struct se_cmd *se_cmd);
@@ -360,6 +361,9 @@ static int tcm_loop_slave_alloc(struct scsi_device *sd)return 0 ; } +struct sas_function_template tcm_loop_sas_transport_functions = { +}; +static struct scsi_host_template tcm_loop_driver_template = { .show_info = tcm_loop_show_info, .proc_name ="tcm_loopback" ,
@@ -408,6 +412,8 @@ static int tcm_loop_driver_probe(struct device *dev) sh->max_lun =0 ; sh->max_channel =0 ; sh->max_cmd_len =SCSI_MAX_VARLEN_CDB_SIZE ; +if (tl_hba->tl_proto_id ==SCSI_PROTOCOL_SAS ) + sh->transportt = tcm_loop_sas_transport_template; host_prot =SHOST_DIF_TYPE1_PROTECTION |SHOST_DIF_TYPE2_PROTECTION | SHOST_DIF_TYPE3_PROTECTION | SHOST_DIX_TYPE1_PROTECTION |
@@ -1290,8 +1296,15 @@ static int __init tcm_loop_fabric_init(void)if (ret) goto out_release_core_bus; + tcm_loop_sas_transport_template = +sas_attach_transport (&tcm_loop_sas_transport_functions); +if (!tcm_loop_sas_transport_template) + goto out_unregister_template; +return 0 ; +out_unregister_template: +target_unregister_template (&loop_ops); out_release_core_bus:tcm_loop_release_core_bus (); out_destroy_cache:
@@ -1304,6 +1317,7 @@ out: static void __exit tcm_loop_fabric_exit(void) { +sas_release_transport (tcm_loop_sas_transport_template);target_unregister_template (&loop_ops);tcm_loop_release_core_bus ();kmem_cache_destroy (tcm_loop_cmd_cache);
Signature · 1 line
1.8.5.2
PATCH 2/8 tcm_loop: Add SAS transport topology
In reply to Hannes ReineckeAs tcm_loop emulates a SAS HBA it should not only
attach to the SAS transport template but also
populate the SAS device hierarchy.
--- drivers/target/loopback/tcm_loop.c | 139 ++++++++++++++++++++++++++++++++----- drivers/target/loopback/tcm_loop.h | 3 + 2 files changed, 125 insertions(+), 17 deletions(-)
drivers/target/loopback/tcm_loop.c +122 -17
@@ -439,6 +439,9 @@ static int tcm_loop_driver_remove(struct device *dev) tl_hba =to_tcm_loop_hba (dev); sh = tl_hba->sh; +if (tl_hba->tl_proto_id ==SCSI_PROTOCOL_SAS ) +sas_remove_host (sh); +scsi_remove_host (sh);scsi_host_put (sh);return 0 ;
@@ -729,10 +732,18 @@ static int tcm_loop_port_link(struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;atomic_inc_mb (&tl_tpg->tl_tpg_port_count); -/* -* Add Linux/SCSI struct scsi_device by HCTL -*/ -scsi_add_device (tl_hba->sh,0 , tl_tpg->tl_tpgt, lun->unpacked_lun); +if (tl_hba->tl_proto_id !=SCSI_PROTOCOL_SAS ) { +/* +* Add Linux/SCSI struct scsi_device by HCTL +*/ +scsi_add_device (tl_hba->sh,0 , + tl_tpg->tl_tpgt, lun->unpacked_lun); + }else { +struct sas_rphy *rphy = tl_tpg->sas_rphy; + +scsi_scan_target (&rphy->dev,0 , rphy->scsi_target_id, + lun->unpacked_lun,0 ); + }pr_debug ("TCM_Loop_ConfigFS: Port Link Successful\n" );return 0 ;
@@ -749,19 +760,21 @@ static void tcm_loop_port_unlink( tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, tl_se_tpg); tl_hba = tl_tpg->tl_hba; - sd =scsi_device_lookup (tl_hba->sh,0 , tl_tpg->tl_tpgt, - se_lun->unpacked_lun); -if (!sd) { -pr_err ("Unable to locate struct scsi_device for %d:%d:" -"%llu\n" ,0 , tl_tpg->tl_tpgt, se_lun->unpacked_lun); -return ; +if (tl_hba->tl_proto_id !=SCSI_PROTOCOL_SAS ) { + sd =scsi_device_lookup (tl_hba->sh,0 , tl_tpg->tl_tpgt, + se_lun->unpacked_lun); +if (!sd) { +pr_err ("Unable to locate struct scsi_device for %d:%d:" +"%llu\n" ,0 , tl_tpg->tl_tpgt, + se_lun->unpacked_lun); +return ; + } +/* +* Remove Linux/SCSI struct scsi_device by HCTL +*/ +scsi_remove_device (sd); +scsi_device_put (sd); } -/* -* Remove Linux/SCSI struct scsi_device by HCTL -*/ -scsi_remove_device (sd); -scsi_device_put (sd); -atomic_dec_mb (&tl_tpg->tl_tpg_port_count);pr_debug ("TCM_Loop_ConfigFS: Port Unlink Successful\n" );
@@ -858,6 +871,33 @@ static int tcm_loop_make_nexus(pr_debug ("TCM_Loop_ConfigFS: Established I_T Nexus to emulated" " %s Initiator Port: %s\n" ,tcm_loop_dump_proto_id (tl_hba), name); + +if (tl_hba->tl_proto_id ==SCSI_PROTOCOL_SAS ) { +struct Scsi_Host *sh = tl_hba->sh; +u64 sas_address; + +if (kstrtoull (name,16 , &sas_address)) { +pr_err ("Invalid SAS address %s\n" , name); +return -ENODEV ; + } + tl_nexus->sas_phy =sas_phy_alloc (&sh->shost_gendev, + tl_tpg->tl_tpgt); +if (!tl_nexus->sas_phy) { +pr_err ("Unable to allocate SAS host phy\n" ); +return -ENOMEM ; + } + tl_nexus->sas_phy->identify.sas_address = sas_address; + tl_nexus->sas_phy->identify.phy_identifier =0 ; + tl_nexus->sas_phy->identify.device_type =SAS_END_DEVICE ; + tl_nexus->sas_phy->identify.initiator_port_protocols =SAS_PROTOCOL_STP |SAS_PROTOCOL_SMP ; +if (sas_phy_add (tl_nexus->sas_phy)) { +sas_phy_free (tl_nexus->sas_phy); + tl_nexus->sas_phy =NULL ; +pr_err ("Unable to add SAS host phy\n" ); +return -ENODEV ; + } +sas_port_add_phy (tl_tpg->sas_port, tl_nexus->sas_phy); + }return 0 ; out:
@@ -886,6 +926,13 @@ static int tcm_loop_drop_nexus(return -EPERM ; } +if (tl_nexus->sas_phy) { +sas_port_delete_phy (tpg->sas_port, tl_nexus->sas_phy); +sas_phy_delete (tl_nexus->sas_phy); +sas_phy_free (tl_nexus->sas_phy); + tl_nexus->sas_phy =NULL ; + } +pr_debug ("TCM_Loop_ConfigFS: Removing I_T Nexus to emulated" " %s Initiator Port: %s\n" ,tcm_loop_dump_proto_id (tpg->tl_hba), tl_nexus->se_sess->se_node_acl->initiatorname);
@@ -956,7 +1003,7 @@ static ssize_t tcm_loop_tpg_store_nexus( tcm_loop_dump_proto_id(tl_hba));return -EINVAL ; } - port_ptr = &i_port[0 ]; + port_ptr = &i_port[4 ]; goto check_newline; } ptr =strstr (i_port,"fc." );
@@ -1089,6 +1136,48 @@ static struct se_portal_group *tcm_loop_make_naa_tpg(if (ret <0 )return ERR_PTR (-ENOMEM ); +if (tl_hba->tl_proto_id ==SCSI_PROTOCOL_SAS ) { +struct Scsi_Host *sh = tl_hba->sh; +u64 sas_address; + + tl_tpg->sas_port =sas_port_alloc (&sh->shost_gendev, tpgt); +if (!tl_tpg->sas_port) { +pr_err ("Unable to allocate SAS port %ld\n" , tpgt); +return ERR_PTR (-ENOMEM ); + } +if ((sas_port_add (tl_tpg->sas_port))) { +sas_port_free (tl_tpg->sas_port); + tl_tpg->sas_port =NULL ; +pr_err ("Unable to add SAS port %ld\n" , tpgt); +return ERR_PTR (-ENODEV ); + } +if (kstrtoull (tl_hba->tl_wwn_address,16 , &sas_address)) { +pr_err ("Invalid SAS address %s\n" , + tl_hba->tl_wwn_address); +sas_port_free (tl_tpg->sas_port); + tl_tpg->sas_port =NULL ; +return ERR_PTR (-ENODEV ); + } + tl_tpg->sas_rphy =sas_end_device_alloc (tl_tpg->sas_port); +if (!tl_tpg->sas_rphy) { +pr_err ("Unable to allocate SAS end device\n" ); +sas_port_free (tl_tpg->sas_port); + tl_tpg->sas_port =NULL ; +return ERR_PTR (-ENOMEM ); + } + tl_tpg->sas_rphy->identify.sas_address = sas_address; + tl_tpg->sas_rphy->identify.phy_identifier =0 ; + tl_tpg->sas_rphy->identify.device_type =SAS_END_DEVICE ; + tl_tpg->sas_rphy->identify.target_port_protocols =SAS_PROTOCOL_STP |SAS_PROTOCOL_SMP ; +if (sas_rphy_add (tl_tpg->sas_rphy)) { +sas_rphy_free (tl_tpg->sas_rphy); + tl_tpg->sas_rphy =NULL ; +sas_port_free (tl_tpg->sas_port); + tl_tpg->sas_port =NULL ; +pr_err ("Unable to add SAS target phy\n" ); +return ERR_PTR (-ENODEV ); + } + }pr_debug ("TCM_Loop_ConfigFS: Allocated Emulated %s" " Target Port %s,t,0x%04lx\n" ,tcm_loop_dump_proto_id (tl_hba),config_item_name (&wwn->wwn_group.cg_item), tpgt);
@@ -1107,10 +1196,25 @@ static void tcm_loop_drop_naa_tpg( tl_hba = tl_tpg->tl_hba; tpgt = tl_tpg->tl_tpgt; + +if (tl_hba->tl_proto_id ==SCSI_PROTOCOL_SAS ) +sas_rphy_delete (tl_tpg->sas_rphy); +/* * Release the I_T Nexus for the Virtual SAS link if present */ tcm_loop_drop_nexus (tl_tpg); + +if (tl_tpg->sas_rphy) { +sas_rphy_delete (tl_tpg->sas_rphy); + tl_tpg->sas_rphy =NULL ; + } + +if (tl_tpg->sas_port) { +sas_port_free (tl_tpg->sas_port); + tl_tpg->sas_port =NULL ; + } +/* * Deregister the tl_tpg as a emulated SAS TCM Target Endpoint */
@@ -1150,6 +1254,7 @@ static struct se_wwn *tcm_loop_make_scsi_hba( ptr =strstr (name,"naa." );if (ptr) { tl_hba->tl_proto_id =SCSI_PROTOCOL_SAS ; + off =4 ;/* Skip over "naa." */ goto check_len; } ptr =strstr (name,"fc." );
drivers/target/loopback/tcm_loop.h +3 -0
@@ -26,6 +26,7 @@ struct tcm_loop_nexus {* Pointer to TCM session for I_T Nexus */ struct se_session *se_sess; +struct sas_phy *sas_phy; };#define TCM_TRANSPORT_ONLINE 0
@@ -39,6 +40,8 @@ struct tcm_loop_tpg {struct se_portal_group tl_se_tpg;struct tcm_loop_hba *tl_hba;struct tcm_loop_nexus *tl_nexus; +struct sas_port *sas_port; +struct sas_rphy *sas_rphy; };struct tcm_loop_hba {
Signature · 1 line
1.8.5.2
PATCH 3/8 tcm_loop: Remove SAS vestigies
In reply to Hannes Reinecketcm_loop is able to emulate several protocols, so remove last vestigies of the SAS protocol.
--- drivers/target/loopback/tcm_loop.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/target/loopback/tcm_loop.c +9 -8
@@ -535,7 +535,7 @@ static inline struct tcm_loop_tpg *tl_tpg(struct se_portal_group *se_tpg)static char *tcm_loop_get_endpoint_wwn (struct se_portal_group *se_tpg) {/* -* Return the passed NAA identifier for the SAS Target Port +* Return the passed NAA identifier for the Target Port */ return &tl_tpg (se_tpg)->tl_hba->tl_wwn_address[0 ]; }
@@ -864,7 +864,7 @@ static int tcm_loop_make_nexus(transport_free_session (tl_nexus->se_sess); goto out; } -/* Now, register the SAS I_T Nexus as active. */ +/* Now, register the I_T Nexus as active. */ transport_register_session (se_tpg, tl_nexus->se_sess->se_node_acl, tl_nexus->se_sess, tl_nexus); tl_tpg->tl_nexus = tl_nexus;
@@ -937,7 +937,7 @@ static int tcm_loop_drop_nexus(" %s Initiator Port: %s\n" ,tcm_loop_dump_proto_id (tpg->tl_hba), tl_nexus->se_sess->se_node_acl->initiatorname);/* -* Release the SCSI I_T Nexus to the emulated SAS Target Port +* Release the SCSI I_T Nexus to the emulated Target Port */ transport_deregister_session (tl_nexus->se_sess); tpg->tl_nexus =NULL ;
@@ -1130,7 +1130,7 @@ static struct se_portal_group *tcm_loop_make_naa_tpg( tl_tpg->tl_hba = tl_hba; tl_tpg->tl_tpgt = tpgt;/* -* Register the tl_tpg as a emulated SAS TCM Target Endpoint +* Register the tl_tpg as a emulated TCM Target Endpoint */ ret =core_tpg_register (wwn, &tl_tpg->tl_se_tpg, tl_hba->tl_proto_id);if (ret <0 )
@@ -1201,7 +1201,7 @@ static void tcm_loop_drop_naa_tpg(sas_rphy_delete (tl_tpg->sas_rphy);/* -* Release the I_T Nexus for the Virtual SAS link if present +* Release the I_T Nexus for the Virtual target link if present */ tcm_loop_drop_nexus (tl_tpg);
@@ -1216,7 +1216,7 @@ static void tcm_loop_drop_naa_tpg( }/* -* Deregister the tl_tpg as a emulated SAS TCM Target Endpoint +* Deregister the tl_tpg as a emulated TCM Target Endpoint */ core_tpg_deregister (se_tpg);
@@ -1310,8 +1310,9 @@ static void tcm_loop_drop_scsi_hba( struct tcm_loop_hba, tl_hba_wwn);pr_debug ("TCM_Loop_ConfigFS: Deallocating emulated Target" -" SAS Address: %s at Linux/SCSI Host ID: %d\n" , - tl_hba->tl_wwn_address, tl_hba->sh->host_no); +" %s Address: %s at Linux/SCSI Host ID: %d\n" , +tcm_loop_dump_proto_id (tl_hba), tl_hba->tl_wwn_address, + tl_hba->sh->host_no);/* * Call device_unregister() on the original tl_hba->dev. * tcm_loop_fabric_scsi.c:tcm_loop_release_adapter() will
Signature · 1 line
1.8.5.2
PATCH 4/8 tcm_loop: Send I_T_NEXUS_LOSS_OCCURRED UA
In reply to Hannes ReineckeIf the virtual SAS link is set to 'offline' we should be queueing an I_T_NEXUS_LOSS_OCCURRED UA.
--- drivers/target/loopback/tcm_loop.c | 5 +++++ drivers/target/target_core_tpg.c | 17 +++++++++++++++++ include/target/target_core_fabric.h | 1 + 3 files changed, 23 insertions(+)
drivers/target/loopback/tcm_loop.c +5 -0
@@ -1087,6 +1087,11 @@ static ssize_t tcm_loop_tpg_store_transport_status( }if (!strncmp (page,"offline" ,7 )) { tl_tpg->tl_transport_status =TCM_TRANSPORT_OFFLINE ; +if (tl_tpg->tl_nexus) { +struct se_session *tl_sess = tl_tpg->tl_nexus->se_sess; + +core_allocate_nexus_loss_ua (tl_sess->se_node_acl); + }return count; }return -EINVAL ;
drivers/target/target_core_tpg.c +17 -0
@@ -43,6 +43,7 @@#include "target_core_internal.h" #include "target_core_alua.h" #include "target_core_pr.h" +#include "target_core_ua.h" extern struct se_device *g_lun0_dev;
@@ -85,6 +86,22 @@ struct se_node_acl *core_tpg_get_initiator_node_acl( }EXPORT_SYMBOL (core_tpg_get_initiator_node_acl); +void core_allocate_nexus_loss_ua ( +struct se_node_acl *nacl) +{ +struct se_dev_entry *deve; + +if (!nacl) +return ; + +rcu_read_lock (); +hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link) +core_scsi3_ua_allocate (deve,0x29 , +ASCQ_29H_NEXUS_LOSS_OCCURRED ); +rcu_read_unlock (); +} +EXPORT_SYMBOL (core_allocate_nexus_loss_ua); +/* core_tpg_add_node_to_devs(): * *
include/target/target_core_fabric.h +1 -0
@@ -152,6 +152,7 @@ int transport_generic_handle_tmr(struct se_cmd *);void transport_generic_request_failure (struct se_cmd *,sense_reason_t );void __target_execute_cmd (struct se_cmd *);int transport_lookup_tmr_lun (struct se_cmd *,u64 ); +void core_allocate_nexus_loss_ua (struct se_node_acl *acl);struct se_node_acl *core_tpg_get_initiator_node_acl (struct se_portal_group *tpg,unsigned char *);
Signature · 1 line
1.8.5.2
PATCH 5/8 tcm_loop: Rescan SCSI target on transport online
In reply to Hannes ReineckeSetting the transport status to 'online' needs to rescan the target, as some devices might have been added while the transport has been offline.
--- drivers/target/loopback/tcm_loop.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/target/loopback/tcm_loop.c +9 -0
@@ -1082,7 +1082,16 @@ static ssize_t tcm_loop_tpg_store_transport_status( struct tcm_loop_tpg, tl_se_tpg);if (!strncmp (page,"online" ,6 )) { +int status = tl_tpg->tl_transport_status; + tl_tpg->tl_transport_status =TCM_TRANSPORT_ONLINE ; +if (status != tl_tpg->tl_transport_status && + tl_tpg->tl_hba->tl_proto_id ==SCSI_PROTOCOL_SAS ) { +struct sas_rphy *rphy = tl_tpg->sas_rphy; + +scsi_scan_target (&rphy->dev,0 , rphy->scsi_target_id, +SCAN_WILD_CARD ,0 ); + }return count; }if (!strncmp (page,"offline" ,7 )) {
Signature · 1 line
1.8.5.2
PATCH 6/8 target: Issue Power-On/Reset UA upon LUN instantiation
In reply to Hannes ReineckeWhenever a LUN is being assigned we should be sending out an Power-On/Reset UA.
--- drivers/target/target_core_device.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/target/target_core_device.c +10 -6
@@ -363,9 +363,11 @@ int core_enable_device_list_for_node(rcu_read_lock ();hlist_for_each_entry_rcu (tmp, &nacl->lun_entry_hlist, link) {if (tmp == new) -continue ; -core_scsi3_ua_allocate (tmp,0x3F , -ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED ); +core_scsi3_ua_allocate (tmp,0x29 , +ASCQ_29H_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURED ); +else +core_scsi3_ua_allocate (tmp,0x3F , +ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED ); }rcu_read_unlock ();
@@ -385,9 +387,11 @@ int core_enable_device_list_for_node(rcu_read_lock ();hlist_for_each_entry_rcu (tmp, &nacl->lun_entry_hlist, link) {if (tmp == new) -continue ; -core_scsi3_ua_allocate (tmp,0x3F , -ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED ); +core_scsi3_ua_allocate (tmp,0x29 , +ASCQ_29H_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURED ); +else +core_scsi3_ua_allocate (tmp,0x3F , +ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED ); }rcu_read_unlock ();return 0 ;
Signature · 1 line
1.8.5.2
PATCH 7/8 target_core_alua: disallow READ_CAPACITY when in standby
In reply to Hannes ReineckeStrictly speaking SPC doesn't require READ CAPACITY and friends to be supported while in the port is in standby.
--- drivers/target/target_core_alua.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/target/target_core_alua.c +0 -9
@@ -561,16 +561,7 @@ static inline int core_alua_state_standby(case REPORT_LUNS :case RECEIVE_DIAGNOSTIC :case SEND_DIAGNOSTIC : -case READ_CAPACITY :return 0 ; -case SERVICE_ACTION_IN_16 : -switch (cdb[1 ] &0x1f ) { -case SAI_READ_CAPACITY_16 : -return 0 ; -default : -set_ascq (cmd,ASCQ_04H_ALUA_TG_PT_STANDBY ); -return 1 ; - }case MAINTENANCE_IN :switch (cdb[1 ] &0x1f ) {case MI_REPORT_TARGET_PGS :
Signature · 1 line
1.8.5.2
Re: [PATCH 7/8] target_core_alua: disallow READ_CAPACITY when in standby
Quoted 2 lines · Hannes Reinecke
Strictly speaking SPC doesn't require READ CAPACITY and friends to be supported while in the port is in standby.
Hi Hannes,
I'd really rather this didn't go away. Yes, strictly speaking SPC doesn't require these commands but Linux in practice does, and ISTR this was added at my request too.
We need it on our storage setups to prevent the Linux SCSI stack from exploding. If this is removed here, they'll start exploding again until the fix goes in and the initiators are updated.
Could this please be kept as an option or something?
Cheers,
Chris
Quoted 27 lines
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/target/target_core_alua.c | 9 --------- 1 file changed, 9 deletions(-)drivers/target/target_core_alua.c +0
-9@@ -561,16 +561,7 @@ static inline int core_alua_state_standby(case REPORT_LUNS :case RECEIVE_DIAGNOSTIC :case SEND_DIAGNOSTIC : -case READ_CAPACITY :return 0 ; -case SERVICE_ACTION_IN_16 : -switch (cdb[1 ] &0x1f ) { -case SAI_READ_CAPACITY_16 : -return 0 ; -default : -set_ascq (cmd,ASCQ_04H_ALUA_TG_PT_STANDBY ); -return 1 ; - }case MAINTENANCE_IN :switch (cdb[1 ] &0x1f ) {case MI_REPORT_TARGET_PGS :
Signature · 2 lines
Chris Boot [email protected]
Re: [PATCH 7/8] target_core_alua: disallow READ_CAPACITY when in standby
Quoted 6 lines · Chris Boot
Quoted 2 lines · Hannes Reinecke
Strictly speaking SPC doesn't require READ CAPACITY and friends to be supported while in the port is in standby.
Hi Hannes,
Quoted 8 lines
I'd really rather this didn't go away. Yes, strictly speaking SPC doesn't require these commands but Linux in practice does, and ISTR this was added at my request too.
We need it on our storage setups to prevent the Linux SCSI stack from exploding. If this is removed here, they'll start exploding again until the fix goes in and the initiators are updated.
This was exactly why I added it, so that one could go about and fix the linux SCSI stack :-)
Quoted 2 lines
Could this please be kept as an option or something?
Yeah, I see what I can do.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 7/8] target_core_alua: disallow READ_CAPACITY when in standby
In reply to Hannes ReineckeQuoted 2 lines · Hannes Reinecke
Strictly speaking SPC doesn't require READ CAPACITY and friends to be supported while in the port is in standby.
But it does allow it. We should always aim to implement the best possible behavior instead of aiming for the worst.
Re: [PATCH 7/8] target_core_alua: disallow READ_CAPACITY when in standby
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Hannes Reinecke
Strictly speaking SPC doesn't require READ CAPACITY and friends to be supported while in the port is in standby.
But it does allow it. We should always aim to implement the best possible behavior instead of aiming for the worst.
Right. As mentioned in my other mail this patch was primarily to fixup READ CAPACITY issues in the linux kernel.
I'll be updating the patch to make it optional.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/8 target: display 'write_protect' attribute for demo-mode LUNs
In reply to Hannes ReineckeWhen LUNs are mapped with a demo-mode initiator we're missing the 'write_protect' attribute to set a LUN read-only.
--- drivers/target/target_core_device.c | 27 ++++++++++++++++++ drivers/target/target_core_fabric_configfs.c | 42 ++++++++++++++++++++++++++++ drivers/target/target_core_internal.h | 1 + 3 files changed, 70 insertions(+)
drivers/target/target_core_device.c +27 -0
@@ -271,6 +271,33 @@ void core_update_device_list_access(mutex_unlock (&nacl->lun_entry_mutex); } +void core_update_lun_access ( +struct se_lun *lun, +u32 lun_access) +{ +struct se_dev_entry *deve; + +if (lun_access ==TRANSPORT_LUNFLAGS_READ_ONLY ) { + lun->lun_access &= ~TRANSPORT_LUNFLAGS_READ_WRITE ; + lun->lun_access |=TRANSPORT_LUNFLAGS_READ_ONLY ; + }else { + lun->lun_access &= ~TRANSPORT_LUNFLAGS_READ_ONLY ; + lun->lun_access |=TRANSPORT_LUNFLAGS_READ_WRITE ; + } + +spin_lock_bh (&lun->lun_deve_lock); +list_for_each_entry (deve, &lun->lun_deve_list, lun_link) { +if (lun_access &TRANSPORT_LUNFLAGS_READ_WRITE ) { + deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY ; + deve->lun_flags |=TRANSPORT_LUNFLAGS_READ_WRITE ; + }else { + deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_WRITE ; + deve->lun_flags |=TRANSPORT_LUNFLAGS_READ_ONLY ; + } + } +spin_unlock_bh (&lun->lun_deve_lock); +} +/* * Called with rcu_read_lock or nacl->device_list_lock held. */
drivers/target/target_core_fabric_configfs.c +42 -0
54 lines not on this page · raw message
drivers/target/target_core_internal.h +1 -0
@@ -36,6 +36,7 @@ void core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);int core_dev_add_lun (struct se_portal_group *,struct se_device *,struct se_lun *lun);void core_dev_del_lun (struct se_portal_group *,struct se_lun *); +void core_update_lun_access (struct se_lun *,u32 );struct se_lun_acl *core_dev_init_initiator_node_lun_acl (struct se_portal_group *,struct se_node_acl *,u64 ,int *); int core_dev_add_initiator_node_lun_acl(struct se_portal_group *,
Signature · 1 line
1.8.5.2
Re: [PATCH 8/8] target: display 'write_protect' attribute for demo-mode LUNs
Quoted 2 lines · Hannes Reinecke
When LUNs are mapped with a demo-mode initiator we're missing the '
write_protect' attribute to set a LUN read-only.
I don't think it's a good idea as-is. The target core clearly differenciates between demo mode and production mode read only, and some drivers already expose attributes for these.
I have a big series in progress to clean the mess around this area up. So for now please don't add anything here, it should become much simpler after my changes, and I might be able to incorporate something like this after the main series.
Re: [PATCH 8/8] target: display 'write_protect' attribute for demo-mode LUNs
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines · Hannes Reinecke
When LUNs are mapped with a demo-mode initiator we're missing the '
write_protect' attribute to set a LUN read-only.
Quoted 9 lines
I don't think it's a good idea as-is. The target core clearly differenciates between demo mode and production mode read only, and some drivers already expose attributes for these.
I have a big series in progress to clean the mess around this area up. So for now please don't add anything here, it should become much simpler after my changes, and I might be able to incorporate something like this after the main series.
I've done this particular patch to simulate write-protected LUNs via tcm_loop. As the hooks already had been there I thought this to be the 'cleanest' approach.
Of course, if you have other suggestions on how this should be achieved I'm happy to try this.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
What's the benefit of the SAS transport class writeout? I honestly always saw tcm_loop as a simple loopback driver, with the different transport IDs in the PR code as a gimmick. Note that vhost and xen-blkback copies that style and I did plan to consolidate it in common code.
Quoted 6 lines · Christoph Hellwig
What's the benefit of the SAS transport class writeout? I honestly always saw
tcm_loopas a simple loopback driver, with the different transport IDs in the PR code as a gimmick. Note that vhost and xen-blkback copies that style and I did plan to consolidate it in common code.
The benefit is that tcm_loop will show up in the system as a 'real' SAS hba; long-term goal is to simulate SAS multipathing here. I was even planning on adding simlated FC infrastructure, too; with that we could simulate FC multipathing, too, and our QA would be _so_ happy...
Again, these patches are mainly a collection of patches I've done to test various scenarios, in the hope others might find them useful, too. So I can easily hold off these patches until you've posted your rework.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Hannes Reinecke
Quoted 6 lines · Christoph Hellwig
What's the benefit of the SAS transport class writeout? I honestly always saw
tcm_loopas a simple loopback driver, with the different transport IDs in the PR code as a gimmick. Note that vhost and xen-blkback copies that style and I did plan to consolidate it in common code.
Quoted 6 lines
The benefit is that
tcm_loopwill show up in the system as a 'real' SAS hba; long-term goal is to simulate SAS multipathing here. I was even planning on adding simlated FC infrastructure, too; with that we could simulate FC multipathing, too, and our QA would be _so_ happy...
Sounds like a reasonable use-case to support for loopback testing.
Quoted 5 lines
Again, these patches are mainly a collection of patches I've done to test various scenarios, in the hope others might find them useful, too. So I can easily hold off these patches until you've posted your rework.
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple tcm_loop LLD specific API for different multipath transports..?
Quoted 23 lines · Nicholas A. Bellinger
Quoted 7 lines · Hannes Reinecke
Quoted 6 lines · Christoph Hellwig
What's the benefit of the SAS transport class writeout? I honestly always saw
tcm_loopas a simple loopback driver, with the different transport IDs in the PR code as a gimmick. Note that vhost and xen-blkback copies that style and I did plan to consolidate it in common code.Quoted 6 lines
The benefit is that
tcm_loopwill show up in the system as a 'real' SAS hba; long-term goal is to simulate SAS multipathing here. I was even planning on adding simlated FC infrastructure, too; with that we could simulate FC multipathing, too, and our QA would be _so_ happy...Sounds like a reasonable use-case to support for loopback testing.
Quoted 5 lines
Again, these patches are mainly a collection of patches I've done to test various scenarios, in the hope others might find them useful, too. So I can easily hold off these patches until you've posted your rework.
Quoted 5 lines
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple
tcm_loopLLD specific API for different multipath transports..?
Actually, I would split off the various transport functions into separate files (tcm_loop_sas, tcm_loop_fc, etc), but keep a common tcm_loop module.
We can even make transport classes optional by adding an explicit 'sas.XXX' prefix scanning when creating the device similar to what we do with the 'fc.XXX' prefix already.
With that we would have a 'sas.XXX', 'fc.XXX', and 'iqn.XXX' WWN which would attach to the respective transport class, and any other WWN (which would be the default) would be getting the standard emulation without any transport class attached.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 29 lines · Hannes Reinecke
Quoted 23 lines · Nicholas A. Bellinger
Quoted 7 lines · Hannes Reinecke
Quoted 6 lines · Christoph Hellwig
What's the benefit of the SAS transport class writeout? I honestly always saw
tcm_loopas a simple loopback driver, with the different transport IDs in the PR code as a gimmick. Note that vhost and xen-blkback copies that style and I did plan to consolidate it in common code.Quoted 6 lines
The benefit is that
tcm_loopwill show up in the system as a 'real' SAS hba; long-term goal is to simulate SAS multipathing here. I was even planning on adding simlated FC infrastructure, too; with that we could simulate FC multipathing, too, and our QA would be _so_ happy...Sounds like a reasonable use-case to support for loopback testing.
Quoted 5 lines
Again, these patches are mainly a collection of patches I've done to test various scenarios, in the hope others might find them useful, too. So I can easily hold off these patches until you've posted your rework.
Quoted 5 lines
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple
tcm_loopLLD specific API for different multipath transports..?
Quoted 10 lines
Actually, I would split off the various transport functions into separate files (
tcm_loop_sas,tcm_loop_fc, etc), but keep a commontcm_loopmodule.
We can even make transport classes optional by adding an explicit 'sas.XXX' prefix scanning when creating the device similar to what we do with the 'fc.XXX' prefix already.
With that we would have a 'sas.XXX', 'fc.XXX', and 'iqn.XXX' WWN which would attach to the respective transport class, and any other WWN (which would be the default) would be getting the standard emulation without any transport class attached.
I'm open to merging the tcm_loop patches #1-#6 as-is for the sas transport pieces, or wait until you've done a large split based on transport class types.
It's really your call how the initial merge should look.
--nab
Quoted 41 lines · Nicholas A. Bellinger
Quoted 29 lines · Hannes Reinecke
Quoted 23 lines · Nicholas A. Bellinger
Quoted 7 lines · Hannes Reinecke
Quoted 6 lines · Christoph Hellwig
What's the benefit of the SAS transport class writeout? I honestly always saw
tcm_loopas a simple loopback driver, with the different transport IDs in the PR code as a gimmick. Note that vhost and xen-blkback copies that style and I did plan to consolidate it in common code.Quoted 6 lines
The benefit is that
tcm_loopwill show up in the system as a 'real' SAS hba; long-term goal is to simulate SAS multipathing here. I was even planning on adding simlated FC infrastructure, too; with that we could simulate FC multipathing, too, and our QA would be _so_ happy...Sounds like a reasonable use-case to support for loopback testing.
Quoted 5 lines
Again, these patches are mainly a collection of patches I've done to test various scenarios, in the hope others might find them useful, too. So I can easily hold off these patches until you've posted your rework.
Quoted 5 lines
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple
tcm_loopLLD specific API for different multipath transports..?Quoted 10 lines
Actually, I would split off the various transport functions into separate files (
tcm_loop_sas,tcm_loop_fc, etc), but keep a commontcm_loopmodule.
We can even make transport classes optional by adding an explicit 'sas.XXX' prefix scanning when creating the device similar to what we do with the 'fc.XXX' prefix already.
With that we would have a 'sas.XXX', 'fc.XXX', and 'iqn.XXX' WWN which would attach to the respective transport class, and any other WWN (which would be the default) would be getting the standard emulation without any transport class attached.
Quoted 6 lines
I'm open to merging the
tcm_looppatches #1-#6 as-is for the sas transport pieces, or wait until you've done a large split based on transport class types.It's really your call how the initial merge should look.
Probably leave out the transport class stuff for now; I kinda like the idea of having all types of transport classes available for tcm_loop.
But this is actually not related to the rest of the patchset, so you can skip those for the time being.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Quoted 3 lines · Hannes Reinecke
Quoted 2 lines · Nicholas A. Bellinger
Quoted 1 line · Hannes Reinecke
On 06/23/2015 10:29 AM, Nicholas A. Bellinger wrote:
<SNIP>
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple
tcm_loopLLD specific API for different multipath transports..?Quoted 10 lines
Actually, I would split off the various transport functions into separate files (
tcm_loop_sas,tcm_loop_fc, etc), but keep a commontcm_loopmodule.
We can even make transport classes optional by adding an explicit 'sas.XXX' prefix scanning when creating the device similar to what we do with the 'fc.XXX' prefix already.
With that we would have a 'sas.XXX', 'fc.XXX', and 'iqn.XXX' WWN which would attach to the respective transport class, and any other WWN (which would be the default) would be getting the standard emulation without any transport class attached.I'm open to merging the
tcm_looppatches #1-#6 as-is for the sas transport pieces, or wait until you've done a large split based on transport class types.
Quoted 8 lines
Quoted 2 lines
It's really your call how the initial merge should look.
Probably leave out the transport class stuff for now; I kinda like the idea of having all types of transport classes available for
tcm_loop.
But this is actually not related to the rest of the patchset, so you can skip those for the time being.
Just to confirm, applying patch #3-#6, and #8 to for-next now.
Skipping #7 for the moment, given host side expectations short of being configurable as noted by HCH.
Quoted 36 lines · Nicholas A. Bellinger
Quoted 3 lines · Hannes Reinecke
Quoted 2 lines · Nicholas A. Bellinger
Quoted 1 line · Hannes Reinecke
On 06/23/2015 10:29 AM, Nicholas A. Bellinger wrote:
<SNIP>
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple
tcm_loopLLD specific API for different multipath transports..?Quoted 10 lines
Actually, I would split off the various transport functions into separate files (
tcm_loop_sas,tcm_loop_fc, etc), but keep a commontcm_loopmodule.
We can even make transport classes optional by adding an explicit 'sas.XXX' prefix scanning when creating the device similar to what we do with the 'fc.XXX' prefix already.
With that we would have a 'sas.XXX', 'fc.XXX', and 'iqn.XXX' WWN which would attach to the respective transport class, and any other WWN (which would be the default) would be getting the standard emulation without any transport class attached.I'm open to merging the
tcm_looppatches #1-#6 as-is for the sas transport pieces, or wait until you've done a large split based on transport class types.Quoted 8 lines
Quoted 2 lines
It's really your call how the initial merge should look.
Probably leave out the transport class stuff for now; I kinda like the idea of having all types of transport classes available for
tcm_loop.
But this is actually not related to the rest of the patchset, so you can skip those for the time being.
Quoted 5 lines
Just to confirm, applying patch #3-#6, and #8 to for-next now.
Skipping #7 for the moment, given host side expectations short of being configurable as noted by HCH.
Precisely. Thank you.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Quoted 37 lines · Hannes Reinecke
Quoted 36 lines · Nicholas A. Bellinger
Quoted 3 lines · Hannes Reinecke
Quoted 2 lines · Nicholas A. Bellinger
Quoted 1 line · Hannes Reinecke
On 06/23/2015 10:29 AM, Nicholas A. Bellinger wrote:
<SNIP>
Quoted 28 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
How different do you expect sas, fc, and iscsi transports to be..?
Do you think this would this be better served by a simple
tcm_loopLLD specific API for different multipath transports..?Quoted 10 lines
Actually, I would split off the various transport functions into separate files (
tcm_loop_sas,tcm_loop_fc, etc), but keep a commontcm_loopmodule.
We can even make transport classes optional by adding an explicit 'sas.XXX' prefix scanning when creating the device similar to what we do with the 'fc.XXX' prefix already.
With that we would have a 'sas.XXX', 'fc.XXX', and 'iqn.XXX' WWN which would attach to the respective transport class, and any other WWN (which would be the default) would be getting the standard emulation without any transport class attached.Quoted 6 lines
I'm open to merging the
tcm_looppatches #1-#6 as-is for the sas transport pieces, or wait until you've done a large split based on transport class types.It's really your call how the initial merge should look.
Probably leave out the transport class stuff for now; I kinda like the idea of having all types of transport classes available for
tcm_loop.
But this is actually not related to the rest of the patchset, so you can skip those for the time being.
Quoted 7 lines
Quoted 5 lines
Just to confirm, applying patch #3-#6, and #8 to for-next now.
Skipping #7 for the moment, given host side expectations short of being configurable as noted by HCH.
Precisely. Thank you.
Whoops, forgot that logic for #6 was already applied to v4.2-rc1, and HCH had some objections to patch #8.
Also, #5 does depend on the sas transport class support.
So just applying #3-#4 for now..