[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH nbdkit 5/6] cow: Implement efficient trimming support.



On 1/26/21 3:51 PM, Richard W.M. Jones wrote:
> By storing an extra bit in the overlay bitmap we can mark when whole
> blocks have been trimmed.  This allows us to match a feature of qcow2
> (zero clusters).
> 
> In theory we could punch holes in the overlay to save a bit of disk
> space.
> ---
>  filters/cow/blk.h |   4 ++
>  filters/cow/blk.c | 106 +++++++++++++++++++++++++++++++---------------
>  filters/cow/cow.c |  75 +++++++++++++++++++++++++++++++-
>  3 files changed, 149 insertions(+), 36 deletions(-)

> +++ b/filters/cow/cow.c
> @@ -150,7 +150,7 @@ cow_can_write (struct nbdkit_next_ops *next_ops, void *nxdata, void *handle)

> +/* Trim data. */
> +static int
> +cow_trim (struct nbdkit_next_ops *next_ops, void *nxdata,
> +          void *handle, uint32_t count, uint64_t offset, uint32_t flags,
> +          int *err)
> +{
> +  CLEANUP_FREE uint8_t *block = NULL;
> +  uint64_t blknum, blkoffs;
> +  int r;
> +
> +  if (!IS_ALIGNED (count | offset, BLKSIZE)) {
> +    block = malloc (BLKSIZE);
> +    if (block == NULL) {
> +      *err = errno;
> +      nbdkit_error ("malloc: %m");
> +      return -1;
> +    }
> +  }

Technically, we could leave the unallocated portions unchanged rather
than forcing it to read as zero.  Maybe it's worth a command-line option
- some users want security (no stale data can leak) while others want
speed (no time wasted on read-modify-write).

Overall, the series looks good (and yes, I know you pushed before my
review, which turned out fine).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]