The fallback cascade Pádraig mentions is already implemented in qemu-2.1.0, in function raw_co_get_block_status. Just swap
ret = try_fiemap( ... )
and
ret = try_seek_hole( ... )
to reverse the order. I can confirm that it works just fine on 3.13 kernel (all version since 3.1, according to lseek(2)), while older versions will fall back to fiemap, which needs to be protected with FIEMAP_FLAG_SYNC in try_fiemap, to be safe.
This should work under all conditions, and avoid redundant syncs where possible, right?
The fallback cascade Pádraig mentions is already implemented in qemu-2.1.0, in function raw_co_ get_block_ status. Just swap
ret = try_fiemap( ... )
and
ret = try_seek_hole( ... )
to reverse the order. I can confirm that it works just fine on 3.13 kernel (all version since 3.1, according to lseek(2)), while older versions will fall back to fiemap, which needs to be protected with FIEMAP_FLAG_SYNC in try_fiemap, to be safe.
This should work under all conditions, and avoid redundant syncs where possible, right?