[sheepdog] [PATCH v2] sheep: get current nodes and vnodes from cache
yaohaiting.wujue at gmail.com
yaohaiting.wujue at gmail.com
Tue May 29 04:56:22 CEST 2012
From: HaiTing Yao <wujue.yht at taobao.com>
Initialize the recovery work, no need to read current nodes from disk.
Signed-off-by: HaiTing Yao <wujue.yht at taobao.com>
---
sheep/recovery.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
difference from v1
use vnodes_info, not use sd_vnodes any more
diff --git a/sheep/recovery.c b/sheep/recovery.c
index d5408e3..8da03b1 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -643,10 +643,18 @@ static int init_rw(struct recovery_work *rw)
{
uint32_t epoch = rw->epoch;
- rw->cur_nr_nodes = epoch_log_read_nr(epoch, (char *)rw->cur_nodes,
- sizeof(rw->cur_nodes));
- qsort(rw->cur_nodes, rw->cur_nr_nodes, sizeof(struct sd_node),
- node_cmp);
+ if (epoch == sys_epoch()) {
+ rw->cur_nr_nodes = sys->nr_nodes;
+ memcpy(rw->cur_nodes, sys->nodes, sizeof(rw->cur_nodes));
+ rw->cur_vnodes = get_vnode_info();
+ } else {
+ rw->cur_nr_nodes = epoch_log_read_nr(epoch,
+ (char *)rw->cur_nodes, sizeof(rw->cur_nodes));
+ qsort(rw->cur_nodes, rw->cur_nr_nodes, sizeof(struct sd_node),
+ node_cmp);
+ rw->cur_vnodes = alloc_vnode_info(rw->cur_nodes,
+ rw->cur_nr_nodes);
+ }
if (rw->cur_nr_nodes <= 0) {
eprintf("failed to read epoch log for epoch %"PRIu32"\n", epoch);
@@ -663,7 +671,6 @@ static int init_rw(struct recovery_work *rw)
node_cmp);
rw->old_vnodes = alloc_vnode_info(rw->old_nodes, rw->old_nr_nodes);
- rw->cur_vnodes = alloc_vnode_info(rw->cur_nodes, rw->cur_nr_nodes);
return 0;
}
--
1.7.1
More information about the sheepdog
mailing list