Skip to contentSkip to conversation

block/qcow2: Use bdrv_truncate for size amend

PATCH In review Max Reitz 2 participants 3 messages Sep 9, 2013 – Oct 2, 2013 Block layer

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 block/qcow2: Use bdrv_truncate for size amend

When amending the size option for a qcow2 image, use bdrv_truncate instead of qcow2_truncate directly, since the latter will not adjust the total_sectors count in the BDS structure (whereas the former will).

---
Depends on (follow-up to):
- block/qcow2: Image file option amendment (series, v5)

---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2.c +1 -1
index d29547b..259edfd 100644
@@ -1997,7 +1997,7 @@ static int qcow2_amend_options(BlockDriverState *bs,
     }
 
     if (new_size) {
-        ret = qcow2_truncate(bs, new_size);
+        ret = bdrv_truncate(bs, new_size);
         if (ret < 0) {
             return ret;
         }
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 17 lines · Max Reitz

When amending the size option for a qcow2 image, use bdrv_truncate instead of qcow2_truncate directly, since the latter will not adjust the total_sectors count in the BDS structure (whereas the former will).

---
Depends on (follow-up to):
- block/qcow2: Image file option amendment (series, v5)

---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2.c +0 -0
index d29547b..259edfd 100644

block/qcow2.c static int qcow2_amend_options(BlockDriverState *bs, · line 2003

Quoted 8 lines
block/qcow2.c +1 -1
@@ -1997,7 +1997,7 @@ static int qcow2_amend_options(BlockDriverState *bs,
     }
 
     if (new_size) {
-        ret = qcow2_truncate(bs, new_size);
+        ret = bdrv_truncate(bs, new_size);
         if (ret < 0) {
             return ret;
         }

It seems this patch was already squashed into 9296b3ed7050cc6e0645fbc3b0aea74406d7eeb2 ("qcow2: Implement bdrv_amend_options").

author
#2 lore raw
Quoted 20 lines · Stefan Hajnoczi
Quoted 19 lines · Max Reitz

When amending the size option for a qcow2 image, use bdrv_truncate instead of qcow2_truncate directly, since the latter will not adjust the total_sectors count in the BDS structure (whereas the former will).

---
Depends on (follow-up to):
- block/qcow2: Image file option amendment (series, v5)

---
  block/qcow2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2.c +0 -0
index d29547b..259edfd 100644
@@ -1997,7 +1997,7 @@ static int qcow2_amend_options(BlockDriverState *bs,
      }
 
Quoted 9 lines

block/qcow2.c static int qcow2_amend_options(BlockDriverState *bs, · line 2003

Quoted 6 lines
block/qcow2.c +1 -1
      if (new_size) {
-        ret = qcow2_truncate(bs, new_size);
+        ret = bdrv_truncate(bs, new_size);
          if (ret < 0) {
              return ret;
          }

It seems this patch was already squashed into 9296b3ed7050cc6e0645fbc3b0aea74406d7eeb2 ("qcow2: Implement bdrv_amend_options").

Yes, as Kevin stated in his reply to that series:

Quoted 4 lines

Thanks, applied to the block branch with the following changes:

- Updated patch 5 with
[PATCH] block/qcow2: Use bdrv_truncate for size amend

Max