diff mbox series

[v2,3/7] block-copy: move progress_set_remaining in block_copy_task_end

Message ID 20210518100757.31243-4-eesposit@redhat.com
State New
Headers show
Series block-copy: protect block-copy internal structures | expand

Commit Message

Emanuele Giuseppe Esposito May 18, 2021, 10:07 a.m. UTC
Moving this function in task_end ensures to update the progress
anyways, even if there is an error.

It also helps in next patch, allowing task_end to have only
one critical section.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 block/block-copy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Vladimir Sementsov-Ogievskiy May 20, 2021, 3:03 p.m. UTC | #1
18.05.2021 13:07, Emanuele Giuseppe Esposito wrote:
> Moving this function in task_end ensures to update the progress
> anyways, even if there is an error.
> 
> It also helps in next patch, allowing task_end to have only
> one critical section.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

> ---
>   block/block-copy.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/block/block-copy.c b/block/block-copy.c
> index d2d3839dec..2e610b4142 100644
> --- a/block/block-copy.c
> +++ b/block/block-copy.c
> @@ -264,6 +264,9 @@ static void coroutine_fn block_copy_task_end(BlockCopyTask *task, int ret)
>           bdrv_set_dirty_bitmap(task->s->copy_bitmap, task->offset, task->bytes);
>       }
>       QLIST_REMOVE(task, list);
> +    progress_set_remaining(task->s->progress,
> +                           bdrv_get_dirty_count(task->s->copy_bitmap) +
> +                           task->s->in_flight_bytes);
>       qemu_co_queue_restart_all(&task->wait_queue);
>   }
>   
> @@ -645,9 +648,6 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
>           }
>           if (s->skip_unallocated && !(ret & BDRV_BLOCK_ALLOCATED)) {
>               block_copy_task_end(task, 0);
> -            progress_set_remaining(s->progress,
> -                                   bdrv_get_dirty_count(s->copy_bitmap) +
> -                                   s->in_flight_bytes);
>               trace_block_copy_skip_range(s, task->offset, task->bytes);
>               offset = task_end(task);
>               bytes = end - offset;
>
diff mbox series

Patch

diff --git a/block/block-copy.c b/block/block-copy.c
index d2d3839dec..2e610b4142 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -264,6 +264,9 @@  static void coroutine_fn block_copy_task_end(BlockCopyTask *task, int ret)
         bdrv_set_dirty_bitmap(task->s->copy_bitmap, task->offset, task->bytes);
     }
     QLIST_REMOVE(task, list);
+    progress_set_remaining(task->s->progress,
+                           bdrv_get_dirty_count(task->s->copy_bitmap) +
+                           task->s->in_flight_bytes);
     qemu_co_queue_restart_all(&task->wait_queue);
 }
 
@@ -645,9 +648,6 @@  block_copy_dirty_clusters(BlockCopyCallState *call_state)
         }
         if (s->skip_unallocated && !(ret & BDRV_BLOCK_ALLOCATED)) {
             block_copy_task_end(task, 0);
-            progress_set_remaining(s->progress,
-                                   bdrv_get_dirty_count(s->copy_bitmap) +
-                                   s->in_flight_bytes);
             trace_block_copy_skip_range(s, task->offset, task->bytes);
             offset = task_end(task);
             bytes = end - offset;