secondary.c (220007) | secondary.c (220271) |
---|---|
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 220007 2011-03-25 20:19:15Z pjd $"); | 32__FBSDID("$FreeBSD: head/sbin/hastd/secondary.c 220271 2011-04-02 09:25:13Z 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> --- 137 unchanged lines hidden (view full) --- 178static void 179init_remote(struct hast_resource *res, struct nv *nvin) 180{ 181 uint64_t resuid; 182 struct nv *nvout; 183 unsigned char *map; 184 size_t mapsize; 185 | 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> --- 137 unchanged lines hidden (view full) --- 178static void 179init_remote(struct hast_resource *res, struct nv *nvin) 180{ 181 uint64_t resuid; 182 struct nv *nvout; 183 unsigned char *map; 184 size_t mapsize; 185 |
186 /* Setup direction. */ 187 if (proto_send(res->hr_remoteout, NULL, 0) == -1) 188 pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); 189 |
|
186 map = NULL; 187 mapsize = 0; 188 nvout = nv_alloc(); 189 nv_add_int64(nvout, (int64_t)res->hr_datasize, "datasize"); 190 nv_add_int32(nvout, (int32_t)res->hr_extentsize, "extentsize"); 191 resuid = nv_get_uint64(nvin, "resuid"); 192 res->hr_primary_localcnt = nv_get_uint64(nvin, "localcnt"); 193 res->hr_primary_remotecnt = nv_get_uint64(nvin, "remotecnt"); --- 147 unchanged lines hidden (view full) --- 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); | 190 map = NULL; 191 mapsize = 0; 192 nvout = nv_alloc(); 193 nv_add_int64(nvout, (int64_t)res->hr_datasize, "datasize"); 194 nv_add_int32(nvout, (int32_t)res->hr_extentsize, "extentsize"); 195 resuid = nv_get_uint64(nvin, "resuid"); 196 res->hr_primary_localcnt = nv_get_uint64(nvin, "localcnt"); 197 res->hr_primary_remotecnt = nv_get_uint64(nvin, "remotecnt"); --- 147 unchanged lines hidden (view full) --- 345 nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize"); 346 if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) { 347 pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s", 348 res->hr_remoteaddr); 349 } 350 if (map != NULL) 351 free(map); 352 nv_free(nvout); |
353 /* Setup direction. */ 354 if (proto_recv(res->hr_remotein, NULL, 0) == -1) 355 pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); |
|
349 if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && 350 res->hr_primary_localcnt > res->hr_secondary_remotecnt) { 351 /* Exit on split-brain. */ 352 event_send(res, EVENT_SPLITBRAIN); 353 exit(EX_CONFIG); 354 } 355} 356 --- 429 unchanged lines hidden --- | 356 if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && 357 res->hr_primary_localcnt > res->hr_secondary_remotecnt) { 358 /* Exit on split-brain. */ 359 event_send(res, EVENT_SPLITBRAIN); 360 exit(EX_CONFIG); 361 } 362} 363 --- 429 unchanged lines hidden --- |