summaryrefslogtreecommitdiffstats
path: root/sbin/hastd/secondary.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-10-24 17:28:25 +0000
committerpjd <pjd@FreeBSD.org>2010-10-24 17:28:25 +0000
commit0a39257e367237138974814b300278b6433e9ce9 (patch)
treedf7a257e29dfd89ef5d31ecfc54f7a7b537997e5 /sbin/hastd/secondary.c
parent9eb542816d93ddad2b6f71e9fdcac572b7b6d758 (diff)
downloadFreeBSD-src-0a39257e367237138974814b300278b6433e9ce9.zip
FreeBSD-src-0a39257e367237138974814b300278b6433e9ce9.tar.gz
Before this change on first connect between primary and secondary we
initialize all the data. This is huge waste of time and resources if there were no writes yet, as there is no real data to synchronize. Optimize this by sending "virgin" argument to secondary, which gives it a hint that synchronization is not needed. In the common case (where noth nodes are configured at the same time) instead of synchronizing everything, we don't synchronize at all. MFC after: 1 week
Diffstat (limited to 'sbin/hastd/secondary.c')
-rw-r--r--sbin/hastd/secondary.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index 6d89f35..a722726 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -243,13 +243,22 @@ init_remote(struct hast_resource *res, struct nv *nvin)
*/
if (res->hr_resuid == 0) {
/*
- * Provider is used for the first time. Initialize everything.
+ * Provider is used for the first time. If primary node done no
+ * writes yet as well (we will find "virgin" argument) then
+ * there is no need to synchronize anything. If primary node
+ * done any writes already we have to synchronize everything.
*/
assert(res->hr_secondary_localcnt == 0);
res->hr_resuid = resuid;
if (metadata_write(res) < 0)
exit(EX_NOINPUT);
- memset(map, 0xff, mapsize);
+ if (nv_exists(nvin, "virgin")) {
+ free(map);
+ map = NULL;
+ mapsize = 0;
+ } else {
+ memset(map, 0xff, mapsize);
+ }
nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc");
} else if (
/* Is primary is out-of-date? */
OpenPOWER on IntegriCloud