[Ocfs2-tools-devel] [PATCH 3/4] o2cb: avoid useless loop when scan global hb disks

Junxiao Bi junxiao.bi at oracle.com
Fri Oct 21 00:42:19 PDT 2016


Done the scanning when all global hb disks are ready. This will avoid the
long latency of "o2cb start-heartbeat $cluster_name" when there are lots
of disks in the system.

Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
---
 o2cb_ctl/o2cb_scandisk.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/o2cb_ctl/o2cb_scandisk.c b/o2cb_ctl/o2cb_scandisk.c
index 4083e9f5ae2e..ad6270dd6d65 100644
--- a/o2cb_ctl/o2cb_scandisk.c
+++ b/o2cb_ctl/o2cb_scandisk.c
@@ -57,7 +57,7 @@ static int fill_desc(char *device, struct o2cb_region_desc *reg,
 	return ret;
 }
 
-static void get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs)
+static int get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs)
 {
 	struct o2cb_device *od;
 	struct list_head *pos, *pos1;
@@ -71,7 +71,7 @@ static void get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs
 	}
 
 	if (!numhbdevs)
-		return;
+		return 0;
 
 	list_for_each(pos, &ctxt->sc_devlist) {
 		hb = list_entry(pos, struct hb_devices, hb_list);
@@ -97,6 +97,8 @@ static void get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs
 		if (!numhbdevs)
 			break;
 	}
+
+	return numhbdevs;
 }
 
 static void free_scan_context(struct scan_context *ctxt)
@@ -198,9 +200,10 @@ void o2cb_scandisk(struct list_head *hbdevs)
 		dev = scan_for_dev(NULL, 5, filter_devices, ctxt);
 		if (!dev)
 			goto bail;
-	} while (ctxt->sc_rescan);
 
-	get_device_uuids(ctxt, hbdevs);
+		if (!get_device_uuids(ctxt, hbdevs))
+			break;
+	} while (ctxt->sc_rescan);
 
 bail:
 	free_scan_context(ctxt);
-- 
1.7.9.5




More information about the Ocfs2-tools-devel mailing list