Received: from eggs.gnu.org ([2001:4830:134:3::10]:51495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anNRT-0006As-QX for qemu-devel@nongnu.org; Tue, 05 Apr 2016 05:38:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anNRS-0006km-FF for qemu-devel@nongnu.org; Tue, 05 Apr 2016 05:38:35 -0400 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]:36675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anNRS-0006kL-4U for qemu-devel@nongnu.org; Tue, 05 Apr 2016 05:38:34 -0400 From: Markus Pargmann Date: Tue, 05 Apr 2016 11:38:25 +0200 Message-ID: <4138293.p7OeGaqt34@adelgunde> In-Reply-To: <1459808143-22482-1-git-send-email-eblake@redhat.com> References: <1459779314-12266-1-git-send-email-eblake@redhat.com> <1459808143-22482-1-git-send-email-eblake@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2380348.mA9oWbZDp0"; micalg="pgp-sha256"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [Nbd] [PATCH v2] doc: Allow NBD_CMD_FLAG_NO_HOLE during NBD_CMD_WRITE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: nbd-general@lists.sourceforge.net Cc: den@openvz.org, qemu-devel@nongnu.org, pborzenkov@virtuozzo.com --nextPart2380348.mA9oWbZDp0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" Hi, On Monday 04 April 2016 16:15:43 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. 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. From=20the commit message it sounds like this is only for new clients supporting WRITE_ZEROES because for those we don't want to search through all the data of normal WRITEs. If you don't need to set this fo= r each WRITE individually perhaps we could move it to the negotiation part? Best Regards, Markus >=20 > Signed-off-by: Eric Blake > --- >=20 > v2: fix some typos, add a sentence about server MUST support > NBD_CMD_FLAG_NO_HOLE if it advertises NBD_FLAG_SEND_WRITE_ZEROES >=20 > doc/proto.md | 38 ++++++++++++++++++++++++++++++-------- > 1 file changed, 30 insertions(+), 8 deletions(-) >=20 > diff --git a/doc/proto.md b/doc/proto.md > index 35a3266..bca0525 100644 > --- a/doc/proto.md > +++ b/doc/proto.md > @@ -487,7 +487,7 @@ valid may depend on negotiation during the handsh= ake phase. > `NBD_CMD_WRITE_ZEROES` commands. SHOULD be set to 1 if the client= requires > "Force Unit Access" mode of operation. MUST NOT be set unless tra= nsmission > flags included `NBD_FLAG_SEND_FUA`. > -- bit 1, `NBD_CMD_NO_HOLE`; defined by the experimental `WRITE_ZEROE= S` > +- bit 1, `NBD_CMD_FLAG_NO_HOLE`; defined by the experimental `WRITE_= ZEROES` > extension; see below. > - bit 2, `NBD_CMD_FLAG_DF`; defined by the experimental `STRUCTURED_= REPLY` > extension; see below > @@ -574,7 +574,7 @@ The following request types exist: >=20 > After issuing this command, a client MUST NOT make any assumptio= ns > about the contents of the export affected by this command, until= > - overwriting it again with `NBD_CMD_WRITE`. > + overwriting it again with `NBD_CMD_WRITE` or `NBD_CMD_WRITE_ZERO= ES`. >=20 > A client MUST NOT send a trim request unless `NBD_FLAG_SEND_TRIM= ` > was set in the transmission flags field. > @@ -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, effect= ively > losing the sparseness. >=20 > -To remedy this, a `WRITE_ZEROES` extension is envisioned. This exten= sion 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 n= ew > +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. >=20 > * `NBD_CMD_WRITE_ZEROES` >=20 > @@ -772,12 +778,28 @@ The server SHOULD return `ENOSPC` if it receive= s a write zeroes request > including one or more sectors beyond the size of the device. It SHOU= LD > return `EPERM` if it receives a write zeroes request on a read-only = export. >=20 > +* `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`; bu= t > + 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` i= n > + the transmission flags. > + > The extension adds the following new command flag: >=20 > -- `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 d= oes > - 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 fiel= d. > +- `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. The server MUST support the use of > + this flag if it advertises `NBD_FLAG_SEND_WRITE_ZEROES`. >=20 > ### `STRUCTURED_REPLY` extension >=20 >=20 =2D-=20 Pengutronix e.K. | = | Industrial Linux Solutions | http://www.pengutronix.de/= | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 = | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-555= 5 | --nextPart2380348.mA9oWbZDp0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJXA4eRAAoJEEpcgKtcEGQQV28QAJL7oRpJA/eL+r30FNHrRI5y 9TmZZ4woBaZxGuVjcSyduHoEXeZX+Y/jPfb2K5vVDMcw/43lZ3aaaA4NxnmmvFmL uTdPCyoBOG6BSCkwOcCkPUhWMe6yIhnD8iPvz+zZgaT5y7V5MUcht9vPCH7p98t+ mE3ivYkoHZupoWBNeNAUHBY6LteAI9tjjJK+8zYGHEPD93cXjCCKeWyykdmijM+Y p0b67q7xlv7SJ4+qE5s3qKj1WQwJBI4TBojCRTpp+ZVxzktjTISNfY2RryMoRMVr IVHndUkbJO0HC2/YfYp/6AV64tCv6ejgWO15sVpK8cqF2x9Lt1SOs9esnNrmJUJw gKlL1SfABewuru6ljgmZPdhO9LAGNP+2xolREHAQYE2xeC+7amvNw6ThQAQ+J3mk gVhV3PGExfe1NpF47CD46O6JCXU1MDzoEKbbBicjVNExR2S4umW9I7391CUiHU2V gdKf69t66yId1G9859NgQdzi+mx3Z/KwDyyrWVdokkq8qJJDvj6RvSX9a0IZzqWD IPidNc8h0PYUKC10WUdwRri21IsZ8KTnl0PgqCH5YsL8JZ6TWTaZfxGHBimu2GAM V3UyDlZ5YrKTwLM8WkvvKRCO17ItiM3KnyzrRHa+e13VzYv6eTrLi1k6ju3ONZEb Qk50PSPva19F2KCvSO/h =ww7D -----END PGP SIGNATURE----- --nextPart2380348.mA9oWbZDp0--