Commit b1935f68 authored by Nicholas Bellinger's avatar Nicholas Bellinger

vhost/scsi: Add preallocation of protection SGLs

This patch updates tcm_vhost_make_nexus() to pre-allocate per descriptor
tcm_vhost_cmd->tvc_prot_sgl[] used to expose protection SGLs from within
virtio-scsi guest memory to vhost-scsi.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 5a01d082
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#define TCM_VHOST_DEFAULT_TAGS 256 #define TCM_VHOST_DEFAULT_TAGS 256
#define TCM_VHOST_PREALLOC_SGLS 2048 #define TCM_VHOST_PREALLOC_SGLS 2048
#define TCM_VHOST_PREALLOC_UPAGES 2048 #define TCM_VHOST_PREALLOC_UPAGES 2048
#define TCM_VHOST_PREALLOC_PROT_SGLS 512
struct vhost_scsi_inflight { struct vhost_scsi_inflight {
/* Wait for the flush operation to finish */ /* Wait for the flush operation to finish */
...@@ -83,6 +84,7 @@ struct tcm_vhost_cmd { ...@@ -83,6 +84,7 @@ struct tcm_vhost_cmd {
u32 tvc_lun; u32 tvc_lun;
/* Pointer to the SGL formatted memory from virtio-scsi */ /* Pointer to the SGL formatted memory from virtio-scsi */
struct scatterlist *tvc_sgl; struct scatterlist *tvc_sgl;
struct scatterlist *tvc_prot_sgl;
struct page **tvc_upages; struct page **tvc_upages;
/* Pointer to response */ /* Pointer to response */
struct virtio_scsi_cmd_resp __user *tvc_resp; struct virtio_scsi_cmd_resp __user *tvc_resp;
...@@ -722,7 +724,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, ...@@ -722,7 +724,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq,
struct tcm_vhost_cmd *cmd; struct tcm_vhost_cmd *cmd;
struct tcm_vhost_nexus *tv_nexus; struct tcm_vhost_nexus *tv_nexus;
struct se_session *se_sess; struct se_session *se_sess;
struct scatterlist *sg; struct scatterlist *sg, *prot_sg;
struct page **pages; struct page **pages;
int tag; int tag;
...@@ -741,10 +743,12 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, ...@@ -741,10 +743,12 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq,
cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[tag]; cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[tag];
sg = cmd->tvc_sgl; sg = cmd->tvc_sgl;
prot_sg = cmd->tvc_prot_sgl;
pages = cmd->tvc_upages; pages = cmd->tvc_upages;
memset(cmd, 0, sizeof(struct tcm_vhost_cmd)); memset(cmd, 0, sizeof(struct tcm_vhost_cmd));
cmd->tvc_sgl = sg; cmd->tvc_sgl = sg;
cmd->tvc_prot_sgl = prot_sg;
cmd->tvc_upages = pages; cmd->tvc_upages = pages;
cmd->tvc_se_cmd.map_tag = tag; cmd->tvc_se_cmd.map_tag = tag;
cmd->tvc_tag = v_req->tag; cmd->tvc_tag = v_req->tag;
...@@ -1703,6 +1707,7 @@ static void tcm_vhost_free_cmd_map_res(struct tcm_vhost_nexus *nexus, ...@@ -1703,6 +1707,7 @@ static void tcm_vhost_free_cmd_map_res(struct tcm_vhost_nexus *nexus,
tv_cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[i]; tv_cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[i];
kfree(tv_cmd->tvc_sgl); kfree(tv_cmd->tvc_sgl);
kfree(tv_cmd->tvc_prot_sgl);
kfree(tv_cmd->tvc_upages); kfree(tv_cmd->tvc_upages);
} }
} }
...@@ -1762,6 +1767,14 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg, ...@@ -1762,6 +1767,14 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg,
pr_err("Unable to allocate tv_cmd->tvc_upages\n"); pr_err("Unable to allocate tv_cmd->tvc_upages\n");
goto out; goto out;
} }
tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) *
TCM_VHOST_PREALLOC_PROT_SGLS, GFP_KERNEL);
if (!tv_cmd->tvc_prot_sgl) {
mutex_unlock(&tpg->tv_tpg_mutex);
pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
goto out;
}
} }
/* /*
* Since we are running in 'demo mode' this call with generate a * Since we are running in 'demo mode' this call with generate a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment