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 <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-08-18 09:45:50 -07:00
parent 29004b6738
commit a17ad921e2
17 changed files with 54 additions and 59 deletions

View File

@ -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;

View File

@ -33,11 +33,10 @@
#include "spdk/copy_engine.h"
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_memcpy.h>
#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;
}

View File

@ -31,6 +31,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <stdio.h>
#include <errno.h>
@ -38,7 +39,6 @@
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_lcore.h>
#include <rte_debug.h>
#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;

View File

@ -33,6 +33,7 @@
#include "spdk/event.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
@ -46,7 +47,6 @@
#include <signal.h>
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_lcore.h>
#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) {

View File

@ -42,7 +42,6 @@
#include <string.h>
#include <unistd.h>
#include <rte_debug.h>
#include <rte_config.h>
#include <rte_per_lcore.h>
#include <rte_eal.h>

View File

@ -33,6 +33,7 @@
#include "spdk/event.h"
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
@ -48,7 +49,6 @@
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_debug.h>
#include <rte_mempool.h>
#include <rte_ring.h>
#include <rte_timer.h>
@ -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;

View File

@ -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();

View File

@ -52,7 +52,6 @@
#include <rte_config.h>
#include <rte_common.h>
#include <rte_debug.h>
#include <rte_log.h>
#include <rte_memory.h>
#include <rte_memcpy.h>
@ -64,7 +63,6 @@
#include <rte_atomic.h>
#include <rte_lcore.h>
#include <rte_branch_prediction.h>
#include <rte_debug.h>
#include <rte_ring.h>
#include <rte_log.h>
#include <rte_mempool.h>
@ -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;
}

View File

@ -45,7 +45,6 @@
#include <rte_atomic.h>
#include <rte_lcore.h>
#include <rte_branch_prediction.h>
#include <rte_debug.h>
#include <rte_ring.h>
#include <rte_log.h>
#include <rte_mempool.h>

View File

@ -41,7 +41,6 @@
#include <stdint.h>
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_cycles.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
@ -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;

View File

@ -31,6 +31,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
@ -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)) {

View File

@ -36,7 +36,6 @@
#include "spdk/endian.h"
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_malloc.h>
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;

View File

@ -33,9 +33,9 @@
#include "spdk/trace.h"
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@ -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));

View File

@ -38,7 +38,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_debug.h>
#include <rte_malloc.h>
#include <rte_ring.h>

View File

@ -40,7 +40,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_debug.h>
#include <rte_mempool.h>
#include <rte_cycles.h>
#include <rte_malloc.h>

View File

@ -39,7 +39,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_debug.h>
#include <rte_mempool.h>
#include <rte_cycles.h>
#include <rte_malloc.h>

View File

@ -37,7 +37,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_debug.h>
#include <rte_mempool.h>
#include <rte_malloc.h>