Re: [PATCH-v3 7/9] vhost/scsi: Drop legacy pre virtio v1.0 !ANY_LAYOUT logic

2015-02-04 Thread Nicholas A. Bellinger
On Tue, 2015-02-03 at 11:37 +0200, Michael S. Tsirkin wrote:
 On Tue, Feb 03, 2015 at 06:30:01AM +, Nicholas A. Bellinger wrote:
  From: Nicholas Bellinger n...@linux-iscsi.org
  
  With the new ANY_LAYOUT logic in place for vhost_scsi_handle_vqal(),
  there is no longer a reason to keep around the legacy code with
  !ANY_LAYOUT assumptions.
  
  Go ahead and drop the pre virtio 1.0 logic in vhost_scsi_handle_vq()
  and associated helpers.
 
 Will probably be easier to review if you smash this with patch 5,
 this way we see both old and new code side by side.
 

So was thinking it might be useful to leave this as a separate patch,
just in case !ANY_LAYOUT needs to be resurrected for some reason, so
both modes can function.

But at this point I really don't see a case why that would be
necessary..

 Also, let's rename _vqal to _vq in this patch?

Merging this patch into 7, changing name to _vq.

--nab

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v3 7/9] vhost/scsi: Drop legacy pre virtio v1.0 !ANY_LAYOUT logic

2015-02-03 Thread Michael S. Tsirkin
On Tue, Feb 03, 2015 at 06:30:01AM +, Nicholas A. Bellinger wrote:
 From: Nicholas Bellinger n...@linux-iscsi.org
 
 With the new ANY_LAYOUT logic in place for vhost_scsi_handle_vqal(),
 there is no longer a reason to keep around the legacy code with
 !ANY_LAYOUT assumptions.
 
 Go ahead and drop the pre virtio 1.0 logic in vhost_scsi_handle_vq()
 and associated helpers.

Will probably be easier to review if you smash this with patch 5,
this way we see both old and new code side by side.

Also, let's rename _vqal to _vq in this patch?

 Cc: Michael S. Tsirkin m...@redhat.com
 Cc: Paolo Bonzini pbonz...@redhat.com
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---
  drivers/vhost/scsi.c | 340 
 +--
  1 file changed, 1 insertion(+), 339 deletions(-)
 
 diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
 index c25fdd7..9af93d0 100644
 --- a/drivers/vhost/scsi.c
 +++ b/drivers/vhost/scsi.c
 @@ -830,93 +830,6 @@ out:
  }
  
  static int
 -vhost_scsi_map_iov_to_sgl(struct tcm_vhost_cmd *cmd,
 -   struct iovec *iov,
 -   int niov,
 -   bool write)
 -{
 - struct scatterlist *sg = cmd-tvc_sgl;
 - unsigned int sgl_count = 0;
 - int ret, i;
 -
 - for (i = 0; i  niov; i++)
 - sgl_count += iov_num_pages(iov[i].iov_base, iov[i].iov_len);
 -
 - if (sgl_count  TCM_VHOST_PREALLOC_SGLS) {
 - pr_err(vhost_scsi_map_iov_to_sgl() sgl_count: %u greater than
 -  preallocated TCM_VHOST_PREALLOC_SGLS: %u\n,
 - sgl_count, TCM_VHOST_PREALLOC_SGLS);
 - return -ENOBUFS;
 - }
 -
 - pr_debug(%s sg %p sgl_count %u\n, __func__, sg, sgl_count);
 - sg_init_table(sg, sgl_count);
 - cmd-tvc_sgl_count = sgl_count;
 -
 - pr_debug(Mapping iovec %p for %u pages\n, iov[0], sgl_count);
 -
 - for (i = 0; i  niov; i++) {
 - ret = vhost_scsi_map_to_sgl(cmd, iov[i].iov_base, 
 iov[i].iov_len,
 - sg, write);
 - if (ret  0) {
 - for (i = 0; i  cmd-tvc_sgl_count; i++) {
 - struct page *page = sg_page(cmd-tvc_sgl[i]);
 - if (page)
 - put_page(page);
 - }
 - cmd-tvc_sgl_count = 0;
 - return ret;
 - }
 - sg += ret;
 - sgl_count -= ret;
 - }
 - return 0;
 -}
 -
 -static int
 -vhost_scsi_map_iov_to_prot(struct tcm_vhost_cmd *cmd,
 -struct iovec *iov,
 -int niov,
 -bool write)
 -{
 - struct scatterlist *prot_sg = cmd-tvc_prot_sgl;
 - unsigned int prot_sgl_count = 0;
 - int ret, i;
 -
 - for (i = 0; i  niov; i++)
 - prot_sgl_count += iov_num_pages(iov[i].iov_base, 
 iov[i].iov_len);
 -
 - if (prot_sgl_count  TCM_VHOST_PREALLOC_PROT_SGLS) {
 - pr_err(vhost_scsi_map_iov_to_prot() sgl_count: %u greater than
 -  preallocated TCM_VHOST_PREALLOC_PROT_SGLS: %u\n,
 - prot_sgl_count, TCM_VHOST_PREALLOC_PROT_SGLS);
 - return -ENOBUFS;
 - }
 -
 - pr_debug(%s prot_sg %p prot_sgl_count %u\n, __func__,
 -  prot_sg, prot_sgl_count);
 - sg_init_table(prot_sg, prot_sgl_count);
 - cmd-tvc_prot_sgl_count = prot_sgl_count;
 -
 - for (i = 0; i  niov; i++) {
 - ret = vhost_scsi_map_to_sgl(cmd, iov[i].iov_base, 
 iov[i].iov_len,
 - prot_sg, write);
 - if (ret  0) {
 - for (i = 0; i  cmd-tvc_prot_sgl_count; i++) {
 - struct page *page = 
 sg_page(cmd-tvc_prot_sgl[i]);
 - if (page)
 - put_page(page);
 - }
 - cmd-tvc_prot_sgl_count = 0;
 - return ret;
 - }
 - prot_sg += ret;
 - prot_sgl_count -= ret;
 - }
 - return 0;
 -}
 -
 -static int
  vhost_scsi_calc_sgls(struct iov_iter *iter, size_t bytes, int max_sgls)
  {
   int sgl_count = 0;
 @@ -1323,254 +1236,6 @@ out:
   mutex_unlock(vq-mutex);
  }
  
 -static void
 -vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
 -{
 - struct tcm_vhost_tpg **vs_tpg;
 - struct virtio_scsi_cmd_req v_req;
 - struct virtio_scsi_cmd_req_pi v_req_pi;
 - struct tcm_vhost_tpg *tpg;
 - struct tcm_vhost_cmd *cmd;
 - u64 tag;
 - u32 exp_data_len, data_first, data_num, data_direction, prot_first;
 - unsigned out, in, i;
 - int head, ret, data_niov, prot_niov, prot_bytes;
 - size_t req_size;
 - u16 lun;
 - u8 *target, *lunp, task_attr;
 - bool hdr_pi;
 - void *req, *cdb;
 -
 -