Received: from eggs.gnu.org ([2001:4830:134:3::10]:60641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1borJO-0005C9-6B for qemu-devel@nongnu.org; Tue, 27 Sep 2016 08:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1borJM-0006p9-NJ for qemu-devel@nongnu.org; Tue, 27 Sep 2016 08:16:38 -0400 References: <1474893981-5302-1-git-send-email-vsementsov@virtuozzo.com> From: "Denis V. Lunev" Message-ID: <27bd2bc9-b879-81ef-c7b6-31335e6be84f@virtuozzo.com> Date: Tue, 27 Sep 2016 12:43:11 +0300 MIME-Version: 1.0 In-Reply-To: <1474893981-5302-1-git-send-email-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] proto: add 'shift' extension. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, qemu-block@nongnu.org, nbd-general@lists.sourceforge.net Cc: alex@alex.org.uk, eblake@redhat.com, kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, w@uter.beEric Blake On 09/26/2016 03:46 PM, Vladimir Sementsov-Ogievskiy wrote: > This extension allows big requests for TRIM and WRITE_ZEROES through > special 'shift' parameter, which means that offset and length should be > shifted left by several bits. > > This is needed for efficient clearing large regions of the disk (up to > the whole disk). > > Signed-off-by: Vladimir Sementsov-Ogievskiy > --- > > Here mentioned WRITE_ZEROES command which is only an experemental > extension for now. > > To dicuss: > NBD_OPT_SHIFT Data. It can be reduced to 8 bits actually... Are some > reserved bits needed here? > > doc/proto.md | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/doc/proto.md b/doc/proto.md > index 2de3a6a..6fd1b16 100644 > --- a/doc/proto.md > +++ b/doc/proto.md > @@ -682,6 +682,8 @@ The field has the following format: > experimental `WRITE_ZEROES` [extension](https://github.com/yoe/nbd/blob/extension-write-zeroes/doc/proto.md). > - bit 7, `NBD_FLAG_SEND_DF`: defined by the experimental `STRUCTURED_REPLY` > [extension](https://github.com/yoe/nbd/blob/extension-structured-reply/doc/proto.md). > +- bit 8, `NBD_FLAG_SEND_SHIFT` : exposes support for `NBD_CMD_FLAG_SHIFT` and > + `NBD_OPT_SHIFT` > > Clients SHOULD ignore unknown flags. > > @@ -765,6 +767,15 @@ of the newstyle negotiation. > > Defined by the experimental `INFO` [extension](https://github.com/yoe/nbd/blob/extension-info/doc/proto.md). > > +- `NBD_OPT_SHIFT` (10) > + > + Defines shift used to calculate request offset and length if > + `NBD_CMD_FLAG_SHIFT` is set. > + > + Data: > + > + - 32 bits, shift (unsigned); Must not be larger than 32. > + > #### Option reply types > > These values are used in the "reply type" field, sent by the server > @@ -872,7 +883,13 @@ valid may depend on negotiation during the handshake phase. > [extension](https://github.com/yoe/nbd/blob/extension-write-zeroes/doc/proto.md). > - bit 2, `NBD_CMD_FLAG_DF`; defined by the experimental `STRUCTURED_REPLY` > [extension](https://github.com/yoe/nbd/blob/extension-structured-reply/doc/proto.md). > - > +- bit 3, `NBD_CMD_FLAG_SHIFT`; This flag is valid for `NBD_CMD_TRIM` and > + `NBD_CMD_WRITE_ZEROES`. If this flag is set the server shifts request > + *length* and *offset* left by N bits, where N is defined by `NBD_OPT_SHIFT` > + option or is assumed to be 16 bits by default if `NBD_OPT_SHIFT` option is > + not specified. If after shift `(offset + length)` exceeds disk size, length > + should be reduced to `( - offset)`. However, `(offset + length)` > + must not exceed disk size by more than `(1 << N) - 1`. > > #### Request types > We could go in a different direction and export flag 'has_zero_init' which will report that the storage is initialized with all zeroes at the moment. In this case mirroring code will not fall into this branch. Den