bdev_aio: handle unexpected res=0 correctly

If res = 0, do not pass this value directly to bdev io completion function,
otherwise it will be treated as a successful completion.
Fix issue: 2679

Signed-off-by: jun.ran <ranjunsh@163.com>
Change-Id: Ice525de1bb5b0ada9ac30d3b59e5c731419efe2f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14364
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
jun.ran 2022-09-06 00:32:31 +08:00 committed by Tomasz Zawadzki
parent c3f628f141
commit 488d6e84c4

View File

@ -307,7 +307,7 @@ bdev_user_io_getevents(io_context_t io_ctx, unsigned int max, struct io_event *u
static int
bdev_aio_io_channel_poll(struct bdev_aio_io_channel *io_ch)
{
int nr, i = 0;
int nr, i, res = 0;
struct bdev_aio_task *aio_task;
struct io_event events[SPDK_AIO_QUEUE_DEPTH];
@ -328,7 +328,12 @@ bdev_aio_io_channel_poll(struct bdev_aio_io_channel *io_ch)
* convert it to signed value for error detection.
*/
SPDK_ERRLOG("failed to complete aio: rc %"PRId64"\n", events[i].res);
spdk_bdev_io_complete_aio_status(spdk_bdev_io_from_ctx(aio_task), (int)events[i].res);
res = (int)events[i].res;
if (res < 0) {
spdk_bdev_io_complete_aio_status(spdk_bdev_io_from_ctx(aio_task), res);
} else {
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_FAILED);
}
}
}