From patchwork Sun Jun 7 20:35:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3949C433E0 for ; Sun, 7 Jun 2020 20:36:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89EE12074B for ; Sun, 7 Jun 2020 20:36:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="rC+itO+g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728193AbgFGUg3 (ORCPT ); Sun, 7 Jun 2020 16:36:29 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:42520 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727912AbgFGUgZ (ORCPT ); Sun, 7 Jun 2020 16:36:25 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KX6rl018275; Sun, 7 Jun 2020 20:36:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=jgyr2JkDKp3PUXRDBjruBVSLsx2itMrxKqHT7pKRPis=; b=rC+itO+gAb1QW22+nYvN7Yus9DDz8K4X9ZpQI32mK4NP9kDHRFemIb+9DaI2exA9HeHq 6mp84lH/9oHZ9DtIAhPbj2jVO2FjlfLdmLGhloKOfW8XXblQA5MnZdN/ua+jteS0y2ak txs7Hs2D0vKpKQJOZLpGvtgoreyIRbKWywG8rtrKR/cf2Vl37aGCEv5g3yhMyCDej7h0 2xFbasrQ+6AVkAjeKFuUP/fCfezqULFZAHjiu9VbFwMHLDxWXCP8mkwKcSkEd4hCRIN8 /FpyFCXItspVstUO1h2aYty5u99x9nlh0Ze6UymqnrpDghAiV6oNJTcevEc+JA/at4jU KA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 31g33kv0qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:12 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KS5v2076497; Sun, 7 Jun 2020 20:36:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 31gmqk8a5r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:12 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 057KaAsR003534; Sun, 7 Jun 2020 20:36:10 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:10 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Paolo Bonzini , Stefan Hajnoczi , Juergen Gross Subject: [PATCH 02/17] target: separate acl name from port ids Date: Sun, 7 Jun 2020 15:35:49 -0500 Message-Id: <1591562164-9766-3-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 suspectscore=2 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 adultscore=0 spamscore=0 cotscore=-2147483648 malwarescore=0 phishscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The PGR code assumes the ACL name is going to be based on the SPC4 transportID type of values. The problem is that for iSCSI we have an extra session id as part of the SCSI port id and some fabric modules support or would like to support non transportID values for the ACL name. For example, iSCSI and SRP would like to use the source address for the ACL name, but that is not a valud transportID value that you can get in a PGR request. This patch adds a new transport_id struct which maps to the SPC4 transportID. In the future it will be used for PGR commands instead of the ACL name. In this patchset it is used to export the initiator info in the session's sysfs dir, so tools can display the info and daemons that execute commands like PGRs in userspace can build a session id to I_T nexus mapping. In this patch only srp is passing in different values for the transport id and acl name. The next patches will convert loop, scsi vhost and xen scsiback that are more complex due to their initiator name emulation. Cc: Michael S. Tsirkin Cc: Jason Wang Cc: Paolo Bonzini Cc: Stefan Hajnoczi Cc: Juergen Gross Signed-off-by: Mike Christie Reviewed-by: Hannes Reinecke Reviewed-by: Lee Duncan --- drivers/infiniband/ulp/srpt/ib_srpt.c | 10 +++++--- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 4 +-- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 +- drivers/target/loopback/tcm_loop.c | 3 ++- drivers/target/sbp/sbp_target.c | 2 +- drivers/target/target_core_fabric_lib.c | 41 +++++++++++++++++++++++++++++++ drivers/target/target_core_transport.c | 42 ++++++++++++++++++++++++-------- drivers/target/tcm_fc/tfc_sess.c | 3 ++- drivers/usb/gadget/function/f_tcm.c | 3 ++- drivers/vhost/scsi.c | 1 + drivers/xen/xen-scsiback.c | 3 ++- include/target/target_core_base.h | 12 +++++++++ include/target/target_core_fabric.h | 5 +++- 13 files changed, 108 insertions(+), 23 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 9855274..d107f63 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -2320,7 +2320,8 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, break; ch->sess = target_setup_session(&stpg->tpg, tag_num, tag_size, TARGET_PROT_NORMAL, - ch->sess_name, ch, NULL); + i_port_id + 2, ch->sess_name, + ch, NULL); } mutex_unlock(&sport->port_guid_id.mutex); @@ -2329,14 +2330,15 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, if (!IS_ERR_OR_NULL(ch->sess)) break; ch->sess = target_setup_session(&stpg->tpg, tag_num, - tag_size, TARGET_PROT_NORMAL, i_port_id, - ch, NULL); + tag_size, TARGET_PROT_NORMAL, + i_port_id + 2, i_port_id, ch, NULL); if (!IS_ERR_OR_NULL(ch->sess)) break; /* Retry without leading "0x" */ ch->sess = target_setup_session(&stpg->tpg, tag_num, tag_size, TARGET_PROT_NORMAL, - i_port_id + 2, ch, NULL); + i_port_id + 2, i_port_id + 2, + ch, NULL); } mutex_unlock(&sport->port_gid_id.mutex); diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index d9e94e8..31459f3 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -2223,8 +2223,8 @@ static int ibmvscsis_make_nexus(struct ibmvscsis_tport *tport) } nexus->se_sess = target_setup_session(&tport->se_tpg, 0, 0, - TARGET_PROT_NORMAL, name, nexus, - NULL); + TARGET_PROT_NORMAL, name, name, + nexus, NULL); if (IS_ERR(nexus->se_sess)) { rc = PTR_ERR(nexus->se_sess); goto transport_init_fail; diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 1f0a185..7b21809 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1483,7 +1483,7 @@ static int tcm_qla2xxx_check_initiator_node_acl( */ se_sess = target_setup_session(&tpg->se_tpg, num_tags, sizeof(struct qla_tgt_cmd), - TARGET_PROT_ALL, port_name, + TARGET_PROT_ALL, port_name, port_name, qlat_sess, tcm_qla2xxx_session_cb); if (IS_ERR(se_sess)) return PTR_ERR(se_sess); diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 3305b47..74aded7 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -742,7 +742,8 @@ static int tcm_loop_make_nexus( tl_nexus->se_sess = target_setup_session(&tl_tpg->tl_se_tpg, 0, 0, TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS, - name, tl_nexus, tcm_loop_alloc_sess_cb); + name, name, tl_nexus, + tcm_loop_alloc_sess_cb); if (IS_ERR(tl_nexus->se_sess)) { ret = PTR_ERR(tl_nexus->se_sess); kfree(tl_nexus); diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index e4a9b9f..2cac4d9 100644 --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c @@ -199,7 +199,7 @@ static struct sbp_session *sbp_session_create( sess->se_sess = target_setup_session(&tpg->se_tpg, 128, sizeof(struct sbp_target_request), TARGET_PROT_NORMAL, guid_str, - sess, NULL); + guid_str, sess, NULL); if (IS_ERR(sess->se_sess)) { pr_err("failed to init se_session\n"); ret = PTR_ERR(sess->se_sess); diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c index 1e031d8..e89b3d8 100644 --- a/drivers/target/target_core_fabric_lib.c +++ b/drivers/target/target_core_fabric_lib.c @@ -422,3 +422,44 @@ const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg, *out_tid_len = 24; return buf + offset; } + +struct t10_transport_id *target_create_transport_id(u8 proto, const char *name, + const char *session_id) +{ + struct t10_transport_id *tpt_id; + + tpt_id = kzalloc(sizeof(*tpt_id), GFP_KERNEL); + if (!tpt_id) + return NULL; + tpt_id->proto = proto; + + tpt_id->name = kstrdup(name, GFP_KERNEL); + if (!tpt_id->name) + goto free_tpt_id; + + if (session_id) { + tpt_id->session_id = kstrdup(session_id, GFP_KERNEL); + if (!tpt_id->session_id) + goto free_name; + } + + return tpt_id; + +free_name: + kfree(tpt_id->name); +free_tpt_id: + kfree(tpt_id); + return NULL; +} +EXPORT_SYMBOL(target_create_transport_id); + +void target_free_transport_id(struct t10_transport_id *tpt_id) +{ + if (!tpt_id) + return; + + kfree(tpt_id->name); + kfree(tpt_id->session_id); + kfree(tpt_id); +} +EXPORT_SYMBOL(target_free_transport_id); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 264a822..c1b0d15 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -413,15 +413,27 @@ void transport_register_session( } EXPORT_SYMBOL(transport_register_session); +/** + * target_setup_session - alloc and add a session to lio core + * @tpg: parent tpg + * @tag_num: if non-zero max num in-flight commands. + * @tag_size: if tag_num is non-zero, fabric driver's per cmd data in bytes. + * @prot_op: bitmask that defines which T10-PI modes are supported. + * @tpt_id_name: SCSI TransportID name/address/identifier + * @acl_name: name used for se_node_acl + * @private: storage for fabric driver accessible via fabric_sess_ptr + * @callback: opt function called before session has been added to lio core. + */ struct se_session * target_setup_session(struct se_portal_group *tpg, unsigned int tag_num, unsigned int tag_size, - enum target_prot_op prot_op, - const char *initiatorname, void *private, + enum target_prot_op prot_op, const char *tpt_id_name, + const char *acl_name, void *private, int (*callback)(struct se_portal_group *, struct se_session *, void *)) { struct se_session *sess; + int rc; /* * If the fabric driver is using percpu-ida based pre allocation @@ -435,26 +447,35 @@ struct se_session * if (IS_ERR(sess)) return sess; + sess->tpt_id = target_create_transport_id(tpg->proto_id, tpt_id_name, + NULL); + if (!sess->tpt_id) { + rc = -ENOMEM; + goto free_sess; + } + sess->se_node_acl = core_tpg_check_initiator_node_acl(tpg, - (unsigned char *)initiatorname); + (unsigned char *)acl_name); if (!sess->se_node_acl) { - transport_free_session(sess); - return ERR_PTR(-EACCES); + rc = -EACCES; + goto free_sess; } /* * Go ahead and perform any remaining fabric setup that is * required before transport_register_session(). */ if (callback != NULL) { - int rc = callback(tpg, sess, private); - if (rc) { - transport_free_session(sess); - return ERR_PTR(rc); - } + rc = callback(tpg, sess, private); + if (rc) + goto free_sess; } transport_register_session(tpg, sess->se_node_acl, sess, private); return sess; + +free_sess: + transport_free_session(sess); + return ERR_PTR(rc); } EXPORT_SYMBOL(target_setup_session); @@ -579,6 +600,7 @@ void transport_free_session(struct se_session *se_sess) sbitmap_queue_free(&se_sess->sess_tag_pool); kvfree(se_sess->sess_cmd_map); } + target_free_transport_id(se_sess->tpt_id); percpu_ref_exit(&se_sess->cmd_count); kmem_cache_free(se_sess_cache, se_sess); } diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index 4fd6a1d..1d1c460 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c @@ -230,7 +230,8 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, sess->se_sess = target_setup_session(se_tpg, TCM_FC_DEFAULT_TAGS, sizeof(struct ft_cmd), TARGET_PROT_NORMAL, &initiatorname[0], - sess, ft_sess_alloc_cb); + &initiatorname[0], sess, + ft_sess_alloc_cb); if (IS_ERR(sess->se_sess)) { int rc = PTR_ERR(sess->se_sess); kfree(sess); diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 3650493..cab3036 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1583,7 +1583,8 @@ static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name) USB_G_DEFAULT_SESSION_TAGS, sizeof(struct usbg_cmd), TARGET_PROT_NORMAL, name, - tv_nexus, usbg_alloc_sess_cb); + name, tv_nexus, + usbg_alloc_sess_cb); if (IS_ERR(tv_nexus->tvn_se_sess)) { #define MAKE_NEXUS_MSG "core_tpg_check_initiator_node_acl() failed for %s\n" pr_debug(MAKE_NEXUS_MSG, name); diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index c399522..15aabc2 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1964,6 +1964,7 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg, VHOST_SCSI_DEFAULT_TAGS, sizeof(struct vhost_scsi_cmd), TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS, + (unsigned char *)name, (unsigned char *)name, tv_nexus, vhost_scsi_nexus_cb); if (IS_ERR(tv_nexus->tvn_se_sess)) { diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 75c0a2e..93cb386 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -1531,7 +1531,8 @@ static int scsiback_make_nexus(struct scsiback_tpg *tpg, VSCSI_DEFAULT_SESSION_TAGS, sizeof(struct vscsibk_pend), TARGET_PROT_NORMAL, name, - tv_nexus, scsiback_alloc_sess_cb); + name, tv_nexus, + scsiback_alloc_sess_cb); if (IS_ERR(tv_nexus->tvn_se_sess)) { kfree(tv_nexus); ret = -ENOMEM; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 6d4a694..2e79cce 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -331,6 +331,17 @@ struct t10_wwn { struct list_head t10_vpd_list; }; +struct t10_transport_id { + /* The format=0 transport specific port id/name value. */ + char *name; + /* + * If proto is iSCSI and it's using format=1, then this is set to the + * initiator session id string defined in spc4r37 table 508. + */ + char *session_id; + u8 proto; +}; + struct t10_pr_registration { /* Used for fabrics that contain WWN+ISID */ #define PR_REG_ISID_LEN 16 @@ -610,6 +621,7 @@ static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item) struct se_session { unsigned sess_tearing_down:1; u64 sess_bin_isid; + struct t10_transport_id *tpt_id; enum target_prot_op sup_prot_ops; enum target_prot_type sess_prot_type; struct se_node_acl *se_node_acl; diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 063f133..af1dd81 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -125,9 +125,12 @@ struct target_core_fabric_ops { int target_depend_item(struct config_item *item); void target_undepend_item(struct config_item *item); +struct t10_transport_id *target_create_transport_id(u8, const char *, + const char *); +void target_free_transport_id(struct t10_transport_id *); struct se_session *target_setup_session(struct se_portal_group *, unsigned int, unsigned int, enum target_prot_op prot_op, - const char *, void *, + const char *, const char *, void *, int (*callback)(struct se_portal_group *, struct se_session *, void *)); void target_remove_session(struct se_session *); From patchwork Sun Jun 7 20:35:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40847C433DF for ; Sun, 7 Jun 2020 20:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1794F2075A for ; Sun, 7 Jun 2020 20:36:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="iSxF5IXx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbgFGUgV (ORCPT ); Sun, 7 Jun 2020 16:36:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51678 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727912AbgFGUgU (ORCPT ); Sun, 7 Jun 2020 16:36:20 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KWjDm125835; Sun, 7 Jun 2020 20:36:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=PRA6+CzMf50HPXBaBCUA/RSf5gWWu72cmsN6V8Cp/cI=; b=iSxF5IXxdSu0zEMxCh7vCsdpq3gXyblbxLiOYdGe59SoHRPYU59pwueSk/9dzDKxDvaI zwAiihY3OPxTevd/Le2hpZ63eeBvJoeVsq2A2PyhKncJ4nAFjMcRRy09Hio2c2N/LENb qUH0jbptiZpkHCqkapCCQNIz0A1gCCAtZ29qna4PsobKujVVrHFHdWpZ7uiPLMUw1D5l NFKvJPAqAWsob98mrMLsqxIiVfkGo90HisBpiDWgn509tNEtXSaNTBvU6/Lc0A5QzKZA OL6YfIyva2oP0HSO1LFm7e92v8Iul8b1mcjZGeBH4KPUW8z3bJrj/icUcdX23+cb0+K2 8A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31g3smkxft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:15 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KSbjg020489; Sun, 7 Jun 2020 20:36:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 31gn205nbd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:14 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 057KaDkw022733; Sun, 7 Jun 2020 20:36:13 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:13 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 08/17] target: use tpt_id in target_stat_iport_port_ident_show Date: Sun, 7 Jun 2020 15:35:55 -0500 Message-Id: <1591562164-9766-9-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use the tpt_id session id instead of sess_get_initiator_sid. Note that for userspace compat this patch continues the behavior: 1. Still add the "+i+" even if there is no session_id. 2. Use the acl initiatorname instead of the transportID port/addr/name. Signed-off-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/target/target_core_stat.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 237309d..3eb1b9b 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c @@ -1308,9 +1308,7 @@ static ssize_t target_stat_iport_port_ident_show(struct config_item *item, struct se_lun_acl *lacl = iport_to_lacl(item); struct se_node_acl *nacl = lacl->se_lun_nacl; struct se_session *se_sess; - struct se_portal_group *tpg; ssize_t ret; - unsigned char buf[64]; spin_lock_irq(&nacl->nacl_sess_lock); se_sess = nacl->nacl_sess; @@ -1319,13 +1317,9 @@ static ssize_t target_stat_iport_port_ident_show(struct config_item *item, return -ENODEV; } - tpg = nacl->se_tpg; - /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */ - memset(buf, 0, 64); - if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) - tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64); - - ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf); + ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, + se_sess->tpt_id->session_id ? se_sess->tpt_id->session_id : + ""); spin_unlock_irq(&nacl->nacl_sess_lock); return ret; } From patchwork Sun Jun 7 20:35:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63FD5C433E0 for ; Sun, 7 Jun 2020 20:38:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CB7E2074B for ; Sun, 7 Jun 2020 20:38:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="BwehrBtk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbgFGUiY (ORCPT ); Sun, 7 Jun 2020 16:38:24 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:52502 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbgFGUiX (ORCPT ); Sun, 7 Jun 2020 16:38:23 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KcImt139768; Sun, 7 Jun 2020 20:38:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=XfWhIYFwEimVuj47/9jv8D1/OxnCuX9y0dJxP64x0b4=; b=BwehrBtkJdrP2Sq0aFlP8UWD/0oK+amM23PrVlUtD6lfaRrZgZGkEDgq37jLsq1eaQ1U +VJd1n+cMKV0EmMP13/h6xDCPVukaWRet4B7ghthT/LPbasYxYm4Bj1toHqAC4PsjoRU OFPhiuMJrlNiMPP8ISNpY0l+QGmaEqF+9d8XCmPC3BmA4r9XWGCu1SNCK+Q87PjmoDjx 6dcWIGwcfqIVIV4/gfSAbTGvtF/q69iGUo0rr99iSmLICmJMz+kTOQk3Y/D4/OsJtvSd zjQ2CCOCp5+qd9W5mHQm0n+TyzXviJIJjoVnIrfFKICqr2HtrTT0HHdXVTvrln1Oex91 iA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31g3smkxhb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:38:18 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KSHFN020325; Sun, 7 Jun 2020 20:36:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 31gn205ncn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:15 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 057KaEBI003652; Sun, 7 Jun 2020 20:36:14 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:14 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 09/17] target: drop sess_get_initiator_sid from PR code Date: Sun, 7 Jun 2020 15:35:56 -0500 Message-Id: <1591562164-9766-10-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070163 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use the transport id session id in the PR related code. Signed-off-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/target/target_core_pr.c | 23 ++++------------------- drivers/target/target_core_transport.c | 11 ++++------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index cd2d32f..fbe3638 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -1204,17 +1204,7 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg( struct se_node_acl *nacl, struct se_session *sess) { - struct se_portal_group *tpg = nacl->se_tpg; - unsigned char buf[PR_REG_ISID_LEN], *isid_ptr = NULL; - - if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) { - memset(&buf[0], 0, PR_REG_ISID_LEN); - tpg->se_tpg_tfo->sess_get_initiator_sid(sess, &buf[0], - PR_REG_ISID_LEN); - isid_ptr = &buf[0]; - } - - return __core_scsi3_locate_pr_reg(dev, nacl, isid_ptr); + return __core_scsi3_locate_pr_reg(dev, nacl, sess->tpt_id->session_id); } static void core_scsi3_put_pr_reg(struct t10_pr_registration *pr_reg) @@ -1592,7 +1582,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) * SCSI Intiatior TransportID w/ ISIDs is enforced * for fabric modules (iSCSI) requiring them. */ - if (tpg->se_tpg_tfo->sess_get_initiator_sid && + if (se_sess->tpt_id->session_id && dev->dev_attrib.enforce_pr_isids && !iport_ptr) { pr_warn("SPC-PR: enforce_pr_isids is set but a isid has not been sent in the SPEC_I_PT data for %s.", @@ -2057,7 +2047,7 @@ static sense_reason_t core_scsi3_update_and_write_aptpl(struct se_device *dev, b struct se_portal_group *se_tpg; struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp; struct t10_reservation *pr_tmpl = &dev->t10_pr; - unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; + unsigned char *isid_ptr = NULL; sense_reason_t ret = TCM_NO_SENSE; int pr_holder = 0, type; @@ -2067,12 +2057,7 @@ static sense_reason_t core_scsi3_update_and_write_aptpl(struct se_device *dev, b } se_tpg = se_sess->se_tpg; - if (se_tpg->se_tpg_tfo->sess_get_initiator_sid) { - memset(&isid_buf[0], 0, PR_REG_ISID_LEN); - se_tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, &isid_buf[0], - PR_REG_ISID_LEN); - isid_ptr = &isid_buf[0]; - } + isid_ptr = se_sess->tpt_id->session_id; /* * Follow logic from spc4r17 Section 5.7.7, Register Behaviors Table 47 */ diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c1b0d15..5d6d736 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -343,7 +343,7 @@ void __transport_register_session( void *fabric_sess_ptr) { const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo; - unsigned char buf[PR_REG_ISID_LEN]; + unsigned char *sid; unsigned long flags; se_sess->se_tpg = se_tpg; @@ -374,12 +374,9 @@ void __transport_register_session( * 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]); - } + sid = se_sess->tpt_id->session_id; + if (sid) + se_sess->sess_bin_isid = get_unaligned_be64(sid); spin_lock_irqsave(&se_nacl->nacl_sess_lock, flags); /* From patchwork Sun Jun 7 20:35:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22F08C433E0 for ; Sun, 7 Jun 2020 20:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F14872076C for ; Sun, 7 Jun 2020 20:36:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="d/P3aezt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727886AbgFGUgY (ORCPT ); Sun, 7 Jun 2020 16:36:24 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51716 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbgFGUgX (ORCPT ); Sun, 7 Jun 2020 16:36:23 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KYLHW137503; Sun, 7 Jun 2020 20:36:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=G+Png8uTl+OmiwQUfZgc/hn2TpO+61jKbR8PL8aMweU=; b=d/P3aeztRtU+nuHWytG4b71JrUEzP30wtbm8zEBoFLGELNZbOid371WMvHwmBd4qqy9W m244vtiHAzIrLxXG55nfYBimsq/3WKXOaglZnC9EeTD957WeultSyYbm8B74+y55FTYG tPcojO47lQzSETuAihSzi/JmBWzh3xs9L92Jt06+eDfHzr5TkZodKTJVQirHeoQiu8Ni Q0dU3EtxfTiI0Zem9t5fiQz5v8BaRj2AbP3LnGXoLJUhjg+m8kQcXvxJLzorAtWUKJJW E0DNR2lDAcsk0pw4DczW83cUmHi2/pJ8+X0qf/l+WLqQyOi+N987GNurA5EJ8QV3N9Nr Fw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31g3smkxfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:16 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KSFmk020050; Sun, 7 Jun 2020 20:36:15 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 31gn205ncw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:15 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 057KaEs5024005; Sun, 7 Jun 2020 20:36:14 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:14 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 10/17] target: drop sess_get_initiator_sid Date: Sun, 7 Jun 2020 15:35:57 -0500 Message-Id: <1591562164-9766-11-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=2 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=2 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org sess_get_initiator_sid is no longer used. Drop it. Signed-off-by: Mike Christie Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/infiniband/ulp/srpt/ib_srpt.c | 1 - drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 -- drivers/target/iscsi/iscsi_target_configfs.c | 13 ------------- drivers/target/tcm_fc/tfc_conf.c | 1 - drivers/usb/gadget/function/f_tcm.c | 1 - drivers/vhost/scsi.c | 1 - drivers/xen/xen-scsiback.c | 1 - include/target/target_core_fabric.h | 6 ------ 8 files changed, 26 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index d107f63..3cda73c 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -3844,7 +3844,6 @@ static ssize_t srpt_wwn_version_show(struct config_item *item, char *buf) .check_stop_free = srpt_check_stop_free, .close_session = srpt_close_session, .sess_get_index = srpt_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = srpt_write_pending, .set_default_node_attributes = srpt_set_default_node_attrs, .get_cmd_state = srpt_get_tcm_cmd_state, diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 7b21809..fff695a 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1852,7 +1852,6 @@ static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item, .release_cmd = tcm_qla2xxx_release_cmd, .close_session = tcm_qla2xxx_close_session, .sess_get_index = tcm_qla2xxx_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = tcm_qla2xxx_write_pending, .set_default_node_attributes = tcm_qla2xxx_set_default_node_attrs, .get_cmd_state = tcm_qla2xxx_get_cmd_state, @@ -1892,7 +1891,6 @@ static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item, .release_cmd = tcm_qla2xxx_release_cmd, .close_session = tcm_qla2xxx_close_session, .sess_get_index = tcm_qla2xxx_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = tcm_qla2xxx_write_pending, .set_default_node_attributes = tcm_qla2xxx_set_default_node_attrs, .get_cmd_state = tcm_qla2xxx_get_cmd_state, diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 0fa1d57..4513740 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1349,18 +1349,6 @@ static u32 lio_sess_get_index(struct se_session *se_sess) return sess->session_index; } -static u32 lio_sess_get_initiator_sid( - struct se_session *se_sess, - unsigned char *buf, - u32 size) -{ - struct iscsi_session *sess = se_sess->fabric_sess_ptr; - /* - * iSCSI Initiator Session Identifier from RFC-3720. - */ - return snprintf(buf, size, "%6phN", sess->isid); -} - static int lio_queue_data_in(struct se_cmd *se_cmd) { struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); @@ -1545,7 +1533,6 @@ static void lio_release_cmd(struct se_cmd *se_cmd) .release_cmd = lio_release_cmd, .close_session = lio_tpg_close_session, .sess_get_index = lio_sess_get_index, - .sess_get_initiator_sid = lio_sess_get_initiator_sid, .write_pending = lio_write_pending, .set_default_node_attributes = lio_set_default_node_attributes, .get_cmd_state = iscsi_get_cmd_state, diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 1a38c98..870b7bb 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c @@ -427,7 +427,6 @@ static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg) .release_cmd = ft_release_cmd, .close_session = ft_sess_close, .sess_get_index = ft_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = ft_write_pending, .set_default_node_attributes = ft_set_default_node_attr, .get_cmd_state = ft_get_cmd_state, diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index cab3036..e81bdbd 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1716,7 +1716,6 @@ static int usbg_check_stop_free(struct se_cmd *se_cmd) .tpg_get_inst_index = usbg_tpg_get_inst_index, .release_cmd = usbg_release_cmd, .sess_get_index = usbg_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = usbg_send_write_request, .set_default_node_attributes = usbg_set_default_node_attrs, .get_cmd_state = usbg_get_cmd_state, diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 37f66f8..d7c9bfc 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -2245,7 +2245,6 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn) .release_cmd = vhost_scsi_release_cmd, .check_stop_free = vhost_scsi_check_stop_free, .sess_get_index = vhost_scsi_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = vhost_scsi_write_pending, .set_default_node_attributes = vhost_scsi_set_default_node_attrs, .get_cmd_state = vhost_scsi_get_cmd_state, diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index f70b6da..883b15c 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -1769,7 +1769,6 @@ static int scsiback_check_false(struct se_portal_group *se_tpg) .check_stop_free = scsiback_check_stop_free, .release_cmd = scsiback_release_cmd, .sess_get_index = scsiback_sess_get_index, - .sess_get_initiator_sid = NULL, .write_pending = scsiback_write_pending, .set_default_node_attributes = scsiback_set_default_node_attrs, .get_cmd_state = scsiback_get_cmd_state, diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 0113e1c..ced377f 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -67,12 +67,6 @@ struct target_core_fabric_ops { void (*release_cmd)(struct se_cmd *); void (*close_session)(struct se_session *); u32 (*sess_get_index)(struct se_session *); - /* - * Used only for SCSI fabrics that contain multi-value TransportIDs - * (like iSCSI). All other SCSI fabrics should set this to NULL. - */ - u32 (*sess_get_initiator_sid)(struct se_session *, - unsigned char *, u32); int (*write_pending)(struct se_cmd *); void (*set_default_node_attributes)(struct se_node_acl *); int (*get_cmd_state)(struct se_cmd *); From patchwork Sun Jun 7 20:36:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE53CC433E1 for ; Sun, 7 Jun 2020 20:36:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BA032075A for ; Sun, 7 Jun 2020 20:36:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="X5sJ6n22" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726993AbgFGUgc (ORCPT ); Sun, 7 Jun 2020 16:36:32 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59716 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbgFGUgY (ORCPT ); Sun, 7 Jun 2020 16:36:24 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KWCgg076554; Sun, 7 Jun 2020 20:36:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=VevP3JX1qVCXb9iERCJIepD9ZJphsewjI5TT3u8riBg=; b=X5sJ6n22rebRVEH+Mj31vmCSHOQmrggfRBrvRDxerZQxR5VQebuLK53y75R3hHG0coA1 +YNE2FP40qp8Fcm0D2Y+Pm4LQshWtnku7svoS9Sxi7iniWl8TStqChcTyo4pvyFI9J7v gYbvYWpbs+DQSktdkUJwyLMwz03Ik5mRrf2tyxsly8qMq+MeVK/we2zzI0E3ftnXCucy ZJJeliamiU/1vrH8F5qzbf8Hj9Ri1RZzUCESfYC1MqJstr3Z65WaT+CONUfksCBoUvgS 6R0rnOImjzuWxQIHR6o2NRM274+7jrT+4fmF57Uj8GnOb4yc8weAj1nyknn5N/FgQchg pA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 31g2jqv28u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:17 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KRlVw015782; Sun, 7 Jun 2020 20:36:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 31gn2u865y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:17 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 057KaG7O024028; Sun, 7 Jun 2020 20:36:16 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:16 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 13/17] iscsi target: replace module sids with lio's sid Date: Sun, 7 Jun 2020 15:36:00 -0500 Message-Id: <1591562164-9766-14-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 cotscore=-2147483648 priorityscore=1501 spamscore=0 suspectscore=2 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This is the first phase in hooking iscsi into the sysfs API. This patch has it use lio core's sid instead of its internal ones. We have 2 sids in the iscsi target layer: - module sid: int id that is unique across all iscsi targets. Used for sess_get_index(). - iscsi target port group sid: int id that is unique in the tpg. Uses for logging. The lio one works exactly like the iscsi target module one, and the iscsi tpg one is not very useful because when you have multiple tpgs you can't tell which tpg the session is under. In the latter case the lio core one is more useful, because it matches what we see in userspace and logs and we can distinguish what fabric/target/tpg the session is under. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 6 ++---- drivers/target/iscsi/iscsi_target_configfs.c | 6 ++---- drivers/target/iscsi/iscsi_target_erl0.c | 11 ++++++----- drivers/target/iscsi/iscsi_target_erl2.c | 8 ++++---- drivers/target/iscsi/iscsi_target_login.c | 20 ++------------------ drivers/target/iscsi/iscsi_target_stat.c | 3 +-- drivers/target/iscsi/iscsi_target_tmr.c | 2 +- drivers/target/iscsi/iscsi_target_tpg.c | 16 +++++++--------- drivers/target/iscsi/iscsi_target_util.c | 2 +- include/target/iscsi/iscsi_target_core.h | 6 ------ 10 files changed, 26 insertions(+), 54 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 59379d6..d9853d5 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -49,7 +49,6 @@ static DEFINE_MUTEX(np_lock); static struct idr tiqn_idr; -DEFINE_IDA(sess_ida); struct mutex auth_id_lock; struct iscsit_global *iscsit_global; @@ -2328,7 +2327,7 @@ int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn) struct iscsi_session *sess = conn->sess; pr_debug("Received logout request CLOSESESSION on CID: %hu" - " for SID: %u.\n", conn->cid, conn->sess->sid); + " for SID: %u.\n", conn->cid, conn->sess->se_sess->sid); atomic_set(&sess->session_logout, 1); atomic_set(&conn->conn_logout_remove, 1); @@ -4107,7 +4106,7 @@ int iscsit_close_connection( struct iscsi_session *sess = conn->sess; pr_debug("Closing iSCSI connection CID %hu on SID:" - " %u\n", conn->cid, sess->sid); + " %u\n", conn->cid, sess->se_sess->sid); /* * Always up conn_logout_comp for the traditional TCP and HW_OFFLOAD * case just in case the RX Thread in iscsi_target_rx_opcode() is @@ -4403,7 +4402,6 @@ int iscsit_close_session(struct iscsi_session *sess) pr_debug("Decremented number of active iSCSI Sessions on" " iSCSI TPG: %hu to %u\n", tpg->tpgt, tpg->nsessions); - ida_free(&sess_ida, sess->session_index); kfree(sess->sess_ops); sess->sess_ops = NULL; spin_unlock_bh(&se_tpg->session_lock); diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 4513740..66a3b8d 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -520,7 +520,7 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) rb += sprintf(page+rb, "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ", - sess->sid, sess->isid, sess->tsih); + se_sess->sid, sess->isid, sess->tsih); rb += sprintf(page+rb, "SessionType: %s\n", (sess->sess_ops->SessionType) ? "Discovery" : "Normal"); @@ -1344,9 +1344,7 @@ static int iscsi_get_cmd_state(struct se_cmd *se_cmd) static u32 lio_sess_get_index(struct se_session *se_sess) { - struct iscsi_session *sess = se_sess->fabric_sess_ptr; - - return sess->session_index; + return se_sess->sid; } static int lio_queue_data_in(struct se_cmd *se_cmd) diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index b4abd7b..e6acd54 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -761,7 +761,7 @@ void iscsit_handle_time2retain_timeout(struct timer_list *t) sess->time2retain_timer_flags |= ISCSI_TF_EXPIRED; pr_err("Time2Retain timer expired for SID: %u, cleaning up" - " iSCSI session.\n", sess->sid); + " iSCSI session.\n", sess->se_sess->sid); iscsit_fill_cxn_timeout_err_stats(sess); spin_unlock_bh(&se_tpg->session_lock); @@ -786,7 +786,8 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess) return; pr_debug("Starting Time2Retain timer for %u seconds on" - " SID: %u\n", sess->sess_ops->DefaultTime2Retain, sess->sid); + " SID: %u\n", sess->sess_ops->DefaultTime2Retain, + sess->se_sess->sid); sess->time2retain_timer_flags &= ~ISCSI_TF_STOP; sess->time2retain_timer_flags |= ISCSI_TF_RUNNING; @@ -815,7 +816,7 @@ int iscsit_stop_time2retain_timer(struct iscsi_session *sess) spin_lock(&se_tpg->session_lock); sess->time2retain_timer_flags &= ~ISCSI_TF_RUNNING; pr_debug("Stopped Time2Retain Timer for SID: %u\n", - sess->sid); + sess->se_sess->sid); return 0; } @@ -882,8 +883,8 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) void iscsit_fall_back_to_erl0(struct iscsi_session *sess) { - pr_debug("Falling back to ErrorRecoveryLevel=0 for SID:" - " %u\n", sess->sid); + pr_debug("Falling back to ErrorRecoveryLevel=0 for SID: %u\n", + sess->se_sess->sid); atomic_set(&sess->session_fall_back_to_erl0, 1); } diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index b1b7db9d..bdc9558 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c @@ -93,7 +93,7 @@ static int iscsit_attach_inactive_connection_recovery_entry( sess->conn_recovery_count++; pr_debug("Incremented connection recovery count to %u for" - " SID: %u\n", sess->conn_recovery_count, sess->sid); + " SID: %u\n", sess->conn_recovery_count, sess->se_sess->sid); spin_unlock(&sess->cr_i_lock); return 0; @@ -176,7 +176,7 @@ int iscsit_remove_active_connection_recovery_entry( sess->conn_recovery_count--; pr_debug("Decremented connection recovery count to %u for" - " SID: %u\n", sess->conn_recovery_count, sess->sid); + " SID: %u\n", sess->conn_recovery_count, sess->se_sess->sid); spin_unlock(&sess->cr_a_lock); kfree(cr); @@ -251,11 +251,11 @@ void iscsit_discard_cr_cmds_by_expstatsn( if (!cr->cmd_count) { pr_debug("No commands to be reassigned for failed" " connection CID: %hu on SID: %u\n", - cr->cid, sess->sid); + cr->cid, sess->se_sess->sid); iscsit_remove_inactive_connection_recovery_entry(cr, sess); iscsit_attach_active_connection_recovery_entry(sess, cr); pr_debug("iSCSI connection recovery successful for CID:" - " %hu on SID: %u\n", cr->cid, sess->sid); + " %hu on SID: %u\n", cr->cid, sess->se_sess->sid); iscsit_remove_active_connection_recovery_entry(cr, sess); } else { iscsit_remove_inactive_connection_recovery_entry(cr, sess); diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 85748e3..417b797 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -186,7 +186,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) pr_debug("%s iSCSI Session SID %u is still active for %s," " performing session reinstatement.\n", (sessiontype) ? - "Discovery" : "Normal", sess->sid, + "Discovery" : "Normal", sess->se_sess->sid, sess->sess_ops->InitiatorName); spin_lock_bh(&sess->conn_lock); @@ -258,7 +258,6 @@ static int iscsi_login_zero_tsih_s1( { struct iscsi_session *sess = NULL; struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; - int ret; sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL); if (!sess) { @@ -292,15 +291,6 @@ static int iscsi_login_zero_tsih_s1( timer_setup(&sess->time2retain_timer, iscsit_handle_time2retain_timeout, 0); - ret = ida_alloc(&sess_ida, GFP_KERNEL); - if (ret < 0) { - pr_err("Session ID allocation failed %d\n", ret); - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, - ISCSI_LOGIN_STATUS_NO_RESOURCES); - goto free_sess; - } - - sess->session_index = ret; sess->creation_time = get_jiffies_64(); /* * The FFP CmdSN window values will be allocated from the TPG's @@ -314,7 +304,7 @@ static int iscsi_login_zero_tsih_s1( ISCSI_LOGIN_STATUS_NO_RESOURCES); pr_err("Unable to allocate memory for" " struct iscsi_sess_ops.\n"); - goto free_id; + goto free_sess; } sess->se_sess = transport_alloc_session(TARGET_PROT_NORMAL); @@ -328,8 +318,6 @@ static int iscsi_login_zero_tsih_s1( free_ops: kfree(sess->sess_ops); -free_id: - ida_free(&sess_ida, sess->session_index); free_sess: kfree(sess); conn->sess = NULL; @@ -768,9 +756,6 @@ void iscsi_post_login_handler( sess->sess_ops->InitiatorName); spin_unlock_bh(&sess->conn_lock); - sess->sid = tpg->sid++; - if (!sess->sid) - sess->sid = tpg->sid++; pr_debug("Established iSCSI session from node: %s\n", sess->sess_ops->InitiatorName); @@ -1161,7 +1146,6 @@ void iscsi_target_login_sess_out(struct iscsi_conn *conn, goto old_sess_out; transport_free_session(conn->sess->se_sess); - ida_free(&sess_ida, conn->sess->session_index); kfree(conn->sess->sess_ops); kfree(conn->sess); conn->sess = NULL; diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c index 35e75a3..8167fdc 100644 --- a/drivers/target/iscsi/iscsi_target_stat.c +++ b/drivers/target/iscsi/iscsi_target_stat.c @@ -630,8 +630,7 @@ static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page) if (se_sess) { sess = se_sess->fabric_sess_ptr; if (sess) - ret = snprintf(page, PAGE_SIZE, "%u\n", - sess->session_index); + ret = snprintf(page, PAGE_SIZE, "%u\n", se_sess->sid); } spin_unlock_bh(&se_nacl->nacl_sess_lock); diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index 7d618db..dbc95eb 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c @@ -186,7 +186,7 @@ static void iscsit_task_reassign_remove_cmd( spin_unlock(&cr->conn_recovery_cmd_lock); if (!ret) { pr_debug("iSCSI connection recovery successful for CID:" - " %hu on SID: %u\n", cr->cid, sess->sid); + " %hu on SID: %u\n", cr->cid, sess->se_sess->sid); iscsit_remove_active_connection_recovery_entry(cr, sess); } } diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index 8075f60..e252a7f 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c @@ -64,16 +64,13 @@ int iscsit_load_discovery_tpg(void) */ tpg->tpg_se_tpg.se_tpg_tfo = &iscsi_ops; ret = core_tpg_register(NULL, &tpg->tpg_se_tpg, -1); - if (ret < 0) { - kfree(tpg); - return -1; - } + if (ret < 0) + goto free_tpg; - tpg->sid = 1; /* First Assigned LIO Session ID */ iscsit_set_default_tpg_attribs(tpg); if (iscsi_create_default_params(&tpg->param_list) < 0) - goto out; + goto dereg_se_tpg; /* * By default we disable authentication for discovery sessions, * this can be changed with: @@ -97,11 +94,12 @@ int iscsit_load_discovery_tpg(void) pr_debug("CORE[0] - Allocated Discovery TPG\n"); return 0; + free_pl_out: iscsi_release_param_list(tpg->param_list); -out: - if (tpg->sid == 1) - core_tpg_deregister(&tpg->tpg_se_tpg); +dereg_se_tpg: + core_tpg_deregister(&tpg->tpg_se_tpg); +free_tpg: kfree(tpg); return -1; } diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 89183b3..f9c0ed0 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -1219,7 +1219,7 @@ void iscsit_print_session_params(struct iscsi_session *sess) struct iscsi_conn *conn; pr_debug("-----------------------------[Session Params for" - " SID: %u]-----------------------------\n", sess->sid); + " SID: %u]-----------------------------\n", sess->se_sess->sid); spin_lock_bh(&sess->conn_lock); list_for_each_entry(conn, &sess->sess_conn_list, conn_list) iscsi_dump_conn_ops(conn->conn_ops); diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 591cd9e..64937be 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -654,11 +654,7 @@ struct iscsi_session { atomic_t max_cmd_sn; struct list_head sess_ooo_cmdsn_list; - /* LIO specific session ID */ - u32 sid; char auth_type[8]; - /* unique within the target */ - int session_index; /* Used for session reference counting */ int session_usage_count; int session_waiting_on_uc; @@ -830,8 +826,6 @@ struct iscsi_portal_group { u32 nsessions; /* Number of Network Portals available for this TPG */ u32 num_tpg_nps; - /* Per TPG LIO specific session ID. */ - u32 sid; /* Spinlock for adding/removing Network Portals */ spinlock_t tpg_np_lock; spinlock_t tpg_state_lock; From patchwork Sun Jun 7 20:36:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB7B2C433E0 for ; Sun, 7 Jun 2020 20:36:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A36CE2075A for ; Sun, 7 Jun 2020 20:36:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JMrJ59jr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727800AbgFGUgZ (ORCPT ); Sun, 7 Jun 2020 16:36:25 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51722 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbgFGUgX (ORCPT ); Sun, 7 Jun 2020 16:36:23 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KX5pY125916; Sun, 7 Jun 2020 20:36:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=v6jxZOi8tREBD/siNCuNcz0iq0JfGXNVyyCVwBym44g=; b=JMrJ59jrT0Gn5CwE1kyB2lMUAmExnErgGxIAiVF32QX4Uqm0PlWcBQGvfzzByRQTOdTj INt2o46U0D5E9/iCstFB/2mmRHiHFZlbLn5gJRfK1LC1esd/bkFogjzrvRIGv7vYgp8r XU2CvgA6i1RJvc4FUUs0NaNTEzpuRCpOQbLPpXdSeOc3XJaiUI7h9UCe+2UHI/IwACsO OomZDW46chzn+989Jlq8v3EiG25p9a1qt290cMXCr+2Ly1E0i+iiyuHKDgOOtc9FYBnt q3RcN2dqsvOO4GS8sTHIiAZl1tv36OCiE/RH20am3RDF8op2AAHrJVyUYLCkvEMTdcyV qw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 31g3smkxfx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KRvWt015877; Sun, 7 Jun 2020 20:36:18 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 31gn2u8667-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:18 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 057KaHhA024049; Sun, 7 Jun 2020 20:36:17 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:16 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 15/17] iscsi target: hook iscsi target into sysfs API Date: Sun, 7 Jun 2020 15:36:02 -0500 Message-Id: <1591562164-9766-16-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=2 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Have the iscsi target export it's sessions in sysfs. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 2 ++ drivers/target/iscsi/iscsi_target_nego.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 4c73374..f26d364 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4383,6 +4383,8 @@ int iscsit_close_session(struct iscsi_session *sess) } } + target_sysfs_remove_session(sess->se_sess); + if (sess->sess_ops->ErrorRecoveryLevel == 2) iscsit_free_connection_recovery_entries(sess); diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index c44613a2..6dcb8ff 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -359,6 +359,13 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log ISCSI_LOGIN_STATUS_NO_RESOURCES); return -1; } + + if (target_sysfs_add_session(&conn->tpg->tpg_se_tpg, + conn->sess->se_sess)) { + iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, + ISCSI_LOGIN_STATUS_NO_RESOURCES); + return -1; + } } if (conn->conn_transport->iscsit_put_login_tx(conn, login, @@ -371,6 +378,8 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log err: if (login->login_complete) { + target_sysfs_remove_session(conn->sess->se_sess); + if (conn->rx_thread && conn->rx_thread_active) { send_sig(SIGINT, conn->rx_thread, 1); complete(&conn->rx_login_comp); From patchwork Sun Jun 7 20:36:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4AF0C433DF for ; Sun, 7 Jun 2020 20:36:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E5C52074B for ; Sun, 7 Jun 2020 20:36:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nTaypmcY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728176AbgFGUg1 (ORCPT ); Sun, 7 Jun 2020 16:36:27 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51726 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbgFGUgY (ORCPT ); Sun, 7 Jun 2020 16:36:24 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KWk5m125838; Sun, 7 Jun 2020 20:36:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=ECKXryUn6iwZIhWoaackKfQjn9LXva6soFkhEvc+ChM=; b=nTaypmcYGinPO2rtbZKDLuTcrqKvTk8F7wRZfWiP0gcnh9kDT4cqvV9e07eQWSJ7XhYF U9UUdUYIlEGu9b898Q6YhdOLK95yFXfP2juQyL8SCIGbRQZI18jLAsCZqoKCXuzoOtKw zhLO6yMdMvyfKgNGVCqC8Ddcx9iOLWZq/85g1D2GxWULMHqjN2ZGgqMlXhl8T7rTDxZ9 u/+VccJ4u/qCmM/2o3m5wd7jSlbqZwwbje8mc4LHw6FHepekXwUPyYoyNjZYjUboYG7O 2VKOcHJamGa6kAE4TJnSO/Z2x6ZTYfMAOSN/y8PEBuuFa4i6mtBjZ/ohL8NuJHBgIqqs lQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 31g3smkxfy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KRp6H015821; Sun, 7 Jun 2020 20:36:18 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 31gn2u8669-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:18 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 057KaH61024052; Sun, 7 Jun 2020 20:36:17 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:17 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 16/17] iscsi target: export session state and alias in sysfs Date: Sun, 7 Jun 2020 15:36:03 -0500 Message-Id: <1591562164-9766-17-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=2 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Export the session state and alias in sysfs. Note: It does not export the per connection state. In the future we can have the iscsi target add/rm an attribute group directly for each connection when we login and logout/drop a connection. Since those are dynamic and can change while the session exists, we don't need them at device addition so it can be done directly from the module. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target_configfs.c | 97 ++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 21 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index ba608fa..64de2ec 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -28,6 +28,28 @@ #include "iscsi_target.h" #include +static const struct { + enum target_sess_state_table value; + char *name; +} session_states[] = { + { TARG_SESS_STATE_FREE, "TARG_SESS_FREE" }, + { TARG_SESS_STATE_ACTIVE, "TARG_SESS_STATE_ACTIVE" }, + { TARG_SESS_STATE_LOGGED_IN, "TARG_SESS_STATE_LOGGED_IN" }, + { TARG_SESS_STATE_FAILED, "TARG_SESS_STATE_FAILED" }, + { TARG_SESS_STATE_IN_CONTINUE, "TARG_SESS_STATE_IN_CONTINUE" }, +}; + +static const char *session_state_name(enum target_sess_state_table state) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(session_states); i++) { + if (session_states[i].value == state) + return session_states[i].name; + } + + return NULL; +} /* Start items for lio_target_portal_cit */ @@ -502,6 +524,7 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) struct iscsi_session *sess; struct iscsi_conn *conn; struct se_session *se_sess; + const char *state_name; ssize_t rb = 0; u32 max_cmd_sn; @@ -525,27 +548,12 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) (sess->sess_ops->SessionType) ? "Discovery" : "Normal"); rb += sprintf(page+rb, "Session State: "); - switch (sess->session_state) { - case TARG_SESS_STATE_FREE: - rb += sprintf(page+rb, "TARG_SESS_FREE\n"); - break; - case TARG_SESS_STATE_ACTIVE: - rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n"); - break; - case TARG_SESS_STATE_LOGGED_IN: - rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n"); - break; - case TARG_SESS_STATE_FAILED: - rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n"); - break; - case TARG_SESS_STATE_IN_CONTINUE: - rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n"); - break; - default: - rb += sprintf(page+rb, "ERROR: Unknown Session" - " State!\n"); - break; - } + + state_name = session_state_name(sess->session_state); + if (state_name) + rb += sprintf(page+rb, "%s\n", state_name); + else + rb += sprintf(page+rb, "ERROR: Unknown Session State!\n"); rb += sprintf(page+rb, "---------------------[iSCSI Session" " Values]-----------------------\n"); @@ -1333,6 +1341,51 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item, /* End lio_target_discovery_auth_cit */ +/* session sysfs */ +static ssize_t +lio_show_sess_state(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct se_session *se_sess = container_of(dev, struct se_session, dev); + struct iscsi_session *sess = se_sess->fabric_sess_ptr; + const char *state_name; + + state_name = session_state_name(sess->session_state); + if (!state_name) + return -EINVAL; + + return snprintf(buf, PAGE_SIZE, "%s", state_name); +} + +static ssize_t +lio_show_initiator_alias(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct se_session *se_sess = container_of(dev, struct se_session, dev); + struct iscsi_session *sess = se_sess->fabric_sess_ptr; + + return snprintf(buf, PAGE_SIZE, "%s", sess->sess_ops->InitiatorAlias); +} + +static DEVICE_ATTR(state, S_IRUGO, lio_show_sess_state, NULL); +static DEVICE_ATTR(initiator_alias, S_IRUGO, lio_show_initiator_alias, NULL); + +static struct attribute *lio_sess_attrs[] = { + &dev_attr_state.attr, + &dev_attr_initiator_alias.attr, + NULL, +}; + +static struct attribute_group lio_sess_attr_group = { + .name = "iscsi_session", + .attrs = lio_sess_attrs, +}; + +static const struct attribute_group *lio_sess_attr_groups[] = { + &lio_sess_attr_group, + NULL, +}; + /* Start functions for target_core_fabric_ops */ static int iscsi_get_cmd_state(struct se_cmd *se_cmd) @@ -1556,6 +1609,8 @@ static void lio_release_cmd(struct se_cmd *se_cmd) .fabric_drop_np = lio_target_call_delnpfromtpg, .fabric_init_nodeacl = lio_target_init_nodeacl, + .session_attr_groups = lio_sess_attr_groups, + .tfc_discovery_attrs = lio_target_discovery_auth_attrs, .tfc_wwn_attrs = lio_target_wwn_attrs, .tfc_tpg_base_attrs = lio_target_tpg_attrs,