From 07f2d83deacae9035e1bcc60ae40dd873afc0c89 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 13 Aug 2020 16:17:01 +0900 Subject: [PATCH] lib/iscsi: Change the type of pending_r2t from int to uint32_t Other count variables in iSCSI library have used uint32_t rather than int. Change the type of spdk_iscsi_conn::pending_r2t from int to uint32_t and add assert to check if pending_r2t is not negative. Signed-off-by: Shuhei Matsumoto Change-Id: I9bd296c0142b0808ae822952277c9ecc133e5f62 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3775 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/iscsi/conn.h | 2 +- lib/iscsi/iscsi.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/iscsi/conn.h b/lib/iscsi/conn.h index be9f8342a..c1ccb0ffc 100644 --- a/lib/iscsi/conn.h +++ b/lib/iscsi/conn.h @@ -137,7 +137,7 @@ struct spdk_iscsi_conn { TAILQ_HEAD(, spdk_iscsi_pdu) write_pdu_list; TAILQ_HEAD(, spdk_iscsi_pdu) snack_pdu_list; - int pending_r2t; + uint32_t pending_r2t; uint16_t cid; diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 8093fab9a..51212674a 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2804,6 +2804,7 @@ iscsi_del_transfer_task(struct spdk_iscsi_conn *conn, uint32_t task_tag) assert(conn->data_out_cnt >= task->data_out_cnt); conn->data_out_cnt -= task->data_out_cnt; + assert(conn->pending_r2t > 0); conn->pending_r2t--; assert(task->is_r2t_active == true); @@ -2834,6 +2835,7 @@ void iscsi_clear_all_transfer_task(struct spdk_iscsi_conn *conn, task->next_expected_r2t_offset = 0; assert(conn->data_out_cnt >= task->data_out_cnt); conn->data_out_cnt -= task->data_out_cnt; + assert(conn->pending_r2t > 0); conn->pending_r2t--; TAILQ_REMOVE(&conn->active_r2t_tasks, task, link);