Message ID | 20220818151456.2118470-3-alexander.ivanov@virtuozzo.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | parallels: Refactor the code of images checks and fix a bug | expand |
On 18.08.2022 17:14, Alexander Ivanov wrote: > When an image is opened for check there is no error if an offset in the BAT > points outside the image. In such a way we can repair the image. > Out-of-image offsets are repaired in the check, but data_end field > still points outside. Fix this field by file size. > > Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> > --- > block/parallels.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/block/parallels.c b/block/parallels.c > index c245ca35cd..24c05b95e8 100644 > --- a/block/parallels.c > +++ b/block/parallels.c > @@ -513,7 +513,15 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, > res->leaks_fixed += count; > } > } > - > + /* > + * If there were an out-of-image cluster it would be repaired, > + * but s->data_end still would point outside image. > + * Fix s->data_end by the file size. > + */ > + size >>= BDRV_SECTOR_BITS; > + if (s->data_end > size) { > + s->data_end = size; > + } > out: > qemu_co_mutex_unlock(&s->lock); > return ret; yes, but the comment is wrong. You could have adjustment to data_end additionally once clusters outside of image are dropped - inside leak check. Where data_end could be reduced. And this leads to error further in the series. Den
diff --git a/block/parallels.c b/block/parallels.c index c245ca35cd..24c05b95e8 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -513,7 +513,15 @@ static int coroutine_fn parallels_co_check(BlockDriverState *bs, res->leaks_fixed += count; } } - + /* + * If there were an out-of-image cluster it would be repaired, + * but s->data_end still would point outside image. + * Fix s->data_end by the file size. + */ + size >>= BDRV_SECTOR_BITS; + if (s->data_end > size) { + s->data_end = size; + } out: qemu_co_mutex_unlock(&s->lock); return ret;
When an image is opened for check there is no error if an offset in the BAT points outside the image. In such a way we can repair the image. Out-of-image offsets are repaired in the check, but data_end field still points outside. Fix this field by file size. Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> --- block/parallels.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)