From patchwork Thu Jan 21 15:24:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Schour X-Patchwork-Id: 43437 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 77ED6B7C8E for ; Fri, 22 Jan 2010 02:28:46 +1100 (EST) Received: from localhost ([127.0.0.1]:54376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXyxf-00047r-HO for incoming@patchwork.ozlabs.org; Thu, 21 Jan 2010 10:28:43 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXyuO-0003KI-Iy for qemu-devel@nongnu.org; Thu, 21 Jan 2010 10:25:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXyuK-0003Ik-S6 for qemu-devel@nongnu.org; Thu, 21 Jan 2010 10:25:20 -0500 Received: from [199.232.76.173] (port=54736 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXyuK-0003Ic-MF for qemu-devel@nongnu.org; Thu, 21 Jan 2010 10:25:16 -0500 Received: from mtagate4.uk.ibm.com ([194.196.100.164]:41907) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NXyuK-00013A-7E for qemu-devel@nongnu.org; Thu, 21 Jan 2010 10:25:16 -0500 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o0LFPErR012530 for ; Thu, 21 Jan 2010 15:25:14 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0LFPCKP1585166 for ; Thu, 21 Jan 2010 15:25:14 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o0LFPCQR029987 for ; Thu, 21 Jan 2010 15:25:12 GMT Received: from localhost.localdomain (vandev1.haifa.ibm.com [9.148.8.11]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o0LFPB3F029936; Thu, 21 Jan 2010 15:25:12 GMT From: Liran Schour To: qemu-devel@nongnu.org Date: Thu, 21 Jan 2010 17:24:01 +0200 Message-Id: <1264087444-14193-2-git-send-email-lirans@il.ibm.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1264087444-14193-1-git-send-email-lirans@il.ibm.com> References: <1264087444-14193-1-git-send-email-lirans@il.ibm.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Liran Schour Subject: [Qemu-devel] [PATCH v2 1/4] Remove unused code 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 blk_mig_save_bulked_block is never called with sync flag. Remove the sync flag. Calculate bulk completion during blk_mig_save_bulked_block. Changes from v1: remove trailing whitespaces and minor cleanups. Signed-off-by: Liran Schour --- block-migration.c | 59 +++++++++++++++++----------------------------------- 1 files changed, 19 insertions(+), 40 deletions(-) diff --git a/block-migration.c b/block-migration.c index 258a88a..f9bb42c 100644 --- a/block-migration.c +++ b/block-migration.c @@ -72,6 +72,7 @@ typedef struct BlkMigState { int transferred; int64_t total_sector_sum; int prev_progress; + int bulk_completed; } BlkMigState; static BlkMigState block_mig_state; @@ -138,7 +139,7 @@ static void blk_mig_read_cb(void *opaque, int ret) } static int mig_save_device_bulk(Monitor *mon, QEMUFile *f, - BlkMigDevState *bmds, int is_async) + BlkMigDevState *bmds) { int64_t total_sectors = bmds->total_sectors; int64_t cur_sector = bmds->cur_sector; @@ -175,27 +176,16 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f, blk->bmds = bmds; blk->sector = cur_sector; - if (is_async) { - blk->iov.iov_base = blk->buf; - blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); - - blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov, - nr_sectors, blk_mig_read_cb, blk); - if (!blk->aiocb) { - goto error; - } - block_mig_state.submitted++; - } else { - if (bdrv_read(bs, cur_sector, blk->buf, nr_sectors) < 0) { - goto error; - } - blk_send(f, blk); + blk->iov.iov_base = blk->buf; + blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE; + qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); - qemu_free(blk->buf); - qemu_free(blk); + blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov, + nr_sectors, blk_mig_read_cb, blk); + if (!blk->aiocb) { + goto error; } - + block_mig_state.submitted++; bdrv_reset_dirty(bs, cur_sector, nr_sectors); bmds->cur_sector = cur_sector + nr_sectors; @@ -229,6 +219,7 @@ static void init_blk_migration(Monitor *mon, QEMUFile *f) block_mig_state.transferred = 0; block_mig_state.total_sector_sum = 0; block_mig_state.prev_progress = -1; + block_mig_state.bulk_completed = 0; for (bs = bdrv_first; bs != NULL; bs = bs->next) { if (bs->type == BDRV_TYPE_HD) { @@ -260,7 +251,7 @@ static void init_blk_migration(Monitor *mon, QEMUFile *f) } } -static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f, int is_async) +static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f) { int64_t completed_sector_sum = 0; BlkMigDevState *bmds; @@ -269,7 +260,7 @@ static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f, int is_async) QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { if (bmds->bulk_completed == 0) { - if (mig_save_device_bulk(mon, f, bmds, is_async) == 1) { + if (mig_save_device_bulk(mon, f, bmds) == 1) { /* completed bulk section for this device */ bmds->bulk_completed = 1; } @@ -362,19 +353,8 @@ static void flush_blks(QEMUFile* f) static int is_stage2_completed(void) { - BlkMigDevState *bmds; - - if (block_mig_state.submitted > 0) { - return 0; - } - - QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { - if (bmds->bulk_completed == 0) { - return 0; - } - } - - return 1; + return (block_mig_state.submitted == 0 && + block_mig_state.bulk_completed); } static void blk_mig_cleanup(Monitor *mon) @@ -432,8 +412,9 @@ static int block_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) while ((block_mig_state.submitted + block_mig_state.read_done) * BLOCK_SIZE < qemu_file_get_rate_limit(f)) { - if (blk_mig_save_bulked_block(mon, f, 1) == 0) { - /* no more bulk blocks for now */ + if (blk_mig_save_bulked_block(mon, f) == 0) { + /* finish saving bulk on all devices */ + block_mig_state.bulk_completed = 1; break; } } @@ -446,9 +427,7 @@ static int block_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) } if (stage == 3) { - while (blk_mig_save_bulked_block(mon, f, 0) != 0) { - /* empty */ - } + /* we now for sure that save bulk is completed */ blk_mig_save_dirty_blocks(mon, f); blk_mig_cleanup(mon);