astyle: enforce braces around single-line statements
Require braces around all conditional statements, e.g.: if (cond) statement(); becomes: if (cond) { statement(); } This is the style used through most of the SPDK code, but several exceptions crept in over time. Add the astyle option to make sure we are consistent. Change-Id: I5a71980147fe8dfb471ff42e8bc06db2124a1a7f Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/390914 Reviewed-by: <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
6bf92c33e5
commit
59970a89be
@ -1,5 +1,7 @@
|
||||
# Bracket Style
|
||||
style=kr # K&R brackets
|
||||
add-braces # Add braces to one-line conditional statements
|
||||
keep-one-line-blocks # Don't break blocks that are on one line
|
||||
|
||||
# Indentation
|
||||
indent=force-tab=8 # Use tabs for indentation, spaces for minor alignment
|
||||
|
@ -45,9 +45,9 @@ static void
|
||||
spdk_sigusr1(int signo __attribute__((__unused__)))
|
||||
{
|
||||
char *config_str = NULL;
|
||||
if (spdk_app_get_running_config(&config_str, "iscsi.conf") < 0)
|
||||
if (spdk_app_get_running_config(&config_str, "iscsi.conf") < 0) {
|
||||
fprintf(stderr, "Error getting config\n");
|
||||
else {
|
||||
} else {
|
||||
fprintf(stdout, "============================\n");
|
||||
fprintf(stdout, " iSCSI target running config\n");
|
||||
fprintf(stdout, "=============================\n");
|
||||
|
@ -56,14 +56,17 @@ static void usage(void)
|
||||
static bool
|
||||
conns_compare(struct spdk_iscsi_conn *first, struct spdk_iscsi_conn *second)
|
||||
{
|
||||
if (first->lcore < second->lcore)
|
||||
if (first->lcore < second->lcore) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (first->lcore > second->lcore)
|
||||
if (first->lcore > second->lcore) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (first->id < second->id)
|
||||
if (first->id < second->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -95,8 +95,9 @@ spdk_get_ifaddr_numa_node(const char *if_addr)
|
||||
addr_in.sin_addr.s_addr = inet_addr(if_addr);
|
||||
|
||||
ret = getifaddrs(&ifaddrs);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
addr = *(struct sockaddr_in *)ifa->ifa_addr;
|
||||
|
@ -135,13 +135,15 @@ print_float(const char *arg_string, float arg)
|
||||
static void
|
||||
print_arg(bool arg_is_ptr, const char *arg_string, uint64_t arg)
|
||||
{
|
||||
if (arg_string[0] == 0)
|
||||
if (arg_string[0] == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg_is_ptr)
|
||||
if (arg_is_ptr) {
|
||||
print_ptr(arg_string, arg);
|
||||
else
|
||||
} else {
|
||||
print_uint64(arg_string, arg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -236,19 +238,23 @@ populate_events(struct spdk_trace_history *history)
|
||||
if (num_entries == num_entries_filled) {
|
||||
first = last = 0;
|
||||
for (i = 1; i < num_entries; i++) {
|
||||
if (e[i].tsc < e[first].tsc)
|
||||
if (e[i].tsc < e[first].tsc) {
|
||||
first = i;
|
||||
if (e[i].tsc > e[last].tsc)
|
||||
}
|
||||
if (e[i].tsc > e[last].tsc) {
|
||||
last = i;
|
||||
}
|
||||
}
|
||||
|
||||
first += g_fudge_factor;
|
||||
if (first >= num_entries)
|
||||
if (first >= num_entries) {
|
||||
first -= num_entries;
|
||||
}
|
||||
|
||||
last -= g_fudge_factor;
|
||||
if (last < 0)
|
||||
if (last < 0) {
|
||||
last += num_entries;
|
||||
}
|
||||
} else {
|
||||
first = 0;
|
||||
last = num_entries_filled - 1;
|
||||
|
@ -43,13 +43,14 @@ check_modules(char *driver_name)
|
||||
char buffer[256];
|
||||
|
||||
fd = fopen(proc_modules, "r");
|
||||
if (!fd)
|
||||
if (!fd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), fd)) {
|
||||
if (strstr(buffer, driver_name) == NULL)
|
||||
if (strstr(buffer, driver_name) == NULL) {
|
||||
continue;
|
||||
else {
|
||||
} else {
|
||||
fclose(fd);
|
||||
return 0;
|
||||
}
|
||||
@ -160,8 +161,9 @@ get_dma_channel_count(void)
|
||||
|
||||
while ((e = readdir(dir)) != NULL) {
|
||||
str = strstr(e->d_name, ":");
|
||||
if (str != NULL)
|
||||
if (str != NULL) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
|
@ -161,25 +161,29 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
|
||||
src_off = (size_t)src & ~PAGE_MASK;
|
||||
dst_off = (size_t)dst & ~PAGE_MASK;
|
||||
|
||||
if (!is_dma_copy_aligned(device, src_off, dst_off, size))
|
||||
if (!is_dma_copy_aligned(device, src_off, dst_off, size)) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
unmap = dmaengine_get_unmap_data(device->dev, 2, GFP_NOWAIT);
|
||||
if (!unmap)
|
||||
if (!unmap) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
unmap->len = size;
|
||||
unmap->addr[0] = dma_map_page(device->dev, virt_to_page(src),
|
||||
src_off, size, DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(device->dev, unmap->addr[0]))
|
||||
if (dma_mapping_error(device->dev, unmap->addr[0])) {
|
||||
goto err_get_unmap;
|
||||
}
|
||||
|
||||
unmap->to_cnt = 1;
|
||||
|
||||
unmap->addr[1] = dma_map_page(device->dev, virt_to_page(dst),
|
||||
dst_off, size, DMA_FROM_DEVICE);
|
||||
if (dma_mapping_error(device->dev, unmap->addr[1]))
|
||||
if (dma_mapping_error(device->dev, unmap->addr[1])) {
|
||||
goto err_get_unmap;
|
||||
}
|
||||
unmap->from_cnt = 1;
|
||||
|
||||
dma_prep_retry:
|
||||
@ -202,8 +206,9 @@ dma_prep_retry:
|
||||
dma_set_unmap(txd, unmap);
|
||||
|
||||
cookie = dmaengine_submit(txd);
|
||||
if (dma_submit_error(cookie))
|
||||
if (dma_submit_error(cookie)) {
|
||||
goto err_set_unmap;
|
||||
}
|
||||
|
||||
atomic_inc(&pctx->dma_sync);
|
||||
|
||||
@ -246,15 +251,17 @@ static int perf_move_data(struct pthr_ctx *pctx, char *dst, char *src,
|
||||
if (copied_chunks == chunks) {
|
||||
tmp = dst;
|
||||
copied_chunks = 0;
|
||||
} else
|
||||
} else {
|
||||
tmp += buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
printk("%s: All DMA descriptors submitted\n", current->comm);
|
||||
|
||||
/* FIXME: need a timeout here eventually */
|
||||
while (atomic_read(&pctx->dma_sync) != 0)
|
||||
while (atomic_read(&pctx->dma_sync) != 0) {
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
pr_info("%s: dma_up: %d dma_down: %d dma_prep_err: %d\n",
|
||||
current->comm, pctx->dma_up, pctx->dma_down,
|
||||
@ -330,14 +337,16 @@ static int dma_perf_thread(void *data)
|
||||
buf_size = 1ULL << seg_order;
|
||||
total = 1ULL << run_order;
|
||||
|
||||
if (buf_size > MAX_TEST_SIZE)
|
||||
if (buf_size > MAX_TEST_SIZE) {
|
||||
buf_size = MAX_TEST_SIZE;
|
||||
}
|
||||
|
||||
dst = (char *)mw->virt_addr;
|
||||
|
||||
atomic_inc(&perf->tsync);
|
||||
while (atomic_read(&perf->tsync) != perf->perf_threads)
|
||||
while (atomic_read(&perf->tsync) != perf->perf_threads) {
|
||||
schedule();
|
||||
}
|
||||
|
||||
rc = perf_move_data(pctx, dst, src, buf_size, win_size, total);
|
||||
|
||||
@ -352,8 +361,9 @@ static int dma_perf_thread(void *data)
|
||||
return 0;
|
||||
|
||||
err:
|
||||
if (src)
|
||||
if (src) {
|
||||
kfree(src);
|
||||
}
|
||||
|
||||
if (dma_chan) {
|
||||
dma_release_channel(dma_chan);
|
||||
@ -367,8 +377,9 @@ static void perf_free_mw(struct pthr_ctx *pctx)
|
||||
{
|
||||
struct perf_mw *mw = &pctx->mw;
|
||||
|
||||
if (!mw->virt_addr)
|
||||
if (!mw->virt_addr) {
|
||||
return;
|
||||
}
|
||||
|
||||
kfree(mw->virt_addr);
|
||||
mw->buf_size = 0;
|
||||
@ -379,8 +390,9 @@ static int perf_set_mw(struct pthr_ctx *pctx, size_t size)
|
||||
{
|
||||
struct perf_mw *mw = &pctx->mw;
|
||||
|
||||
if (!size)
|
||||
if (!size) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mw->buf_size = size;
|
||||
|
||||
@ -401,8 +413,9 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
|
||||
char *buf;
|
||||
ssize_t ret, out_offset;
|
||||
|
||||
if (!perf)
|
||||
if (!perf) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf = kmalloc(64, GFP_KERNEL);
|
||||
out_offset = snprintf(buf, 64, "%d\n", perf->run);
|
||||
@ -418,11 +431,13 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
||||
struct perf_ctx *perf = filp->private_data;
|
||||
int node, i;
|
||||
|
||||
if (perf->perf_threads == 0)
|
||||
if (perf->perf_threads == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (atomic_read(&perf->tsync) == 0)
|
||||
if (atomic_read(&perf->tsync) == 0) {
|
||||
perf->run = false;
|
||||
}
|
||||
|
||||
if (perf->run == true) {
|
||||
/* lets stop the threads */
|
||||
@ -431,8 +446,9 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
||||
if (perf->pthr_ctx[i].thread) {
|
||||
kthread_stop(perf->pthr_ctx[i].thread);
|
||||
perf->pthr_ctx[i].thread = NULL;
|
||||
} else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
perf->run = true;
|
||||
@ -473,21 +489,23 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
|
||||
kthread_create_on_node(dma_perf_thread,
|
||||
(void *)pctx,
|
||||
node, "dma_perf %d", i);
|
||||
if (pctx->thread)
|
||||
if (pctx->thread) {
|
||||
wake_up_process(pctx->thread);
|
||||
else {
|
||||
} else {
|
||||
perf->run = false;
|
||||
for (i = 0; i < MAX_THREADS; i++) {
|
||||
if (pctx->thread) {
|
||||
kthread_stop(pctx->thread);
|
||||
pctx->thread = NULL;
|
||||
} else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (perf->run == false)
|
||||
if (perf->run == false) {
|
||||
return -ENXIO;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -509,8 +527,9 @@ static ssize_t debugfs_status_read(struct file *filp, char __user *ubuf,
|
||||
char *buf;
|
||||
ssize_t ret, out_offset;
|
||||
|
||||
if (!perf)
|
||||
if (!perf) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf = kmalloc(64, GFP_KERNEL);
|
||||
out_offset = snprintf(buf, 64, "%s\n", atomic_read(&perf->tsync) ? "running" : "idle");
|
||||
@ -532,69 +551,80 @@ static int perf_debugfs_setup(struct perf_ctx *perf)
|
||||
int i;
|
||||
char temp_name[64];
|
||||
|
||||
if (!perf_debugfs_dir)
|
||||
if (!perf_debugfs_dir) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_node_dir = debugfs_create_dir("dmaperf",
|
||||
perf_debugfs_dir);
|
||||
if (!perf->debugfs_node_dir)
|
||||
if (!perf->debugfs_node_dir) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_run = debugfs_create_file("run", S_IRUSR | S_IWUSR,
|
||||
perf->debugfs_node_dir, perf,
|
||||
&dma_perf_debugfs_run);
|
||||
if (!perf->debugfs_run)
|
||||
if (!perf->debugfs_run) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_status = debugfs_create_file("status", S_IRUSR,
|
||||
perf->debugfs_node_dir, perf,
|
||||
&dma_perf_debugfs_status);
|
||||
if (!perf->debugfs_status)
|
||||
if (!perf->debugfs_status) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_threads = debugfs_create_u8("threads", S_IRUSR | S_IWUSR,
|
||||
perf->debugfs_node_dir,
|
||||
&perf->perf_threads);
|
||||
if (!perf->debugfs_threads)
|
||||
if (!perf->debugfs_threads) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_queue_depth = debugfs_create_u32("queue_depth", S_IRUSR | S_IWUSR,
|
||||
perf->debugfs_node_dir,
|
||||
&queue_depth);
|
||||
if (!perf->debugfs_queue_depth)
|
||||
if (!perf->debugfs_queue_depth) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_transfer_size_order = debugfs_create_u32("transfer_size_order", S_IRUSR | S_IWUSR,
|
||||
perf->debugfs_node_dir,
|
||||
&seg_order);
|
||||
if (!perf->debugfs_transfer_size_order)
|
||||
if (!perf->debugfs_transfer_size_order) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
perf->debugfs_total_size_order = debugfs_create_u32("total_size_order", S_IRUSR | S_IWUSR,
|
||||
perf->debugfs_node_dir,
|
||||
&run_order);
|
||||
if (!perf->debugfs_total_size_order)
|
||||
if (!perf->debugfs_total_size_order) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_THREADS; i++) {
|
||||
struct pthr_ctx *pctx = &perf->pthr_ctx[i];
|
||||
sprintf(temp_name, "thread_%d", i);
|
||||
|
||||
pctx->debugfs_thr_dir = debugfs_create_dir(temp_name, perf->debugfs_node_dir);
|
||||
if (!pctx->debugfs_thr_dir)
|
||||
if (!pctx->debugfs_thr_dir) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
pctx->debugfs_copied = debugfs_create_u64("copied", S_IRUSR,
|
||||
pctx->debugfs_thr_dir,
|
||||
&pctx->copied);
|
||||
if (!pctx->debugfs_copied)
|
||||
if (!pctx->debugfs_copied) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
pctx->debugfs_elapsed_time = debugfs_create_u64("elapsed_time", S_IRUSR,
|
||||
pctx->debugfs_thr_dir,
|
||||
&pctx->elapsed_time);
|
||||
if (!pctx->debugfs_elapsed_time)
|
||||
if (!pctx->debugfs_elapsed_time) {
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -619,12 +649,14 @@ static int perf_probe(void)
|
||||
|
||||
if (debugfs_initialized() && !perf_debugfs_dir) {
|
||||
perf_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
|
||||
if (!perf_debugfs_dir)
|
||||
if (!perf_debugfs_dir) {
|
||||
goto err_ctx;
|
||||
}
|
||||
|
||||
rc = perf_debugfs_setup(perf);
|
||||
if (rc)
|
||||
if (rc) {
|
||||
goto err_ctx;
|
||||
}
|
||||
}
|
||||
|
||||
g_perf = perf;
|
||||
@ -648,8 +680,9 @@ static void perf_remove(void)
|
||||
|
||||
for (i = 0; i < MAX_THREADS; i++) {
|
||||
struct pthr_ctx *pctx = &perf->pthr_ctx[i];
|
||||
if (pctx->dma_chan)
|
||||
if (pctx->dma_chan) {
|
||||
dma_release_channel(pctx->dma_chan);
|
||||
}
|
||||
perf_free_mw(pctx);
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,9 @@ static void prepare_ioat_task(struct thread_entry *thread_entry, struct ioat_tas
|
||||
/* ensure that the length of memset block is 8 Bytes aligned */
|
||||
num_ddwords = (rand_r(&seed) % SRC_BUFFER_SIZE) / 8;
|
||||
len = num_ddwords * 8;
|
||||
if (len < 8)
|
||||
if (len < 8) {
|
||||
len = 8;
|
||||
}
|
||||
dst_offset = rand_r(&seed) % (SRC_BUFFER_SIZE - len);
|
||||
ioat_task->fill_pattern = fill_pattern;
|
||||
} else {
|
||||
@ -172,8 +173,9 @@ ioat_done(void *cb_arg)
|
||||
}
|
||||
value += 8;
|
||||
}
|
||||
if (!failed)
|
||||
if (!failed) {
|
||||
thread_entry->fill_completed++;
|
||||
}
|
||||
} else {
|
||||
if (memcmp(ioat_task->src, ioat_task->dst, ioat_task->len)) {
|
||||
thread_entry->xfer_failed++;
|
||||
@ -307,8 +309,9 @@ submit_xfers(struct thread_entry *thread_entry, uint64_t queue_depth)
|
||||
|
||||
ioat_task->type = IOAT_COPY_TYPE;
|
||||
if (spdk_ioat_get_dma_capabilities(thread_entry->chan) & SPDK_IOAT_ENGINE_FILL_SUPPORTED) {
|
||||
if (queue_depth % 2)
|
||||
if (queue_depth % 2) {
|
||||
ioat_task->type = IOAT_FILL_TYPE;
|
||||
}
|
||||
}
|
||||
prepare_ioat_task(thread_entry, ioat_task);
|
||||
submit_single_xfer(ioat_task);
|
||||
|
@ -267,8 +267,9 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
|
||||
g_controllers = entry;
|
||||
|
||||
if ((g_arbitration.latency_tracking_enable != 0) &&
|
||||
spdk_nvme_ctrlr_is_feature_supported(ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING))
|
||||
spdk_nvme_ctrlr_is_feature_supported(ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) {
|
||||
set_latency_tracking_feature(ctrlr, true);
|
||||
}
|
||||
|
||||
num_ns = spdk_nvme_ctrlr_get_num_ns(ctrlr);
|
||||
for (nsid = 1; nsid <= num_ns; nsid++) {
|
||||
@ -902,8 +903,9 @@ unregister_controllers(void)
|
||||
while (entry) {
|
||||
struct ctrlr_entry *next = entry->next;
|
||||
if (g_arbitration.latency_tracking_enable &&
|
||||
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING))
|
||||
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) {
|
||||
set_latency_tracking_feature(entry->ctrlr, false);
|
||||
}
|
||||
spdk_nvme_detach(entry->ctrlr);
|
||||
free(entry);
|
||||
entry = next;
|
||||
|
@ -587,10 +587,11 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
|
||||
printf(" May be connected to multiple hosts: %s\n", cdata->cmic.multi_host ? "Yes" : "No");
|
||||
printf(" Associated with SR-IOV VF: %s\n", cdata->cmic.sr_iov ? "Yes" : "No");
|
||||
printf("Max Data Transfer Size: ");
|
||||
if (cdata->mdts == 0)
|
||||
if (cdata->mdts == 0) {
|
||||
printf("Unlimited\n");
|
||||
else
|
||||
} else {
|
||||
printf("%" PRIu64 "\n", (uint64_t)1 << (12 + cap.bits.mpsmin + cdata->mdts));
|
||||
}
|
||||
if (features[SPDK_NVME_FEAT_ERROR_RECOVERY].valid) {
|
||||
unsigned tler = features[SPDK_NVME_FEAT_ERROR_RECOVERY].result & 0xFFFF;
|
||||
printf("Error Recovery Timeout: ");
|
||||
@ -665,15 +666,17 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
|
||||
printf("Abort Command Limit: %d\n", cdata->acl + 1);
|
||||
printf("Async Event Request Limit: %d\n", cdata->aerl + 1);
|
||||
printf("Number of Firmware Slots: ");
|
||||
if (cdata->oacs.firmware != 0)
|
||||
if (cdata->oacs.firmware != 0) {
|
||||
printf("%d\n", cdata->frmw.num_slots);
|
||||
else
|
||||
} else {
|
||||
printf("N/A\n");
|
||||
}
|
||||
printf("Firmware Slot 1 Read-Only: ");
|
||||
if (cdata->oacs.firmware != 0)
|
||||
if (cdata->oacs.firmware != 0) {
|
||||
printf("%s\n", cdata->frmw.slot1_ro ? "Yes" : "No");
|
||||
else
|
||||
} else {
|
||||
printf("N/A\n");
|
||||
}
|
||||
if (cdata->fwug == 0x00) {
|
||||
printf("Firmware Update Granularity: No Information Provided\n");
|
||||
} else if (cdata->fwug == 0xFF) {
|
||||
|
@ -194,8 +194,9 @@ display_namespace(struct spdk_nvme_ns *ns)
|
||||
(long long)nsdata->nuse / 1024 / 1024);
|
||||
printf("Format Progress Indicator: %s\n",
|
||||
nsdata->fpi.fpi_supported ? "Supported" : "Not Supported");
|
||||
if (nsdata->fpi.fpi_supported && nsdata->fpi.percentage_remaining)
|
||||
if (nsdata->fpi.fpi_supported && nsdata->fpi.percentage_remaining) {
|
||||
printf("Formatted Percentage: %d%%\n", 100 - nsdata->fpi.percentage_remaining);
|
||||
}
|
||||
printf("Number of LBA Formats: %d\n", nsdata->nlbaf + 1);
|
||||
printf("Current LBA Format: LBA Format #%02d\n",
|
||||
nsdata->flbas.format);
|
||||
@ -945,8 +946,9 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
if (exit_flag)
|
||||
if (exit_flag) {
|
||||
break;
|
||||
}
|
||||
|
||||
while (getchar() != '\n');
|
||||
printf("press Enter to display cmd menu ...\n");
|
||||
|
@ -320,8 +320,9 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
|
||||
g_controllers = entry;
|
||||
|
||||
if (g_latency_ssd_tracking_enable &&
|
||||
spdk_nvme_ctrlr_is_feature_supported(ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING))
|
||||
spdk_nvme_ctrlr_is_feature_supported(ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) {
|
||||
set_latency_tracking_feature(ctrlr, true);
|
||||
}
|
||||
|
||||
num_ns = spdk_nvme_ctrlr_get_num_ns(ctrlr);
|
||||
for (nsid = 1; nsid <= num_ns; nsid++) {
|
||||
@ -870,12 +871,14 @@ print_latency_page(struct ctrlr_entry *entry)
|
||||
printf("--------------------------------------------------------\n");
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (entry->latency_page->buckets_32us[i])
|
||||
if (entry->latency_page->buckets_32us[i]) {
|
||||
printf("Bucket %dus - %dus: %d\n", i * 32, (i + 1) * 32, entry->latency_page->buckets_32us[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 31; i++) {
|
||||
if (entry->latency_page->buckets_1ms[i])
|
||||
if (entry->latency_page->buckets_1ms[i]) {
|
||||
printf("Bucket %dms - %dms: %d\n", i + 1, i + 2, entry->latency_page->buckets_1ms[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 31; i++) {
|
||||
if (entry->latency_page->buckets_32ms[i])
|
||||
@ -1280,8 +1283,9 @@ unregister_controllers(void)
|
||||
struct ctrlr_entry *next = entry->next;
|
||||
spdk_dma_free(entry->latency_page);
|
||||
if (g_latency_ssd_tracking_enable &&
|
||||
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING))
|
||||
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) {
|
||||
set_latency_tracking_feature(entry->ctrlr, false);
|
||||
}
|
||||
spdk_nvme_detach(entry->ctrlr);
|
||||
free(entry);
|
||||
entry = next;
|
||||
|
@ -157,8 +157,9 @@ reservation_ns_register(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *q
|
||||
spdk_nvme_qpair_process_completions(qpair, 100);
|
||||
}
|
||||
|
||||
if (reserve_command_result)
|
||||
if (reserve_command_result) {
|
||||
fprintf(stderr, "Reservation Register Failed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -249,8 +250,9 @@ reservation_ns_acquire(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qp
|
||||
spdk_nvme_qpair_process_completions(qpair, 100);
|
||||
}
|
||||
|
||||
if (reserve_command_result)
|
||||
if (reserve_command_result) {
|
||||
fprintf(stderr, "Reservation Acquire Failed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -283,8 +285,9 @@ reservation_ns_release(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qp
|
||||
spdk_nvme_qpair_process_completions(qpair, 100);
|
||||
}
|
||||
|
||||
if (reserve_command_result)
|
||||
if (reserve_command_result) {
|
||||
fprintf(stderr, "Reservation Release Failed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -305,8 +308,9 @@ reserve_controller(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair,
|
||||
printf("Reservations: %s\n",
|
||||
cdata->oncs.reservations ? "Supported" : "Not Supported");
|
||||
|
||||
if (!cdata->oncs.reservations)
|
||||
if (!cdata->oncs.reservations) {
|
||||
return;
|
||||
}
|
||||
|
||||
get_host_identifier(ctrlr);
|
||||
|
||||
|
@ -360,8 +360,9 @@ static const struct spdk_bdev_fn_table aio_fn_table = {
|
||||
|
||||
static void aio_free_disk(struct file_disk *fdisk)
|
||||
{
|
||||
if (fdisk == NULL)
|
||||
if (fdisk == NULL) {
|
||||
return;
|
||||
}
|
||||
free(fdisk->filename);
|
||||
free(fdisk->disk.name);
|
||||
free(fdisk);
|
||||
@ -540,8 +541,9 @@ bdev_aio_get_spdk_running_config(FILE *fp)
|
||||
name = fdisk->disk.name;
|
||||
block_size = fdisk->disk.blocklen;
|
||||
fprintf(fp, " AIO %s %s ", file, name);
|
||||
if (fdisk->block_size_override)
|
||||
if (fdisk->block_size_override) {
|
||||
fprintf(fp, "%d", block_size);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
|
@ -209,8 +209,9 @@ _vbdev_lvs_remove_cb(void *cb_arg, int lvserrno)
|
||||
free(lvs_bdev);
|
||||
}
|
||||
|
||||
if (req->cb_fn != NULL)
|
||||
if (req->cb_fn != NULL) {
|
||||
req->cb_fn(req->cb_arg, lvserrno);
|
||||
}
|
||||
free(req);
|
||||
}
|
||||
|
||||
@ -226,16 +227,18 @@ _vbdev_lvs_remove(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void
|
||||
lvs_bdev = vbdev_get_lvs_bdev_by_lvs(lvs);
|
||||
if (!lvs_bdev) {
|
||||
SPDK_ERRLOG("No such lvol store found\n");
|
||||
if (cb_fn != NULL)
|
||||
if (cb_fn != NULL) {
|
||||
cb_fn(cb_arg, -ENODEV);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
req = calloc(1, sizeof(*req));
|
||||
if (!req) {
|
||||
SPDK_ERRLOG("Cannot alloc memory for vbdev lvol store request pointer\n");
|
||||
if (cb_fn != NULL)
|
||||
if (cb_fn != NULL) {
|
||||
cb_fn(cb_arg, -ENOMEM);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -133,8 +133,9 @@ bdev_malloc_check_iov_len(struct iovec *iovs, int iovcnt, size_t nbytes)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < iovcnt; i++) {
|
||||
if (nbytes < iovs[i].iov_len)
|
||||
if (nbytes < iovs[i].iov_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
nbytes -= iovs[i].iov_len;
|
||||
}
|
||||
|
@ -1221,8 +1221,9 @@ bdev_nvme_queued_reset_sgl(void *ref, uint32_t sgl_offset)
|
||||
bio->iov_offset = sgl_offset;
|
||||
for (bio->iovpos = 0; bio->iovpos < bio->iovcnt; bio->iovpos++) {
|
||||
iov = &bio->iovs[bio->iovpos];
|
||||
if (bio->iov_offset < iov->iov_len)
|
||||
if (bio->iov_offset < iov->iov_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
bio->iov_offset -= iov->iov_len;
|
||||
}
|
||||
|
@ -211,8 +211,9 @@ bdev_rbd_rw(struct bdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
{
|
||||
struct bdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
if (iovcnt != 1 || iov->iov_len != len)
|
||||
if (iovcnt != 1 || iov->iov_len != len) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return bdev_rbd_start_aio(rbdio_ch->image, bdev_io, iov->iov_base, offset, len);
|
||||
}
|
||||
@ -566,8 +567,9 @@ bdev_rbd_library_init(void)
|
||||
/* Init rbd block devices */
|
||||
for (i = 0; ; i++) {
|
||||
val = spdk_conf_section_get_nval(sp, "Ceph", i);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* get the Rbd_pool name */
|
||||
pool_name = spdk_conf_section_get_nmval(sp, "Ceph", i, 0);
|
||||
|
@ -75,8 +75,9 @@ vring_desc_init(struct vring_desc *dp, uint16_t n)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for (i = 0; i < n - 1; i++)
|
||||
for (i = 0; i < n - 1; i++) {
|
||||
dp[i].next = (uint16_t)(i + 1);
|
||||
}
|
||||
dp[i].next = VQ_RING_DESC_CHAIN_END;
|
||||
}
|
||||
|
||||
@ -110,8 +111,9 @@ vq_update_avail_ring(struct virtqueue *vq, uint16_t desc_idx)
|
||||
* descriptor.
|
||||
*/
|
||||
avail_idx = (uint16_t)(vq->vq_avail_idx & (vq->vq_nentries - 1));
|
||||
if (spdk_unlikely(vq->vq_ring.avail->ring[avail_idx] != desc_idx))
|
||||
if (spdk_unlikely(vq->vq_ring.avail->ring[avail_idx] != desc_idx)) {
|
||||
vq->vq_ring.avail->ring[avail_idx] = desc_idx;
|
||||
}
|
||||
vq->vq_avail_idx++;
|
||||
}
|
||||
|
||||
@ -237,13 +239,15 @@ virtio_free_queues(struct virtio_dev *dev)
|
||||
struct virtqueue *vq;
|
||||
uint16_t i;
|
||||
|
||||
if (dev->vqs == NULL)
|
||||
if (dev->vqs == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < nr_vq; i++) {
|
||||
vq = dev->vqs[i];
|
||||
if (!vq)
|
||||
if (!vq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
spdk_dma_free(vq->vq_ring_virt_mem);
|
||||
|
||||
@ -337,12 +341,14 @@ virtio_dev_restart(struct virtio_dev *dev, uint64_t req_features)
|
||||
|
||||
/* Tell the host we've known how to drive the device. */
|
||||
virtio_dev_set_status(dev, VIRTIO_CONFIG_S_DRIVER);
|
||||
if (virtio_negotiate_features(dev, req_features) < 0)
|
||||
if (virtio_negotiate_features(dev, req_features) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = virtio_alloc_queues(dev);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtio_dev_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
|
||||
return 0;
|
||||
@ -517,8 +523,9 @@ virtio_recv_pkts(struct virtqueue *vq, struct virtio_req **reqs, uint16_t nb_pkt
|
||||
|
||||
num = (uint16_t)(spdk_likely(nb_used <= nb_pkts) ? nb_used : nb_pkts);
|
||||
num = (uint16_t)(spdk_likely(num <= VIRTIO_MBUF_BURST_SZ) ? num : VIRTIO_MBUF_BURST_SZ);
|
||||
if (spdk_likely(num > DESC_PER_CACHELINE))
|
||||
if (spdk_likely(num > DESC_PER_CACHELINE)) {
|
||||
num = num - ((vq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);
|
||||
}
|
||||
|
||||
num = virtqueue_dequeue_burst_rx(vq, rcv_pkts, len, num);
|
||||
SPDK_DEBUGLOG(SPDK_LOG_VIRTIO_DEV, "used:%"PRIu16" dequeue:%"PRIu16"\n", nb_used, num);
|
||||
@ -688,8 +695,9 @@ virtio_dev_stop(struct virtio_dev *dev)
|
||||
void
|
||||
virtio_dev_set_status(struct virtio_dev *dev, uint8_t status)
|
||||
{
|
||||
if (status != VIRTIO_CONFIG_S_RESET)
|
||||
if (status != VIRTIO_CONFIG_S_RESET) {
|
||||
status |= virtio_dev_backend_ops(dev)->get_status(dev);
|
||||
}
|
||||
|
||||
virtio_dev_backend_ops(dev)->set_status(dev, status);
|
||||
}
|
||||
|
@ -141,8 +141,9 @@ modern_read_dev_config(struct virtio_dev *dev, size_t offset,
|
||||
old_gen = spdk_mmio_read_1(&hw->common_cfg->config_generation);
|
||||
|
||||
p = dst;
|
||||
for (i = 0; i < length; i++)
|
||||
for (i = 0; i < length; i++) {
|
||||
*p++ = spdk_mmio_read_1((uint8_t *)hw->dev_cfg + offset + i);
|
||||
}
|
||||
|
||||
new_gen = spdk_mmio_read_1(&hw->common_cfg->config_generation);
|
||||
} while (old_gen != new_gen);
|
||||
@ -156,8 +157,9 @@ modern_write_dev_config(struct virtio_dev *dev, size_t offset,
|
||||
int i;
|
||||
const uint8_t *p = src;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
for (i = 0; i < length; i++) {
|
||||
spdk_mmio_write_1(((uint8_t *)hw->dev_cfg) + offset + i, *p++);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
@ -237,8 +239,9 @@ modern_setup_queue(struct virtio_dev *dev, struct virtqueue *vq)
|
||||
uint64_t desc_addr, avail_addr, used_addr;
|
||||
uint16_t notify_off;
|
||||
|
||||
if (!check_vq_phys_addr_ok(vq))
|
||||
if (!check_vq_phys_addr_ok(vq)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
desc_addr = vq->vq_ring_mem;
|
||||
avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
|
||||
@ -360,8 +363,9 @@ virtio_read_caps(struct virtio_hw *hw)
|
||||
break;
|
||||
}
|
||||
|
||||
if (cap.cap_vndr == PCI_CAP_ID_MSIX)
|
||||
if (cap.cap_vndr == PCI_CAP_ID_MSIX) {
|
||||
hw->use_msix = 1;
|
||||
}
|
||||
|
||||
if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_VIRTIO_PCI,
|
||||
|
@ -137,17 +137,20 @@ virtio_user_start_device(struct virtio_dev *vdev)
|
||||
int ret;
|
||||
|
||||
/* tell vhost to create queues */
|
||||
if (virtio_user_queue_setup(vdev, virtio_user_create_queue) < 0)
|
||||
if (virtio_user_queue_setup(vdev, virtio_user_create_queue) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* share memory regions */
|
||||
ret = dev->ops->send_request(dev, VHOST_USER_SET_MEM_TABLE, NULL);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* kick queues */
|
||||
if (virtio_user_queue_setup(vdev, virtio_user_kick_queue) < 0)
|
||||
if (virtio_user_queue_setup(vdev, virtio_user_kick_queue) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -172,8 +175,9 @@ virtio_user_dev_setup(struct virtio_dev *vdev)
|
||||
|
||||
dev->ops = &ops_user;
|
||||
|
||||
if (dev->ops->setup(dev) < 0)
|
||||
if (dev->ops->setup(dev) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -196,25 +196,30 @@ get_hugepage_file_info(struct hugepage_file_info huges[], int max)
|
||||
tmp = strchr(tmp, ' ') + 1; /** skip offset */
|
||||
tmp = strchr(tmp, ' ') + 1; /** skip dev */
|
||||
tmp = strchr(tmp, ' ') + 1; /** skip inode */
|
||||
while (*tmp == ' ') /** skip spaces */
|
||||
while (*tmp == ' ') { /** skip spaces */
|
||||
tmp++;
|
||||
}
|
||||
tail = strrchr(tmp, '\n'); /** remove newline if exists */
|
||||
if (tail)
|
||||
if (tail) {
|
||||
*tail = '\0';
|
||||
}
|
||||
|
||||
/* Match HUGEFILE_FMT, aka "%s/%smap_%d",
|
||||
* which is defined in eal_filesystem.h
|
||||
*/
|
||||
str_underline = strrchr(tmp, '_');
|
||||
if (!str_underline)
|
||||
if (!str_underline) {
|
||||
continue;
|
||||
}
|
||||
|
||||
str_start = str_underline - strlen("map");
|
||||
if (str_start < tmp)
|
||||
if (str_start < tmp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sscanf(str_start, "map_%d", &huge_index) != 1)
|
||||
if (sscanf(str_start, "map_%d", &huge_index) != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (idx >= max) {
|
||||
SPDK_ERRLOG("Exceed maximum of %d\n", max);
|
||||
@ -314,8 +319,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
||||
break;
|
||||
|
||||
case VHOST_USER_SET_MEM_TABLE:
|
||||
if (prepare_vhost_memory_user(&msg, fds) < 0)
|
||||
if (prepare_vhost_memory_user(&msg, fds) < 0) {
|
||||
return -1;
|
||||
}
|
||||
fd_num = msg.payload.memory.nregions;
|
||||
msg.size = sizeof(msg.payload.memory.nregions);
|
||||
msg.size += sizeof(msg.payload.memory.padding);
|
||||
@ -350,10 +356,11 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
||||
file = arg;
|
||||
msg.payload.u64 = file->index & VHOST_USER_VRING_IDX_MASK;
|
||||
msg.size = sizeof(msg.payload.u64);
|
||||
if (file->fd > 0)
|
||||
if (file->fd > 0) {
|
||||
fds[fd_num++] = file->fd;
|
||||
else
|
||||
} else {
|
||||
msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -370,8 +377,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
||||
}
|
||||
|
||||
if (req == VHOST_USER_SET_MEM_TABLE)
|
||||
for (i = 0; i < fd_num; ++i)
|
||||
for (i = 0; i < fd_num; ++i) {
|
||||
close(fds[i]);
|
||||
}
|
||||
|
||||
if (need_reply) {
|
||||
if (vhost_user_read(vhostfd, &msg) < 0) {
|
||||
|
@ -545,8 +545,9 @@ iter_delete_cb(void *ctx, int bserrno)
|
||||
struct spdk_fs_cb_args *args = &req->args;
|
||||
struct spdk_filesystem *fs = args->fs;
|
||||
|
||||
if (_handle_deleted_files(req) == 0)
|
||||
if (_handle_deleted_files(req) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
args->fn.fs_op_with_handle(args->arg, fs, 0);
|
||||
free_fs_request(req);
|
||||
@ -566,8 +567,9 @@ iter_cb(void *ctx, struct spdk_blob *blob, int rc)
|
||||
|
||||
if (rc == -ENOENT) {
|
||||
/* Finished iterating */
|
||||
if (_handle_deleted_files(req) == 0)
|
||||
if (_handle_deleted_files(req) == 0) {
|
||||
return;
|
||||
}
|
||||
args->fn.fs_op_with_handle(args->arg, fs, 0);
|
||||
free_fs_request(req);
|
||||
return;
|
||||
|
@ -286,8 +286,9 @@ copy_engine_ioat_init(void)
|
||||
/* Init the whitelist */
|
||||
for (i = 0; i < IOAT_MAX_CHANNELS; i++) {
|
||||
pci_bdf = spdk_conf_section_get_nmval(sp, "Whitelist", i, 0);
|
||||
if (!pci_bdf)
|
||||
if (!pci_bdf) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (spdk_pci_addr_parse(&probe_ctx.whitelist[probe_ctx.num_whitelist_devices], pci_bdf) < 0) {
|
||||
SPDK_ERRLOG("Invalid Ioat Whitelist address %s\n", pci_bdf);
|
||||
|
@ -390,12 +390,14 @@ spdk_pci_device_get_serial_number(struct spdk_pci_device *dev, char *sn, size_t
|
||||
uint32_t pos, header = 0;
|
||||
uint32_t i, buf[2];
|
||||
|
||||
if (len < 17)
|
||||
if (len < 17) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
err = spdk_pci_device_cfg_read32(dev, &header, PCI_CFG_SIZE);
|
||||
if (err || !header)
|
||||
if (err || !header) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pos = PCI_CFG_SIZE;
|
||||
while (1) {
|
||||
@ -405,8 +407,9 @@ spdk_pci_device_get_serial_number(struct spdk_pci_device *dev, char *sn, size_t
|
||||
pos += 4;
|
||||
for (i = 0; i < 2; i++) {
|
||||
err = spdk_pci_device_cfg_read32(dev, &buf[i], pos + 4 * i);
|
||||
if (err)
|
||||
if (err) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
snprintf(sn, len, "%08x%08x", buf[1], buf[0]);
|
||||
return 0;
|
||||
@ -414,11 +417,13 @@ spdk_pci_device_get_serial_number(struct spdk_pci_device *dev, char *sn, size_t
|
||||
}
|
||||
pos = (header >> 20) & 0xffc;
|
||||
/* 0 if no other items exist */
|
||||
if (pos < PCI_CFG_SIZE)
|
||||
if (pos < PCI_CFG_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
err = spdk_pci_device_cfg_read32(dev, &header, pos);
|
||||
if (err)
|
||||
if (err) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -284,8 +284,9 @@ spdk_vtophys_iommu_init(void)
|
||||
}
|
||||
|
||||
while ((d = readdir(dir)) != NULL) {
|
||||
if (d->d_type != DT_LNK)
|
||||
if (d->d_type != DT_LNK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
snprintf(proc_fd_path, sizeof(proc_fd_path), "/proc/self/fd/%s", d->d_name);
|
||||
if (readlink(proc_fd_path, link_path, sizeof(link_path)) != (sizeof(vfio_path) - 1)) {
|
||||
|
@ -102,8 +102,9 @@ spdk_app_get_shm_id(void)
|
||||
static void
|
||||
spdk_app_config_dump_global_section(FILE *fp)
|
||||
{
|
||||
if (NULL == fp)
|
||||
if (NULL == fp) {
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(fp, GLOBAL_CONFIG_TMPL,
|
||||
spdk_app_get_core_mask(), spdk_trace_get_tpoint_group_mask());
|
||||
@ -148,8 +149,9 @@ spdk_app_get_running_config(char **config_str, char *name)
|
||||
}
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
ret = fread(*config_str, sizeof(char), length, fp);
|
||||
if (ret < length)
|
||||
if (ret < length) {
|
||||
SPDK_ERRLOG("short read\n");
|
||||
}
|
||||
fclose(fp);
|
||||
(*config_str)[length] = '\0';
|
||||
|
||||
@ -185,8 +187,9 @@ __shutdown_event_cb(void *arg1, void *arg2)
|
||||
void
|
||||
spdk_app_opts_init(struct spdk_app_opts *opts)
|
||||
{
|
||||
if (!opts)
|
||||
if (!opts) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
|
||||
|
@ -90,8 +90,9 @@ subsystem_sort(void)
|
||||
if (strcmp(subsystem->name, subsystem_dep->name) == 0) {
|
||||
depends_on = true;
|
||||
depends_on_sorted = !!spdk_subsystem_find(&subsystems_list, subsystem_dep->depends_on);
|
||||
if (depends_on_sorted)
|
||||
if (depends_on_sorted) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -238,7 +239,8 @@ spdk_subsystem_config(FILE *fp)
|
||||
struct spdk_subsystem *subsystem;
|
||||
|
||||
TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
|
||||
if (subsystem->config)
|
||||
if (subsystem->config) {
|
||||
subsystem->config(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,8 +387,9 @@ ioat_channel_start(struct spdk_ioat_chan *ioat)
|
||||
|
||||
/* Always support DMA copy */
|
||||
ioat->dma_capabilities = SPDK_IOAT_ENGINE_COPY_SUPPORTED;
|
||||
if (ioat->regs->dmacapability & SPDK_IOAT_DMACAP_BFILL)
|
||||
if (ioat->regs->dmacapability & SPDK_IOAT_DMACAP_BFILL) {
|
||||
ioat->dma_capabilities |= SPDK_IOAT_ENGINE_FILL_SUPPORTED;
|
||||
}
|
||||
xfercap = ioat->regs->xfercap;
|
||||
|
||||
/* Only bits [4:0] are valid. */
|
||||
@ -446,8 +447,9 @@ ioat_channel_start(struct spdk_ioat_chan *ioat)
|
||||
while (i-- > 0) {
|
||||
spdk_delay_us(100);
|
||||
status = ioat_get_chansts(ioat);
|
||||
if (is_ioat_idle(status))
|
||||
if (is_ioat_idle(status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_ioat_idle(status)) {
|
||||
|
@ -384,8 +384,9 @@ int spdk_initialize_iscsi_conns(void)
|
||||
g_num_connections[i] = 0;
|
||||
}
|
||||
|
||||
if (g_conn_idle_interval_in_tsc == -1)
|
||||
if (g_conn_idle_interval_in_tsc == -1) {
|
||||
spdk_iscsi_set_min_conn_idle_interval(spdk_net_framework_idle_time());
|
||||
}
|
||||
|
||||
STAILQ_INIT(&g_idle_conn_list_head);
|
||||
if (init_idle_conns() < 0) {
|
||||
@ -447,14 +448,17 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
|
||||
|
||||
conn->partial_text_parameter = NULL;
|
||||
|
||||
for (i = 0; i < MAX_CONNECTION_PARAMS; i++)
|
||||
for (i = 0; i < MAX_CONNECTION_PARAMS; i++) {
|
||||
conn->conn_param_state_negotiated[i] = false;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SESSION_PARAMS; i++)
|
||||
for (i = 0; i < MAX_SESSION_PARAMS; i++) {
|
||||
conn->sess_param_state_negotiated[i] = false;
|
||||
}
|
||||
|
||||
for (i = 0; i < DEFAULT_MAXR2T; i++)
|
||||
for (i = 0; i < DEFAULT_MAXR2T; i++) {
|
||||
conn->outstanding_r2t_tasks[i] = NULL;
|
||||
}
|
||||
|
||||
TAILQ_INIT(&conn->write_pdu_list);
|
||||
TAILQ_INIT(&conn->snack_pdu_list);
|
||||
@ -472,16 +476,18 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
|
||||
|
||||
bufsize = 2 * 1024 * 1024;
|
||||
rc = spdk_sock_set_recvbuf(conn->sock, bufsize);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("spdk_sock_set_recvbuf failed\n");
|
||||
}
|
||||
|
||||
bufsize = 32 * 1024 * 1024 / g_spdk_iscsi.MaxConnections;
|
||||
if (bufsize > 2 * 1024 * 1024) {
|
||||
bufsize = 2 * 1024 * 1024;
|
||||
}
|
||||
rc = spdk_sock_set_sendbuf(conn->sock, bufsize);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("spdk_sock_set_sendbuf failed\n");
|
||||
}
|
||||
|
||||
/* set low water mark */
|
||||
rc = spdk_sock_set_recvlowat(conn->sock, 1);
|
||||
@ -575,8 +581,9 @@ static int spdk_iscsi_conn_free_tasks(struct spdk_iscsi_conn *conn)
|
||||
spdk_put_pdu(pdu);
|
||||
}
|
||||
|
||||
if (conn->pending_task_cnt)
|
||||
if (conn->pending_task_cnt) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -585,8 +592,9 @@ static int spdk_iscsi_conn_free_tasks(struct spdk_iscsi_conn *conn)
|
||||
static void spdk_iscsi_conn_free(struct spdk_iscsi_conn *conn)
|
||||
{
|
||||
|
||||
if (conn == NULL)
|
||||
if (conn == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_iscsi_param_free(conn->params);
|
||||
|
||||
@ -664,8 +672,9 @@ spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
|
||||
/* clean up all tasks to all LUNs for session */
|
||||
rc = spdk_iscsi_tgt_node_cleanup_luns(conn,
|
||||
conn->sess->target);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("target abort failed\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -732,8 +741,9 @@ spdk_iscsi_get_active_conns(void)
|
||||
pthread_mutex_lock(&g_conns_mutex);
|
||||
for (i = 0; i < MAX_ISCSI_CONNECTIONS; i++) {
|
||||
conn = spdk_find_iscsi_connection_by_id(i);
|
||||
if (conn == NULL)
|
||||
if (conn == NULL) {
|
||||
continue;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
pthread_mutex_unlock(&g_conns_mutex);
|
||||
@ -853,8 +863,9 @@ void spdk_shutdown_iscsi_conns(void)
|
||||
|
||||
for (i = 0; i < MAX_ISCSI_CONNECTIONS; i++) {
|
||||
conn = spdk_find_iscsi_connection_by_id(i);
|
||||
if (conn == NULL)
|
||||
if (conn == NULL) {
|
||||
continue;
|
||||
}
|
||||
conn->state = ISCSI_CONN_STATE_EXITING;
|
||||
}
|
||||
|
||||
@ -878,14 +889,17 @@ spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn, const char *conn_match,
|
||||
for (i = 0; i < MAX_ISCSI_CONNECTIONS; i++) {
|
||||
xconn = spdk_find_iscsi_connection_by_id(i);
|
||||
|
||||
if (xconn == NULL)
|
||||
if (xconn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (xconn == conn)
|
||||
if (xconn == conn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!drop_all && xconn->initiator_port == NULL)
|
||||
if (!drop_all && xconn->initiator_port == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
xconn_match =
|
||||
drop_all ? xconn->initiator_name : spdk_scsi_port_get_name(xconn->initiator_port);
|
||||
@ -1437,8 +1451,9 @@ spdk_iscsi_conn_login_do_work(void *arg)
|
||||
|
||||
/* General connection processing */
|
||||
rc = spdk_iscsi_conn_execute(conn);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if this connection transitioned to full feature phase. If it
|
||||
* did, migrate it to a dedicated reactor for the target node.
|
||||
|
@ -300,8 +300,9 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
|
||||
/* counts number of definitions */
|
||||
for (i = 0; ; i++) {
|
||||
val = spdk_conf_section_get_nval(sp, "InitiatorName", i);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
SPDK_ERRLOG("num_initiator_names = 0\n");
|
||||
@ -314,8 +315,9 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
|
||||
}
|
||||
for (i = 0; ; i++) {
|
||||
val = spdk_conf_section_get_nval(sp, "Netmask", i);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
SPDK_ERRLOG("num_initiator_mask = 0\n");
|
||||
@ -524,8 +526,9 @@ spdk_initiator_group_unregister(struct spdk_iscsi_init_grp *ig)
|
||||
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
TAILQ_FOREACH_SAFE(initiator_group, &g_spdk_iscsi.ig_head, tailq, initiator_group_tmp) {
|
||||
if (ig->tag == initiator_group->tag)
|
||||
if (ig->tag == initiator_group->tag) {
|
||||
TAILQ_REMOVE(&g_spdk_iscsi.ig_head, initiator_group, tailq);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
}
|
||||
|
@ -142,8 +142,9 @@ spdk_match_digest_word(const uint8_t *buf, uint32_t crc32c)
|
||||
static uint8_t *
|
||||
spdk_make_digest_word(uint8_t *buf, size_t len, uint32_t crc32c)
|
||||
{
|
||||
if (len < ISCSI_DIGEST_LEN)
|
||||
if (len < ISCSI_DIGEST_LEN) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf[0] = (crc32c >> 0) & 0xffU;
|
||||
buf[1] = (crc32c >> 8) & 0xffU;
|
||||
@ -229,8 +230,9 @@ spdk_bin2hex(char *buf, size_t len, const uint8_t *data, size_t data_len)
|
||||
size_t total = 0;
|
||||
size_t idx;
|
||||
|
||||
if (len < 3)
|
||||
if (len < 3) {
|
||||
return -1;
|
||||
}
|
||||
buf[total] = '0';
|
||||
total++;
|
||||
buf[total] = 'x';
|
||||
@ -261,8 +263,9 @@ spdk_hex2bin(uint8_t *data, size_t data_len, const char *str)
|
||||
int n0, n1;
|
||||
|
||||
p = str;
|
||||
if (p[0] != '0' && (p[1] != 'x' && p[1] != 'X'))
|
||||
if (p[0] != '0' && (p[1] != 'x' && p[1] != 'X')) {
|
||||
return -1;
|
||||
}
|
||||
p += 2;
|
||||
|
||||
while (p[0] != '\0' && p[1] != '\0') {
|
||||
@ -737,8 +740,9 @@ spdk_iscsi_chap_get_authinfo(struct iscsi_chap_auth *auth, const char *authfile,
|
||||
}
|
||||
for (i = 0; ; i++) {
|
||||
val = spdk_conf_section_get_nval(sp, "Auth", i);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
user = spdk_conf_section_get_nmval(sp, "Auth", i, 0);
|
||||
secret = spdk_conf_section_get_nmval(sp, "Auth", i, 1);
|
||||
muser = spdk_conf_section_get_nmval(sp, "Auth", i, 2);
|
||||
@ -1047,8 +1051,9 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
|
||||
data_len = 0;
|
||||
alloc_len = ISCSI_BHS_LEN + (4 * total_ahs_len);
|
||||
|
||||
if (conn->header_digest)
|
||||
if (conn->header_digest) {
|
||||
alloc_len += ISCSI_DIGEST_LEN;
|
||||
}
|
||||
|
||||
data = malloc(alloc_len);
|
||||
if (!data) {
|
||||
@ -1263,17 +1268,20 @@ spdk_iscsi_op_login_session_discovery_chap(struct spdk_iscsi_conn *conn)
|
||||
conn->req_auth = 0;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
||||
"None", "None");
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
} else if (g_spdk_iscsi.req_discovery_auth) {
|
||||
conn->req_auth = 1;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
||||
"CHAP", "CHAP");
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
if (g_spdk_iscsi.req_discovery_auth_mutual)
|
||||
if (g_spdk_iscsi.req_discovery_auth_mutual) {
|
||||
conn->req_mutual = 1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
@ -1296,18 +1304,21 @@ spdk_iscsi_op_login_negotiate_chap_param(struct spdk_iscsi_conn *conn,
|
||||
conn->req_auth = 0;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
||||
"None", "None");
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
} else if (target->auth_chap_required) {
|
||||
conn->req_auth = 1;
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "AuthMethod",
|
||||
"CHAP", "CHAP");
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (target->auth_chap_mutual)
|
||||
if (target->auth_chap_mutual) {
|
||||
conn->req_mutual = 1;
|
||||
}
|
||||
|
||||
if (target->header_digest) {
|
||||
/*
|
||||
@ -1317,8 +1328,9 @@ spdk_iscsi_op_login_negotiate_chap_param(struct spdk_iscsi_conn *conn,
|
||||
*/
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "HeaderDigest",
|
||||
"CRC32C", "CRC32C");
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (target->data_digest) {
|
||||
@ -1329,8 +1341,9 @@ spdk_iscsi_op_login_negotiate_chap_param(struct spdk_iscsi_conn *conn,
|
||||
*/
|
||||
rc = spdk_iscsi_op_login_update_param(conn, "DataDigest",
|
||||
"CRC32C", "CRC32C");
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1465,8 +1478,9 @@ spdk_iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn,
|
||||
target);
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
conn->target = *target;
|
||||
conn->dev = (*target)->dev;
|
||||
@ -1475,8 +1489,9 @@ spdk_iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn,
|
||||
|
||||
rc = spdk_iscsi_op_login_check_session(conn, rsp_pdu,
|
||||
initiator_port_name, cid);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* force target flags */
|
||||
pthread_mutex_lock(&((*target)->mutex));
|
||||
@ -1504,9 +1519,9 @@ spdk_iscsi_op_login_session_type(struct spdk_iscsi_conn *conn,
|
||||
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
||||
session_type_str = spdk_iscsi_param_get_val(params, "SessionType");
|
||||
if (session_type_str == NULL) {
|
||||
if (rsph->tsih != 0)
|
||||
if (rsph->tsih != 0) {
|
||||
*session_type = SESSION_TYPE_NORMAL;
|
||||
else {
|
||||
} else {
|
||||
SPDK_ERRLOG("SessionType is empty\n");
|
||||
/* Missing parameter */
|
||||
rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR;
|
||||
@ -1514,11 +1529,11 @@ spdk_iscsi_op_login_session_type(struct spdk_iscsi_conn *conn,
|
||||
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
||||
}
|
||||
} else {
|
||||
if (strcasecmp(session_type_str, "Discovery") == 0)
|
||||
if (strcasecmp(session_type_str, "Discovery") == 0) {
|
||||
*session_type = SESSION_TYPE_DISCOVERY;
|
||||
else if (strcasecmp(session_type_str, "Normal") == 0)
|
||||
} else if (strcasecmp(session_type_str, "Normal") == 0) {
|
||||
*session_type = SESSION_TYPE_NORMAL;
|
||||
else {
|
||||
} else {
|
||||
*session_type = SESSION_TYPE_INVALID;
|
||||
SPDK_ERRLOG("SessionType is invalid\n");
|
||||
/* Missing parameter */
|
||||
@ -1649,10 +1664,11 @@ spdk_iscsi_op_login_set_target_info(struct spdk_iscsi_conn *conn,
|
||||
/* declarative parameters */
|
||||
if (target != NULL) {
|
||||
pthread_mutex_lock(&target->mutex);
|
||||
if (target->alias != NULL)
|
||||
if (target->alias != NULL) {
|
||||
snprintf(buf, sizeof buf, "%s", target->alias);
|
||||
else
|
||||
} else {
|
||||
snprintf(buf, sizeof buf, "%s", "");
|
||||
}
|
||||
pthread_mutex_unlock(&target->mutex);
|
||||
rc = spdk_iscsi_param_set(conn->sess->params, "TargetAlias", buf);
|
||||
if (rc < 0) {
|
||||
@ -1733,21 +1749,24 @@ spdk_iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
|
||||
initiator_port_name,
|
||||
MAX_INITIATOR_NAME,
|
||||
params);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = spdk_iscsi_op_login_session_type(conn, rsp_pdu, &session_type,
|
||||
params);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Target Name and Port */
|
||||
if (session_type == SESSION_TYPE_NORMAL) {
|
||||
rc = spdk_iscsi_op_login_session_normal(conn, rsp_pdu,
|
||||
initiator_port_name,
|
||||
params, &target, cid);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
} else if (session_type == SESSION_TYPE_DISCOVERY) {
|
||||
target = NULL;
|
||||
@ -1757,8 +1776,9 @@ spdk_iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
rc = spdk_iscsi_op_login_session_discovery_chap(conn);
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
} else {
|
||||
SPDK_ERRLOG("unknown session type\n");
|
||||
/* Missing parameter */
|
||||
@ -1770,8 +1790,9 @@ spdk_iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
|
||||
rc = spdk_iscsi_op_login_set_conn_info(conn, rsp_pdu,
|
||||
initiator_port_name,
|
||||
session_type, target, cid);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* limit conns on discovery session */
|
||||
if (session_type == SESSION_TYPE_DISCOVERY) {
|
||||
@ -1787,8 +1808,9 @@ spdk_iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
|
||||
|
||||
rc = spdk_iscsi_op_login_set_target_info(conn, rsp_pdu, session_type,
|
||||
alloc_len, target);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
@ -1837,8 +1859,9 @@ spdk_iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
||||
rsph->flags |= (reqh->flags & ISCSI_LOGIN_TRANSIT);
|
||||
rsph->flags |= (reqh->flags & ISCSI_LOGIN_CONTINUE);
|
||||
rsph->flags |= (reqh->flags & ISCSI_LOGIN_CURRENT_STAGE_MASK);
|
||||
if (ISCSI_BHS_LOGIN_GET_TBIT(rsph->flags))
|
||||
if (ISCSI_BHS_LOGIN_GET_TBIT(rsph->flags)) {
|
||||
rsph->flags |= (reqh->flags & ISCSI_LOGIN_NEXT_STAGE_MASK);
|
||||
}
|
||||
|
||||
/* We don't need to convert from network byte order. Just store it */
|
||||
memcpy(&rsph->isid, reqh->isid, 6);
|
||||
@ -1847,8 +1870,9 @@ spdk_iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
|
||||
rsp_pdu->cmd_sn = from_be32(&reqh->cmd_sn);
|
||||
*cid = from_be16(&reqh->cid);
|
||||
|
||||
if (rsph->tsih)
|
||||
if (rsph->tsih) {
|
||||
rsph->stat_sn = reqh->exp_stat_sn;
|
||||
}
|
||||
|
||||
SPDK_TRACEDUMP(SPDK_LOG_ISCSI, "PDU", (uint8_t *)&pdu->bhs, ISCSI_BHS_LEN);
|
||||
|
||||
@ -1945,9 +1969,9 @@ spdk_iscsi_op_login_rsp_handle_csg_bit(struct spdk_iscsi_conn *conn,
|
||||
rsph->status_detail = ISCSI_LOGIN_MISSING_PARMS;
|
||||
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
||||
}
|
||||
if (strcasecmp(auth_method, "None") == 0)
|
||||
if (strcasecmp(auth_method, "None") == 0) {
|
||||
conn->authenticated = 1;
|
||||
else {
|
||||
} else {
|
||||
rc = spdk_iscsi_auth_params(conn, params, auth_method,
|
||||
rsp_pdu->data, alloc_len,
|
||||
rsp_pdu->data_segment_len);
|
||||
@ -2100,8 +2124,9 @@ spdk_iscsi_op_login_rsp_handle_t_bit(struct spdk_iscsi_conn *conn,
|
||||
to_be16(&rsph->tsih, conn->sess->tsih);
|
||||
|
||||
rc = spdk_iscsi_op_login_notify_session_info(conn, rsp_pdu);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
conn->full_feature = 1;
|
||||
break;
|
||||
@ -2155,12 +2180,14 @@ spdk_iscsi_op_login_rsp_handle(struct spdk_iscsi_conn *conn,
|
||||
/* handle the CSG bit case */
|
||||
rc = spdk_iscsi_op_login_rsp_handle_csg_bit(conn, rsp_pdu, *params,
|
||||
alloc_len);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* handle the T bit case */
|
||||
if (ISCSI_BHS_LOGIN_GET_TBIT(rsph->flags))
|
||||
if (ISCSI_BHS_LOGIN_GET_TBIT(rsph->flags)) {
|
||||
rc = spdk_iscsi_op_login_rsp_handle_t_bit(conn, rsp_pdu);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -2326,8 +2353,9 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
if (val != NULL) {
|
||||
if (spdk_iscsi_param_eq_val(conn->sess->params,
|
||||
"SessionType", "Discovery")) {
|
||||
if (strcasecmp(val, "") == 0)
|
||||
if (strcasecmp(val, "") == 0) {
|
||||
val = "ALL";
|
||||
}
|
||||
|
||||
data_len = spdk_iscsi_send_tgts(conn,
|
||||
conn->initiator_name,
|
||||
@ -2335,8 +2363,9 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
val, data, alloc_len,
|
||||
data_len);
|
||||
} else {
|
||||
if (strcasecmp(val, "") == 0)
|
||||
if (strcasecmp(val, "") == 0) {
|
||||
val = conn->target->name;
|
||||
}
|
||||
|
||||
if (strcasecmp(val, "ALL") == 0) {
|
||||
/* not in discovery session */
|
||||
@ -2370,11 +2399,13 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
rsp_pdu->data = data;
|
||||
rsph->opcode = ISCSI_OP_TEXT_RSP;
|
||||
|
||||
if (F_bit)
|
||||
if (F_bit) {
|
||||
rsph->flags |= ISCSI_FLAG_FINAL;
|
||||
}
|
||||
|
||||
if (C_bit)
|
||||
if (C_bit) {
|
||||
rsph->flags |= ISCSI_TEXT_CONTINUE;
|
||||
}
|
||||
|
||||
DSET24(rsph->data_segment_len, data_len);
|
||||
to_be64(&rsph->lun, lun);
|
||||
@ -2634,17 +2665,20 @@ spdk_iscsi_send_datain(struct spdk_iscsi_conn *conn,
|
||||
|
||||
rsph->opcode = ISCSI_OP_SCSI_DATAIN;
|
||||
|
||||
if (F_bit)
|
||||
if (F_bit) {
|
||||
rsph->flags |= ISCSI_FLAG_FINAL;
|
||||
}
|
||||
|
||||
/* we leave the A_bit clear */
|
||||
|
||||
if (F_bit && S_bit) {
|
||||
if (O_bit)
|
||||
if (O_bit) {
|
||||
rsph->flags |= ISCSI_DATAIN_OVERFLOW;
|
||||
}
|
||||
|
||||
if (U_bit)
|
||||
if (U_bit) {
|
||||
rsph->flags |= ISCSI_DATAIN_UNDERFLOW;
|
||||
}
|
||||
}
|
||||
|
||||
if (S_bit) {
|
||||
@ -2662,24 +2696,28 @@ spdk_iscsi_send_datain(struct spdk_iscsi_conn *conn,
|
||||
conn->StatSN++;
|
||||
}
|
||||
|
||||
if (F_bit && S_bit && !spdk_iscsi_task_is_immediate(primary))
|
||||
if (F_bit && S_bit && !spdk_iscsi_task_is_immediate(primary)) {
|
||||
conn->sess->MaxCmdSN++;
|
||||
}
|
||||
|
||||
to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN);
|
||||
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
|
||||
|
||||
to_be32(&rsph->data_sn, DataSN);
|
||||
|
||||
if (conn->sess->ErrorRecoveryLevel >= 1)
|
||||
if (conn->sess->ErrorRecoveryLevel >= 1) {
|
||||
primary->datain_datasn = DataSN;
|
||||
}
|
||||
DataSN++;
|
||||
|
||||
if (task->scsi.parent)
|
||||
if (task->scsi.parent) {
|
||||
offset += primary->scsi.data_transferred;
|
||||
}
|
||||
to_be32(&rsph->buffer_offset, (uint32_t)offset);
|
||||
|
||||
if (F_bit && S_bit)
|
||||
if (F_bit && S_bit) {
|
||||
to_be32(&rsph->res_cnt, residual_len);
|
||||
}
|
||||
|
||||
spdk_iscsi_write_pdu(conn, rsp_pdu);
|
||||
|
||||
@ -2799,12 +2837,14 @@ spdk_iscsi_transfer_in(struct spdk_iscsi_conn *conn,
|
||||
}
|
||||
}
|
||||
|
||||
if (task != primary)
|
||||
if (task != primary) {
|
||||
primary->scsi.data_transferred += task->scsi.data_transferred;
|
||||
}
|
||||
primary->datain_datasn = DataSN;
|
||||
|
||||
if (sent_status)
|
||||
if (sent_status) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2820,13 +2860,15 @@ spdk_iscsi_compare_pdu_bhs_within_existed_r2t_tasks(struct spdk_iscsi_conn *conn
|
||||
struct spdk_iscsi_task *task;
|
||||
|
||||
TAILQ_FOREACH(task, &conn->active_r2t_tasks, link) {
|
||||
if (!memcmp(&pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN))
|
||||
if (!memcmp(&pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(task, &conn->queued_r2t_tasks, link) {
|
||||
if (!memcmp(&pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN))
|
||||
if (!memcmp(&pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -3036,9 +3078,9 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
}
|
||||
|
||||
/* Non-immediate writes */
|
||||
if (pdu->data_segment_len == 0)
|
||||
if (pdu->data_segment_len == 0) {
|
||||
return 0;
|
||||
else {
|
||||
} else {
|
||||
/* we are doing the first partial write task */
|
||||
task->scsi.ref++;
|
||||
spdk_scsi_task_set_data(&task->scsi, pdu->data, pdu->data_segment_len);
|
||||
@ -3151,8 +3193,9 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
|
||||
return;
|
||||
}
|
||||
|
||||
if (primary->bytes_completed != primary->scsi.transfer_len)
|
||||
if (primary->bytes_completed != primary->scsi.transfer_len) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
o_bit = u_bit = O_bit = U_bit = 0;
|
||||
@ -3198,17 +3241,21 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
|
||||
rsph->opcode = ISCSI_OP_SCSI_RSP;
|
||||
rsph->flags |= 0x80; /* bit 0 is default to 1 */
|
||||
|
||||
if (o_bit)
|
||||
if (o_bit) {
|
||||
rsph->flags |= ISCSI_SCSI_BIDI_OVERFLOW;
|
||||
}
|
||||
|
||||
if (u_bit)
|
||||
if (u_bit) {
|
||||
rsph->flags |= ISCSI_SCSI_BIDI_UNDERFLOW;
|
||||
}
|
||||
|
||||
if (O_bit)
|
||||
if (O_bit) {
|
||||
rsph->flags |= ISCSI_SCSI_OVERFLOW;
|
||||
}
|
||||
|
||||
if (U_bit)
|
||||
if (U_bit) {
|
||||
rsph->flags |= ISCSI_SCSI_UNDERFLOW;
|
||||
}
|
||||
|
||||
rsph->status = task->scsi.status;
|
||||
if (task->scsi.sense_data_len) {
|
||||
@ -3220,8 +3267,9 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
|
||||
to_be32(&rsph->stat_sn, conn->StatSN);
|
||||
conn->StatSN++;
|
||||
|
||||
if (!spdk_iscsi_task_is_immediate(primary))
|
||||
if (!spdk_iscsi_task_is_immediate(primary)) {
|
||||
conn->sess->MaxCmdSN++;
|
||||
}
|
||||
|
||||
to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN);
|
||||
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
|
||||
@ -3337,8 +3385,9 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
#if 0
|
||||
spdk_iscsi_drop_conns(conn, conn->initiator_name, 1 /* drop all */);
|
||||
rc = spdk_iscsi_tgt_node_reset(conn->sess->target, lun);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("tgt_node reset failed\n");
|
||||
}
|
||||
#else
|
||||
task->scsi.response = SPDK_SCSI_TASK_MGMT_RESP_REJECT_FUNC_NOT_SUPPORTED;
|
||||
#endif
|
||||
@ -3351,8 +3400,9 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
spdk_iscsi_drop_conns(conn, conn->initiator_name, 1 /* drop all */);
|
||||
|
||||
rc = spdk_iscsi_tgt_node_reset(conn->sess->target, lun);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("tgt_node reset failed\n");
|
||||
}
|
||||
|
||||
conn->state = ISCSI_CONN_STATE_EXITING;
|
||||
#else
|
||||
@ -3536,8 +3586,9 @@ spdk_add_transfer_task(struct spdk_iscsi_conn *conn,
|
||||
data_len += len;
|
||||
task->next_r2t_offset = data_len;
|
||||
task->outstanding_r2t++;
|
||||
if (conn->sess->MaxOutstandingR2T == task->outstanding_r2t)
|
||||
if (conn->sess->MaxOutstandingR2T == task->outstanding_r2t) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TAILQ_INSERT_TAIL(&conn->active_r2t_tasks, task, link);
|
||||
@ -3561,8 +3612,9 @@ void spdk_del_transfer_task(struct spdk_iscsi_conn *conn, uint32_t task_tag)
|
||||
}
|
||||
|
||||
if (found) {
|
||||
for (; i < conn->pending_r2t - 1; i++)
|
||||
for (; i < conn->pending_r2t - 1; i++) {
|
||||
conn->outstanding_r2t_tasks[i] = conn->outstanding_r2t_tasks[i + 1];
|
||||
}
|
||||
|
||||
conn->pending_r2t--;
|
||||
conn->outstanding_r2t_tasks[conn->pending_r2t] = NULL;
|
||||
@ -3623,8 +3675,9 @@ void spdk_clear_all_transfer_task(struct spdk_iscsi_conn *conn,
|
||||
}
|
||||
|
||||
for (i = 0; i < pending_r2t; i++) {
|
||||
if (conn->outstanding_r2t_tasks[i] != NULL)
|
||||
if (conn->outstanding_r2t_tasks[i] != NULL) {
|
||||
continue;
|
||||
}
|
||||
for (j = i + 1; j < pending_r2t; j++) {
|
||||
if (conn->outstanding_r2t_tasks[j] != NULL) {
|
||||
conn->outstanding_r2t_tasks[i] = conn->outstanding_r2t_tasks[j];
|
||||
@ -3669,8 +3722,9 @@ spdk_iscsi_handle_r2t_snack(struct spdk_iscsi_conn *conn,
|
||||
ISCSI_REASON_INVALID_PDU_FIELD);
|
||||
}
|
||||
last_r2tsn = (beg_run + run_length);
|
||||
} else
|
||||
} else {
|
||||
last_r2tsn = task->R2TSN;
|
||||
}
|
||||
|
||||
for (i = beg_run; i < last_r2tsn; i++)
|
||||
if (spdk_iscsi_send_r2t_recovery(conn, task, i, false) < 0)
|
||||
@ -3706,9 +3760,10 @@ spdk_iscsi_handle_recovery_datain(struct spdk_iscsi_conn *conn,
|
||||
return spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
if (run_length == 0)
|
||||
if (run_length == 0) {
|
||||
/* as the DataSN begins at 0 */
|
||||
run_length = task->datain_datasn + 1;
|
||||
}
|
||||
|
||||
if ((beg_run + run_length - 1) > task->datain_datasn) {
|
||||
SPDK_ERRLOG("Initiator requests BegRun: 0x%08x, RunLength:"
|
||||
@ -3716,8 +3771,9 @@ spdk_iscsi_handle_recovery_datain(struct spdk_iscsi_conn *conn,
|
||||
beg_run, run_length, task->datain_datasn);
|
||||
|
||||
return -1;
|
||||
} else
|
||||
} else {
|
||||
last_statsn = beg_run + run_length - 1;
|
||||
}
|
||||
|
||||
for (i = beg_run; i <= last_statsn; i++) {
|
||||
TAILQ_FOREACH_SAFE(old_pdu, &conn->snack_pdu_list, tailq, pdu_temp) {
|
||||
@ -3756,9 +3812,9 @@ spdk_iscsi_handle_status_snack(struct spdk_iscsi_conn *conn,
|
||||
"%d, conn->exp_statsn=%d\n", beg_run, run_length,
|
||||
conn->StatSN, conn->exp_statsn);
|
||||
|
||||
if (!beg_run)
|
||||
if (!beg_run) {
|
||||
beg_run = conn->exp_statsn;
|
||||
else if (beg_run < conn->exp_statsn) {
|
||||
} else if (beg_run < conn->exp_statsn) {
|
||||
SPDK_ERRLOG("Got Status SNACK Begrun: 0x%08x, RunLength: 0x%08x "
|
||||
"but already got ExpStatSN: 0x%08x on CID:%hu.\n",
|
||||
beg_run, run_length, conn->StatSN, conn->cid);
|
||||
@ -3843,8 +3899,9 @@ spdk_iscsi_handle_data_ack(struct spdk_iscsi_conn *conn,
|
||||
if ((from_be32(&datain_header->ttt) == transfer_tag) &&
|
||||
(old_datasn == beg_run - 1)) {
|
||||
TAILQ_REMOVE(&conn->snack_pdu_list, old_pdu, tailq);
|
||||
if (old_pdu->task)
|
||||
if (old_pdu->task) {
|
||||
spdk_iscsi_task_put(old_pdu->task);
|
||||
}
|
||||
spdk_put_pdu(old_pdu);
|
||||
break;
|
||||
}
|
||||
@ -3888,10 +3945,11 @@ spdk_iscsi_remove_r2t_pdu_from_snack_list(struct spdk_iscsi_conn *conn,
|
||||
}
|
||||
}
|
||||
|
||||
if (found_pdu)
|
||||
if (found_pdu) {
|
||||
TAILQ_REMOVE(&conn->snack_pdu_list, pdu, tailq);
|
||||
else
|
||||
} else {
|
||||
pdu = NULL;
|
||||
}
|
||||
|
||||
return pdu;
|
||||
|
||||
@ -3932,8 +3990,9 @@ spdk_iscsi_send_r2t_recovery(struct spdk_iscsi_conn *conn,
|
||||
task->next_expected_r2t_offset));
|
||||
|
||||
/* remove the old_r2t_pdu */
|
||||
if (pdu->task)
|
||||
if (pdu->task) {
|
||||
spdk_iscsi_task_put(pdu->task);
|
||||
}
|
||||
spdk_put_pdu(pdu);
|
||||
|
||||
/* re-send a new r2t pdu */
|
||||
@ -4161,8 +4220,9 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn,
|
||||
|
||||
send_r2t_recovery_return:
|
||||
rc = spdk_iscsi_send_r2t_recovery(conn, task, task->acked_r2tsn, true);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
goto reject_return;
|
||||
}
|
||||
return rc;
|
||||
|
||||
reject_return:
|
||||
@ -4289,8 +4349,9 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
struct spdk_iscsi_sess *sess;
|
||||
struct iscsi_bhs_scsi_req *reqh;
|
||||
|
||||
if (pdu == NULL)
|
||||
if (pdu == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
opcode = pdu->bhs.opcode;
|
||||
reqh = (struct iscsi_bhs_scsi_req *)&pdu->bhs;
|
||||
@ -4334,11 +4395,12 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
SPDK_ERRLOG("CmdSN(%u) ignore (ExpCmdSN=%u, MaxCmdSN=%u)\n",
|
||||
pdu->cmd_sn, sess->ExpCmdSN, sess->MaxCmdSN);
|
||||
|
||||
if (sess->ErrorRecoveryLevel >= 1)
|
||||
if (sess->ErrorRecoveryLevel >= 1) {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Skip the error in"
|
||||
" ERL 1 and 2\n");
|
||||
else
|
||||
} else {
|
||||
return SPDK_PDU_FATAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pdu->cmd_sn != sess->ExpCmdSN) {
|
||||
@ -4364,8 +4426,9 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
ExpStatSN = conn->StatSN;
|
||||
}
|
||||
|
||||
if (sess->ErrorRecoveryLevel >= 1)
|
||||
if (sess->ErrorRecoveryLevel >= 1) {
|
||||
spdk_remove_acked_pdu(conn, ExpStatSN);
|
||||
}
|
||||
|
||||
if (opcode == ISCSI_OP_NOPOUT || opcode == ISCSI_OP_SCSI) {
|
||||
QCmdSN = sess->MaxCmdSN - sess->ExpCmdSN + 1;
|
||||
@ -4377,8 +4440,9 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
}
|
||||
}
|
||||
|
||||
if (!I_bit && opcode != ISCSI_OP_SCSI_DATAOUT)
|
||||
if (!I_bit && opcode != ISCSI_OP_SCSI_DATAOUT) {
|
||||
sess->ExpCmdSN++;
|
||||
}
|
||||
|
||||
switch (opcode) {
|
||||
case ISCSI_OP_NOPOUT:
|
||||
@ -4451,8 +4515,9 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
|
||||
void spdk_free_sess(struct spdk_iscsi_sess *sess)
|
||||
{
|
||||
if (sess == NULL)
|
||||
if (sess == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
sess->tag = 0;
|
||||
sess->target = NULL;
|
||||
@ -4481,8 +4546,9 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn,
|
||||
/* configuration values */
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
|
||||
if (target != NULL)
|
||||
if (target != NULL) {
|
||||
pthread_mutex_lock(&target->mutex);
|
||||
}
|
||||
|
||||
sess->MaxConnections = g_spdk_iscsi.MaxConnectionsPerSession;
|
||||
sess->MaxOutstandingR2T = DEFAULT_MAXOUTSTANDINGR2T;
|
||||
@ -4497,8 +4563,9 @@ spdk_create_iscsi_sess(struct spdk_iscsi_conn *conn,
|
||||
sess->DataSequenceInOrder = DEFAULT_DATASEQUENCEINORDER;
|
||||
sess->ErrorRecoveryLevel = g_spdk_iscsi.ErrorRecoveryLevel;
|
||||
|
||||
if (target != NULL)
|
||||
if (target != NULL) {
|
||||
pthread_mutex_unlock(&target->mutex);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
|
||||
@ -4685,12 +4752,14 @@ spdk_append_iscsi_sess(struct spdk_iscsi_conn *conn,
|
||||
|
||||
bool spdk_iscsi_is_deferred_free_pdu(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
if (pdu == NULL)
|
||||
if (pdu == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pdu->bhs.opcode == ISCSI_OP_R2T ||
|
||||
pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN)
|
||||
pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -88,18 +88,21 @@ spdk_iscsi_config_dump_section(FILE *fp)
|
||||
const char *authmethod = "None";
|
||||
char authgroup[32] = "None";
|
||||
|
||||
if (NULL == fp)
|
||||
if (NULL == fp) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_spdk_iscsi.req_discovery_auth)
|
||||
if (g_spdk_iscsi.req_discovery_auth) {
|
||||
authmethod = "CHAP";
|
||||
else if (g_spdk_iscsi.req_discovery_auth_mutual)
|
||||
} else if (g_spdk_iscsi.req_discovery_auth_mutual) {
|
||||
authmethod = "CHAP Mutual";
|
||||
else if (!g_spdk_iscsi.no_discovery_auth)
|
||||
} else if (!g_spdk_iscsi.no_discovery_auth) {
|
||||
authmethod = "Auto";
|
||||
}
|
||||
|
||||
if (g_spdk_iscsi.discovery_auth_group)
|
||||
if (g_spdk_iscsi.discovery_auth_group) {
|
||||
snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", g_spdk_iscsi.discovery_auth_group);
|
||||
}
|
||||
|
||||
fprintf(fp, ISCSI_CONFIG_TMPL,
|
||||
g_spdk_iscsi.nodebase, g_spdk_iscsi.authfile,
|
||||
@ -140,11 +143,11 @@ spdk_iscsi_config_dump_portal_groups(FILE *fp)
|
||||
|
||||
/* Dump portal groups */
|
||||
TAILQ_FOREACH(pg, &g_spdk_iscsi.pg_head, tailq) {
|
||||
if (NULL == pg) continue;
|
||||
if (NULL == pg) { continue; }
|
||||
fprintf(fp, PORTAL_GROUP_TMPL, pg->tag, pg->tag);
|
||||
/* Dump portals */
|
||||
TAILQ_FOREACH(p, &pg->head, per_pg_tailq) {
|
||||
if (NULL == p) continue;
|
||||
if (NULL == p) { continue; }
|
||||
fprintf(fp, PORTAL_TMPL, p->host, p->port);
|
||||
}
|
||||
}
|
||||
@ -181,7 +184,7 @@ spdk_iscsi_config_dump_initiator_groups(FILE *fp)
|
||||
|
||||
/* Dump initiator groups */
|
||||
TAILQ_FOREACH(ig, &g_spdk_iscsi.ig_head, tailq) {
|
||||
if (NULL == ig) continue;
|
||||
if (NULL == ig) { continue; }
|
||||
fprintf(fp, INITIATOR_GROUP_TMPL, ig->tag, ig->tag);
|
||||
|
||||
/* Dump initiators */
|
||||
@ -246,7 +249,7 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp)
|
||||
const char *usedigest = "Auto";
|
||||
|
||||
dev = target->dev;
|
||||
if (NULL == dev) continue;
|
||||
if (NULL == dev) { continue; }
|
||||
|
||||
idx = target->num;
|
||||
fprintf(fp, TARGET_NODE_TMPL, idx, idx, target->name, spdk_scsi_dev_get_name(dev));
|
||||
@ -259,22 +262,25 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp)
|
||||
}
|
||||
}
|
||||
|
||||
if (target->auth_chap_disabled)
|
||||
if (target->auth_chap_disabled) {
|
||||
authmethod = "None";
|
||||
else if (!target->auth_chap_required)
|
||||
} else if (!target->auth_chap_required) {
|
||||
authmethod = "Auto";
|
||||
else if (target->auth_chap_mutual)
|
||||
} else if (target->auth_chap_mutual) {
|
||||
authmethod = "CHAP Mutual";
|
||||
else
|
||||
} else {
|
||||
authmethod = "CHAP";
|
||||
}
|
||||
|
||||
if (target->auth_group > 0)
|
||||
if (target->auth_group > 0) {
|
||||
snprintf(authgroup, sizeof(authgroup), "AuthGroup%d", target->auth_group);
|
||||
}
|
||||
|
||||
if (target->header_digest)
|
||||
if (target->header_digest) {
|
||||
usedigest = "Header";
|
||||
else if (target->data_digest)
|
||||
} else if (target->data_digest) {
|
||||
usedigest = "Data";
|
||||
}
|
||||
|
||||
fprintf(fp, TARGET_NODE_AUTH_TMPL,
|
||||
authmethod, authgroup, usedigest);
|
||||
@ -489,8 +495,9 @@ spdk_iscsi_free_pools(void)
|
||||
|
||||
void spdk_put_pdu(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
if (!pdu)
|
||||
if (!pdu) {
|
||||
return;
|
||||
}
|
||||
|
||||
pdu->ref--;
|
||||
|
||||
@ -500,11 +507,13 @@ void spdk_put_pdu(struct spdk_iscsi_pdu *pdu)
|
||||
}
|
||||
|
||||
if (pdu->ref == 0) {
|
||||
if (pdu->mobj)
|
||||
if (pdu->mobj) {
|
||||
rte_mempool_put(pdu->mobj->mp, (void *)pdu->mobj);
|
||||
}
|
||||
|
||||
if (pdu->data && !pdu->data_from_mempool)
|
||||
if (pdu->data && !pdu->data_from_mempool) {
|
||||
free(pdu->data);
|
||||
}
|
||||
|
||||
rte_mempool_put(g_spdk_iscsi.pdu_pool, (void *)pdu);
|
||||
}
|
||||
@ -746,12 +755,14 @@ spdk_iscsi_read_parameters_from_config_file(struct spdk_conf_section *sp)
|
||||
}
|
||||
}
|
||||
min_conn_per_core = spdk_conf_section_get_intval(sp, "MinConnectionsPerCore");
|
||||
if (min_conn_per_core >= 0)
|
||||
if (min_conn_per_core >= 0) {
|
||||
spdk_iscsi_conn_set_min_per_core(min_conn_per_core);
|
||||
}
|
||||
|
||||
conn_idle_interval = spdk_conf_section_get_intval(sp, "MinConnectionIdleInterval");
|
||||
if (conn_idle_interval > 0)
|
||||
if (conn_idle_interval > 0) {
|
||||
spdk_iscsi_set_min_conn_idle_interval(conn_idle_interval);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -42,8 +42,9 @@ int spdk_md5init(struct spdk_md5ctx *md5ctx)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (md5ctx == NULL)
|
||||
if (md5ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
rc = MD5_Init(&md5ctx->md5ctx);
|
||||
return rc;
|
||||
}
|
||||
@ -52,8 +53,9 @@ int spdk_md5final(void *md5, struct spdk_md5ctx *md5ctx)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (md5ctx == NULL || md5 == NULL)
|
||||
if (md5ctx == NULL || md5 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
rc = MD5_Final(md5, &md5ctx->md5ctx);
|
||||
return rc;
|
||||
}
|
||||
@ -62,10 +64,12 @@ int spdk_md5update(struct spdk_md5ctx *md5ctx, const void *data, size_t len)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (md5ctx == NULL)
|
||||
if (md5ctx == NULL) {
|
||||
return -1;
|
||||
if (data == NULL || len == 0)
|
||||
}
|
||||
if (data == NULL || len == 0) {
|
||||
return 0;
|
||||
}
|
||||
rc = MD5_Update(&md5ctx->md5ctx, data, len);
|
||||
return rc;
|
||||
}
|
||||
|
@ -56,12 +56,14 @@ spdk_iscsi_param_free(struct iscsi_param *params)
|
||||
{
|
||||
struct iscsi_param *param, *next_param;
|
||||
|
||||
if (params == NULL)
|
||||
if (params == NULL) {
|
||||
return;
|
||||
}
|
||||
for (param = params; param != NULL; param = next_param) {
|
||||
next_param = param->next;
|
||||
if (param->list)
|
||||
if (param->list) {
|
||||
free(param->list);
|
||||
}
|
||||
free(param->val);
|
||||
free(param->key);
|
||||
free(param);
|
||||
@ -74,8 +76,9 @@ spdk_iscsi_find_key_in_array(const char *key, const char *array[])
|
||||
int i;
|
||||
|
||||
for (i = 0; array[i] != NULL; i++) {
|
||||
if (strcasecmp(key, array[i]) == 0)
|
||||
if (strcasecmp(key, array[i]) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -85,8 +88,9 @@ spdk_iscsi_param_find(struct iscsi_param *params, const char *key)
|
||||
{
|
||||
struct iscsi_param *param;
|
||||
|
||||
if (params == NULL || key == NULL)
|
||||
if (params == NULL || key == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (param = params; param != NULL; param = param->next) {
|
||||
if (param->key != NULL && param->key[0] == key[0]
|
||||
&& strcasecmp(param->key, key) == 0) {
|
||||
@ -102,8 +106,9 @@ spdk_iscsi_param_del(struct iscsi_param **params, const char *key)
|
||||
struct iscsi_param *param, *prev_param = NULL;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "del %s\n", key);
|
||||
if (params == NULL || key == NULL)
|
||||
if (params == NULL || key == NULL) {
|
||||
return 0;
|
||||
}
|
||||
for (param = *params; param != NULL; param = param->next) {
|
||||
if (param->key != NULL && param->key[0] == key[0]
|
||||
&& strcasecmp(param->key, key) == 0) {
|
||||
@ -129,12 +134,14 @@ spdk_iscsi_param_add(struct iscsi_param **params, const char *key,
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add %s=%s, list=[%s], type=%d\n",
|
||||
key, val, list, type);
|
||||
if (key == NULL)
|
||||
if (key == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
param = spdk_iscsi_param_find(*params, key);
|
||||
if (param != NULL)
|
||||
if (param != NULL) {
|
||||
spdk_iscsi_param_del(params, key);
|
||||
}
|
||||
|
||||
param = malloc(sizeof * param);
|
||||
if (!param) {
|
||||
@ -308,8 +315,9 @@ spdk_iscsi_parse_params(struct iscsi_param **params, const uint8_t *data,
|
||||
}
|
||||
rc = spdk_iscsi_parse_param(params, p);
|
||||
free(p);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return -1;
|
||||
}
|
||||
free(*partial_parameter);
|
||||
*partial_parameter = NULL;
|
||||
|
||||
@ -350,8 +358,9 @@ spdk_iscsi_param_get_val(struct iscsi_param *params, const char *key)
|
||||
struct iscsi_param *param;
|
||||
|
||||
param = spdk_iscsi_param_find(params, key);
|
||||
if (param == NULL)
|
||||
if (param == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return param->val;
|
||||
}
|
||||
|
||||
@ -362,10 +371,12 @@ spdk_iscsi_param_eq_val(struct iscsi_param *params, const char *key,
|
||||
struct iscsi_param *param;
|
||||
|
||||
param = spdk_iscsi_param_find(params, key);
|
||||
if (param == NULL)
|
||||
if (param == NULL) {
|
||||
return 0;
|
||||
if (strcasecmp(param->val, val) == 0)
|
||||
}
|
||||
if (strcasecmp(param->val, val) == 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -626,8 +637,9 @@ static char *spdk_iscsi_negotiate_param_list(int *add_param_value,
|
||||
char *in_start, *in_end;
|
||||
int flag = 0;
|
||||
|
||||
if (add_param_value == NULL)
|
||||
if (add_param_value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
in_start = in_val;
|
||||
do {
|
||||
@ -650,8 +662,9 @@ static char *spdk_iscsi_negotiate_param_list(int *add_param_value,
|
||||
val_start = val_end + 1;
|
||||
}
|
||||
} while (val_end);
|
||||
if (flag)
|
||||
if (flag) {
|
||||
break;
|
||||
}
|
||||
if (in_end) {
|
||||
*in_end = ',';
|
||||
in_start = in_end + 1;
|
||||
@ -677,13 +690,15 @@ static char *spdk_iscsi_negotiate_param_numerical(int *add_param_value,
|
||||
int val_i, cur_val_i;
|
||||
int min_i, max_i;
|
||||
|
||||
if (add_param_value == NULL)
|
||||
if (add_param_value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
val_i = (int)strtol(param->val, NULL, 10);
|
||||
/* check whether the key is FirstBurstLength, if that we use in_val */
|
||||
if (strcasecmp(param->key, "FirstBurstLength") == 0)
|
||||
if (strcasecmp(param->key, "FirstBurstLength") == 0) {
|
||||
val_i = (int)strtol(in_val, NULL, 10);
|
||||
}
|
||||
|
||||
cur_val_i = (int)strtol(cur_val, NULL, 10);
|
||||
valid_next = valid_list;
|
||||
@ -728,8 +743,9 @@ static char *spdk_iscsi_negotiate_param_boolean(int *add_param_value,
|
||||
{
|
||||
char *new_val = NULL;
|
||||
|
||||
if (add_param_value == NULL)
|
||||
if (add_param_value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Make sure the val is Yes or No */
|
||||
if (!((strcasecmp(in_val, "Yes") == 0) ||
|
||||
@ -744,8 +760,9 @@ static char *spdk_iscsi_negotiate_param_boolean(int *add_param_value,
|
||||
if (strcasecmp(cur_val, value) == 0) {
|
||||
snprintf(in_val, ISCSI_TEXT_MAX_VAL_LEN + 1, "%s", value);
|
||||
new_val = in_val;
|
||||
} else
|
||||
} else {
|
||||
new_val = param->val;
|
||||
}
|
||||
|
||||
return new_val;
|
||||
}
|
||||
@ -833,16 +850,18 @@ spdk_iscsi_negotiate_param_init(struct spdk_iscsi_conn *conn,
|
||||
index = (*cur_param_p)->state_index;
|
||||
if (conn->sess_param_state_negotiated[index] &&
|
||||
!spdk_iscsi_find_key_in_array(param->key,
|
||||
target_declarative_params))
|
||||
target_declarative_params)) {
|
||||
return SPDK_ISCSI_PARAMETER_EXCHANGE_NOT_ONCE;
|
||||
}
|
||||
conn->sess_param_state_negotiated[index] = true;
|
||||
}
|
||||
} else {
|
||||
index = (*cur_param_p)->state_index;
|
||||
if (conn->conn_param_state_negotiated[index] &&
|
||||
!spdk_iscsi_find_key_in_array(param->key,
|
||||
multi_negot_conn_params))
|
||||
multi_negot_conn_params)) {
|
||||
return SPDK_ISCSI_PARAMETER_EXCHANGE_NOT_ONCE;
|
||||
}
|
||||
conn->conn_param_state_negotiated[index] = true;
|
||||
}
|
||||
|
||||
@ -951,8 +970,9 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
||||
continue;
|
||||
}
|
||||
/* CHAP keys */
|
||||
if (spdk_iscsi_find_key_in_array(param->key, chap_type))
|
||||
if (spdk_iscsi_find_key_in_array(param->key, chap_type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 12.2, 12.10, 12.11, 12.13, 12.14, 12.17, 12.18, 12.19 */
|
||||
if (discovery &&
|
||||
@ -1038,8 +1058,9 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
||||
data,
|
||||
alloc_len,
|
||||
total);
|
||||
if (total < 0)
|
||||
if (total < 0) {
|
||||
goto final_return;
|
||||
}
|
||||
|
||||
total = spdk_iscsi_special_param_construction(conn,
|
||||
param,
|
||||
@ -1047,8 +1068,9 @@ spdk_iscsi_negotiate_params(struct spdk_iscsi_conn *conn,
|
||||
data,
|
||||
alloc_len,
|
||||
total);
|
||||
if (total < 0)
|
||||
if (total < 0) {
|
||||
goto final_return;
|
||||
}
|
||||
} else {
|
||||
total = -1;
|
||||
break;
|
||||
|
@ -446,8 +446,9 @@ spdk_iscsi_portal_grp_create_from_configfile(struct spdk_conf_section *sp)
|
||||
*/
|
||||
label = spdk_conf_section_get_nmval(sp, "Portal", i, 0);
|
||||
portal = spdk_conf_section_get_nmval(sp, "Portal", i, 1);
|
||||
if (label == NULL || portal == NULL)
|
||||
if (label == NULL || portal == NULL) {
|
||||
break;
|
||||
}
|
||||
rc = spdk_iscsi_portal_create_from_configline(portal, &p, 1);
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("parse portal error (%s)\n", portal);
|
||||
@ -634,8 +635,9 @@ spdk_iscsi_portal_grp_unregister(struct spdk_iscsi_portal_grp *pg)
|
||||
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
TAILQ_FOREACH_SAFE(portal_group, &g_spdk_iscsi.pg_head, tailq, portal_group_tmp) {
|
||||
if (portal_group->tag == pg->tag)
|
||||
if (portal_group->tag == pg->tag) {
|
||||
TAILQ_REMOVE(&g_spdk_iscsi.pg_head, portal_group, tailq);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
}
|
||||
|
@ -63,14 +63,17 @@ spdk_iscsi_ipv6_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
int bits, bmask;
|
||||
int i;
|
||||
|
||||
if (netmask[0] != '[')
|
||||
if (netmask[0] != '[') {
|
||||
return false;
|
||||
}
|
||||
p = strchr(netmask, ']');
|
||||
if (p == NULL)
|
||||
if (p == NULL) {
|
||||
return false;
|
||||
}
|
||||
n = p - (netmask + 1);
|
||||
if (n + 1 > sizeof mask)
|
||||
if (n + 1 > sizeof mask) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(mask, netmask + 1, n);
|
||||
mask[n] = '\0';
|
||||
@ -78,8 +81,9 @@ spdk_iscsi_ipv6_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
|
||||
if (p[0] == '/') {
|
||||
bits = (int) strtol(p + 1, NULL, 10);
|
||||
if (bits < 0 || bits > 128)
|
||||
if (bits < 0 || bits > 128) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
bits = 128;
|
||||
}
|
||||
@ -97,13 +101,15 @@ spdk_iscsi_ipv6_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
|
||||
/* check 128bits */
|
||||
for (i = 0; i < (bits / 8); i++) {
|
||||
if (in6_mask.s6_addr[i] != in6_addr.s6_addr[i])
|
||||
if (in6_mask.s6_addr[i] != in6_addr.s6_addr[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (bits % 8) {
|
||||
bmask = (0xffU << (8 - (bits % 8))) & 0xffU;
|
||||
if ((in6_mask.s6_addr[i] & bmask) != (in6_addr.s6_addr[i] & bmask))
|
||||
if ((in6_mask.s6_addr[i] & bmask) != (in6_addr.s6_addr[i] & bmask)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* match */
|
||||
@ -126,16 +132,18 @@ spdk_iscsi_ipv4_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
p = netmask + strlen(netmask);
|
||||
}
|
||||
n = p - netmask;
|
||||
if (n + 1 > sizeof mask)
|
||||
if (n + 1 > sizeof mask) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(mask, netmask, n);
|
||||
mask[n] = '\0';
|
||||
|
||||
if (p[0] == '/') {
|
||||
bits = (int) strtol(p + 1, NULL, 10);
|
||||
if (bits < 0 || bits > 32)
|
||||
if (bits < 0 || bits > 32) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
bits = 32;
|
||||
}
|
||||
@ -148,8 +156,9 @@ spdk_iscsi_ipv4_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
|
||||
/* check 32bits */
|
||||
bmask = (0xffffffffULL << (32 - bits)) & 0xffffffffU;
|
||||
if ((ntohl(in4_mask.s_addr) & bmask) != (ntohl(in4_addr.s_addr) & bmask))
|
||||
if ((ntohl(in4_mask.s_addr) & bmask) != (ntohl(in4_addr.s_addr) & bmask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* match */
|
||||
return true;
|
||||
@ -158,18 +167,22 @@ spdk_iscsi_ipv4_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
static bool
|
||||
spdk_iscsi_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
{
|
||||
if (netmask == NULL || addr == NULL)
|
||||
if (netmask == NULL || addr == NULL) {
|
||||
return false;
|
||||
if (strcasecmp(netmask, "ALL") == 0)
|
||||
}
|
||||
if (strcasecmp(netmask, "ALL") == 0) {
|
||||
return true;
|
||||
}
|
||||
if (netmask[0] == '[') {
|
||||
/* IPv6 */
|
||||
if (spdk_iscsi_ipv6_netmask_allow_addr(netmask, addr))
|
||||
if (spdk_iscsi_ipv6_netmask_allow_addr(netmask, addr)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
/* IPv4 */
|
||||
if (spdk_iscsi_ipv4_netmask_allow_addr(netmask, addr))
|
||||
if (spdk_iscsi_ipv4_netmask_allow_addr(netmask, addr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -228,8 +241,9 @@ spdk_iscsi_tgt_node_access(struct spdk_iscsi_conn *conn,
|
||||
int rc;
|
||||
bool allowed = false;
|
||||
|
||||
if (conn == NULL || target == NULL || iqn == NULL || addr == NULL)
|
||||
if (conn == NULL || target == NULL || iqn == NULL || addr == NULL) {
|
||||
return false;
|
||||
}
|
||||
pg = conn->portal->group;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "pg=%d, iqn=%s, addr=%s\n",
|
||||
@ -268,8 +282,9 @@ spdk_iscsi_tgt_node_allow_iscsi_name(struct spdk_iscsi_tgt_node *target, const c
|
||||
int rc;
|
||||
bool result = false;
|
||||
|
||||
if (target == NULL || iqn == NULL)
|
||||
if (target == NULL || iqn == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(pg_map, &target->pg_map_head, tailq) {
|
||||
TAILQ_FOREACH(ig_map, &pg_map->ig_map_head, tailq) {
|
||||
@ -298,8 +313,9 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
||||
int len;
|
||||
int rc;
|
||||
|
||||
if (conn == NULL)
|
||||
if (conn == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
total = data_len;
|
||||
if (alloc_len < 1) {
|
||||
@ -386,8 +402,9 @@ spdk_iscsi_find_tgt_node(const char *target_name)
|
||||
{
|
||||
struct spdk_iscsi_tgt_node *target;
|
||||
|
||||
if (target_name == NULL)
|
||||
if (target_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
TAILQ_FOREACH(target, &g_spdk_iscsi.target_head, tailq) {
|
||||
if (strcasecmp(target_name, target->name) == 0) {
|
||||
return target;
|
||||
@ -786,18 +803,24 @@ spdk_check_iscsi_name(const char *name)
|
||||
|
||||
/* valid iSCSI name? */
|
||||
for (n = 0; up[n] != 0; n++) {
|
||||
if (up[n] > 0x00U && up[n] <= 0x2cU)
|
||||
if (up[n] > 0x00U && up[n] <= 0x2cU) {
|
||||
return -1;
|
||||
if (up[n] == 0x2fU)
|
||||
}
|
||||
if (up[n] == 0x2fU) {
|
||||
return -1;
|
||||
if (up[n] >= 0x3bU && up[n] <= 0x40U)
|
||||
}
|
||||
if (up[n] >= 0x3bU && up[n] <= 0x40U) {
|
||||
return -1;
|
||||
if (up[n] >= 0x5bU && up[n] <= 0x60U)
|
||||
}
|
||||
if (up[n] >= 0x5bU && up[n] <= 0x60U) {
|
||||
return -1;
|
||||
if (up[n] >= 0x7bU && up[n] <= 0x7fU)
|
||||
}
|
||||
if (up[n] >= 0x7bU && up[n] <= 0x7fU) {
|
||||
return -1;
|
||||
if (isspace(up[n]))
|
||||
}
|
||||
if (isspace(up[n])) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* valid format? */
|
||||
if (strncasecmp(name, "iqn.", 4) == 0) {
|
||||
@ -852,8 +875,9 @@ spdk_iscsi_tgt_node_construct(int target_index,
|
||||
&& strncasecmp(name, "eui.", 4) != 0
|
||||
&& strncasecmp(name, "naa.", 4) != 0) {
|
||||
snprintf(fullname, sizeof(fullname), "%s:%s", g_spdk_iscsi.nodebase, name);
|
||||
} else
|
||||
} else {
|
||||
snprintf(fullname, sizeof(fullname), "%s", name);
|
||||
}
|
||||
|
||||
if (spdk_check_iscsi_name(fullname) != 0) {
|
||||
SPDK_ERRLOG("TargetName %s contains an invalid character or format.\n",
|
||||
@ -983,8 +1007,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
||||
|
||||
for (i = 0; i < MAX_TARGET_MAP; i++) {
|
||||
val = spdk_conf_section_get_nmval(sp, "Mapping", i, 0);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
pg_tag = spdk_conf_section_get_nmval(sp, "Mapping", i, 0);
|
||||
ig_tag = spdk_conf_section_get_nmval(sp, "Mapping", i, 1);
|
||||
if (pg_tag == NULL || ig_tag == NULL) {
|
||||
@ -1021,8 +1046,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
||||
if (val != NULL) {
|
||||
for (i = 0; ; i++) {
|
||||
val = spdk_conf_section_get_nmval(sp, "AuthMethod", 0, i);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
if (strcasecmp(val, "CHAP") == 0) {
|
||||
auth_chap_required = 1;
|
||||
} else if (strcasecmp(val, "Mutual") == 0) {
|
||||
@ -1085,8 +1111,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
|
||||
if (val != NULL) {
|
||||
for (i = 0; ; i++) {
|
||||
val = spdk_conf_section_get_nmval(sp, "UseDigest", 0, i);
|
||||
if (val == NULL)
|
||||
if (val == NULL) {
|
||||
break;
|
||||
}
|
||||
if (strcasecmp(val, "Header") == 0) {
|
||||
header_digest = 1;
|
||||
} else if (strcasecmp(val, "Data") == 0) {
|
||||
@ -1223,8 +1250,9 @@ spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
||||
struct spdk_scsi_lun *lun = spdk_scsi_dev_get_lun(target->dev, i);
|
||||
|
||||
if (!lun)
|
||||
if (!lun) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* we create a fake management task per LUN to cleanup */
|
||||
task = spdk_iscsi_task_get(conn, NULL, spdk_iscsi_task_mgmt_cpl);
|
||||
|
@ -60,23 +60,23 @@ decode:
|
||||
/* \uXXXX */
|
||||
assert(buf_end > str);
|
||||
|
||||
if (*str++ != '\\') return SPDK_JSON_PARSE_INVALID;
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if (*str++ != '\\') { return SPDK_JSON_PARSE_INVALID; }
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
|
||||
if (*str++ != 'u') return SPDK_JSON_PARSE_INVALID;
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if (*str++ != 'u') { return SPDK_JSON_PARSE_INVALID; }
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
|
||||
if ((v3 = hex_value(*str++)) < 0) return SPDK_JSON_PARSE_INVALID;
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if ((v3 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; }
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
|
||||
if ((v2 = hex_value(*str++)) < 0) return SPDK_JSON_PARSE_INVALID;
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if ((v2 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; }
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
|
||||
if ((v1 = hex_value(*str++)) < 0) return SPDK_JSON_PARSE_INVALID;
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if ((v1 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; }
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
|
||||
if ((v0 = hex_value(*str++)) < 0) return SPDK_JSON_PARSE_INVALID;
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if ((v0 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; }
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
|
||||
val = v0 | (v1 << 4) | (v2 << 8) | (v3 << 12);
|
||||
|
||||
@ -98,7 +98,7 @@ decode:
|
||||
*
|
||||
* Loop around to get the low half of the surrogate pair.
|
||||
*/
|
||||
if (buf_end == str) return SPDK_JSON_PARSE_INCOMPLETE;
|
||||
if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; }
|
||||
goto decode;
|
||||
} else if (utf16_valid_surrogate_low(val)) {
|
||||
/*
|
||||
@ -261,20 +261,20 @@ json_valid_number(uint8_t *start, uint8_t *buf_end)
|
||||
uint8_t *p = start;
|
||||
uint8_t c;
|
||||
|
||||
if (p >= buf_end) return -1;
|
||||
if (p >= buf_end) { return -1; }
|
||||
|
||||
c = *p++;
|
||||
if (c >= '1' && c <= '9') goto num_int_digits;
|
||||
if (c == '0') goto num_frac_or_exp;
|
||||
if (c == '-') goto num_int_first_digit;
|
||||
if (c >= '1' && c <= '9') { goto num_int_digits; }
|
||||
if (c == '0') { goto num_frac_or_exp; }
|
||||
if (c == '-') { goto num_int_first_digit; }
|
||||
p--;
|
||||
goto done_invalid;
|
||||
|
||||
num_int_first_digit:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c == '0') goto num_frac_or_exp;
|
||||
if (c >= '1' && c <= '9') goto num_int_digits;
|
||||
if (c == '0') { goto num_frac_or_exp; }
|
||||
if (c >= '1' && c <= '9') { goto num_int_digits; }
|
||||
p--;
|
||||
}
|
||||
goto done_invalid;
|
||||
@ -282,9 +282,9 @@ num_int_first_digit:
|
||||
num_int_digits:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c >= '0' && c <= '9') goto num_int_digits;
|
||||
if (c == '.') goto num_frac_first_digit;
|
||||
if (c == 'e' || c == 'E') goto num_exp_sign;
|
||||
if (c >= '0' && c <= '9') { goto num_int_digits; }
|
||||
if (c == '.') { goto num_frac_first_digit; }
|
||||
if (c == 'e' || c == 'E') { goto num_exp_sign; }
|
||||
p--;
|
||||
}
|
||||
goto done_valid;
|
||||
@ -292,8 +292,8 @@ num_int_digits:
|
||||
num_frac_or_exp:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c == '.') goto num_frac_first_digit;
|
||||
if (c == 'e' || c == 'E') goto num_exp_sign;
|
||||
if (c == '.') { goto num_frac_first_digit; }
|
||||
if (c == 'e' || c == 'E') { goto num_exp_sign; }
|
||||
p--;
|
||||
}
|
||||
goto done_valid;
|
||||
@ -301,7 +301,7 @@ num_frac_or_exp:
|
||||
num_frac_first_digit:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c >= '0' && c <= '9') goto num_frac_digits;
|
||||
if (c >= '0' && c <= '9') { goto num_frac_digits; }
|
||||
p--;
|
||||
}
|
||||
goto done_invalid;
|
||||
@ -309,8 +309,8 @@ num_frac_first_digit:
|
||||
num_frac_digits:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c >= '0' && c <= '9') goto num_frac_digits;
|
||||
if (c == 'e' || c == 'E') goto num_exp_sign;
|
||||
if (c >= '0' && c <= '9') { goto num_frac_digits; }
|
||||
if (c == 'e' || c == 'E') { goto num_exp_sign; }
|
||||
p--;
|
||||
}
|
||||
goto done_valid;
|
||||
@ -318,8 +318,8 @@ num_frac_digits:
|
||||
num_exp_sign:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c >= '0' && c <= '9') goto num_exp_digits;
|
||||
if (c == '-' || c == '+') goto num_exp_first_digit;
|
||||
if (c >= '0' && c <= '9') { goto num_exp_digits; }
|
||||
if (c == '-' || c == '+') { goto num_exp_first_digit; }
|
||||
p--;
|
||||
}
|
||||
goto done_invalid;
|
||||
@ -327,7 +327,7 @@ num_exp_sign:
|
||||
num_exp_first_digit:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c >= '0' && c <= '9') goto num_exp_digits;
|
||||
if (c >= '0' && c <= '9') { goto num_exp_digits; }
|
||||
p--;
|
||||
}
|
||||
goto done_invalid;
|
||||
@ -335,7 +335,7 @@ num_exp_first_digit:
|
||||
num_exp_digits:
|
||||
if (spdk_likely(p != buf_end)) {
|
||||
c = *p++;
|
||||
if (c >= '0' && c <= '9') goto num_exp_digits;
|
||||
if (c >= '0' && c <= '9') { goto num_exp_digits; }
|
||||
p--;
|
||||
}
|
||||
goto done_valid;
|
||||
@ -483,11 +483,11 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
case 'f':
|
||||
case 'n':
|
||||
/* true, false, or null */
|
||||
if (state != STATE_VALUE) goto done_invalid;
|
||||
if (state != STATE_VALUE) { goto done_invalid; }
|
||||
lit = &g_json_literals[(c >> 3) & 3]; /* See comment above g_json_literals[] */
|
||||
assert(lit->str[0] == c);
|
||||
rc = match_literal(data, json_end, lit->str, lit->len);
|
||||
if (rc < 0) goto done_rc;
|
||||
if (rc < 0) { goto done_rc; }
|
||||
ADD_VALUE(lit->type, data, data + rc);
|
||||
data += rc;
|
||||
state = depth ? STATE_VALUE_SEPARATOR : STATE_END;
|
||||
@ -495,7 +495,7 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (state != STATE_VALUE && state != STATE_NAME) goto done_invalid;
|
||||
if (state != STATE_VALUE && state != STATE_NAME) { goto done_invalid; }
|
||||
rc = json_decode_string(data, json_end, &new_data, flags);
|
||||
if (rc < 0) {
|
||||
data = new_data;
|
||||
@ -527,9 +527,9 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (state != STATE_VALUE) goto done_invalid;
|
||||
if (state != STATE_VALUE) { goto done_invalid; }
|
||||
rc = json_valid_number(data, json_end);
|
||||
if (rc < 0) goto done_rc;
|
||||
if (rc < 0) { goto done_rc; }
|
||||
ADD_VALUE(SPDK_JSON_VAL_NUMBER, data, data + rc);
|
||||
data += rc;
|
||||
state = depth ? STATE_VALUE_SEPARATOR : STATE_END;
|
||||
@ -538,7 +538,7 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
|
||||
case '{':
|
||||
case '[':
|
||||
if (state != STATE_VALUE) goto done_invalid;
|
||||
if (state != STATE_VALUE) { goto done_invalid; }
|
||||
if (depth == SPDK_JSON_MAX_NESTING_DEPTH) {
|
||||
rc = SPDK_JSON_PARSE_MAX_DEPTH_EXCEEDED;
|
||||
goto done_rc;
|
||||
@ -559,8 +559,8 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
|
||||
case '}':
|
||||
case ']':
|
||||
if (trailing_comma) goto done_invalid;
|
||||
if (depth == 0) goto done_invalid;
|
||||
if (trailing_comma) { goto done_invalid; }
|
||||
if (depth == 0) { goto done_invalid; }
|
||||
con_type = containers[--depth];
|
||||
con_start_value = con_value[depth];
|
||||
if (values && con_start_value < num_values) {
|
||||
@ -590,7 +590,7 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if (state != STATE_VALUE_SEPARATOR) goto done_invalid;
|
||||
if (state != STATE_VALUE_SEPARATOR) { goto done_invalid; }
|
||||
data++;
|
||||
assert(con_type == SPDK_JSON_VAL_ARRAY_BEGIN ||
|
||||
con_type == SPDK_JSON_VAL_OBJECT_BEGIN);
|
||||
@ -599,7 +599,7 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (state != STATE_NAME_SEPARATOR) goto done_invalid;
|
||||
if (state != STATE_NAME_SEPARATOR) { goto done_invalid; }
|
||||
data++;
|
||||
state = STATE_VALUE;
|
||||
break;
|
||||
@ -609,7 +609,7 @@ spdk_json_parse(void *json, size_t size, struct spdk_json_val *values, size_t nu
|
||||
goto done_invalid;
|
||||
}
|
||||
rc = json_valid_comment(data, json_end);
|
||||
if (rc < 0) goto done_rc;
|
||||
if (rc < 0) { goto done_rc; }
|
||||
/* Skip over comment */
|
||||
data += rc;
|
||||
break;
|
||||
|
@ -166,7 +166,7 @@ emit_indent(struct spdk_json_write_ctx *w)
|
||||
|
||||
if (w->flags & SPDK_JSON_WRITE_FLAG_FORMATTED) {
|
||||
for (i = 0; i < w->indent; i++) {
|
||||
if (emit(w, " ", 2)) return fail(w);
|
||||
if (emit(w, " ", 2)) { return fail(w); }
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -177,13 +177,13 @@ begin_value(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
// TODO: check for value state
|
||||
if (w->new_indent) {
|
||||
if (emit_fmt(w, "\n", 1)) return fail(w);
|
||||
if (emit_indent(w)) return fail(w);
|
||||
if (emit_fmt(w, "\n", 1)) { return fail(w); }
|
||||
if (emit_indent(w)) { return fail(w); }
|
||||
}
|
||||
if (!w->first_value) {
|
||||
if (emit(w, ",", 1)) return fail(w);
|
||||
if (emit_fmt(w, "\n", 1)) return fail(w);
|
||||
if (emit_indent(w)) return fail(w);
|
||||
if (emit(w, ",", 1)) { return fail(w); }
|
||||
if (emit_fmt(w, "\n", 1)) { return fail(w); }
|
||||
if (emit_indent(w)) { return fail(w); }
|
||||
}
|
||||
w->first_value = false;
|
||||
w->new_indent = false;
|
||||
@ -193,21 +193,21 @@ begin_value(struct spdk_json_write_ctx *w)
|
||||
int
|
||||
spdk_json_write_val_raw(struct spdk_json_write_ctx *w, const void *data, size_t len)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
return emit(w, data, len);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_json_write_null(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
return emit(w, "null", 4);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_json_write_bool(struct spdk_json_write_ctx *w, bool val)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
if (val) {
|
||||
return emit(w, "true", 4);
|
||||
} else {
|
||||
@ -221,9 +221,9 @@ spdk_json_write_int32(struct spdk_json_write_ctx *w, int32_t val)
|
||||
char buf[32];
|
||||
int count;
|
||||
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
count = snprintf(buf, sizeof(buf), "%" PRId32, val);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) { return fail(w); }
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
@ -233,9 +233,9 @@ spdk_json_write_uint32(struct spdk_json_write_ctx *w, uint32_t val)
|
||||
char buf[32];
|
||||
int count;
|
||||
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
count = snprintf(buf, sizeof(buf), "%" PRIu32, val);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) { return fail(w); }
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
@ -245,9 +245,9 @@ spdk_json_write_int64(struct spdk_json_write_ctx *w, int64_t val)
|
||||
char buf[32];
|
||||
int count;
|
||||
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
count = snprintf(buf, sizeof(buf), "%" PRId64, val);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) { return fail(w); }
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
@ -257,9 +257,9 @@ spdk_json_write_uint64(struct spdk_json_write_ctx *w, uint64_t val)
|
||||
char buf[32];
|
||||
int count;
|
||||
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
count = snprintf(buf, sizeof(buf), "%" PRIu64, val);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) { return fail(w); }
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ write_string_or_name(struct spdk_json_write_ctx *w, const char *val, size_t len)
|
||||
const uint8_t *p = val;
|
||||
const uint8_t *end = val + len;
|
||||
|
||||
if (emit(w, "\"", 1)) return fail(w);
|
||||
if (emit(w, "\"", 1)) { return fail(w); }
|
||||
|
||||
while (p != end) {
|
||||
int codepoint_len;
|
||||
@ -355,7 +355,7 @@ write_string_or_name(struct spdk_json_write_ctx *w, const char *val, size_t len)
|
||||
return fail(w);
|
||||
}
|
||||
|
||||
if (write_codepoint(w, codepoint)) return fail(w);
|
||||
if (write_codepoint(w, codepoint)) { return fail(w); }
|
||||
p += codepoint_len;
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ write_string_or_name_utf16le(struct spdk_json_write_ctx *w, const uint16_t *val,
|
||||
const uint16_t *p = val;
|
||||
const uint16_t *end = val + len;
|
||||
|
||||
if (emit(w, "\"", 1)) return fail(w);
|
||||
if (emit(w, "\"", 1)) { return fail(w); }
|
||||
|
||||
while (p != end) {
|
||||
int codepoint_len;
|
||||
@ -386,7 +386,7 @@ write_string_or_name_utf16le(struct spdk_json_write_ctx *w, const uint16_t *val,
|
||||
return fail(w);
|
||||
}
|
||||
|
||||
if (write_codepoint(w, codepoint)) return fail(w);
|
||||
if (write_codepoint(w, codepoint)) { return fail(w); }
|
||||
p += codepoint_len;
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ write_string_or_name_utf16le(struct spdk_json_write_ctx *w, const uint16_t *val,
|
||||
int
|
||||
spdk_json_write_string_raw(struct spdk_json_write_ctx *w, const char *val, size_t len)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
return write_string_or_name(w, val, len);
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ spdk_json_write_string(struct spdk_json_write_ctx *w, const char *val)
|
||||
int
|
||||
spdk_json_write_string_utf16le_raw(struct spdk_json_write_ctx *w, const uint16_t *val, size_t len)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
return write_string_or_name_utf16le(w, val, len);
|
||||
}
|
||||
|
||||
@ -449,11 +449,11 @@ spdk_json_write_string_fmt(struct spdk_json_write_ctx *w, const char *fmt, ...)
|
||||
int
|
||||
spdk_json_write_array_begin(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
w->first_value = true;
|
||||
w->new_indent = true;
|
||||
w->indent++;
|
||||
if (emit(w, "[", 1)) return fail(w);
|
||||
if (emit(w, "[", 1)) { return fail(w); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -461,11 +461,11 @@ int
|
||||
spdk_json_write_array_end(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
w->first_value = false;
|
||||
if (w->indent == 0) return fail(w);
|
||||
if (w->indent == 0) { return fail(w); }
|
||||
w->indent--;
|
||||
if (!w->new_indent) {
|
||||
if (emit_fmt(w, "\n", 1)) return fail(w);
|
||||
if (emit_indent(w)) return fail(w);
|
||||
if (emit_fmt(w, "\n", 1)) { return fail(w); }
|
||||
if (emit_indent(w)) { return fail(w); }
|
||||
}
|
||||
w->new_indent = false;
|
||||
return emit(w, "]", 1);
|
||||
@ -474,11 +474,11 @@ spdk_json_write_array_end(struct spdk_json_write_ctx *w)
|
||||
int
|
||||
spdk_json_write_object_begin(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
w->first_value = true;
|
||||
w->new_indent = true;
|
||||
w->indent++;
|
||||
if (emit(w, "{", 1)) return fail(w);
|
||||
if (emit(w, "{", 1)) { return fail(w); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -488,8 +488,8 @@ spdk_json_write_object_end(struct spdk_json_write_ctx *w)
|
||||
w->first_value = false;
|
||||
w->indent--;
|
||||
if (!w->new_indent) {
|
||||
if (emit_fmt(w, "\n", 1)) return fail(w);
|
||||
if (emit_indent(w)) return fail(w);
|
||||
if (emit_fmt(w, "\n", 1)) { return fail(w); }
|
||||
if (emit_indent(w)) { return fail(w); }
|
||||
}
|
||||
w->new_indent = false;
|
||||
return emit(w, "}", 1);
|
||||
@ -499,10 +499,10 @@ int
|
||||
spdk_json_write_name_raw(struct spdk_json_write_ctx *w, const char *name, size_t len)
|
||||
{
|
||||
/* TODO: check that container is an object */
|
||||
if (begin_value(w)) return fail(w);
|
||||
if (write_string_or_name(w, name, len)) return fail(w);
|
||||
if (begin_value(w)) { return fail(w); }
|
||||
if (write_string_or_name(w, name, len)) { return fail(w); }
|
||||
w->first_value = true;
|
||||
if (emit(w, ":", 1)) return fail(w);
|
||||
if (emit(w, ":", 1)) { return fail(w); }
|
||||
return emit_fmt(w, " ", 1);
|
||||
}
|
||||
|
||||
|
@ -668,8 +668,9 @@ _spdk_lvs_destruct_cb(void *cb_arg, int lvserrno)
|
||||
|
||||
SPDK_INFOLOG(SPDK_LOG_LVOL, "Lvol store bdev deleted\n");
|
||||
|
||||
if (req->cb_fn != NULL)
|
||||
if (req->cb_fn != NULL) {
|
||||
req->cb_fn(req->cb_arg, lvserrno);
|
||||
}
|
||||
free(req);
|
||||
}
|
||||
|
||||
@ -797,8 +798,9 @@ _spdk_lvol_delete_blob_cb(void *cb_arg, int lvolerrno)
|
||||
TAILQ_REMOVE(&lvol->lvol_store->lvols, lvol, link);
|
||||
|
||||
if (lvol->lvol_store->destruct_req && TAILQ_EMPTY(&lvol->lvol_store->lvols)) {
|
||||
if (lvol->lvol_store->destruct)
|
||||
if (lvol->lvol_store->destruct) {
|
||||
spdk_lvs_destroy(lvol->lvol_store, _spdk_lvs_destruct_cb, lvol->lvol_store->destruct_req);
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_INFOLOG(SPDK_LOG_LVOL, "Lvol %s deleted\n", lvol->old_name);
|
||||
|
@ -331,8 +331,9 @@ static int netlink_addr_msg(uint32_t ifc_idx, uint32_t ip_address, uint32_t crea
|
||||
} req;
|
||||
struct rtattr *rta;
|
||||
|
||||
if (spdk_interface_available(ifc_idx))
|
||||
if (spdk_interface_available(ifc_idx)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
if (fd < 0) {
|
||||
|
@ -43,8 +43,9 @@ static int get_addr_str(struct sockaddr *sa, char *host, size_t hlen)
|
||||
{
|
||||
const char *result = NULL;
|
||||
|
||||
if (sa == NULL || host == NULL)
|
||||
if (sa == NULL || host == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
@ -59,10 +60,11 @@ static int get_addr_str(struct sockaddr *sa, char *host, size_t hlen)
|
||||
break;
|
||||
}
|
||||
|
||||
if (result != NULL)
|
||||
if (result != NULL) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -132,13 +134,15 @@ spdk_sock_create(const char *ip, int port, enum spdk_sock_create_type type)
|
||||
int val = 1;
|
||||
int rc;
|
||||
|
||||
if (ip == NULL)
|
||||
if (ip == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (ip[0] == '[') {
|
||||
snprintf(buf, sizeof(buf), "%s", ip + 1);
|
||||
p = strchr(buf, ']');
|
||||
if (p != NULL)
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
}
|
||||
ip = (const char *) &buf[0];
|
||||
}
|
||||
|
||||
@ -284,8 +288,9 @@ spdk_sock_set_recvlowat(int s, int nbytes)
|
||||
|
||||
val = nbytes;
|
||||
rc = setsockopt(s, SOL_SOCKET, SO_RCVLOWAT, &val, sizeof val);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1844,8 +1844,9 @@ spdk_nvme_ctrlr_attach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
status.done = false;
|
||||
res = nvme_ctrlr_cmd_attach_ns(ctrlr, nsid, payload,
|
||||
nvme_completion_poll_cb, &status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
|
||||
@ -1869,8 +1870,9 @@ spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
status.done = false;
|
||||
res = nvme_ctrlr_cmd_detach_ns(ctrlr, nsid, payload,
|
||||
nvme_completion_poll_cb, &status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
|
||||
@ -1892,8 +1894,9 @@ spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns_dat
|
||||
|
||||
status.done = false;
|
||||
res = nvme_ctrlr_cmd_create_ns(ctrlr, payload, nvme_completion_poll_cb, &status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return 0;
|
||||
}
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
|
||||
@ -1921,8 +1924,9 @@ spdk_nvme_ctrlr_delete_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
|
||||
|
||||
status.done = false;
|
||||
res = nvme_ctrlr_cmd_delete_ns(ctrlr, nsid, nvme_completion_poll_cb, &status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
|
||||
@ -1946,8 +1950,9 @@ spdk_nvme_ctrlr_format(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
status.done = false;
|
||||
res = nvme_ctrlr_cmd_format(ctrlr, nsid, format, nvme_completion_poll_cb,
|
||||
&status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
|
||||
@ -2003,8 +2008,9 @@ spdk_nvme_ctrlr_update_firmware(struct spdk_nvme_ctrlr *ctrlr, void *payload, ui
|
||||
res = nvme_ctrlr_cmd_fw_image_download(ctrlr, transfer, offset, p,
|
||||
nvme_completion_poll_cb,
|
||||
&status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
@ -2029,8 +2035,9 @@ spdk_nvme_ctrlr_update_firmware(struct spdk_nvme_ctrlr *ctrlr, void *payload, ui
|
||||
|
||||
res = nvme_ctrlr_cmd_fw_commit(ctrlr, &fw_commit, nvme_completion_poll_cb,
|
||||
&status);
|
||||
if (res)
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
while (status.done == false) {
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
|
@ -68,8 +68,9 @@ spdk_nvme_ctrlr_cmd_io_raw_with_md(struct spdk_nvme_ctrlr *ctrlr,
|
||||
payload.md = md_buf;
|
||||
|
||||
req = nvme_allocate_request(qpair, &payload, len, cb_fn, cb_arg);
|
||||
if (req == NULL)
|
||||
if (req == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(&req->cmd, cmd, sizeof(req->cmd));
|
||||
|
||||
|
@ -539,8 +539,9 @@ spdk_nvme_ns_cmd_comparev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair
|
||||
struct nvme_request *req;
|
||||
struct nvme_payload payload;
|
||||
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL)
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload.type = NVME_PAYLOAD_TYPE_SGL;
|
||||
payload.md = NULL;
|
||||
@ -615,8 +616,9 @@ spdk_nvme_ns_cmd_readv(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
struct nvme_request *req;
|
||||
struct nvme_payload payload;
|
||||
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL)
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload.type = NVME_PAYLOAD_TYPE_SGL;
|
||||
payload.md = NULL;
|
||||
@ -687,8 +689,9 @@ spdk_nvme_ns_cmd_writev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
struct nvme_request *req;
|
||||
struct nvme_payload payload;
|
||||
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL)
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload.type = NVME_PAYLOAD_TYPE_SGL;
|
||||
payload.md = NULL;
|
||||
@ -898,8 +901,9 @@ spdk_nvme_ns_cmd_reservation_report(struct spdk_nvme_ns *ns,
|
||||
struct nvme_request *req;
|
||||
struct spdk_nvme_cmd *cmd;
|
||||
|
||||
if (len % 4)
|
||||
if (len % 4) {
|
||||
return -EINVAL;
|
||||
}
|
||||
num_dwords = len / 4;
|
||||
|
||||
req = nvme_allocate_request_user_copy(qpair, payload, len, cb_fn, cb_arg, false);
|
||||
|
@ -428,13 +428,15 @@ nvme_pcie_ctrlr_map_cmb(struct nvme_pcie_ctrlr *pctrlr)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!cmbsz.bits.sz)
|
||||
if (!cmbsz.bits.sz) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
bir = cmbloc.bits.bir;
|
||||
/* Values 0 2 3 4 5 are valid for BAR */
|
||||
if (bir > 5 || bir == 1)
|
||||
if (bir > 5 || bir == 1) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* unit size for 4KB/64KB/1MB/16MB/256MB/4GB/64GB */
|
||||
unit_size = (uint64_t)1 << (12 + 4 * cmbsz.bits.szu);
|
||||
@ -500,8 +502,9 @@ nvme_pcie_ctrlr_alloc_cmb(struct spdk_nvme_ctrlr *ctrlr, uint64_t length, uint64
|
||||
round_offset = pctrlr->cmb_current_offset;
|
||||
round_offset = (round_offset + (aligned - 1)) & ~(aligned - 1);
|
||||
|
||||
if (round_offset + length > pctrlr->cmb_size)
|
||||
if (round_offset + length > pctrlr->cmb_size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*offset = round_offset;
|
||||
pctrlr->cmb_current_offset = round_offset + length;
|
||||
@ -1953,8 +1956,9 @@ nvme_pcie_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
|
||||
while (1) {
|
||||
cpl = &pqpair->cpl[pqpair->cq_head];
|
||||
|
||||
if (cpl->status.p != pqpair->phase)
|
||||
if (cpl->status.p != pqpair->phase) {
|
||||
break;
|
||||
}
|
||||
#ifdef __PPC64__
|
||||
/*
|
||||
* This memory barrier prevents reordering of:
|
||||
|
@ -436,8 +436,9 @@ nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *re
|
||||
TAILQ_FOREACH_SAFE(child_req, &req->children, child_tailq, tmp) {
|
||||
if (!child_req_failed) {
|
||||
rc = nvme_qpair_submit_request(qpair, child_req);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
child_req_failed = true;
|
||||
}
|
||||
} else { /* free remaining child_reqs since one child_req fails */
|
||||
nvme_request_remove_child(req, child_req);
|
||||
nvme_free_request(child_req);
|
||||
|
@ -60,8 +60,9 @@ spdk_uevent_connect(void)
|
||||
addr.nl_groups = 0xffffffff;
|
||||
|
||||
netlink_fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
|
||||
if (netlink_fd < 0)
|
||||
if (netlink_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
setsockopt(netlink_fd, SOL_SOCKET, SO_RCVBUFFORCE, &size, sizeof(size));
|
||||
|
||||
|
@ -617,8 +617,9 @@ SpdkEnv::~SpdkEnv()
|
||||
spdk_fs_iter iter;
|
||||
struct spdk_file *file;
|
||||
|
||||
if (!g_sync_args.channel)
|
||||
if (!g_sync_args.channel) {
|
||||
SpdkInitializeThread();
|
||||
}
|
||||
iter = spdk_fs_iter_first(g_fs);
|
||||
while (iter != NULL) {
|
||||
file = spdk_fs_iter_get_file(iter);
|
||||
|
@ -104,8 +104,9 @@ spdk_scsi_dev_delete_lun(struct spdk_scsi_dev *dev,
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
||||
if (dev->lun[i] == lun)
|
||||
if (dev->lun[i] == lun) {
|
||||
dev->lun[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,8 +299,9 @@ spdk_scsi_dev_print(struct spdk_scsi_dev *dev)
|
||||
|
||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
||||
lun = dev->lun[i];
|
||||
if (lun == NULL)
|
||||
if (lun == NULL) {
|
||||
continue;
|
||||
}
|
||||
printf("device %d: LUN%d %s\n", dev->id, i, lun->name);
|
||||
}
|
||||
}
|
||||
|
@ -62,11 +62,13 @@
|
||||
static int
|
||||
spdk_hex2bin(char ch)
|
||||
{
|
||||
if ((ch >= '0') && (ch <= '9'))
|
||||
if ((ch >= '0') && (ch <= '9')) {
|
||||
return ch - '0';
|
||||
}
|
||||
ch = tolower(ch);
|
||||
if ((ch >= 'a') && (ch <= 'f'))
|
||||
if ((ch >= 'a') && (ch <= 'f')) {
|
||||
return ch - 'a' + 10;
|
||||
}
|
||||
return (int)ch;
|
||||
}
|
||||
|
||||
@ -106,8 +108,9 @@ spdk_bdev_scsi_report_luns(struct spdk_scsi_lun *lun,
|
||||
int hlen, len = 0;
|
||||
int i;
|
||||
|
||||
if (alloc_len < 8)
|
||||
if (alloc_len < 8) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sel == 0x00) {
|
||||
/* logical unit with addressing method */
|
||||
@ -115,8 +118,9 @@ spdk_bdev_scsi_report_luns(struct spdk_scsi_lun *lun,
|
||||
/* well known logical unit */
|
||||
} else if (sel == 0x02) {
|
||||
/* logical unit */
|
||||
} else
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* LUN LIST LENGTH */
|
||||
memset(data, 0, 4);
|
||||
@ -128,11 +132,13 @@ spdk_bdev_scsi_report_luns(struct spdk_scsi_lun *lun,
|
||||
dev = lun->dev;
|
||||
|
||||
for (i = 0; i < SPDK_SCSI_DEV_MAX_LUN; i++) {
|
||||
if (dev->lun[i] == NULL)
|
||||
if (dev->lun[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (alloc_len - (hlen + len) < 8)
|
||||
if (alloc_len - (hlen + len) < 8) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
lun_id = (uint64_t)i;
|
||||
|
||||
@ -179,8 +185,9 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
|
||||
struct spdk_scsi_cdb_inquiry *inq = (struct spdk_scsi_cdb_inquiry *)cdb;
|
||||
|
||||
/* standard inquiry command at lease with 36 Bytes */
|
||||
if (alloc_len < 0x24)
|
||||
if (alloc_len < 0x24) {
|
||||
goto inq_error;
|
||||
}
|
||||
|
||||
lun = task->lun;
|
||||
dev = lun->dev;
|
||||
@ -530,8 +537,9 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
|
||||
/* MAXIMUM COMPARE AND WRITE LENGTH */
|
||||
blocks = SPDK_WORK_ATS_BLOCK_SIZE / block_size;
|
||||
|
||||
if (blocks > 0xff)
|
||||
if (blocks > 0xff) {
|
||||
blocks = 0xff;
|
||||
}
|
||||
|
||||
data[5] = (uint8_t)blocks;
|
||||
|
||||
@ -783,8 +791,9 @@ inq_error:
|
||||
static void
|
||||
mode_sense_page_init(uint8_t *buf, int len, int page, int subpage)
|
||||
{
|
||||
if (!buf)
|
||||
if (!buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(buf, 0, len);
|
||||
if (subpage != 0) {
|
||||
@ -832,8 +841,9 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
/* Read-Write Error Recovery */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI,
|
||||
"MODE_SENSE Read-Write Error Recovery\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
plen = 0x0a + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
len += plen;
|
||||
@ -842,8 +852,9 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
/* Disconnect-Reconnect */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI,
|
||||
"MODE_SENSE Disconnect-Reconnect\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
plen = 0x0e + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
len += plen;
|
||||
@ -865,8 +876,9 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI,
|
||||
"MODE_SENSE Verify Error Recovery\n");
|
||||
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
|
||||
plen = 0x0a + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
@ -875,18 +887,21 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
case 0x08: {
|
||||
/* Caching */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "MODE_SENSE Caching\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
|
||||
plen = 0x12 + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
|
||||
if (cp && spdk_bdev_has_write_cache(bdev) && pc != 0x01)
|
||||
cp[2] |= 0x4; /* WCE */
|
||||
if (cp && spdk_bdev_has_write_cache(bdev) && pc != 0x01) {
|
||||
cp[2] |= 0x4; /* WCE */
|
||||
}
|
||||
|
||||
/* Read Cache Disable (RCD) = 1 */
|
||||
if (cp && pc != 0x01)
|
||||
if (cp && pc != 0x01) {
|
||||
cp[2] |= 0x1;
|
||||
}
|
||||
|
||||
len += plen;
|
||||
break;
|
||||
@ -944,8 +959,9 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
case 0x10:
|
||||
/* XOR Control */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "MODE_SENSE XOR Control\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
plen = 0x16 + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
len += plen;
|
||||
@ -973,8 +989,9 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
/* Power Condition */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI,
|
||||
"MODE_SENSE Power Condition\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
plen = 0x0a + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
len += plen;
|
||||
@ -986,8 +1003,9 @@ spdk_bdev_scsi_mode_sense_page(struct spdk_bdev *bdev,
|
||||
/* Informational Exceptions Control */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI,
|
||||
"MODE_SENSE Informational Exceptions Control\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
|
||||
plen = 0x0a + 2;
|
||||
mode_sense_page_init(cp, plen, page, subpage);
|
||||
@ -1098,8 +1116,9 @@ spdk_bdev_scsi_mode_sense(struct spdk_bdev *bdev, int md,
|
||||
}
|
||||
|
||||
total = hlen + blen + plen;
|
||||
if (data == NULL)
|
||||
if (data == NULL) {
|
||||
return total;
|
||||
}
|
||||
|
||||
hdr = &data[0];
|
||||
if (hlen == 4) {
|
||||
@ -1126,10 +1145,11 @@ spdk_bdev_scsi_mode_sense(struct spdk_bdev *bdev, int md,
|
||||
to_be32(&bdesc[12], block_size);
|
||||
} else if (blen == 8) {
|
||||
/* Number of Blocks */
|
||||
if (num_blocks > 0xffffffffULL)
|
||||
if (num_blocks > 0xffffffffULL) {
|
||||
memset(&bdesc[0], 0xff, 4);
|
||||
else
|
||||
} else {
|
||||
to_be32(&bdesc[0], num_blocks);
|
||||
}
|
||||
|
||||
/* Block Length */
|
||||
to_be32(&bdesc[4], block_size);
|
||||
@ -1161,16 +1181,18 @@ spdk_bdev_scsi_mode_select_page(struct spdk_bdev *bdev,
|
||||
if (spf) {
|
||||
/* Sub_page mode page format */
|
||||
hlen = 4;
|
||||
if (len < hlen)
|
||||
if (len < hlen) {
|
||||
return 0;
|
||||
}
|
||||
subpage = data[1];
|
||||
|
||||
plen = from_be16(&data[2]);
|
||||
} else {
|
||||
/* Page_0 mode page format */
|
||||
hlen = 2;
|
||||
if (len < hlen)
|
||||
if (len < hlen) {
|
||||
return 0;
|
||||
}
|
||||
subpage = 0;
|
||||
plen = data[1];
|
||||
}
|
||||
@ -1185,8 +1207,9 @@ spdk_bdev_scsi_mode_select_page(struct spdk_bdev *bdev,
|
||||
//int wce;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "MODE_SELECT Caching\n");
|
||||
if (subpage != 0x00)
|
||||
if (subpage != 0x00) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (plen != 0x12 + hlen) {
|
||||
/* unknown format */
|
||||
@ -1687,8 +1710,9 @@ spdk_bdev_scsi_process_block(struct spdk_bdev *bdev,
|
||||
to_be32(&buffer[4], spdk_bdev_get_block_size(bdev));
|
||||
|
||||
len = spdk_min(task->length, sizeof(buffer));
|
||||
if (spdk_scsi_task_scatter_data(task, buffer, len) < 0)
|
||||
if (spdk_scsi_task_scatter_data(task, buffer, len) < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
task->data_transferred = len;
|
||||
task->status = SPDK_SCSI_STATUS_GOOD;
|
||||
@ -1712,8 +1736,9 @@ spdk_bdev_scsi_process_block(struct spdk_bdev *bdev,
|
||||
}
|
||||
|
||||
len = spdk_min(from_be32(&cdb[10]), sizeof(buffer));
|
||||
if (spdk_scsi_task_scatter_data(task, buffer, len) < 0)
|
||||
if (spdk_scsi_task_scatter_data(task, buffer, len) < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
task->data_transferred = len;
|
||||
task->status = SPDK_SCSI_STATUS_GOOD;
|
||||
@ -1755,8 +1780,9 @@ spdk_bdev_scsi_process_block(struct spdk_bdev *bdev,
|
||||
static int
|
||||
spdk_bdev_scsi_check_len(struct spdk_scsi_task *task, int len, int min_len)
|
||||
{
|
||||
if (len >= min_len)
|
||||
if (len >= min_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* INVALID FIELD IN CDB */
|
||||
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
|
||||
@ -2010,8 +2036,9 @@ spdk_bdev_scsi_process_primary(struct spdk_bdev *bdev,
|
||||
task->status = SPDK_SCSI_STATUS_GOOD;
|
||||
}
|
||||
|
||||
if (data)
|
||||
if (data) {
|
||||
spdk_dma_free(data);
|
||||
}
|
||||
|
||||
return SPDK_SCSI_TASK_COMPLETE;
|
||||
}
|
||||
|
@ -131,8 +131,9 @@ spdk_scsi_task_scatter_data(struct spdk_scsi_task *task, const void *src, size_t
|
||||
struct iovec *iovs = task->iovs;
|
||||
const uint8_t *pos;
|
||||
|
||||
if (buf_len == 0)
|
||||
if (buf_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (task->iovcnt == 1 && iovs[0].iov_base == NULL) {
|
||||
spdk_scsi_task_alloc_data(task, buf_len);
|
||||
|
@ -82,8 +82,9 @@ spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
|
||||
next_entry->arg1 = arg1;
|
||||
|
||||
lcore_history->next_entry++;
|
||||
if (lcore_history->next_entry == SPDK_TRACE_SIZE)
|
||||
if (lcore_history->next_entry == SPDK_TRACE_SIZE) {
|
||||
lcore_history->next_entry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -278,8 +278,9 @@ spdk_vhost_scsi_task_init_target(struct spdk_vhost_scsi_task *task, const __u8 *
|
||||
SPDK_TRACEDUMP(SPDK_LOG_VHOST_SCSI_QUEUE, "LUN", lun, 8);
|
||||
|
||||
/* First byte must be 1 and second is target */
|
||||
if (lun[0] != 1 || lun[1] >= SPDK_VHOST_SCSI_CTRLR_MAX_DEVS)
|
||||
if (lun[0] != 1 || lun[1] >= SPDK_VHOST_SCSI_CTRLR_MAX_DEVS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev = task->svdev->scsi_dev[lun[1]];
|
||||
task->scsi_dev = dev;
|
||||
|
@ -230,12 +230,14 @@ sgl_chop_buffer(struct bdevio_request *req, int iov_len)
|
||||
char *buf = req->buf;
|
||||
|
||||
req->iovcnt = 0;
|
||||
if (!iov_len)
|
||||
if (!iov_len) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (; data_len > 0 && req->iovcnt < BUFFER_IOVS; req->iovcnt++) {
|
||||
if (data_len < iov_len)
|
||||
if (data_len < iov_len) {
|
||||
iov_len = data_len;
|
||||
}
|
||||
|
||||
req->iov[req->iovcnt].iov_base = buf;
|
||||
req->iov[req->iovcnt].iov_len = iov_len;
|
||||
|
22
test/lib/env/vtophys/vtophys.c
vendored
22
test/lib/env/vtophys/vtophys.c
vendored
@ -45,8 +45,9 @@ vtophys_negative_test(void)
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
p = malloc(size);
|
||||
if (p == NULL)
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (spdk_vtophys(p) != SPDK_VTOPHYS_ERROR) {
|
||||
rc = -1;
|
||||
@ -66,10 +67,11 @@ vtophys_negative_test(void)
|
||||
printf("Err: kernel-mode address incorrectly allowed\n");
|
||||
}
|
||||
|
||||
if (!rc)
|
||||
if (!rc) {
|
||||
printf("vtophys_negative_test passed\n");
|
||||
else
|
||||
} else {
|
||||
printf("vtophys_negative_test failed\n");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -84,8 +86,9 @@ vtophys_positive_test(void)
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
p = spdk_dma_zmalloc(size, 512, NULL);
|
||||
if (p == NULL)
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (spdk_vtophys(p) == SPDK_VTOPHYS_ERROR) {
|
||||
rc = -1;
|
||||
@ -98,10 +101,11 @@ vtophys_positive_test(void)
|
||||
size = size << 1;
|
||||
}
|
||||
|
||||
if (!rc)
|
||||
if (!rc) {
|
||||
printf("vtophys_positive_test passed\n");
|
||||
else
|
||||
} else {
|
||||
printf("vtophys_positive_test failed\n");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -154,12 +158,14 @@ main(int argc, char **argv)
|
||||
spdk_env_init(&opts);
|
||||
|
||||
rc = vtophys_negative_test();
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = vtophys_positive_test();
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = mem_map_test();
|
||||
return rc;
|
||||
|
@ -111,10 +111,11 @@ struct io_request {
|
||||
static void
|
||||
io_complete(void *ctx, const struct spdk_nvme_cpl *cpl)
|
||||
{
|
||||
if (spdk_nvme_cpl_is_error(cpl))
|
||||
if (spdk_nvme_cpl_is_error(cpl)) {
|
||||
io_complete_flag = 2;
|
||||
else
|
||||
} else {
|
||||
io_complete_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -128,10 +129,11 @@ ns_data_buffer_reset(struct spdk_nvme_ns *ns, struct io_request *req, uint8_t da
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
|
||||
for (i = 0; i < req->lba_count; i++) {
|
||||
if (req->use_extended_lba)
|
||||
if (req->use_extended_lba) {
|
||||
offset = (sector_size + md_size) * i;
|
||||
else
|
||||
} else {
|
||||
offset = sector_size * i;
|
||||
}
|
||||
|
||||
buf = (uint8_t *)req->contig + offset;
|
||||
memset(buf, data_pattern, sector_size);
|
||||
@ -169,14 +171,16 @@ static uint32_t dp_guard_check_extended_lba_test(struct spdk_nvme_ns *ns, struct
|
||||
req->lba_count = 2;
|
||||
|
||||
/* extended LBA only for the test case */
|
||||
if (!(spdk_nvme_ns_supports_extended_lba(ns)))
|
||||
if (!(spdk_nvme_ns_supports_extended_lba(ns))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_dma_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->lba = 0x200000;
|
||||
req->use_extended_lba = true;
|
||||
@ -211,8 +215,9 @@ static uint32_t dp_with_pract_test(struct spdk_nvme_ns *ns, struct io_request *r
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
/* No additional metadata buffer provided */
|
||||
req->contig = spdk_dma_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (spdk_nvme_ns_get_pi_type(ns)) {
|
||||
case SPDK_NVME_FMT_NVM_PROTECTION_TYPE3:
|
||||
@ -252,14 +257,16 @@ static uint32_t dp_without_pract_extended_lba_test(struct spdk_nvme_ns *ns, stru
|
||||
}
|
||||
|
||||
/* extended LBA only for the test case */
|
||||
if (!(spdk_nvme_ns_supports_extended_lba(ns)))
|
||||
if (!(spdk_nvme_ns_supports_extended_lba(ns))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_dma_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->lba = 0x200000;
|
||||
req->use_extended_lba = true;
|
||||
@ -286,14 +293,16 @@ static uint32_t dp_without_flags_extended_lba_test(struct spdk_nvme_ns *ns, stru
|
||||
req->lba_count = 16;
|
||||
|
||||
/* extended LBA only for the test case */
|
||||
if (!(spdk_nvme_ns_supports_extended_lba(ns)))
|
||||
if (!(spdk_nvme_ns_supports_extended_lba(ns))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_dma_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->lba = 0x400000;
|
||||
req->use_extended_lba = true;
|
||||
@ -320,14 +329,16 @@ static uint32_t dp_without_pract_separate_meta_test(struct spdk_nvme_ns *ns, str
|
||||
}
|
||||
|
||||
/* separate metadata payload for the test case */
|
||||
if (spdk_nvme_ns_supports_extended_lba(ns))
|
||||
if (spdk_nvme_ns_supports_extended_lba(ns)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_dma_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->metadata = spdk_dma_zmalloc(md_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->metadata) {
|
||||
@ -363,14 +374,16 @@ static uint32_t dp_without_pract_separate_meta_apptag_test(struct spdk_nvme_ns *
|
||||
req->lba_count = 1;
|
||||
|
||||
/* separate metadata payload for the test case */
|
||||
if (spdk_nvme_ns_supports_extended_lba(ns))
|
||||
if (spdk_nvme_ns_supports_extended_lba(ns)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_dma_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->metadata = spdk_dma_zmalloc(md_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->metadata) {
|
||||
@ -404,14 +417,16 @@ static uint32_t dp_without_flags_separate_meta_test(struct spdk_nvme_ns *ns, str
|
||||
req->lba_count = 16;
|
||||
|
||||
/* separate metadata payload for the test case */
|
||||
if (spdk_nvme_ns_supports_extended_lba(ns))
|
||||
if (spdk_nvme_ns_supports_extended_lba(ns)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sector_size = spdk_nvme_ns_get_sector_size(ns);
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
req->contig = spdk_dma_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->contig)
|
||||
if (!req->contig) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
req->metadata = spdk_dma_zmalloc(md_size * req->lba_count, 0x1000, NULL);
|
||||
if (!req->metadata) {
|
||||
@ -436,11 +451,13 @@ free_req(struct io_request *req)
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->contig)
|
||||
if (req->contig) {
|
||||
spdk_dma_free(req->contig);
|
||||
}
|
||||
|
||||
if (req->metadata)
|
||||
if (req->metadata) {
|
||||
spdk_dma_free(req->metadata);
|
||||
}
|
||||
|
||||
spdk_dma_free(req);
|
||||
}
|
||||
@ -456,10 +473,11 @@ ns_data_buffer_compare(struct spdk_nvme_ns *ns, struct io_request *req, uint8_t
|
||||
md_size = spdk_nvme_ns_get_md_size(ns);
|
||||
|
||||
for (i = 0; i < req->lba_count; i++) {
|
||||
if (req->use_extended_lba)
|
||||
if (req->use_extended_lba) {
|
||||
offset = (sector_size + md_size) * i;
|
||||
else
|
||||
} else {
|
||||
offset = sector_size * i;
|
||||
}
|
||||
|
||||
buf = (uint8_t *)req->contig + offset;
|
||||
for (j = 0; j < sector_size; j++) {
|
||||
@ -490,8 +508,9 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(spdk_nvme_ns_get_flags(ns) & SPDK_NVME_NS_DPS_PI_SUPPORTED))
|
||||
if (!(spdk_nvme_ns_get_flags(ns) & SPDK_NVME_NS_DPS_PI_SUPPORTED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsdata = spdk_nvme_ns_get_data(ns);
|
||||
if (!nsdata || !spdk_nvme_ns_get_sector_size(ns)) {
|
||||
@ -541,8 +560,9 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
|
||||
|
||||
io_complete_flag = 0;
|
||||
|
||||
while (!io_complete_flag)
|
||||
while (!io_complete_flag) {
|
||||
spdk_nvme_qpair_process_completions(qpair, 1);
|
||||
}
|
||||
|
||||
if (io_complete_flag != 1) {
|
||||
fprintf(stderr, "%s: %s write exec failed\n", dev->name, test_name);
|
||||
@ -574,8 +594,9 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (!io_complete_flag)
|
||||
while (!io_complete_flag) {
|
||||
spdk_nvme_qpair_process_completions(qpair, 1);
|
||||
}
|
||||
|
||||
if (io_complete_flag != 1) {
|
||||
fprintf(stderr, "%s: %s read failed\n", dev->name, test_name);
|
||||
|
@ -82,8 +82,9 @@ static void nvme_request_reset_sgl(void *cb_arg, uint32_t sgl_offset)
|
||||
for (i = 0; i < req->nseg; i++) {
|
||||
iov = &req->iovs[i];
|
||||
offset += iov->len;
|
||||
if (offset > sgl_offset)
|
||||
if (offset > sgl_offset) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
req->current_iov_index = i;
|
||||
req->current_iov_bytes_left = offset - sgl_offset;
|
||||
@ -120,10 +121,11 @@ static int nvme_request_next_sge(void *cb_arg, void **address, uint32_t *length)
|
||||
static void
|
||||
io_complete(void *ctx, const struct spdk_nvme_cpl *cpl)
|
||||
{
|
||||
if (spdk_nvme_cpl_is_error(cpl))
|
||||
if (spdk_nvme_cpl_is_error(cpl)) {
|
||||
io_complete_flag = 2;
|
||||
else
|
||||
} else {
|
||||
io_complete_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void build_io_request_0(struct io_request *req)
|
||||
@ -400,8 +402,9 @@ writev_readv_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, const ch
|
||||
|
||||
io_complete_flag = 0;
|
||||
|
||||
while (!io_complete_flag)
|
||||
while (!io_complete_flag) {
|
||||
spdk_nvme_qpair_process_completions(qpair, 1);
|
||||
}
|
||||
|
||||
if (io_complete_flag != 1) {
|
||||
fprintf(stderr, "%s: %s writev failed\n", dev->name, test_name);
|
||||
@ -429,8 +432,9 @@ writev_readv_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, const ch
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (!io_complete_flag)
|
||||
while (!io_complete_flag) {
|
||||
spdk_nvme_qpair_process_completions(qpair, 1);
|
||||
}
|
||||
|
||||
if (io_complete_flag != 1) {
|
||||
fprintf(stderr, "%s: %s readv failed\n", dev->name, test_name);
|
||||
|
@ -100,8 +100,9 @@ spdk_lvs_load(struct spdk_bs_dev *dev,
|
||||
int
|
||||
spdk_bs_bdev_claim(struct spdk_bs_dev *bs_dev, struct spdk_bdev_module_if *module)
|
||||
{
|
||||
if (lvol_already_opened == true)
|
||||
if (lvol_already_opened == true) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
lvol_already_opened = true;
|
||||
|
||||
@ -143,8 +144,9 @@ spdk_bdev_create_bs_dev(struct spdk_bdev *bdev, spdk_bdev_remove_cb_t remove_cb,
|
||||
{
|
||||
struct spdk_bs_dev *bs_dev;
|
||||
|
||||
if (lvol_already_opened == true || bdev == NULL)
|
||||
if (lvol_already_opened == true || bdev == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bs_dev = calloc(1, sizeof(*bs_dev));
|
||||
SPDK_CU_ASSERT_FATAL(bs_dev != NULL);
|
||||
@ -167,8 +169,9 @@ spdk_lvs_init(struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o,
|
||||
struct spdk_lvol_store *lvs;
|
||||
int error = 0;
|
||||
|
||||
if (lvol_store_initialize_fail)
|
||||
if (lvol_store_initialize_fail) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lvol_store_initialize_cb_fail) {
|
||||
bs_dev->destroy(bs_dev);
|
||||
@ -201,8 +204,9 @@ spdk_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *c
|
||||
|
||||
g_bs_dev->destroy(g_bs_dev);
|
||||
|
||||
if (cb_fn != NULL)
|
||||
if (cb_fn != NULL) {
|
||||
cb_fn(cb_arg, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -223,8 +227,9 @@ spdk_lvs_destroy(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn,
|
||||
|
||||
g_bs_dev->destroy(g_bs_dev);
|
||||
|
||||
if (cb_fn != NULL)
|
||||
if (cb_fn != NULL) {
|
||||
cb_fn(cb_arg, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,8 +32,9 @@ spdk_scsi_task_put(struct spdk_scsi_task *task)
|
||||
void
|
||||
spdk_put_pdu(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
if (!pdu)
|
||||
if (!pdu) {
|
||||
return;
|
||||
}
|
||||
|
||||
pdu->ref--;
|
||||
if (pdu->ref < 0) {
|
||||
|
@ -122,8 +122,9 @@ void *
|
||||
spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
void *buf = malloc(size);
|
||||
if (phys_addr)
|
||||
if (phys_addr) {
|
||||
*phys_addr = (uint64_t)buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -131,8 +132,9 @@ void *
|
||||
spdk_dma_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
void *buf = calloc(size, 1);
|
||||
if (phys_addr)
|
||||
if (phys_addr) {
|
||||
*phys_addr = (uint64_t)buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -188,17 +190,18 @@ spdk_bdev_scsi_reset(struct spdk_bdev *bdev, struct spdk_scsi_task *task)
|
||||
int
|
||||
spdk_bdev_scsi_execute(struct spdk_bdev *bdev, struct spdk_scsi_task *task)
|
||||
{
|
||||
if (g_lun_execute_fail)
|
||||
if (g_lun_execute_fail) {
|
||||
return -EINVAL;
|
||||
else {
|
||||
} else {
|
||||
task->status = SPDK_SCSI_STATUS_GOOD;
|
||||
|
||||
if (g_lun_execute_status == SPDK_SCSI_TASK_PENDING)
|
||||
if (g_lun_execute_status == SPDK_SCSI_TASK_PENDING) {
|
||||
return g_lun_execute_status;
|
||||
else if (g_lun_execute_status == SPDK_SCSI_TASK_COMPLETE)
|
||||
} else if (g_lun_execute_status == SPDK_SCSI_TASK_COMPLETE) {
|
||||
return g_lun_execute_status;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,9 @@ void *
|
||||
spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
void *buf = malloc(size);
|
||||
if (phys_addr)
|
||||
if (phys_addr) {
|
||||
*phys_addr = (uint64_t)buf;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
@ -58,8 +59,9 @@ void *
|
||||
spdk_dma_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
void *buf = calloc(size, 1);
|
||||
if (phys_addr)
|
||||
if (phys_addr) {
|
||||
*phys_addr = (uint64_t)buf;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
@ -127,8 +129,9 @@ spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_tas
|
||||
static void
|
||||
spdk_put_task(struct spdk_scsi_task *task)
|
||||
{
|
||||
if (task->alloc_len)
|
||||
if (task->alloc_len) {
|
||||
free(task->iov.iov_base);
|
||||
}
|
||||
|
||||
task->iov.iov_base = NULL;
|
||||
task->iov.iov_len = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user