diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-02-22 21:08:24 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-06-02 15:42:01 -0400 |
commit | b1935f687bb93b207ef690f7debc0e9921fc484f (patch) | |
tree | 411904ec301b4f92cb3d279b1d311ff89500b1cb | |
parent | 5a01d08217e39f3d36d3ca160361c7b019ff1598 (diff) |
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: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/vhost/scsi.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index ae434db2d384..30402e618078 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c | |||
@@ -58,6 +58,7 @@ | |||
58 | #define TCM_VHOST_DEFAULT_TAGS 256 | 58 | #define TCM_VHOST_DEFAULT_TAGS 256 |
59 | #define TCM_VHOST_PREALLOC_SGLS 2048 | 59 | #define TCM_VHOST_PREALLOC_SGLS 2048 |
60 | #define TCM_VHOST_PREALLOC_UPAGES 2048 | 60 | #define TCM_VHOST_PREALLOC_UPAGES 2048 |
61 | #define TCM_VHOST_PREALLOC_PROT_SGLS 512 | ||
61 | 62 | ||
62 | struct vhost_scsi_inflight { | 63 | struct vhost_scsi_inflight { |
63 | /* Wait for the flush operation to finish */ | 64 | /* Wait for the flush operation to finish */ |
@@ -83,6 +84,7 @@ struct tcm_vhost_cmd { | |||
83 | u32 tvc_lun; | 84 | u32 tvc_lun; |
84 | /* Pointer to the SGL formatted memory from virtio-scsi */ | 85 | /* Pointer to the SGL formatted memory from virtio-scsi */ |
85 | struct scatterlist *tvc_sgl; | 86 | struct scatterlist *tvc_sgl; |
87 | struct scatterlist *tvc_prot_sgl; | ||
86 | struct page **tvc_upages; | 88 | struct page **tvc_upages; |
87 | /* Pointer to response */ | 89 | /* Pointer to response */ |
88 | struct virtio_scsi_cmd_resp __user *tvc_resp; | 90 | struct virtio_scsi_cmd_resp __user *tvc_resp; |
@@ -722,7 +724,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, | |||
722 | struct tcm_vhost_cmd *cmd; | 724 | struct tcm_vhost_cmd *cmd; |
723 | struct tcm_vhost_nexus *tv_nexus; | 725 | struct tcm_vhost_nexus *tv_nexus; |
724 | struct se_session *se_sess; | 726 | struct se_session *se_sess; |
725 | struct scatterlist *sg; | 727 | struct scatterlist *sg, *prot_sg; |
726 | struct page **pages; | 728 | struct page **pages; |
727 | int tag; | 729 | int tag; |
728 | 730 | ||
@@ -741,10 +743,12 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, | |||
741 | 743 | ||
742 | cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[tag]; | 744 | cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[tag]; |
743 | sg = cmd->tvc_sgl; | 745 | sg = cmd->tvc_sgl; |
746 | prot_sg = cmd->tvc_prot_sgl; | ||
744 | pages = cmd->tvc_upages; | 747 | pages = cmd->tvc_upages; |
745 | memset(cmd, 0, sizeof(struct tcm_vhost_cmd)); | 748 | memset(cmd, 0, sizeof(struct tcm_vhost_cmd)); |
746 | 749 | ||
747 | cmd->tvc_sgl = sg; | 750 | cmd->tvc_sgl = sg; |
751 | cmd->tvc_prot_sgl = prot_sg; | ||
748 | cmd->tvc_upages = pages; | 752 | cmd->tvc_upages = pages; |
749 | cmd->tvc_se_cmd.map_tag = tag; | 753 | cmd->tvc_se_cmd.map_tag = tag; |
750 | cmd->tvc_tag = v_req->tag; | 754 | cmd->tvc_tag = v_req->tag; |
@@ -1703,6 +1707,7 @@ static void tcm_vhost_free_cmd_map_res(struct tcm_vhost_nexus *nexus, | |||
1703 | tv_cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[i]; | 1707 | tv_cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[i]; |
1704 | 1708 | ||
1705 | kfree(tv_cmd->tvc_sgl); | 1709 | kfree(tv_cmd->tvc_sgl); |
1710 | kfree(tv_cmd->tvc_prot_sgl); | ||
1706 | kfree(tv_cmd->tvc_upages); | 1711 | kfree(tv_cmd->tvc_upages); |
1707 | } | 1712 | } |
1708 | } | 1713 | } |
@@ -1762,6 +1767,14 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg, | |||
1762 | pr_err("Unable to allocate tv_cmd->tvc_upages\n"); | 1767 | pr_err("Unable to allocate tv_cmd->tvc_upages\n"); |
1763 | goto out; | 1768 | goto out; |
1764 | } | 1769 | } |
1770 | |||
1771 | tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) * | ||
1772 | TCM_VHOST_PREALLOC_PROT_SGLS, GFP_KERNEL); | ||
1773 | if (!tv_cmd->tvc_prot_sgl) { | ||
1774 | mutex_unlock(&tpg->tv_tpg_mutex); | ||
1775 | pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n"); | ||
1776 | goto out; | ||
1777 | } | ||
1765 | } | 1778 | } |
1766 | /* | 1779 | /* |
1767 | * Since we are running in 'demo mode' this call with generate a | 1780 | * Since we are running in 'demo mode' this call with generate a |