summaryrefslogtreecommitdiffstats
path: root/sbin/hastd
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/hastd')
-rw-r--r--sbin/hastd/Makefile3
-rw-r--r--sbin/hastd/activemap.c13
-rw-r--r--sbin/hastd/control.c3
-rw-r--r--sbin/hastd/primary.c9
-rw-r--r--sbin/hastd/secondary.c4
-rw-r--r--sbin/hastd/subr.c12
6 files changed, 32 insertions, 12 deletions
diff --git a/sbin/hastd/Makefile b/sbin/hastd/Makefile
index 1ffd0a2..3c4eef1 100644
--- a/sbin/hastd/Makefile
+++ b/sbin/hastd/Makefile
@@ -20,8 +20,9 @@ SRCS+= y.tab.h
MAN= hastd.8 hast.conf.5
NO_WFORMAT=
-CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457
CFLAGS+=-I${.CURDIR}
+CFLAGS+=-DHAVE_CAPSICUM
+CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457
CFLAGS+=-DINET
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+=-DINET6
diff --git a/sbin/hastd/activemap.c b/sbin/hastd/activemap.c
index 2777ac5..127b2c8 100644
--- a/sbin/hastd/activemap.c
+++ b/sbin/hastd/activemap.c
@@ -205,7 +205,7 @@ keepdirty_find(struct activemap *amp, int extent)
return (kd);
}
-static void
+static bool
keepdirty_add(struct activemap *amp, int extent)
{
struct keepdirty *kd;
@@ -217,7 +217,7 @@ keepdirty_add(struct activemap *amp, int extent)
*/
TAILQ_REMOVE(&amp->am_keepdirty, kd, kd_next);
TAILQ_INSERT_HEAD(&amp->am_keepdirty, kd, kd_next);
- return;
+ return (false);
}
/*
* Add new element, but first remove the most unused one if
@@ -238,6 +238,8 @@ keepdirty_add(struct activemap *amp, int extent)
amp->am_nkeepdirty++;
TAILQ_INSERT_HEAD(&amp->am_keepdirty, kd, kd_next);
}
+
+ return (true);
}
static void
@@ -308,9 +310,9 @@ activemap_write_start(struct activemap *amp, off_t offset, off_t length)
assert(!bit_test(amp->am_memmap, ext));
bit_set(amp->am_memmap, ext);
amp->am_ndirty++;
- modified = true;
}
- keepdirty_add(amp, ext);
+ if (keepdirty_add(amp, ext))
+ modified = true;
}
return (modified);
@@ -345,7 +347,8 @@ activemap_write_complete(struct activemap *amp, off_t offset, off_t length)
if (--amp->am_memtab[ext] == 0) {
bit_clear(amp->am_memmap, ext);
amp->am_ndirty--;
- modified = true;
+ if (keepdirty_find(amp, ext) == NULL)
+ modified = true;
}
}
diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c
index 4d00403..57a1c8a 100644
--- a/sbin/hastd/control.c
+++ b/sbin/hastd/control.c
@@ -155,8 +155,7 @@ control_status_worker(struct hast_resource *res, struct nv *nvout,
const char *str;
int error;
- cnvin = cnvout = NULL;
- error = 0;
+ cnvin = NULL;
/*
* Prepare and send command to worker process.
diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c
index abda5cb..dd414f8 100644
--- a/sbin/hastd/primary.c
+++ b/sbin/hastd/primary.c
@@ -726,11 +726,13 @@ init_remote(struct hast_resource *res, struct proto_conn **inp,
(void)hast_activemap_flush(res);
}
nv_free(nvin);
+#ifdef notyet
/* Setup directions. */
if (proto_send(out, NULL, 0) == -1)
pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
if (proto_recv(in, NULL, 0) == -1)
pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
+#endif
pjdlog_info("Connected to %s.", res->hr_remoteaddr);
if (inp != NULL && outp != NULL) {
*inp = in;
@@ -1685,8 +1687,11 @@ ggate_send_thread(void *arg)
}
if (ggio->gctl_error == 0 && ggio->gctl_cmd == BIO_WRITE) {
mtx_lock(&res->hr_amp_lock);
- activemap_write_complete(res->hr_amp,
- ggio->gctl_offset, ggio->gctl_length);
+ if (activemap_write_complete(res->hr_amp,
+ ggio->gctl_offset, ggio->gctl_length)) {
+ res->hr_stat_activemap_update++;
+ (void)hast_activemap_flush(res);
+ }
mtx_unlock(&res->hr_amp_lock);
}
if (ggio->gctl_cmd == BIO_WRITE) {
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index 1597af8..7120d3d 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -183,9 +183,11 @@ init_remote(struct hast_resource *res, struct nv *nvin)
unsigned char *map;
size_t mapsize;
+#ifdef notyet
/* Setup direction. */
if (proto_send(res->hr_remoteout, NULL, 0) == -1)
pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
+#endif
map = NULL;
mapsize = 0;
@@ -351,9 +353,11 @@ init_remote(struct hast_resource *res, struct nv *nvin)
if (map != NULL)
free(map);
nv_free(nvout);
+#ifdef notyet
/* Setup direction. */
if (proto_recv(res->hr_remotein, NULL, 0) == -1)
pjdlog_errno(LOG_WARNING, "Unable to set connection direction");
+#endif
if (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&
res->hr_primary_localcnt > res->hr_secondary_remotecnt) {
/* Exit on split-brain. */
diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c
index 806338b..89ffda0 100644
--- a/sbin/hastd/subr.c
+++ b/sbin/hastd/subr.c
@@ -31,7 +31,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef HAVE_CAPSICUM
#include <sys/capability.h>
+#endif
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/ioctl.h>
@@ -230,9 +232,15 @@ drop_privs(struct hast_resource *res)
* ioctls and secondary uses ioctls to handle BIO_DELETE and BIO_FLUSH.
* For now capsicum is only used to sandbox hastctl.
*/
- if (res == NULL)
+#ifdef HAVE_CAPSICUM
+ if (res == NULL) {
capsicum = (cap_enter() == 0);
- else
+ if (!capsicum) {
+ pjdlog_common(LOG_DEBUG, 1, errno,
+ "Unable to sandbox using capsicum");
+ }
+ } else
+#endif
capsicum = false;
/*
OpenPOWER on IntegriCloud