Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/nfs Import FreeBSD's "newnfs" nfs client and server c...



details:   https://anonhg.NetBSD.org/src/rev/a20009b58b9f
branches:  trunk
changeset: 790248:a20009b58b9f
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Sep 30 07:18:57 2013 +0000

description:
Import FreeBSD's "newnfs" nfs client and server code. This contains
nfsv4 as well as new implementations of nfsv3 and nfsv2.

This import is from tonight's FreeBSD head and is unchanged from there
except for automated munging of rcsids, rearranging of paths, and an
autogenerated files.* file that might or might not be syntactically
valid. (I will check in the script that does this shortly.)

There is not the slightest chance this will configure yet, let alone
compile or run.

diffstat:

 sys/fs/nfs/client/nfs.h             |   111 +
 sys/fs/nfs/client/nfs_clbio.c       |  1889 +++++++++++
 sys/fs/nfs/client/nfs_clcomsubs.c   |   576 +++
 sys/fs/nfs/client/nfs_clkrpc.c      |   294 +
 sys/fs/nfs/client/nfs_clnfsiod.c    |   344 ++
 sys/fs/nfs/client/nfs_clnode.c      |   337 ++
 sys/fs/nfs/client/nfs_clport.c      |  1356 ++++++++
 sys/fs/nfs/client/nfs_clrpcops.c    |  5879 +++++++++++++++++++++++++++++++++++
 sys/fs/nfs/client/nfs_clstate.c     |  5218 +++++++++++++++++++++++++++++++
 sys/fs/nfs/client/nfs_clsubs.c      |   406 ++
 sys/fs/nfs/client/nfs_clvfsops.c    |  1830 ++++++++++
 sys/fs/nfs/client/nfs_clvnops.c     |  3530 +++++++++++++++++++++
 sys/fs/nfs/client/nfs_kdtrace.h     |   122 +
 sys/fs/nfs/client/nfsmount.h        |   130 +
 sys/fs/nfs/client/nfsnode.h         |   195 +
 sys/fs/nfs/client/nlminfo.h         |    43 +
 sys/fs/nfs/common/bootp_subr.c      |  1867 +++++++++++
 sys/fs/nfs/common/krpc.h            |    32 +
 sys/fs/nfs/common/krpc_subr.c       |   469 ++
 sys/fs/nfs/common/nfs.h             |   664 +++
 sys/fs/nfs/common/nfs_common.h      |   137 +
 sys/fs/nfs/common/nfs_commonacl.c   |   513 +++
 sys/fs/nfs/common/nfs_commonkrpc.c  |  1217 +++++++
 sys/fs/nfs/common/nfs_commonport.c  |   638 +++
 sys/fs/nfs/common/nfs_commonsubs.c  |  3770 ++++++++++++++++++++++
 sys/fs/nfs/common/nfs_diskless.c    |   429 ++
 sys/fs/nfs/common/nfs_fha.c         |   558 +++
 sys/fs/nfs/common/nfs_fha.h         |   114 +
 sys/fs/nfs/common/nfs_kdtrace.h     |   122 +
 sys/fs/nfs/common/nfs_lock.c        |   401 ++
 sys/fs/nfs/common/nfs_lock.h        |    94 +
 sys/fs/nfs/common/nfs_mountcommon.h |    56 +
 sys/fs/nfs/common/nfs_nfssvc.c      |   159 +
 sys/fs/nfs/common/nfs_var.h         |   659 +++
 sys/fs/nfs/common/nfscl.h           |    79 +
 sys/fs/nfs/common/nfsclstate.h      |   372 ++
 sys/fs/nfs/common/nfsdiskless.h     |   116 +
 sys/fs/nfs/common/nfsdport.h        |   119 +
 sys/fs/nfs/common/nfskpiport.h      |    75 +
 sys/fs/nfs/common/nfsm_subs.h       |   156 +
 sys/fs/nfs/common/nfsport.h         |   983 +++++
 sys/fs/nfs/common/nfsproto.h        |  1218 +++++++
 sys/fs/nfs/common/nfsrvcache.h      |   117 +
 sys/fs/nfs/common/nfsrvstate.h      |   252 +
 sys/fs/nfs/common/nfssvc.h          |    82 +
 sys/fs/nfs/common/nfsv4_errstr.h    |   103 +
 sys/fs/nfs/common/old_xdr_subs.h    |    93 +
 sys/fs/nfs/common/oldnfsproto.h     |   701 ++++
 sys/fs/nfs/common/rpcv2.h           |   209 +
 sys/fs/nfs/common/xdr_subs.h        |   101 +
 sys/fs/nfs/files.newnfs             |    44 +
 sys/fs/nfs/nlm/nlm.h                |   234 +
 sys/fs/nfs/nlm/nlm_advlock.c        |  1235 +++++++
 sys/fs/nfs/nlm/nlm_prot.h           |   450 ++
 sys/fs/nfs/nlm/nlm_prot_clnt.c      |   371 ++
 sys/fs/nfs/nlm/nlm_prot_impl.c      |  2429 ++++++++++++++
 sys/fs/nfs/nlm/nlm_prot_server.c    |   720 ++++
 sys/fs/nfs/nlm/nlm_prot_svc.c       |   527 +++
 sys/fs/nfs/nlm/nlm_prot_xdr.c       |   456 ++
 sys/fs/nfs/nlm/sm_inter.h           |   114 +
 sys/fs/nfs/nlm/sm_inter_xdr.c       |   109 +
 sys/fs/nfs/server/nfs_fha_new.c     |   274 +
 sys/fs/nfs/server/nfs_fha_new.h     |    41 +
 sys/fs/nfs/server/nfs_nfsdcache.c   |  1021 ++++++
 sys/fs/nfs/server/nfs_nfsdkrpc.c    |   504 +++
 sys/fs/nfs/server/nfs_nfsdport.c    |  3377 ++++++++++++++++++++
 sys/fs/nfs/server/nfs_nfsdserv.c    |  3520 ++++++++++++++++++++
 sys/fs/nfs/server/nfs_nfsdsocket.c  |   957 +++++
 sys/fs/nfs/server/nfs_nfsdstate.c   |  5286 +++++++++++++++++++++++++++++++
 sys/fs/nfs/server/nfs_nfsdsubs.c    |  2077 ++++++++++++
 70 files changed, 62681 insertions(+), 0 deletions(-)

diffs (truncated from 62961 to 300 lines):

diff -r 0cf961f433fb -r a20009b58b9f sys/fs/nfs/client/nfs.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/fs/nfs/client/nfs.h   Mon Sep 30 07:18:57 2013 +0000
@@ -0,0 +1,111 @@
+/*     $NetBSD: nfs.h,v 1.1.1.1 2013/09/30 07:19:30 dholland Exp $     */
+/*-
+ * Copyright (c) 1989, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Rick Macklem at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * FreeBSD: head/sys/fs/nfsclient/nfs.h 221040 2011-04-25 23:12:18Z rmacklem 
+ * $NetBSD: nfs.h,v 1.1.1.1 2013/09/30 07:19:30 dholland Exp $
+ */
+
+#ifndef _NFSCLIENT_NFS_H_
+#define        _NFSCLIENT_NFS_H_
+
+#if defined(_KERNEL)
+
+#ifndef NFS_TPRINTF_INITIAL_DELAY
+#define        NFS_TPRINTF_INITIAL_DELAY       12
+#endif
+
+#ifndef NFS_TPRINTF_DELAY
+#define        NFS_TPRINTF_DELAY               30
+#endif
+
+/*
+ * Nfs version macros.
+ */
+#define        NFS_ISV3(v) \
+       (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
+#define        NFS_ISV4(v) \
+       (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV4)
+#define        NFS_ISV34(v) \
+       (VFSTONFS((v)->v_mount)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4))
+
+/*
+ * NFS iod threads can be in one of these three states once spawned.
+ * NFSIOD_NOT_AVAILABLE - Cannot be assigned an I/O operation at this time.
+ * NFSIOD_AVAILABLE - Available to be assigned an I/O operation.
+ * NFSIOD_CREATED_FOR_NFS_ASYNCIO - Newly created for nfs_asyncio() and
+ *     will be used by the thread that called nfs_asyncio().
+ */
+enum nfsiod_state {
+       NFSIOD_NOT_AVAILABLE = 0,
+       NFSIOD_AVAILABLE = 1,
+       NFSIOD_CREATED_FOR_NFS_ASYNCIO = 2,
+};
+
+/*
+ * Function prototypes.
+ */
+int ncl_meta_setsize(struct vnode *, struct ucred *, struct thread *,
+    u_quad_t);
+void ncl_doio_directwrite(struct buf *);
+int ncl_bioread(struct vnode *, struct uio *, int, struct ucred *);
+int ncl_biowrite(struct vnode *, struct uio *, int, struct ucred *);
+int ncl_vinvalbuf(struct vnode *, int, struct thread *, int);
+int ncl_asyncio(struct nfsmount *, struct buf *, struct ucred *,
+    struct thread *);
+int ncl_doio(struct vnode *, struct buf *, struct ucred *, struct thread *,
+    int);
+void ncl_nhinit(void);
+void ncl_nhuninit(void);
+void ncl_nodelock(struct nfsnode *);
+void ncl_nodeunlock(struct nfsnode *);
+int ncl_getattrcache(struct vnode *, struct vattr *);
+int ncl_readrpc(struct vnode *, struct uio *, struct ucred *);
+int ncl_writerpc(struct vnode *, struct uio *, struct ucred *, int *, int *,
+    int);
+int ncl_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
+int ncl_readdirrpc(struct vnode *, struct uio *, struct ucred *,
+    struct thread *);
+int ncl_readdirplusrpc(struct vnode *, struct uio *, struct ucred *,
+    struct thread *);
+int ncl_writebp(struct buf *, int, struct thread *);
+int ncl_commit(struct vnode *, u_quad_t, int, struct ucred *, struct thread *);
+void ncl_clearcommit(struct mount *);
+int ncl_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
+    struct thread *);
+int ncl_init(struct vfsconf *);
+int ncl_uninit(struct vfsconf *);
+void   ncl_nfsiodnew(void);
+void   ncl_nfsiodnew_tq(__unused void *, int);
+
+#endif /* _KERNEL */
+
+#endif /* _NFSCLIENT_NFS_H_ */
diff -r 0cf961f433fb -r a20009b58b9f sys/fs/nfs/client/nfs_clbio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/fs/nfs/client/nfs_clbio.c     Mon Sep 30 07:18:57 2013 +0000
@@ -0,0 +1,1889 @@
+/*     $NetBSD: nfs_clbio.c,v 1.1.1.1 2013/09/30 07:19:30 dholland Exp $       */
+/*-
+ * Copyright (c) 1989, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Rick Macklem at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)nfs_bio.c   8.9 (Berkeley) 3/30/95
+ */
+
+#include <sys/cdefs.h>
+/* __FBSDID("FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 252072 2013-06-21 22:26:18Z rmacklem "); */
+__RCSID("$NetBSD: nfs_clbio.c,v 1.1.1.1 2013/09/30 07:19:30 dholland Exp $");
+
+#include "opt_kdtrace.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bio.h>
+#include <sys/buf.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/rwlock.h>
+#include <sys/vmmeter.h>
+#include <sys/vnode.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_object.h>
+#include <vm/vm_pager.h>
+#include <vm/vnode_pager.h>
+
+#include <fs/nfs/nfsport.h>
+#include <fs/nfsclient/nfsmount.h>
+#include <fs/nfsclient/nfs.h>
+#include <fs/nfsclient/nfsnode.h>
+#include <fs/nfsclient/nfs_kdtrace.h>
+
+extern int newnfs_directio_allow_mmap;
+extern struct nfsstats newnfsstats;
+extern struct mtx ncl_iod_mutex;
+extern int ncl_numasync;
+extern enum nfsiod_state ncl_iodwant[NFS_MAXASYNCDAEMON];
+extern struct nfsmount *ncl_iodmount[NFS_MAXASYNCDAEMON];
+extern int newnfs_directio_enable;
+extern int nfs_keep_dirty_on_error;
+
+int ncl_pbuf_freecnt = -1;     /* start out unlimited */
+
+static struct buf *nfs_getcacheblk(struct vnode *vp, daddr_t bn, int size,
+    struct thread *td);
+static int nfs_directio_write(struct vnode *vp, struct uio *uiop,
+    struct ucred *cred, int ioflag);
+
+/*
+ * Vnode op for VM getpages.
+ */
+int
+ncl_getpages(struct vop_getpages_args *ap)
+{
+       int i, error, nextoff, size, toff, count, npages;
+       struct uio uio;
+       struct iovec iov;
+       vm_offset_t kva;
+       struct buf *bp;
+       struct vnode *vp;
+       struct thread *td;
+       struct ucred *cred;
+       struct nfsmount *nmp;
+       vm_object_t object;
+       vm_page_t *pages;
+       struct nfsnode *np;
+
+       vp = ap->a_vp;
+       np = VTONFS(vp);
+       td = curthread;                         /* XXX */
+       cred = curthread->td_ucred;             /* XXX */
+       nmp = VFSTONFS(vp->v_mount);
+       pages = ap->a_m;
+       count = ap->a_count;
+
+       if ((object = vp->v_object) == NULL) {
+               ncl_printf("nfs_getpages: called with non-merged cache vnode??\n");
+               return (VM_PAGER_ERROR);
+       }
+
+       if (newnfs_directio_enable && !newnfs_directio_allow_mmap) {
+               mtx_lock(&np->n_mtx);
+               if ((np->n_flag & NNONCACHE) && (vp->v_type == VREG)) {
+                       mtx_unlock(&np->n_mtx);
+                       ncl_printf("nfs_getpages: called on non-cacheable vnode??\n");
+                       return (VM_PAGER_ERROR);
+               } else
+                       mtx_unlock(&np->n_mtx);
+       }
+
+       mtx_lock(&nmp->nm_mtx);
+       if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
+           (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) {
+               mtx_unlock(&nmp->nm_mtx);
+               /* We'll never get here for v4, because we always have fsinfo */
+               (void)ncl_fsinfo(nmp, vp, cred, td);
+       } else
+               mtx_unlock(&nmp->nm_mtx);
+
+       npages = btoc(count);
+
+       /*
+        * If the requested page is partially valid, just return it and
+        * allow the pager to zero-out the blanks.  Partially valid pages
+        * can only occur at the file EOF.
+        */
+       VM_OBJECT_WLOCK(object);
+       if (pages[ap->a_reqpage]->valid != 0) {
+               for (i = 0; i < npages; ++i) {
+                       if (i != ap->a_reqpage) {
+                               vm_page_lock(pages[i]);
+                               vm_page_free(pages[i]);
+                               vm_page_unlock(pages[i]);
+                       }
+               }
+               VM_OBJECT_WUNLOCK(object);
+               return (0);
+       }
+       VM_OBJECT_WUNLOCK(object);
+
+       /*
+        * We use only the kva address for the buffer, but this is extremely
+        * convienient and fast.
+        */
+       bp = getpbuf(&ncl_pbuf_freecnt);
+
+       kva = (vm_offset_t) bp->b_data;
+       pmap_qenter(kva, pages, npages);
+       PCPU_INC(cnt.v_vnodein);
+       PCPU_ADD(cnt.v_vnodepgsin, npages);
+
+       iov.iov_base = (caddr_t) kva;
+       iov.iov_len = count;
+       uio.uio_iov = &iov;
+       uio.uio_iovcnt = 1;
+       uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
+       uio.uio_resid = count;
+       uio.uio_segflg = UIO_SYSSPACE;
+       uio.uio_rw = UIO_READ;
+       uio.uio_td = td;
+
+       error = ncl_readrpc(vp, &uio, cred);
+       pmap_qremove(kva, npages);
+
+       relpbuf(bp, &ncl_pbuf_freecnt);
+
+       if (error && (uio.uio_resid == count)) {
+               ncl_printf("nfs_getpages: error %d\n", error);



Home | Main Index | Thread Index | Old Index