Status Update: Mono Flat Almost Ready

After one week’s work, our mono-flat support is now bound into vmdk. The support includes probe, open, read, write, is_allocated and also backing_hd of monolithicFlat type images.

Read/write are using the same routine with get_cluster_offset handling address lookup. We can observe flat extent as a very large cluster, this view provides inconsistent between flat and sparse extents. When look up an offset within either format, we need a cluster_offset and index_in_cluster. So for flat the cluster_offset is 0 and index_in_cluster is the sector index in the whole extent.

There’s a bug that fails qemu-iotest 019(which writes to image that has parent). The cause is that when allocating cluster that is not present, get_whole_cluster reads from parent image, with an offset that is not aligned to cluster, and write to the newly allocated cluster.

1
2
3
4
5
6
7
8
9
10
11
12
    ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain,
            extent->cluster_sectors);
    if (ret < 0) {
        return -1;
    }

    //Write grain only into the active image
    ret = bdrv_write(extent->file, cluster_offset, whole_grain,
            extent->cluster_sectors);
    if (ret < 0) {
        return -1;
    }

This is obviously bug if offset is 512, and cluster_offset points to #0. To correct it only one line is added ahead:

1
2
        // floor offset to cluster
        offset -= offset % (extent->cluster_sectors * 512);

That’s it.

Comments