diff mbox

[v22,02/10] Backup: clear all bitmap when doing block checkpoint

Message ID 1469182567-3114-3-git-send-email-wangww.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang WeiWei July 22, 2016, 10:15 a.m. UTC
From: Wen Congyang <wency@cn.fujitsu.com>

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Signed-off-by: Wang WeiWei <wangww.fnst@cn.fujitsu.com>
---
 block/backup.c               | 18 ++++++++++++++++++
 include/block/block_backup.h |  3 +++
 2 files changed, 21 insertions(+)
 create mode 100644 include/block/block_backup.h

Comments

Max Reitz July 25, 2016, 9:18 p.m. UTC | #1
On 22.07.2016 12:15, Wang WeiWei wrote:
> From: Wen Congyang <wency@cn.fujitsu.com>
> 
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
> Signed-off-by: Wang WeiWei <wangww.fnst@cn.fujitsu.com>
> ---
>  block/backup.c               | 18 ++++++++++++++++++
>  include/block/block_backup.h |  3 +++
>  2 files changed, 21 insertions(+)
>  create mode 100644 include/block/block_backup.h

[...]

> diff --git a/include/block/block_backup.h b/include/block/block_backup.h
> new file mode 100644
> index 0000000..3753bcb
> --- /dev/null
> +++ b/include/block/block_backup.h
> @@ -0,0 +1,3 @@
> +#include "block/block_int.h"
> +
> +void backup_do_checkpoint(BlockJob *job, Error **errp);

Include guards and copyright notice missing. I don't mind the missing
copyright notice because it will default to GPL anyway. Also, I
personally don't really mind the missing include guards, but I thought
I'd say something anyway.

Max
Changlong Xie July 26, 2016, 1:28 a.m. UTC | #2
On 07/26/2016 05:18 AM, Max Reitz wrote:
> On 22.07.2016 12:15, Wang WeiWei wrote:
>> From: Wen Congyang <wency@cn.fujitsu.com>
>>
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
>> Signed-off-by: Wang WeiWei <wangww.fnst@cn.fujitsu.com>
>> ---
>>   block/backup.c               | 18 ++++++++++++++++++
>>   include/block/block_backup.h |  3 +++
>>   2 files changed, 21 insertions(+)
>>   create mode 100644 include/block/block_backup.h
>
> [...]
>
>> diff --git a/include/block/block_backup.h b/include/block/block_backup.h
>> new file mode 100644
>> index 0000000..3753bcb
>> --- /dev/null
>> +++ b/include/block/block_backup.h
>> @@ -0,0 +1,3 @@
>> +#include "block/block_int.h"
>> +
>> +void backup_do_checkpoint(BlockJob *job, Error **errp);
>
> Include guards and copyright notice missing. I don't mind the missing
> copyright notice because it will default to GPL anyway. Also, I

I think i can copy the Copyright from backup.c and update it

> personally don't really mind the missing include guards, but I thought

Btw i'll add #ifndef...#define...#endif in next version

> I'd say something anyway.

warm welcome

>
> Max
>
diff mbox

Patch

diff --git a/block/backup.c b/block/backup.c
index 2c05323..3bce416 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -17,6 +17,7 @@ 
 #include "block/block.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "block/block_backup.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/ratelimit.h"
@@ -253,6 +254,23 @@  static void backup_attached_aio_context(BlockJob *job, AioContext *aio_context)
     blk_set_aio_context(s->target, aio_context);
 }
 
+void backup_do_checkpoint(BlockJob *job, Error **errp)
+{
+    BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common);
+    int64_t len;
+
+    assert(job->driver->job_type == BLOCK_JOB_TYPE_BACKUP);
+
+    if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) {
+        error_setg(errp, "The backup job only supports block checkpoint in"
+                   " sync=none mode");
+        return;
+    }
+
+    len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size);
+    bitmap_zero(backup_job->done_bitmap, len);
+}
+
 static const BlockJobDriver backup_job_driver = {
     .instance_size          = sizeof(BackupBlockJob),
     .job_type               = BLOCK_JOB_TYPE_BACKUP,
diff --git a/include/block/block_backup.h b/include/block/block_backup.h
new file mode 100644
index 0000000..3753bcb
--- /dev/null
+++ b/include/block/block_backup.h
@@ -0,0 +1,3 @@ 
+#include "block/block_int.h"
+
+void backup_do_checkpoint(BlockJob *job, Error **errp);