From cc402a588e1b136ee49aa1874d877f299f893702 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Sun, 9 Oct 2016 12:31:06 +0800 Subject: [PATCH] iscsi: change the type and name of data_ref in spdk_iscsi_pdu Change the type from int to bool and change the name from data_ref to data_from_mempool. Change-Id: If1fc11761e63561443ed44d6a0860e416e424df8 Signed-off-by: Ziye Yang --- lib/iscsi/iscsi.c | 6 +++--- lib/iscsi/iscsi.h | 2 +- lib/iscsi/iscsi_subsystem.c | 2 +- test/lib/iscsi/common.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 251b8faaa..7835365ba 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -504,7 +504,7 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu) } pdu->data = pdu->data_buf; - pdu->data_ref++; + pdu->data_from_mempool = true; pdu->data_segment_len = data_len; } @@ -2617,7 +2617,7 @@ spdk_iscsi_send_datain(struct spdk_iscsi_conn *conn, rsp_pdu = spdk_get_pdu(); rsph = (struct iscsi_bhs_data_in *)&rsp_pdu->bhs; rsp_pdu->data = task->scsi.rbuf + offset; - rsp_pdu->data_ref++; + rsp_pdu->data_from_mempool = true; task_tag = task->scsi.id; transfer_tag = 0xffffffffU; @@ -3147,7 +3147,7 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn, rsp_pdu = spdk_get_pdu(); rsph = (struct iscsi_bhs_scsi_resp *)&rsp_pdu->bhs; rsp_pdu->data = task->scsi.sense_data; - rsp_pdu->data_ref++; + rsp_pdu->data_from_mempool = true; /* * we need to hold onto this task/cmd because until the diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index a101c34fa..c47822437 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -170,7 +170,7 @@ struct spdk_iscsi_pdu { int hdigest_valid_bytes; int ddigest_valid_bytes; int ref; - int data_ref; + bool data_from_mempool; /* indicate whether the data buffer is allocated from mempool */ struct spdk_iscsi_task *task; /* data tied to a task buffer */ uint32_t cmd_sn; uint32_t writev_offset; diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index bcc851193..4933c785e 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -511,7 +511,7 @@ void spdk_put_pdu(struct spdk_iscsi_pdu *pdu) if (pdu->mobj) rte_mempool_put(pdu->mobj->mp, (void *)pdu->mobj); - if (pdu->data && !pdu->data_ref) + if (pdu->data && !pdu->data_from_mempool) free(pdu->data); rte_mempool_put(g_spdk_iscsi.pdu_pool, (void *)pdu); diff --git a/test/lib/iscsi/common.c b/test/lib/iscsi/common.c index fa6ba9e34..210ab433d 100644 --- a/test/lib/iscsi/common.c +++ b/test/lib/iscsi/common.c @@ -36,7 +36,7 @@ spdk_put_pdu(struct spdk_iscsi_pdu *pdu) } if (pdu->ref == 0) { - if (pdu->data && !pdu->data_ref) { + if (pdu->data && !pdu->data_from_mempool) { free(pdu->data); } free(pdu);