Subject: Exports list management, take 3
To: None <tech-kern@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 09/17/2005 14:44:00
Hi again,

after reading many comments about how to do the exports list
management thing (and after implementing all of them *many*
times) it seems to me that the best way to go is what Chuck
suggested: extend nfssvc(2) to allow this new operation.

fcntl(2) can do the job but it's inappropriate.  We are not managing
file descriptors, so adding the functionality there is conceptually
incorrect.

fsctl(2) could be the best solution if we didn't have nfssvc(2).  However,
as we already have a system call dedicated to NFS stuff, it seems to
me that the best move is to add the new functionality there (which also
has some benefits, as seen below).

Take a look at the patch at:
    ftp://ftp.NetBSD.org/pub/NetBSD/misc/jmmv/export.diff

What it does is:
- Remove NFS export list handling from file system specific code,
  making the file systems set a single flag indicating whether they
  support NFS or not.  (The patch only does a part of this, but work
  on all other file systems will be done before commiting.)
- Drop the vfs_checkexp hook because it can be easily generalized
  (see the new nfs_check_export function).
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
  file nfs/nfs_export.c.  The former was becoming large and its code
  is always compiled, regardless of the build options.  Using the
  latter, the code is only compiled in when NFSSERVER is enabled.
  While doing this, also make some functions in nfs_subs.c conditional
  to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST,
  that takes a path and a set of export entries.  At the moment it can
  only clear the exports list or append entries, one by one, but it is
  done in a way that allows setting the whole set of entries atomically
  in the future (see the comment in mountd_set_exports_list or in
  TODO.nits).
- Change mountd(8) to use the nfssvc(2) system call instead of
  mount(2) so that it becomes file system agnostic.  Also clear exports
  upon SIGTERM (any reason why this wasn't done before?).
- Change the mount_* commands to not deal with NFS stuff; done
  internally by the kernel when initializing the NFS support for each
  file system.

Comments, please?

Thanks,

--=20
Julio M. Merino Vidal <jmmv84@gmail.com>
http://www.livejournal.com/users/jmmv/
The NetBSD Project - http://www.NetBSD.org/