From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anZp4-0005qN-Tm for qemu-devel@nongnu.org; Tue, 05 Apr 2016 18:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anZoz-0002fC-Q4 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 18:51:46 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:33496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anZoz-0002el-G4 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 18:51:41 -0400 Received: by mail-wm0-x232.google.com with SMTP id f198so50452954wme.0 for ; Tue, 05 Apr 2016 15:51:40 -0700 (PDT) Sender: Paolo Bonzini References: <1459779314-12266-1-git-send-email-eblake@redhat.com> From: Paolo Bonzini Message-ID: <57044177.80804@redhat.com> Date: Wed, 6 Apr 2016 00:51:35 +0200 MIME-Version: 1.0 In-Reply-To: <1459779314-12266-1-git-send-email-eblake@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] doc: Allow NBD_CMD_FLAG_NO_HOLE during NBD_CMD_WRITE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , "nbd-general@lists.sourceforge.net" Cc: "Denis V. Lunev" , qemu-devel , Pavel Borzenkov On 04/04/2016 16:15, Eric Blake wrote: > qemu already has an existing server implementation option that will > explicitly search the payload of NBD_CMD_WRITE for large blocks of > zeroes, and punch holes in the underlying file. For old clients > that don't know how to use the new NBD_CMD_WRITE_ZEROES, this is a > workaround to keep the server's destination file approximately as > sparse as the client's source. I don't think this is the case; the flag is explicitly meant to override the client. Paolo > However, for new clients that know > how to explicitly request holes, it is unnecessary overhead; and > can lead to the server punching a hole and risking fragmentation or > future ENOSPC even when the client explicitly wanted to write > zeroes rather than a hole. So it makes sense to let the new > NBD_CMD_FLAG_NO_HOLE work for WRITE as well as WRITE_ZEROES. > > Signed-off-by: Eric Blake > --- > doc/proto.md | 33 +++++++++++++++++++++++++++------ > 1 file changed, 27 insertions(+), 6 deletions(-) > > diff --git a/doc/proto.md b/doc/proto.md > index 35a3266..fb97217 100644 > --- a/doc/proto.md > +++ b/doc/proto.md > @@ -737,8 +737,14 @@ by a sparse file. With current NBD command set, the client has to issue > through the wire. The server has to write the data onto disk, effectively > losing the sparseness. > > -To remedy this, a `WRITE_ZEROES` extension is envisioned. This extension adds > -one new command and one new command flag. > +To remedy this, a `WRITE_ZEROES` extension is envisioned. This > +extension adds one new transmission flag, one new command, and one new > +command flag; and refines an existing command. > + > +* `NBD_FLAG_SEND_WRITE_ZEROES` > + > + The server SHOULD set this transmission flag to 1 if the > + `NBD_CMD_WRITE_ZEROES` request is supported. > > * `NBD_CMD_WRITE_ZEROES` > > @@ -772,12 +778,27 @@ The server SHOULD return `ENOSPC` if it receives a write zeroes request > including one or more sectors beyond the size of the device. It SHOULD > return `EPERM` if it receives a write zeroes request on a read-only export. > > +* `NBD_CMD_WRITE` > + > + By default, the server MAY search for large contiguous blocks of > + all zero content, and use trimming to zero out those portions of > + the write, even if it did not advertise `NBD_FLAG_SEND_TRIM`; but > + it MUST ensure that any trimmed areas of data read back as zero. > + However, the client MAY set the command flag > + `NBD_CMD_FLAG_NO_HOLE` to inform the server that the entire > + written area MUST be fully provisioned, ensuring that future > + writes to the same area will not cause fragmentation or cause > + failure due to insufficient space. Clients SHOULD NOT set this > + flag unless the server advertised `NBD_FLAG_SEND_WRITE_ZEROES` in > + the transmisison flags. > + > The extension adds the following new command flag: > > -- `NBD_CMD_FLAG_NO_HOLE`; valid during `NBD_CMD_WRITE_ZEROES`. > - SHOULD be set to 1 if the client wants to ensure that the server does > - not create a hole. The client MAY send `NBD_CMD_FLAG_NO_HOLE` even > - if `NBD_FLAG_SEND_TRIM` was not set in the transmission flags field. > +- `NBD_CMD_FLAG_NO_HOLE`; valid during `NBD_CMD_WRITE` and > + `NBD_CMD_WRITE_ZEROES`. SHOULD be set to 1 if the client wants to > + ensure that the server does not create a hole. The client MAY send > + `NBD_CMD_FLAG_NO_HOLE` even if `NBD_FLAG_SEND_TRIM` was not set in > + the transmission flags field. > > ### `STRUCTURED_REPLY` extension >