mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-03 10:55:20 +00:00
Our local fence script attempts to interpret errors executing `findmnt` as critical errors, but the program exit code explicitly returns EXIT_FAILURE when the total number of matching mount entries is zero. This can happen if the mount disappeared while we're attempting to fence the mount, but, the scoutfs sysfs files are still in place as we read them. It's a small window, but, it's a fork/exec plus full parse of /etc/fstab, and a lot can happen in the 0.015s findmnt takes on my system. There's no other exit codes from findmnt other than 0 and 1. At that point, we can only assume that if the stdout is empty, the mount isn't there anymore. Signed-off-by: Auke Kok <auke.kok@versity.com>
41 lines
822 B
Bash
Executable File
41 lines
822 B
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
#
|
|
# This fencing script is used for testing clusters of multiple mounts on
|
|
# a single host. It finds mounts to fence by looking for their rids and
|
|
# only knows how to "fence" by using forced unmount.
|
|
#
|
|
|
|
echo "$0 running rid '$SCOUTFS_FENCED_REQ_RID' ip '$SCOUTFS_FENCED_REQ_IP' args '$@'"
|
|
|
|
echo_fail() {
|
|
echo "$@" >> /dev/stderr
|
|
exit 1
|
|
}
|
|
|
|
# silence error messages
|
|
quiet_cat()
|
|
{
|
|
cat "$@" 2>/dev/null
|
|
}
|
|
|
|
rid="$SCOUTFS_FENCED_REQ_RID"
|
|
|
|
shopt -s nullglob
|
|
for fs in /sys/fs/scoutfs/*; do
|
|
fs_rid="$(quiet_cat $fs/rid)"
|
|
nr="$(quiet_cat $fs/data_device_maj_min)"
|
|
[ ! -d "$fs" -o "$fs_rid" != "$rid" ] && continue
|
|
|
|
mnt=$(findmnt -l -n -t scoutfs -o TARGET -S $nr)
|
|
[ -z "$mnt" ] && continue
|
|
|
|
if ! umount -qf "$mnt"; then
|
|
if [ -d "$fs" ]; then
|
|
echo_fail "umount -qf $mnt failed"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
exit 0
|