qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] raw-posix: Support discard on more filesystems


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] raw-posix: Support discard on more filesystems
Date: Mon, 7 Jan 2013 14:54:50 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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



reply via email to

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