All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Liu, Changpeng" <changpeng.liu@intel.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
	"cavery@redhat.com" <cavery@redhat.com>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH v4] virtio_blk: add DISCARD and WRIET ZEROES commands support
Date: Fri, 1 Jun 2018 09:59:35 +0100	[thread overview]
Message-ID: <20180601085935.GA8196@stefanha-x1.localdomain> (raw)
In-Reply-To: <FF7FC980937D6342B9D289F5F3C7C2625B6DCEE5@SHSMSX103.ccr.corp.intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 2364 bytes --]

On Thu, May 31, 2018 at 11:53:26PM +0000, Liu, Changpeng wrote:
> 
> 
> > -----Original Message-----
> > From: Stefan Hajnoczi [mailto:stefanha@redhat.com]
> > Sent: Thursday, May 31, 2018 6:31 PM
> > To: Liu, Changpeng <changpeng.liu@intel.com>
> > Cc: virtualization@lists.linux-foundation.org; cavery@redhat.com;
> > jasowang@redhat.com; pbonzini@redhat.com; Wang, Wei W
> > <wei.w.wang@intel.com>
> > Subject: Re: [PATCH v4] virtio_blk: add DISCARD and WRIET ZEROES commands
> > support
> > 
> > On Tue, May 29, 2018 at 09:42:24AM +0800, Changpeng Liu wrote:
> > >  	num = blk_rq_map_sg(hctx->queue, req, vbr->sg);
> > >  	if (num) {
> > > -		if (rq_data_dir(req) == WRITE)
> > > +		if (rq_data_dir(req) == WRITE || type == VIRTIO_BLK_T_DISCARD
> > ||
> > > +		    type == VIRTIO_BLK_T_WRITE_ZEROES)
> > >  			vbr->out_hdr.type |= cpu_to_virtio32(vblk->vdev,
> > VIRTIO_BLK_T_OUT);
> > 
> > The VIRTIO specification says:
> > 
> >   The type of the request is either a read (VIRTIO_BLK_T_IN), a write
> >   (VIRTIO_BLK_T_OUT), a discard (VIRTIO_BLK_T_DISCARD), a write zeroes
> >   (VIRTIO_BLK_T_WRITE_ZEROES) or a flush (VIRTIO_BLK_T_FLUSH).
> > 
> > But this patch actually uses VIRTIO_BLK_T_DISCARD | VIRTIO_BLK_T_OUT or
> > VIRTIO_BLK_T_WRITE_ZEROES | VIRTIO_BLK_T_OUT.  "either A or B" is
> > exclusive, it does not mean "A and B".
> Hi Stefan,
> 
> For the new add DISCARD and WRITE ZEROES commands, I defined the 
> type code to 11 and 13, so the last bit always is 1, there is no difference
> in practice.

Then the code is misleading.  This is clearer:

  if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES)
      /* Do nothing, type already set */
  else if (rq_data_dir(req) == WRITE)
      vbr->out_hdr.type |= cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_OUT);
  ...

> But I believe the specification says VIRTIO_BLK_T_OUT means direction, so
> OR the two bits together should compliance with the specification.

I cannot find that in the specification:

  http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-2020002

and it would contradict the "The type of the request is either ... or
..." wording that I quoted from the spec above.

If you do find something in the spec, please let me know and we can
figure out how to make the spec consistent.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2018-06-01  8:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29  1:42 [PATCH v4] virtio_blk: add DISCARD and WRIET ZEROES commands support Changpeng Liu
2018-05-31 10:30 ` Stefan Hajnoczi
2018-05-31 23:53   ` Liu, Changpeng
2018-06-01  8:59     ` Stefan Hajnoczi [this message]
2018-06-04  4:14       ` Liu, Changpeng
2018-06-04 10:02         ` Paolo Bonzini
2018-06-05  0:55           ` Liu, Changpeng

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=20180601085935.GA8196@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=cavery@redhat.com \
    --cc=changpeng.liu@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.