qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V3] qemu-img create: add 'nocow' option


From: Chun Yan Liu
Subject: Re: [Qemu-devel] [PATCH V3] qemu-img create: add 'nocow' option
Date: Sun, 29 Jun 2014 22:50:56 -0600


>>> On 6/27/2014 at 07:48 PM, in message
<address@hidden>, Stefan Hajnoczi
<address@hidden> wrote: 
> On Mon, Jun 23, 2014 at 05:17:02PM +0800, Chunyan Liu wrote: 
> > Add 'nocow' option so that users could have a chance to set NOCOW flag to 
> > newly created files. It's useful on btrfs file system to enhance  
> performance. 
> >  
> > Btrfs has low 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. Generally, there are 
> > two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow, then 
> > all newly created files will be NOCOW. b) per file. Add the NOCOW file 
> > attribute. It could only be done to empty or new files. 
> >  
> > This patch tries the second way, according to the option, it could add  
> NOCOW 
> > per file. 
> >  
> > For most block drivers, since the create file step is in raw-posix.c, so we 
> > can do setting NOCOW flag ioctl in raw-posix.c only. 
> >  
> > But there are some exceptions, like block/vpc.c and block/vdi.c, they are 
> > creating file by calling qemu_open directly. For them, do the same setting 
> > NOCOW flag ioctl work in them separately. 
> >  
> > Signed-off-by: Chunyan Liu <address@hidden> 
> > --- 
> > Changes to v2: 
> >   * based on QemuOpts instead of old QEMUOptionParameters 
> >   * add nocow description in man page and html doc 
> >  
> >   Old v2 is here: 
> >   http://lists.gnu.org/archive/html/qemu-devel/2013-11/msg02429.html 
> >  
> > --- 
> >  block/cow.c               |  5 +++++ 
> >  block/qcow.c              |  5 +++++ 
> >  block/qcow2.c             |  5 +++++ 
> >  block/qed.c               | 11 ++++++++--- 
> >  block/raw-posix.c         | 25 +++++++++++++++++++++++++ 
> >  block/vdi.c               | 29 +++++++++++++++++++++++++++++ 
> >  block/vhdx.c              |  5 +++++ 
> >  block/vmdk.c              | 11 ++++++++--- 
> >  block/vpc.c               | 29 +++++++++++++++++++++++++++++ 
> >  include/block/block_int.h |  1 + 
> >  qemu-doc.texi             | 16 ++++++++++++++++ 
> >  qemu-img.texi             | 16 ++++++++++++++++ 
> >  12 files changed, 152 insertions(+), 6 deletions(-) 
>  
> Are you sure it's necessary to touch all image formats in order to pass 
> through the nocow option?  Looking at bdrv_img_create() I think it will 
> work without touching all image formats since both drv and 
> proto_drv->create_opts are appended: 

Right. For those calling bdrv_create_file to create file, it's not necessary
to add NOCOW option to their .create_opts. Adding NOCOW to raw-posix.c
is enough. There will be no difference to users when they do:
qemu-img create -f fmt name size -o nocow=on
or
qemu-img create -f fmt name size -o ?

>  
> void bdrv_img_create(const char *filename, const char *fmt, 
>                      const char *base_filename, const char *base_fmt, 
>                      char *options, uint64_t img_size, int flags, 
>                      Error **errp, bool quiet) 
> { 
>     QemuOptsList *create_opts = NULL; 
> ... 
>     create_opts = qemu_opts_append(create_opts, drv->create_opts); 
>     create_opts = qemu_opts_append(create_opts, proto_drv->create_opts); 
>  
>     /* Create parameter list with default values */ 
>     opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); 
>     qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size); 
>  
>     /* Parse -o options */ 
>     if (options) { 
>         if (qemu_opts_do_parse(opts, options, NULL) != 0) { 
>             error_setg(errp, "Invalid options for file format '%s'", fmt); 
>             goto out; 
>         } 
>     } 
>  




reply via email to

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