qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Chunyan Liu <cyliu@suse.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qemu-img: set nocow flag to new file
Date: Fri, 15 Nov 2013 13:26:40 +0100	[thread overview]
Message-ID: <20131115122640.GB3092@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <CAERYnobd4vthoq_dHmiEW80LrT5JHK+xpAJw2G7Vq+jrVJc-hQ@mail.gmail.com>

Am 15.11.2013 um 05:05 hat Chunyan Liu geschrieben:
> 
> 
> 
> 2013/11/14 Kevin Wolf <kwolf@redhat.com>
> 
>     Am 14.11.2013 um 09:15 hat Chunyan Liu geschrieben:
>     > 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 <cyliu@suse.com>
>     > ---
>     >  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
> 
>     ioctl() returning an error is ignored. This is probably okay because
>     we're only talking about an optimisation here. Perhaps worth a word or
>     two in the comment.
> 
>     However, while this ioctl is setting FS_NOCOW_FL, it is at the same time
>     clearing all other flags. This doesn't look right.
> 
>  
> Yes, strictly it should be GETFLAGS and then SETFLAGS. Here because it does
> FS_IOC_SETFLAGS right after creating the file, and checking the qemu_open()
> parameter, in fact no FLAGS has been set, so just setting FS_NOCOW_FL directly.
> I can revise that if it's not good.

Is there a guarantee that even just creating the file doesn't set any
flags? For example, while reading up on this, I saw that there's a
nodatacow mount option, which means exactly that FS_NOCOW_FL gets set
for new files. If any similar mechanism existed for other flags (or was
to be introduced in future kernel versions), we would break it here.

So, I'd prefer to play it safe and use GETFLAGS first.

Kevin

  reply	other threads:[~2013-11-15 12:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14  8:15 [Qemu-devel] [PATCH] qemu-img: set nocow flag to new file Chunyan Liu
2013-11-14  9:17 ` Kevin Wolf
2013-11-14 14:23   ` Alex Bligh
2013-11-14 14:28     ` Alex Bligh
2013-11-15  4:05   ` Chunyan Liu
2013-11-15 12:26     ` Kevin Wolf [this message]
2013-11-14  9:44 ` Alex Bennée
2013-11-14 10:14   ` Kevin Wolf
2013-11-15  9:38 ` Stefan Hajnoczi
2013-11-18  4:54   ` Chunyan Liu
2013-11-18  9:57     ` Stefan Hajnoczi
2013-12-10 22:23       ` Alex Bennée
2013-12-11  8:29         ` Stefan Hajnoczi
2013-12-18 14:24           ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131115122640.GB3092@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=cyliu@suse.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).