summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-20 17:23:17 +0300
committerPaul Buetow <paul@buetow.org>2026-06-20 17:23:17 +0300
commit6c13b6a253aec415b8ad850df4abfcecc8efbcd7 (patch)
tree466fcea5a71bc17ed3f56213aa10d424ac5853d0
parent87d8b7b36c3528b7ad14e01ac0aec06df88d6ff3 (diff)
carp: flip sink dataset read-write on MASTER takeover, read-only on BACKUP
When f1 (BACKUP) becomes MASTER, its zrepl sink dataset (zdata/sink/f0/zdata/enc/nfsdata) was kept readonly=on. NFS clients could mount and read but all writes failed with EROFS. carpcontrol.sh now sets readonly=off before starting NFS services on MASTER takeover, and restores readonly=on before stopping them on BACKUP transition so zrepl can resume receiving snapshots from f0. Without this, every controlled CARP failover to f1 left NFS read-only until manually fixed with `zfs set readonly=off`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--f3s/freebsd-hosts/carp/carpcontrol.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/f3s/freebsd-hosts/carp/carpcontrol.sh b/f3s/freebsd-hosts/carp/carpcontrol.sh
index 12f0c6b..6caa447 100644
--- a/f3s/freebsd-hosts/carp/carpcontrol.sh
+++ b/f3s/freebsd-hosts/carp/carpcontrol.sh
@@ -25,6 +25,12 @@ fi
case "$2" in
MASTER)
logger "CARP state changed to MASTER, starting services"
+ # On the BACKUP host (f1), the sink dataset is kept readonly=on so
+ # zrepl can write incoming snapshots. On MASTER takeover we flip it
+ # read-write so NFS clients can write to it.
+ if [ "$HOSTNAME" != 'f0.lan.buetow.org' ]; then
+ zfs set readonly=off zdata/sink/f0/zdata/enc/nfsdata
+ fi
service rpcbind start >/dev/null 2>&1
service mountd start >/dev/null 2>&1
service nfsd start >/dev/null 2>&1
@@ -38,6 +44,11 @@ case "$2" in
service nfsd stop >/dev/null 2>&1
service mountd stop >/dev/null 2>&1
service nfsuserd stop >/dev/null 2>&1
+ # Restore readonly=on on the sink dataset so that zrepl can resume
+ # writing incoming snapshot data from f0.
+ if [ "$HOSTNAME" != 'f0.lan.buetow.org' ]; then
+ zfs set readonly=on zdata/sink/f0/zdata/enc/nfsdata
+ fi
logger "CARP BACKUP: NFS and stunnel services stopped"
;;
*)