[Top][All Lists]

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

Re: [Qemu-devel] [PATCH for-3.0] file-posix: Fix write_zeroes with unmap

From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH for-3.0] file-posix: Fix write_zeroes with unmap on block devices
Date: Thu, 26 Jul 2018 13:00:00 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 07/26/2018 12:34 PM, Nir Soffer wrote:

Anyway this looks the same level of documentation as FALLOC_FL_ZERO_RANGE,
so if we are ok with using it, FALLOC_FL_PUNCH_HOLE is fine.

Does this change mean that oVirt can start to enable discard for VM when
disks are using wipe-after-delete?

Currently we disable discard if a disk is marked for wiping, since discard
does not
guarantee that discarded ranges are zeroed.

Discard does not ever guarantee anything (it is ALWAYS advisory, and thus may be ignored at any point in the stack). If you NEED to guarantee that something reads as zeros, you have to either explicitly write zeroes, or do a combination of discard first and write zeroes second (and hopefully, the combination of discard+write zeroes is sufficiently optimized in the case where you were lucky that discard does result in a reads-as-zeroes to not do any extra work on the write zeroes call).

Oddly enough, write zeroes first and discard second is NOT guaranteed to read zeroes; the most obvious case would be if discard across an encrypted volume has some bulk-erase mechanism that writes all 0s to the hardware but decrypting all 0s now sees garbage, which is different from writing 0s which gets encrypted to something not all 0s on hardware (that said, such a scenario might still be considered reasonably clean for a wipe-after-delete disk - although with discard being advisory, it's hard to make guarantees).

The current kernel implementation that Kevin posted makes it look like for block devices, you now get:

FL_PUNCH_HOLE: guarantee that you read zeroes, using the fastest means possible (possibly by discarding - but only when discard reads as zeroes)

FL_PUNCH_HOLE | FL_NO_HIDE_STALE: deallocate, what you read is no longer guaranteed (a true discard, regardless of whether discard reads as zeroes)

FL_ZERO_RANGE: guarantee that you read zeroes, without using discard

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

reply via email to

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