From b1bb9917a9988e58c6bde16a281c136b7287e9a3 Mon Sep 17 00:00:00 2001 From: Maciej Szwed Date: Tue, 7 Jul 2020 09:47:21 +0200 Subject: [PATCH] bdev/delay: Return poller status based on completions number Signed-off-by: Maciej Szwed Change-Id: I54d4a41602f678aed4d2df61d7059adc1ae37f78 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3235 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- module/bdev/delay/vbdev_delay.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/module/bdev/delay/vbdev_delay.c b/module/bdev/delay/vbdev_delay.c index ecee65049..b4ea1b413 100644 --- a/module/bdev/delay/vbdev_delay.c +++ b/module/bdev/delay/vbdev_delay.c @@ -165,16 +165,18 @@ vbdev_delay_destruct(void *ctx) return 0; } -static void +static int _process_io_stailq(void *arg, uint64_t ticks) { STAILQ_HEAD(, delay_bdev_io) *head = arg; struct delay_bdev_io *io_ctx, *tmp; + int completions = 0; STAILQ_FOREACH_SAFE(io_ctx, head, link, tmp) { if (io_ctx->completion_tick <= ticks) { STAILQ_REMOVE(head, io_ctx, delay_bdev_io, link); spdk_bdev_io_complete(spdk_bdev_io_from_ctx(io_ctx), io_ctx->status); + completions++; } else { /* In the general case, I/O will become ready in an fifo order. When timeouts are dynamically * changed, this is not necessarily the case. However, the normal behavior will be restored @@ -186,6 +188,8 @@ _process_io_stailq(void *arg, uint64_t ticks) break; } } + + return completions; } static int @@ -193,13 +197,14 @@ _delay_finish_io(void *arg) { struct delay_io_channel *delay_ch = arg; uint64_t ticks = spdk_get_ticks(); + int completions = 0; - _process_io_stailq(&delay_ch->avg_read_io, ticks); - _process_io_stailq(&delay_ch->avg_write_io, ticks); - _process_io_stailq(&delay_ch->p99_read_io, ticks); - _process_io_stailq(&delay_ch->p99_write_io, ticks); + completions += _process_io_stailq(&delay_ch->avg_read_io, ticks); + completions += _process_io_stailq(&delay_ch->avg_write_io, ticks); + completions += _process_io_stailq(&delay_ch->p99_read_io, ticks); + completions += _process_io_stailq(&delay_ch->p99_write_io, ticks); - return SPDK_POLLER_BUSY; + return completions == 0 ? SPDK_POLLER_IDLE : SPDK_POLLER_BUSY; } /* Completion callback for IO that were issued from this bdev. The original bdev_io