Skip to contentSkip to conversation

qcow2: discard bitmap when removed

PATCH In review Andrey Shinkevich 3 participants 5 messages Feb 28, 2019 – Apr 9, 2019 1 message not in the archive Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qcow2: discard bitmap when removed

When a bitmap is removed, we can clean some space on the disk. The size of a cluster may be larger, so is the size of the bitmap that includes many clusters. Some bitmaps can be as large as tens of megabytes. The flag QCOW2_DISCARD_ALWAYS allows a call to the raw_co_pdiscard() that does the actual cleaning of the image on disk, while with the flag QCOW2_DISCARD_OTHER, a reference count of the cluster is updated only.

---
v1: Discard old bitmap directories in QCOW2 image

In the first version of the patch, any call to qcow2_free_clusters() in block/qcow2-bitmap.c was with the flag QCOW2_DISCARD_ALWAYS, even in the cases when the cleaned space is insignificant, particularly, in case of bitmap directories.
Discussed in the email thread with the message ID <1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com>

 block/qcow2-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-bitmap.c +1 -1
index 3ee524d..162744e 100644
@@ -202,7 +202,7 @@ static void clear_bitmap_table(BlockDriverState *bs, uint64_t *bitmap_table,
             continue;
         }
 
-        qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER);
+        qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_ALWAYS);
         bitmap_table[i] = 0;
     }
 }
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Andrey Shinkevich

When a bitmap is removed, we can clean some space on the disk. The size of a cluster may be larger, so is the size of the bitmap that includes many clusters. Some bitmaps can be as large as tens of megabytes. The flag QCOW2_DISCARD_ALWAYS allows a call to the raw_co_pdiscard() that does the actual cleaning of the image on disk, while with the flag QCOW2_DISCARD_OTHER, a reference count of the cluster is updated only.

not quite right, as it depends on configuration.

So I'd reword the whole message to be simpler, like:

Bitmap data may take a lot of disk space, so it's better to discard it always.

Quoted 2 lines
Quoted 27 lines

---
v1: Discard old bitmap directories in QCOW2 image

In the first version of the patch, any call to qcow2_free_clusters() in block/qcow2-bitmap.c was with the flag QCOW2_DISCARD_ALWAYS, even in the cases when the cleaned space is insignificant, particularly, in case of bitmap directories.
Discussed in the email thread with the message ID <1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com>

  block/qcow2-bitmap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-bitmap.c +1 -1
index 3ee524d..162744e 100644
@@ -202,7 +202,7 @@ static void clear_bitmap_table(BlockDriverState *bs, uint64_t *bitmap_table,
              continue;
          }
 
-        qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER);
+        qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_ALWAYS);
          bitmap_table[i] = 0;
      }
  }
Signature · 2 lines
Best regards,
Vladimir

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PINGING

I kindly remind you about this small patch for QEMU 4.1. I am going to be away for vacation from April, 10th to May, 15th.

Signature · 2 lines
With the best regards,
Andrey Shinkevich
Quoted 47 lines · John Snow
Quoted 27 lines · Andrey Shinkevich

When a bitmap is removed, we can clean some space on the disk. The size of a cluster may be larger, so is the size of the bitmap that includes many clusters. Some bitmaps can be as large as tens of megabytes. The flag QCOW2_DISCARD_ALWAYS allows a call to the raw_co_pdiscard() that does the actual cleaning of the image on disk, while with the flag QCOW2_DISCARD_OTHER, a reference count of the cluster is updated only.

---
v1: Discard old bitmap directories in QCOW2 image

In the first version of the patch, any call to qcow2_free_clusters() in block/qcow2-bitmap.c was with the flag QCOW2_DISCARD_ALWAYS, even in the cases when the cleaned space is insignificant, particularly, in case of bitmap directories.
Discussed in the email thread with the message ID <1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com>

  block/qcow2-bitmap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-bitmap.c +0 -0
index 3ee524d..162744e 100644

block/qcow2-bitmap.c static void clear_bitmap_table(BlockDriverState *bs, uint64_t *bitmap_table, · line 208

Quoted 8 lines
block/qcow2-bitmap.c +1 -1
@@ -202,7 +202,7 @@ static void clear_bitmap_table(BlockDriverState *bs, uint64_t *bitmap_table,
              continue;
          }
 
-        qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER);
+        qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_ALWAYS);
          bitmap_table[i] = 0;
      }
  }

Looks like 4.1 material now. Kevin may have been expecting me to engage with this, even though I do not maintain the qcow2-bitmap.c file. (And I'm very behind on reading mail that was not directly addressed to me, sorry...!)

Please resend when the 4.1 window opens and we'll address this then.

--js

#4 lore raw
In reply to Andrey Shinkevich
Quoted 18 lines · Andrey Shinkevich

When a bitmap is removed, we can clean some space on the disk. The size of a cluster may be larger, so is the size of the bitmap that includes many clusters. Some bitmaps can be as large as tens of megabytes. The flag QCOW2_DISCARD_ALWAYS allows a call to the raw_co_pdiscard() that does the actual cleaning of the image on disk, while with the flag QCOW2_DISCARD_OTHER, a reference count of the cluster is updated only.

---
v1: Discard old bitmap directories in QCOW2 image

In the first version of the patch, any call to qcow2_free_clusters() in block/qcow2-bitmap.c was with the flag QCOW2_DISCARD_ALWAYS, even in the cases when the cleaned space is insignificant, particularly, in case of bitmap directories.
Discussed in the email thread with the message ID <1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com>

Quoted 2 lines
 block/qcow2-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, changed the commit message to Vladimir’s proposal and applied to my block-next branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block-next

Max

#5 lore raw
Quoted 22 lines · Max Reitz
Quoted 18 lines · Andrey Shinkevich

When a bitmap is removed, we can clean some space on the disk. The size of a cluster may be larger, so is the size of the bitmap that includes many clusters. Some bitmaps can be as large as tens of megabytes. The flag QCOW2_DISCARD_ALWAYS allows a call to the raw_co_pdiscard() that does the actual cleaning of the image on disk, while with the flag QCOW2_DISCARD_OTHER, a reference count of the cluster is updated only.

---
v1: Discard old bitmap directories in QCOW2 image

In the first version of the patch, any call to qcow2_free_clusters() in block/qcow2-bitmap.c was with the flag QCOW2_DISCARD_ALWAYS, even in the cases when the cleaned space is insignificant, particularly, in case of bitmap directories.
Discussed in the email thread with the message ID <1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com>

Quoted 2 lines
  block/qcow2-bitmap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines

Thanks, changed the commit message to Vladimir’s proposal and applied to my block-next branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block-next

Max

Thank you, Max!

Signature · 2 lines
With the best regards,
Andrey Shinkevich