Patchwork [05/41] block-migration: remove useless calls to blk_mig_cleanup

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 15, 2013, 5:46 p.m.
Message ID <1360950433-17106-6-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/220806/
State New
Headers show

Comments

Paolo Bonzini - Feb. 15, 2013, 5:46 p.m.
Now that the cancel callback is called consistently for all errors,
we can avoid doing its work in the other callbacks.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block-migration.c |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)
Orit Wasserman - Feb. 18, 2013, 9:17 a.m.
On 02/15/2013 07:46 PM, Paolo Bonzini wrote:
> Now that the cancel callback is called consistently for all errors,
> we can avoid doing its work in the other callbacks.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block-migration.c |   26 ++++++++------------------
>  1 files changed, 8 insertions(+), 18 deletions(-)
> 
> diff --git a/block-migration.c b/block-migration.c
> index 43ab202..e6c917d 100644
> --- a/block-migration.c
> +++ b/block-migration.c
> @@ -524,16 +524,10 @@ static int block_save_setup(QEMUFile *f, void *opaque)
>      set_dirty_tracking(1);
>  
>      ret = flush_blks(f);
> -    if (ret) {
> -        blk_mig_cleanup();
> -        return ret;
> -    }
> -
>      blk_mig_reset_dirty_cursor();
> -
>      qemu_put_be64(f, BLK_MIG_FLAG_EOS);
>  
> -    return 0;
> +    return ret;
>  }
>  
>  static int block_save_iterate(QEMUFile *f, void *opaque)
> @@ -546,7 +540,6 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
>  
>      ret = flush_blks(f);
>      if (ret) {
> -        blk_mig_cleanup();
>          return ret;
>      }
>  
> @@ -564,20 +557,18 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
>              }
>          } 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) {
> -        blk_mig_cleanup();
> -        return ret;
> -    }
>  
>      ret = flush_blks(f);
>      if (ret) {
> -        blk_mig_cleanup();
>          return ret;
>      }
>  
> @@ -595,7 +586,6 @@ static int block_save_complete(QEMUFile *f, void *opaque)
>  
>      ret = flush_blks(f);
>      if (ret) {
> -        blk_mig_cleanup();
>          return ret;
>      }
>  
> @@ -607,12 +597,11 @@ static int block_save_complete(QEMUFile *f, void *opaque)
>  
>      do {
>          ret = blk_mig_save_dirty_block(f, 0);
> +        if (ret < 0) {
> +            return ret;
> +        }
>      } while (ret == 0);
>  
> -    blk_mig_cleanup();
> -    if (ret < 0) {
> -        return ret;
> -    }
>      /* report completion */
>      qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS);
>  
> @@ -620,6 +609,7 @@ static int block_save_complete(QEMUFile *f, void *opaque)
>  
>      qemu_put_be64(f, BLK_MIG_FLAG_EOS);
>  
> +    blk_mig_cleanup();
>      return 0;
>  }
>  
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Juan Quintela - Feb. 21, 2013, 5:24 p.m.
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Now that the cancel callback is called consistently for all errors,
> we can avoid doing its work in the other callbacks.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

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

Patch

diff --git a/block-migration.c b/block-migration.c
index 43ab202..e6c917d 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -524,16 +524,10 @@  static int block_save_setup(QEMUFile *f, void *opaque)
     set_dirty_tracking(1);
 
     ret = flush_blks(f);
-    if (ret) {
-        blk_mig_cleanup();
-        return ret;
-    }
-
     blk_mig_reset_dirty_cursor();
-
     qemu_put_be64(f, BLK_MIG_FLAG_EOS);
 
-    return 0;
+    return ret;
 }
 
 static int block_save_iterate(QEMUFile *f, void *opaque)
@@ -546,7 +540,6 @@  static int block_save_iterate(QEMUFile *f, void *opaque)
 
     ret = flush_blks(f);
     if (ret) {
-        blk_mig_cleanup();
         return ret;
     }
 
@@ -564,20 +557,18 @@  static int block_save_iterate(QEMUFile *f, void *opaque)
             }
         } 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) {
-        blk_mig_cleanup();
-        return ret;
-    }
 
     ret = flush_blks(f);
     if (ret) {
-        blk_mig_cleanup();
         return ret;
     }
 
@@ -595,7 +586,6 @@  static int block_save_complete(QEMUFile *f, void *opaque)
 
     ret = flush_blks(f);
     if (ret) {
-        blk_mig_cleanup();
         return ret;
     }
 
@@ -607,12 +597,11 @@  static int block_save_complete(QEMUFile *f, void *opaque)
 
     do {
         ret = blk_mig_save_dirty_block(f, 0);
+        if (ret < 0) {
+            return ret;
+        }
     } while (ret == 0);
 
-    blk_mig_cleanup();
-    if (ret < 0) {
-        return ret;
-    }
     /* report completion */
     qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS);
 
@@ -620,6 +609,7 @@  static int block_save_complete(QEMUFile *f, void *opaque)
 
     qemu_put_be64(f, BLK_MIG_FLAG_EOS);
 
+    blk_mig_cleanup();
     return 0;
 }