qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@virtuozzo.com>
To: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com,
	vsementsov@yandex-team.ru
Subject: Re: [PATCH] block: allocate aligned write buffer for 'truncate -m full'
Date: Mon, 11 Dec 2023 12:27:27 +0100	[thread overview]
Message-ID: <c197c97a-e296-45fb-ad8b-5ca5dff81ca8@virtuozzo.com> (raw)
In-Reply-To: <20231211105559.316897-1-andrey.drobyshev@virtuozzo.com>

On 12/11/23 11:55, Andrey Drobyshev wrote:
> In case we're truncating an image opened with O_DIRECT, we might get
> -EINVAL on write with unaligned buffer.  In particular, when running
> iotests/298 with '-nocache' we get:
>
> qemu-io: Failed to resize underlying file: Could not write zeros for
> preallocation: Invalid argument
>
> Let's just allocate the buffer using qemu_blockalign0() instead.
>
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> ---
>   block/file-posix.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index b862406c71..cee8de510b 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -2354,7 +2354,7 @@ static int handle_aiocb_truncate(void *opaque)
>               goto out;
>           }
>   
> -        buf = g_malloc0(65536);
> +        buf = qemu_blockalign0(aiocb->bs, 65536);
>   
>           seek_result = lseek(fd, current_length, SEEK_SET);
>           if (seek_result < 0) {
> @@ -2413,7 +2413,7 @@ out:
>           }
>       }
>   
> -    g_free(buf);
> +    qemu_vfree(buf);
>       return result;
>   }
>   
Reviewed-by: Denis V. Lunev <den@openvz.org>


  reply	other threads:[~2023-12-11 11:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 10:55 [PATCH] block: allocate aligned write buffer for 'truncate -m full' Andrey Drobyshev
2023-12-11 11:27 ` Denis V. Lunev [this message]
2024-01-11 12:53   ` Andrey Drobyshev
2024-01-25 16:37     ` Andrey Drobyshev
2024-01-25 16:46 ` Vladimir Sementsov-Ogievskiy
2024-02-08 18:32   ` Andrey Drobyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c197c97a-e296-45fb-ad8b-5ca5dff81ca8@virtuozzo.com \
    --to=den@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).