mirror of
https://github.com/versity/scoutfs.git
synced 2025-12-23 05:25:18 +00:00
The fence script we use for our single node multi-mount tests only knows how to fence by using forced unmount to destroy a mount. As of now, the tests only generate failing nodes that need to be fenced by using forced unmount as well. This results in the awkward situation where the testing fence script doesn't have anything to do because the mount is already gone. When the test fence script has nothing to do we might not notice if it isn't run. This adds explicit verification to the fencing tests that the script was really run. It adds per-invocation logging to the fence script and the test makes sure that it was run. While we're at it, we take the opportunity to tidy up some of the scripting around this. We use a sysfs file with the data device major:minor numbers so that the fencing script can find and unmount mounts without having to ask them for their rid. They may not be operational. Signed-off-by: Zach Brown <zab@versity.com>
44 lines
919 B
Bash
Executable File
44 lines
919 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 '$@'"
|
|
|
|
log() {
|
|
echo "$@" > /dev/stderr
|
|
exit 1
|
|
}
|
|
|
|
echo_fail() {
|
|
echo "$@" > /dev/stderr
|
|
exit 1
|
|
}
|
|
|
|
rid="$SCOUTFS_FENCED_REQ_RID"
|
|
|
|
for fs in /sys/fs/scoutfs/*; do
|
|
[ ! -d "$fs" ] && continue
|
|
|
|
fs_rid="$(cat $fs/rid)" || \
|
|
echo_fail "failed to get rid in $fs"
|
|
if [ "$fs_rid" != "$rid" ]; then
|
|
continue
|
|
fi
|
|
|
|
nr="$(cat $fs/data_device_maj_min)" || \
|
|
echo_fail "failed to get data device major:minor in $fs"
|
|
|
|
mnts=$(findmnt -l -n -t scoutfs -o TARGET -S $nr) || \
|
|
echo_fail "findmnt -t scoutfs -S $nr failed"
|
|
for mnt in $mnts; do
|
|
umount -f "$mnt" || \
|
|
echo_fail "umout -f $mnt failed"
|
|
done
|
|
done
|
|
|
|
exit 0
|