Skip to content

Commit adc1f44

Browse files
committed
High: exportfs: Make fsid optional (bsc#1045161)
The fsid export option is not needed any more. There might be some strange corner cases where it can be useful, but it definitely shouldn't be assumed to be needed by default. The `fsid=0` usage used to be important for NFSv4, but this is no longer the case. It is best *not* to use `fsid=0` and to let `exportfs/mountd` create a "NFSv4 pseudo root" themselves. This is (almost) always what is wanted and is least confusing. The `fsid=N N!=0` usage was important some years ago when the device number of hard drives started to change. NFS used to use the device id, which was problematic. Setting an explicit fsid= removed the instability. However for quite some years now NFS has been using the UUID of the filesystem, rather than the device id, to identify a filesystem. So unless you have multiple filesystems with the same uuid, or are using some weird type of filesystem which doesn't have a uuid, `fsid=` isn't needed and is best avoided. So exportfs_test should be changed to not require `fsid=` any more.
1 parent 9b260cb commit adc1f44

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

heartbeat/exportfs

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The directory or directories to export.
7676
<content type="string" />
7777
</parameter>
7878
79-
<parameter name="fsid" unique="1" required="1">
79+
<parameter name="fsid" unique="1" required="0">
8080
<longdesc lang="en">
8181
The fsid option to pass to exportfs. This can be a unique positive
8282
integer, a UUID (assuredly sans comma characters), or the special string
@@ -197,11 +197,11 @@ forall() {
197197
fast_exit=1
198198
shift 1
199199
fi
200-
reset_fsid
200+
[ -n "$(get_fsid)" ] && reset_fsid
201201
for dir in $OCF_RESKEY_directory; do
202202
$func $dir "$@"
203203
rc=$(($rc | $?))
204-
[ $NUMDIRS -gt 1 ] && bump_fsid
204+
[ $NUMDIRS -gt 1 ] && [ -n "$(get_fsid)" ] && bump_fsid
205205
[ "$fast_exit" ] && continue
206206
[ $rc -ne 0 ] && return $rc
207207
done
@@ -291,12 +291,14 @@ export_one() {
291291
opts="$OCF_RESKEY_options"
292292
sep=","
293293
fi
294-
if echo "$opts" | grep fsid >/dev/null; then
295-
#replace fsid in options list
296-
opts=`echo "$opts" | sed "s,fsid=[^,]*,fsid=$(get_fsid),g"`
297-
else
298-
#tack the fsid option onto our options list.
299-
opts="${opts}${sep}fsid=$(get_fsid)"
294+
if [ -n "$(get_fsid)" ]; then
295+
if echo "$opts" | grep fsid >/dev/null; then
296+
#replace fsid in options list
297+
opts=`echo "$opts" | sed "s,fsid=[^,]*,fsid=$(get_fsid),g"`
298+
else
299+
#tack the fsid option onto our options list.
300+
opts="${opts}${sep}fsid=$(get_fsid)"
301+
fi
300302
fi
301303
opts="-o $opts"
302304

@@ -353,18 +355,21 @@ wait_for_leasetime() {
353355
}
354356
cleanup_export_cache() {
355357
# see if the cache is blocking unexport
358+
# TODO: this doesn't work without fsid
356359
local contentfile=/proc/net/rpc/nfsd.export/content
357360
local fsid_re
358361
local i=1
359-
fsid_re="fsid=(echo `forall get_fsid`|sed 's/ /|/g'),"
360-
while :; do
361-
grep -E -q "$fsid_re" $contentfile ||
362-
break
363-
ocf_log info "Cleanup export cache ... (try $i)"
364-
ocf_run exportfs -f
365-
sleep 0.5
366-
i=$((i + 1))
367-
done
362+
if [ -n "$(get_fsid)" ]; then
363+
fsid_re="fsid=(echo `forall get_fsid`|sed 's/ /|/g'),"
364+
while :; do
365+
grep -E -q "$fsid_re" $contentfile ||
366+
break
367+
ocf_log info "Cleanup export cache ... (try $i)"
368+
ocf_run exportfs -f
369+
sleep 0.5
370+
i=$((i + 1))
371+
done
372+
fi
368373
}
369374
unexport_one() {
370375
local dir=$1
@@ -420,14 +425,16 @@ testdir() {
420425
}
421426
exportfs_validate_all ()
422427
{
423-
if echo "$OCF_RESKEY_fsid" | grep -q -F ','; then
424-
ocf_exit_reason "$OCF_RESKEY_fsid cannot contain a comma"
425-
return $OCF_ERR_CONFIGURED
426-
fi
427-
if [ $NUMDIRS -gt 1 ] &&
428-
! ocf_is_decimal "$OCF_RESKEY_fsid"; then
429-
ocf_exit_reason "use integer fsid when exporting multiple directories"
430-
return $OCF_ERR_CONFIGURED
428+
if [ -n "$OCF_RESKEY_fsid" ]; then
429+
if echo "$OCF_RESKEY_fsid" | grep -q -F ','; then
430+
ocf_exit_reason "$OCF_RESKEY_fsid cannot contain a comma"
431+
return $OCF_ERR_CONFIGURED
432+
fi
433+
if [ $NUMDIRS -gt 1 ] &&
434+
! ocf_is_decimal "$OCF_RESKEY_fsid"; then
435+
ocf_exit_reason "use integer fsid when exporting multiple directories"
436+
return $OCF_ERR_CONFIGURED
437+
fi
431438
fi
432439
if ! forall testdir; then
433440
return $OCF_ERR_INSTALLED
@@ -444,6 +451,6 @@ if [ -n "$newdir" ]; then
444451
fi
445452

446453
NUMDIRS=`echo "$OCF_RESKEY_directory" | wc -w`
447-
OCF_REQUIRED_PARAMS="directory fsid clientspec"
454+
OCF_REQUIRED_PARAMS="directory clientspec"
448455
OCF_REQUIRED_BINARIES="exportfs"
449456
ocf_rarun $*

0 commit comments

Comments
 (0)