[sheepdog] [PATCH v6 1/3] sheep: count recovered objects with uint64_t

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Mon Aug 5 13:26:43 CEST 2013


In theory, a number of recovered objects (or their candidate) would be
larger than 2 ^ 32. This patch lets the recovery process use uint64_t
for counting the numbers.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
v6:
 - let the recovery process count the objects with uint64_t

 sheep/recovery.c |   35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 3c65bd1..68d61c3 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -32,7 +32,7 @@ struct recovery_work {
 struct recovery_list_work {
 	struct recovery_work base;
 
-	int count;
+	uint64_t count;
 	uint64_t *oids;
 };
 
@@ -58,7 +58,7 @@ struct recovery_info {
 
 	uint32_t epoch;
 	uint32_t tgt_epoch;
-	uint32_t done;
+	uint64_t done;
 
 	/*
 	 * true when automatic recovery is disabled
@@ -67,11 +67,11 @@ struct recovery_info {
 	bool suspended;
 	bool notify_complete;
 
-	int count;
+	uint64_t count;
 	uint64_t *oids;
 	uint64_t *prio_oids;
-	int nr_prio_oids;
-	int nr_scheduled_prio_oids;
+	uint64_t nr_prio_oids;
+	uint64_t nr_scheduled_prio_oids;
 
 	struct vnode_info *old_vinfo;
 	struct vnode_info *cur_vinfo;
@@ -338,7 +338,7 @@ bool node_in_recovery(void)
 static inline void prepare_schedule_oid(uint64_t oid)
 {
 	struct recovery_info *rinfo = main_thread_get(current_rinfo);
-	int i;
+	uint64_t i;
 
 	for (i = 0; i < rinfo->nr_prio_oids; i++)
 		if (rinfo->prio_oids[i] == oid)
@@ -361,7 +361,7 @@ static inline void prepare_schedule_oid(uint64_t oid)
 	rinfo->prio_oids = xrealloc(rinfo->prio_oids,
 				    rinfo->nr_prio_oids * sizeof(uint64_t));
 	rinfo->prio_oids[rinfo->nr_prio_oids - 1] = oid;
-	sd_dprintf("%"PRIx64" nr_prio_oids %d", oid, rinfo->nr_prio_oids);
+	sd_dprintf("%"PRIx64" nr_prio_oids %"PRIu64, oid, rinfo->nr_prio_oids);
 
 	resume_suspended_recovery();
 }
@@ -369,7 +369,7 @@ static inline void prepare_schedule_oid(uint64_t oid)
 bool oid_in_recovery(uint64_t oid)
 {
 	struct recovery_info *rinfo = main_thread_get(current_rinfo);
-	int i;
+	uint64_t i;
 
 	if (!node_in_recovery())
 		return false;
@@ -511,9 +511,7 @@ static inline void finish_recovery(struct recovery_info *rinfo)
 
 static inline bool oid_in_prio_oids(struct recovery_info *rinfo, uint64_t oid)
 {
-	int i;
-
-	for (i = 0; i < rinfo->nr_prio_oids; i++)
+	for (uint64_t i = 0; i < rinfo->nr_prio_oids; i++)
 		if (rinfo->prio_oids[i] == oid)
 			return true;
 	return false;
@@ -529,7 +527,7 @@ static inline bool oid_in_prio_oids(struct recovery_info *rinfo, uint64_t oid)
  */
 static inline void finish_schedule_oids(struct recovery_info *rinfo)
 {
-	int i, nr_recovered = rinfo->done, new_idx;
+	uint64_t i, nr_recovered = rinfo->done, new_idx;
 	uint64_t *new_oids;
 
 	/* If I am the last oid, done */
@@ -548,7 +546,8 @@ static inline void finish_schedule_oids(struct recovery_info *rinfo)
 		new_oids[new_idx++] = rinfo->oids[i];
 	}
 	/* rw->count should eq new_idx, otherwise something is wrong */
-	sd_dprintf("%snr_recovered %d, nr_prio_oids %d, count %d = new %d",
+	sd_dprintf("%snr_recovered %"PRIu64", nr_prio_oids %"PRIu64", "
+		   "count %"PRIu64" = new %"PRIu64,
 		   rinfo->count == new_idx ? "" : "WARN: ", nr_recovered,
 		   rinfo->nr_prio_oids, rinfo->count, new_idx);
 
@@ -628,7 +627,7 @@ static void recover_object_main(struct work *work)
 	wakeup_requests_on_oid(row->oid);
 	rinfo->done++;
 
-	sd_eprintf("done:%"PRIu32" count:%"PRIu32", oid:%"PRIx64, rinfo->done,
+	sd_eprintf("done:%"PRIu64" count:%"PRIu64", oid:%"PRIx64, rinfo->done,
 		   rinfo->count, row->oid);
 
 	if (rinfo->done < rinfo->count) {
@@ -715,9 +714,9 @@ static void screen_object_list(struct recovery_list_work *rlw,
 {
 	struct recovery_work *rw = &rlw->base;
 	const struct sd_vnode *vnodes[SD_MAX_COPIES];
-	int old_count = rlw->count;
-	int nr_objs;
-	int i, j;
+	uint64_t old_count = rlw->count;
+	uint64_t nr_objs;
+	uint64_t i, j;
 
 	for (i = 0; i < nr_oids; i++) {
 		if (xbsearch(&oids[i], rlw->oids, old_count, obj_cmp))
@@ -792,7 +791,7 @@ again:
 		goto again;
 	}
 
-	sd_dprintf("%d", rlw->count);
+	sd_dprintf("%"PRIu64, rlw->count);
 }
 
 int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo,
-- 
1.7.10.4




More information about the sheepdog mailing list