From: Paolo Bonzini <pbonzini@redhat.com>
To: Felipe Franciosi <felipe@nutanix.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
stable <stable@vger.kernel.org>
Subject: Re: [PATCH] scsi: virtio_scsi: don't send sc payload with tmfs
Date: Wed, 27 Feb 2019 17:28:17 +0100 [thread overview]
Message-ID: <a4ff6218-40c9-d232-0852-5a30e2c2eaab@redhat.com> (raw)
In-Reply-To: <1550403730-27876-1-git-send-email-felipe@nutanix.com>
On 27/02/19 17:10, Felipe Franciosi wrote:
> The virtio scsi spec defines struct virtio_scsi_ctrl_tmf as a set of
> device-readable records and a single device-writable response entry:
>
> struct virtio_scsi_ctrl_tmf
> {
> // Device-readable part
> le32 type;
> le32 subtype;
> u8 lun[8];
> le64 id;
> // Device-writable part
> u8 response;
> }
>
> The above should be organised as two descriptor entries (or potentially
> more if using VIRTIO_F_ANY_LAYOUT), but without any extra data after
> "le64 id" or after "u8 response".
>
> The Linux driver doesn't respect that, with virtscsi_abort() and
> virtscsi_device_reset() setting cmd->sc before calling virtscsi_tmf().
> It results in the original scsi command payload (or writable buffers)
> added to the tmf.
>
> This fixes the problem by leaving cmd->sc zeroed out, which makes
> virtscsi_kick_cmd() add the tmf to the control vq without any payload.
Indeed, all that the completion routine needs is cmd->comp, which is set
directly in virtscsi_tmf.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
>
> Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
> ---
> drivers/scsi/virtio_scsi.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 772b976..464cba5 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -594,7 +594,6 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
> return FAILED;
>
> memset(cmd, 0, sizeof(*cmd));
> - cmd->sc = sc;
> cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
> .type = VIRTIO_SCSI_T_TMF,
> .subtype = cpu_to_virtio32(vscsi->vdev,
> @@ -653,7 +652,6 @@ static int virtscsi_abort(struct scsi_cmnd *sc)
> return FAILED;
>
> memset(cmd, 0, sizeof(*cmd));
> - cmd->sc = sc;
> cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
> .type = VIRTIO_SCSI_T_TMF,
> .subtype = VIRTIO_SCSI_T_TMF_ABORT_TASK,
>
next prev parent reply other threads:[~2019-02-27 16:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 16:10 Felipe Franciosi
2019-02-27 16:28 ` Paolo Bonzini [this message]
2019-03-06 17:35 ` Martin K. Petersen
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=a4ff6218-40c9-d232-0852-5a30e2c2eaab@redhat.com \
--to=pbonzini@redhat.com \
--cc=felipe@nutanix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefanha@redhat.com \
/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
Powered by JetHome