scsi: Remove cb_event. It is no longer necessary.
This is an artifact from a past design. There is no longer any reason to create an event here - the bdev layer will correctly queue events and call completions on the correct thread. Change-Id: I145dab4046899834c0449ec7380dcbb28215b493 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/364831 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
293f920158
commit
4185205540
@ -72,11 +72,6 @@ enum spdk_scsi_task_func {
|
|||||||
SPDK_SCSI_TASK_FUNC_LUN_RESET,
|
SPDK_SCSI_TASK_FUNC_LUN_RESET,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum spdk_scsi_task_type {
|
|
||||||
SPDK_SCSI_TASK_TYPE_CMD = 0,
|
|
||||||
SPDK_SCSI_TASK_TYPE_MANAGE,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SAM does not define the value for these service responses. Each transport
|
* SAM does not define the value for these service responses. Each transport
|
||||||
* (i.e. SAS, FC, iSCSI) will map these value to transport-specific codes,
|
* (i.e. SAS, FC, iSCSI) will map these value to transport-specific codes,
|
||||||
@ -91,8 +86,11 @@ enum spdk_scsi_task_mgmt_resp {
|
|||||||
SPDK_SCSI_TASK_MGMT_RESP_REJECT_FUNC_NOT_SUPPORTED
|
SPDK_SCSI_TASK_MGMT_RESP_REJECT_FUNC_NOT_SUPPORTED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct spdk_scsi_task;
|
||||||
|
typedef void (*spdk_scsi_task_cpl)(struct spdk_scsi_task *task);
|
||||||
|
typedef void (*spdk_scsi_task_free)(struct spdk_scsi_task *task);
|
||||||
|
|
||||||
struct spdk_scsi_task {
|
struct spdk_scsi_task {
|
||||||
uint8_t type;
|
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
uint8_t function; /* task mgmt function */
|
uint8_t function; /* task mgmt function */
|
||||||
uint8_t response; /* task mgmt response */
|
uint8_t response; /* task mgmt response */
|
||||||
@ -100,7 +98,9 @@ struct spdk_scsi_task {
|
|||||||
struct spdk_io_channel *ch;
|
struct spdk_io_channel *ch;
|
||||||
struct spdk_scsi_port *target_port;
|
struct spdk_scsi_port *target_port;
|
||||||
struct spdk_scsi_port *initiator_port;
|
struct spdk_scsi_port *initiator_port;
|
||||||
struct spdk_event *cb_event;
|
|
||||||
|
spdk_scsi_task_cpl cpl_fn;
|
||||||
|
spdk_scsi_task_free free_fn;
|
||||||
|
|
||||||
uint32_t ref;
|
uint32_t ref;
|
||||||
uint32_t transfer_len;
|
uint32_t transfer_len;
|
||||||
@ -116,8 +116,6 @@ struct spdk_scsi_task {
|
|||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
struct spdk_scsi_task *parent;
|
struct spdk_scsi_task *parent;
|
||||||
|
|
||||||
void (*free_fn)(struct spdk_scsi_task *);
|
|
||||||
|
|
||||||
uint8_t *cdb;
|
uint8_t *cdb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,7 +206,8 @@ const char *spdk_scsi_port_get_name(const struct spdk_scsi_port *port);
|
|||||||
|
|
||||||
|
|
||||||
void spdk_scsi_task_construct(struct spdk_scsi_task *task,
|
void spdk_scsi_task_construct(struct spdk_scsi_task *task,
|
||||||
void (*free_fn)(struct spdk_scsi_task *task),
|
spdk_scsi_task_cpl cpl_fn,
|
||||||
|
spdk_scsi_task_free free_fn,
|
||||||
struct spdk_scsi_task *parent);
|
struct spdk_scsi_task *parent);
|
||||||
void spdk_scsi_task_put(struct spdk_scsi_task *task);
|
void spdk_scsi_task_put(struct spdk_scsi_task *task);
|
||||||
|
|
||||||
|
@ -847,13 +847,12 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
process_task_mgmt_completion(void *arg1, void *arg2)
|
spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_conn *conn = arg1;
|
struct spdk_iscsi_task *task = spdk_iscsi_task_from_scsi_task(scsi_task);
|
||||||
struct spdk_iscsi_task *task = arg2;
|
|
||||||
|
|
||||||
conn->last_activity_tsc = spdk_get_ticks();
|
task->conn->last_activity_tsc = spdk_get_ticks();
|
||||||
spdk_iscsi_task_mgmt_response(conn, task);
|
spdk_iscsi_task_mgmt_response(task->conn, task);
|
||||||
spdk_iscsi_task_put(task);
|
spdk_iscsi_task_put(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,11 +908,12 @@ process_read_task_completion(struct spdk_iscsi_conn *conn,
|
|||||||
process_completed_read_subtask_list(conn, primary);
|
process_completed_read_subtask_list(conn, primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_task_completion(void *arg1, void *arg2)
|
void
|
||||||
|
spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_conn *conn = arg1;
|
|
||||||
struct spdk_iscsi_task *task = arg2;
|
|
||||||
struct spdk_iscsi_task *primary;
|
struct spdk_iscsi_task *primary;
|
||||||
|
struct spdk_iscsi_task *task = spdk_iscsi_task_from_scsi_task(scsi_task);
|
||||||
|
struct spdk_iscsi_conn *conn = task->conn;
|
||||||
|
|
||||||
assert(task != NULL);
|
assert(task != NULL);
|
||||||
spdk_trace_record(TRACE_ISCSI_TASK_DONE, conn->id, 0, (uintptr_t)task, 0);
|
spdk_trace_record(TRACE_ISCSI_TASK_DONE, conn->id, 0, (uintptr_t)task, 0);
|
||||||
|
@ -2830,8 +2830,6 @@ spdk_iscsi_compare_pdu_bhs_within_existed_r2t_tasks(struct spdk_iscsi_conn *conn
|
|||||||
static void spdk_iscsi_queue_task(struct spdk_iscsi_conn *conn,
|
static void spdk_iscsi_queue_task(struct spdk_iscsi_conn *conn,
|
||||||
struct spdk_iscsi_task *task)
|
struct spdk_iscsi_task *task)
|
||||||
{
|
{
|
||||||
task->scsi.cb_event = spdk_event_allocate(spdk_env_get_current_core(), process_task_completion,
|
|
||||||
conn, task);
|
|
||||||
spdk_trace_record(TRACE_ISCSI_TASK_QUEUE, conn->id, task->scsi.length,
|
spdk_trace_record(TRACE_ISCSI_TASK_QUEUE, conn->id, task->scsi.length,
|
||||||
(uintptr_t)task, (uintptr_t)task->pdu);
|
(uintptr_t)task, (uintptr_t)task->pdu);
|
||||||
spdk_scsi_dev_queue_task(conn->dev, &task->scsi);
|
spdk_scsi_dev_queue_task(conn->dev, &task->scsi);
|
||||||
@ -2841,8 +2839,6 @@ static void spdk_iscsi_queue_mgmt_task(struct spdk_iscsi_conn *conn,
|
|||||||
struct spdk_iscsi_task *task,
|
struct spdk_iscsi_task *task,
|
||||||
enum spdk_scsi_task_func func)
|
enum spdk_scsi_task_func func)
|
||||||
{
|
{
|
||||||
task->scsi.cb_event = spdk_event_allocate(spdk_env_get_current_core(), process_task_mgmt_completion,
|
|
||||||
conn, task);
|
|
||||||
spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi, func);
|
spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2866,7 +2862,7 @@ int spdk_iscsi_conn_handle_queued_tasks(struct spdk_iscsi_conn *conn)
|
|||||||
uint32_t remaining_size = 0;
|
uint32_t remaining_size = 0;
|
||||||
|
|
||||||
remaining_size = task->scsi.transfer_len - task->current_datain_offset;
|
remaining_size = task->scsi.transfer_len - task->current_datain_offset;
|
||||||
subtask = spdk_iscsi_task_get(conn, task);
|
subtask = spdk_iscsi_task_get(conn, task, spdk_iscsi_task_cpl);
|
||||||
assert(subtask != NULL);
|
assert(subtask != NULL);
|
||||||
subtask->scsi.offset = task->current_datain_offset;
|
subtask->scsi.offset = task->current_datain_offset;
|
||||||
subtask->scsi.length = DMIN32(SPDK_BDEV_LARGE_BUF_MAX_SIZE, remaining_size);
|
subtask->scsi.length = DMIN32(SPDK_BDEV_LARGE_BUF_MAX_SIZE, remaining_size);
|
||||||
@ -2937,7 +2933,7 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
|
|
||||||
SPDK_TRACEDUMP(SPDK_TRACE_DEBUG, "CDB", cdb, 16);
|
SPDK_TRACEDUMP(SPDK_TRACE_DEBUG, "CDB", cdb, 16);
|
||||||
|
|
||||||
task = spdk_iscsi_task_get(conn, NULL);
|
task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_cpl);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
SPDK_ERRLOG("Unable to acquire task\n");
|
SPDK_ERRLOG("Unable to acquire task\n");
|
||||||
return SPDK_ISCSI_CONNECTION_FATAL;
|
return SPDK_ISCSI_CONNECTION_FATAL;
|
||||||
@ -2963,7 +2959,7 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
|
|
||||||
if (task->scsi.lun == NULL) {
|
if (task->scsi.lun == NULL) {
|
||||||
spdk_scsi_task_process_null_lun(&task->scsi);
|
spdk_scsi_task_process_null_lun(&task->scsi);
|
||||||
process_task_completion(conn, task);
|
spdk_iscsi_task_cpl(&task->scsi);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3253,7 +3249,7 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
|||||||
lun_i = spdk_islun2lun(lun);
|
lun_i = spdk_islun2lun(lun);
|
||||||
dev = conn->dev;
|
dev = conn->dev;
|
||||||
|
|
||||||
task = spdk_iscsi_task_get(conn, NULL);
|
task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_mgmt_cpl);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
SPDK_ERRLOG("Unable to acquire task\n");
|
SPDK_ERRLOG("Unable to acquire task\n");
|
||||||
return SPDK_ISCSI_CONNECTION_FATAL;
|
return SPDK_ISCSI_CONNECTION_FATAL;
|
||||||
@ -4089,7 +4085,7 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn,
|
|||||||
task->current_r2t_length = 0;
|
task->current_r2t_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtask = spdk_iscsi_task_get(conn, task);
|
subtask = spdk_iscsi_task_get(conn, task, spdk_iscsi_task_cpl);
|
||||||
if (subtask == NULL) {
|
if (subtask == NULL) {
|
||||||
SPDK_ERRLOG("Unable to acquire subtask\n");
|
SPDK_ERRLOG("Unable to acquire subtask\n");
|
||||||
return SPDK_ISCSI_CONNECTION_FATAL;
|
return SPDK_ISCSI_CONNECTION_FATAL;
|
||||||
|
@ -357,8 +357,8 @@ int spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
|||||||
int alloc_len, int data_len);
|
int alloc_len, int data_len);
|
||||||
int spdk_iscsi_copy_param2var(struct spdk_iscsi_conn *conn);
|
int spdk_iscsi_copy_param2var(struct spdk_iscsi_conn *conn);
|
||||||
|
|
||||||
void process_task_completion(void *arg1, void *arg2);
|
void spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task);
|
||||||
void process_task_mgmt_completion(void *arg1, void *arg2);
|
void spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task);
|
||||||
|
|
||||||
/* Memory management */
|
/* Memory management */
|
||||||
void spdk_put_pdu(struct spdk_iscsi_pdu *pdu);
|
void spdk_put_pdu(struct spdk_iscsi_pdu *pdu);
|
||||||
|
@ -51,7 +51,8 @@ spdk_iscsi_task_free(struct spdk_scsi_task *scsi_task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_iscsi_task *
|
struct spdk_iscsi_task *
|
||||||
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent)
|
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent,
|
||||||
|
spdk_scsi_task_cpl cpl_fn)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_task *task;
|
struct spdk_iscsi_task *task;
|
||||||
int rc;
|
int rc;
|
||||||
@ -67,6 +68,7 @@ spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent
|
|||||||
assert(conn->pending_task_cnt < UINT32_MAX);
|
assert(conn->pending_task_cnt < UINT32_MAX);
|
||||||
conn->pending_task_cnt++;
|
conn->pending_task_cnt++;
|
||||||
spdk_scsi_task_construct(&task->scsi,
|
spdk_scsi_task_construct(&task->scsi,
|
||||||
|
cpl_fn,
|
||||||
spdk_iscsi_task_free,
|
spdk_iscsi_task_free,
|
||||||
parent ? &parent->scsi : NULL);
|
parent ? &parent->scsi : NULL);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
@ -155,7 +155,8 @@ spdk_iscsi_task_get_cmdsn(struct spdk_iscsi_task *task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_iscsi_task *spdk_iscsi_task_get(struct spdk_iscsi_conn *conn,
|
struct spdk_iscsi_task *spdk_iscsi_task_get(struct spdk_iscsi_conn *conn,
|
||||||
struct spdk_iscsi_task *parent);
|
struct spdk_iscsi_task *parent,
|
||||||
|
spdk_scsi_task_cpl cpl_fn);
|
||||||
|
|
||||||
static inline struct spdk_iscsi_task *
|
static inline struct spdk_iscsi_task *
|
||||||
spdk_iscsi_task_from_scsi_task(struct spdk_scsi_task *task)
|
spdk_iscsi_task_from_scsi_task(struct spdk_scsi_task *task)
|
||||||
|
@ -1059,7 +1059,7 @@ spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* we create a fake management task per LUN to cleanup */
|
/* we create a fake management task per LUN to cleanup */
|
||||||
task = spdk_iscsi_task_get(conn, NULL);
|
task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_mgmt_cpl);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
SPDK_ERRLOG("Unable to acquire task\n");
|
SPDK_ERRLOG("Unable to acquire task\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -1069,8 +1069,6 @@ spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
|||||||
task->scsi.initiator_port = conn->initiator_port;
|
task->scsi.initiator_port = conn->initiator_port;
|
||||||
task->scsi.lun = lun;
|
task->scsi.lun = lun;
|
||||||
|
|
||||||
task->scsi.cb_event = spdk_event_allocate(spdk_env_get_current_core(),
|
|
||||||
process_task_mgmt_completion, conn, task);
|
|
||||||
spdk_scsi_dev_queue_mgmt_task(target->dev, &task->scsi, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
spdk_scsi_dev_queue_mgmt_task(target->dev, &task->scsi, SPDK_SCSI_TASK_FUNC_LUN_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,6 @@ spdk_scsi_dev_queue_mgmt_task(struct spdk_scsi_dev *dev,
|
|||||||
{
|
{
|
||||||
assert(task != NULL);
|
assert(task != NULL);
|
||||||
|
|
||||||
task->type = SPDK_SCSI_TASK_TYPE_MANAGE;
|
|
||||||
task->function = func;
|
task->function = func;
|
||||||
spdk_scsi_lun_task_mgmt_execute(task, func);
|
spdk_scsi_lun_task_mgmt_execute(task, func);
|
||||||
}
|
}
|
||||||
@ -219,7 +218,6 @@ spdk_scsi_dev_queue_task(struct spdk_scsi_dev *dev,
|
|||||||
{
|
{
|
||||||
assert(task != NULL);
|
assert(task != NULL);
|
||||||
|
|
||||||
task->type = SPDK_SCSI_TASK_TYPE_CMD;
|
|
||||||
if (spdk_scsi_lun_append_task(task->lun, task) == 0) {
|
if (spdk_scsi_lun_append_task(task->lun, task) == 0) {
|
||||||
/* ready to execute, disk is valid for LUN access */
|
/* ready to execute, disk is valid for LUN access */
|
||||||
spdk_scsi_lun_execute_tasks(task->lun);
|
spdk_scsi_lun_execute_tasks(task->lun);
|
||||||
|
@ -46,7 +46,7 @@ spdk_scsi_lun_complete_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *ta
|
|||||||
TAILQ_REMOVE(&lun->tasks, task, scsi_link);
|
TAILQ_REMOVE(&lun->tasks, task, scsi_link);
|
||||||
spdk_trace_record(TRACE_SCSI_TASK_DONE, lun->dev->id, 0, (uintptr_t)task, 0);
|
spdk_trace_record(TRACE_SCSI_TASK_DONE, lun->dev->id, 0, (uintptr_t)task, 0);
|
||||||
}
|
}
|
||||||
spdk_event_call(task->cb_event);
|
task->cpl_fn(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -56,7 +56,7 @@ spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_tas
|
|||||||
task->status == SPDK_SCSI_STATUS_GOOD) {
|
task->status == SPDK_SCSI_STATUS_GOOD) {
|
||||||
spdk_scsi_lun_clear_all(task->lun);
|
spdk_scsi_lun_clear_all(task->lun);
|
||||||
}
|
}
|
||||||
spdk_event_call(task->cb_event);
|
task->cpl_fn(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -66,10 +66,15 @@ spdk_scsi_task_put(struct spdk_scsi_task *task)
|
|||||||
|
|
||||||
void
|
void
|
||||||
spdk_scsi_task_construct(struct spdk_scsi_task *task,
|
spdk_scsi_task_construct(struct spdk_scsi_task *task,
|
||||||
void (*free_fn)(struct spdk_scsi_task *task),
|
spdk_scsi_task_cpl cpl_fn,
|
||||||
|
spdk_scsi_task_free free_fn,
|
||||||
struct spdk_scsi_task *parent)
|
struct spdk_scsi_task *parent)
|
||||||
{
|
{
|
||||||
|
assert(task != NULL);
|
||||||
|
assert(cpl_fn != NULL);
|
||||||
assert(free_fn != NULL);
|
assert(free_fn != NULL);
|
||||||
|
|
||||||
|
task->cpl_fn = cpl_fn;
|
||||||
task->free_fn = free_fn;
|
task->free_fn = free_fn;
|
||||||
|
|
||||||
task->ref++;
|
task->ref++;
|
||||||
|
@ -43,11 +43,6 @@
|
|||||||
#include "spdk/vhost.h"
|
#include "spdk/vhost.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#undef container_of
|
|
||||||
#define container_of(ptr, type, member) ({ \
|
|
||||||
typeof(((type *)0)->member) *__mptr = (ptr); \
|
|
||||||
(type *)((char *)__mptr - offsetof(type, member)); })
|
|
||||||
|
|
||||||
static struct rte_mempool *g_task_pool;
|
static struct rte_mempool *g_task_pool;
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -66,7 +61,7 @@ spdk_vhost_task_free_cb(struct spdk_scsi_task *scsi_task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_vhost_task *
|
struct spdk_vhost_task *
|
||||||
spdk_vhost_task_get(struct spdk_vhost_scsi_dev *vdev)
|
spdk_vhost_task_get(struct spdk_vhost_scsi_dev *vdev, spdk_scsi_task_cpl cpl_fn)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_task *task;
|
struct spdk_vhost_task *task;
|
||||||
int rc;
|
int rc;
|
||||||
@ -80,7 +75,10 @@ spdk_vhost_task_get(struct spdk_vhost_scsi_dev *vdev)
|
|||||||
memset(task, 0, sizeof(*task));
|
memset(task, 0, sizeof(*task));
|
||||||
task->svdev = vdev;
|
task->svdev = vdev;
|
||||||
spdk_vhost_dev_task_ref((struct spdk_vhost_dev *) task->svdev);
|
spdk_vhost_dev_task_ref((struct spdk_vhost_dev *) task->svdev);
|
||||||
spdk_scsi_task_construct(&task->scsi, spdk_vhost_task_free_cb, NULL);
|
spdk_scsi_task_construct(&task->scsi,
|
||||||
|
cpl_fn,
|
||||||
|
spdk_vhost_task_free_cb,
|
||||||
|
NULL);
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
|
|
||||||
#include "spdk/scsi.h"
|
#include "spdk/scsi.h"
|
||||||
|
|
||||||
|
#undef container_of
|
||||||
|
#define container_of(ptr, type, member) ({ \
|
||||||
|
typeof(((type *)0)->member) *__mptr = (ptr); \
|
||||||
|
(type *)((char *)__mptr - offsetof(type, member)); })
|
||||||
|
|
||||||
/* Allocated iovec buffer len */
|
/* Allocated iovec buffer len */
|
||||||
#define VHOST_SCSI_IOVS_LEN 128
|
#define VHOST_SCSI_IOVS_LEN 128
|
||||||
|
|
||||||
@ -59,9 +64,13 @@ struct spdk_vhost_task {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void spdk_vhost_task_put(struct spdk_vhost_task *task);
|
void spdk_vhost_task_put(struct spdk_vhost_task *task);
|
||||||
struct spdk_vhost_task *spdk_vhost_task_get(struct spdk_vhost_scsi_dev *vdev);
|
struct spdk_vhost_task *spdk_vhost_task_get(struct spdk_vhost_scsi_dev *vdev,
|
||||||
|
spdk_scsi_task_cpl cpl_fn);
|
||||||
|
|
||||||
void spdk_vhost_dev_task_ref(struct spdk_vhost_dev *vdev);
|
void spdk_vhost_dev_task_ref(struct spdk_vhost_dev *vdev);
|
||||||
void spdk_vhost_dev_task_unref(struct spdk_vhost_dev *vdev);
|
void spdk_vhost_dev_task_unref(struct spdk_vhost_dev *vdev);
|
||||||
|
|
||||||
|
void spdk_vhost_task_cpl(struct spdk_scsi_task *scsi_task);
|
||||||
|
void spdk_vhost_task_mgmt_cpl(struct spdk_scsi_task *scsi_task);
|
||||||
|
|
||||||
#endif /* SPDK_VHOST_TASK_H */
|
#endif /* SPDK_VHOST_TASK_H */
|
||||||
|
@ -106,18 +106,18 @@ submit_completion(struct spdk_vhost_task *task)
|
|||||||
spdk_vhost_task_put(task);
|
spdk_vhost_task_put(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
process_mgmt_task_completion(void *arg1, void *arg2)
|
spdk_vhost_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_task *task = arg1;
|
struct spdk_vhost_task *task = container_of(scsi_task, struct spdk_vhost_task, scsi);
|
||||||
|
|
||||||
submit_completion(task);
|
submit_completion(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
process_task_completion(void *arg1, void *arg2)
|
spdk_vhost_task_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_task *task = arg1;
|
struct spdk_vhost_task *task = container_of(scsi_task, struct spdk_vhost_task, scsi);
|
||||||
|
|
||||||
/* The SCSI task has completed. Do final processing and then post
|
/* The SCSI task has completed. Do final processing and then post
|
||||||
notification to the virtqueue's "used" ring.
|
notification to the virtqueue's "used" ring.
|
||||||
@ -137,14 +137,11 @@ static void
|
|||||||
task_submit(struct spdk_vhost_task *task)
|
task_submit(struct spdk_vhost_task *task)
|
||||||
{
|
{
|
||||||
/* The task is ready to be submitted. First create the callback event that
|
/* The task is ready to be submitted. First create the callback event that
|
||||||
will be invoked when the SCSI command is completed. See process_task_completion()
|
will be invoked when the SCSI command is completed. See spdk_vhost_task_cpl()
|
||||||
for what SPDK vhost-scsi does when the task is completed.
|
for what SPDK vhost-scsi does when the task is completed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
task->resp->response = VIRTIO_SCSI_S_OK;
|
task->resp->response = VIRTIO_SCSI_S_OK;
|
||||||
task->scsi.cb_event = spdk_event_allocate(rte_lcore_id(),
|
|
||||||
process_task_completion,
|
|
||||||
task, NULL);
|
|
||||||
spdk_scsi_dev_queue_task(task->scsi_dev, &task->scsi);
|
spdk_scsi_dev_queue_task(task->scsi_dev, &task->scsi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,9 +149,6 @@ static void
|
|||||||
mgmt_task_submit(struct spdk_vhost_task *task, enum spdk_scsi_task_func func)
|
mgmt_task_submit(struct spdk_vhost_task *task, enum spdk_scsi_task_func func)
|
||||||
{
|
{
|
||||||
task->tmf_resp->response = VIRTIO_SCSI_S_OK;
|
task->tmf_resp->response = VIRTIO_SCSI_S_OK;
|
||||||
task->scsi.cb_event = spdk_event_allocate(rte_lcore_id(),
|
|
||||||
process_mgmt_task_completion,
|
|
||||||
task, NULL);
|
|
||||||
spdk_scsi_dev_queue_mgmt_task(task->scsi_dev, &task->scsi, func);
|
spdk_scsi_dev_queue_mgmt_task(task->scsi_dev, &task->scsi, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +202,7 @@ process_ctrl_request(struct spdk_vhost_scsi_dev *svdev, struct rte_vhost_vring *
|
|||||||
SPDK_TRACEDUMP(SPDK_TRACE_VHOST_SCSI_QUEUE, "Request desriptor", (uint8_t *)ctrl_req,
|
SPDK_TRACEDUMP(SPDK_TRACE_VHOST_SCSI_QUEUE, "Request desriptor", (uint8_t *)ctrl_req,
|
||||||
desc->len);
|
desc->len);
|
||||||
|
|
||||||
task = spdk_vhost_task_get(svdev);
|
task = spdk_vhost_task_get(svdev, spdk_vhost_task_mgmt_cpl);
|
||||||
task->vq = controlq;
|
task->vq = controlq;
|
||||||
task->svdev = svdev;
|
task->svdev = svdev;
|
||||||
task->req_idx = req_idx;
|
task->req_idx = req_idx;
|
||||||
@ -429,7 +423,7 @@ process_requestq(struct spdk_vhost_scsi_dev *svdev, struct rte_vhost_vring *vq)
|
|||||||
assert(reqs_cnt <= 32);
|
assert(reqs_cnt <= 32);
|
||||||
|
|
||||||
for (i = 0; i < reqs_cnt; i++) {
|
for (i = 0; i < reqs_cnt; i++) {
|
||||||
task = spdk_vhost_task_get(svdev);
|
task = spdk_vhost_task_get(svdev, spdk_vhost_task_cpl);
|
||||||
|
|
||||||
SPDK_TRACELOG(SPDK_TRACE_VHOST_SCSI, "====== Starting processing request idx %"PRIu16"======\n",
|
SPDK_TRACELOG(SPDK_TRACE_VHOST_SCSI, "====== Starting processing request idx %"PRIu16"======\n",
|
||||||
reqs[i]);
|
reqs[i]);
|
||||||
@ -442,7 +436,7 @@ process_requestq(struct spdk_vhost_scsi_dev *svdev, struct rte_vhost_vring *vq)
|
|||||||
SPDK_TRACELOG(SPDK_TRACE_VHOST_SCSI, "====== Task %p req_idx %d submitted ======\n", task,
|
SPDK_TRACELOG(SPDK_TRACE_VHOST_SCSI, "====== Task %p req_idx %d submitted ======\n", task,
|
||||||
task->req_idx);
|
task->req_idx);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
process_task_completion(task, NULL);
|
spdk_vhost_task_cpl(&task->scsi);
|
||||||
SPDK_TRACELOG(SPDK_TRACE_VHOST_SCSI, "====== Task %p req_idx %d finished early ======\n", task,
|
SPDK_TRACELOG(SPDK_TRACE_VHOST_SCSI, "====== Task %p req_idx %d finished early ======\n", task,
|
||||||
task->req_idx);
|
task->req_idx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
SPDK_LOG_REGISTER_TRACE_FLAG("iscsi", SPDK_TRACE_ISCSI)
|
SPDK_LOG_REGISTER_TRACE_FLAG("iscsi", SPDK_TRACE_ISCSI)
|
||||||
|
|
||||||
struct spdk_iscsi_task *
|
struct spdk_iscsi_task *
|
||||||
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent)
|
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn,
|
||||||
|
struct spdk_iscsi_task *parent,
|
||||||
|
spdk_scsi_task_cpl cpl_fn)
|
||||||
{
|
{
|
||||||
struct spdk_iscsi_task *task;
|
struct spdk_iscsi_task *task;
|
||||||
|
|
||||||
@ -130,13 +132,15 @@ spdk_shutdown_iscsi_conns(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
process_task_completion(void *arg1, void *arg2)
|
spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
process_task_mgmt_completion(void *arg1, void *arg2)
|
spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -75,6 +75,11 @@ void spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
@ -93,7 +98,9 @@ spdk_get_task(uint32_t *owner_task_ctr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_scsi_task_construct(task, spdk_lun_ut_free_task, NULL);
|
spdk_scsi_task_construct(task, spdk_lun_ut_cpl_task,
|
||||||
|
spdk_lun_ut_free_task,
|
||||||
|
NULL);
|
||||||
g_task_count++;
|
g_task_count++;
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
|
Loading…
Reference in New Issue
Block a user