qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: nbd-general@lists.sourceforge.net
Cc: den@openvz.org, qemu-devel@nongnu.org, pborzenkov@virtuozzo.com
Subject: Re: [Qemu-devel] [Nbd] [PATCH] doc: Flip bit sense for allowing trim during WRITE_ZEROES
Date: Mon, 4 Apr 2016 07:56:16 -0600	[thread overview]
Message-ID: <57027280.1020800@redhat.com> (raw)
In-Reply-To: <1459546186-17002-1-git-send-email-eblake@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2766 bytes --]

On 04/01/2016 03:29 PM, Eric Blake wrote:
> Rather than requiring allocation by default and allowing trims
> only on request during WRITE_ZEROES, it seems like a better
> default is to allow server optimizations by default and require
> full allocation by specific request.  Since WRITE_ZEROES is
> experimental and has not yet been implemented, we can flip the
> sense of the command flag so that the default flags of all 0s
> is the most efficient, and flags (whether _FUA or _NO_HOLE) are
> added to make the operation have tighter constraints but
> possibly slower execution.
> 
> The name NO_HOLE is also slightly nicer at expressing the fact
> that there is no dependency on whether NBD_CMD_TRIM is supported.
> 

> -    If the flag `NBD_CMD_FLAG_MAY_TRIM` was set by the client in the command
> -    flags field, the server MAY use trimming to zero out the area, but it
> -    MUST ensure that the data reads back as zero.
> +    By default, the server MAY use trimming to zero out the area, even
> +    if it did not advertise `NBD_FLAG_SEND_TRIM`; but it MUST ensure
> +    that the data reads back as zero.  However, the client MAY set the
> +    command flag `NBD_CMD_FLAG_NO_HOLE` to inform the server that the
> +    area MUST be fully provisioned, ensuring that future writes to the
> +    same area will not cause fragmentation or cause failure due to
> +    insufficient space.

Question - qemu already has the notion of an nbd server that can be
configured to explicitly check for large repetitions of zero during
NBD_CMD_WRITE, and create holes in the corresponding file as a result
(basically because qemu is compensating for NBD_CMD_WRITE_ZEROES not
being part of the protocol yet, so that the destination file can still
be sparse even though lots of zeroes were sent over the wire). Should we
also allow servers to accept NBD_CMD_FLAG_NO_HOLE during NBD_CMD_WRITE
as an explicit request to NOT perform the magic of searching for large
runs of zeroes, but to just write everything as written?

For older qemu clients that are not aware of the new WRITE_ZEROES
command, the client will also not use the NO_HOLE flag for normal
writes, and everything is at the mercy of the server recognizing zeroes.
 But for newer qemu clients, it can be usefully assumed that the client
will always prefer WRITE_ZEROES (without flags) when it is okay to punch
a hole, and therefore that the new client will also send the NO_HOLE
flag to normal WRITE to inform the server that it doesn't need to waste
time searching for large runs of zeroes.

If this sounds reasonable, I'll go ahead and propose a patch.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2016-04-04 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 21:29 [Qemu-devel] [PATCH] doc: Flip bit sense for allowing trim during WRITE_ZEROES Eric Blake
2016-04-01 22:20 ` Alex Bligh
2016-04-02  7:38 ` Denis V. Lunev
2016-04-04 13:56 ` Eric Blake [this message]
2016-04-04 15:15   ` [Qemu-devel] [Nbd] " Alex Bligh

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=57027280.1020800@redhat.com \
    --to=eblake@redhat.com \
    --cc=den@openvz.org \
    --cc=nbd-general@lists.sourceforge.net \
    --cc=pborzenkov@virtuozzo.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).