All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, Wouter Verhelst <w@uter.be>
Cc: "nbd-general@lists.sourceforge.net"
	<nbd-general@lists.sourceforge.net>,
	"Denis V. Lunev" <den@openvz.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Alex Bligh <alex@alex.org.uk>
Subject: Re: [Qemu-devel] [Nbd] [RFC 1/1] nbd (specification): add NBD_CMD_WRITE_ZEROES command
Date: Fri, 4 Mar 2016 15:03:26 +0100	[thread overview]
Message-ID: <56D995AE.1080805@redhat.com> (raw)
In-Reply-To: <20160304095413.GC4366@noname.redhat.com>



On 04/03/2016 10:54, Kevin Wolf wrote:
>>> - pls write the following amount of zeroes in either way (even calling
>>> > >    write directly), i.e. ensure that the data is zeroed and the space on
>>> > >    the file system is allocated for that.
>> > 
>> > IOW, you *don't* want to have a sparse file in that case? Or do I
>> > misunderstand things here?
> I think what we're looking for is more like "zero out this area, feel
> free to use whatever method is most efficient to achieve that".
> 
> So if the server knows that the backing store supports an efficient way
> to write zeros (e.g. FALLOC_FL_ZERO_RANGE), it will use that. Otherwise,
> if TRIM works and we know that the result is zeroed space instead of
> undefined contents, the server is free to use it. And if even that
> fails, it just falls back to an explicit write of a zeroed buffer.
> 
> If we want, we can give the client a little more control about whether
> or not discarding in the process is allowed (or maybe even preferred).
> qemu's interface for writing zeros has a BDRV_REQ_MAY_UNMAP flag, for
> example.

NBD-wise, I think the TRIM command is good as it is, and
NBD_CMD_WRITE_ZEROES should be added like Den is doing.

It also makes sense to use trimming to implement NBD_CMD_WRITE_ZEROES,
but it should be explicitly requested by the user.  For this, my
suggestion is that NBD_CMD_WRITE_ZEROES should have an NBD_FLAG_TRY_TRIM
flag in bit 16.  If specified, the backend can use a zero-writing
mechanism that trims, _but_ it must ensure that the bytes read as zero.
 If it cannot ensure that, it must not trim and it should instead do a
full write.  This is similar to the SCSI command WRITE SAME (when the
command payload is all zeroes).  Like Kevin said, it also happens to map
nicely to the QEMU block device layer.

Paolo

  reply	other threads:[~2016-03-04 14:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 18:10 [Qemu-devel] [RFC 1/1] nbd (specification): add NBD_CMD_WRITE_ZEROES command Denis V. Lunev
2016-02-17 20:58 ` Eric Blake
2016-02-18  4:46   ` Denis V. Lunev
2016-02-18  8:30     ` Denis V. Lunev
2016-02-18  9:18   ` Roman Kagan
2016-02-18 10:36     ` Denis V. Lunev
2016-02-18 16:35     ` Eric Blake
2016-02-18 17:23       ` [Qemu-devel] SUMMARY: " Denis V. Lunev
2016-02-18 17:55         ` Eric Blake
2016-02-18 19:29         ` [Qemu-devel] [Nbd] " Alex Bligh
2016-02-19  7:12         ` [Qemu-devel] " Denis V. Lunev
2016-02-19  8:56           ` Vladimir Sementsov-Ogievskiy
2016-02-19  9:11           ` Daniel P. Berrange
2016-02-18 12:14   ` [Qemu-devel] " Daniel P. Berrange
2016-02-18 14:05     ` Denis V. Lunev
2016-02-18  8:09 ` Alex Bligh
2016-02-18  8:34   ` Denis V. Lunev
2016-03-04  8:49     ` [Qemu-devel] [Nbd] " Wouter Verhelst
2016-03-04  9:54       ` Kevin Wolf
2016-03-04 14:03         ` Paolo Bonzini [this message]
2016-03-06 10:28           ` Wouter Verhelst
2016-03-06 18:54             ` Denis V. Lunev

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=56D995AE.1080805@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex@alex.org.uk \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=nbd-general@lists.sourceforge.net \
    --cc=qemu-devel@nongnu.org \
    --cc=w@uter.be \
    /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.