diff mbox series

[v2,01/11] qcow2: make function update_refcount_discard() global

Message ID 20240513063203.113911-2-andrey.drobyshev@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series qcow2: make subclusters discardable | expand

Commit Message

Andrey Drobyshev May 13, 2024, 6:31 a.m. UTC
We are going to need it for discarding separate subclusters.  The
function itself doesn't do anything with the refcount tables, it simply
adds a discard request to the queue, so rename it to qcow2_queue_discard().

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
---
 block/qcow2-refcount.c | 8 ++++----
 block/qcow2.h          | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Alberto Garcia May 15, 2024, 10:26 p.m. UTC | #1
On Mon 13 May 2024 09:31:53 AM +03, Andrey Drobyshev wrote:
> We are going to need it for discarding separate subclusters.  The
> function itself doesn't do anything with the refcount tables, it simply
> adds a discard request to the queue, so rename it to qcow2_queue_discard().
>
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> Reviewed-by: Hanna Czenczek <hreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto
Alexander Ivanov May 21, 2024, 8:31 a.m. UTC | #2
On 5/13/24 08:31, Andrey Drobyshev wrote:
> We are going to need it for discarding separate subclusters.  The
> function itself doesn't do anything with the refcount tables, it simply
> adds a discard request to the queue, so rename it to qcow2_queue_discard().
>
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
> ---
>   block/qcow2-refcount.c | 8 ++++----
>   block/qcow2.h          | 2 ++
>   2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 0266542cee..2026f5fa21 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -754,8 +754,8 @@ void qcow2_process_discards(BlockDriverState *bs, int ret)
>       }
>   }
>   
> -static void update_refcount_discard(BlockDriverState *bs,
> -                                    uint64_t offset, uint64_t length)
> +void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset,
> +                         uint64_t length)
>   {
>       BDRVQcow2State *s = bs->opaque;
>       Qcow2DiscardRegion *d, *p, *next;
> @@ -902,7 +902,7 @@ update_refcount(BlockDriverState *bs, int64_t offset, int64_t length,
>               }
>   
>               if (s->discard_passthrough[type]) {
> -                update_refcount_discard(bs, cluster_offset, s->cluster_size);
> +                qcow2_queue_discard(bs, cluster_offset, s->cluster_size);
>               }
>           }
>       }
> @@ -3619,7 +3619,7 @@ qcow2_discard_refcount_block(BlockDriverState *bs, uint64_t discard_block_offs)
>           /* discard refblock from the cache if refblock is cached */
>           qcow2_cache_discard(s->refcount_block_cache, refblock);
>       }
> -    update_refcount_discard(bs, discard_block_offs, s->cluster_size);
> +    qcow2_queue_discard(bs, discard_block_offs, s->cluster_size);
>   
>       return 0;
>   }
> diff --git a/block/qcow2.h b/block/qcow2.h
> index a9e3481c6e..197bdcdf53 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -891,6 +891,8 @@ int coroutine_fn qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *re
>                                          BdrvCheckMode fix);
>   
>   void GRAPH_RDLOCK qcow2_process_discards(BlockDriverState *bs, int ret);
> +void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset,
> +                         uint64_t length);
>   
>   int GRAPH_RDLOCK
>   qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
Reviewed-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
diff mbox series

Patch

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 0266542cee..2026f5fa21 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -754,8 +754,8 @@  void qcow2_process_discards(BlockDriverState *bs, int ret)
     }
 }
 
-static void update_refcount_discard(BlockDriverState *bs,
-                                    uint64_t offset, uint64_t length)
+void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset,
+                         uint64_t length)
 {
     BDRVQcow2State *s = bs->opaque;
     Qcow2DiscardRegion *d, *p, *next;
@@ -902,7 +902,7 @@  update_refcount(BlockDriverState *bs, int64_t offset, int64_t length,
             }
 
             if (s->discard_passthrough[type]) {
-                update_refcount_discard(bs, cluster_offset, s->cluster_size);
+                qcow2_queue_discard(bs, cluster_offset, s->cluster_size);
             }
         }
     }
@@ -3619,7 +3619,7 @@  qcow2_discard_refcount_block(BlockDriverState *bs, uint64_t discard_block_offs)
         /* discard refblock from the cache if refblock is cached */
         qcow2_cache_discard(s->refcount_block_cache, refblock);
     }
-    update_refcount_discard(bs, discard_block_offs, s->cluster_size);
+    qcow2_queue_discard(bs, discard_block_offs, s->cluster_size);
 
     return 0;
 }
diff --git a/block/qcow2.h b/block/qcow2.h
index a9e3481c6e..197bdcdf53 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -891,6 +891,8 @@  int coroutine_fn qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *re
                                        BdrvCheckMode fix);
 
 void GRAPH_RDLOCK qcow2_process_discards(BlockDriverState *bs, int ret);
+void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset,
+                         uint64_t length);
 
 int GRAPH_RDLOCK
 qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,