Additionally, introduce the new function transport_register_session_with_nacl(). This patch does not change any functionality but makes the next two patches easier to review. Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx> Cc: Andy Grover <agrover@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Sagi Grimberg <sagig@xxxxxxxxxxxx> --- drivers/target/target_core_transport.c | 115 ++++++++++++++++++--------------- include/target/target_core_fabric.h | 4 +- 2 files changed, 65 insertions(+), 54 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 4b2c95c..1b5525f 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -297,83 +297,94 @@ struct se_session *transport_init_session_tags(unsigned int tag_num, } EXPORT_SYMBOL(transport_init_session_tags); +static int __transport_register_session_with_nacl(struct se_node_acl *se_nacl, + struct se_session *se_sess) +{ + struct se_portal_group *const se_tpg = se_sess->se_tpg; + const struct target_core_fabric_ops *const tfo = se_tpg->se_tpg_tfo; + unsigned char buf[PR_REG_ISID_LEN]; + int ret = 0; + + /* + * Determine if fabric allows for T10-PI feature bits exposed to + * initiators for device backends with !dev->dev_attrib.pi_prot_type. + * + * If so, then always save prot_type on a per se_node_acl node + * basis and re-instate the previous sess_prot_type to avoid + * disabling PI from below any previously initiator side + * registered LUNs. + */ + if (se_nacl->saved_prot_type) + se_sess->sess_prot_type = se_nacl->saved_prot_type; + else if (tfo->tpg_check_prot_fabric_only) + se_sess->sess_prot_type = se_nacl->saved_prot_type = + tfo->tpg_check_prot_fabric_only(se_tpg); + /* + * If the fabric module supports an ISID based TransportID, + * save this value in binary from the fabric I_T Nexus now. + */ + if (se_tpg->se_tpg_tfo->sess_get_initiator_sid) { + memset(&buf[0], 0, PR_REG_ISID_LEN); + se_tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, + &buf[0], PR_REG_ISID_LEN); + se_sess->sess_bin_isid = get_unaligned_be64(&buf[0]); + } + kref_get(&se_nacl->acl_kref); + + spin_lock_irq(&se_nacl->nacl_sess_lock); + /* + * The se_nacl->nacl_sess pointer will be set to the + * last active I_T Nexus for each struct se_node_acl. + */ + se_nacl->nacl_sess = se_sess; + list_add_tail(&se_sess->sess_acl_list, &se_nacl->acl_sess_list); + spin_unlock_irq(&se_nacl->nacl_sess_lock); + + return ret; +} + /* * Called with spin_lock_irqsave(&struct se_portal_group->session_lock called. */ -void __transport_register_session( - struct se_portal_group *se_tpg, - struct se_node_acl *se_nacl, - struct se_session *se_sess, - void *fabric_sess_ptr) +int __transport_register_session(struct se_portal_group *se_tpg, + struct se_node_acl *se_nacl, + struct se_session *se_sess, + void *fabric_sess_ptr) { - const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo; - unsigned char buf[PR_REG_ISID_LEN]; + int ret = 0; se_sess->se_tpg = se_tpg; se_sess->fabric_sess_ptr = fabric_sess_ptr; /* - * Used by struct se_node_acl's under ConfigFS to locate active se_session-t + * Used by struct se_node_acl's under ConfigFS to locate active session. * * Only set for struct se_session's that will actually be moving I/O. * eg: *NOT* discovery sessions. */ - if (se_nacl) { - /* - * - * Determine if fabric allows for T10-PI feature bits exposed to - * initiators for device backends with !dev->dev_attrib.pi_prot_type. - * - * If so, then always save prot_type on a per se_node_acl node - * basis and re-instate the previous sess_prot_type to avoid - * disabling PI from below any previously initiator side - * registered LUNs. - */ - if (se_nacl->saved_prot_type) - se_sess->sess_prot_type = se_nacl->saved_prot_type; - else if (tfo->tpg_check_prot_fabric_only) - se_sess->sess_prot_type = se_nacl->saved_prot_type = - tfo->tpg_check_prot_fabric_only(se_tpg); - /* - * If the fabric module supports an ISID based TransportID, - * save this value in binary from the fabric I_T Nexus now. - */ - if (se_tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) { - memset(&buf[0], 0, PR_REG_ISID_LEN); - se_tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, - &buf[0], PR_REG_ISID_LEN); - se_sess->sess_bin_isid = get_unaligned_be64(&buf[0]); - } - kref_get(&se_nacl->acl_kref); - - spin_lock_irq(&se_nacl->nacl_sess_lock); - /* - * The se_nacl->nacl_sess pointer will be set to the - * last active I_T Nexus for each struct se_node_acl. - */ - se_nacl->nacl_sess = se_sess; - - list_add_tail(&se_sess->sess_acl_list, - &se_nacl->acl_sess_list); - spin_unlock_irq(&se_nacl->nacl_sess_lock); - } + if (se_nacl) + __transport_register_session_with_nacl(se_nacl, se_sess); list_add_tail(&se_sess->sess_list, &se_tpg->tpg_sess_list); pr_debug("TARGET_CORE[%s]: Registered fabric_sess_ptr: %p\n", se_tpg->se_tpg_tfo->get_fabric_name(), se_sess->fabric_sess_ptr); + + return ret; } EXPORT_SYMBOL(__transport_register_session); -void transport_register_session( - struct se_portal_group *se_tpg, - struct se_node_acl *se_nacl, - struct se_session *se_sess, - void *fabric_sess_ptr) +int transport_register_session(struct se_portal_group *se_tpg, + struct se_node_acl *se_nacl, + struct se_session *se_sess, + void *fabric_sess_ptr) { unsigned long flags; + int ret = 0; spin_lock_irqsave(&se_tpg->session_lock, flags); __transport_register_session(se_tpg, se_nacl, se_sess, fabric_sess_ptr); spin_unlock_irqrestore(&se_tpg->session_lock, flags); + + return ret; } EXPORT_SYMBOL(transport_register_session); diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 0d83f6c..e24fa76 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -112,9 +112,9 @@ int transport_alloc_session_tags(struct se_session *, unsigned int, unsigned int); struct se_session *transport_init_session_tags(unsigned int, unsigned int, enum target_prot_op); -void __transport_register_session(struct se_portal_group *, +int __transport_register_session(struct se_portal_group *, struct se_node_acl *, struct se_session *, void *); -void transport_register_session(struct se_portal_group *, +int transport_register_session(struct se_portal_group *, struct se_node_acl *, struct se_session *, void *); void target_get_session(struct se_session *); void target_put_session(struct se_session *); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html