From: Stefan Hajnoczi <stefanha@gmail.com>
To: Teng-Feng Yang <shinrairis@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] TRIM/DISCARD/UNMAP support on qemu-nbd
Date: Mon, 6 Jan 2014 10:45:24 +0800 [thread overview]
Message-ID: <20140106024524.GD9790@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAKTMprM8tuGyppzWHVj0ViPan4nuCz0oveJOCA2dcVLxZ2t7=w@mail.gmail.com>
On Mon, Dec 30, 2013 at 07:58:29PM +0800, Teng-Feng Yang wrote:
> I have been studying QCOW2 file format for a couple of days, and I am
> a little bit confused about whether QCOW2 supports UNMAP or not.
Discard is an area that has seen a lot of development activity over the
past year or two. That means it's still relatively new, you may find
outdated information online, etc.
> As I surf through internet, some mailing list discussion had mentioned
> that qemu-nbd and nbd module both support UNMAP command.
Yes:
* qemu-nbd since QEMU 1.1 supports TRIM
* nbd.ko since Linux 3.7 supports discard
> So I follow the steps below on my machine (Ubuntu 13.10 with linux
> kernel 3.12) to test if qemu-nbd and QCOW2 do support UNMAP.
>
> 1. Create a qcow2 file via qemu-img
> > sudo qemu-img create -f qcow2 -o cluster_size=524288 base.qcow2 1G
>
> 2. Connect this qcow2 file with qemu-nbd
> > sudo qemu-nbd -c /dev/nbd0 base.qcow2 --discard=unmap
>
> 3. Use sg_unmap command to issue UNMAP command to this NBD
> > sudo sg_unmap --lba=0 --num=1 /dev/nbd0
>
> Everytime I get the following error message:
>
> unmap cdb: 42 00 00 00 00 00 00 00 18 00
> unmap: pass through os error: Inappropriate ioctl for device
> UNMAP failed (use '-v' to get more information)
>
> I also try to format this nbd device with EXT4 and mount it, but still
> cannot perform fstrim on the mount point.
NBD isn't a SCSI device so sending UNMAP commands doesn't work. I think
you need to issue ioctl(BLKDISCARD) instead. See blkdiscard(8).
Also, make sure to use qemu.git/master if you want qcow2 discard
support. I didn't check the details but the unmap implementation for
qcow2 has recently been added/modified.
Stefan
prev parent reply other threads:[~2014-01-06 2:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-30 11:58 [Qemu-devel] TRIM/DISCARD/UNMAP support on qemu-nbd Teng-Feng Yang
2014-01-02 16:15 ` Richard W.M. Jones
2014-01-07 14:48 ` Paolo Bonzini
2014-01-07 20:27 ` Richard W.M. Jones
2014-01-07 20:48 ` Paolo Bonzini
2014-01-07 21:22 ` Richard W.M. Jones
2014-01-08 22:11 ` Paolo Bonzini
2014-01-08 22:24 ` Richard W.M. Jones
2014-01-08 22:45 ` Paolo Bonzini
2014-01-08 22:53 ` Richard W.M. Jones
2014-01-09 7:02 ` Paolo Bonzini
2014-01-07 21:27 ` Richard W.M. Jones
2014-01-06 2:45 ` Stefan Hajnoczi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140106024524.GD9790@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=shinrairis@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).