From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: sw@weilnetz.de, Jeff Cody <jcody@redhat.com>,
Peter Lieven <pl@dlhnet.de>,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/7] block: only force IO completion in .bdrv_truncate if we are shrinking
Date: Thu, 07 Mar 2013 17:45:31 +0100 [thread overview]
Message-ID: <5138C42B.7060701@redhat.com> (raw)
In-Reply-To: <20130307085038.GB2536@dhcp-200-207.str.redhat.com>
Il 07/03/2013 09:50, Kevin Wolf ha scritto:
> Am 06.03.2013 um 21:39 hat Paolo Bonzini geschrieben:
>> Il 06/03/2013 20:03, Peter Lieven ha scritto:
>>> Am 06.03.2013 19:48, schrieb Jeff Cody:
>>>> On Wed, Mar 06, 2013 at 07:31:51PM +0100, Paolo Bonzini wrote:
>>>>> Il 06/03/2013 19:14, Jeff Cody ha scritto:
>>>>>> QCOW breaks with it using a normal raw posix file as a device. As a
>>>>>> test: qemu-img create -f qcow test.qcow 5G. Now run qemu with that
>>>>>> drive mounted, and try to partition and format it. QEMU now asserts.
>>>>>>
>>>>>> The nicety of being able to using truncate during a write call,
>>>>>> especially for VHDX (which can have relatively large block/cluster
>>>>>> sizes), so to grow the file sparsely in a dynamically allocated file.
>>>>>
>>>>> Perhaps we need two APIs, "truncate" and "revalidate".
>>>>>
>>>>> Truncate should be a no-op if (!bs->growable).
>>>>>
>>>>> Revalidate could be called by the block_resize monitor command with no
>>>>> size specified.
>>>>
>>>> I think that is a good solution. Is it better to have "truncate" and
>>>> "revalidate", or "truncate" and "grow", with grow being a subset of
>>>> truncate, with fewer restrictions? There may still be operations
>>>> where it is OK to grow a file, but not OK to shrink it.
>
> What semantics would the both operations have? Is truncate the same as
> it used to be? I don't really understand what "revalidate" would do, it
> sounds like a read-only operation from its name?
Revalidate would update the current size. Files fetch it on all calls
to bdrv_getlength, but other backends cache it. It would visit the BDS
->file chain from the bottom (bs->file->file->file...) to the top
implicitly, with no need for an explicit recursion in the callback (like
we do for flush_to_os). Before starting the recursion, bdrv_revalidate
does a bdrv_drain_all, so using the current iscsi_truncate for
iscsi_revalidate would be fine.
The block_resize command will always call revalidate before doing
anything. Then block_resize will try to do a bdrv_truncate if the
callback is there.
Another change that could make sense, is to make bdrv_truncate succeed
if there is no bdrv_truncate callback but bs is larger than the
requested size. This would be a difference from today's
if (!drv->bdrv_truncate)
return -ENOTSUP;
And it could even do the same if the callback is there, but returns
ENOTSUP. It would simplify some code, like this in raw-posix.c's
raw_truncate:
} else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
if (offset > raw_getlength(bs)) {
return -EINVAL;
}
} else {
return -ENOTSUP;
}
The "else if" branch can just go away.
The remaining question is about usage of bdrv_truncate in the formats.
One important aspect is that both QCOW and VHDX, in addition to using
bdrv_truncate to extend the file, rely on bdrv_getlength to fetch the
last _used_ byte of the file, not the available space. I think we can
say that bdrv_getlength behaves like that iff bs->growable. If so, QCOW
and VHDX should fail to open for write if the underlying file has
!bs->growable. Which will never fail right now, but it will as soon as
we implement this:
>> Let's start from (c). bdrv_file_open sets bs->growable = 1. I think it
>> should be removed and only the file protocol should set it.
>
> This is probably right.
Good. More precisely, raw_open should only set it if the file is a
regular file.
Paolo
next prev parent reply other threads:[~2013-03-07 16:45 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-06 14:46 [Qemu-devel] [PATCH 0/7] Initial VHDX support (and a bug fix for QCOW) Jeff Cody
2013-03-06 14:47 ` [Qemu-devel] [PATCH 1/7] block: only force IO completion in .bdrv_truncate if we are shrinking Jeff Cody
2013-03-06 17:50 ` Peter Lieven
2013-03-06 18:06 ` Paolo Bonzini
2013-03-06 18:14 ` Jeff Cody
2013-03-06 18:31 ` Paolo Bonzini
2013-03-06 18:48 ` Jeff Cody
2013-03-06 19:03 ` Peter Lieven
2013-03-06 20:39 ` Paolo Bonzini
2013-03-07 8:50 ` Kevin Wolf
2013-03-07 8:56 ` Peter Lieven
2013-03-07 9:03 ` Kevin Wolf
2013-03-07 9:16 ` Peter Lieven
2013-03-07 9:22 ` Kevin Wolf
2013-03-07 9:25 ` Peter Lieven
2013-03-07 10:00 ` Kevin Wolf
2013-03-07 10:22 ` Peter Lieven
2013-03-07 16:45 ` Paolo Bonzini [this message]
2013-03-07 8:53 ` Peter Lieven
2013-03-07 8:59 ` Kevin Wolf
2013-03-07 16:09 ` Paolo Bonzini
2013-03-08 7:53 ` Peter Lieven
2013-03-08 9:23 ` Paolo Bonzini
2013-03-08 9:35 ` Kevin Wolf
2013-03-08 11:46 ` Peter Lieven
2013-03-08 11:56 ` Kevin Wolf
2013-03-09 9:36 ` Peter Lieven
[not found] ` <51378A23.5090301@dlhnet.de>
[not found] ` <20130306184217.GC3743@localhost.localdomain>
2013-03-06 18:46 ` Peter Lieven
2013-03-06 18:27 ` Peter Lieven
2013-03-07 8:57 ` Kevin Wolf
2013-03-06 18:32 ` Jeff Cody
2013-03-06 20:22 ` Paolo Bonzini
2013-03-06 14:47 ` [Qemu-devel] [PATCH 2/7] qemu: add castagnoli crc32c checksum algorithm Jeff Cody
2013-03-06 14:47 ` [Qemu-devel] [PATCH 3/7] block: vhdx header for the QEMU support of VHDX images Jeff Cody
2013-03-07 13:15 ` Stefan Hajnoczi
2013-03-07 13:43 ` Jeff Cody
2013-03-06 14:48 ` [Qemu-devel] [PATCH 4/7] block: initial VHDX driver support framework - supports open and probe Jeff Cody
2013-03-07 14:30 ` Stefan Hajnoczi
2013-03-07 15:23 ` Jeff Cody
2013-03-07 16:12 ` Stefan Hajnoczi
2013-03-08 8:35 ` Kevin Wolf
2013-03-06 14:48 ` [Qemu-devel] [PATCH 5/7] block: add read-only support to VHDX image format Jeff Cody
2013-03-06 14:48 ` [Qemu-devel] [PATCH 6/7] block: add header update capability for VHDX images Jeff Cody
2013-03-07 14:50 ` Stefan Hajnoczi
2013-03-07 15:33 ` Jeff Cody
2013-03-07 16:15 ` Stefan Hajnoczi
2013-03-06 14:48 ` [Qemu-devel] [PATCH 7/7] block: add write support " Jeff Cody
2013-03-07 15:59 ` Stefan Hajnoczi
2013-03-07 16:05 ` Jeff Cody
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=5138C42B.7060701@redhat.com \
--to=pbonzini@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pl@dlhnet.de \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/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).