From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsDAG-0006Z4-2n for qemu-devel@nongnu.org; Mon, 07 Jan 2013 08:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsDAF-00038Y-0x for qemu-devel@nongnu.org; Mon, 07 Jan 2013 08:54:56 -0500 Received: from mail-bk0-f41.google.com ([209.85.214.41]:61175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsDAE-00038T-Pk for qemu-devel@nongnu.org; Mon, 07 Jan 2013 08:54:54 -0500 Received: by mail-bk0-f41.google.com with SMTP id jg9so8394265bkc.14 for ; Mon, 07 Jan 2013 05:54:53 -0800 (PST) Date: Mon, 7 Jan 2013 14:54:50 +0100 From: Stefan Hajnoczi Message-ID: <20130107135450.GF17997@stefanha-thinkpad.redhat.com> References: <20130105120511.388913E403B@msa101.auone-net.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130105120511.388913E403B@msa101.auone-net.jp> Subject: Re: [Qemu-devel] [PATCH] raw-posix: Support discard on more filesystems List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kusanagi Kouichi Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi 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