From a17ad921e271889bce46a687f02f597107bc6138 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 18 Aug 2016 09:45:50 -0700 Subject: [PATCH] Replace RTE_VERIFY with assert We already require the assert header from the C standard library, so use that instead of RTE_VERIFY to further isolate DPDK dependencies. Change-Id: I4a718af858c88aff6080e33e6c3dd533c077b8f4 Signed-off-by: Ben Walker --- lib/bdev/bdev.c | 10 +++++----- lib/copy/copy_engine.c | 7 +++---- lib/copy/ioat/copy_engine_ioat.c | 6 +++--- lib/event/app.c | 4 ++-- lib/event/dpdk_init.c | 1 - lib/event/reactor.c | 23 ++++++++++++++--------- lib/iscsi/conn.c | 14 +++++++------- lib/iscsi/iscsi.c | 8 +++----- lib/iscsi/iscsi_subsystem.c | 1 - lib/nvmf/rdma.c | 7 +++---- lib/rpc/rpc.c | 7 ++++--- lib/scsi/task.c | 5 ++--- lib/trace/trace.c | 16 ++++++++-------- test/lib/bdev/bdevio/bdevio.c | 1 - test/lib/bdev/bdevperf/bdevperf.c | 1 - test/lib/event/event/event.c | 1 - test/lib/memory/vtophys.c | 1 - 17 files changed, 54 insertions(+), 59 deletions(-) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index d64ba0103..cf9487a32 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -112,8 +112,8 @@ struct spdk_bdev *spdk_bdev_get_by_name(const char *bdev_name) static void spdk_bdev_io_set_rbuf(struct spdk_bdev_io *bdev_io, void *buf) { - RTE_VERIFY(bdev_io->get_rbuf_cb != NULL); - RTE_VERIFY(buf != NULL); + assert(bdev_io->get_rbuf_cb != NULL); + assert(buf != NULL); bdev_io->u.read.buf_unaligned = buf; bdev_io->u.read.buf = (void *)((unsigned long)((char *)buf + 512) & ~511UL); bdev_io->u.read.put_rbuf = true; @@ -447,7 +447,7 @@ spdk_bdev_io_submit(struct spdk_bdev_io *bdev_io) if (bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING) { cb_event = spdk_event_allocate(rte_lcore_id(), bdev_io->cb, bdev_io->caller_ctx, bdev_io, NULL); - RTE_VERIFY(cb_event != NULL); + assert(cb_event != NULL); } __submit_request(bdev, bdev_io, cb_event); @@ -791,7 +791,7 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta bdev_io->status = status; - RTE_VERIFY(bdev_io->cb_event != NULL); + assert(bdev_io->cb_event != NULL); spdk_event_call(bdev_io->cb_event); } @@ -822,7 +822,7 @@ spdk_bdev_unregister(struct spdk_bdev *bdev) void spdk_bdev_io_get_rbuf(struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_rbuf_cb cb) { - RTE_VERIFY(cb != NULL); + assert(cb != NULL); if (bdev_io->u.read.buf == NULL) { bdev_io->get_rbuf_cb = cb; diff --git a/lib/copy/copy_engine.c b/lib/copy/copy_engine.c index 5308839e8..4694f6f4e 100644 --- a/lib/copy/copy_engine.c +++ b/lib/copy/copy_engine.c @@ -33,11 +33,10 @@ #include "spdk/copy_engine.h" +#include #include #include -#include #include -#include #include #include "spdk/log.h" @@ -59,14 +58,14 @@ struct copy_io_channel { void spdk_copy_engine_register(struct spdk_copy_engine *copy_engine) { - RTE_VERIFY(hw_copy_engine == NULL); + assert(hw_copy_engine == NULL); hw_copy_engine = copy_engine; } static void spdk_memcpy_register(struct spdk_copy_engine *copy_engine) { - RTE_VERIFY(mem_copy_engine == NULL); + assert(mem_copy_engine == NULL); mem_copy_engine = copy_engine; } diff --git a/lib/copy/ioat/copy_engine_ioat.c b/lib/copy/ioat/copy_engine_ioat.c index 5acc66802..fa3ba4542 100644 --- a/lib/copy/ioat/copy_engine_ioat.c +++ b/lib/copy/ioat/copy_engine_ioat.c @@ -31,6 +31,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include @@ -38,7 +39,6 @@ #include #include #include -#include #include "spdk/copy_engine.h" #include "spdk/vtophys.h" @@ -168,7 +168,7 @@ ioat_copy_submit(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src, struct ioat_task *ioat_task = (struct ioat_task *)cb_arg; struct ioat_io_channel *ioat_ch = spdk_io_channel_get_ctx(ch); - RTE_VERIFY(ioat_ch->ioat_ch != NULL); + assert(ioat_ch->ioat_ch != NULL); ioat_task->cb = cb; @@ -183,7 +183,7 @@ ioat_copy_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8 struct ioat_io_channel *ioat_ch = spdk_io_channel_get_ctx(ch); uint64_t fill64 = 0x0101010101010101ULL * fill; - RTE_VERIFY(ioat_ch->ioat_ch != NULL); + assert(ioat_ch->ioat_ch != NULL); ioat_task->cb = cb; diff --git a/lib/event/app.c b/lib/event/app.c index bab54527c..9c558cfa0 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -33,6 +33,7 @@ #include "spdk/event.h" +#include #include #include #include @@ -46,7 +47,6 @@ #include #include -#include #include #include "spdk/log.h" @@ -246,7 +246,7 @@ spdk_app_init(struct spdk_app_opts *opts) } config = spdk_conf_allocate(); - RTE_VERIFY(config != NULL); + assert(config != NULL); if (opts->config_file) { rc = spdk_conf_read(config, opts->config_file); if (rc != 0) { diff --git a/lib/event/dpdk_init.c b/lib/event/dpdk_init.c index 0f2668330..4c44b627e 100644 --- a/lib/event/dpdk_init.c +++ b/lib/event/dpdk_init.c @@ -42,7 +42,6 @@ #include #include -#include #include #include #include diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 88735b493..41b029706 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -33,6 +33,7 @@ #include "spdk/event.h" +#include #include #include #include @@ -48,7 +49,6 @@ #include #include -#include #include #include #include @@ -131,10 +131,13 @@ spdk_event_allocate(uint32_t lcore, spdk_event_fn fn, void *arg1, void *arg2, struct spdk_event *event = NULL; int rc; uint8_t socket_id = rte_lcore_to_socket_id(lcore); - RTE_VERIFY(socket_id < SPDK_MAX_SOCKET); + assert(socket_id < SPDK_MAX_SOCKET); rc = rte_mempool_get(g_spdk_event_mempool[socket_id], (void **)&event); - RTE_VERIFY((rc == 0) && (event != NULL)); + if (rc != 0 || event == NULL) { + assert(false); + return NULL; + } event->lcore = lcore; event->fn = fn; @@ -149,7 +152,7 @@ static void spdk_event_free(uint32_t lcore, struct spdk_event *event) { uint8_t socket_id = rte_lcore_to_socket_id(lcore); - RTE_VERIFY(socket_id < SPDK_MAX_SOCKET); + assert(socket_id < SPDK_MAX_SOCKET); rte_mempool_put(g_spdk_event_mempool[socket_id], (void *)event); } @@ -162,9 +165,11 @@ spdk_event_call(spdk_event_t event) reactor = spdk_reactor_get(event->lcore); - RTE_VERIFY(reactor->events != NULL); + assert(reactor->events != NULL); rc = rte_ring_enqueue(reactor->events, event); - RTE_VERIFY(rc == 0); + if (rc != 0) { + assert(false); + } } static uint32_t @@ -190,7 +195,7 @@ spdk_event_queue_run_single(uint32_t lcore) reactor = spdk_reactor_get(lcore); - RTE_VERIFY(reactor->events != NULL); + assert(reactor->events != NULL); rc = rte_ring_dequeue(reactor->events, (void **)&event); if ((rc != 0) || event == NULL) { @@ -389,7 +394,7 @@ spdk_reactor_construct(struct spdk_reactor *reactor, uint32_t lcore, uint64_t ma snprintf(ring_name, sizeof(ring_name) - 1, "spdk_event_queue_%u", lcore); reactor->events = rte_ring_create(ring_name, 65536, rte_lcore_to_socket_id(lcore), RING_F_SC_DEQ); - RTE_VERIFY(reactor->events != NULL); + assert(reactor->events != NULL); } static void @@ -514,7 +519,7 @@ spdk_reactors_start(void) struct spdk_reactor *reactor; uint32_t i; - RTE_VERIFY(rte_get_master_lcore() == rte_lcore_id()); + assert(rte_get_master_lcore() == rte_lcore_id()); g_reactor_state = SPDK_REACTOR_STATE_RUNNING; diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index ff02d911a..441e9505e 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -141,7 +141,7 @@ spdk_find_iscsi_connection_by_id(int cid) static int init_idle_conns(void) { - RTE_VERIFY(g_epoll_fd == 0); + assert(g_epoll_fd == 0); g_epoll_fd = epoll_create1(0); if (g_epoll_fd < 0) { SPDK_ERRLOG("epoll_create1 failed master lcore\n"); @@ -213,7 +213,7 @@ check_idle_conns(void) if (nfds > SPDK_MAX_POLLERS_PER_CORE) { SPDK_ERRLOG("epoll_wait events exceeded limit! %d > %d\n", nfds, SPDK_MAX_POLLERS_PER_CORE); - RTE_VERIFY(0); + assert(0); } /* @@ -624,7 +624,7 @@ static void spdk_iscsi_conn_check_shutdown(struct rte_timer *timer, void *arg) { if (spdk_iscsi_get_active_conns() == 0) { - RTE_VERIFY(timer == &g_shutdown_timer); + assert(timer == &g_shutdown_timer); rte_timer_stop(timer); spdk_iscsi_conns_cleanup(); spdk_app_stop(0); @@ -686,7 +686,7 @@ spdk_iscsi_conn_stop_poller(struct spdk_iscsi_conn *conn, spdk_event_fn fn_after target->num_active_conns--; pthread_mutex_unlock(&target->mutex); - RTE_VERIFY(conn->dev != NULL); + assert(conn->dev != NULL); spdk_scsi_dev_free_io_channels(conn->dev); } rte_atomic32_dec(&g_num_connections[spdk_app_get_current_core()]); @@ -906,7 +906,7 @@ void process_task_completion(spdk_event_t event) struct spdk_iscsi_task *task = spdk_event_get_arg2(event); struct spdk_iscsi_task *primary; - RTE_VERIFY(task != NULL); + assert(task != NULL); spdk_trace_record(TRACE_ISCSI_TASK_DONE, conn->id, 0, (uintptr_t)task, 0); conn->last_activity_tsc = rte_get_timer_cycles(); @@ -1274,7 +1274,7 @@ spdk_iscsi_conn_full_feature_migrate(struct spdk_event *event) struct spdk_iscsi_conn *conn = spdk_event_get_arg1(event); if (conn->sess->session_type == SESSION_TYPE_NORMAL) { - RTE_VERIFY(conn->dev != NULL); + assert(conn->dev != NULL); spdk_scsi_dev_allocate_io_channels(conn->dev); } @@ -1356,7 +1356,7 @@ void spdk_iscsi_conn_idle_do_work(void *arg) /* Now walk the idle list to process timer based actions */ STAILQ_FOREACH(tconn, &g_idle_conn_list_head, link) { - RTE_VERIFY(tconn->is_idle == 1); + assert(tconn->is_idle == 1); if (tconn->pending_activate_event == false) { tsc = rte_get_timer_cycles(); diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 193933735..01aa3a6b1 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -52,7 +52,6 @@ #include #include -#include #include #include #include @@ -64,7 +63,6 @@ #include #include #include -#include #include #include #include @@ -359,7 +357,7 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu) /* AHS */ ahs_len = pdu->bhs.total_ahs_len * 4; - RTE_VERIFY(ahs_len <= ISCSI_AHS_LEN); + assert(ahs_len <= ISCSI_AHS_LEN); if (pdu->ahs_valid_bytes < ahs_len) { rc = spdk_iscsi_conn_read_data(conn, ahs_len - pdu->ahs_valid_bytes, @@ -2859,7 +2857,7 @@ int spdk_iscsi_conn_handle_queued_tasks(struct spdk_iscsi_conn *conn) remaining_size = task->scsi.transfer_len - task->current_datain_offset; subtask = spdk_iscsi_task_get(&conn->pending_task_cnt, task); - RTE_VERIFY(subtask != NULL); + assert(subtask != NULL); subtask->scsi.offset = task->current_datain_offset; subtask->scsi.length = DMIN32(SPDK_BDEV_LARGE_RBUF_MAX_SIZE, remaining_size); subtask->scsi.rbuf = NULL; @@ -4592,7 +4590,7 @@ spdk_get_iscsi_sess_by_tsih(uint16_t tsih) } session = g_spdk_iscsi.session[tsih - 1]; - RTE_VERIFY(tsih == session->tsih); + assert(tsih == session->tsih); return session; } diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index 3b7ebf680..d93f950ed 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index 35c9ed695..6c8ddb8a8 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -41,7 +41,6 @@ #include #include -#include #include #include #include @@ -326,8 +325,8 @@ nvmf_ibv_send_wr_init(struct ibv_send_wr *wr, int send_flags) { struct spdk_nvmf_rdma_request *rdma_req = get_rdma_req(req); - RTE_VERIFY(wr != NULL); - RTE_VERIFY(sg_list != NULL); + assert(wr != NULL); + assert(sg_list != NULL); wr->wr_id = (uint64_t)rdma_req; wr->opcode = opcode; @@ -341,7 +340,7 @@ nvmf_ibv_send_wr_set_rkey(struct ibv_send_wr *wr, struct spdk_nvmf_request *req) { struct spdk_nvme_sgl_descriptor *sgl = &req->cmd->nvme_cmd.dptr.sgl1; - RTE_VERIFY(sgl->generic.type == SPDK_NVME_SGL_TYPE_KEYED_DATA_BLOCK); + assert(sgl->generic.type == SPDK_NVME_SGL_TYPE_KEYED_DATA_BLOCK); wr->wr.rdma.rkey = sgl->keyed.key; wr->wr.rdma.remote_addr = sgl->address; diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index a88f167aa..945c599f6 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -31,6 +31,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -104,10 +105,10 @@ spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func) struct spdk_rpc_method *m; m = calloc(1, sizeof(struct spdk_rpc_method)); - RTE_VERIFY(m != NULL); + assert(m != NULL); m->name = strdup(method); - RTE_VERIFY(m->name != NULL); + assert(m->name != NULL); m->func = func; @@ -124,7 +125,7 @@ spdk_jsonrpc_handler( { struct spdk_rpc_method *m; - RTE_VERIFY(method != NULL); + assert(method != NULL); SLIST_FOREACH(m, &g_rpc_methods, slist) { if (spdk_json_strequal(method, m->name)) { diff --git a/lib/scsi/task.c b/lib/scsi/task.c index a77d3fc0e..f2fdaa88f 100644 --- a/lib/scsi/task.c +++ b/lib/scsi/task.c @@ -36,7 +36,6 @@ #include "spdk/endian.h" #include -#include #include void @@ -68,7 +67,7 @@ spdk_put_task(struct spdk_scsi_task *task) task->rbuf = NULL; - RTE_VERIFY(task->owner_task_ctr != NULL); + assert(task->owner_task_ctr != NULL); if (*(task->owner_task_ctr) > 0) { *(task->owner_task_ctr) -= 1; } else { @@ -85,7 +84,7 @@ spdk_scsi_task_construct(struct spdk_scsi_task *task, uint32_t *owner_task_ctr, { task->ref++; - RTE_VERIFY(owner_task_ctr != NULL); + assert(owner_task_ctr != NULL); task->owner_task_ctr = owner_task_ctr; *owner_task_ctr += 1; diff --git a/lib/trace/trace.c b/lib/trace/trace.c index 0cb7a9959..266c05c98 100644 --- a/lib/trace/trace.c +++ b/lib/trace/trace.c @@ -33,9 +33,9 @@ #include "spdk/trace.h" +#include #include #include - #include #include #include @@ -211,13 +211,13 @@ spdk_trace_register_owner(uint8_t type, char id_prefix) { struct spdk_trace_owner *owner; - RTE_VERIFY(type != OWNER_NONE); + assert(type != OWNER_NONE); /* 'owner' has 256 entries and since 'type' is a uint8_t, it * can't overrun the array. */ owner = &g_trace_histories->owner[type]; - RTE_VERIFY(owner->type == 0); + assert(owner->type == 0); owner->type = type; owner->id_prefix = id_prefix; @@ -228,13 +228,13 @@ spdk_trace_register_object(uint8_t type, char id_prefix) { struct spdk_trace_object *object; - RTE_VERIFY(type != OBJECT_NONE); + assert(type != OBJECT_NONE); /* 'object' has 256 entries and since 'type' is a uint8_t, it * can't overrun the array. */ object = &g_trace_histories->object[type]; - RTE_VERIFY(object->type == 0); + assert(object->type == 0); object->type = type; object->id_prefix = id_prefix; @@ -249,11 +249,11 @@ spdk_trace_register_description(const char *name, const char *short_name, { struct spdk_trace_tpoint *tpoint; - RTE_VERIFY(tpoint_id != 0); - RTE_VERIFY(tpoint_id < SPDK_TRACE_MAX_TPOINT_ID); + assert(tpoint_id != 0); + assert(tpoint_id < SPDK_TRACE_MAX_TPOINT_ID); tpoint = &g_trace_histories->tpoint[tpoint_id]; - RTE_VERIFY(tpoint->tpoint_id == 0); + assert(tpoint->tpoint_id == 0); strncpy(tpoint->name, name, sizeof(tpoint->name)); strncpy(tpoint->short_name, short_name, sizeof(tpoint->short_name)); diff --git a/test/lib/bdev/bdevio/bdevio.c b/test/lib/bdev/bdevio/bdevio.c index b3c5e6dc8..3de231c58 100644 --- a/test/lib/bdev/bdevio/bdevio.c +++ b/test/lib/bdev/bdevio/bdevio.c @@ -38,7 +38,6 @@ #include #include -#include #include #include diff --git a/test/lib/bdev/bdevperf/bdevperf.c b/test/lib/bdev/bdevperf/bdevperf.c index 9047f6d2e..6011cf3ea 100644 --- a/test/lib/bdev/bdevperf/bdevperf.c +++ b/test/lib/bdev/bdevperf/bdevperf.c @@ -40,7 +40,6 @@ #include #include -#include #include #include #include diff --git a/test/lib/event/event/event.c b/test/lib/event/event/event.c index cbaa82789..145958850 100644 --- a/test/lib/event/event/event.c +++ b/test/lib/event/event/event.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include diff --git a/test/lib/memory/vtophys.c b/test/lib/memory/vtophys.c index 3eff06ad4..27adcf503 100644 --- a/test/lib/memory/vtophys.c +++ b/test/lib/memory/vtophys.c @@ -37,7 +37,6 @@ #include #include -#include #include #include