From patchwork Tue Dec 11 10:30:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 205154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 703DF2C0081 for ; Tue, 11 Dec 2012 21:31:18 +1100 (EST) Received: from localhost ([::1]:50456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiN7M-00036A-KE for incoming@patchwork.ozlabs.org; Tue, 11 Dec 2012 05:31:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiN79-000357-2z for qemu-devel@nongnu.org; Tue, 11 Dec 2012 05:31:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiN74-0000EO-Re for qemu-devel@nongnu.org; Tue, 11 Dec 2012 05:31:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiN74-0000EF-Il for qemu-devel@nongnu.org; Tue, 11 Dec 2012 05:30:58 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBAUoe5025716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Dec 2012 05:30:53 -0500 Received: from dhcp-5-188.str.redhat.com (dhcp-200-232.str.redhat.com [10.33.200.232]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBBAUbrg009614 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 11 Dec 2012 05:30:44 -0500 Message-ID: <50C70B4D.1000505@redhat.com> Date: Tue, 11 Dec 2012 11:30:37 +0100 From: Kevin Wolf User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Heinz Graalfs References: <1353488287-47077-1-git-send-email-borntraeger@de.ibm.com> <50AC9B96.9070908@redhat.com> <1354911963.3635.4.camel@br8hfpp0.de.ibm.com> <50C5A37F.9020300@redhat.com> <1355219892.4245.14.camel@br8hfpp0.de.ibm.com> In-Reply-To: <1355219892.4245.14.camel@br8hfpp0.de.ibm.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Christian Borntraeger , jfrei@linux.vnet.ibm.com, qemu-devel@nongnu.org, Stefan Hajnoczi , agraf@suse.de Subject: Re: [Qemu-devel] [PATCH/RFC] block: Ensure that block size constraints are considered X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Am 11.12.2012 10:58, schrieb Heinz Graalfs: > Hi Kevin, > > I'm using the bdrv_pread() function during boot partition detection ... > > In detail: > bdrv_pread() is called to read 32 bytes from a 2048 bytes formatted > disk. This results in setting up a read of 512 bytes (1 sector > multiplied by 512 current code in paio_submit()), which is wrong for a > O_DIRECT opened file, and produces the error. So this sounds like the real problem: bdrv_pread/pwrite assume 512 byte sectors. May it's better to fix it there instead of just fixing one code path in one backend. In any case this patch as submitted is wrong as it overflows the buffer passed to paio_submit. Test it with this patch: return 0; $ ./qemu-io -n -c 'read -p 0 512' /tmp/foo read 512/512 bytes at offset 0 512 bytes, 1 ops; 0.0001 sec (3.727 MiB/sec and 7633.5878 ops/sec) *** glibc detected *** ./qemu-io: double free or corruption (out): 0x00007fa22349b000 *** Kevin --- a/qemu-io.c +++ b/qemu-io.c @@ -1718,6 +1718,8 @@ static int openfile(char *name, int flags, int growable) bs = NULL; return 1; } + + bdrv_set_buffer_alignment(bs, 4096); }