Add a uint8_t flag "set_bitmap" to sd_req.vdi_state.
Function notify_vdi_add will set bitmap if "set_bitmap" is not 0.

This feature will be used for recovering vdi state and vdi bitmap
on all nodes after loading snapshot to a new cluster.

Signed-off-by: Kai Zhang <[email protected]>
---
 include/sheepdog_proto.h |    2 ++
 sheep/ops.c              |    3 +++
 sheep/vdi.c              |    1 +
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 5440721..af4ec32 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -144,6 +144,8 @@ struct sd_req {
                        uint32_t        old_vid;
                        uint32_t        new_vid;
                        uint32_t        copies;
+                       uint8_t         set_bitmap; /* 0 means false */
+                                                   /* others mean true */
                } vdi_state;
 
                uint32_t                __pad[8];
diff --git a/sheep/ops.c b/sheep/ops.c
index e2107c3..7c1f6f6 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -619,6 +619,9 @@ static int cluster_notify_vdi_add(const struct sd_req *req, 
struct sd_rsp *rsp,
                              get_vdi_copy_number(req->vdi_state.old_vid),
                              true);
 
+       if (req->vdi_state.set_bitmap)
+               set_bit(req->vdi_state.new_vid, sys->vdi_inuse);
+
        add_vdi_state(req->vdi_state.new_vid, req->vdi_state.copies, false);
 
        return SD_RES_SUCCESS;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 98abe10..6ac8b15 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -482,6 +482,7 @@ static int notify_vdi_add(uint32_t vdi_id, uint32_t 
nr_copies, uint32_t old_vid)
        hdr.vdi_state.old_vid = old_vid;
        hdr.vdi_state.new_vid = vdi_id;
        hdr.vdi_state.copies = nr_copies;
+       hdr.vdi_state.set_bitmap = 0;
 
        ret = exec_local_req(&hdr, NULL);
        if (ret != SD_RES_SUCCESS)
-- 
1.7.1

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to