mirror of
https://github.com/versity/scoutfs.git
synced 2025-12-23 05:25:18 +00:00
The userspace fencing process wasn't careful about handling underlying directories that disappear while it was working. On the server/fenced side, fencing requests can linger after they've been resolved by writing 1 to fenced or error. The script could come back around to see the directory before the server finally removes it, causing all later uses of the request dir to fail. We saw this in the logs as a bunch of cat errors for the various request files. On the local fence script side, all the mounts can be in the process of being unmounted so both the /sys/fs dirs and the mount it self can be removed while we're working. For both, when we're working with the /sys/fs files we read them without logging errors and then test that the dir still exists before using what we read. When fencing a mount, we stop if findmnt doesn't find the mount and then raise a umount error if the /sys/fs dir exists after umount fails. And while we're at it, we have each scripts logging append instead of truncating (if, say, it's a log file instead of an interactive tty). Signed-off-by: Zach Brown <zab@versity.com>
42 lines
874 B
Bash
Executable File
42 lines
874 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) || \
|
|
echo_fail "findmnt -t scoutfs -S $nr failed"
|
|
[ -z "$mnt" ] && continue
|
|
|
|
if ! umount -qf "$mnt"; then
|
|
if [ -d "$fs" ]; then
|
|
echo_fail "umount -qf $mnt failed"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
exit 0
|