lib/iscsi: Use spdk_sn32_lt/gt() to compare two sequence numbers

This patch does drop in replacement of SN32_LT and SN32_GT by
spdk_sn32_lt and spdk_sn32_gt, respectively.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I5df1e461d2b25a2f20222e823fb1ec68ced049ad
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1347
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-03-18 11:50:46 +09:00 committed by Tomasz Zawadzki
parent ded6d2c7f2
commit 4b23e3f2b9
3 changed files with 7 additions and 22 deletions

View File

@ -1028,7 +1028,7 @@ spdk_iscsi_conn_abort_queued_datain_tasks(struct spdk_iscsi_conn *conn,
TAILQ_FOREACH_SAFE(task, &conn->queued_datain_tasks, link, task_tmp) {
pdu_tmp = spdk_iscsi_task_get_pdu(task);
if ((lun == NULL || lun == task->scsi.lun) &&
(pdu == NULL || (SN32_LT(pdu_tmp->cmd_sn, pdu->cmd_sn)))) {
(pdu == NULL || (spdk_sn32_lt(pdu_tmp->cmd_sn, pdu->cmd_sn)))) {
rc = _iscsi_conn_abort_queued_datain_task(conn, task);
if (rc != 0) {
return rc;

View File

@ -2833,7 +2833,7 @@ del_connection_queued_task(struct spdk_iscsi_conn *conn, void *tailq,
TAILQ_FOREACH_SAFE(task, head, link, task_tmp) {
pdu_tmp = spdk_iscsi_task_get_pdu(task);
if ((lun == NULL || lun == task->scsi.lun) &&
(pdu == NULL || SN32_LT(pdu_tmp->cmd_sn, pdu->cmd_sn))) {
(pdu == NULL || spdk_sn32_lt(pdu_tmp->cmd_sn, pdu->cmd_sn))) {
TAILQ_REMOVE(head, task, link);
task->is_r2t_active = false;
if (lun != NULL && spdk_scsi_lun_is_removing(lun)) {
@ -2858,7 +2858,7 @@ void spdk_clear_all_transfer_task(struct spdk_iscsi_conn *conn,
task = conn->outstanding_r2t_tasks[i];
pdu_tmp = spdk_iscsi_task_get_pdu(task);
if ((lun == NULL || lun == task->scsi.lun) &&
(pdu == NULL || SN32_LT(pdu_tmp->cmd_sn, pdu->cmd_sn))) {
(pdu == NULL || spdk_sn32_lt(pdu_tmp->cmd_sn, pdu->cmd_sn))) {
conn->outstanding_r2t_tasks[i] = NULL;
task->outstanding_r2t = 0;
task->next_r2t_offset = 0;
@ -4406,7 +4406,7 @@ remove_acked_pdu(struct spdk_iscsi_conn *conn, uint32_t ExpStatSN)
conn->exp_statsn = spdk_min(ExpStatSN, conn->StatSN);
TAILQ_FOREACH_SAFE(pdu, &conn->snack_pdu_list, tailq, pdu_temp) {
stat_sn = from_be32(&pdu->bhs.stat_sn);
if (SN32_LT(stat_sn, conn->exp_statsn)) {
if (spdk_sn32_lt(stat_sn, conn->exp_statsn)) {
TAILQ_REMOVE(&conn->snack_pdu_list, pdu, tailq);
spdk_iscsi_conn_free_pdu(conn, pdu);
}
@ -4435,8 +4435,8 @@ iscsi_update_cmdsn(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
I_bit = reqh->immediate;
if (I_bit == 0) {
if (SN32_LT(pdu->cmd_sn, sess->ExpCmdSN) ||
SN32_GT(pdu->cmd_sn, sess->MaxCmdSN)) {
if (spdk_sn32_lt(pdu->cmd_sn, sess->ExpCmdSN) ||
spdk_sn32_gt(pdu->cmd_sn, sess->MaxCmdSN)) {
if (sess->session_type == SESSION_TYPE_NORMAL &&
opcode != ISCSI_OP_SCSI_DATAOUT) {
SPDK_ERRLOG("CmdSN(%u) ignore (ExpCmdSN=%u, MaxCmdSN=%u)\n",
@ -4465,7 +4465,7 @@ iscsi_update_cmdsn(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
}
ExpStatSN = from_be32(&reqh->exp_stat_sn);
if (SN32_GT(ExpStatSN, conn->StatSN)) {
if (spdk_sn32_gt(ExpStatSN, conn->StatSN)) {
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "StatSN(%u) advanced\n", ExpStatSN);
ExpStatSN = conn->StatSN;
}

View File

@ -133,21 +133,6 @@
*/
#define ISCSI_LOGOUT_TIMEOUT 5 /* in seconds */
/* according to RFC1982 */
#define SN32_CMPMAX (((uint32_t)1U) << (32 - 1))
#define SN32_LT(S1,S2) \
(((uint32_t)(S1) != (uint32_t)(S2)) \
&& (((uint32_t)(S1) < (uint32_t)(S2) \
&& ((uint32_t)(S2) - (uint32_t)(S1) < SN32_CMPMAX)) \
|| ((uint32_t)(S1) > (uint32_t)(S2) \
&& ((uint32_t)(S1) - (uint32_t)(S2) > SN32_CMPMAX))))
#define SN32_GT(S1,S2) \
(((uint32_t)(S1) != (uint32_t)(S2)) \
&& (((uint32_t)(S1) < (uint32_t)(S2) \
&& ((uint32_t)(S2) - (uint32_t)(S1) > SN32_CMPMAX)) \
|| ((uint32_t)(S1) > (uint32_t)(S2) \
&& ((uint32_t)(S1) - (uint32_t)(S2) < SN32_CMPMAX))))
/* For spdk_iscsi_login_in related function use, we need to avoid the conflict
* with other errors
* */