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 v6] virtio_blk: add DISCARD and WRIET ZEROES commands support
Date: Fri, 8 Jun 2018 11:20:27 +0100	[thread overview]
Message-ID: <20180608102027.GB31164@stefanha-x1.localdomain> (raw)
In-Reply-To: <FF7FC980937D6342B9D289F5F3C7C2625B6DED4D@SHSMSX103.ccr.corp.intel.com>


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

On Thu, Jun 07, 2018 at 11:07:06PM +0000, Liu, Changpeng wrote:
> 
> 
> > -----Original Message-----
> > From: Stefan Hajnoczi [mailto:stefanha@redhat.com]
> > Sent: Thursday, June 7, 2018 9:10 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 v6] virtio_blk: add DISCARD and WRIET ZEROES commands
> > support
> > 
> > On Wed, Jun 06, 2018 at 12:19:00PM +0800, Changpeng Liu wrote:
> > > Existing virtio-blk protocol doesn't have DISCARD/WRITE ZEROES commands
> > > support, this will impact the performance when using SSD backend over
> > > file systems.
> > >
> > > Commit 88c85538 "virtio-blk: add discard and write zeroes features to
> > > specification"(see https://github.com/oasis-tcs/virtio-spec) extended
> > > existing virtio-blk protocol, adding extra DISCARD and WRITE ZEROES
> > > commands support.
> > >
> > > While here, using 16 bytes descriptor to describe one segment of DISCARD
> > > or WRITE ZEROES commands, each command may contain one or more
> > decriptors.
> > >
> > > The following data structure shows the definition of one descriptor:
> > >
> > > struct virtio_blk_discard_write_zeroes {
> > >         le64 sector;
> > >         le32 num_sectors;
> > >         le32 unmap;
> > > };
> > >
> > > Field 'sector' means the start sector for DISCARD and WRITE ZEROES,
> > > filed 'num_sectors' means the number of sectors for DISCARD and WRITE
> > > ZEROES, if both DISCARD and WRITE ZEROES are supported, field 'unmap'
> > > maybe used for WRITE ZEROES command with DISCARD enabled.
> > >
> > > We also extended the virtio-blk configuration space to let backend
> > > device put DISCARD and WRITE ZEROES configuration parameters.
> > >
> > > struct virtio_blk_config {
> > >         [...]
> > >
> > >         le32 max_discard_sectors;
> > >         le32 max_discard_seg;
> > >         le32 discard_sector_alignment;
> > >         le32 max_write_zeroes_sectors;
> > >         le32 max_write_zeroes_seg;
> > >         u8 write_zeroes_may_unmap;
> > > }
> > >
> > > New feature bit [VIRTIO_BLK_F_DISCARD (13)]: Device can support discard
> > > command, maximum discard sectors size in field 'max_discard_sectors' and
> > > maximum discard segment number in field 'max_discard_seg'.
> > >
> > > New feature [VIRTIO_BLK_F_WRITE_ZEROES (14)]: Device can support write
> > > zeroes command, maximum write zeroes sectors size in field
> > > 'max_write_zeroes_sectors' and maximum write zeroes segment number in
> > > field 'max_write_zeroes_seg'.
> > >
> > > The parameters in the configuration space of the device field
> > > 'max_discard_sectors' and field 'discard_sector_alignment' are expressed in
> > > 512-byte units if the VIRTIO_BLK_F_DISCARD feature bit is negotiated. The
> > > field 'max_write_zeroes_sectors' is expressed in 512-byte units if the
> > > VIRTIO_BLK_F_WRITE_ZEROES feature bit is negotiated.
> > >
> > > Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
> > > ---
> > > CHANGELOG:
> > > v6: don't set T_OUT bit to discard and write zeroes commands.
> > 
> > I don't see this in the patch...
> Yeah, do noting with DISCARD/WRITE ZEROES means no need to OR BLK_T_OUT again.
> > 
> > > @@ -225,6 +260,7 @@ static blk_status_t virtio_queue_rq(struct
> > blk_mq_hw_ctx *hctx,
> > >  	int qid = hctx->queue_num;
> > >  	int err;
> > >  	bool notify = false;
> > > +	bool unmap = false;
> > >  	u32 type;
> > >
> > >  	BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
> > > @@ -237,6 +273,13 @@ static blk_status_t virtio_queue_rq(struct
> > blk_mq_hw_ctx *hctx,
> > >  	case REQ_OP_FLUSH:
> > >  		type = VIRTIO_BLK_T_FLUSH;
> > >  		break;
> > > +	case REQ_OP_DISCARD:
> > > +		type = VIRTIO_BLK_T_DISCARD;
> > > +		break;
> > > +	case REQ_OP_WRITE_ZEROES:
> > > +		type = VIRTIO_BLK_T_WRITE_ZEROES;
> > > +		unmap = !(req->cmd_flags & REQ_NOUNMAP);
> > > +		break;
> > >  	case REQ_OP_SCSI_IN:
> > >  	case REQ_OP_SCSI_OUT:
> > >  		type = VIRTIO_BLK_T_SCSI_CMD;
> > > @@ -256,6 +299,12 @@ static blk_status_t virtio_queue_rq(struct
> > blk_mq_hw_ctx *hctx,
> > >
> > >  	blk_mq_start_request(req);
> > >
> > > +	if (type == VIRTIO_BLK_T_DISCARD || type ==
> > VIRTIO_BLK_T_WRITE_ZEROES) {
> > > +		err = virtblk_setup_discard_write_zeroes(req, unmap);
> > > +		if (err)
> > > +			return BLK_STS_RESOURCE;
> > > +	}
> > > +
> > >  	num = blk_rq_map_sg(hctx->queue, req, vbr->sg);
> > >  	if (num) {
> > >  		if (rq_data_dir(req) == WRITE)
> > 
> > ...since we still do blk_rq_map_sg() here and num should be != 0.
> No, while here, we should keep the original logic for READ/WRITE commands.

My question is: why does the changelog say "don't set T_OUT" but the
code *will* set it because blk_rq_map_sg() returns != 0 and
rq_data_dir(req) == WRITE?

Maybe I'm misreading the code, but it looks to me like this patch
does the opposite of what the changelog says.

Stefan

[-- 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-08 10:20 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06  4:19 [PATCH v6] virtio_blk: add DISCARD and WRIET ZEROES commands support Changpeng Liu
2018-06-07 13:10 ` Stefan Hajnoczi
2018-06-07 23:07   ` Liu, Changpeng
2018-06-08 10:20     ` Stefan Hajnoczi [this message]
2018-06-11  3:37       ` Liu, Changpeng
2018-06-12 16:05         ` Stefan Hajnoczi
2018-08-28 22:25 ` [PATCH v7] virtio_blk: add discard and write zeroes support Daniel Verkamp
2018-10-12 21:06 ` [PATCH v8] " Daniel Verkamp
2018-10-12 21:06   ` Daniel Verkamp
2018-10-15  0:54   ` Michael S. Tsirkin
2018-10-15  0:54     ` Michael S. Tsirkin
2018-10-15  9:21   ` Ming Lei
2018-10-15  9:27   ` Christoph Hellwig
2018-10-15  9:27     ` Christoph Hellwig
2018-10-15 23:16     ` Daniel Verkamp
2018-10-15 23:16       ` Daniel Verkamp
2018-10-16  1:45       ` Liu, Changpeng
2018-10-16  1:45         ` Liu, Changpeng
2018-10-16  1:40     ` Liu, Changpeng
2018-10-16  1:40       ` Liu, Changpeng
2018-10-25 23:28     ` Paolo Bonzini
2018-10-25 23:28       ` Paolo Bonzini
2018-10-26  8:26       ` Christoph Hellwig
2018-10-26  8:26         ` Christoph Hellwig
2018-10-29  3:21         ` Liu, Changpeng
2018-10-29  3:21           ` Liu, Changpeng
2018-10-29 18:03         ` Paolo Bonzini
2018-10-29 18:03           ` Paolo Bonzini
2018-10-26  8:08   ` Stefan Hajnoczi
2018-10-26  8:08     ` Stefan Hajnoczi
2018-10-26 14:47     ` Michael S. Tsirkin
2018-10-26 14:47       ` Michael S. Tsirkin
2018-10-29  5:05       ` Stefan Hajnoczi
2018-10-29  5:05         ` Stefan Hajnoczi
2018-11-01 21:25         ` Michael S. Tsirkin
2018-11-01 21:25           ` Michael S. Tsirkin
2018-11-01 22:18           ` Daniel Verkamp
2018-11-01 22:18             ` Daniel Verkamp
2018-11-01 22:40 ` [PATCH v9] " Daniel Verkamp
2018-11-01 22:40   ` Daniel Verkamp
2018-11-01 23:43   ` Dongli Zhang
2018-11-01 23:43     ` Dongli Zhang
2018-11-02 18:25     ` Daniel Verkamp
2018-11-02 18:25       ` Daniel Verkamp
2018-11-02  4:17   ` Stefan Hajnoczi
2018-11-02  4:17     ` Stefan Hajnoczi
2018-12-05  9:46     ` Liu, Changpeng
2018-12-05  9:46       ` Liu, Changpeng
2018-12-05 13:41       ` Michael S. Tsirkin
2018-12-05 13:41         ` Michael S. Tsirkin

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=20180608102027.GB31164@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.