From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> This patch converts a handful of se_node_acl statistics to type atomic_long_t, instead of using se_node_acl->stats_lock when incrementing these values. More importantly, go ahead and drop the spinlock usage within iscsit_setup_scsi_cmd(), iscsit_check_dataout_hdr() and iscsit_send_datain() fast-path code. Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> --- drivers/target/iscsi/iscsi_target.c | 23 ++++++++--------------- drivers/target/target_core_tpg.c | 2 -- include/target/target_core_base.h | 7 +++---- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index ba9787d..241f913 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -802,11 +802,8 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, spin_lock_bh(&conn->sess->session_stats_lock); conn->sess->cmd_pdus++; - if (conn->sess->se_sess->se_node_acl) { - spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock); - conn->sess->se_sess->se_node_acl->num_cmds++; - spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock); - } + if (conn->sess->se_sess->se_node_acl) + atomic_long_inc(&conn->sess->se_sess->se_node_acl->num_cmds); spin_unlock_bh(&conn->sess->session_stats_lock); hdr = (struct iscsi_scsi_req *) buf; @@ -1256,11 +1253,9 @@ iscsit_check_dataout_hdr(struct iscsi_conn *conn, unsigned char *buf, /* iSCSI write */ spin_lock_bh(&conn->sess->session_stats_lock); conn->sess->rx_data_octets += payload_length; - if (conn->sess->se_sess->se_node_acl) { - spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock); - conn->sess->se_sess->se_node_acl->write_bytes += payload_length; - spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock); - } + if (conn->sess->se_sess->se_node_acl) + atomic_long_add(payload_length, + &conn->sess->se_sess->se_node_acl->write_bytes); spin_unlock_bh(&conn->sess->session_stats_lock); if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { @@ -2633,11 +2628,9 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) spin_lock_bh(&conn->sess->session_stats_lock); conn->sess->tx_data_octets += datain.length; - if (conn->sess->se_sess->se_node_acl) { - spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock); - conn->sess->se_sess->se_node_acl->read_bytes += datain.length; - spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock); - } + if (conn->sess->se_sess->se_node_acl) + atomic_long_add(datain.length, + &conn->sess->se_sess->se_node_acl->read_bytes); spin_unlock_bh(&conn->sess->session_stats_lock); /* * Special case for successfully execution w/ both DATAIN diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index f697f8b..f755712 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -278,7 +278,6 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); acl->se_tpg = tpg; acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); - spin_lock_init(&acl->stats_lock); acl->dynamic_node_acl = 1; tpg->se_tpg_tfo->set_default_node_attributes(acl); @@ -406,7 +405,6 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); acl->se_tpg = tpg; acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); - spin_lock_init(&acl->stats_lock); tpg->se_tpg_tfo->set_default_node_attributes(acl); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index fab91ba..499e85d 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -516,10 +516,9 @@ struct se_node_acl { u32 acl_index; #define MAX_ACL_TAG_SIZE 64 char acl_tag[MAX_ACL_TAG_SIZE]; - u64 num_cmds; - u64 read_bytes; - u64 write_bytes; - spinlock_t stats_lock; + atomic_long_t num_cmds; + atomic_long_t read_bytes; + atomic_long_t write_bytes; /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ atomic_t acl_pr_ref_count; struct se_dev_entry **device_list; -- 1.7.10.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