From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVL5O-0003zZ-8i for qemu-devel@nongnu.org; Tue, 10 Mar 2015 10:24:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVL5J-0007ZO-1W for qemu-devel@nongnu.org; Tue, 10 Mar 2015 10:24:42 -0400 Received: from mx2.parallels.com ([199.115.105.18]:60512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVL5I-0007ZJ-S1 for qemu-devel@nongnu.org; Tue, 10 Mar 2015 10:24:36 -0400 Date: Tue, 10 Mar 2015 17:24:25 +0300 From: Roman Kagan Message-ID: <20150310142425.GC6024@rkaganb.sw.ru> References: <1425977481-13317-1-git-send-email-den@openvz.org> <1425977481-13317-19-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1425977481-13317-19-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 18/27] block/parallels: implement parallels_check method of block driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Tue, Mar 10, 2015 at 11:51:12AM +0300, Denis V. Lunev wrote: > The check is very simple at the moment. It calculates necessary stats > and fix only the following errors: > - space leak at the end of the image. This would happens due to > preallocation > - clusters outside the image are zeroed. Nothing else could be done here > > Signed-off-by: Denis V. Lunev > CC: Roman Kagan > CC: Kevin Wolf > CC: Stefan Hajnoczi > --- > block/parallels.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 82 insertions(+) > > diff --git a/block/parallels.c b/block/parallels.c > index 65f6418..e5b475e 100644 > --- a/block/parallels.c > +++ b/block/parallels.c > @@ -228,6 +228,87 @@ fail: > return ret; > } > > + > +static int parallels_check(BlockDriverState *bs, BdrvCheckResult *res, > + BdrvCheckMode fix) > +{ > + BDRVParallelsState *s = bs->opaque; > + int64_t size, prev_off, high_off; > + int ret; > + uint32_t i; > + bool flush_bat = false; > + int cluster_size = s->tracks << BDRV_SECTOR_BITS; > + > + size = bdrv_getlength(bs->file); > + if (size < 0) { > + res->check_errors++; > + return size; > + } > + > + res->bfi.total_clusters = s->bat_size; > + res->bfi.compressed_clusters = 0; /* compression is not supported */ > + > + high_off = 0; > + prev_off = 0; > + for (i = 0; i < s->bat_size; i++) { > + int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS; > + if (off == 0) > + continue; If you don't update prev_off here you can get fragmentation stats wrong (dunno how important it is) > + > + /* cluster outside the image */ > + if (off > size) { > + fprintf(stderr, "%s cluster %u is outside image\n", > + fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); > + res->corruptions++; > + if (fix & BDRV_FIX_ERRORS) { > + s->bat_bitmap[i] = 0; > + res->corruptions_fixed++; > + flush_bat = true; > + continue; > + } Ditto Roman.