Deleted Added
full compact
secondary.c (220005) secondary.c (220007)
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sbin/hastd/secondary.c 220005 2011-03-25 20:13:38Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/secondary.c 220007 2011-03-25 20:19:15Z pjd $");
33
34#include <sys/param.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/stat.h>
39
40#include <err.h>

--- 155 unchanged lines hidden (view full) ---

196 mapsize = activemap_calc_ondisk_size(res->hr_local_mediasize -
197 METADATA_SIZE, res->hr_extentsize, res->hr_local_sectorsize);
198 map = malloc(mapsize);
199 if (map == NULL) {
200 pjdlog_exitx(EX_TEMPFAIL,
201 "Unable to allocate memory (%zu bytes) for activemap.",
202 mapsize);
203 }
33
34#include <sys/param.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/stat.h>
39
40#include <err.h>

--- 155 unchanged lines hidden (view full) ---

196 mapsize = activemap_calc_ondisk_size(res->hr_local_mediasize -
197 METADATA_SIZE, res->hr_extentsize, res->hr_local_sectorsize);
198 map = malloc(mapsize);
199 if (map == NULL) {
200 pjdlog_exitx(EX_TEMPFAIL,
201 "Unable to allocate memory (%zu bytes) for activemap.",
202 mapsize);
203 }
204 nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize");
205 /*
206 * When we work as primary and secondary is missing we will increase
207 * localcnt in our metadata. When secondary is connected and synced
208 * we make localcnt be equal to remotecnt, which means nodes are more
209 * or less in sync.
210 * Split-brain condition is when both nodes are not able to communicate
211 * and are both configured as primary nodes. In turn, they can both
212 * make incompatible changes to the data and we have to detect that.

--- 121 unchanged lines hidden (view full) ---

334 nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc");
335 }
336 pjdlog_warning("This should never happen, asking for full synchronization (primary(local=%ju, remote=%ju), secondary(local=%ju, remote=%ju)).",
337 (uintmax_t)res->hr_primary_localcnt,
338 (uintmax_t)res->hr_primary_remotecnt,
339 (uintmax_t)res->hr_secondary_localcnt,
340 (uintmax_t)res->hr_secondary_remotecnt);
341 }
204 /*
205 * When we work as primary and secondary is missing we will increase
206 * localcnt in our metadata. When secondary is connected and synced
207 * we make localcnt be equal to remotecnt, which means nodes are more
208 * or less in sync.
209 * Split-brain condition is when both nodes are not able to communicate
210 * and are both configured as primary nodes. In turn, they can both
211 * make incompatible changes to the data and we have to detect that.

--- 121 unchanged lines hidden (view full) ---

333 nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc");
334 }
335 pjdlog_warning("This should never happen, asking for full synchronization (primary(local=%ju, remote=%ju), secondary(local=%ju, remote=%ju)).",
336 (uintmax_t)res->hr_primary_localcnt,
337 (uintmax_t)res->hr_primary_remotecnt,
338 (uintmax_t)res->hr_secondary_localcnt,
339 (uintmax_t)res->hr_secondary_remotecnt);
340 }
341 nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize");
342 if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) {
343 pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s",
344 res->hr_remoteaddr);
345 }
346 if (map != NULL)
347 free(map);
348 nv_free(nvout);
349 if (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&

--- 436 unchanged lines hidden ---
342 if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) {
343 pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s",
344 res->hr_remoteaddr);
345 }
346 if (map != NULL)
347 free(map);
348 nv_free(nvout);
349 if (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&

--- 436 unchanged lines hidden ---