[sheepdog] [PATCH] dog: initialize a reference count of check/repair work correctly

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Wed Dec 18 09:50:35 CET 2013


Current dog initializes a reference count of check/repair work in an
invalid way. This patch fixes it.

Cc: Valerio Pachera <sirio81 at gmail.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 dog/vdi.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index c716589..58acec8 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -1657,6 +1657,20 @@ static void check_replicatoin_object(struct vdi_check_info *info)
 		return;
 	}
 
+	/*
+	 * before queuing actual repair work, we have to caliculate a number of
+	 * the works
+	 */
+	for (int i = 0; i < info->nr_copies; i++) {
+		if (&info->vcw[i] == info->majority)
+			continue;
+
+		if (!info->vcw[i].object_found ||
+		    memcmp(info->majority->hash, info->vcw[i].hash,
+			   sizeof(info->majority->hash)) != 0)
+			info->refcnt++;
+	}
+
 	for (int i = 0; i < info->nr_copies; i++) {
 		if (&info->vcw[i] == info->majority)
 			continue;
@@ -1666,7 +1680,6 @@ static void check_replicatoin_object(struct vdi_check_info *info)
 			   sizeof(info->majority->hash)) != 0) {
 			info->vcw[i].work.fn = vdi_repair_work;
 			info->vcw[i].work.done = vdi_repair_main;
-			info->refcnt++;
 			queue_work(info->wq, &info->vcw[i].work);
 		}
 	}
@@ -1814,13 +1827,13 @@ static void queue_vdi_check_work(const struct sd_inode *inode, uint64_t oid,
 	info->copy_policy = inode->copy_policy;
 
 	oid_to_vnodes(oid, &sd_vroot, nr_copies, tgt_vnodes);
+	info->refcnt = nr_copies;
 	for (int i = 0; i < nr_copies; i++) {
 		info->vcw[i].info = info;
 		info->vcw[i].ec_index = i;
 		info->vcw[i].vnode = tgt_vnodes[i];
 		info->vcw[i].work.fn = vdi_check_object_work;
 		info->vcw[i].work.done = vdi_check_object_main;
-		info->refcnt++;
 		queue_work(info->wq, &info->vcw[i].work);
 	}
 }
-- 
1.7.10.4




More information about the sheepdog mailing list