On 31.01.19 18:55, Kevin Wolf wrote: > This changes the qcow2 implementation to direct all guest data I/O to > s->data_file rather than bs->file, while metadata I/O still uses > bs->file. At the moment, this is still always the same, but soon we'll > add options to set s->data_file to an external data file. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > block/qcow2.h | 2 +- > block/qcow2-bitmap.c | 7 ++++--- > block/qcow2-cache.c | 6 +++--- > block/qcow2-cluster.c | 46 +++++++++++++++++++++++++++++++++++------- > block/qcow2-refcount.c | 30 +++++++++++++++++++-------- > block/qcow2-snapshot.c | 7 ++++--- > block/qcow2.c | 39 +++++++++++++++++++++++++---------- > 7 files changed, 101 insertions(+), 36 deletions(-)
[...] > diff --git a/block/qcow2.c b/block/qcow2.c > index 2b81cf839d..ac9934b3ed 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c [...] > @@ -3598,6 +3598,16 @@ static int coroutine_fn > qcow2_co_truncate(BlockDriverState *bs, int64_t offset, > int64_t old_file_size, new_file_size; > uint64_t nb_new_data_clusters, nb_new_l2_tables; > > + /* With a data file, preallocation means just allocating the metadata > + * and forwarding the truncate request to the data file */ That's true, but... > + if (has_data_file(bs)) { > + ret = preallocate_co(bs, old_length, offset); > + if (ret < 0) { > + error_setg_errno(errp, -ret, "Preallocation failed"); > + goto fail; > + } ...without a break here we're still going to preallocate bs->file as before. Max > + } > + > old_file_size = bdrv_getlength(bs->file->bs); > if (old_file_size < 0) { > error_setg_errno(errp, -old_file_size,
signature.asc
Description: OpenPGP digital signature