[sheepdog] [Qemu-devel] [PATCH 6/7] sheepdog: Pass old and new size to sd_prealloc()

Eric Blake eblake at redhat.com
Tue Feb 13 16:04:12 CET 2018


On 02/13/2018 07:03 AM, Max Reitz wrote:
> sd_prealloc() will now preallocate the area [old_size, new_size).  As
> before, it rounds to buf_size and may thus overshoot and preallocate
> areas that were not requested to be preallocated.  For image creation,
> this is no change in behavior.  For truncation, this is in accordance
> with the documentation for preallocated truncation.
> 
> Signed-off-by: Max Reitz <mreitz at redhat.com>
> ---
>   block/sheepdog.c | 16 +++++-----------
>   1 file changed, 5 insertions(+), 11 deletions(-)
> 

> @@ -1847,19 +1847,13 @@ static int sd_prealloc(BlockDriverState *bs, Error **errp)
>   
>       blk_set_allow_write_beyond_eof(blk, true);
>   
> -    vdi_size = blk_getlength(blk);
> -    if (vdi_size < 0) {
> -        ret = vdi_size;
> -        goto out;
> -    }
> -

> @@ -2119,7 +2113,7 @@ static int sd_create(const char *filename, QemuOpts *opts,
>               goto out;
>           }
>   
> -        ret = sd_prealloc(bs, errp);
> +        ret = sd_prealloc(bs, 0, s->inode.vdi_size, errp);

Nice - you also got rid of a potential failure in blk_getlength().

Reviewed-by: Eric Blake <eblake at redhat.com>

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


More information about the sheepdog mailing list