event: pass arg1 and arg2 directly to event fn

This allows the elimination of the spdk_event_get_arg1() and
spdk_event_get_arg2() macros, which accessed the event structure
directly; this was preventing the event structure definition from being
moved out of the public API header.

Change-Id: I74eced799ad7df61ff0b1390c63fb533e3fae8eb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2017-01-04 18:19:02 -07:00 committed by Ben Walker
parent 3d528833d5
commit 44ef085bed
17 changed files with 84 additions and 91 deletions

View File

@ -85,7 +85,7 @@ usage(char *executable_name)
}
static void
spdk_startup(spdk_event_t event)
spdk_startup(void *arg1, void *arg2)
{
if (getenv("MEMZONE_DUMP") != NULL) {
spdk_memzone_dump(stdout);

View File

@ -64,9 +64,9 @@ shutdown_complete(void)
}
static void
subsystem_delete_event(struct spdk_event *event)
subsystem_delete_event(void *arg1, void *arg2)
{
struct nvmf_tgt_subsystem *app_subsys = spdk_event_get_arg1(event);
struct nvmf_tgt_subsystem *app_subsys = arg1;
struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem;
TAILQ_REMOVE(&g_subsystems, app_subsys, tailq);
@ -116,7 +116,7 @@ shutdown_subsystems(void)
}
static void
acceptor_poller_unregistered_event(struct spdk_event *event)
acceptor_poller_unregistered_event(void *arg1, void *arg2)
{
spdk_nvmf_tgt_fini();
shutdown_subsystems();
@ -145,9 +145,9 @@ subsystem_poll(void *arg)
}
static void
connect_event(struct spdk_event *event)
connect_event(void *arg1, void *arg2)
{
struct spdk_nvmf_request *req = spdk_event_get_arg1(event);
struct spdk_nvmf_request *req = arg1;
spdk_nvmf_handle_connect(req);
}
@ -164,9 +164,9 @@ connect_cb(void *cb_ctx, struct spdk_nvmf_request *req)
}
static void
disconnect_event(struct spdk_event *event)
disconnect_event(void *arg1, void *arg2)
{
struct spdk_nvmf_conn *conn = spdk_event_get_arg1(event);
struct spdk_nvmf_conn *conn = arg1;
spdk_nvmf_session_disconnect(conn);
}
@ -183,9 +183,9 @@ disconnect_cb(void *cb_ctx, struct spdk_nvmf_conn *conn)
}
static void
_nvmf_tgt_start_subsystem(struct spdk_event *event)
_nvmf_tgt_start_subsystem(void *arg1, void *arg2)
{
struct nvmf_tgt_subsystem *app_subsys = spdk_event_get_arg1(event);
struct nvmf_tgt_subsystem *app_subsys = arg1;
struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem;
struct spdk_bdev *bdev;
struct spdk_io_channel *ch;
@ -326,7 +326,7 @@ acceptor_poll(void *arg)
}
static void
spdk_nvmf_startup(spdk_event_t event)
spdk_nvmf_startup(void *arg1, void *arg2)
{
int rc;

View File

@ -81,7 +81,7 @@
#include "spdk/queue.h"
typedef struct spdk_event *spdk_event_t;
typedef void (*spdk_event_fn)(spdk_event_t);
typedef void (*spdk_event_fn)(void *arg1, void *arg2);
/**
* \brief An event is a function that is passed to and called on an lcore.
@ -214,9 +214,6 @@ spdk_event_t spdk_event_allocate(uint32_t lcore, spdk_event_fn fn,
*/
void spdk_event_call(spdk_event_t event);
#define spdk_event_get_arg1(event) (event)->arg1
#define spdk_event_get_arg2(event) (event)->arg2
/* TODO: This is only used by tests and should be made private */
uint32_t spdk_event_queue_run_batch(uint32_t lcore);

View File

@ -210,7 +210,7 @@ __shutdown_signal(int signo)
}
static void
__shutdown_event_cb(spdk_event_t event)
__shutdown_event_cb(void *arg1, void *arg2)
{
g_spdk_app.shutdown_cb();
}

View File

@ -200,7 +200,7 @@ spdk_event_queue_run_batch(uint32_t lcore)
for (i = 0; i < count; i++) {
struct spdk_event *event = events[i];
event->fn(event);
event->fn(event->arg1, event->arg2);
}
spdk_mempool_put_bulk(g_spdk_event_mempool[socket_id], events, count);
@ -635,10 +635,10 @@ _spdk_poller_register(struct spdk_reactor *reactor, struct spdk_poller *poller)
}
static void
_spdk_event_add_poller(spdk_event_t event)
_spdk_event_add_poller(void *arg1, void *arg2)
{
struct spdk_reactor *reactor = spdk_event_get_arg1(event);
struct spdk_poller *poller = spdk_event_get_arg2(event);
struct spdk_reactor *reactor = arg1;
struct spdk_poller *poller = arg2;
_spdk_poller_register(reactor, poller);
}
@ -719,11 +719,11 @@ _spdk_poller_unregister(struct spdk_reactor *reactor, struct spdk_poller *poller
}
static void
_spdk_event_remove_poller(spdk_event_t event)
_spdk_event_remove_poller(void *arg1, void *arg2)
{
struct spdk_poller *poller = spdk_event_get_arg1(event);
struct spdk_poller *poller = arg1;
struct spdk_reactor *reactor = spdk_reactor_get(poller->lcore);
struct spdk_event *next = event->next;
struct spdk_event *next = arg2;
_spdk_poller_unregister(reactor, poller, next);
}
@ -759,7 +759,7 @@ spdk_poller_unregister(struct spdk_poller **ppoller,
* The poller is registered on a different core.
* Schedule an event to run on the poller's core that will remove the poller.
*/
spdk_event_call(spdk_event_allocate(lcore, _spdk_event_remove_poller, poller, NULL,
complete));
spdk_event_call(spdk_event_allocate(lcore, _spdk_event_remove_poller, poller, complete,
NULL));
}
}

View File

@ -81,7 +81,7 @@ static pthread_mutex_t g_conns_mutex;
static struct spdk_poller *g_shutdown_timer = NULL;
static uint32_t spdk_iscsi_conn_allocate_reactor(uint64_t cpumask);
static void __add_idle_conn(spdk_event_t event);
static void __add_idle_conn(void *arg1, void *arg2);
/** Global variables used for managing idle connections. */
static int g_epoll_fd = 0;
@ -92,7 +92,7 @@ void spdk_iscsi_conn_login_do_work(void *arg);
void spdk_iscsi_conn_full_feature_do_work(void *arg);
void spdk_iscsi_conn_idle_do_work(void *arg);
static void spdk_iscsi_conn_full_feature_migrate(struct spdk_event *event);
static void spdk_iscsi_conn_full_feature_migrate(void *arg1, void *arg2);
static struct spdk_event *spdk_iscsi_conn_get_migrate_event(struct spdk_iscsi_conn *conn,
int *lcore);
static void spdk_iscsi_conn_stop_poller(struct spdk_iscsi_conn *conn, spdk_event_fn fn_after_stop,
@ -559,10 +559,9 @@ spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
}
static void
_spdk_iscsi_conn_free(spdk_event_t event)
_spdk_iscsi_conn_free(void *arg1, void *arg2)
{
struct spdk_iscsi_conn *conn = spdk_event_get_arg1(event);
struct spdk_iscsi_conn *conn = arg1;
pthread_mutex_lock(&g_conns_mutex);
spdk_iscsi_remove_conn(conn);
@ -854,10 +853,10 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
}
void
process_task_mgmt_completion(spdk_event_t event)
process_task_mgmt_completion(void *arg1, void *arg2)
{
struct spdk_iscsi_conn *conn = spdk_event_get_arg1(event);
struct spdk_iscsi_task *task = spdk_event_get_arg2(event);
struct spdk_iscsi_conn *conn = arg1;
struct spdk_iscsi_task *task = arg2;
conn->last_activity_tsc = spdk_get_ticks();
spdk_iscsi_task_mgmt_response(conn, task);
@ -916,10 +915,10 @@ process_read_task_completion(struct spdk_iscsi_conn *conn,
process_completed_read_subtask_list(conn, primary);
}
void process_task_completion(spdk_event_t event)
void process_task_completion(void *arg1, void *arg2)
{
struct spdk_iscsi_conn *conn = spdk_event_get_arg1(event);
struct spdk_iscsi_task *task = spdk_event_get_arg2(event);
struct spdk_iscsi_conn *conn = arg1;
struct spdk_iscsi_task *task = arg2;
struct spdk_iscsi_task *primary;
assert(task != NULL);
@ -1287,9 +1286,9 @@ conn_exit:
}
static void
spdk_iscsi_conn_full_feature_migrate(struct spdk_event *event)
spdk_iscsi_conn_full_feature_migrate(void *arg1, void *arg2)
{
struct spdk_iscsi_conn *conn = spdk_event_get_arg1(event);
struct spdk_iscsi_conn *conn = arg1;
if (conn->sess->session_type == SESSION_TYPE_NORMAL) {
assert(conn->dev != NULL);
@ -1405,9 +1404,9 @@ void spdk_iscsi_conn_idle_do_work(void *arg)
}
static void
__add_idle_conn(spdk_event_t e)
__add_idle_conn(void *arg1, void *arg2)
{
struct spdk_iscsi_conn *conn = spdk_event_get_arg1(e);
struct spdk_iscsi_conn *conn = arg1;
int rc;
/*

View File

@ -357,8 +357,8 @@ int spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
int alloc_len, int data_len);
int spdk_iscsi_copy_param2var(struct spdk_iscsi_conn *conn);
void process_task_completion(spdk_event_t event);
void process_task_mgmt_completion(spdk_event_t event);
void process_task_completion(void *arg1, void *arg2);
void process_task_mgmt_completion(void *arg1, void *arg2);
/* Memory management */
void spdk_put_pdu(struct spdk_iscsi_pdu *pdu);

View File

@ -929,7 +929,7 @@ spdk_iscsi_app_read_parameters(void)
}
static void
spdk_iscsi_setup(struct spdk_event *event)
spdk_iscsi_setup(void *arg1, void *arg2)
{
int rc;

View File

@ -118,10 +118,10 @@ nvmf_virtual_ctrlr_poll_for_completions(struct spdk_nvmf_session *session)
}
static void
nvmf_virtual_ctrlr_complete_cmd(spdk_event_t event)
nvmf_virtual_ctrlr_complete_cmd(void *arg1, void *arg2)
{
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct spdk_nvmf_request *req = spdk_event_get_arg1(event);
struct spdk_bdev_io *bdev_io = arg2;
struct spdk_nvmf_request *req = arg1;
enum spdk_bdev_io_status status = bdev_io->status;
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;

View File

@ -244,7 +244,7 @@ spdk_rpc_initialize(void)
}
static void
spdk_rpc_finish_cleanup(struct spdk_event *event)
spdk_rpc_finish_cleanup(void *arg1, void *arg2)
{
if (g_jsonrpc_server) {
spdk_jsonrpc_server_shutdown(g_jsonrpc_server);

View File

@ -1222,10 +1222,10 @@ spdk_bdev_scsi_mode_select_page(struct spdk_bdev *bdev,
}
static void
spdk_bdev_scsi_task_complete(spdk_event_t event)
spdk_bdev_scsi_task_complete(void *arg1, void *arg2)
{
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct spdk_scsi_task *task = spdk_event_get_arg1(event);
struct spdk_bdev_io *bdev_io = arg2;
struct spdk_scsi_task *task = arg1;
enum spdk_bdev_io_status status = bdev_io->status;
if (task->type == SPDK_SCSI_TASK_TYPE_CMD) {

View File

@ -118,10 +118,10 @@ initialize_buffer(char **buf, int pattern, int size)
}
static void
quick_test_complete(spdk_event_t event)
quick_test_complete(void *arg1, void *arg2)
{
struct bdevio_request *req = spdk_event_get_arg1(event);
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct bdevio_request *req = arg1;
struct spdk_bdev_io *bdev_io = arg2;
if (req->target->ch) {
spdk_put_io_channel(req->target->ch);
@ -133,9 +133,9 @@ quick_test_complete(spdk_event_t event)
}
static void
__blockdev_write(spdk_event_t event)
__blockdev_write(void *arg1, void *arg2)
{
struct bdevio_request *req = spdk_event_get_arg1(event);
struct bdevio_request *req = arg1;
struct io_target *target = req->target;
struct spdk_bdev_io *bdev_io;
@ -203,9 +203,9 @@ blockdev_write(struct io_target *target, char *tx_buf,
}
static void
__blockdev_read(spdk_event_t event)
__blockdev_read(void *arg1, void *arg2)
{
struct bdevio_request *req = spdk_event_get_arg1(event);
struct bdevio_request *req = arg1;
struct io_target *target = req->target;
struct spdk_bdev_io *bdev_io;
@ -621,10 +621,10 @@ blockdev_overlapped_write_read_8k(void)
}
static void
__blockdev_reset(spdk_event_t event)
__blockdev_reset(void *arg1, void *arg2)
{
struct bdevio_request *req = spdk_event_get_arg1(event);
enum spdk_bdev_reset_type *reset_type = spdk_event_get_arg2(event);
struct bdevio_request *req = arg1;
enum spdk_bdev_reset_type *reset_type = arg2;
struct io_target *target = req->target;
int rc;
@ -676,7 +676,7 @@ blockdev_test_reset(void)
}
static void
test_main(spdk_event_t event)
test_main(void *arg1, void *arg2)
{
CU_pSuite suite = NULL;
unsigned int num_failures;

View File

@ -163,7 +163,7 @@ bdevperf_construct_targets(void)
}
static void
end_run(spdk_event_t event)
end_run(void *arg1, void *arg2)
{
if (--g_target_count == 0) {
if (g_show_performance_real_time) {
@ -180,11 +180,11 @@ end_run(spdk_event_t event)
struct rte_mempool *task_pool;
static void
bdevperf_complete(spdk_event_t event)
bdevperf_complete(void *arg1, void *arg2)
{
struct io_target *target;
struct bdevperf_task *task = spdk_event_get_arg1(event);
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct bdevperf_task *task = arg1;
struct spdk_bdev_io *bdev_io = arg2;
spdk_event_t complete;
target = task->target;
@ -227,11 +227,11 @@ bdevperf_complete(spdk_event_t event)
}
static void
bdevperf_unmap_complete(spdk_event_t event)
bdevperf_unmap_complete(void *arg1, void *arg2)
{
struct io_target *target;
struct bdevperf_task *task = spdk_event_get_arg1(event);
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct bdevperf_task *task = arg1;
struct spdk_bdev_io *bdev_io = arg2;
target = task->target;
@ -250,11 +250,11 @@ bdevperf_unmap_complete(spdk_event_t event)
}
static void
bdevperf_verify_write_complete(spdk_event_t event)
bdevperf_verify_write_complete(void *arg1, void *arg2)
{
struct io_target *target;
struct bdevperf_task *task = spdk_event_get_arg1(event);
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct bdevperf_task *task = arg1;
struct spdk_bdev_io *bdev_io = arg2;
target = task->target;
@ -365,9 +365,9 @@ end_target(void *arg)
static void reset_target(void *arg);
static void
reset_cb(spdk_event_t event)
reset_cb(void *arg1, void *arg2)
{
struct spdk_bdev_io *bdev_io = spdk_event_get_arg2(event);
struct spdk_bdev_io *bdev_io = arg2;
int status = bdev_io->status;
struct bdevperf_task *task = bdev_io->caller_ctx;
struct io_target *target = task->target;
@ -400,9 +400,9 @@ reset_target(void *arg)
}
static void
bdevperf_submit_on_core(spdk_event_t event)
bdevperf_submit_on_core(void *arg1, void *arg2)
{
struct io_target *target = spdk_event_get_arg1(event);
struct io_target *target = arg1;
/* Submit initial I/O for each block device. Each time one
* completes, another will be submitted. */
@ -481,7 +481,7 @@ performance_statistics_thread(void *arg)
}
static void
bdevperf_run(spdk_event_t evt)
bdevperf_run(void *arg1, void *arg2)
{
int i;
struct io_target *target;

View File

@ -55,8 +55,9 @@ static __thread uint64_t __call_count = 0;
static uint64_t call_count[RTE_MAX_LCORE];
static void
submit_new_event(spdk_event_t event)
submit_new_event(void *arg1, void *arg2)
{
struct spdk_event *event;
static __thread uint32_t next_lcore = RTE_MAX_LCORE;
if (next_lcore == RTE_MAX_LCORE) {
@ -75,10 +76,10 @@ event_work_fn(void *arg)
tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
submit_new_event(NULL);
submit_new_event(NULL);
submit_new_event(NULL);
submit_new_event(NULL);
submit_new_event(NULL, NULL);
submit_new_event(NULL, NULL);
submit_new_event(NULL, NULL);
submit_new_event(NULL, NULL);
while (1) {

View File

@ -74,7 +74,7 @@ nop(void *arg)
}
static void
test_start(spdk_event_t evt)
test_start(void *arg1, void *arg2)
{
printf("test_start\n");

View File

@ -129,12 +129,12 @@ spdk_shutdown_iscsi_conns(void)
}
void
process_task_completion(spdk_event_t event)
process_task_completion(void *arg1, void *arg2)
{
}
void
process_task_mgmt_completion(spdk_event_t event)
process_task_mgmt_completion(void *arg1, void *arg2)
{
}

View File

@ -473,7 +473,6 @@ inquiry_overflow_test(void)
static void
task_complete_test(void)
{
struct spdk_event event;
struct spdk_scsi_task task;
struct spdk_bdev_io bdev_io = {};
struct spdk_scsi_lun lun;
@ -484,12 +483,9 @@ task_complete_test(void)
TAILQ_INSERT_TAIL(&lun.tasks, &task, scsi_link);
task.lun = &lun;
event.arg1 = &task;
event.arg2 = &bdev_io;
task.type = SPDK_SCSI_TASK_TYPE_CMD;
bdev_io.status = SPDK_BDEV_IO_STATUS_SUCCESS;
spdk_bdev_scsi_task_complete(&event);
spdk_bdev_scsi_task_complete(&task, &bdev_io);
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_GOOD);
bdev_io.status = SPDK_BDEV_IO_STATUS_SCSI_ERROR;
@ -497,14 +493,14 @@ task_complete_test(void)
bdev_io.error.scsi.sk = SPDK_SCSI_SENSE_HARDWARE_ERROR;
bdev_io.error.scsi.asc = SPDK_SCSI_ASC_WARNING;
bdev_io.error.scsi.ascq = SPDK_SCSI_ASCQ_POWER_LOSS_EXPECTED;
spdk_bdev_scsi_task_complete(&event);
spdk_bdev_scsi_task_complete(&task, &bdev_io);
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(task.sense_data[2] & 0xf, SPDK_SCSI_SENSE_HARDWARE_ERROR);
CU_ASSERT_EQUAL(task.sense_data[12], SPDK_SCSI_ASC_WARNING);
CU_ASSERT_EQUAL(task.sense_data[13], SPDK_SCSI_ASCQ_POWER_LOSS_EXPECTED);
bdev_io.status = SPDK_BDEV_IO_STATUS_FAILED;
spdk_bdev_scsi_task_complete(&event);
spdk_bdev_scsi_task_complete(&task, &bdev_io);
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(task.sense_data[2] & 0xf, SPDK_SCSI_SENSE_ABORTED_COMMAND);
CU_ASSERT_EQUAL(task.sense_data[12], SPDK_SCSI_ASC_NO_ADDITIONAL_SENSE);