Re: nfs, exportfs feature?

From: Neil Brown (neilb@cse.unsw.edu.au)
Date: Wed Jun 14 2000 - 01:04:49 EST


On Wednesday June 14, rsousa@grad.physics.sunysb.edu wrote:
> Neil Brown wrote:
> >
> > On Tuesday June 13, rsousa@grad.physics.sunysb.edu wrote:
> > > Hi,
> > >
> > > I just realized that exporting a directory with an already mounted
> > > file system pins it down and it's not possible to umount it. That is:
> > >
> > > mount /dev/hda1 /tmp
> > > exportfs -r <-- export /tmp
> > > umount /tmp <-- fails (/tmp busy)
> > > exportfs -au
> > > umount /tmp <-- succeeds
> > >
> > > But if I do:
> > >
> > > exportfs -r
> > > mount /tmp
> > > umount /tmp <-- succeeds
> > >
> > > Is this right? Or not a kernel issue?
> > >
> > > This is kernel 2.2.16, knfsd-1.4.7-7 and RedHat 6.1
> > >
> > > Rui Sousa
> >
> > Yep, thats right.
> > Same as if you cd to the directory, or hold open a file in the mounted
> > filesystem or ....
>
> In all these situations the directory is actually being used.
> In the above I'm talking about when _no_ clients have mounted
> the file system trough nfs and there are no open files.

NFS is a stateless protocol, in that the server keeps no state about
the clients. It does not know if any clients have it mounted. It
does not know if any clients have any files open.
When a read request arrives, the nfs daemon effectively does
open/seek/read/close.

There are mount/unmount requests, and by matching them you can get
some idea about whether clients have anything mounted, but these are
not very reliable, and depending on the gets you quickly into trouble.

Hence the condition "if it is exported, it is inuse" rather than "if
it is mounted it is inuse".

>
> > How do you expect knfsd to export something that isn't mounted?
>
> It does so in the second example. The mount point is always and are
> exporting the mount point. Whatever is mounted there, if anything at all,
> should not matter.

Well, in the second example, it is not the mounted filesystem "/tmp"
that is being exported, but the underlying directory called "/tmp" in
the root filesystem the is being exported.
If a mount request arrives while /tmp is mounted on, mountd may try to
export the mounted filesystem as well, or it mught just fail, I'm not
sure.

>
> >
> > Do you have a specific problem with this, or were you just wondering?
>
> An exported filesystem mounted locally using autofs never expires.

Ah yes, that one.

What we need to solve this situation is to have a call-back from the
kernel to mountd when a request for an unexported filesystem
arrives. This has been talked about for a while and there are some
patches which have a go at it, but nobody has actually written a
generally workable solution yet. It is not very hard, but it does
require some work. I hope to do it one day - probably this year - if
nobody beats me to it, but there are other irons in the fire.

You would need to combine this with automatic expiry of unused exports
in the kernel and som reliable mechanism for mountd to convert from a
filehandle to a particular export.
This is all doable, particular in 2.4 where the format of filehandles
is a lot more general, but it jsut needs to be done.

So for now, the answer is "Sorry, you cannot unmount something that is
exported", but I hope that by 2.6, maybe even a late 2.4, the answer
will be "Yep, here is how you do it".

NeilBrown

>
> Rui Sousa
>
> -
> 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/

-
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/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:30 EST