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>
This commit is contained in:
Родитель
ee480683d9
Коммит
04f3b31bff
|
@ -800,14 +800,7 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
|
|||
int iscsi_task_attr;
|
||||
int sam_task_attr;
|
||||
|
||||
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);
|
||||
}
|
||||
spin_unlock_bh(&conn->sess->session_stats_lock);
|
||||
atomic_long_inc(&conn->sess->cmd_pdus);
|
||||
|
||||
hdr = (struct iscsi_scsi_req *) buf;
|
||||
payload_length = ntoh24(hdr->dlength);
|
||||
|
@ -1254,14 +1247,7 @@ 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);
|
||||
}
|
||||
spin_unlock_bh(&conn->sess->session_stats_lock);
|
||||
atomic_long_add(payload_length, &conn->sess->rx_data_octets);
|
||||
|
||||
if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) {
|
||||
pr_err("DataSegmentLength: %u is greater than"
|
||||
|
@ -2631,14 +2617,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
|
|||
return -1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
spin_unlock_bh(&conn->sess->session_stats_lock);
|
||||
atomic_long_add(datain.length, &conn->sess->tx_data_octets);
|
||||
/*
|
||||
* Special case for successfully execution w/ both DATAIN
|
||||
* and Sense Data.
|
||||
|
@ -3163,9 +3142,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
|
|||
if (inc_stat_sn)
|
||||
cmd->stat_sn = conn->stat_sn++;
|
||||
|
||||
spin_lock_bh(&conn->sess->session_stats_lock);
|
||||
conn->sess->rsp_pdus++;
|
||||
spin_unlock_bh(&conn->sess->session_stats_lock);
|
||||
atomic_long_inc(&conn->sess->rsp_pdus);
|
||||
|
||||
memset(hdr, 0, ISCSI_HDR_LEN);
|
||||
hdr->opcode = ISCSI_OP_SCSI_CMD_RSP;
|
||||
|
@ -4114,9 +4091,7 @@ restart:
|
|||
* hit default in the switch below.
|
||||
*/
|
||||
memset(buffer, 0xff, ISCSI_HDR_LEN);
|
||||
spin_lock_bh(&conn->sess->session_stats_lock);
|
||||
conn->sess->conn_digest_errors++;
|
||||
spin_unlock_bh(&conn->sess->session_stats_lock);
|
||||
atomic_long_inc(&conn->sess->conn_digest_errors);
|
||||
} else {
|
||||
pr_debug("Got HeaderDigest CRC32C"
|
||||
" 0x%08x\n", checksum);
|
||||
|
|
|
@ -651,14 +651,13 @@ struct iscsi_session {
|
|||
/* Used for session reference counting */
|
||||
int session_usage_count;
|
||||
int session_waiting_on_uc;
|
||||
u32 cmd_pdus;
|
||||
u32 rsp_pdus;
|
||||
u64 tx_data_octets;
|
||||
u64 rx_data_octets;
|
||||
u32 conn_digest_errors;
|
||||
u32 conn_timeout_errors;
|
||||
atomic_long_t cmd_pdus;
|
||||
atomic_long_t rsp_pdus;
|
||||
atomic_long_t tx_data_octets;
|
||||
atomic_long_t rx_data_octets;
|
||||
atomic_long_t conn_digest_errors;
|
||||
atomic_long_t conn_timeout_errors;
|
||||
u64 creation_time;
|
||||
spinlock_t session_stats_lock;
|
||||
/* Number of active connections */
|
||||
atomic_t nconn;
|
||||
atomic_t session_continuation;
|
||||
|
|
|
@ -785,7 +785,7 @@ static void iscsit_handle_time2retain_timeout(unsigned long data)
|
|||
tiqn->sess_err_stats.last_sess_failure_type =
|
||||
ISCSI_SESS_ERR_CXN_TIMEOUT;
|
||||
tiqn->sess_err_stats.cxn_timeout_errors++;
|
||||
sess->conn_timeout_errors++;
|
||||
atomic_long_inc(&sess->conn_timeout_errors);
|
||||
spin_unlock(&tiqn->sess_err_stats.lock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,7 +305,6 @@ static int iscsi_login_zero_tsih_s1(
|
|||
}
|
||||
|
||||
sess->creation_time = get_jiffies_64();
|
||||
spin_lock_init(&sess->session_stats_lock);
|
||||
/*
|
||||
* The FFP CmdSN window values will be allocated from the TPG's
|
||||
* Initiator Node's ACL once the login has been successfully completed.
|
||||
|
|
|
@ -792,7 +792,8 @@ static ssize_t iscsi_stat_sess_show_attr_cmd_pdus(
|
|||
if (se_sess) {
|
||||
sess = se_sess->fabric_sess_ptr;
|
||||
if (sess)
|
||||
ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus);
|
||||
ret = snprintf(page, PAGE_SIZE, "%lu\n",
|
||||
atomic_long_read(&sess->cmd_pdus));
|
||||
}
|
||||
spin_unlock_bh(&se_nacl->nacl_sess_lock);
|
||||
|
||||
|
@ -815,7 +816,8 @@ static ssize_t iscsi_stat_sess_show_attr_rsp_pdus(
|
|||
if (se_sess) {
|
||||
sess = se_sess->fabric_sess_ptr;
|
||||
if (sess)
|
||||
ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus);
|
||||
ret = snprintf(page, PAGE_SIZE, "%lu\n",
|
||||
atomic_long_read(&sess->rsp_pdus));
|
||||
}
|
||||
spin_unlock_bh(&se_nacl->nacl_sess_lock);
|
||||
|
||||
|
@ -838,8 +840,8 @@ static ssize_t iscsi_stat_sess_show_attr_txdata_octs(
|
|||
if (se_sess) {
|
||||
sess = se_sess->fabric_sess_ptr;
|
||||
if (sess)
|
||||
ret = snprintf(page, PAGE_SIZE, "%llu\n",
|
||||
(unsigned long long)sess->tx_data_octets);
|
||||
ret = snprintf(page, PAGE_SIZE, "%lu\n",
|
||||
atomic_long_read(&sess->tx_data_octets));
|
||||
}
|
||||
spin_unlock_bh(&se_nacl->nacl_sess_lock);
|
||||
|
||||
|
@ -862,8 +864,8 @@ static ssize_t iscsi_stat_sess_show_attr_rxdata_octs(
|
|||
if (se_sess) {
|
||||
sess = se_sess->fabric_sess_ptr;
|
||||
if (sess)
|
||||
ret = snprintf(page, PAGE_SIZE, "%llu\n",
|
||||
(unsigned long long)sess->rx_data_octets);
|
||||
ret = snprintf(page, PAGE_SIZE, "%lu\n",
|
||||
atomic_long_read(&sess->rx_data_octets));
|
||||
}
|
||||
spin_unlock_bh(&se_nacl->nacl_sess_lock);
|
||||
|
||||
|
@ -886,8 +888,8 @@ static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors(
|
|||
if (se_sess) {
|
||||
sess = se_sess->fabric_sess_ptr;
|
||||
if (sess)
|
||||
ret = snprintf(page, PAGE_SIZE, "%u\n",
|
||||
sess->conn_digest_errors);
|
||||
ret = snprintf(page, PAGE_SIZE, "%lu\n",
|
||||
atomic_long_read(&sess->conn_digest_errors));
|
||||
}
|
||||
spin_unlock_bh(&se_nacl->nacl_sess_lock);
|
||||
|
||||
|
@ -910,8 +912,8 @@ static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors(
|
|||
if (se_sess) {
|
||||
sess = se_sess->fabric_sess_ptr;
|
||||
if (sess)
|
||||
ret = snprintf(page, PAGE_SIZE, "%u\n",
|
||||
sess->conn_timeout_errors);
|
||||
ret = snprintf(page, PAGE_SIZE, "%lu\n",
|
||||
atomic_long_read(&sess->conn_timeout_errors));
|
||||
}
|
||||
spin_unlock_bh(&se_nacl->nacl_sess_lock);
|
||||
|
||||
|
|
|
@ -980,7 +980,7 @@ static void iscsit_handle_nopin_response_timeout(unsigned long data)
|
|||
tiqn->sess_err_stats.last_sess_failure_type =
|
||||
ISCSI_SESS_ERR_CXN_TIMEOUT;
|
||||
tiqn->sess_err_stats.cxn_timeout_errors++;
|
||||
conn->sess->conn_timeout_errors++;
|
||||
atomic_long_inc(&conn->sess->conn_timeout_errors);
|
||||
spin_unlock_bh(&tiqn->sess_err_stats.lock);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче