From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV2Nv-0003hw-5Z for qemu-devel@nongnu.org; Tue, 01 Apr 2014 13:22:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WV2No-0003Y4-Rt for qemu-devel@nongnu.org; Tue, 01 Apr 2014 13:22:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV2No-0003Xx-JW for qemu-devel@nongnu.org; Tue, 01 Apr 2014 13:21:56 -0400 From: Stefan Hajnoczi Date: Tue, 1 Apr 2014 19:19:29 +0200 Message-Id: <1396372769-11688-52-git-send-email-stefanha@redhat.com> In-Reply-To: <1396372769-11688-1-git-send-email-stefanha@redhat.com> References: <1396372769-11688-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL for-2.0 51/51] qcow2: link all L2 meta updates in preallocate() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi preallocate() only links the first QCowL2Meta's data clusters into the L2 table and ignores any chained QCowL2Metas in the linked list. Chains of QCowL2Meta structs are built up when contiguous clusters span L2 tables. Each QCowL2Meta describes one L2 table update. This is a rare case in preallocate() but can happen. This patch fixes preallocate() by iterating over the whole list of QCowL2Metas. Compare with the qcow2_co_writev() function's implementation, which is similar but also also handles request dependencies. preallocate() only performs one allocation at a time so there can be no dependencies. Signed-off-by: Stefan Hajnoczi --- block/qcow2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index bb6000f..333e26d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1531,7 +1531,9 @@ static int preallocate(BlockDriverState *bs) return ret; } - if (meta != NULL) { + while (meta) { + QCowL2Meta *next = meta->next; + ret = qcow2_alloc_cluster_link_l2(bs, meta); if (ret < 0) { qcow2_free_any_clusters(bs, meta->alloc_offset, @@ -1542,6 +1544,9 @@ static int preallocate(BlockDriverState *bs) /* There are no dependent requests, but we need to remove our * request from the list of in-flight requests */ QLIST_REMOVE(meta, next_in_flight); + + g_free(meta); + meta = next; } /* TODO Preallocate data if requested */ -- 1.9.0