[Cause found, no patch yet] knfsd: nfs_revalidate_inode fails.

David Woodhouse (David.Woodhouse@mvhi.com)
Wed, 18 Nov 1998 00:04:04 +0000


OK, I think I've found the reason why I get NFS failures when rebooting the
server.

We have two partitions for home directories: /home_1 and /home_2.
We have wildcard export entries for each partition in /etc/exports:
/home_1 10.0.0.0/255.0.0.0(rw,no_root_squash)
/home_2 10.0.0.0/255.0.0.0(rw,no_root_squash)

Individual home directories are mounted on the clients in /homes/$(user) using
autofs.

With this setup, when clients attempt to mount a home directory, kmountd
adds an explicit export entry for that _subdirectory_:

server /proc/fs/nfs $ egrep home.*devel2 exports
/home_2/pican devel2.axiom.internal(rw,no_root_squash,async,wdelay) # 10.0.1.4
/home_2/wfc devel2.axiom.internal(rw,no_root_squash,async,wdelay) # 10.0.1.4
/home_2/elaine devel2.axiom.internal(rw,no_root_squash,async,wdelay) # 10.0.1.4
/home_2/dwmw2 devel2.axiom.internal(rw,no_root_squash,async,wdelay) # 10.0.1.4
/home_1/cjd devel2.axiom.internal(rw,no_root_squash,async,wdelay) # 10.0.1.4

But if I then use amd ('cd /net/server'), it tries to mount the root
directories of each partition: /home_1 and /home_2. This now fails, and the
server complains: "(export not valid (Rule 3)"

However, if start with a clean NFS server, and I use amd _first_, then kmountd
adds an explicit export entry for the _partition_. Later autofs mounts of home
directories work OK, but the server complains "sub-export not valid (Rule 2)"
because kmountd attempts to add the export entry for the subdirectory even
though the partition is already exported.

The above is the cause of the problems I've been seeing...

If a subdirectory is mounted in the first case, (when only the subdirectories
are in the kernel's export list), and the export list is later changed to
export the partition, then I see stale NFS file handles.

Likewise vice versa - when a mount of a subdirectory was allowed because the
whole partition is exported, and the exports list is later changed to only
include the directory that's mounted.

It seems to be non-deterministic which case (either partition or subdirs
exported) will occur each time the server boots. Presumably it's related to
whether it's amd or autofs which tries to access the NFS server first.

I believe that the logic for handling subdirectory mounts is faulty. What it
does at the moment is add the directory in the _request_ to the export list.
What it should do is add the directory in the configured _export_ instead.¹
That way it would be deterministic, and the problem would never occur.

I'm about to go and look into the code further to fix this myself, and
hopefully a patch should follow shortly.

¹ Note that I'm not saying that we should unconditionally export the whole
partition if a subdirectory is configured to be exported. That would be a
blatant breach of security. What I'm saying is that when we have been
configured to export the partition, but the client only requests a
subdirectory, we should actually export the partition anyway.

---- ---- ----
David Woodhouse David.Woodhouse@mvhi.com Office: (+44) 1223 810302
Project Leader, Process Information Systems Mobile: (+44) 976 658355
Axiom (Cambridge) Ltd., Swaffham Bulbeck, Cambridge, CB5 0NA, UK.
finger dwmw2@ferret.lmh.ox.ac.uk for PGP key.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/