Received: from eggs.gnu.org ([2001:4830:134:3::10]:59894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcttq-0003Ui-Q7 for qemu-devel@nongnu.org; Tue, 10 Jul 2018 10:45:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcttp-0002Pz-Rk for qemu-devel@nongnu.org; Tue, 10 Jul 2018 10:45:54 -0400 Date: Tue, 10 Jul 2018 16:45:43 +0200 From: Kevin Wolf Message-ID: <20180710144543.GK5852@localhost.localdomain> References: <20180710063124.2263-1-famz@redhat.com> <20180710063124.2263-8-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180710063124.2263-8-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 07/10] block: Use common req handling for discard List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, Paolo Bonzini , vsementsov@virtuozzo.com, qemu-block@nongnu.org, Max Reitz , Jeff Cody , Eric Blake , John Snow , Stefan Hajnoczi Am 10.07.2018 um 08:31 hat Fam Zheng geschrieben: > Reuse the new bdrv_co_write_req_prepare/finish helpers. The variation > here is that discard requests don't affect bs->wr_highest_offset, and it > cannot extend the image. > > Signed-off-by: Fam Zheng > --- > block/io.c | 32 ++++++++++++++++++++++---------- > 1 file changed, 22 insertions(+), 10 deletions(-) > > diff --git a/block/io.c b/block/io.c > index 10a475302a..cc426bab2e 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -1601,15 +1601,31 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes, > > atomic_inc(&bs->write_gen); > > - stat64_max(&bs->wr_highest_offset, offset + bytes); > - > + /* Discard cannot extend the image, but in error handling cases, such as > + * when reverting a qcow2 cluster allocation, the discarded range can pass > + * the end of image file, so we cannot assert about BDRV_TRACKED_DISCARD > + * here. Instead, just skip it, since semantically a discard request > + * beyond EOF cannot expand the image anyway. > + * */ Oh, yet another style for the end of a multiline comment. :-) I'll fix this while applying. Kevin