bdev: start lock process on original channel
If a locking operation has to wait because of an existing lock, we queue the lock context. When the existing lock finishes unlocking, we restart the queued lock context. But we have to make sure we restart the lock context on the same thread it was originally submitted, since it has a channel associated with it. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I555515f3adfc3c13a86584c601ed541d605980b7 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482463 Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Maciej Szwed <maciej.szwed@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
327668c8c9
commit
da11a46466
@ -6147,6 +6147,8 @@ bdev_lock_lba_range_get_channel(struct spdk_io_channel_iter *i)
|
||||
static void
|
||||
bdev_lock_lba_range_ctx(struct spdk_bdev *bdev, struct locked_lba_range_ctx *ctx)
|
||||
{
|
||||
assert(spdk_get_thread() == ctx->range.owner_ch->channel->thread);
|
||||
|
||||
/* We will add a copy of this range to each channel now. */
|
||||
spdk_for_each_channel(__bdev_to_io_dev(bdev), bdev_lock_lba_range_get_channel, ctx,
|
||||
bdev_lock_lba_range_cb);
|
||||
@ -6207,6 +6209,14 @@ bdev_lock_lba_range(struct spdk_bdev_desc *desc, struct spdk_io_channel *_ch,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_lock_lba_range_ctx_msg(void *_ctx)
|
||||
{
|
||||
struct locked_lba_range_ctx *ctx = _ctx;
|
||||
|
||||
bdev_lock_lba_range_ctx(ctx->bdev, ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_unlock_lba_range_cb(struct spdk_io_channel_iter *i, int status)
|
||||
{
|
||||
@ -6228,7 +6238,8 @@ bdev_unlock_lba_range_cb(struct spdk_io_channel_iter *i, int status)
|
||||
TAILQ_REMOVE(&bdev->internal.pending_locked_ranges, range, tailq);
|
||||
pending_ctx = SPDK_CONTAINEROF(range, struct locked_lba_range_ctx, range);
|
||||
TAILQ_INSERT_TAIL(&bdev->internal.locked_ranges, range, tailq);
|
||||
bdev_lock_lba_range_ctx(bdev, pending_ctx);
|
||||
spdk_thread_send_msg(pending_ctx->range.owner_ch->channel->thread,
|
||||
bdev_lock_lba_range_ctx_msg, pending_ctx);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&bdev->internal.mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user