Skip to content

Commit e6bb402

Browse files
Fix auto-reexporting the root of an NFS v4 server
When exporting the root "/" of an NFS v4 server with AUTO_REEXPORT enabled; attempting to navigate to nested volumes would result in an error such as "/mnt/files is not a directory". This is because the logic that ensures the root export always has "fsid=0" was overriding the re-export logic. The updated logic correctly applies both conditions to the export. Change-Id: Iaa47fc46df16281e91037405b5d1c332b779e995
1 parent 9e70033 commit e6bb402

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

deployment/terraform-module-knfsd/resources/proxy-startup.sh

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,34 @@ NEXT_FSID=1
135135
function add_nfs_export() {
136136
local FSID
137137

138-
if [[ $1 == / ]]; then
139-
# Special handling when re-exporting root exports.
140-
# For NFS v4 the FSID of the root should be set to 0.
141-
FSID="fsid=0"
142-
elif [[ $FSID_MODE == "static" ]]; then
138+
if [[ $FSID_MODE == "static" ]]; then
143139
# Statically assign fsid numbers to exports without using the fsidd service.
144140
# This doesn't really have any advantage over FSID_MODE=local, but can be
145141
# useful for testing, debugging or troubleshooting.
146-
FSID="fsid=${NEXT_FSID}"
147-
NEXT_FSID=$((NEXT_FSID+1))
142+
143+
if [[ $1 == / ]]; then
144+
# Special handling when re-exporting root exports.
145+
# For NFS v4 the FSID of the root should be set to 0.
146+
FSID="fsid=0"
147+
else
148+
FSID="fsid=${NEXT_FSID}"
149+
NEXT_FSID=$((NEXT_FSID+1))
150+
fi
148151
else
149152
# For FSID_MODE local or external use reexport=auto-fsidnum to automatically
150-
# assign fsid numbers using the fsidd service.
153+
# assign fsid numbers using the fsidd service.
151154
# When FSID_MODE is set to external this will ensure that all the knfsd
152-
# instances in a cluster have the same fsid for each export.
155+
# instances in a cluster have the same fsid for each export.
153156
# This is less useful when FSID_MODE is set to local, but it will still
154157
# ensure the knfsd instance uses the same fsids after a reboot.
155-
FSID="reexport=auto-fsidnum"
158+
159+
if [[ $1 == / ]]; then
160+
# Special handling when re-exporting root exports.
161+
# For NFS v4 the FSID of the root should be set to 0.
162+
FSID="fsid=0,reexport=auto-fsidnum"
163+
else
164+
FSID="reexport=auto-fsidnum"
165+
fi
156166
fi
157167

158168
echo "Creating NFS share export for $1..."

docs/changes/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Fetch Ubuntu Kernel source from launchpad
44
* Display Kernel and OS version information at end of packer build
55
* Fix proxy startup script always prints "Error starting proxy"
6+
* Fix auto-reexporting the root of an NFS v4 server
67

78
## Fetch Ubuntu Kernel source from launchpad
89

@@ -17,6 +18,12 @@ useful when looking at past build logs.
1718

1819
The proxy startup script would always print the error message "Error starting proxy", even after the "Reached Proxy Startup Exit. Happy caching!" message. This was due to a typo when checking the startup_complete variable.
1920

21+
## Fix auto-reexporting the root of an NFS v4 server
22+
23+
When exporting the root "/" of an NFS v4 server with AUTO_REEXPORT enabled; attempting to navigate to nested volumes would result in an error such as "/mnt/files is not a directory".
24+
25+
This is because the logic that ensures the root export always has `fsid=0` was overriding the re-export logic. The updated logic correctly applies both conditions to the export.
26+
2027
# v1.0.0-beta7
2128

2229
* Fix error applying Terraform when nodes greater than 1

0 commit comments

Comments
 (0)