[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug 1884831] [NEW] qemu-nbd fails to discard bigger chunks
From: |
Eric Blake |
Subject: |
Re: [Bug 1884831] [NEW] qemu-nbd fails to discard bigger chunks |
Date: |
Tue, 23 Jun 2020 15:38:49 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 6/23/20 3:19 PM, TobiasHunger wrote:
Public bug reported:
This report is moved from systemd to here:
https://github.com/systemd/systemd/issues/16242
A qemu-nbd device reports that it can discard a lot of bytes:
cat /sys/block/nbd0/queue/discard_max_bytes
2199023255040
That smells fishy. It is 0xffffffff * 512. But in reality, the NBD
protocol is (currently) capped at 32 bits, so it cannot handle any
request 4G or larger.
It is not qemu-nbd that populates
/sys/block/nbd0/queue/discard_max_bytes, but the kernel. Are you sure
this is not a bug in the kernel's nbd.ko module, where it may be the
case that it is reporting -1 as a 32-bit value which then gets
mistakenly turned into a faulty advertisement? Can you tweak your
software to behave as if /dev/nbd0 had a discard_max_bytes of 0xfffff000
instead?
In fact, to prove the bug is in the kernel's nbd.ko and not in qemu-nbd,
I created an NBD server using nbdkit:
# modprobe nbd
# nbdkit memory 5G
# nbd-client -b 512 localhost /dev/nbd0
# cat /sys/block/nbd0/queue/discard_max_bytes
2199023255040
Same answer, different nbd server. So it's not qemu's fault.
And indeed, discard works with small images:
$ qemu-img create -f qcow2 /tmp/image.img 2M
$ sudo qemu-nbd --connect=/dev/nbd0 /tmp/image.img
$ sudo blkdiscard /dev/nbd0
but not for bigger ones (still smaller than discard_max_bytes):
$ qemu-img create -f qcow2 /tmp/image.img 5G
$ sudo qemu-nbd --connect=/dev/nbd0 /tmp/image.img
$ sudo blkdiscard /dev/nbd0
** Affects: qemu
Importance: Undecided
Status: New
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org