Skip to content

Commit

Permalink
thread: send message for completion with no channels
Browse files Browse the repository at this point in the history
When spdk_for_each_channel() was called on an io_device with no
channels, the completion function would be called immediately in the
context of the spdk_for_each_channel() caller.  This is different than
the normal completion when channels are present, which is always called
asynchronously via spdk_thread_send_msg(), causing problems for callers
that did not expect to get the completion callback before
for_each_channel returned.

In particular, this causes problems with the set_bdev_qos_limit_iops RPC
method, which holds a mutex around the spdk_for_each_channel() call and
also attempts to lock that mutex again within the completion callback.
(This is GitHub issue spdk#344.)

To avoid this problem and make the completion call consistent between
no-channels and channels-present cases, always send the completion via
spdk_thread_send_msg().

Change-Id: I9e5ec3592462c7b2ed682e665fe62ae3a5b5cc59
Signed-off-by: Daniel Verkamp <[email protected]>
Reviewed-on: https://review.gerrithub.io/417068
Tested-by: SPDK Automated Test System <[email protected]>
Reviewed-by: Shuhei Matsumoto <[email protected]>
Reviewed-by: Ben Walker <[email protected]>
  • Loading branch information
danielverkamp committed Jun 28, 2018
1 parent a33a7b4 commit 8e5eef8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/thread/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,7 @@ spdk_for_each_channel(void *io_device, spdk_channel_msg fn, void *ctx,

pthread_mutex_unlock(&g_devlist_mutex);

cpl(i, 0);

free(i);
spdk_thread_send_msg(i->orig_thread, _call_completion, i);
}

void
Expand Down

0 comments on commit 8e5eef8

Please sign in to comment.