From: levin li <[email protected]> In some path such as the object cache path, we need to determine the copies count with the zones count, but we can't get the sd_vnodes list to calucate the zones count, so it's better to include a nr_zones field in cluster_info, everytime the cluster complete recovering, we recalucate the nr_zones field.
Signed-off-by: levin li <[email protected]> --- sheep/farm/trunk.c | 8 ++++++-- sheep/group.c | 16 ++++++++-------- sheep/sheep_priv.h | 1 + 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sheep/farm/trunk.c b/sheep/farm/trunk.c index 6725c47..2a38c4c 100644 --- a/sheep/farm/trunk.c +++ b/sheep/farm/trunk.c @@ -282,10 +282,14 @@ static struct omap_entry *omap_file_insert(struct strbuf *buf, struct omap_entry static int oid_stale(uint64_t oid) { - int i, vidx; + int i, vidx, copies; struct sd_vnode *vnodes = sys->vnodes; - for (i = 0; i < sys->nr_sobjs; i++) { + copies = sys->nr_sobjs; + if (copies > sys->nr_zones) + copies = sys->nr_zones; + + for (i = 0; i < copies; i++) { vidx = obj_to_sheep(vnodes, sys->nr_vnodes, oid, i); if (is_myself(vnodes[vidx].addr, vnodes[vidx].port)) return 0; diff --git a/sheep/group.c b/sheep/group.c index 65933c5..62824ae 100644 --- a/sheep/group.c +++ b/sheep/group.c @@ -162,7 +162,7 @@ int get_ordered_sd_vnode_list(struct sd_vnode **entries, return SD_RES_NO_MEM; } - cache->nr_zones = get_zones_nr_from(sys->nodes, sys->nr_nodes); + cache->nr_zones = sys->nr_zones; memcpy(cache->vnodes, sys->vnodes, sizeof(sys->vnodes[0]) * sys->nr_vnodes); cache->nr_vnodes = sys->nr_vnodes; cache->epoch = sys->epoch; @@ -589,6 +589,8 @@ join_finished: qsort(sys->nodes, sys->nr_nodes, sizeof(*sys->nodes), node_cmp); sys->nr_vnodes = nodes_to_vnodes(sys->nodes, sys->nr_nodes, sys->vnodes); + sys->nr_zones = get_zones_nr_from(sys->nodes, sys->nr_nodes); + if (msg->cluster_status == SD_STATUS_OK || msg->cluster_status == SD_STATUS_HALT) { if (msg->inc_epoch) { @@ -843,9 +845,7 @@ static void __sd_join_done(struct cpg_event *cevent) } if (sys_stat_halt()) { - int nr_zones = get_zones_nr_from(sys->nodes, sys->nr_nodes); - - if (nr_zones >= sys->nr_sobjs) + if (sys->nr_zones >= sys->nr_sobjs) sys_stat_set(SD_STATUS_OK); } @@ -863,6 +863,8 @@ static void __sd_leave_done(struct cpg_event *cevent) qsort(sys->nodes, sys->nr_nodes, sizeof(*sys->nodes), node_cmp); sys->nr_vnodes = nodes_to_vnodes(sys->nodes, sys->nr_nodes, sys->vnodes); + sys->nr_zones = get_zones_nr_from(sys->nodes, sys->nr_nodes); + if (sys_can_recover()) { sys->epoch++; update_epoch_store(sys->epoch); @@ -875,9 +877,7 @@ static void __sd_leave_done(struct cpg_event *cevent) start_recovery(sys->epoch); if (sys_can_halt()) { - int nr_zones = get_zones_nr_from(sys->nodes, sys->nr_nodes); - - if (nr_zones < sys->nr_sobjs) + if (sys->nr_zones < sys->nr_sobjs) sys_stat_set(SD_STATUS_HALT); } } @@ -1008,7 +1008,7 @@ int is_access_to_busy_objects(uint64_t oid) continue; } if (oid == req->local_oid) - return 1; + return 1; } return 0; } diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h index 7dbfab2..311c95f 100644 --- a/sheep/sheep_priv.h +++ b/sheep/sheep_priv.h @@ -137,6 +137,7 @@ struct cluster_info { struct list_head blocking_conn_list; uint32_t nr_sobjs; + int nr_zones; struct list_head cpg_event_siblings; struct cpg_event *cur_cevent; -- 1.7.1 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
