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 225786 2011-09-27 08:26:09Z 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
--- 250 unchanged lines hidden (view full) ---
291 buf = activemap_bitmap(res->hr_amp, &size);
292 PJDLOG_ASSERT(buf != NULL);
293 PJDLOG_ASSERT((size % res->hr_local_sectorsize) == 0);
294 if (pwrite(res->hr_localfd, buf, size, METADATA_SIZE) !=
295 (ssize_t)size) {
296 pjdlog_errno(LOG_ERR, "Unable to flush activemap to disk");
297 return (-1);
298 }
299 return (0);
300}
301
302static bool
303real_remote(const struct hast_resource *res)
304{
305
306 return (strcmp(res->hr_remoteaddr, "none") != 0);
--- 1687 unchanged lines hidden (view full) ---
1994 PJDLOG_ASSERT(gres == res);
1995 nv_assert(nv, "remoteaddr");
1996 nv_assert(nv, "sourceaddr");
1997 nv_assert(nv, "replication");
1998 nv_assert(nv, "checksum");
1999 nv_assert(nv, "compression");
2000 nv_assert(nv, "timeout");
2001 nv_assert(nv, "exec");
2002
2003 ncomps = HAST_NCOMPONENTS;
2004
2005#define MODIFIED_REMOTEADDR 0x01
2006#define MODIFIED_SOURCEADDR 0x02
2007#define MODIFIED_REPLICATION 0x04
2008#define MODIFIED_CHECKSUM 0x08
2009#define MODIFIED_COMPRESSION 0x10
2010#define MODIFIED_TIMEOUT 0x20
2011#define MODIFIED_EXEC 0x40
2012 modified = 0;
2013
2014 vstr = nv_get_string(nv, "remoteaddr");
2015 if (strcmp(gres->hr_remoteaddr, vstr) != 0) {
2016 /*
2017 * Don't copy res->hr_remoteaddr to gres just yet.
2018 * We want remote_close() to log disconnect from the old
2019 * addresses, not from the new ones.
--- 25 unchanged lines hidden (view full) ---
2045 gres->hr_timeout = vint;
2046 modified |= MODIFIED_TIMEOUT;
2047 }
2048 vstr = nv_get_string(nv, "exec");
2049 if (strcmp(gres->hr_exec, vstr) != 0) {
2050 strlcpy(gres->hr_exec, vstr, sizeof(gres->hr_exec));
2051 modified |= MODIFIED_EXEC;
2052 }
2053
2054 /*
2055 * Change timeout for connected sockets.
2056 * Don't bother if we need to reconnect.
2057 */
2058 if ((modified & MODIFIED_TIMEOUT) != 0 &&
2059 (modified & (MODIFIED_REMOTEADDR | MODIFIED_SOURCEADDR |
2060 MODIFIED_REPLICATION)) == 0) {
--- 33 unchanged lines hidden (view full) ---
2094 }
2095#undef MODIFIED_REMOTEADDR
2096#undef MODIFIED_SOURCEADDR
2097#undef MODIFIED_REPLICATION
2098#undef MODIFIED_CHECKSUM
2099#undef MODIFIED_COMPRESSION
2100#undef MODIFIED_TIMEOUT
2101#undef MODIFIED_EXEC
2102
2103 pjdlog_info("Configuration reloaded successfully.");
2104}
2105
2106static void
2107guard_one(struct hast_resource *res, unsigned int ncomp)
2108{
2109 struct proto_conn *in, *out;
--- 107 unchanged lines hidden ---
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 225786 2011-09-27 08:26:09Z 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
--- 250 unchanged lines hidden (view full) ---
291 buf = activemap_bitmap(res->hr_amp, &size);
292 PJDLOG_ASSERT(buf != NULL);
293 PJDLOG_ASSERT((size % res->hr_local_sectorsize) == 0);
294 if (pwrite(res->hr_localfd, buf, size, METADATA_SIZE) !=
295 (ssize_t)size) {
296 pjdlog_errno(LOG_ERR, "Unable to flush activemap to disk");
297 return (-1);
298 }
299 return (0);
300}
301
302static bool
303real_remote(const struct hast_resource *res)
304{
305
306 return (strcmp(res->hr_remoteaddr, "none") != 0);
--- 1687 unchanged lines hidden (view full) ---
1994 PJDLOG_ASSERT(gres == res);
1995 nv_assert(nv, "remoteaddr");
1996 nv_assert(nv, "sourceaddr");
1997 nv_assert(nv, "replication");
1998 nv_assert(nv, "checksum");
1999 nv_assert(nv, "compression");
2000 nv_assert(nv, "timeout");
2001 nv_assert(nv, "exec");
2002
2003 ncomps = HAST_NCOMPONENTS;
2004
2005#define MODIFIED_REMOTEADDR 0x01
2006#define MODIFIED_SOURCEADDR 0x02
2007#define MODIFIED_REPLICATION 0x04
2008#define MODIFIED_CHECKSUM 0x08
2009#define MODIFIED_COMPRESSION 0x10
2010#define MODIFIED_TIMEOUT 0x20
2011#define MODIFIED_EXEC 0x40
2012 modified = 0;
2013
2014 vstr = nv_get_string(nv, "remoteaddr");
2015 if (strcmp(gres->hr_remoteaddr, vstr) != 0) {
2016 /*
2017 * Don't copy res->hr_remoteaddr to gres just yet.
2018 * We want remote_close() to log disconnect from the old
2019 * addresses, not from the new ones.
--- 25 unchanged lines hidden (view full) ---
2045 gres->hr_timeout = vint;
2046 modified |= MODIFIED_TIMEOUT;
2047 }
2048 vstr = nv_get_string(nv, "exec");
2049 if (strcmp(gres->hr_exec, vstr) != 0) {
2050 strlcpy(gres->hr_exec, vstr, sizeof(gres->hr_exec));
2051 modified |= MODIFIED_EXEC;
2052 }
2053
2054 /*
2055 * Change timeout for connected sockets.
2056 * Don't bother if we need to reconnect.
2057 */
2058 if ((modified & MODIFIED_TIMEOUT) != 0 &&
2059 (modified & (MODIFIED_REMOTEADDR | MODIFIED_SOURCEADDR |
2060 MODIFIED_REPLICATION)) == 0) {
--- 33 unchanged lines hidden (view full) ---
2094 }
2095#undef MODIFIED_REMOTEADDR
2096#undef MODIFIED_SOURCEADDR
2097#undef MODIFIED_REPLICATION
2098#undef MODIFIED_CHECKSUM
2099#undef MODIFIED_COMPRESSION
2100#undef MODIFIED_TIMEOUT
2101#undef MODIFIED_EXEC
2102
2103 pjdlog_info("Configuration reloaded successfully.");
2104}
2105
2106static void
2107guard_one(struct hast_resource *res, unsigned int ncomp)
2108{
2109 struct proto_conn *in, *out;
--- 107 unchanged lines hidden ---