On Sat, Jan 05, 2013 at 09:05:10PM +0900, Kusanagi Kouichi wrote: > @@ -1098,15 +1101,30 @@ static int xfs_discard(BDRVRawState *s, int64_t > sector_num, int nb_sectors) > static coroutine_fn int raw_co_discard(BlockDriverState *bs, > int64_t sector_num, int nb_sectors) > { > -#ifdef CONFIG_XFS > +#if defined(CONFIG_FALLOCATE_PUNCH_HOLE) || defined(CONFIG_XFS) > BDRVRawState *s = bs->opaque; > +#endif > + int ret = 0; > > +#ifdef CONFIG_FALLOCATE_PUNCH_HOLE > + do { > + if (fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > + sector_num << BDRV_SECTOR_BITS, > + nb_sectors << BDRV_SECTOR_BITS) == 0) { > + return 0; > + } > + } while (errno == EINTR);
Is fallocate(fd, FALLOC_FL_PUNCH_HOLE) a blocking operation? If yes, we need to perform this call in an aio worker thread (see read/write/flush/ioctl in block/raw-posix.c). Failure to do this means QEMU and the guest will be blocked during fallocate and this causes poor performance. Stefan