ocf: Improve handling of partial IOs
Improve handling of partial IOs for case when iovcnt == 1. This case is pretty frqeuent because all data allocated by OCF have iovcnt == 1 (see ctx->data->alloc() or vbdev_ocf_ctx_data_alloc()) Change-Id: I8d38ca9e9d2bd3e6ce298bf788ce6ed782b56594 Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456202 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
2bfa860dfe
commit
7b7590f838
@ -303,27 +303,40 @@ vbdev_ocf_volume_submit_io(struct ocf_io *io)
|
||||
offset = io_ctx->offset;
|
||||
|
||||
if (len < io_ctx->data->size) {
|
||||
i = get_starting_vec(io_ctx->data->iovs, io_ctx->data->iovcnt, &offset);
|
||||
if (io_ctx->data->iovcnt == 1) {
|
||||
if (io->dir == OCF_READ) {
|
||||
status = spdk_bdev_read(base->desc, io_ctx->ch,
|
||||
io_ctx->data->iovs[0].iov_base + offset, addr, len,
|
||||
vbdev_ocf_volume_submit_io_cb, io);
|
||||
} else if (io->dir == OCF_WRITE) {
|
||||
status = spdk_bdev_write(base->desc, io_ctx->ch,
|
||||
io_ctx->data->iovs[0].iov_base + offset, addr, len,
|
||||
vbdev_ocf_volume_submit_io_cb, io);
|
||||
}
|
||||
goto end;
|
||||
} else {
|
||||
i = get_starting_vec(io_ctx->data->iovs, io_ctx->data->iovcnt, &offset);
|
||||
|
||||
if (i < 0) {
|
||||
SPDK_ERRLOG("offset bigger than data size\n");
|
||||
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||
return;
|
||||
if (i < 0) {
|
||||
SPDK_ERRLOG("offset bigger than data size\n");
|
||||
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||
return;
|
||||
}
|
||||
|
||||
iovcnt = io_ctx->data->iovcnt - i;
|
||||
|
||||
io_ctx->iovs_allocated = true;
|
||||
iovs = env_malloc(sizeof(*iovs) * iovcnt, ENV_MEM_NOIO);
|
||||
|
||||
if (!iovs) {
|
||||
SPDK_ERRLOG("allocation failed\n");
|
||||
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||
return;
|
||||
}
|
||||
|
||||
initialize_cpy_vector(iovs, io_ctx->data->iovcnt, &io_ctx->data->iovs[i],
|
||||
iovcnt, offset, len);
|
||||
}
|
||||
|
||||
iovcnt = io_ctx->data->iovcnt - i;
|
||||
|
||||
io_ctx->iovs_allocated = true;
|
||||
iovs = env_malloc(sizeof(*iovs) * iovcnt, ENV_MEM_NOIO);
|
||||
|
||||
if (!iovs) {
|
||||
SPDK_ERRLOG("allocation failed\n");
|
||||
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||
return;
|
||||
}
|
||||
|
||||
initialize_cpy_vector(iovs, io_ctx->data->iovcnt, &io_ctx->data->iovs[i],
|
||||
iovcnt, offset, len);
|
||||
} else {
|
||||
iovs = io_ctx->data->iovs;
|
||||
iovcnt = io_ctx->data->iovcnt;
|
||||
@ -337,6 +350,7 @@ vbdev_ocf_volume_submit_io(struct ocf_io *io)
|
||||
iovs, iovcnt, addr, len, vbdev_ocf_volume_submit_io_cb, io);
|
||||
}
|
||||
|
||||
end:
|
||||
if (status) {
|
||||
/* TODO [ENOMEM]: implement ENOMEM handling when submitting IO to base device */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user