Deleted Added
full compact
primary.c (220271) primary.c (220865)
1/*-
2 * Copyright (c) 2009 The FreeBSD Foundation
3 * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
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 The FreeBSD Foundation
3 * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
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/primary.c 220271 2011-04-02 09:25:13Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/primary.c 220865 2011-04-19 19:26:27Z pjd $");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/refcount.h>
39#include <sys/stat.h>
40

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

662 pjdlog_warning("Extent size differs between nodes (local=%zd, remote=%zd).",
663 (ssize_t)res->hr_extentsize, (ssize_t)extentsize);
664 nv_free(nvin);
665 goto close;
666 }
667 res->hr_secondary_localcnt = nv_get_uint64(nvin, "localcnt");
668 res->hr_secondary_remotecnt = nv_get_uint64(nvin, "remotecnt");
669 res->hr_syncsrc = nv_get_uint8(nvin, "syncsrc");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/refcount.h>
39#include <sys/stat.h>
40

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

662 pjdlog_warning("Extent size differs between nodes (local=%zd, remote=%zd).",
663 (ssize_t)res->hr_extentsize, (ssize_t)extentsize);
664 nv_free(nvin);
665 goto close;
666 }
667 res->hr_secondary_localcnt = nv_get_uint64(nvin, "localcnt");
668 res->hr_secondary_remotecnt = nv_get_uint64(nvin, "remotecnt");
669 res->hr_syncsrc = nv_get_uint8(nvin, "syncsrc");
670 if (nv_exists(nvin, "virgin")) {
671 /*
672 * Secondary was reinitialized, bump localcnt if it is 0 as
673 * only we have the data.
674 */
675 PJDLOG_ASSERT(res->hr_syncsrc == HAST_SYNCSRC_PRIMARY);
676 PJDLOG_ASSERT(res->hr_secondary_localcnt == 0);
677
678 if (res->hr_primary_localcnt == 0) {
679 PJDLOG_ASSERT(res->hr_secondary_remotecnt == 0);
680
681 mtx_lock(&metadata_lock);
682 res->hr_primary_localcnt++;
683 pjdlog_debug(1, "Increasing localcnt to %ju.",
684 (uintmax_t)res->hr_primary_localcnt);
685 (void)metadata_write(res);
686 mtx_unlock(&metadata_lock);
687 }
688 }
670 map = NULL;
671 mapsize = nv_get_uint32(nvin, "mapsize");
672 if (mapsize > 0) {
673 map = malloc(mapsize);
674 if (map == NULL) {
675 pjdlog_error("Unable to allocate memory for remote activemap (mapsize=%ju).",
676 (uintmax_t)mapsize);
677 nv_free(nvin);

--- 1471 unchanged lines hidden ---
689 map = NULL;
690 mapsize = nv_get_uint32(nvin, "mapsize");
691 if (mapsize > 0) {
692 map = malloc(mapsize);
693 if (map == NULL) {
694 pjdlog_error("Unable to allocate memory for remote activemap (mapsize=%ju).",
695 (uintmax_t)mapsize);
696 nv_free(nvin);

--- 1471 unchanged lines hidden ---