Skip to content

High: exportfs: Make fsid optional (bsc#1045161) #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions heartbeat/exportfs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The directory or directories to export.
<content type="string" />
</parameter>

<parameter name="fsid" unique="1" required="1">
<parameter name="fsid" unique="1" required="0">
<longdesc lang="en">
The fsid option to pass to exportfs. This can be a unique positive
integer, a UUID (assuredly sans comma characters), or the special string
Expand Down Expand Up @@ -197,11 +197,11 @@ forall() {
fast_exit=1
shift 1
fi
reset_fsid
[ -n "$(get_fsid)" ] && reset_fsid
for dir in $OCF_RESKEY_directory; do
$func $dir "$@"
rc=$(($rc | $?))
[ $NUMDIRS -gt 1 ] && bump_fsid
[ $NUMDIRS -gt 1 ] && [ -n "$(get_fsid)" ] && bump_fsid
[ "$fast_exit" ] && continue
[ $rc -ne 0 ] && return $rc
done
Expand Down Expand Up @@ -291,12 +291,14 @@ export_one() {
opts="$OCF_RESKEY_options"
sep=","
fi
if echo "$opts" | grep fsid >/dev/null; then
#replace fsid in options list
opts=`echo "$opts" | sed "s,fsid=[^,]*,fsid=$(get_fsid),g"`
else
#tack the fsid option onto our options list.
opts="${opts}${sep}fsid=$(get_fsid)"
if [ -n "$(get_fsid)" ]; then
if echo "$opts" | grep fsid >/dev/null; then
#replace fsid in options list
opts=`echo "$opts" | sed "s,fsid=[^,]*,fsid=$(get_fsid),g"`
else
#tack the fsid option onto our options list.
opts="${opts}${sep}fsid=$(get_fsid)"
fi
fi
opts="-o $opts"

Expand Down Expand Up @@ -353,18 +355,21 @@ wait_for_leasetime() {
}
cleanup_export_cache() {
# see if the cache is blocking unexport
# TODO: this doesn't work without fsid
local contentfile=/proc/net/rpc/nfsd.export/content
local fsid_re
local i=1
fsid_re="fsid=(echo `forall get_fsid`|sed 's/ /|/g'),"
while :; do
grep -E -q "$fsid_re" $contentfile ||
break
ocf_log info "Cleanup export cache ... (try $i)"
ocf_run exportfs -f
sleep 0.5
i=$((i + 1))
done
if [ -n "$(get_fsid)" ]; then
fsid_re="fsid=(echo `forall get_fsid`|sed 's/ /|/g'),"
while :; do
grep -E -q "$fsid_re" $contentfile ||
break
ocf_log info "Cleanup export cache ... (try $i)"
ocf_run exportfs -f
sleep 0.5
i=$((i + 1))
done
fi
}
unexport_one() {
local dir=$1
Expand Down Expand Up @@ -420,14 +425,16 @@ testdir() {
}
exportfs_validate_all ()
{
if echo "$OCF_RESKEY_fsid" | grep -q -F ','; then
ocf_exit_reason "$OCF_RESKEY_fsid cannot contain a comma"
return $OCF_ERR_CONFIGURED
fi
if [ $NUMDIRS -gt 1 ] &&
! ocf_is_decimal "$OCF_RESKEY_fsid"; then
ocf_exit_reason "use integer fsid when exporting multiple directories"
return $OCF_ERR_CONFIGURED
if [ -n "$OCF_RESKEY_fsid" ]; then
if echo "$OCF_RESKEY_fsid" | grep -q -F ','; then
ocf_exit_reason "$OCF_RESKEY_fsid cannot contain a comma"
return $OCF_ERR_CONFIGURED
fi
if [ $NUMDIRS -gt 1 ] &&
! ocf_is_decimal "$OCF_RESKEY_fsid"; then
ocf_exit_reason "use integer fsid when exporting multiple directories"
return $OCF_ERR_CONFIGURED
fi
fi
if ! forall testdir; then
return $OCF_ERR_INSTALLED
Expand All @@ -444,6 +451,6 @@ if [ -n "$newdir" ]; then
fi

NUMDIRS=`echo "$OCF_RESKEY_directory" | wc -w`
OCF_REQUIRED_PARAMS="directory fsid clientspec"
OCF_REQUIRED_PARAMS="directory clientspec"
OCF_REQUIRED_BINARIES="exportfs"
ocf_rarun $*