linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Nicholas A. Bellinger" <nab@daterainc.com>
Cc: target-devel <target-devel@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	kvm-devel <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Al Viro <viro@ZenIV.linux.org.uk>, Christoph Hellwig <hch@lst.de>,
	Nicholas Bellinger <nab@linux-iscsi.org>
Subject: Re: [PATCH-v3 1/9] vhost/scsi: Convert completion path to use copy_to_iser
Date: Tue, 3 Feb 2015 11:24:05 +0200	[thread overview]
Message-ID: <20150203092405.GH2830@redhat.com> (raw)
In-Reply-To: <1422945003-24538-2-git-send-email-nab@daterainc.com>



On Tue, Feb 03, 2015 at 06:29:55AM +0000, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> Required for ANY_LAYOUT support when the incoming virtio-scsi response
> header + fixed size sense buffer payload may span more than a single
> iovec entry.
> 
> This changes existing code to save cmd->tvc_resp_iov instead of the
> first single iovec base pointer from &vq->iov[out].

Typo in subject: should be copy_to_iter.

> v3 changes:
>   - Convert memcpy_toiovecend -> copy_to_iser usage

This belongs after ---

> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>  drivers/vhost/scsi.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 01c01cb..1ad5b0f 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -72,6 +72,8 @@ struct tcm_vhost_cmd {
>  	int tvc_vq_desc;
>  	/* virtio-scsi initiator task attribute */
>  	int tvc_task_attr;
> +	/* virtio-scsi response incoming iovecs */
> +	int tvc_in_iovs;
>  	/* virtio-scsi initiator data direction */
>  	enum dma_data_direction tvc_data_direction;
>  	/* Expected data transfer length from virtio-scsi header */
> @@ -87,8 +89,8 @@ struct tcm_vhost_cmd {
>  	struct scatterlist *tvc_sgl;
>  	struct scatterlist *tvc_prot_sgl;
>  	struct page **tvc_upages;
> -	/* Pointer to response */
> -	struct virtio_scsi_cmd_resp __user *tvc_resp;
> +	/* Pointer to response header iovec */
> +	struct iovec *tvc_resp_iov;
>  	/* Pointer to vhost_scsi for our device */
>  	struct vhost_scsi *tvc_vhost;
>  	/* Pointer to vhost_virtqueue for the cmd */
> @@ -682,6 +684,7 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
>  	struct tcm_vhost_cmd *cmd;
>  	struct llist_node *llnode;
>  	struct se_cmd *se_cmd;
> +	struct iov_iter iov_iter;
>  	int ret, vq;
>  
>  	bitmap_zero(signal, VHOST_SCSI_MAX_VQ);
> @@ -703,8 +706,11 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
>  						 se_cmd->scsi_sense_length);
>  		memcpy(v_rsp.sense, cmd->tvc_sense_buf,
>  		       se_cmd->scsi_sense_length);
> -		ret = copy_to_user(cmd->tvc_resp, &v_rsp, sizeof(v_rsp));
> -		if (likely(ret == 0)) {
> +
> +		iov_iter_init(&iov_iter, WRITE, cmd->tvc_resp_iov,
> +			      cmd->tvc_in_iovs, sizeof(v_rsp));
> +		ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter);
> +		if (likely(ret == sizeof(v_rsp))) {
>  			struct vhost_scsi_virtqueue *q;
>  			vhost_add_used(cmd->tvc_vq, cmd->tvc_vq_desc, 0);
>  			q = container_of(cmd->tvc_vq, struct vhost_scsi_virtqueue, vq);
> @@ -1159,7 +1165,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
>  
>  		cmd->tvc_vhost = vs;
>  		cmd->tvc_vq = vq;
> -		cmd->tvc_resp = vq->iov[out].iov_base;
> +		cmd->tvc_resp_iov = &vq->iov[out];
> +		cmd->tvc_in_iovs = in;
>  
>  		pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n",
>  			cmd->tvc_cdb[0], cmd->tvc_lun);
> -- 
> 1.9.1

  reply	other threads:[~2015-02-03  9:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03  6:29 [PATCH-v3 0/9] vhost/scsi: Add ANY_LAYOUT + VERSION_1 support Nicholas A. Bellinger
2015-02-03  6:29 ` [PATCH-v3 1/9] vhost/scsi: Convert completion path to use copy_to_iser Nicholas A. Bellinger
2015-02-03  9:24   ` Michael S. Tsirkin [this message]
2015-02-04  8:47     ` Nicholas A. Bellinger
2015-02-03  6:29 ` [PATCH-v3 2/9] vhost/scsi: Fix incorrect early vhost_scsi_handle_vq failures Nicholas A. Bellinger
2015-02-03  6:29 ` [PATCH-v3 3/9] vhost/scsi: Change vhost_scsi_map_to_sgl to accept iov ptr + len Nicholas A. Bellinger
2015-02-03  6:29 ` [PATCH-v3 4/9] vhost/scsi: Add ANY_LAYOUT iov -> sgl mapping prerequisites Nicholas A. Bellinger
2015-02-03  9:32   ` Michael S. Tsirkin
2015-02-04  8:48     ` Nicholas A. Bellinger
2015-02-03  6:29 ` [PATCH-v3 5/9] vhost/scsi: Add ANY_LAYOUT vhost_virtqueue callback Nicholas A. Bellinger
2015-02-03 10:14   ` Michael S. Tsirkin
2015-02-04  9:40     ` Nicholas A. Bellinger
2015-02-04  9:42       ` Michael S. Tsirkin
2015-02-04 10:41         ` Nicholas A. Bellinger
2015-02-04 10:55           ` Nicholas A. Bellinger
2015-02-04 13:16             ` Michael S. Tsirkin
2015-02-04 13:13           ` Michael S. Tsirkin
2015-02-04 13:15           ` Michael S. Tsirkin
2015-02-03 15:22   ` Michael S. Tsirkin
2015-02-03 23:56   ` Al Viro
2015-02-04  7:14     ` Michael S. Tsirkin
2015-02-04 10:11     ` Nicholas A. Bellinger
2015-02-04 10:20       ` Michael S. Tsirkin
2015-02-04 10:41         ` Nicholas A. Bellinger
2015-02-03  6:30 ` [PATCH-v3 6/9] vhost/scsi: Set VIRTIO_F_ANY_LAYOUT + VIRTIO_F_VERSION_1 feature bits Nicholas A. Bellinger
2015-02-03  9:40   ` Michael S. Tsirkin
2015-02-04  9:13     ` Nicholas A. Bellinger
2015-02-04  9:34       ` Michael S. Tsirkin
2015-02-03  6:30 ` [PATCH-v3 7/9] vhost/scsi: Drop legacy pre virtio v1.0 !ANY_LAYOUT logic Nicholas A. Bellinger
2015-02-03  9:37   ` Michael S. Tsirkin
2015-02-04  9:03     ` Nicholas A. Bellinger
2015-02-03  6:30 ` [PATCH-v3 8/9] vhost/scsi: Drop left-over scsi_tcq.h include Nicholas A. Bellinger
2015-02-03  9:38   ` Michael S. Tsirkin
2015-02-03  6:30 ` [PATCH-v3 9/9] vhost/scsi: Global tcm_vhost -> vhost_scsi rename Nicholas A. Bellinger
2015-02-03  9:38   ` Michael S. Tsirkin
2015-02-03  9:35 ` [PATCH-v3 0/9] vhost/scsi: Add ANY_LAYOUT + VERSION_1 support Michael S. Tsirkin
2015-02-04  8:51   ` Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150203092405.GH2830@redhat.com \
    --to=mst@redhat.com \
    --cc=hch@lst.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@daterainc.com \
    --cc=nab@linux-iscsi.org \
    --cc=pbonzini@redhat.com \
    --cc=target-devel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).