[Libguestfs] virt-sparsify and iSCSI

Richard W.M. Jones rjones at redhat.com
Mon Jan 29 13:13:09 UTC 2018


On Mon, Jan 29, 2018 at 03:04:39AM +0200, Shmuel Melamud wrote:
> Hi!
> 
> This question emerged during testing of oVirt sparsify integration.
> oVirt now is able to run virt-sparsify on VM disks. But virt-sparsify
> seems to have no effect on iSCSI disks.
> 
> Does virt-sparsify work on iSCSI disks? Maybe in sum situation, with
> some configuration of iSCSI server, with some specific virt-sparsify
> options?

Note there are two quite different virt-sparsify modes.  I'm going to
assume here you're talking about ‘virt-sparsify --in-place’.

In-place works by doing either fstrim (or in some cases blkdiscard) on
all the filesystems in the disk image.  There are a couple of things
to say about this: (a) There's a very complex interaction between the
libguestfs appliance kernel, qemu, the host kernel and the actual
backing store to make this work.  And (b) fstrim/blkdiscard is a
voluntary hint, which any layer in the storage system may ignore
without even a warning.

So it's entirely possible this will work for some storage systems and
then silently stop working because some element in the stack changes.

In this case let's assume it's iSCSI which is at fault.  I believe
qemu will see a /dev/sdX device and will issue ‘ioctl (fd, BLKDISCARD...)’:

https://git.qemu.org/?p=qemu.git;a=blob;f=block/file-posix.c;h=36ee89e9402277360821baf679d3c82da9724917;hb=6233b4a8c2a32ef6955a921246fa08705bbb3676#l1434

You can probably strace qemu to see if it's doing this.

As you can see from the rest of the file-posix.c file there are a lot
of different cases depending on what the kernel and storage system
report.

Also it depends on various SCSI flags reported by the device.  These
are contained in the SCSI "VPD" data.  It might be interesting to run
sg_inq and sg_vpd (from sg3_utils) on the device:

$ sudo sg_inq -p 0xb0 /dev/sda
$ sudo sg_vpd -p 0xb2 /dev/sda

The LBPRZ & various unmap settings are all relevant.

See also:

https://rwmj.wordpress.com/2014/03/11/blkdiscard-blkzeroout-blkdiscardzeroes-blksecdiscard/

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list