From patchwork Tue Jan 26 13:49:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 43700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 40612B7D1C for ; Wed, 27 Jan 2010 01:22:35 +1100 (EST) Received: from localhost ([127.0.0.1]:48132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZmIY-0002kS-5p for incoming@patchwork.ozlabs.org; Tue, 26 Jan 2010 09:21:42 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZlnA-0005He-7N for qemu-devel@nongnu.org; Tue, 26 Jan 2010 08:49:16 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZln5-0005Bt-HM for qemu-devel@nongnu.org; Tue, 26 Jan 2010 08:49:15 -0500 Received: from [199.232.76.173] (port=46088 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZln5-0005Bc-9k for qemu-devel@nongnu.org; Tue, 26 Jan 2010 08:49:11 -0500 Received: from verein.lst.de ([213.95.11.210]:51487) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1NZln4-0004Bd-I0 for qemu-devel@nongnu.org; Tue, 26 Jan 2010 08:49:10 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o0QDn8WY001926 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 26 Jan 2010 14:49:08 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o0QDn8Nw001925 for qemu-devel@nongnu.org; Tue, 26 Jan 2010 14:49:08 +0100 Date: Tue, 26 Jan 2010 14:49:08 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100126134908.GA1883@lst.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam-Score: -0.001 () BAYES_44 X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH v2] block: avoid creating too large iovecs in multiwrite_merge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If we go over the maximum number of iovecs support by syscall we get back EINVAL from the kernel which translate to I/O errors for the guest. Add a MAX_IOV defintion for platforms that don't have it. For now we use the same 1024 define that's used on Linux and various other platforms, but until the windows block backend implements some kind of vectored I/O it doesn't matter. Signed-off-by: Christoph Hellwig Index: qemu/block.c =================================================================== --- qemu.orig/block.c 2010-01-26 10:59:39.757004445 +0100 +++ qemu/block.c 2010-01-26 11:01:38.056023231 +0100 @@ -1689,6 +1689,10 @@ static int multiwrite_merge(BlockDriverS merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]); } + if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) { + merge = 0; + } + if (merge) { size_t size; QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov)); Index: qemu/qemu-common.h =================================================================== --- qemu.orig/qemu-common.h 2010-01-26 14:41:40.894254285 +0100 +++ qemu/qemu-common.h 2010-01-26 14:42:27.267275698 +0100 @@ -54,6 +54,10 @@ struct iovec { void *iov_base; size_t iov_len; }; +/* + * Use the same value as Linux for now. + */ +#define IOV_MAX 1024 #else #include #endif