From adc1f44b7fbdd61b24b4e9ba3e64fdac42c80e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Mon, 28 Aug 2017 09:38:14 +0200 Subject: [PATCH] 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. --- heartbeat/exportfs | 61 ++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/heartbeat/exportfs b/heartbeat/exportfs index e70dbd3aa7..a51b1314e9 100755 --- a/heartbeat/exportfs +++ b/heartbeat/exportfs @@ -76,7 +76,7 @@ The directory or directories to export. - + The fsid option to pass to exportfs. This can be a unique positive integer, a UUID (assuredly sans comma characters), or the special string @@ -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 @@ -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" @@ -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 @@ -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 @@ -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 $*