Source-Changes-HG archive

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

[src/trunk]: src/sys/nfs Add flag/command NFSSVC_REPLACEEXPORTSLIST to nfssvc...



details:   https://anonhg.NetBSD.org/src/rev/74cf5a8eee9f
branches:  trunk
changeset: 1021545:74cf5a8eee9f
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Jun 04 10:44:58 2021 +0000

description:
Add flag/command NFSSVC_REPLACEEXPORTSLIST to nfssvc(2) system call.

Works like NFSSVC_SETEXPORTSLIST but supports "mel_nexports > 1"
and will atomically update the complete exports list for a file system.

diffstat:

 sys/nfs/nfs.h          |   3 ++-
 sys/nfs/nfs_export.c   |  50 ++++++++++++++++++++------------------------------
 sys/nfs/nfs_syscalls.c |   9 +++++----
 sys/nfs/nfs_var.h      |   4 ++--
 4 files changed, 29 insertions(+), 37 deletions(-)

diffs (166 lines):

diff -r c630f31648b8 -r 74cf5a8eee9f sys/nfs/nfs.h
--- a/sys/nfs/nfs.h     Fri Jun 04 08:57:05 2021 +0000
+++ b/sys/nfs/nfs.h     Fri Jun 04 10:44:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs.h,v 1.78 2018/08/22 01:05:24 msaitoh Exp $ */
+/*     $NetBSD: nfs.h,v 1.79 2021/06/04 10:44:58 hannken Exp $ */
 /*
  * Copyright (c) 1989, 1993, 1995
  *     The Regents of the University of California.  All rights reserved.
@@ -285,6 +285,7 @@
 #define        NFSSVC_AUTHINFAIL 0x080
 #define        NFSSVC_MNTD     0x100
 #define        NFSSVC_SETEXPORTSLIST   0x200
+#define        NFSSVC_REPLACEEXPORTSLIST       0x400
 
 /*
  * fs.nfs sysctl(3) identifiers
diff -r c630f31648b8 -r 74cf5a8eee9f sys/nfs/nfs_export.c
--- a/sys/nfs/nfs_export.c      Fri Jun 04 08:57:05 2021 +0000
+++ b/sys/nfs/nfs_export.c      Fri Jun 04 10:44:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $       */
+/*     $NetBSD: nfs_export.c,v 1.63 2021/06/04 10:44:58 hannken Exp $  */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008, 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.63 2021/06/04 10:44:58 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -233,17 +233,14 @@
  * Returns zero on success or an appropriate error code otherwise.
  *
  * Helper function for the nfssvc(2) system call (NFSSVC_SETEXPORTSLIST
- * command).
+ * and NFSSVC_REPLACEEXPORTSLIST command).
  */
 int
 mountd_set_exports_list(const struct mountd_exports_list *mel, struct lwp *l,
-    struct mount *nmp)
+    struct mount *nmp, int cmd)
 {
        int error;
-#ifdef notyet
-       /* XXX: See below to see the reason why this is disabled. */
        size_t i;
-#endif
        struct mount *mp;
        struct netexport *ne;
        struct pathbuf *pb;
@@ -302,31 +299,24 @@
        KASSERT(ne != NULL);
        KASSERT(ne->ne_mount == mp);
 
-       /*
-        * XXX: The part marked as 'notyet' works fine from the kernel's
-        * point of view, in the sense that it is able to atomically update
-        * the complete exports list for a file system.  However, supporting
-        * this in mountd(8) requires a lot of work; so, for now, keep the
-        * old behavior of updating a single entry per call.
-        *
-        * When mountd(8) is fixed, just remove the second branch of this
-        * preprocessor conditional and enable the first one.
-        */
-#ifdef notyet
-       netexport_clear(ne);
-       for (i = 0; error == 0 && i < mel->mel_nexports; i++)
-               error = export(ne, &mel->mel_exports[i]);
-#else
-       if (mel->mel_nexports == 0)
+       if (cmd == NFSSVC_SETEXPORTSLIST) {
+               if (mel->mel_nexports == 0)
+                       netexport_clear(ne);
+               else if (mel->mel_nexports == 1)
+                       error = export(ne, &mel->mel_exports[0]);
+               else {
+                       printf("%s: Cannot set more than one "
+                           "entry at once (unimplemented)\n", __func__);
+                       error = EOPNOTSUPP;
+               }
+       } else if (cmd == NFSSVC_REPLACEEXPORTSLIST) {
                netexport_clear(ne);
-       else if (mel->mel_nexports == 1)
-               error = export(ne, &mel->mel_exports[0]);
-       else {
-               printf("%s: Cannot set more than one "
-                   "entry at once (unimplemented)\n", __func__);
+               for (i = 0; error == 0 && i < mel->mel_nexports; i++)
+                       error = export(ne, &mel->mel_exports[i]);
+       } else {
+               printf("%s: Command %#x not implemented\n", __func__, cmd);
                error = EOPNOTSUPP;
        }
-#endif
 
 out:
        netexport_wrunlock();
@@ -455,7 +445,7 @@
                mel.mel_exports = (void *)&args->eargs;
        }
 
-       return mountd_set_exports_list(&mel, curlwp, mp);
+       return mountd_set_exports_list(&mel, curlwp, mp, NFSSVC_SETEXPORTSLIST);
 }
 
 /*
diff -r c630f31648b8 -r 74cf5a8eee9f sys/nfs/nfs_syscalls.c
--- a/sys/nfs/nfs_syscalls.c    Fri Jun 04 08:57:05 2021 +0000
+++ b/sys/nfs/nfs_syscalls.c    Fri Jun 04 10:44:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_syscalls.c,v 1.162 2020/03/14 18:08:39 ad Exp $    */
+/*     $NetBSD: nfs_syscalls.c,v 1.163 2021/06/04 10:44:58 hannken Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.162 2020/03/14 18:08:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.163 2021/06/04 10:44:58 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -340,7 +340,7 @@
                }
                error = nfssvc_addsock(fp, nam);
                fd_putfile(nfsdarg.sock);
-       } else if (flag & NFSSVC_SETEXPORTSLIST) {
+       } else if (flag & (NFSSVC_SETEXPORTSLIST | NFSSVC_REPLACEEXPORTSLIST)) {
                struct export_args *args;
                struct mountd_exports_list mel;
 
@@ -357,7 +357,8 @@
                }
                mel.mel_exports = args;
 
-               error = mountd_set_exports_list(&mel, l, NULL);
+               error = mountd_set_exports_list(&mel, l, NULL,
+                   flag & (NFSSVC_SETEXPORTSLIST | NFSSVC_REPLACEEXPORTSLIST));
 
                free(args, M_TEMP);
        } else {
diff -r c630f31648b8 -r 74cf5a8eee9f sys/nfs/nfs_var.h
--- a/sys/nfs/nfs_var.h Fri Jun 04 08:57:05 2021 +0000
+++ b/sys/nfs/nfs_var.h Fri Jun 04 10:44:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_var.h,v 1.94 2015/07/15 03:28:55 manu Exp $        */
+/*     $NetBSD: nfs_var.h,v 1.95 2021/06/04 10:44:58 hannken Exp $     */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -356,7 +356,7 @@
 /* nfs_export.c */
 extern struct nfs_public nfs_pub;
 int mountd_set_exports_list(const struct mountd_exports_list *, struct lwp *,
-    struct mount *);
+    struct mount *, int);
 int netexport_check(const fsid_t *, struct mbuf *, struct mount **, int *,
     kauth_cred_t *);
 void netexport_rdlock(void);



Home | Main Index | Thread Index | Old Index