summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-08-03 14:22:04 -0400
committerSteve Dickson <steved@redhat.com>2016-08-03 14:25:15 -0400
commit188354e57dd8476e66ce30d647180a106da29b88 (patch)
tree4fdaac685b79f577254ebc0de13bbf8fa19c4072
parent2375c47bd7ee1935d5d3ff603f7e346e4ff03088 (diff)
downloadnfs-utils-188354e57dd8476e66ce30d647180a106da29b88.tar.gz
mountd: fail nfsd.export lookup for path to unmounted exportpointnfs-utils-1-3-4-rc7nfs-utils-1-3-4
If an export point should be mounted ("mountpoint" option set) but isn't, then an attempt to mount using the MOUNT protocol for NFSv3 will fail and an attempt to access the filesystem using a pre-existing filehandle will block because nfsd_fh wont tell the kernel about it. However a lookup from the parent, as happens with an NFSv4 mount request, will pass the name to nfsd_export(), and it doesn't check the mointpoint option, and so exports the underlying (typically "/") filesystem. So change nfsd_export() to refused to export that exportpoint, but instead to explictly say that it isn't exported. This will cause an 'ls' in the parent pseudo-root directory to not show the name and will cause a "mount" attempt which walks down through the pseudo root to fail in the same way that it does with NFSv3. An access from a pre-existing NFSv4 mount will still hang until the filesystem is mounted, just like it does with NFSv3. In order to be a bit more responsive to the filesystem getting mounted, just a short timeout (1 minutes) on exports of missing "mountpoint" exportpoints. Acked-by: J. Bruce Fields <bfields@fieldses.org> Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/mountd/cache.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 9cc2706..ca6c84f 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -1334,7 +1334,23 @@ static void nfsd_export(int f)
found = lookup_export(dom, path, ai);
if (found) {
- if (dump_to_cache(f, buf, sizeof(buf), dom, path, &found->m_export, 0) < 0) {
+ char *mp = found->m_export.e_mountpoint;
+
+ if (mp && !*mp)
+ mp = found->m_export.e_path;
+ if (mp && !is_mountpoint(mp))
+ /* Exportpoint is not mounted, so tell kernel it is
+ * not available.
+ * This will cause it not to appear in the V4 Pseudo-root
+ * and so a "mount" of this path will fail, just like with
+ * V3.
+ * And filehandle for this mountpoint from an earlier
+ * mount will block in nfsd.fh lookup.
+ */
+ dump_to_cache(f, buf, sizeof(buf), dom, path,
+ NULL, 60);
+ else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
+ &found->m_export, 0) < 0) {
xlog(L_WARNING,
"Cannot export %s, possibly unsupported filesystem"
" or fsid= required", path);