On 08/19/2018 11:56 AM, Nir Soffer wrote:
fallocate(FALLOC_FL_ZERO_RANGE) is supported for block devices with
modern kernel, but when it is not, we fall back to manual zeroing.
For block device, try also to use ioctl(BLKZEROOUT) if offset and count
are aligned to block device sector size.
@@ -119,9 +126,12 @@ file_config_complete (void)
/* The per-connection handle. */
struct handle {
int fd;
+ bool is_block_device;
+ int sector_size;
bool can_punch_hole;
bool can_zero_range;
bool can_fallocate;
+ bool can_zeroout;
I generally try to group members by size, to avoid holes that push
struct sizes beyond a cache line size. Thankfully, it looks like this
struct is now 16 bytes on both 32- and 64-bit architectures, whether or
not you sink 'is_block_device' so that all 5 bools are contiguous. If
we were worried about it, we could use ':1' for the bools to make the
struct occupy 12 bytes instead, but I doubt this code is in the hotspot
for it to make a difference. So I'm not changing it.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org