tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Problem with autounload of nfsserver module



On Sat, 14 Dec 2013, Christos Zoulas wrote:

In article <Pine.NEB.4.64.1312140541170.819%screamer.whooppee.com@localhost>,
Paul Goyette  <paul%whooppee.com@localhost> wrote:
I believe that the nfsserver module should not be allowed to autounload.

Consider the following sequence of events:

1. mountd is started, and calls nfssvc(2)
2. The module subsystem autoloads the nfsserver module
3. mountd continues, adding entries to the exports list

So far, everything is fine.  However....

4. When the autounload timer expires, the module subsystem unloads the
   nfsserver module
5. As part of nfsserver_modcmd(), the export list is cleared
6. The autounload completes successfully
7. At some later time, we finally get around to starting nfsd.  This
   succeeds, but the export list has been cleared, so there is nothing
   for nfsd to deliver to the clients.

So, depending on how much time it takes between starting mountd and
starting nfsd, we could end up serving an empty exports list.

The following patch prevents the module subsystem from unloading the
nfsserver module.  (Manual unloading of the module will still work.)
Comments?

Perhaps you want it to prevent it from unloading while there are exported
filesystems?

Yeah, that would work, too. :) The following patch prevents the module from being auto-unloaded if there are exported filesystems. (If a manual unload is requested, we will still forcibly delete the exports list.)


Index: nfs_export.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_export.c,v
retrieving revision 1.57
diff -u -p -r1.57 nfs_export.c
--- nfs_export.c        23 Nov 2013 14:20:46 -0000      1.57
+++ nfs_export.c        14 Dec 2013 15:06:47 -0000
@@ -225,6 +225,13 @@ netexport_fini(void)
        rw_destroy(&netexport_lock);
 }

+int
+netexport_listempty(void)
+{
+
+       return TAILQ_EMPTY(&netexport_list);
+}
+

 /*
  * Atomically set the NFS exports list of the given file system, replacing
Index: nfs_serv.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_serv.c,v
retrieving revision 1.166
diff -u -p -r1.166 nfs_serv.c
--- nfs_serv.c  14 Sep 2013 22:29:08 -0000      1.166
+++ nfs_serv.c  14 Dec 2013 15:06:47 -0000
@@ -144,6 +144,11 @@ nfsserver_modcmd(modcmd_t cmd, void *arg
                nfsrv_finicache();
                nfs_fini();
                return 0;
+       case MODULE_CMD_AUTOUNLOAD:
+               /* Don't allow auto-unload if there are any exports */
+               if (!netexport_listempty())
+                       return EBUSY;
+               /* FALLTHROUGH */
        default:
                return ENOTTY;
        }
Index: nfs_var.h
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_var.h,v
retrieving revision 1.90
diff -u -p -r1.90 nfs_var.h
--- nfs_var.h   2 Mar 2010 23:19:09 -0000       1.90
+++ nfs_var.h   14 Dec 2013 15:06:47 -0000
@@ -349,4 +349,5 @@ void netexport_rdlock(void);
 void netexport_rdunlock(void);
 void netexport_init(void);
 void netexport_fini(void);
+int netexport_listempty(void);
 #endif /* _KERNEL */


-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index