Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs Introduce layer library in genfs. This set of fil...



details:   https://anonhg.NetBSD.org/src/rev/293717beda2b
branches:  trunk
changeset: 474479:293717beda2b
user:      wrstuden <wrstuden%NetBSD.org@localhost>
date:      Thu Jul 08 01:18:59 1999 +0000

description:
Introduce layer library in genfs. This set of files abstracts most of
the functionality of nullfs. The latter is now just a mount & unmount
routine, and a few tables. umapfs borrow most of this infrastructure.

Both fs's are now nfs-exportable.

All layered fs's share a common format to private mount & private
vnode structs (which a particular fs can extend).

Also add genfs_noerr_rele(), a vnode op which will vrele/vput
operand vnodes appropriately.

diffstat:

 sys/miscfs/genfs/Makefile       |    4 +-
 sys/miscfs/genfs/genfs.h        |   37 +-
 sys/miscfs/genfs/genfs_vnops.c  |  165 ++++---
 sys/miscfs/genfs/layer.h        |  167 +++++++
 sys/miscfs/genfs/layer_extern.h |  118 +++++
 sys/miscfs/genfs/layer_subr.c   |  386 +++++++++++++++++
 sys/miscfs/genfs/layer_vfsops.c |  285 ++++++++++++
 sys/miscfs/genfs/layer_vnops.c  |  880 ++++++++++++++++++++++++++++++++++++++++
 sys/miscfs/nullfs/null.h        |   93 ++-
 sys/miscfs/nullfs/null_subr.c   |  369 ----------------
 sys/miscfs/nullfs/null_vfsops.c |  322 ++++----------
 sys/miscfs/nullfs/null_vnops.c  |  577 ++-----------------------
 sys/miscfs/umapfs/umap.h        |   48 +-
 sys/miscfs/umapfs/umap_subr.c   |  333 +-------------
 sys/miscfs/umapfs/umap_vfsops.c |  294 +++----------
 sys/miscfs/umapfs/umap_vnops.c  |  365 ++++++---------
 16 files changed, 2457 insertions(+), 1986 deletions(-)

diffs (truncated from 5147 to 300 lines):

diff -r 7a3f6a236723 -r 293717beda2b sys/miscfs/genfs/Makefile
--- a/sys/miscfs/genfs/Makefile Thu Jul 08 01:05:58 1999 +0000
+++ b/sys/miscfs/genfs/Makefile Thu Jul 08 01:18:59 1999 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: Makefile,v 1.1 1998/06/12 23:23:02 cgd Exp $
+#      $NetBSD: Makefile,v 1.2 1999/07/08 01:18:59 wrstuden Exp $
 
 INCSDIR= /usr/include/miscfs/genfs
 
-INCS=  genfs.h
+INCS=  genfs.h layer.h
 
 .include <bsd.kinc.mk>
diff -r 7a3f6a236723 -r 293717beda2b sys/miscfs/genfs/genfs.h
--- a/sys/miscfs/genfs/genfs.h  Thu Jul 08 01:05:58 1999 +0000
+++ b/sys/miscfs/genfs/genfs.h  Thu Jul 08 01:18:59 1999 +0000
@@ -1,18 +1,23 @@
-/*     $NetBSD: genfs.h,v 1.8 1998/08/13 09:59:52 kleink Exp $ */
+/*     $NetBSD: genfs.h,v 1.9 1999/07/08 01:18:59 wrstuden Exp $       */
 
-int    genfs_badop     __P((void *));
-int    genfs_nullop    __P((void *));
-int    genfs_enoioctl  __P((void *));
-int    genfs_einval    __P((void *));
-int    genfs_eopnotsupp __P((void *));
-int    genfs_ebadf     __P((void *));
-int    genfs_nolock    __P((void *));
-int    genfs_noislocked __P((void *));
-int    genfs_nounlock  __P((void *));
+int    genfs_badop             __P((void *));
+int    genfs_nullop            __P((void *));
+int    genfs_enoioctl          __P((void *));
+int    genfs_enoextops         __P((void *));
+int    genfs_einval            __P((void *));
+int    genfs_eopnotsupp        __P((void *));
+int    genfs_eopnotsupp_rele   __P((void *));
+int    genfs_ebadf             __P((void *));
+int    genfs_nolock            __P((void *));
+int    genfs_noislocked        __P((void *));
+int    genfs_nounlock          __P((void *));
 
-int    genfs_poll      __P((void *));
-int    genfs_fsync     __P((void *));
-int    genfs_seek      __P((void *));
-int    genfs_abortop   __P((void *));
-int    genfs_revoke    __P((void *));
-int    genfs_lease_check __P((void *));
+int    genfs_poll              __P((void *));
+int    genfs_fsync             __P((void *));
+int    genfs_seek              __P((void *));
+int    genfs_abortop           __P((void *));
+int    genfs_revoke            __P((void *));
+int    genfs_lease_check       __P((void *));
+int    genfs_lock              __P((void *));
+int    genfs_islocked          __P((void *));
+int    genfs_unlock            __P((void *));
diff -r 7a3f6a236723 -r 293717beda2b sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c    Thu Jul 08 01:05:58 1999 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c    Thu Jul 08 01:18:59 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_vnops.c,v 1.11 1999/03/05 21:09:49 mycroft Exp $ */
+/*     $NetBSD: genfs_vnops.c,v 1.12 1999/07/08 01:18:59 wrstuden Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -158,6 +158,45 @@
        return (EOPNOTSUPP);
 }
 
+/*
+ * Called when an fs doesn't support a particular vop but the vop needs to
+ * vrele, vput, or vunlock passed in vnodes.
+ */
+int
+genfs_eopnotsupp_rele(v)
+       void *v;
+{
+       struct vop_generic_args /*
+               struct vnodeop_desc *a_desc;
+               / * other random data follows, presumably * / 
+       } */ *ap = v;
+       struct vnodeop_desc *desc = ap->a_desc;
+       struct vnode *vp;
+       int flags, i, j, offset;
+
+       flags = desc->vdesc_flags;
+       for (i = 0; i < VDESC_MAX_VPS; flags >>=1, i++) {
+               if ((offset = desc->vdesc_vp_offsets[i]) == VDESC_NO_OFFSET)
+                       break;  /* stop at end of list */
+               if ((j = flags & VDESC_VP0_WILLPUT)) {
+                       vp = *VOPARG_OFFSETTO(struct vnode**,offset,ap);
+                       switch (j) {
+                       case VDESC_VP0_WILLPUT:
+                               vput(vp);
+                               break;
+                       case VDESC_VP0_WILLUNLOCK:
+                               VOP_UNLOCK(vp, 0);
+                               break;
+                       case VDESC_VP0_WILLRELE:
+                               vrele(vp);
+                               break;
+                       }
+               }
+       }
+
+       return (EOPNOTSUPP);
+}
+
 /*ARGSUSED*/
 int
 genfs_ebadf(v)
@@ -242,12 +281,58 @@
        return (0);
 }
 
+/*
+ * Lock the node.
+ */
+int
+genfs_lock(v)
+       void *v;
+{
+       struct vop_lock_args /* {
+               struct vnode *a_vp;
+               int a_flags;
+               struct proc *a_p;
+       } */ *ap = v;
+       struct vnode *vp = ap->a_vp;
+
+       return (lockmgr(&vp->v_lock, ap->a_flags, &vp->v_interlock));
+}
+
+/*
+ * Unlock the node.
+ */
+int
+genfs_unlock(v)
+       void *v;
+{
+       struct vop_unlock_args /* {
+               struct vnode *a_vp;
+               int a_flags;
+               struct proc *a_p;
+       } */ *ap = v;
+       struct vnode *vp = ap->a_vp;
+
+       return (lockmgr(&vp->v_lock, ap->a_flags | LK_RELEASE,
+               &vp->v_interlock));
+}
+
+/*
+ * Return whether or not the node is locked.
+ */
+int
+genfs_islocked(v)
+       void *v;
+{
+       struct vop_islocked_args /* {
+               struct vnode *a_vp;
+       } */ *ap = v;
+       struct vnode *vp = ap->a_vp;
+
+       return (lockstatus(&vp->v_lock));
+}
 
 /*
  * Stubs to use when there is no locking to be done on the underlying object.
- * A minimal shared lock is necessary to ensure that the underlying object
- * is not revoked while an operation is in progress. So, an active shared
- * count is maintained in an auxillary vnode lock structure.
  */
 int
 genfs_nolock(v)
@@ -259,51 +344,6 @@
                struct proc *a_p;
        } */ *ap = v;
 
-#ifdef notyet
-       /*
-        * This code cannot be used until all the non-locking filesystems
-        * (notably NFS) are converted to properly lock and release nodes.
-        * Also, certain vnode operations change the locking state within
-        * the operation (create, mknod, remove, link, rename, mkdir, rmdir,
-        * and symlink). Ideally these operations should not change the
-        * lock state, but should be changed to let the caller of the
-        * function unlock them. Otherwise all intermediate vnode layers
-        * (such as union, umapfs, etc) must catch these functions to do
-        * the necessary locking at their layer. Note that the inactive
-        * and lookup operations also change their lock state, but this 
-        * cannot be avoided, so these two operations will always need
-        * to be handled in intermediate layers.
-        */
-       struct vnode *vp = ap->a_vp;
-       int vnflags, flags = ap->a_flags;
-
-       if (vp->v_vnlock == NULL) {
-               if ((flags & LK_TYPE_MASK) == LK_DRAIN)
-                       return (0);
-               MALLOC(vp->v_vnlock, struct lock *, sizeof(struct lock),
-                   M_VNODE, M_WAITOK);
-               lockinit(vp->v_vnlock, PVFS, "vnlock", 0, 0);
-       }
-       switch (flags & LK_TYPE_MASK) {
-       case LK_DRAIN:
-               vnflags = LK_DRAIN;
-               break;
-       case LK_EXCLUSIVE:
-       case LK_SHARED:
-               vnflags = LK_SHARED;
-               break;
-       case LK_UPGRADE:
-       case LK_EXCLUPGRADE:
-       case LK_DOWNGRADE:
-               return (0);
-       case LK_RELEASE:
-       default:
-               panic("vop_nolock: bad operation %d", flags & LK_TYPE_MASK);
-       }
-       if (flags & LK_INTERLOCK)
-               vnflags |= LK_INTERLOCK;
-       return(lockmgr(vp->v_vnlock, vnflags, &vp->v_interlock));
-#else /* for now */
        /*
         * Since we are not using the lock manager, we must clear
         * the interlock here.
@@ -311,43 +351,20 @@
        if (ap->a_flags & LK_INTERLOCK)
                simple_unlock(&ap->a_vp->v_interlock);
        return (0);
-#endif
 }
 
-/*
- * Decrement the active use count.
- */
 int
 genfs_nounlock(v)
        void *v;
 {
-       struct vop_unlock_args /* {
-               struct vnode *a_vp;
-               int a_flags;
-               struct proc *a_p;
-       } */ *ap = v;
-       struct vnode *vp = ap->a_vp;
-
-       if (vp->v_vnlock == NULL)
-               return (0);
-       return (lockmgr(vp->v_vnlock, LK_RELEASE, NULL));
+       return (0);
 }
 
-/*
- * Return whether or not the node is in use.
- */
 int
 genfs_noislocked(v)
        void *v;
 {
-       struct vop_islocked_args /* {
-               struct vnode *a_vp;
-       } */ *ap = v;
-       struct vnode *vp = ap->a_vp;
-
-       if (vp->v_vnlock == NULL)
-               return (0);
-       return (lockstatus(vp->v_vnlock));
+       return (0);
 }
 
 /*
diff -r 7a3f6a236723 -r 293717beda2b sys/miscfs/genfs/layer.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/genfs/layer.h  Thu Jul 08 01:18:59 1999 +0000
@@ -0,0 +1,167 @@
+/*     $NetBSD: layer.h,v 1.1 1999/07/08 01:18:59 wrstuden Exp $       */
+
+/*
+ * Copyright (c) 1999 National Aeronautics & Space Administration
+ * All rights reserved.
+ *
+ * This software was written by William Studenmund of the
+ * Numerical Aerospace Similation Facility, NASA Ames Research Center.
+ *
+ * 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.
+ * 3. Neither the the name of the National Aeronautics & Space Administration
+ *    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 NATIONAL AERONAUTICS & SPACE ADMINISTRATION
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR



Home | Main Index | Thread Index | Old Index