From 4b23e3f2b9f924b648077e77af26125463a78e6c Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 18 Mar 2020 11:50:46 +0900 Subject: [PATCH] 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 Change-Id: I5df1e461d2b25a2f20222e823fb1ec68ced049ad Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1347 Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/iscsi/conn.c | 2 +- lib/iscsi/iscsi.c | 12 ++++++------ lib/iscsi/iscsi.h | 15 --------------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index fd198785d..40d1435e0 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -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; diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index d44e36245..85327f083 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -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; } diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index 674382f87..11af10d05 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -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 * */