Skip to contentSkip to conversation

block: Turn on "unmap" in active commit

PATCH Superseded Fam Zheng 2 participants 5 messages Sep 27, 2016 Block layer

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v2 1/1 block: Turn on "unmap" in active commit

We already specified BDRV_O_UNMAP when opening images in 'qemu-img commit', but didn't turn on the "unmap" in the active commit job. This patch fixes that so that zeroed clusters in top image can be discarded which is desired in the virt-sparsify use case, where a temporary overlay is created and fstrim'ed before commiting back, to free space in the original image.

This also enables it for block-commit.

---
v2: Add "unmap" to block-commit as well. [Kevin]

---
 block/mirror.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/mirror.c +1 -1
index f9d1fec..8f6f506 100644
@@ -1043,7 +1043,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
     mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
                      MIRROR_LEAVE_BACKING_CHAIN,
                      on_error, on_error, false, cb, opaque, &local_err,
-                     &commit_active_job_driver, false, base, auto_complete);
+                     &commit_active_job_driver, true, base, auto_complete);
     if (local_err) {
         error_propagate(errp, local_err);
         goto error_restore_flags;
Signature · 1 line
2.7.4
author
#1 lore raw
Quoted 10 lines · Fam Zheng

We already specified BDRV_O_UNMAP when opening images in 'qemu-img commit', but didn't turn on the "unmap" in the active commit job. This patch fixes that so that zeroed clusters in top image can be discarded which is desired in the virt-sparsify use case, where a temporary overlay is created and fstrim'ed before commiting back, to free space in the original image.

This also enables it for block-commit.

Sent too soon. I see a number of iotests failures (020 040 097 129), still investigating.

Fam

author
#2 lore raw
In reply to Fam Zheng
Quoted 21 lines · Fam Zheng

We already specified BDRV_O_UNMAP when opening images in 'qemu-img commit', but didn't turn on the "unmap" in the active commit job. This patch fixes that so that zeroed clusters in top image can be discarded which is desired in the virt-sparsify use case, where a temporary overlay is created and fstrim'ed before commiting back, to free space in the original image.

This also enables it for block-commit.

---
v2: Add "unmap" to block-commit as well. [Kevin]

---
 block/mirror.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/mirror.c +0 -0
index f9d1fec..8f6f506 100644

block/mirror.c void commit_active_start(const char *job_id, BlockDriverState *bs, · line 1046

Quoted 5 lines
block/mirror.c +1 -1
@@ -1043,7 +1043,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
     mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
                      MIRROR_LEAVE_BACKING_CHAIN,
                      on_error, on_error, false, cb, opaque, &local_err,
-                     &commit_active_job_driver, false, base, auto_complete);
+                     &commit_active_job_driver, true, base, auto_complete);

I'm an idiot! I changed the wrong parameter (is_none_mode).

Will send v3.

Fam

Quoted 7 lines
block/mirror.c +0 -0
     if (local_err) {
         error_propagate(errp, local_err);
         goto error_restore_flags;
Signature · 1 line
2.7.4
#3 lore raw

Am 27.09.2016 um 13:04 hat Fam Zheng geschrieben:

Quoted 17 lines · Fam Zheng
Quoted 16 lines

We already specified BDRV_O_UNMAP when opening images in 'qemu-img commit', but didn't turn on the "unmap" in the active commit job. This patch fixes that so that zeroed clusters in top image can be discarded which is desired in the virt-sparsify use case, where a temporary overlay is created and fstrim'ed before commiting back, to free space in the original image.

This also enables it for block-commit.

---
v2: Add "unmap" to block-commit as well. [Kevin]

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

block/mirror.c void commit_active_start(const char *job_id, BlockDriverState *bs, · line 1046

Quoted 10 lines
block/mirror.c +1 -1
index f9d1fec..8f6f506 100644
@@ -1043,7 +1043,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
     mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
                      MIRROR_LEAVE_BACKING_CHAIN,
                      on_error, on_error, false, cb, opaque, &local_err,
-                     &commit_active_job_driver, false, base, auto_complete);
+                     &commit_active_job_driver, true, base, auto_complete);

I'm an idiot! I changed the wrong parameter (is_none_mode).

Actually, the idiotic part is having a function with eighteen parameters. Not too surprising that someone confuses them sooner or later...

Perhaps we could enable QAPI boxing for blockdev-mirror and then just pass down a struct. Then we could have designated initialisers here in commit_active_start() and it would be obvious if the wrong one is changed.

Not something to do in this series, of course, just a general idea for improvement.

Kevin

author
#4 lore raw
Quoted 31 lines · Kevin Wolf

Am 27.09.2016 um 13:04 hat Fam Zheng geschrieben:

Quoted 17 lines · Fam Zheng
Quoted 16 lines

We already specified BDRV_O_UNMAP when opening images in 'qemu-img commit', but didn't turn on the "unmap" in the active commit job. This patch fixes that so that zeroed clusters in top image can be discarded which is desired in the virt-sparsify use case, where a temporary overlay is created and fstrim'ed before commiting back, to free space in the original image.

This also enables it for block-commit.

---
v2: Add "unmap" to block-commit as well. [Kevin]

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

block/mirror.c void commit_active_start(const char *job_id, BlockDriverState *bs, · line 1046

Quoted 10 lines
block/mirror.c +1 -1
index f9d1fec..8f6f506 100644
@@ -1043,7 +1043,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
     mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
                      MIRROR_LEAVE_BACKING_CHAIN,
                      on_error, on_error, false, cb, opaque, &local_err,
-                     &commit_active_job_driver, false, base, auto_complete);
+                     &commit_active_job_driver, true, base, auto_complete);

I'm an idiot! I changed the wrong parameter (is_none_mode).

Quoted 8 lines

Actually, the idiotic part is having a function with eighteen parameters. Not too surprising that someone confuses them sooner or later...

Perhaps we could enable QAPI boxing for blockdev-mirror and then just pass down a struct. Then we could have designated initialisers here in commit_active_start() and it would be obvious if the wrong one is changed.

Good, one more thing in my TODO list. Thanks.

Fam

Quoted 5 lines

Not something to do in this series, of course, just a general idea for improvement.

Kevin