Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Apr 2006 12:56:11 +0300
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        freebsd-hackers@freebsd.org
Subject:   Atomic updates of NFS export lists
Message-ID:  <20060421095610.GA1137@pm513-1.comsys.ntu-kpi.kiev.ua>

next in thread | raw e-mail | index | archive | help
Greetings,

In my environment non-atomic updates of NFS export lists are not
acceptable.  So, I decided to correct this problem.  As the result
mountd, kern/vfs_export.c were completely rewritten, mount.h,
vfs_mount.c and nfs_srvsubs.c also got changes.

For details see kern/9619.

I changed struct export_args{} and now it has two fields:
a number of export specifications and a pointer to export
specifications array.  One export specification is a EXPC_xxx
command and corresponding data for this command.  I defined
EXPC_ADD, UPDATE, DELETE and CLEAR commands.

When mountd wants to update export list it builds an array of
export specifications and passes this array to the kernel.
Currently it always construct array of CLEAR, ADD, ADD...
form, but support for UPDATE and DELETE commands also is ready.

vfs_export.c and nfs_srvsubs.c are still Giant protected, but
do not have race conditions, previously they did not protect
own data correctly.  I saw that there is work in progress
for removing Giant from VFS, so I decided to not remove Giant
from this part.  vfs_export.c uses radix tree.

Two memory leaks were corrected.  There was memory leak if
WebNFS index file were passed several times.  And there was
memory leak when some NFS exported filesystem was unmounted.

While working on mountd I wrote simple library, which was
called "Socket configuration library" or sockconf(3), which
allows network servers to use getsockconf(3) function to
configure network sockets and to not invite own "-h host...",
"-p port...", "-t" (TCP) and "-u" (UDP) options.  What do you
think about this idea?  Read sockconf(3), sockconf(5) and
sockconf(8) manual pages.

Visible changes in mountd:

1. The "-p port" option was removed.  The "-s sockconf" option
   was added.  Now it is possible to dump configuration to
   stdout using the -t option.

2. Now it is possible to use back-slash character in exports.
   Now it is possible to use several -network options in one line.

3. Several bugs with network masks were corrected: Class A, B, C...
   masks were created incorrectly for incomplete addresses, /xx masks
   were calculated incorrectly if xx % 8 != 0.

4. mountd sends better information to showmount now.

5. Now it is safe to update export lists without receiving EPERM
   on a client side.

(I do not remember other changes.)

Now mountd does not work if there is some error in exports file.
I think this is correct behaviour and I'm ready to explain this.

In mountd everything is organized in linked lists with small
optimizations.

Open questions (not complex really, without any order, I haven't
implemented anything listed below, just to not make too many changes
at once):

1. Is ex_root field in struct export_args{} still necessary?

2. The ex_flags field from struct export_args{} now can be removed,
   since check (specs != NULL) is enough.

3. Looks like that xdr_long() should should accept uint32_t argument.

4. When filesystem is unmounted, then umount(8) also should inform
   mountd, like mount(8) does.

5. If mount(MNT_UPDATE) is called for not VV_ROOT directory, then it
   should return something != EINVAL.  Also see question 9.

6. Some better method should exist for communication between mount(8)
   and umount(8) with mountd(8).  This can be sync mounting/unmounting
   and export lists changing using PF_LOCAL socket to communicate
   with mountd.  It is not safe to send the HUP signal, mount/umount
   and update export lists.

7. Currently -public flag is not passed for address (network), but
   I think it should.  There is XXX-comment in nfs_srvsubs.c related
   to this question.  Is there some program for accessing WebNFS?

8. Is it necessary to check scope_id for IPv6 addresses in mountd?

9. What about passing export_args to the kernel using another
   syscall, for example nfssvc(2), and removing export_args
   fields from all filesystems xxx_args structures?  It would be
   possible to remove some lines from VFS_MOUNT implementations.

10. What about moving MNT_DEFEXPORTED and MNT_EXPUBLIC from mp->mnt_flag
   to netexport structure?  Are these flags very important in statfs(2)
   result?  What about removing MNT_EXRDONLY and MNT_EXPORTANON and
   using EXPF_RDONLY and EXPF_ANON instead?  (I aslo have another idea
   here.)

-----------------------------------------------------------------------

I probably forgot something to say above...

Everything is available for downloading and can be used on 6.1-RC,
I tested everything on UP i386 system:

http://comsys.ntu-kpi.kiev.ua/~simon/mountd/

SHA256 (mountd-20060421.tar.bz2) = e3f6b14468c42aeb6064a7d240955136a13f910bd12825e44096edcb8d1a6b04

Please read INSTALL before installing.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060421095610.GA1137>