Received: from eggs.gnu.org ([2001:4830:134:3::10]:38641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1TYc-0004Gt-Hp for qemu-devel@nongnu.org; Mon, 30 Jun 2014 00:51:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1TYY-0002Hh-0A for qemu-devel@nongnu.org; Mon, 30 Jun 2014 00:51:10 -0400 Received: from soto.provo.novell.com ([137.65.250.214]:42678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1TYX-0002Gr-PB for qemu-devel@nongnu.org; Mon, 30 Jun 2014 00:51:05 -0400 Message-Id: <53B15D300200006600040FEC@soto.provo.novell.com> Date: Sun, 29 Jun 2014 22:50:56 -0600 From: "Chun Yan Liu" References: <1403515022-24802-1-git-send-email-cyliu@suse.com> <20140627114806.GM12061@stefanha-thinkpad.muc.redhat.com> In-Reply-To: <20140627114806.GM12061@stefanha-thinkpad.muc.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Qemu-devel] [PATCH V3] qemu-img create: add 'nocow' option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org >>> On 6/27/2014 at 07:48 PM, in message <20140627114806.GM12061@stefanha-thinkpad.muc.redhat.com>, Stefan Hajnoczi wrote:=20 > On Mon, Jun 23, 2014 at 05:17:02PM +0800, Chunyan Liu wrote:=20 > > Add 'nocow' option so that users could have a chance to set NOCOW flag = to=20 > > newly created files. It's useful on btrfs file system to enhance =20 > performance.=20 > > =20 > > Btrfs has low performance when hosting VM images, even more when the = guest=20 > > in those VM are also using btrfs as file system. One way to mitigate = this =20 > bad=20 > > performance is to turn off COW attributes on VM files. Generally, = there are=20 > > two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow, = then=20 > > all newly created files will be NOCOW. b) per file. Add the NOCOW = file=20 > > attribute. It could only be done to empty or new files.=20 > > =20 > > This patch tries the second way, according to the option, it could add = =20 > NOCOW=20 > > per file.=20 > > =20 > > For most block drivers, since the create file step is in raw-posix.c, = so we=20 > > can do setting NOCOW flag ioctl in raw-posix.c only.=20 > > =20 > > But there are some exceptions, like block/vpc.c and block/vdi.c, they = are=20 > > creating file by calling qemu_open directly. For them, do the same = setting=20 > > NOCOW flag ioctl work in them separately.=20 > > =20 > > Signed-off-by: Chunyan Liu =20 > > ---=20 > > Changes to v2:=20 > > * based on QemuOpts instead of old QEMUOptionParameters=20 > > * add nocow description in man page and html doc=20 > > =20 > > Old v2 is here:=20 > > http://lists.gnu.org/archive/html/qemu-devel/2013-11/msg02429.html=20= > > =20 > > ---=20 > > block/cow.c | 5 +++++=20 > > block/qcow.c | 5 +++++=20 > > block/qcow2.c | 5 +++++=20 > > block/qed.c | 11 ++++++++---=20 > > block/raw-posix.c | 25 +++++++++++++++++++++++++=20 > > block/vdi.c | 29 +++++++++++++++++++++++++++++=20 > > block/vhdx.c | 5 +++++=20 > > block/vmdk.c | 11 ++++++++---=20 > > block/vpc.c | 29 +++++++++++++++++++++++++++++=20 > > include/block/block_int.h | 1 +=20 > > qemu-doc.texi | 16 ++++++++++++++++=20 > > qemu-img.texi | 16 ++++++++++++++++=20 > > 12 files changed, 152 insertions(+), 6 deletions(-)=20 > =20 > Are you sure it's necessary to touch all image formats in order to = pass=20 > through the nocow option? Looking at bdrv_img_create() I think it = will=20 > work without touching all image formats since both drv and=20 > proto_drv->create_opts are appended:=20 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=3Don or qemu-img create -f fmt name size -o ? > =20 > void bdrv_img_create(const char *filename, const char *fmt,=20 > const char *base_filename, const char *base_fmt,=20 > char *options, uint64_t img_size, int flags,=20 > Error **errp, bool quiet)=20 > {=20 > QemuOptsList *create_opts =3D NULL;=20 > ...=20 > create_opts =3D qemu_opts_append(create_opts, drv->create_opts);=20 > create_opts =3D qemu_opts_append(create_opts, proto_drv->create_opts)= ;=20 > =20 > /* Create parameter list with default values */=20 > opts =3D qemu_opts_create(create_opts, NULL, 0, &error_abort);=20 > qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size);=20 > =20 > /* Parse -o options */=20 > if (options) {=20 > if (qemu_opts_do_parse(opts, options, NULL) !=3D 0) {=20 > error_setg(errp, "Invalid options for file format '%s'", = fmt);=20 > goto out;=20 > }=20 > }=20 > =20