diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-15 06:53:31 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-15 06:53:31 +0000 |
commit | 0afc849b8a3d5819aa5731d22441d0e7f7beb662 (patch) | |
tree | a41481ab00a9121aa98602d6606904c05a4179fb | |
parent | cecfaa252c4fe2a72387d6e1d9304b17c73d878b (diff) |
Don't keep the reference to the root vnode all the time. Treat the root vnode
just like all other vnodes.
This removes a lot of code, simplifies unmount (which was incorrect btw.) and
removes the need for our own mount structure.
-rw-r--r-- | sys/miscfs/fdesc/fdesc.h | 7 | ||||
-rw-r--r-- | sys/miscfs/fdesc/fdesc_vfsops.c | 50 |
2 files changed, 11 insertions, 46 deletions
diff --git a/sys/miscfs/fdesc/fdesc.h b/sys/miscfs/fdesc/fdesc.h index 11c60d9b6ee..e6c203dd35b 100644 --- a/sys/miscfs/fdesc/fdesc.h +++ b/sys/miscfs/fdesc/fdesc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdesc.h,v 1.5 1997/11/06 05:58:32 csapuntz Exp $ */ +/* $OpenBSD: fdesc.h,v 1.6 2001/05/15 06:53:29 art Exp $ */ /* $NetBSD: fdesc.h,v 1.9 1996/02/09 22:40:03 christos Exp $ */ /* @@ -42,10 +42,6 @@ */ #ifdef _KERNEL -struct fdescmount { - struct vnode *f_root; /* Root node */ -}; - #define FD_ROOT 2 #define FD_DEVFD 3 #define FD_STDIN 4 @@ -72,7 +68,6 @@ struct fdescnode { int fd_ix; /* filesystem index */ }; -#define VFSTOFDESC(mp) ((struct fdescmount *)((mp)->mnt_data)) #define VTOFDESC(vp) ((struct fdescnode *)(vp)->v_data) extern dev_t devctty; diff --git a/sys/miscfs/fdesc/fdesc_vfsops.c b/sys/miscfs/fdesc/fdesc_vfsops.c index d4079efa31a..c526d705826 100644 --- a/sys/miscfs/fdesc/fdesc_vfsops.c +++ b/sys/miscfs/fdesc/fdesc_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdesc_vfsops.c,v 1.9 2001/02/20 01:50:09 assar Exp $ */ +/* $OpenBSD: fdesc_vfsops.c,v 1.10 2001/05/15 06:53:30 art Exp $ */ /* $NetBSD: fdesc_vfsops.c,v 1.21 1996/02/09 22:40:07 christos Exp $ */ /* @@ -82,10 +82,7 @@ fdesc_mount(mp, path, data, ndp, p) struct nameidata *ndp; struct proc *p; { - int error = 0; size_t size; - struct fdescmount *fmp; - struct vnode *rvp; /* * Update is a no-op @@ -93,17 +90,7 @@ fdesc_mount(mp, path, data, ndp, p) if (mp->mnt_flag & MNT_UPDATE) return (EOPNOTSUPP); - error = fdesc_allocvp(Froot, FD_ROOT, mp, &rvp); - if (error) - return (error); - - MALLOC(fmp, struct fdescmount *, sizeof(struct fdescmount), - M_UFSMNT, M_WAITOK); /* XXX */ - rvp->v_type = VDIR; - rvp->v_flag |= VROOT; - fmp->f_root = rvp; mp->mnt_flag |= MNT_LOCAL; - mp->mnt_data = (qaddr_t)fmp; vfs_getnewfsid(mp); (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); @@ -128,37 +115,18 @@ fdesc_unmount(mp, mntflags, p) int mntflags; struct proc *p; { - int error; int flags = 0; - struct vnode *rootvp = VFSTOFDESC(mp)->f_root; + int error; if (mntflags & MNT_FORCE) flags |= FORCECLOSE; /* - * Clear out buffer cache. I don't think we - * ever get anything cached at this level at the - * moment, but who knows... + * Flush out our vnodes. */ - if (rootvp->v_usecount > 1) - return (EBUSY); - if ((error = vflush(mp, rootvp, flags)) != 0) + if ((error = vflush(mp, NULL, flags)) != 0) return (error); - /* - * Release reference on underlying root vnode - */ - vrele(rootvp); - /* - * And blow it away for future re-use - */ - vgone(rootvp); - /* - * Finally, throw away the fdescmount structure - */ - free(mp->mnt_data, M_UFSMNT); /* XXX */ - mp->mnt_data = 0; - return (0); } @@ -168,13 +136,15 @@ fdesc_root(mp, vpp) struct vnode **vpp; { struct vnode *vp; - struct proc *p = curproc; /* XXX */ + int error; /* * Return locked reference to root. */ - vp = VFSTOFDESC(mp)->f_root; - VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + error = fdesc_allocvp(Froot, FD_ROOT, mp, &vp); + if (error) + return (error); + vp->v_type = VDIR; + vp->v_flag |= VROOT; *vpp = vp; return (0); } |