All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] Is the use of bdrv_getlength() in handle_aiocb_write_zeroes() kosher?
Date: Fri, 04 Aug 2017 16:20:10 +0200	[thread overview]
Message-ID: <87y3qzbejp.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <5f5a45ed-26c8-e96d-f39f-39e7a289ec91@openvz.org> (Denis V. Lunev's message of "Fri, 4 Aug 2017 16:08:09 +0300")

"Denis V. Lunev" <den@openvz.org> writes:

> On 08/04/2017 03:16 PM, Markus Armbruster wrote:
>> Denis, you added this in commit d50d822:
>>
>> #ifdef CONFIG_FALLOCATE
>>     if (s->has_fallocate && aiocb->aio_offset >= bdrv_getlength(aiocb->bs)) {
>>         int ret = do_fallocate(s->fd, 0, aiocb->aio_offset, aiocb->aio_nbytes);
>>         if (ret == 0 || ret != -ENOTSUP) {
>>             return ret;
>>         }
>>         s->has_fallocate = false;
>>     }
>> #endif
>>
>> bdrv_getlength() can fail.  Does it do the right thing then?  For what
>> it's worth, the comparison of its value is signed.
> fallocate() with 0 flags can work only beyond end of file
> or on top of the hole. Thus the check is made to validate
> that we are beyond EOF.
>
> Technically fallocate should fail if that condition will be
> violated. But you right, we can add sanity check here.
> This would not harm.
>
> Should I send it?

I figure an explicit check for bdrv_getlength() failure would make the
code easier to understand.  In short: yes, please!

      reply	other threads:[~2017-08-04 14:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 12:16 [Qemu-devel] Is the use of bdrv_getlength() in handle_aiocb_write_zeroes() kosher? Markus Armbruster
2017-08-04 12:31 ` [Qemu-devel] Is the use of bdrv_getlength() in parallels.c kosher? (was: Is the use of bdrv_getlength() in handle_aiocb_write_zeroes() kosher?) Markus Armbruster
2017-08-04 13:10   ` [Qemu-devel] Is the use of bdrv_getlength() in parallels.c kosher? Denis V. Lunev
2017-08-04 13:08 ` [Qemu-devel] Is the use of bdrv_getlength() in handle_aiocb_write_zeroes() kosher? Denis V. Lunev
2017-08-04 14:20   ` Markus Armbruster [this message]

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=87y3qzbejp.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.