qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qemu-img: set nocow flag to new file


From: Chunyan Liu
Subject: Re: [Qemu-devel] [PATCH] qemu-img: set nocow flag to new file
Date: Mon, 18 Nov 2013 12:54:59 +0800




2013/11/15 Stefan Hajnoczi <address@hidden>
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 <address@hidden>
> ---
>  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.


The problem is: if users want to use copy-on-write (e.g, for snapshotting) and
don't care about performance degrade, they still be able to issue "chattr" to
change it to be COW. However, if a file is created as COW, but later users care 
about performance, there is no way to switch to NOCOW per file. NOCOW should be 
set to new or empty file only on btrfs.

Chunyan

Stefan



reply via email to

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