aboutsummaryrefslogtreecommitdiff
path: root/sbin/hastd/secondary.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2010-10-24 17:28:25 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2010-10-24 17:28:25 +0000
commitce837469ba69aeb842d9022c3d574f868140ea5e (patch)
treedf7a257e29dfd89ef5d31ecfc54f7a7b537997e5 /sbin/hastd/secondary.c
parentb9ffbb0a94fc0aac41c5956117b566d4b7b40c22 (diff)
downloadsrc-ce837469ba69aeb842d9022c3d574f868140ea5e.tar.gz
src-ce837469ba69aeb842d9022c3d574f868140ea5e.zip
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
Notes
Notes: svn path=/head/; revision=214284
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 6d89f3559704..a722726f5e6c 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? */