scsi: Change spdk_scsi_task_alloc/free_data() from public to private
This patch does a little cleanup of SPDK SCSI layer APIs. spdk_scsi_task_alloc_data() is only used in spdk_scsi_task_scatter_data(). spck_scsi_task_free_data() is only used in spdk_scsi_task_put(). The latter was called in UT code but this can be removed without any degradation. SPDK SCSI layer is relatively matured and these will not be used out of lib/scsi/task.c. Additionally memory leak detected by ASAN is fixed in this patch. Change-Id: I8eff7b4dbfc307c211087734649a9b9b10555f8d Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/413872 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
86637cae4f
commit
f2554ee973
@ -206,7 +206,6 @@ void spdk_scsi_task_construct(struct spdk_scsi_task *task,
|
|||||||
spdk_scsi_task_free free_fn);
|
spdk_scsi_task_free free_fn);
|
||||||
void spdk_scsi_task_put(struct spdk_scsi_task *task);
|
void spdk_scsi_task_put(struct spdk_scsi_task *task);
|
||||||
|
|
||||||
void spdk_scsi_task_free_data(struct spdk_scsi_task *task);
|
|
||||||
/**
|
/**
|
||||||
* Set internal buffer to given one. Caller is owner of that buffer.
|
* Set internal buffer to given one. Caller is owner of that buffer.
|
||||||
*
|
*
|
||||||
@ -216,20 +215,6 @@ void spdk_scsi_task_free_data(struct spdk_scsi_task *task);
|
|||||||
*/
|
*/
|
||||||
void spdk_scsi_task_set_data(struct spdk_scsi_task *task, void *data, uint32_t len);
|
void spdk_scsi_task_set_data(struct spdk_scsi_task *task, void *data, uint32_t len);
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocate internal buffer of requested size. Caller is not owner of
|
|
||||||
* returned buffer and must not free it. Caller is permitted to call
|
|
||||||
* spdk_scsi_task_free_data() to free internal buffer if it is not required
|
|
||||||
* anymore, but must assert that task is done and not used by library.
|
|
||||||
*
|
|
||||||
* Allocated buffer is stored in iov field of task object.
|
|
||||||
*
|
|
||||||
* \param task Task struct
|
|
||||||
* \param alloc_len Size of allocated buffer.
|
|
||||||
* \return Pointer to buffer or NULL on error.
|
|
||||||
*/
|
|
||||||
void *spdk_scsi_task_alloc_data(struct spdk_scsi_task *task, uint32_t alloc_len);
|
|
||||||
|
|
||||||
int spdk_scsi_task_scatter_data(struct spdk_scsi_task *task, const void *src, size_t len);
|
int spdk_scsi_task_scatter_data(struct spdk_scsi_task *task, const void *src, size_t len);
|
||||||
void *spdk_scsi_task_gather_data(struct spdk_scsi_task *task, int *len);
|
void *spdk_scsi_task_gather_data(struct spdk_scsi_task *task, int *len);
|
||||||
void spdk_scsi_task_build_sense_data(struct spdk_scsi_task *task, int sk, int asc,
|
void spdk_scsi_task_build_sense_data(struct spdk_scsi_task *task, int sk, int asc,
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
#include "spdk/util.h"
|
#include "spdk/util.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_scsi_task_free_data(struct spdk_scsi_task *task);
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_scsi_task_put(struct spdk_scsi_task *task)
|
spdk_scsi_task_put(struct spdk_scsi_task *task)
|
||||||
{
|
{
|
||||||
@ -81,7 +84,7 @@ spdk_scsi_task_construct(struct spdk_scsi_task *task,
|
|||||||
task->iovcnt = 1;
|
task->iovcnt = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
spdk_scsi_task_free_data(struct spdk_scsi_task *task)
|
spdk_scsi_task_free_data(struct spdk_scsi_task *task)
|
||||||
{
|
{
|
||||||
if (task->alloc_len != 0) {
|
if (task->alloc_len != 0) {
|
||||||
@ -93,7 +96,7 @@ spdk_scsi_task_free_data(struct spdk_scsi_task *task)
|
|||||||
task->iov.iov_len = 0;
|
task->iov.iov_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
static void *
|
||||||
spdk_scsi_task_alloc_data(struct spdk_scsi_task *task, uint32_t alloc_len)
|
spdk_scsi_task_alloc_data(struct spdk_scsi_task *task, uint32_t alloc_len)
|
||||||
{
|
{
|
||||||
assert(task->alloc_len == 0);
|
assert(task->alloc_len == 0);
|
||||||
|
@ -86,8 +86,6 @@ spdk_lun_ut_cpl_task(struct spdk_scsi_task *task)
|
|||||||
static void
|
static void
|
||||||
spdk_lun_ut_free_task(struct spdk_scsi_task *task)
|
spdk_lun_ut_free_task(struct spdk_scsi_task *task)
|
||||||
{
|
{
|
||||||
/* This should never get called since we never call spdk_scsi_task_put(). */
|
|
||||||
SPDK_CU_ASSERT_FATAL(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -442,7 +440,7 @@ lun_append_task_null_lun_task_cdb_spc_inquiry(void)
|
|||||||
|
|
||||||
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_GOOD);
|
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_GOOD);
|
||||||
|
|
||||||
spdk_scsi_task_free_data(&task);
|
spdk_scsi_task_put(&task);
|
||||||
|
|
||||||
/* spdk_scsi_task_process_null_lun() does not call cpl_fn */
|
/* spdk_scsi_task_process_null_lun() does not call cpl_fn */
|
||||||
CU_ASSERT_EQUAL(g_task_count, 1);
|
CU_ASSERT_EQUAL(g_task_count, 1);
|
||||||
@ -467,6 +465,8 @@ lun_append_task_null_lun_alloc_len_lt_4096(void)
|
|||||||
|
|
||||||
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_GOOD);
|
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_GOOD);
|
||||||
|
|
||||||
|
spdk_scsi_task_put(&task);
|
||||||
|
|
||||||
/* spdk_scsi_task_process_null_lun() does not call cpl_fn */
|
/* spdk_scsi_task_process_null_lun() does not call cpl_fn */
|
||||||
CU_ASSERT_EQUAL(g_task_count, 1);
|
CU_ASSERT_EQUAL(g_task_count, 1);
|
||||||
g_task_count = 0;
|
g_task_count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user