From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhFrc-0006m8-JD for qemu-devel@nongnu.org; Fri, 15 Nov 2013 04:39:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhFrX-0000Bq-1J for qemu-devel@nongnu.org; Fri, 15 Nov 2013 04:38:56 -0500 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:43216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhFrW-0000Bh-Qh for qemu-devel@nongnu.org; Fri, 15 Nov 2013 04:38:50 -0500 Received: by mail-wi0-f174.google.com with SMTP id hi5so717283wib.1 for ; Fri, 15 Nov 2013 01:38:50 -0800 (PST) Date: Fri, 15 Nov 2013 10:38:46 +0100 From: Stefan Hajnoczi Message-ID: <20131115093846.GJ12545@stefanha-thinkpad.redhat.com> References: <1384416928-3441-1-git-send-email-cyliu@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1384416928-3441-1-git-send-email-cyliu@suse.com> Subject: Re: [Qemu-devel] [PATCH] qemu-img: set nocow flag to new file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, Nov 14, 2013 at 04:15:28PM +0800, Chunyan Liu wrote: > Set NOCOW flag to newly created images to solve performance issues on btrfs. > > Btrfs has terrible performance when hosting VM images, even more when the guest > in those VM are also using btrfs as file system. One way to mitigate this bad > performance is to turn off COW attributes on VM files (since having copy on > write for this kind of data is not useful). > > Signed-off-by: Chunyan Liu > --- > block/raw-posix.c | 6 ++++++ > block/vdi.c | 7 +++++++ > block/vmdk.c | 7 +++++++ > include/qemu-common.h | 9 +++++++++ > 4 files changed, 29 insertions(+), 0 deletions(-) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index f6d48bb..4a3e9d0 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -1072,6 +1072,12 @@ static int raw_create(const char *filename, QEMUOptionParameter *options, > result = -errno; > error_setg_errno(errp, -result, "Could not create file"); > } else { > +#ifdef __linux__ > + /* set NOCOW flag to solve performance issue on fs like btrfs */ > + int attr; > + attr = FS_NOCOW_FL; > + ioctl(fd, FS_IOC_SETFLAGS, &attr); > +#endif This should be optional and I'm not sure it should be the default. Rationale: If you're on btrfs you probably expect the copy-on-write and snapshot features of the file system. We shouldn't silently disable that unless the user asks for it. Stefan