From: Jeff Cody <jcody@redhat.com>
To: Peter Lieven <pl@dlhnet.de>
Cc: kwolf@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org,
stefanha@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/7] block: only force IO completion in .bdrv_truncate if we are shrinking
Date: Wed, 6 Mar 2013 13:32:47 -0500 [thread overview]
Message-ID: <20130306183247.GA22782@localhost.localdomain> (raw)
In-Reply-To: <51378200.5010705@dlhnet.de>
On Wed, Mar 06, 2013 at 06:50:56PM +0100, Peter Lieven wrote:
> Am 06.03.2013 15:47, schrieb Jeff Cody:
> > Commit 9a665b2b made bdrv_truncate() call bdrv_drain_all(), but this breaks
> > QCOW images, as well other future image formats (such as VHDX) that may call
> > bdrv_truncate(bs->file) from within a read/write operation. For example, QCOW
> > will cause an assert, due to tracked_requests not being empty (since the
> > read/write that called bdrv_truncate() is still in progress).
> >
> > This modifies the check to only force the bdrv_drain_all() call if the BDS to
> > be truncated is not growable, or if we are shrinking the BDS. Otherwise, if we
> > are just growing the file, allow it to happen without forcing a call to
> > bdrv_drain_all().
>
> This will actually break iscsi_truncate(). Paolo requested that the iscsi_tuncate command
> should use sync I/O for rereading the LUN capacity. Using sync I/O is only possible if
> there are no async requests in-flight.
>
> Looking at the source I have not found a place where bs->growable is set to 0 for any
> block driver, maybe I miss something. Having bs->growable for iSCSI would also be ok.
>
> Shouldn't it be possible to call bdrv_drain_all() any time? There are other places
> where this is called. One I have in mind is e.g. if you cancel an ongoing block migration.
>
That is a good point - what happens to QCOW now, if there is a block
job in progress (e.g. block-commit, block-stream, etc...)? I would
imagine -EBUSY gets thrown, since bdrv_truncate() checks
bdrv_in_use().
>
> >
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > ---
> > block.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/block.c b/block.c
> > index 124a9eb..dce844c 100644
> > --- a/block.c
> > +++ b/block.c
> > @@ -2450,8 +2450,14 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset)
> > if (bdrv_in_use(bs))
> > return -EBUSY;
> >
> > - /* There better not be any in-flight IOs when we truncate the device. */
> > - bdrv_drain_all();
> > + /* Don't force a drain if we are just growing the file - otherwise,
> > + * using bdrv_truncate() from within a block driver in a read/write
> > + * operation will cause an assert, because bdrv_drain_all() will assert if
> > + * a tracked_request is still in progress. */
> > + if (!bs->growable || offset < bdrv_getlength(bs)) {
> > + /* There better not be any in-flight IOs when we truncate the device. */
> > + bdrv_drain_all();
> > + }
> >
> > ret = drv->bdrv_truncate(bs, offset);
> > if (ret == 0) {
> >
>
next prev parent reply other threads:[~2013-03-06 18:32 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
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 [this message]
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=20130306183247.GA22782@localhost.localdomain \
--to=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@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 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.