diff mbox

[16/41] block-migration: small preparatory changes for locking

Message ID 1360950433-17106-17-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Feb. 15, 2013, 5:46 p.m. UTC
Some small changes that will simplify the positioning of lock/unlock
primitives
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block-migration.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

Comments

Orit Wasserman Feb. 18, 2013, 1:47 p.m. UTC | #1
On 02/15/2013 07:46 PM, Paolo Bonzini wrote:
> Some small changes that will simplify the positioning of lock/unlock
> primitives
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block-migration.c |   26 +++++++++++++++-----------
>  1 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/block-migration.c b/block-migration.c
> index e72f322..fe3c040 100644
> --- a/block-migration.c
> +++ b/block-migration.c
> @@ -231,9 +231,10 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds)
>      blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
>      qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
>  
> +    block_mig_state.submitted++;
> +
>      blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
>                                  nr_sectors, blk_mig_read_cb, blk);
> -    block_mig_state.submitted++;
>  
>      bdrv_reset_dirty(bs, cur_sector, nr_sectors);
>      bmds->cur_sector = cur_sector + nr_sectors;
> @@ -440,9 +441,10 @@ static int flush_blks(QEMUFile *f)
>              ret = blk->ret;
>              break;
>          }
> -        blk_send(f, blk);
>  
>          QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
> +        blk_send(f, blk);
> +
>          g_free(blk->buf);
>          g_free(blk);
>  
> @@ -542,15 +544,16 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
>                  /* finished saving bulk on all devices */
>                  block_mig_state.bulk_completed = 1;
>              }
> +	    ret = 0;
Looks like white space damage ...
>          } else {
>              ret = blk_mig_save_dirty_block(f, 1);
> -            if (ret < 0) {
> -                return ret;
> -            }
> -            if (ret != 0) {
> -                /* no more dirty blocks */
> -                break;
> -            }
> +        }
> +        if (ret < 0) {
> +            return ret;
> +        }
> +        if (ret != 0) {
> +            /* no more dirty blocks */
> +            break;
>          }
>      }
>  
> @@ -560,7 +563,6 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
>      }
>  
>      qemu_put_be64(f, BLK_MIG_FLAG_EOS);
> -
>      return qemu_ftell(f) - last_ftell;
>  }
>  
> @@ -603,7 +605,9 @@ static int block_save_complete(QEMUFile *f, void *opaque)
>  static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
>  {
>      /* Estimate pending number of bytes to send */
> -    uint64_t pending = get_remaining_dirty() +
> +    uint64_t pending;
> +
> +    pending = get_remaining_dirty() +
>                         block_mig_state.submitted * BLOCK_SIZE +
>                         block_mig_state.read_done * BLOCK_SIZE;
>  
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Paolo Bonzini Feb. 18, 2013, 2:17 p.m. UTC | #2
Il 18/02/2013 14:47, Orit Wasserman ha scritto:
>> > +	    ret = 0;
> Looks like white space damage ...

Hmm, yes, a tab sneaked in.

Paolo
Juan Quintela Feb. 22, 2013, 10:50 a.m. UTC | #3
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Some small changes that will simplify the positioning of lock/unlock
> primitives
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
diff mbox

Patch

diff --git a/block-migration.c b/block-migration.c
index e72f322..fe3c040 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -231,9 +231,10 @@  static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds)
     blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
     qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
 
+    block_mig_state.submitted++;
+
     blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
                                 nr_sectors, blk_mig_read_cb, blk);
-    block_mig_state.submitted++;
 
     bdrv_reset_dirty(bs, cur_sector, nr_sectors);
     bmds->cur_sector = cur_sector + nr_sectors;
@@ -440,9 +441,10 @@  static int flush_blks(QEMUFile *f)
             ret = blk->ret;
             break;
         }
-        blk_send(f, blk);
 
         QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
+        blk_send(f, blk);
+
         g_free(blk->buf);
         g_free(blk);
 
@@ -542,15 +544,16 @@  static int block_save_iterate(QEMUFile *f, void *opaque)
                 /* finished saving bulk on all devices */
                 block_mig_state.bulk_completed = 1;
             }
+	    ret = 0;
         } else {
             ret = blk_mig_save_dirty_block(f, 1);
-            if (ret < 0) {
-                return ret;
-            }
-            if (ret != 0) {
-                /* no more dirty blocks */
-                break;
-            }
+        }
+        if (ret < 0) {
+            return ret;
+        }
+        if (ret != 0) {
+            /* no more dirty blocks */
+            break;
         }
     }
 
@@ -560,7 +563,6 @@  static int block_save_iterate(QEMUFile *f, void *opaque)
     }
 
     qemu_put_be64(f, BLK_MIG_FLAG_EOS);
-
     return qemu_ftell(f) - last_ftell;
 }
 
@@ -603,7 +605,9 @@  static int block_save_complete(QEMUFile *f, void *opaque)
 static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
 {
     /* Estimate pending number of bytes to send */
-    uint64_t pending = get_remaining_dirty() +
+    uint64_t pending;
+
+    pending = get_remaining_dirty() +
                        block_mig_state.submitted * BLOCK_SIZE +
                        block_mig_state.read_done * BLOCK_SIZE;