thread: return int from spdk_thread_seng_msg
This at least allows the caller to know there was a problem, and that the messages wasn't actually sent. SPDK by default creates huge rings so this problem should never occur, but out-of-tree use cases may send messages much more often and require at least a notification when it fails. While here, change the thread check to an assert. There's no need to work around someone calling this function with a null thread parameter. Fixes issue #811. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ie6d432d616be45c7a4232aff1548cef198702bc0 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472438 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
296e7fba03
commit
4036f95bf8
@ -7,6 +7,11 @@
|
||||
Updated ISA-L submodule to commit f3993f5c0b6911 which includes implementation and
|
||||
optimization for aarch64.
|
||||
|
||||
### thread
|
||||
|
||||
`spdk_thread_send_msg` now returns int indicating if the message was successfully
|
||||
sent.
|
||||
|
||||
## v19.10:
|
||||
|
||||
### rpc
|
||||
|
@ -373,8 +373,12 @@ int spdk_thread_get_stats(struct spdk_thread_stats *stats);
|
||||
* \param thread The target thread.
|
||||
* \param fn This function will be called on the given thread.
|
||||
* \param ctx This context will be passed to fn when called.
|
||||
*
|
||||
* \return 0 on success
|
||||
* \return -ENOMEM if the message could not be allocated
|
||||
* \return -EIO if the message could not be sent to the destination thread
|
||||
*/
|
||||
void spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx);
|
||||
int spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx);
|
||||
|
||||
/**
|
||||
* Send a message to each thread, serially.
|
||||
|
@ -648,17 +648,14 @@ spdk_thread_get_stats(struct spdk_thread_stats *stats)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx)
|
||||
{
|
||||
struct spdk_thread *local_thread;
|
||||
struct spdk_msg *msg;
|
||||
int rc;
|
||||
|
||||
if (!thread) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
assert(thread != NULL);
|
||||
|
||||
local_thread = _get_thread();
|
||||
|
||||
@ -675,8 +672,8 @@ spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx
|
||||
if (msg == NULL) {
|
||||
msg = spdk_mempool_get(g_spdk_msg_mempool);
|
||||
if (!msg) {
|
||||
assert(false);
|
||||
return;
|
||||
SPDK_ERRLOG("msg could not be allocated\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
@ -685,10 +682,12 @@ spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx
|
||||
|
||||
rc = spdk_ring_enqueue(thread->messages, (void **)&msg, 1, NULL);
|
||||
if (rc != 1) {
|
||||
assert(false);
|
||||
SPDK_ERRLOG("msg could not be enqueued\n");
|
||||
spdk_mempool_put(g_spdk_msg_mempool, msg);
|
||||
return;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_poller *
|
||||
@ -1200,6 +1199,7 @@ spdk_for_each_channel(void *io_device, spdk_channel_msg fn, void *ctx,
|
||||
struct spdk_thread *thread;
|
||||
struct spdk_io_channel *ch;
|
||||
struct spdk_io_channel_iter *i;
|
||||
int rc;
|
||||
|
||||
i = calloc(1, sizeof(*i));
|
||||
if (!i) {
|
||||
@ -1223,7 +1223,8 @@ spdk_for_each_channel(void *io_device, spdk_channel_msg fn, void *ctx,
|
||||
i->cur_thread = thread;
|
||||
i->ch = ch;
|
||||
pthread_mutex_unlock(&g_devlist_mutex);
|
||||
spdk_thread_send_msg(thread, _call_channel, i);
|
||||
rc = spdk_thread_send_msg(thread, _call_channel, i);
|
||||
assert(rc == 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1231,7 +1232,8 @@ spdk_for_each_channel(void *io_device, spdk_channel_msg fn, void *ctx,
|
||||
|
||||
pthread_mutex_unlock(&g_devlist_mutex);
|
||||
|
||||
spdk_thread_send_msg(i->orig_thread, _call_completion, i);
|
||||
rc = spdk_thread_send_msg(i->orig_thread, _call_completion, i);
|
||||
assert(rc == 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -145,10 +145,11 @@ spdk_bdev_close(struct spdk_bdev_desc *desc)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx)
|
||||
{
|
||||
fn(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_thread *
|
||||
|
Loading…
Reference in New Issue
Block a user