On Fri, Apr 08, 2022 at 08:45:56PM +0300, Nir Soffer wrote:
On Fri, Apr 8, 2022 at 6:47 PM Eric Blake <eblake(a)redhat.com>
wrote:
>
> On Fri, Apr 08, 2022 at 04:48:59PM +0300, Nir Soffer wrote:
...
> > > BTW attached is an nbdkit plugin that creates an NBD server that
> > > responds with massive numbers of byte-granularity extents, in case
> > > anyone wants to test how nbdkit and/or clients respond:
> > >
> > > $ chmod +x /var/tmp/lots-of-extents.py
> > > $ /var/tmp/lots-of-extents.py -f
> > >
> > > $ nbdinfo --map nbd://localhost | head
> > > 0 1 3 hole,zero
> > > 1 1 0 data
> > > 2 1 3 hole,zero
> > > 3 1 0 data
> > > 4 1 3 hole,zero
> > > 5 1 0 data
> > > 6 1 3 hole,zero
> > > 7 1 0 data
> > > 8 1 3 hole,zero
> > > 9 1 0 data
> > > $ nbdinfo --map --totals nbd://localhost
> > > 524288 50.0% 0 data
> > > 524288 50.0% 3 hole,zero
> >
> > This is a malicious server. A good client will drop the connection when
> > receiving the first 1 byte chunk.
>
> Depends on the server. Most servers don't serve 1-byte extents, and
> the NBD spec even recommends that extents be at least 512 bytes in
> size, and requires that extents be a multiple of any minimum block
> size if one was advertised by the server.
>
> But even though most servers don't have 1-byte extents does not mean
> that the NBD protocol must forbid them.
Forbidding this simplifies clients without limiting real world use cases.
I'm not even sure this is true. Clients are quite free to only make
requests on 512 byte block boundaries if they want, and refuse to deal
with servers which offer non-aligned disk sizes or extents.
If clients are doing this and still have problems they ought to be
fixed, although I don't know what those would be.
What is a reason to allow this?
Because you don't always want to serve things which are exactly disk
images, or which make assumptions related to modern PCs (256 byte
sectors were used into the 90s).
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html