From patchwork Tue Jan 26 08:31:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Schour X-Patchwork-Id: 43684 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 AA428B6F08 for ; Tue, 26 Jan 2010 19:56:19 +1100 (EST) Received: from localhost ([127.0.0.1]:41109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZh58-0000qA-LI for incoming@patchwork.ozlabs.org; Tue, 26 Jan 2010 03:47:30 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZgrJ-0003Jx-R8 for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZgrE-0003HC-8t for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:12 -0500 Received: from [199.232.76.173] (port=50316 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZgrA-0003GR-NX for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:05 -0500 Received: from mx20.gnu.org ([199.232.41.8]:43115) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NZgr9-0008JX-QP for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:04 -0500 Received: from mtagate7.uk.ibm.com ([194.196.100.167]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZgr8-0003dP-Bm for qemu-devel@nongnu.org; Tue, 26 Jan 2010 03:33:02 -0500 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate7.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o0Q8Wx08026689 for ; Tue, 26 Jan 2010 08:32:59 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 o0Q8WxbA1232920 for ; Tue, 26 Jan 2010 08:32:59 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 o0Q8Ww1f012276 for ; Tue, 26 Jan 2010 08:32:58 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 o0Q8WvQ4012257; Tue, 26 Jan 2010 08:32:58 GMT From: Liran Schour To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2010 10:31:45 +0200 Message-Id: <1264494709-31848-2-git-send-email-lirans@il.ibm.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1264494709-31848-1-git-send-email-lirans@il.ibm.com> References: <1264494709-31848-1-git-send-email-lirans@il.ibm.com> X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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 v3 1/5] 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. Remove unused constants. Signed-off-by: Liran Schour --- block-migration.c | 61 +++++++++++++++------------------------------------- 1 files changed, 18 insertions(+), 43 deletions(-) diff --git a/block-migration.c b/block-migration.c index 258a88a..93d86d9 100644 --- a/block-migration.c +++ b/block-migration.c @@ -26,9 +26,6 @@ #define BLK_MIG_FLAG_PROGRESS 0x04 #define MAX_IS_ALLOCATED_SEARCH 65536 -#define MAX_BLOCKS_READ 10000 -#define BLOCKS_READ_CHANGE 100 -#define INITIAL_BLOCKS_READ 100 //#define DEBUG_BLK_MIGRATION @@ -72,6 +69,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 +136,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 +173,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 +216,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 +248,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 +257,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 +350,7 @@ 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 +408,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) { + /* finished saving bulk on all devices */ + block_mig_state.bulk_completed = 1; break; } } @@ -446,9 +423,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 know for sure that save bulk is completed */ blk_mig_save_dirty_blocks(mon, f); blk_mig_cleanup(mon);