We need to add '--force' option to remove old objects, but currently collie always delete old objects when make fs is invoked. Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> --- collie/group.c | 40 +++++++++++++++++++++++++++++++++++----- 1 files changed, 35 insertions(+), 5 deletions(-) diff --git a/collie/group.c b/collie/group.c index 676ddbb..1571c19 100644 --- a/collie/group.c +++ b/collie/group.c @@ -875,6 +875,12 @@ static void vdi_op_done(struct vdi_op_message *msg) struct vm *vm; struct request *req; int ret = msg->rsp.result; + int i, latest_epoch, nr_nodes; + struct sheepdog_node_list_entry entry[SD_MAX_NODES]; + uint64_t ctime, hval; + + if (ret != SD_RES_SUCCESS) + goto out; switch (hdr->opcode) { case SD_OP_NEW_VDI: @@ -910,11 +916,35 @@ static void vdi_op_done(struct vdi_op_message *msg) case SD_OP_GET_VDI_INFO: break; case SD_OP_MAKE_FS: - if (ret == SD_RES_SUCCESS) { - sys->nr_sobjs = ((struct sd_so_req *)hdr)->copies; - eprintf("%d\n", sys->nr_sobjs); - } + sys->nr_sobjs = ((struct sd_so_req *)hdr)->copies; + eprintf("%d\n", sys->nr_sobjs); + + ctime = ((struct sd_so_req *)hdr)->ctime; + set_cluster_ctime(ctime); + latest_epoch = get_latest_epoch(); + for (i = 1; i <= latest_epoch; i++) + remove_epoch(i); + + sys->epoch = 1; + sys->is_object_updated = 0; + nr_nodes = build_node_list(&sys->sd_node_list, entry); + + dprintf("write epoch log, %d, %d\n", sys->epoch, nr_nodes); + ret = epoch_log_write(sys->epoch, (char *)entry, + nr_nodes * sizeof(struct sheepdog_node_list_entry)); + if (ret < 0) + eprintf("can't write epoch %u\n", sys->epoch); + update_epoch_store(sys->epoch); + set_epoch_updated(sys->epoch, 1); + + /* FIXME: free epoch tree */ + INIT_TREE_VERTEX(&sys->epoch_tree_root, 0, 0); + hval = epoch_hash_val(sys->epoch, ctime, entry, nr_nodes); + add_epoch_log(sys->epoch, 0, hval, nr_nodes, entry, 1, ctime); + + sys->status = SD_STATUS_OK; + break; case SD_OP_SHUTDOWN: sys->status = SD_STATUS_SHUTDOWN; break; @@ -924,7 +954,7 @@ static void vdi_op_done(struct vdi_op_message *msg) eprintf("unknown operation %d\n", hdr->opcode); ret = SD_RES_UNKNOWN; } - +out: if (node_cmp(&sys->this_node, &msg->header.from) != 0) return; -- 1.5.6.5 |