Add a bool flag "set_bitmap" to sd_req.vdi_state. Function notify_vdi_add will set bitmap if "set_bitmap" is true.
This feature will be used to recover 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 | 7 ++++--- sheep/ops.c | 3 +++ sheep/vdi.c | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h index 0916948..e170200 100644 --- a/include/sheepdog_proto.h +++ b/include/sheepdog_proto.h @@ -143,6 +143,7 @@ struct sd_req { uint32_t old_vid; uint32_t new_vid; uint32_t copies; + bool set_bitmap; } vdi_state; uint32_t __pad[8]; @@ -314,9 +315,9 @@ static inline bool vdi_is_snapshot(const struct sd_inode *inode) static inline __attribute__((used)) void __sd_proto_build_bug_ons(void) { - /* never called, only for checking BUILD_BUG_ON()s */ - BUILD_BUG_ON(sizeof(struct sd_req) != SD_REQ_SIZE); - BUILD_BUG_ON(sizeof(struct sd_rsp) != SD_RSP_SIZE); + /* never called, only for checking BUILD_BUG_ON()s */ + BUILD_BUG_ON(sizeof(struct sd_req) != SD_REQ_SIZE); + BUILD_BUG_ON(sizeof(struct sd_rsp) != SD_RSP_SIZE); } #endif diff --git a/sheep/ops.c b/sheep/ops.c index 56bcf62..8adbaa3 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..6120068 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 = false; 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
