Skip to contentSkip to conversation

vmdk: Leave bdi intact if -ENOTSUP in vmdk_get_info

PATCH Applied Fam Zheng 3 participants 4 messages Nov 14, 2014 – Nov 17, 2014 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 vmdk: Leave bdi intact if -ENOTSUP in vmdk_get_info

When extent types don't match, we return -ENOTSUP. In this case, be polite to the caller and don't modify bdi.

---
 block/vmdk.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
block/vmdk.c +13 -7
index 673d3f5..2cbfd3e 100644
@@ -2137,23 +2137,29 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
     return spec_info;
 }
 
+static bool vmdk_extents_type_eq(const VmdkExtent *a, const VmdkExtent *b)
+{
+    return a->flat == b->flat &&
+           a->compressed == b->compressed &&
+           (a->flat || a->cluster_sectors == b->cluster_sectors);
+}
+
 static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
 {
     int i;
     BDRVVmdkState *s = bs->opaque;
     assert(s->num_extents);
-    bdi->needs_compressed_writes = s->extents[0].compressed;
-    if (!s->extents[0].flat) {
-        bdi->cluster_size = s->extents[0].cluster_sectors << BDRV_SECTOR_BITS;
-    }
+
     /* See if we have multiple extents but they have different cases */
     for (i = 1; i < s->num_extents; i++) {
-        if (bdi->needs_compressed_writes != s->extents[i].compressed ||
-            (bdi->cluster_size && bdi->cluster_size !=
-                s->extents[i].cluster_sectors << BDRV_SECTOR_BITS)) {
+        if (!vmdk_extents_type_eq(&s->extents[0], &s->extents[i])) {
             return -ENOTSUP;
         }
     }
+    bdi->needs_compressed_writes = s->extents[0].compressed;
+    if (!s->extents[0].flat) {
+        bdi->cluster_size = s->extents[0].cluster_sectors << BDRV_SECTOR_BITS;
+    }
     return 0;
 }
 
Signature · 1 line
1.9.3
#2 lore raw
In reply to Fam Zheng
Quoted 7 lines · Fam Zheng

When extent types don't match, we return -ENOTSUP. In this case, be polite to the caller and don't modify bdi.

---
 block/vmdk.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

At this stage of the release process it would be very helpful to include some context for this patch: is it a pure cleanup or actually a bug fix that needs to go into QEMU 2.2?

Since you are a regular contributor and I therefore trust you, I have merged this patch. But please be clear in commit descriptions about whether or not a patch is a bug fix (how to reproduce the bug, if a previous commit's regression is being fixed, etc).

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

author
#3 lore raw
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Fam Zheng

When extent types don't match, we return -ENOTSUP. In this case, be polite to the caller and don't modify bdi.

Quoted 8 lines
Quoted 4 lines
---
 block/vmdk.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

At this stage of the release process it would be very helpful to include some context for this patch: is it a pure cleanup or actually a bug fix that needs to go into QEMU 2.2?

This one is more of a cleanup than bug fix: although there is a small logical change, it's only visible to user on abnormally structured VMDK (mixed extent type, etc.) that require manual editing image file, which is AFAIK not a valid use case and will not cause anything worse than an error. I sent the patch mostly for the function semantic purpose: don't change caller's data unless it's necessary to.

Quoted 5 lines

Since you are a regular contributor and I therefore trust you, I have merged this patch. But please be clear in commit descriptions about whether or not a patch is a bug fix (how to reproduce the bug, if a previous commit's regression is being fixed, etc).

OK. I'll remember next time. Thanks for pointing out.

Fam