vhost_blk: separate out generic virtio_blk request processing
This patch adds process_virtio_blk_request() that will be called by virtio_blk transports to process incoming requests. Meanwhile vhost_user_blk_request_finish() will be replaced with a callback to the virtio_blk transport to notify of the result. blk_request_finish() should only be called as direct result of process_virtio_blk_request(), usually from it. Some error paths now call vhost_user_blk_request_finish() directly, if vhost_user_process_blk_request() was not called yet. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I0cce22f15b922fe45f30fb659c384b6e836def4c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9537 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
8c609f29bc
commit
eef6af95d1
@ -110,8 +110,8 @@ static const struct spdk_json_object_decoder rpc_construct_vhost_blk[] = {
|
|||||||
static const struct spdk_vhost_dev_backend vhost_blk_device_backend;
|
static const struct spdk_vhost_dev_backend vhost_blk_device_backend;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
process_blk_request(struct spdk_vhost_dev *vdev, struct spdk_io_channel *ch,
|
virtio_blk_process_request(struct spdk_vhost_dev *vdev, struct spdk_io_channel *ch,
|
||||||
struct spdk_vhost_blk_task *task);
|
struct spdk_vhost_blk_task *task);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vhost_user_process_blk_request(struct spdk_vhost_user_blk_task *user_task)
|
vhost_user_process_blk_request(struct spdk_vhost_user_blk_task *user_task)
|
||||||
@ -119,7 +119,7 @@ vhost_user_process_blk_request(struct spdk_vhost_user_blk_task *user_task)
|
|||||||
struct spdk_vhost_blk_session *bvsession = user_task->bvsession;
|
struct spdk_vhost_blk_session *bvsession = user_task->bvsession;
|
||||||
struct spdk_vhost_dev *vdev = &bvsession->bvdev->vdev;
|
struct spdk_vhost_dev *vdev = &bvsession->bvdev->vdev;
|
||||||
|
|
||||||
return process_blk_request(vdev, bvsession->io_channel, &user_task->blk_task);
|
return virtio_blk_process_request(vdev, bvsession->io_channel, &user_task->blk_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct spdk_vhost_blk_dev *
|
static struct spdk_vhost_blk_dev *
|
||||||
@ -179,14 +179,10 @@ blk_task_enqueue(struct spdk_vhost_user_blk_task *task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
blk_request_finish(uint8_t status, struct spdk_vhost_blk_task *task)
|
vhost_user_blk_request_finish(uint8_t status, struct spdk_vhost_blk_task *task)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_user_blk_task *user_task;
|
struct spdk_vhost_user_blk_task *user_task;
|
||||||
|
|
||||||
if (task->status) {
|
|
||||||
*task->status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
user_task = SPDK_CONTAINEROF(task, struct spdk_vhost_user_blk_task, blk_task);
|
user_task = SPDK_CONTAINEROF(task, struct spdk_vhost_user_blk_task, blk_task);
|
||||||
|
|
||||||
blk_task_enqueue(user_task);
|
blk_task_enqueue(user_task);
|
||||||
@ -196,6 +192,17 @@ blk_request_finish(uint8_t status, struct spdk_vhost_blk_task *task)
|
|||||||
blk_task_finish(user_task);
|
blk_task_finish(user_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
blk_request_finish(uint8_t status, struct spdk_vhost_blk_task *task)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (task->status) {
|
||||||
|
*task->status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
vhost_user_blk_request_finish(status, task);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process task's descriptor chain and setup data related fields.
|
* Process task's descriptor chain and setup data related fields.
|
||||||
* Return
|
* Return
|
||||||
@ -440,7 +447,7 @@ blk_request_resubmit(void *arg)
|
|||||||
struct spdk_vhost_blk_task *task = arg;
|
struct spdk_vhost_blk_task *task = arg;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
rc = process_blk_request(task->bdev_io_wait_vdev, task->bdev_io_wait_ch, task);
|
rc = virtio_blk_process_request(task->bdev_io_wait_vdev, task->bdev_io_wait_ch, task);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
SPDK_DEBUGLOG(vhost_blk, "====== Task %p resubmitted ======\n", task);
|
SPDK_DEBUGLOG(vhost_blk, "====== Task %p resubmitted ======\n", task);
|
||||||
} else {
|
} else {
|
||||||
@ -468,8 +475,8 @@ blk_request_queue_io(struct spdk_vhost_dev *vdev, struct spdk_io_channel *ch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
process_blk_request(struct spdk_vhost_dev *vdev, struct spdk_io_channel *ch,
|
virtio_blk_process_request(struct spdk_vhost_dev *vdev, struct spdk_io_channel *ch,
|
||||||
struct spdk_vhost_blk_task *task)
|
struct spdk_vhost_blk_task *task)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev);
|
struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev);
|
||||||
struct virtio_blk_outhdr req;
|
struct virtio_blk_outhdr req;
|
||||||
@ -676,7 +683,7 @@ process_blk_task(struct spdk_vhost_virtqueue *vq, uint16_t req_idx)
|
|||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_DEBUGLOG(vhost_blk, "Invalid request (req_idx = %"PRIu16").\n", task->req_idx);
|
SPDK_DEBUGLOG(vhost_blk, "Invalid request (req_idx = %"PRIu16").\n", task->req_idx);
|
||||||
/* Only READ and WRITE are supported for now. */
|
/* Only READ and WRITE are supported for now. */
|
||||||
blk_request_finish(VIRTIO_BLK_S_UNSUPP, blk_task);
|
vhost_user_blk_request_finish(VIRTIO_BLK_S_UNSUPP, blk_task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,7 +748,7 @@ process_packed_blk_task(struct spdk_vhost_virtqueue *vq, uint16_t req_idx)
|
|||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_DEBUGLOG(vhost_blk, "Invalid request (req_idx = %"PRIu16").\n", task->req_idx);
|
SPDK_DEBUGLOG(vhost_blk, "Invalid request (req_idx = %"PRIu16").\n", task->req_idx);
|
||||||
/* Only READ and WRITE are supported for now. */
|
/* Only READ and WRITE are supported for now. */
|
||||||
blk_request_finish(VIRTIO_BLK_S_UNSUPP, blk_task);
|
vhost_user_blk_request_finish(VIRTIO_BLK_S_UNSUPP, blk_task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,7 +809,7 @@ process_packed_inflight_blk_task(struct spdk_vhost_virtqueue *vq,
|
|||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_DEBUGLOG(vhost_blk, "Invalid request (req_idx = %"PRIu16").\n", task->req_idx);
|
SPDK_DEBUGLOG(vhost_blk, "Invalid request (req_idx = %"PRIu16").\n", task->req_idx);
|
||||||
/* Only READ and WRITE are supported for now. */
|
/* Only READ and WRITE are supported for now. */
|
||||||
blk_request_finish(VIRTIO_BLK_S_UNSUPP, blk_task);
|
vhost_user_blk_request_finish(VIRTIO_BLK_S_UNSUPP, blk_task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user