Message ID | 1379502855-27759-3-git-send-email-famz@redhat.com |
---|---|
State | New |
Headers | show |
On Wed, Sep 18, 2013 at 07:14:15PM +0800, Fam Zheng wrote: > We use the extent size as cluster size for flat extents (where no L1/L2 > table is allocated so it's safe). Why is the extent size passed as the cluster size parameter? The cleaner fix would be to stop passing it as cluster size :). Stefan
Il 19/09/2013 13:31, Stefan Hajnoczi ha scritto: >> > We use the extent size as cluster size for flat extents (where no L1/L2 >> > table is allocated so it's safe). > Why is the extent size passed as the cluster size parameter? I think it's so that the flat extent doesn't take up too many cache entries. Paolo > The cleaner fix would be to stop passing it as cluster size :).
On Fri, 09/20 17:04, Paolo Bonzini wrote: > Il 19/09/2013 13:31, Stefan Hajnoczi ha scritto: > >> > We use the extent size as cluster size for flat extents (where no L1/L2 > >> > table is allocated so it's safe). > > Why is the extent size passed as the cluster size parameter? > > I think it's so that the flat extent doesn't take up too many cache entries. > > Paolo Flat extent doesn't take cache entry at all. It's passed as this because so that more the code path for finding data offset can be the same with sparse: flat is a special case of sparse with only 1 cluster. Otherwize flat needs to be treated specially. Another fix would be pass zero to cluster size parameter but initialize it to extent size after parameter checking. But not quite different. Fam
diff --git a/block/vmdk.c b/block/vmdk.c index fb5b529..fdd4eaa 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -396,7 +396,7 @@ static int vmdk_add_extent(BlockDriverState *bs, VmdkExtent *extent; BDRVVmdkState *s = bs->opaque; - if (cluster_sectors > 0x200000) { + if (!flat && cluster_sectors > 0x200000) { /* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */ error_report("invalid granularity, image may be corrupt"); return -EINVAL;
We use the extent size as cluster size for flat extents (where no L1/L2 table is allocated so it's safe). So don't check the cluster size for flat case in opening. Otherwise flat extent opening is broken: # qemu-img create -f vmdk -o subformat=monolithicFlat /tmp/a.vmdk 100G Formatting '/tmp/a.vmdk', fmt=vmdk size=107374182400 compat6=off subformat='monolithicFlat' zeroed_grain=off # qemu-img info /tmp/a.vmdk image: /tmp/a.vmdk file format: raw virtual size: 0 (0 bytes) disk size: 4.0K Signed-off-by: Fam Zheng <famz@redhat.com> --- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)