From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR5ve-0001qL-Jy for qemu-devel@nongnu.org; Fri, 21 Mar 2014 16:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WR5vX-0004c2-4f for qemu-devel@nongnu.org; Fri, 21 Mar 2014 16:20:34 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:36430 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR5vW-0004bn-J2 for qemu-devel@nongnu.org; Fri, 21 Mar 2014 16:20:26 -0400 Message-ID: <532C9EFB.9040206@kamp.de> Date: Fri, 21 Mar 2014 21:20:11 +0100 From: Peter Lieven MIME-Version: 1.0 References: <1395412589-30601-1-git-send-email-pl@kamp.de> <532C51BA.5030808@redhat.com> In-Reply-To: <532C51BA.5030808@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCHv2] block: optimize zero writes with bdrv_write_zeroes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, famz@redhat.com, stefanha@redhat.com, mreitz@redhat.com Am 21.03.2014 15:50, schrieb Eric Blake: > On 03/21/2014 08:36 AM, Peter Lieven wrote: >> this patch tries to optimize zero write requests >> by automatically using bdrv_write_zeroes if it is >> supported by the format. >> >> this should significantly speed up file system initialization and >> should speed zero write test used to test backend storage performance. >> >> the difference can simply be tested by e.g. >> >> dd if=/dev/zero of=/dev/vdX bs=1M >> >> Signed-off-by: Peter Lieven >> --- >> v1->v2: - add detect-zeroes=off|on|unmap knob to drive cmdline parameter >> - call zero detection only for format (bs->file != NULL) >> >> +static int bdrv_set_detect_zeroes(BlockDriverState *bs, >> + const char *detect_zeroes, >> + Error **errp) >> +{ >> + if (!detect_zeroes || !strncmp(detect_zeroes, "off", 3)) { >> + bs->detect_zeroes = BDRV_DETECT_ZEROES_OFF; > This parses "offer" > >> + } else if (!strncmp(detect_zeroes, "on", 2)) { >> + bs->detect_zeroes = BDRV_DETECT_ZEROES_ON; > and this parses "onto". > >> + } else if (!strncmp(detect_zeroes, "unmap", 5)) { >> + bs->detect_zeroes = BDRV_DETECT_ZEROES_UNMAP; > In all three cases, shouldn't you be using strcmp() instead of strncmp()? yes, you are right. Thanks, Peter > >> + } else { >> + error_setg(errp, "invalid value for detect-zeroes: %s", >> + detect_zeroes); > Especially since you warn about other unknown spellings, it feels weird > to not warn about the spellings where the prefix matches but the overall > spelling is unknown. >> file sectors into the image file. >> +@item detect-zeroes=@var{detect-zeroes} >> +@var{detect-zeroes} is "off", "on" or "unmap" and enables the automatic >> +conversion of plain zero writes by the OS to driver specific optimized >> +zero write commands. If "unmap" is choosen and @var{discard} is "on" > s/choosen/chosen/ >