Re: [PATCH 6/6] virtio-scsi: Enable DIF/DIX modes in SCSI host LLD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2014-04-07 at 11:03 +0300, Sagi Grimberg wrote:
> On 4/7/2014 12:32 AM, Nicholas A. Bellinger wrote:
> > From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
> >
> > This patch updates virtscsi_probe() to setup necessary Scsi_Host
> > level protection resources. (currently hardcoded to 1)
> >
> > It changes virtscsi_add_cmd() to attach outgoing / incoming
> > protection SGLs preceeding the data payload, and is using the
> > new virtio_scsi_cmd_req_pi->d[oi],pi_niv field to signal
> > to signal to vhost/scsi how many prot_sgs to expect.
> >
> > v3 changes:
> >    - Use VIRTIO_SCSI_F_T10_PI to determine PI or non PI header (Paolo)
> >
> > v2 changes:
> >    - Make protection buffer come before data buffer (Paolo)
> >    - Enable virtio_scsi_cmd_req_pi usage (Paolo)
> >
> > Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> > Cc: Michael S. Tsirkin <mst@xxxxxxxxxx>
> > Cc: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
> > Cc: Christoph Hellwig <hch@xxxxxx>
> > Cc: Hannes Reinecke <hare@xxxxxxx>
> > Cc: Sagi Grimberg <sagig@xxxxxxxxxxxxxxxxxx>
> > Cc: H. Peter Anvin <hpa@xxxxxxxxx>
> > Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
> > ---
> >   drivers/scsi/virtio_scsi.c |   78 ++++++++++++++++++++++++++++++++++----------
> >   1 file changed, 60 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> > index 16bfd50..68d8d1b 100644
> > --- a/drivers/scsi/virtio_scsi.c
> > +++ b/drivers/scsi/virtio_scsi.c
> > @@ -37,6 +37,7 @@ struct virtio_scsi_cmd {
> >   	struct completion *comp;
> >   	union {
> >   		struct virtio_scsi_cmd_req       cmd;
> > +		struct virtio_scsi_cmd_req_pi    cmd_pi;
> >   		struct virtio_scsi_ctrl_tmf_req  tmf;
> >   		struct virtio_scsi_ctrl_an_req   an;
> >   	} req;
> > @@ -440,7 +441,7 @@ static int virtscsi_add_cmd(struct virtqueue *vq,
> >   			    size_t req_size, size_t resp_size, gfp_t gfp)
> >   {
> >   	struct scsi_cmnd *sc = cmd->sc;
> > -	struct scatterlist *sgs[4], req, resp;
> > +	struct scatterlist *sgs[6], req, resp;
> >   	struct sg_table *out, *in;
> >   	unsigned out_num = 0, in_num = 0;
> >   
> > @@ -458,16 +459,24 @@ static int virtscsi_add_cmd(struct virtqueue *vq,
> >   	sgs[out_num++] = &req;
> >   
> >   	/* Data-out buffer.  */
> > -	if (out)
> > +	if (out) {
> > +		/* Place WRITE protection SGLs before Data OUT payload */
> > +		if (scsi_prot_sg_count(sc))
> 
> Didn't we agree that the LLD should not discard the scmnd prot_op? Martin?
> 

Without the initiator providing a protection buffer, there is not much
else that can be done here.

So for the special case where the protect CDB is set, but no protection
buffer is provided, the WRITE_INSERT / READ_STRIP emulation should kick
in on the target side.

--nab

> > +			sgs[out_num++] = scsi_prot_sglist(sc);
> >   		sgs[out_num++] = out->sgl;
> > +	}
> >   
> >   	/* Response header.  */
> >   	sg_init_one(&resp, &cmd->resp, resp_size);
> >   	sgs[out_num + in_num++] = &resp;
> >   
> >   	/* Data-in buffer */
> > -	if (in)
> > +	if (in) {
> > +		/* Place READ protection SGLs before Data IN payload */
> > +		if (scsi_prot_sg_count(sc))
> 
> Same here.
> 
> > +			sgs[out_num + in_num++] = scsi_prot_sglist(sc);
> >   		sgs[out_num + in_num++] = in->sgl;
> > +	}
> >   
> >   	return virtqueue_add_sgs(vq, sgs, out_num, in_num, cmd, gfp);
> >   }
> >

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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux