[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] virtio-scsi vs. virtio-blk

From: ronnie sahlberg
Subject: Re: [Qemu-devel] virtio-scsi vs. virtio-blk
Date: Fri, 10 Aug 2012 21:12:27 +1000

You want discard to work?

That should not be a problem with iscsi.

You are using qemu 1.0 ?
So you dont have the qemu support for scsi-generic passthrough to iscsi devices.

This should though work without too much trouble

First you need an iscsi target that supports SBC UNMAP command.
STGT  does support this :   http://stgt.sourceforge.net/
This is a userspace software iscsi target that works on most distros of linux.

Support for thin-provisioning in STGT is very very recent :
    commit 9a855ac0026971c2b5c7f7133febfaf9462410dc
    Author: Ronnie Sahlberg <address@hidden>
    Date:   Sun Apr 15 12:07:32 2012 +1000

    SBC: Add support for thin-provisioning and the UNMAP command

    The UNMAP command is implemented using FALLOC_FL_PUNCH_HOLE and
    release UNMAPPED blocks back to the underlying filesystem.

    FALLOC_FL_PUNCH_HOLE is fairly new addition to Linux but works o
    ext4 and XFS filesystems currently.

    Signed-off-by: Ronnie Sahlberg <address@hidden>
    Signed-off-by: FUJITA Tomonori <address@hidden>

That means STGT version 1.0.27 or later.
As this is very recent your distro probably does not have support for this yet,
so you probably want to download, compile and install STGT from the
current git tree.

Thin-provisioning in STGT requires the also very recent addition on
(and also SEEK_HOLE/SEEK_DATA if you want "get_lba_status" support)
Because STGT just calls out to these functions.

I think you need to run the target on linux 3.2 or later kernels using
ext4/xfs filessytem for this to work since I dont think any
other filesystems support it. Never tested XFS myself but google
claims it works.

Once you have STGT running on a 3.2 or later kernel and using a
filesystem that supports discard,  this is the command to tell TGTD to
thin-provisioning support for the LUN :

   tgtadm --lld iscsi --mode logicalunit --op update --tid $TID --lun
1 --params thin_provisioning=1

STGT will show the thin provisioning status like this

        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 105 MB, Block size: 512
            Online: Yes
            Removable media: Yes
            Prevent removal: No
            Readonly: No
            Thin-provisioning: Yes
            Backing store type: rdwr
            Backing store path: /100mb.img
            Backing store flags:

Once you got STGT up and running and setup for thin provisioning that
should be almost all you need.
(Other iscsi targets may also probably support thin-provisioning but I
have no idea on how to set them up)

Once you have set STGT up,  you just need a guest that supports discard.
Any recent linux distro with a kernel 3.2 or later should do.
I often use latest mint when I test.

Just set it up and put a ext4 filesystem on the iscsi lun, and use the
'discard' mount option in the guest.
Use 'ls -ls <path-to-lun>' on the target and see that the file
'shrinks' in size when  you delete files from the ext4 filesystem.

You can also use wireshark, it understands and decodes the unmap UNMAP
that is used to punch holes in the medium.

NOTE: STGT does not yet support/implement the "thresholds" for
thin-provisioning so there is not yet any mechanism to automatically
inform your guest when the unterlying storage is running low on space.
So you do need to track space utilization on the target backing
filesystem youself!
At some stage I will add the thresholds from sbc but it wont
be anytime soon. (patches are likely welcome)

That should be all you need to do to get it running. It is pretty easy.
Ping me if you have any trouble.

ronnie sahlberg

On Fri, Aug 10, 2012 at 8:30 PM, Paolo Bonzini <address@hidden> wrote:
> Il 10/08/2012 12:28, Stefan Priebe - Profihost AG ha scritto:
>> I'm using iscsi. So no raw or qcow2.
> Ok, then you need to use scsi-block as your device instead of scsi-disk
> or scsi-hd.  This will disable the QEMU SCSI emulation and let your VM
> talk directly to the NAS.
> CCing Ronnie who may be interested in bug reports since I'm on holiday
> starting "soon".
> Paolo
>> Thanks,
>> Stefan
>> Am 10.08.2012 12:20, schrieb Paolo Bonzini:
>>> Il 10/08/2012 11:22, Stefan Priebe - Profihost AG ha scritto:
>>>> virtio-scsi is now working fine. Could you please help me to get discard
>>>> / trim running? I can't find any information what is needed to get
>>>> discard / trim working.
>>> You need to add discard_granularity=NNN, where NNN is usually 512 for
>>> raw and the cluster size (65536) for qcow2.
>>> However, discard is supported only for XFS on raw, and on qcow2 it will
>>> not reclaim space---the space will only be reused for future qcow2
>>> allocation.
>>> Better support for discard on raw (other filesystems + block devices),
>>> and more efficient support also on other formats is on my todo list for
>>> the future.  However, an efficient implementation unfortunately requires
>>> changes at all levels including the kernel.
>>> I hope to present something about it at KVM Forum.
>>> Paolo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]