aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2013-11-13 21:54:45 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2013-11-20 00:38:52 -0500
commit04f3b31bff720f01d684100c868c88f67ced8dc8 (patch)
treed9b5fac82a5e6c23b98f33c64901affa37bbfd67 /drivers/target
parentee480683d975973e3ff679850871e00e011c4a96 (diff)
iscsi-target: Convert iscsi_session statistics to atomic_long_t
This patch converts a handful of iscsi_session statistics to type atomic_long_t, instead of using iscsi_session->session_stats_lock when incrementing these values. More importantly, go ahead and drop the spinlock usage within iscsit_setup_scsi_cmd(), iscsit_check_dataout_hdr(), iscsit_send_datain(), and iscsit_build_rsp_pdu() fast-path code. (Squash in Roland's target: Remove write-only stats fields and lock from struct se_node_acl) Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/iscsi/iscsi_target.c35
-rw-r--r--drivers/target/iscsi/iscsi_target_core.h13
-rw-r--r--drivers/target/iscsi/iscsi_target_erl0.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c1
-rw-r--r--drivers/target/iscsi/iscsi_target_stat.c22
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c2
6 files changed, 25 insertions, 50 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index ba9787d24c12..bf76fc46fc52 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -800,14 +800,7 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
800 int iscsi_task_attr; 800 int iscsi_task_attr;
801 int sam_task_attr; 801 int sam_task_attr;
802 802
803 spin_lock_bh(&conn->sess->session_stats_lock); 803 atomic_long_inc(&conn->sess->cmd_pdus);
804 conn->sess->cmd_pdus++;
805 if (conn->sess->se_sess->se_node_acl) {
806 spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock);
807 conn->sess->se_sess->se_node_acl->num_cmds++;
808 spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock);
809 }
810 spin_unlock_bh(&conn->sess->session_stats_lock);
811 804
812 hdr = (struct iscsi_scsi_req *) buf; 805 hdr = (struct iscsi_scsi_req *) buf;
813 payload_length = ntoh24(hdr->dlength); 806 payload_length = ntoh24(hdr->dlength);
@@ -1254,14 +1247,7 @@ iscsit_check_dataout_hdr(struct iscsi_conn *conn, unsigned char *buf,
1254 } 1247 }
1255 1248
1256 /* iSCSI write */ 1249 /* iSCSI write */
1257 spin_lock_bh(&conn->sess->session_stats_lock); 1250 atomic_long_add(payload_length, &conn->sess->rx_data_octets);
1258 conn->sess->rx_data_octets += payload_length;
1259 if (conn->sess->se_sess->se_node_acl) {
1260 spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock);
1261 conn->sess->se_sess->se_node_acl->write_bytes += payload_length;
1262 spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock);
1263 }
1264 spin_unlock_bh(&conn->sess->session_stats_lock);
1265 1251
1266 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { 1252 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) {
1267 pr_err("DataSegmentLength: %u is greater than" 1253 pr_err("DataSegmentLength: %u is greater than"
@@ -2631,14 +2617,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2631 return -1; 2617 return -1;
2632 } 2618 }
2633 2619
2634 spin_lock_bh(&conn->sess->session_stats_lock); 2620 atomic_long_add(datain.length, &conn->sess->tx_data_octets);
2635 conn->sess->tx_data_octets += datain.length;
2636 if (conn->sess->se_sess->se_node_acl) {
2637 spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock);
2638 conn->sess->se_sess->se_node_acl->read_bytes += datain.length;
2639 spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock);
2640 }
2641 spin_unlock_bh(&conn->sess->session_stats_lock);
2642 /* 2621 /*
2643 * Special case for successfully execution w/ both DATAIN 2622 * Special case for successfully execution w/ both DATAIN
2644 * and Sense Data. 2623 * and Sense Data.
@@ -3163,9 +3142,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
3163 if (inc_stat_sn) 3142 if (inc_stat_sn)
3164 cmd->stat_sn = conn->stat_sn++; 3143 cmd->stat_sn = conn->stat_sn++;
3165 3144
3166 spin_lock_bh(&conn->sess->session_stats_lock); 3145 atomic_long_inc(&conn->sess->rsp_pdus);
3167 conn->sess->rsp_pdus++;
3168 spin_unlock_bh(&conn->sess->session_stats_lock);
3169 3146
3170 memset(hdr, 0, ISCSI_HDR_LEN); 3147 memset(hdr, 0, ISCSI_HDR_LEN);
3171 hdr->opcode = ISCSI_OP_SCSI_CMD_RSP; 3148 hdr->opcode = ISCSI_OP_SCSI_CMD_RSP;
@@ -4114,9 +4091,7 @@ restart:
4114 * hit default in the switch below. 4091 * hit default in the switch below.
4115 */ 4092 */
4116 memset(buffer, 0xff, ISCSI_HDR_LEN); 4093 memset(buffer, 0xff, ISCSI_HDR_LEN);
4117 spin_lock_bh(&conn->sess->session_stats_lock); 4094 atomic_long_inc(&conn->sess->conn_digest_errors);
4118 conn->sess->conn_digest_errors++;
4119 spin_unlock_bh(&conn->sess->session_stats_lock);
4120 } else { 4095 } else {
4121 pr_debug("Got HeaderDigest CRC32C" 4096 pr_debug("Got HeaderDigest CRC32C"
4122 " 0x%08x\n", checksum); 4097 " 0x%08x\n", checksum);
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
index b03ee2ff31e5..f2094d2f8eef 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -651,14 +651,13 @@ struct iscsi_session {
651 /* Used for session reference counting */ 651 /* Used for session reference counting */
652 int session_usage_count; 652 int session_usage_count;
653 int session_waiting_on_uc; 653 int session_waiting_on_uc;
654 u32 cmd_pdus; 654 atomic_long_t cmd_pdus;
655 u32 rsp_pdus; 655 atomic_long_t rsp_pdus;
656 u64 tx_data_octets; 656 atomic_long_t tx_data_octets;
657 u64 rx_data_octets; 657 atomic_long_t rx_data_octets;
658 u32 conn_digest_errors; 658 atomic_long_t conn_digest_errors;
659 u32 conn_timeout_errors; 659 atomic_long_t conn_timeout_errors;
660 u64 creation_time; 660 u64 creation_time;
661 spinlock_t session_stats_lock;
662 /* Number of active connections */ 661 /* Number of active connections */
663 atomic_t nconn; 662 atomic_t nconn;
664 atomic_t session_continuation; 663 atomic_t session_continuation;
diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c
index cbea7f16d625..0d1e6ee3e992 100644
--- a/drivers/target/iscsi/iscsi_target_erl0.c
+++ b/drivers/target/iscsi/iscsi_target_erl0.c
@@ -785,7 +785,7 @@ static void iscsit_handle_time2retain_timeout(unsigned long data)
785 tiqn->sess_err_stats.last_sess_failure_type = 785 tiqn->sess_err_stats.last_sess_failure_type =
786 ISCSI_SESS_ERR_CXN_TIMEOUT; 786 ISCSI_SESS_ERR_CXN_TIMEOUT;
787 tiqn->sess_err_stats.cxn_timeout_errors++; 787 tiqn->sess_err_stats.cxn_timeout_errors++;
788 sess->conn_timeout_errors++; 788 atomic_long_inc(&sess->conn_timeout_errors);
789 spin_unlock(&tiqn->sess_err_stats.lock); 789 spin_unlock(&tiqn->sess_err_stats.lock);
790 } 790 }
791 } 791 }
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 646632aa2002..4eb93b2b6473 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -305,7 +305,6 @@ static int iscsi_login_zero_tsih_s1(
305 } 305 }
306 306
307 sess->creation_time = get_jiffies_64(); 307 sess->creation_time = get_jiffies_64();
308 spin_lock_init(&sess->session_stats_lock);
309 /* 308 /*
310 * The FFP CmdSN window values will be allocated from the TPG's 309 * The FFP CmdSN window values will be allocated from the TPG's
311 * Initiator Node's ACL once the login has been successfully completed. 310 * Initiator Node's ACL once the login has been successfully completed.
diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c
index f788e8b5e855..103395510307 100644
--- a/drivers/target/iscsi/iscsi_target_stat.c
+++ b/drivers/target/iscsi/iscsi_target_stat.c
@@ -792,7 +792,8 @@ static ssize_t iscsi_stat_sess_show_attr_cmd_pdus(
792 if (se_sess) { 792 if (se_sess) {
793 sess = se_sess->fabric_sess_ptr; 793 sess = se_sess->fabric_sess_ptr;
794 if (sess) 794 if (sess)
795 ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus); 795 ret = snprintf(page, PAGE_SIZE, "%lu\n",
796 atomic_long_read(&sess->cmd_pdus));
796 } 797 }
797 spin_unlock_bh(&se_nacl->nacl_sess_lock); 798 spin_unlock_bh(&se_nacl->nacl_sess_lock);
798 799
@@ -815,7 +816,8 @@ static ssize_t iscsi_stat_sess_show_attr_rsp_pdus(
815 if (se_sess) { 816 if (se_sess) {
816 sess = se_sess->fabric_sess_ptr; 817 sess = se_sess->fabric_sess_ptr;
817 if (sess) 818 if (sess)
818 ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus); 819 ret = snprintf(page, PAGE_SIZE, "%lu\n",
820 atomic_long_read(&sess->rsp_pdus));
819 } 821 }
820 spin_unlock_bh(&se_nacl->nacl_sess_lock); 822 spin_unlock_bh(&se_nacl->nacl_sess_lock);
821 823
@@ -838,8 +840,8 @@ static ssize_t iscsi_stat_sess_show_attr_txdata_octs(
838 if (se_sess) { 840 if (se_sess) {
839 sess = se_sess->fabric_sess_ptr; 841 sess = se_sess->fabric_sess_ptr;
840 if (sess) 842 if (sess)
841 ret = snprintf(page, PAGE_SIZE, "%llu\n", 843 ret = snprintf(page, PAGE_SIZE, "%lu\n",
842 (unsigned long long)sess->tx_data_octets); 844 atomic_long_read(&sess->tx_data_octets));
843 } 845 }
844 spin_unlock_bh(&se_nacl->nacl_sess_lock); 846 spin_unlock_bh(&se_nacl->nacl_sess_lock);
845 847
@@ -862,8 +864,8 @@ static ssize_t iscsi_stat_sess_show_attr_rxdata_octs(
862 if (se_sess) { 864 if (se_sess) {
863 sess = se_sess->fabric_sess_ptr; 865 sess = se_sess->fabric_sess_ptr;
864 if (sess) 866 if (sess)
865 ret = snprintf(page, PAGE_SIZE, "%llu\n", 867 ret = snprintf(page, PAGE_SIZE, "%lu\n",
866 (unsigned long long)sess->rx_data_octets); 868 atomic_long_read(&sess->rx_data_octets));
867 } 869 }
868 spin_unlock_bh(&se_nacl->nacl_sess_lock); 870 spin_unlock_bh(&se_nacl->nacl_sess_lock);
869 871
@@ -886,8 +888,8 @@ static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors(
886 if (se_sess) { 888 if (se_sess) {
887 sess = se_sess->fabric_sess_ptr; 889 sess = se_sess->fabric_sess_ptr;
888 if (sess) 890 if (sess)
889 ret = snprintf(page, PAGE_SIZE, "%u\n", 891 ret = snprintf(page, PAGE_SIZE, "%lu\n",
890 sess->conn_digest_errors); 892 atomic_long_read(&sess->conn_digest_errors));
891 } 893 }
892 spin_unlock_bh(&se_nacl->nacl_sess_lock); 894 spin_unlock_bh(&se_nacl->nacl_sess_lock);
893 895
@@ -910,8 +912,8 @@ static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors(
910 if (se_sess) { 912 if (se_sess) {
911 sess = se_sess->fabric_sess_ptr; 913 sess = se_sess->fabric_sess_ptr;
912 if (sess) 914 if (sess)
913 ret = snprintf(page, PAGE_SIZE, "%u\n", 915 ret = snprintf(page, PAGE_SIZE, "%lu\n",
914 sess->conn_timeout_errors); 916 atomic_long_read(&sess->conn_timeout_errors));
915 } 917 }
916 spin_unlock_bh(&se_nacl->nacl_sess_lock); 918 spin_unlock_bh(&se_nacl->nacl_sess_lock);
917 919
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index f2de28e178fd..45b8fd13fa72 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -980,7 +980,7 @@ static void iscsit_handle_nopin_response_timeout(unsigned long data)
980 tiqn->sess_err_stats.last_sess_failure_type = 980 tiqn->sess_err_stats.last_sess_failure_type =
981 ISCSI_SESS_ERR_CXN_TIMEOUT; 981 ISCSI_SESS_ERR_CXN_TIMEOUT;
982 tiqn->sess_err_stats.cxn_timeout_errors++; 982 tiqn->sess_err_stats.cxn_timeout_errors++;
983 conn->sess->conn_timeout_errors++; 983 atomic_long_inc(&conn->sess->conn_timeout_errors);
984 spin_unlock_bh(&tiqn->sess_err_stats.lock); 984 spin_unlock_bh(&tiqn->sess_err_stats.lock);
985 } 985 }
986 } 986 }