On Tue, 07/19 21:47, Eric Blake wrote: > > In block/raw-posix.c:handle_aiocb_write_zeroes(): > >> #ifdef CONFIG_FALLOCATE_PUNCH_HOLE > >> if (s->has_discard && s->has_fallocate) { > >> int ret = do_fallocate(s->fd, > >> FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > >> aiocb->aio_offset, aiocb->aio_nbytes); > >> if (ret == 0) { > >> ret = do_fallocate(s->fd, 0, aiocb->aio_offset, > >> aiocb->aio_nbytes); > > That is just implementation: punch a hole, BUT THEN reallocate it back, > so that in the end, the file is still not sparse in that region. Or am > I reading it wrong?
Yes, you are right about this, I was confused because "qemu-img map" does not report this allocation state after zero write. (No idea why SEEK_DATA doesn't hit the fallocate'ed area.) Then, when it comes to qcow2, it's a bit different: after a NO_HOLE write zero doesn't allocate anything, it only sets the bit in cluster table. In other words, NO_HOLE only ensures allocated clusters are not deallocated, but it doesn't ensure the population of previously unallocated area. Is that intended? Fam