1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* (c) UNIX System Laboratories, Inc.
|
|
|
|
* All or some portions of this file are derived from material licensed
|
|
|
|
* to the University of California by American Telephone and Telegraph
|
|
|
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
|
|
|
* the permission of UNIX System Laboratories, Inc.
|
|
|
|
*
|
|
|
|
* 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. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 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.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* External virtual filesystem routines
|
|
|
|
*/
|
1996-01-04 21:13:23 +00:00
|
|
|
#include "opt_ddb.h"
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1998-12-24 12:07:16 +00:00
|
|
|
#include <sys/fcntl.h>
|
1995-11-16 09:45:23 +00:00
|
|
|
#include <sys/kernel.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/proc.h>
|
1999-07-01 13:21:46 +00:00
|
|
|
#include <sys/kthread.h>
|
1997-10-12 20:26:33 +00:00
|
|
|
#include <sys/malloc.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/mount.h>
|
1998-03-28 12:04:40 +00:00
|
|
|
#include <sys/socket.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/domain.h>
|
1997-07-17 07:17:33 +00:00
|
|
|
#include <sys/dirent.h>
|
1997-12-29 00:25:11 +00:00
|
|
|
#include <sys/vmmeter.h>
|
1999-08-08 18:43:05 +00:00
|
|
|
#include <sys/conf.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-08-26 11:59:20 +00:00
|
|
|
#include <machine/limits.h>
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_extern.h>
|
1997-12-19 09:03:37 +00:00
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_map.h>
|
1999-01-21 08:29:12 +00:00
|
|
|
#include <vm/vm_page.h>
|
1998-01-17 09:17:02 +00:00
|
|
|
#include <vm/vm_pager.h>
|
1996-08-21 21:56:23 +00:00
|
|
|
#include <vm/vnode_pager.h>
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
#include <vm/vm_zone.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
1997-10-12 20:26:33 +00:00
|
|
|
static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
|
1997-10-11 18:31:40 +00:00
|
|
|
|
1997-11-22 08:35:46 +00:00
|
|
|
static void insmntque __P((struct vnode *vp, struct mount *mp));
|
1997-02-10 02:22:35 +00:00
|
|
|
static void vclean __P((struct vnode *vp, int flags, struct proc *p));
|
1997-11-22 08:35:46 +00:00
|
|
|
static void vfree __P((struct vnode *));
|
1997-04-01 13:05:34 +00:00
|
|
|
static void vgonel __P((struct vnode *vp, struct proc *p));
|
1997-11-22 08:35:46 +00:00
|
|
|
static unsigned long numvnodes;
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
SYSCTL_INT(_debug, OID_AUTO, numvnodes, CTLFLAG_RD, &numvnodes, 0, "");
|
1995-12-02 18:58:56 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
enum vtype iftovt_tab[16] = {
|
|
|
|
VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
|
|
|
|
VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VBAD,
|
|
|
|
};
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int vttoif_tab[9] = {
|
1994-05-24 10:09:53 +00:00
|
|
|
0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK,
|
|
|
|
S_IFSOCK, S_IFIFO, S_IFMT,
|
|
|
|
};
|
|
|
|
|
1998-02-09 06:11:36 +00:00
|
|
|
static TAILQ_HEAD(freelst, vnode) vnode_free_list; /* vnode free list */
|
1998-01-12 01:46:33 +00:00
|
|
|
struct tobefreelist vnode_tobefree_list; /* vnode free list */
|
|
|
|
|
1997-09-25 16:17:57 +00:00
|
|
|
static u_long wantfreevnodes = 25;
|
1997-09-24 07:46:54 +00:00
|
|
|
SYSCTL_INT(_debug, OID_AUTO, wantfreevnodes, CTLFLAG_RW, &wantfreevnodes, 0, "");
|
1996-07-12 07:41:34 +00:00
|
|
|
static u_long freevnodes = 0;
|
1997-08-31 07:32:39 +00:00
|
|
|
SYSCTL_INT(_debug, OID_AUTO, freevnodes, CTLFLAG_RD, &freevnodes, 0, "");
|
1995-03-09 20:27:04 +00:00
|
|
|
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
static int reassignbufcalls;
|
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, reassignbufcalls, CTLFLAG_RW, &reassignbufcalls, 0, "");
|
|
|
|
static int reassignbufloops;
|
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, reassignbufloops, CTLFLAG_RW, &reassignbufloops, 0, "");
|
|
|
|
static int reassignbufsortgood;
|
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, reassignbufsortgood, CTLFLAG_RW, &reassignbufsortgood, 0, "");
|
|
|
|
static int reassignbufsortbad;
|
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, reassignbufsortbad, CTLFLAG_RW, &reassignbufsortbad, 0, "");
|
|
|
|
static int reassignbufmethod = 1;
|
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, reassignbufmethod, CTLFLAG_RW, &reassignbufmethod, 0, "");
|
|
|
|
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
#ifdef ENABLE_VFS_IOOPT
|
1999-07-08 06:06:00 +00:00
|
|
|
int vfs_ioopt = 0;
|
1997-12-29 01:03:55 +00:00
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, ioopt, CTLFLAG_RW, &vfs_ioopt, 0, "");
|
1998-03-14 19:50:36 +00:00
|
|
|
#endif
|
1997-12-29 01:03:55 +00:00
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
struct mntlist mountlist; /* mounted filesystem list */
|
1997-02-10 02:22:35 +00:00
|
|
|
struct simplelock mountlist_slock;
|
|
|
|
struct simplelock mntvnode_slock;
|
1998-09-05 15:17:34 +00:00
|
|
|
int nfs_mount_type = -1;
|
1999-01-02 11:34:57 +00:00
|
|
|
#ifndef NULL_SIMPLELOCKS
|
|
|
|
static struct simplelock mntid_slock;
|
1998-02-09 06:11:36 +00:00
|
|
|
static struct simplelock vnode_free_list_slock;
|
1997-02-10 02:22:35 +00:00
|
|
|
static struct simplelock spechash_slock;
|
1999-01-02 11:34:57 +00:00
|
|
|
#endif
|
1997-07-17 07:17:33 +00:00
|
|
|
struct nfs_public nfs_pub; /* publicly exported FS */
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
static vm_zone_t vnode_zone;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
1998-03-08 09:59:44 +00:00
|
|
|
/*
|
|
|
|
* The workitem queue.
|
|
|
|
*/
|
|
|
|
#define SYNCER_MAXDELAY 32
|
1998-12-21 23:38:33 +00:00
|
|
|
static int syncer_maxdelay = SYNCER_MAXDELAY; /* maximum delay time */
|
1999-06-15 23:37:29 +00:00
|
|
|
time_t syncdelay = 30; /* max time to delay syncing data */
|
|
|
|
time_t filedelay = 30; /* time to delay syncing files */
|
|
|
|
SYSCTL_INT(_kern, OID_AUTO, filedelay, CTLFLAG_RW, &filedelay, 0, "");
|
1999-06-26 02:47:16 +00:00
|
|
|
time_t dirdelay = 29; /* time to delay syncing directories */
|
1999-06-15 23:37:29 +00:00
|
|
|
SYSCTL_INT(_kern, OID_AUTO, dirdelay, CTLFLAG_RW, &dirdelay, 0, "");
|
1999-06-26 02:47:16 +00:00
|
|
|
time_t metadelay = 28; /* time to delay syncing metadata */
|
1999-06-15 23:37:29 +00:00
|
|
|
SYSCTL_INT(_kern, OID_AUTO, metadelay, CTLFLAG_RW, &metadelay, 0, "");
|
|
|
|
static int rushjob; /* number of slots to run ASAP */
|
|
|
|
static int stat_rush_requests; /* number of times I/O speeded up */
|
|
|
|
SYSCTL_INT(_debug, OID_AUTO, rush_requests, CTLFLAG_RW, &stat_rush_requests, 0, "");
|
1998-03-08 09:59:44 +00:00
|
|
|
|
|
|
|
static int syncer_delayno = 0;
|
|
|
|
static long syncer_mask;
|
|
|
|
LIST_HEAD(synclist, vnode);
|
|
|
|
static struct synclist *syncer_workitem_pending;
|
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int desiredvnodes;
|
1999-05-03 23:57:32 +00:00
|
|
|
SYSCTL_INT(_kern, KERN_MAXVNODES, maxvnodes, CTLFLAG_RW,
|
|
|
|
&desiredvnodes, 0, "Maximum number of vnodes");
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-12-02 18:58:56 +00:00
|
|
|
static void vfs_free_addrlist __P((struct netexport *nep));
|
|
|
|
static int vfs_free_netcred __P((struct radix_node *rn, void *w));
|
|
|
|
static int vfs_hang_addrlist __P((struct mount *mp, struct netexport *nep,
|
|
|
|
struct export_args *argp));
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Initialize the vnode management data structures.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1994-05-24 10:09:53 +00:00
|
|
|
vntblinit()
|
|
|
|
{
|
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
desiredvnodes = maxproc + cnt.v_page_count / 4;
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock_init(&mntvnode_slock);
|
|
|
|
simple_lock_init(&mntid_slock);
|
|
|
|
simple_lock_init(&spechash_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
TAILQ_INIT(&vnode_free_list);
|
1998-01-12 01:46:33 +00:00
|
|
|
TAILQ_INIT(&vnode_tobefree_list);
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock_init(&vnode_free_list_slock);
|
1995-08-11 11:31:18 +00:00
|
|
|
CIRCLEQ_INIT(&mountlist);
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5);
|
1998-03-08 09:59:44 +00:00
|
|
|
/*
|
|
|
|
* Initialize the filesystem syncer.
|
|
|
|
*/
|
|
|
|
syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE,
|
|
|
|
&syncer_mask);
|
|
|
|
syncer_maxdelay = syncer_mask + 1;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Mark a mount point as busy. Used to synchronize access and to delay
|
|
|
|
* unmounting. Interlock is not released on failure.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_busy(mp, flags, interlkp, p)
|
|
|
|
struct mount *mp;
|
|
|
|
int flags;
|
|
|
|
struct simplelock *interlkp;
|
|
|
|
struct proc *p;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
int lkflags;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-11-12 05:42:33 +00:00
|
|
|
if (mp->mnt_kern_flag & MNTK_UNMOUNT) {
|
1997-02-10 02:22:35 +00:00
|
|
|
if (flags & LK_NOWAIT)
|
|
|
|
return (ENOENT);
|
1997-11-12 05:42:33 +00:00
|
|
|
mp->mnt_kern_flag |= MNTK_MWAIT;
|
1997-02-10 02:22:35 +00:00
|
|
|
if (interlkp) {
|
|
|
|
simple_unlock(interlkp);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Since all busy locks are shared except the exclusive
|
|
|
|
* lock granted when unmounting, the only place that a
|
|
|
|
* wakeup needs to be done is at the release of the
|
|
|
|
* exclusive lock at the end of dounmount.
|
|
|
|
*/
|
|
|
|
tsleep((caddr_t)mp, PVFS, "vfs_busy", 0);
|
|
|
|
if (interlkp) {
|
|
|
|
simple_lock(interlkp);
|
|
|
|
}
|
|
|
|
return (ENOENT);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
This mega-commit is meant to fix numerous interrelated problems. There
has been some bitrot and incorrect assumptions in the vfs_bio code. These
problems have manifest themselves worse on NFS type filesystems, but can
still affect local filesystems under certain circumstances. Most of
the problems have involved mmap consistancy, and as a side-effect broke
the vfs.ioopt code. This code might have been committed seperately, but
almost everything is interrelated.
1) Allow (pmap_object_init_pt) prefaulting of buffer-busy pages that
are fully valid.
2) Rather than deactivating erroneously read initial (header) pages in
kern_exec, we now free them.
3) Fix the rundown of non-VMIO buffers that are in an inconsistent
(missing vp) state.
4) Fix the disassociation of pages from buffers in brelse. The previous
code had rotted and was faulty in a couple of important circumstances.
5) Remove a gratuitious buffer wakeup in vfs_vmio_release.
6) Remove a crufty and currently unused cluster mechanism for VBLK
files in vfs_bio_awrite. When the code is functional, I'll add back
a cleaner version.
7) The page busy count wakeups assocated with the buffer cache usage were
incorrectly cleaned up in a previous commit by me. Revert to the
original, correct version, but with a cleaner implementation.
8) The cluster read code now tries to keep data associated with buffers
more aggressively (without breaking the heuristics) when it is presumed
that the read data (buffers) will be soon needed.
9) Change to filesystem lockmgr locks so that they use LK_NOPAUSE. The
delay loop waiting is not useful for filesystem locks, due to the
length of the time intervals.
10) Correct and clean-up spec_getpages.
11) Implement a fully functional nfs_getpages, nfs_putpages.
12) Fix nfs_write so that modifications are coherent with the NFS data on
the server disk (at least as well as NFS seems to allow.)
13) Properly support MS_INVALIDATE on NFS.
14) Properly pass down MS_INVALIDATE to lower levels of the VM code from
vm_map_clean.
15) Better support the notion of pages being busy but valid, so that
fewer in-transit waits occur. (use p->busy more for pageouts instead
of PG_BUSY.) Since the page is fully valid, it is still usable for
reads.
16) It is possible (in error) for cached pages to be busy. Make the
page allocation code handle that case correctly. (It should probably
be a printf or panic, but I want the system to handle coding errors
robustly. I'll probably add a printf.)
17) Correct the design and usage of vm_page_sleep. It didn't handle
consistancy problems very well, so make the design a little less
lofty. After vm_page_sleep, if it ever blocked, it is still important
to relookup the page (if the object generation count changed), and
verify it's status (always.)
18) In vm_pageout.c, vm_pageout_clean had rotted, so clean that up.
19) Push the page busy for writes and VM_PROT_READ into vm_pageout_flush.
20) Fix vm_pager_put_pages and it's descendents to support an int flag
instead of a boolean, so that we can pass down the invalidate bit.
1998-03-07 21:37:31 +00:00
|
|
|
lkflags = LK_SHARED | LK_NOPAUSE;
|
1997-02-10 02:22:35 +00:00
|
|
|
if (interlkp)
|
|
|
|
lkflags |= LK_INTERLOCK;
|
|
|
|
if (lockmgr(&mp->mnt_lock, lkflags, interlkp, p))
|
|
|
|
panic("vfs_busy: unexpected lock failure");
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Free a busy filesystem.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
void
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_unbusy(mp, p)
|
|
|
|
struct mount *mp;
|
|
|
|
struct proc *p;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Lookup a filesystem type, and if found allocate and initialize
|
|
|
|
* a mount structure for it.
|
|
|
|
*
|
|
|
|
* Devname is usually updated by mount(8) after booting.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_rootmountalloc(fstypename, devname, mpp)
|
|
|
|
char *fstypename;
|
|
|
|
char *devname;
|
|
|
|
struct mount **mpp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
|
|
|
struct vfsconf *vfsp;
|
|
|
|
struct mount *mp;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-06-07 17:13:14 +00:00
|
|
|
if (fstypename == NULL)
|
|
|
|
return (ENODEV);
|
1997-02-10 02:22:35 +00:00
|
|
|
for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
|
|
|
|
if (!strcmp(vfsp->vfc_name, fstypename))
|
|
|
|
break;
|
|
|
|
if (vfsp == NULL)
|
|
|
|
return (ENODEV);
|
|
|
|
mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
|
|
|
|
bzero((char *)mp, (u_long)sizeof(struct mount));
|
This mega-commit is meant to fix numerous interrelated problems. There
has been some bitrot and incorrect assumptions in the vfs_bio code. These
problems have manifest themselves worse on NFS type filesystems, but can
still affect local filesystems under certain circumstances. Most of
the problems have involved mmap consistancy, and as a side-effect broke
the vfs.ioopt code. This code might have been committed seperately, but
almost everything is interrelated.
1) Allow (pmap_object_init_pt) prefaulting of buffer-busy pages that
are fully valid.
2) Rather than deactivating erroneously read initial (header) pages in
kern_exec, we now free them.
3) Fix the rundown of non-VMIO buffers that are in an inconsistent
(missing vp) state.
4) Fix the disassociation of pages from buffers in brelse. The previous
code had rotted and was faulty in a couple of important circumstances.
5) Remove a gratuitious buffer wakeup in vfs_vmio_release.
6) Remove a crufty and currently unused cluster mechanism for VBLK
files in vfs_bio_awrite. When the code is functional, I'll add back
a cleaner version.
7) The page busy count wakeups assocated with the buffer cache usage were
incorrectly cleaned up in a previous commit by me. Revert to the
original, correct version, but with a cleaner implementation.
8) The cluster read code now tries to keep data associated with buffers
more aggressively (without breaking the heuristics) when it is presumed
that the read data (buffers) will be soon needed.
9) Change to filesystem lockmgr locks so that they use LK_NOPAUSE. The
delay loop waiting is not useful for filesystem locks, due to the
length of the time intervals.
10) Correct and clean-up spec_getpages.
11) Implement a fully functional nfs_getpages, nfs_putpages.
12) Fix nfs_write so that modifications are coherent with the NFS data on
the server disk (at least as well as NFS seems to allow.)
13) Properly support MS_INVALIDATE on NFS.
14) Properly pass down MS_INVALIDATE to lower levels of the VM code from
vm_map_clean.
15) Better support the notion of pages being busy but valid, so that
fewer in-transit waits occur. (use p->busy more for pageouts instead
of PG_BUSY.) Since the page is fully valid, it is still usable for
reads.
16) It is possible (in error) for cached pages to be busy. Make the
page allocation code handle that case correctly. (It should probably
be a printf or panic, but I want the system to handle coding errors
robustly. I'll probably add a printf.)
17) Correct the design and usage of vm_page_sleep. It didn't handle
consistancy problems very well, so make the design a little less
lofty. After vm_page_sleep, if it ever blocked, it is still important
to relookup the page (if the object generation count changed), and
verify it's status (always.)
18) In vm_pageout.c, vm_pageout_clean had rotted, so clean that up.
19) Push the page busy for writes and VM_PROT_READ into vm_pageout_flush.
20) Fix vm_pager_put_pages and it's descendents to support an int flag
instead of a boolean, so that we can pass down the invalidate bit.
1998-03-07 21:37:31 +00:00
|
|
|
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
|
1997-02-10 02:22:35 +00:00
|
|
|
(void)vfs_busy(mp, LK_NOWAIT, 0, p);
|
|
|
|
LIST_INIT(&mp->mnt_vnodelist);
|
|
|
|
mp->mnt_vfc = vfsp;
|
|
|
|
mp->mnt_op = vfsp->vfc_vfsops;
|
|
|
|
mp->mnt_flag = MNT_RDONLY;
|
|
|
|
mp->mnt_vnodecovered = NULLVP;
|
|
|
|
vfsp->vfc_refcount++;
|
1999-09-29 20:05:33 +00:00
|
|
|
mp->mnt_iosize_max = DFLTPHYS;
|
1997-02-10 02:22:35 +00:00
|
|
|
mp->mnt_stat.f_type = vfsp->vfc_typenum;
|
|
|
|
mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
|
|
|
|
strncpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN);
|
|
|
|
mp->mnt_stat.f_mntonname[0] = '/';
|
|
|
|
mp->mnt_stat.f_mntonname[1] = 0;
|
|
|
|
(void) copystr(devname, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 0);
|
|
|
|
*mpp = mp;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Find an appropriate filesystem to use for the root. If a filesystem
|
|
|
|
* has not been preselected, walk through the list of known filesystems
|
|
|
|
* trying those that have mountroot routines, and try them until one
|
|
|
|
* works or we have tried them all.
|
1994-08-20 16:03:26 +00:00
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
#ifdef notdef /* XXX JH */
|
|
|
|
int
|
1997-09-16 11:44:05 +00:00
|
|
|
lite2_vfs_mountroot()
|
1994-08-20 16:03:26 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vfsconf *vfsp;
|
1997-09-16 11:44:05 +00:00
|
|
|
extern int (*lite2_mountroot) __P((void));
|
1994-08-20 16:03:26 +00:00
|
|
|
int error;
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (lite2_mountroot != NULL)
|
|
|
|
return ((*lite2_mountroot)());
|
|
|
|
for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) {
|
|
|
|
if (vfsp->vfc_mountroot == NULL)
|
1994-08-20 16:03:26 +00:00
|
|
|
continue;
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((error = (*vfsp->vfc_mountroot)()) == 0)
|
|
|
|
return (0);
|
|
|
|
printf("%s_mountroot failed: %d\n", vfsp->vfc_name, error);
|
1994-08-20 16:03:26 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
return (ENODEV);
|
1994-08-20 16:03:26 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
#endif
|
1994-08-20 16:03:26 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Lookup a mount point by filesystem identifier.
|
|
|
|
*/
|
|
|
|
struct mount *
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_getvfs(fsid)
|
1994-05-24 10:09:53 +00:00
|
|
|
fsid_t *fsid;
|
|
|
|
{
|
|
|
|
register struct mount *mp;
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&mountlist_slock);
|
1995-08-11 11:31:18 +00:00
|
|
|
for (mp = mountlist.cqh_first; mp != (void *)&mountlist;
|
|
|
|
mp = mp->mnt_list.cqe_next) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] &&
|
1997-02-10 02:22:35 +00:00
|
|
|
mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) {
|
|
|
|
simple_unlock(&mountlist_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (mp);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&mountlist_slock);
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
return ((struct mount *) 0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a new unique fsid
|
1999-09-19 06:24:21 +00:00
|
|
|
*
|
|
|
|
* Keep in mind that several mounts may be running in parallel,
|
|
|
|
* so always increment mntid_base even if lower numbers are available.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1999-09-19 06:24:21 +00:00
|
|
|
|
|
|
|
static u_short mntid_base;
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
void
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_getnewfsid(mp)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mount *mp;
|
|
|
|
{
|
|
|
|
fsid_t tfsid;
|
1997-02-10 02:22:35 +00:00
|
|
|
int mtype;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&mntid_slock);
|
1999-09-19 06:24:21 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
mtype = mp->mnt_vfc->vfc_typenum;
|
1999-09-19 06:24:21 +00:00
|
|
|
for (;;) {
|
|
|
|
tfsid.val[0] = makeudev(255, mtype + (mntid_base << 16));
|
|
|
|
tfsid.val[1] = mtype;
|
|
|
|
++mntid_base;
|
|
|
|
if (vfs_getvfs(&tfsid) == NULL)
|
|
|
|
break;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1999-09-19 06:24:21 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
mp->mnt_stat.f_fsid.val[0] = tfsid.val[0];
|
1999-09-19 06:24:21 +00:00
|
|
|
mp->mnt_stat.f_fsid.val[1] = tfsid.val[1];
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&mntid_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1999-09-19 06:24:21 +00:00
|
|
|
/*
|
|
|
|
* Get what should become the root fsid.
|
|
|
|
*
|
|
|
|
* This is somewhat of a hack. If the rootdev is not known we
|
|
|
|
* assume that vfs_getnewfsid() will be called momentarily to
|
|
|
|
* allocate it, and we return what vfs_getnewfsid() will return.
|
|
|
|
*/
|
|
|
|
|
|
|
|
dev_t
|
|
|
|
vfs_getrootfsid(struct mount *mp)
|
|
|
|
{
|
|
|
|
int mtype;
|
|
|
|
|
|
|
|
mtype = mp->mnt_vfc->vfc_typenum;
|
|
|
|
return(makedev(255, mtype + (mntid_base << 16)));
|
|
|
|
}
|
|
|
|
|
Support full-precision file timestamps. Until now, only the seconds
have been maintained, and that is still the default. A new sysctl
variable "vfs.timestamp_precision" can be used to enable higher
levels of precision:
0 = seconds only; nanoseconds zeroed (default).
1 = seconds and nanoseconds, accurate within 1/HZ.
2 = seconds and nanoseconds, truncated to microseconds.
>=3 = seconds and nanoseconds, maximum precision.
Level 1 uses getnanotime(), which is fast but can be wrong by up
to 1/HZ. Level 2 uses microtime(). It might be desirable for
consistency with utimes() and friends, which take timeval structures
rather than timespecs. Level 3 uses nanotime() for the higest
precision.
I benchmarked levels 0, 1, and 3 by copying a 550 MB tree with
"cpio -pdu". There was almost negligible difference in the system
times -- much less than 1%, and less than the variation among
multiple runs at the same level. Bruce Evans dreamed up a torture
test involving 1-byte reads with intervening fstat() calls, but
the cpio test seems more realistic to me.
This feature is currently implemented only for the UFS (FFS and
MFS) filesystems. But I think it should be easy to support it in
the others as well.
An earlier version of this was reviewed by Bruce. He's not to
blame for any breakage I've introduced since then.
Reviewed by: bde (an earlier version of the code)
1999-08-22 00:15:16 +00:00
|
|
|
/*
|
|
|
|
* Knob to control the precision of file timestamps:
|
|
|
|
*
|
|
|
|
* 0 = seconds only; nanoseconds zeroed.
|
|
|
|
* 1 = seconds and nanoseconds, accurate within 1/HZ.
|
|
|
|
* 2 = seconds and nanoseconds, truncated to microseconds.
|
|
|
|
* >=3 = seconds and nanoseconds, maximum precision.
|
|
|
|
*/
|
|
|
|
enum { TSP_SEC, TSP_HZ, TSP_USEC, TSP_NSEC };
|
|
|
|
|
|
|
|
static int timestamp_precision = TSP_SEC;
|
|
|
|
SYSCTL_INT(_vfs, OID_AUTO, timestamp_precision, CTLFLAG_RW,
|
|
|
|
×tamp_precision, 0, "");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a current timestamp.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vfs_timestamp(tsp)
|
|
|
|
struct timespec *tsp;
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
switch (timestamp_precision) {
|
|
|
|
case TSP_SEC:
|
|
|
|
tsp->tv_sec = time_second;
|
|
|
|
tsp->tv_nsec = 0;
|
|
|
|
break;
|
|
|
|
case TSP_HZ:
|
|
|
|
getnanotime(tsp);
|
|
|
|
break;
|
|
|
|
case TSP_USEC:
|
|
|
|
microtime(&tv);
|
|
|
|
TIMEVAL_TO_TIMESPEC(&tv, tsp);
|
|
|
|
break;
|
|
|
|
case TSP_NSEC:
|
|
|
|
default:
|
|
|
|
nanotime(tsp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Set vnode attributes to VNOVAL
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
|
|
|
vattr_null(vap)
|
1994-05-24 10:09:53 +00:00
|
|
|
register struct vattr *vap;
|
|
|
|
{
|
|
|
|
|
|
|
|
vap->va_type = VNON;
|
1994-05-25 09:21:21 +00:00
|
|
|
vap->va_size = VNOVAL;
|
|
|
|
vap->va_bytes = VNOVAL;
|
1998-07-12 16:45:39 +00:00
|
|
|
vap->va_mode = VNOVAL;
|
|
|
|
vap->va_nlink = VNOVAL;
|
|
|
|
vap->va_uid = VNOVAL;
|
|
|
|
vap->va_gid = VNOVAL;
|
|
|
|
vap->va_fsid = VNOVAL;
|
|
|
|
vap->va_fileid = VNOVAL;
|
|
|
|
vap->va_blocksize = VNOVAL;
|
|
|
|
vap->va_rdev = VNOVAL;
|
|
|
|
vap->va_atime.tv_sec = VNOVAL;
|
|
|
|
vap->va_atime.tv_nsec = VNOVAL;
|
|
|
|
vap->va_mtime.tv_sec = VNOVAL;
|
|
|
|
vap->va_mtime.tv_nsec = VNOVAL;
|
|
|
|
vap->va_ctime.tv_sec = VNOVAL;
|
|
|
|
vap->va_ctime.tv_nsec = VNOVAL;
|
|
|
|
vap->va_flags = VNOVAL;
|
|
|
|
vap->va_gen = VNOVAL;
|
1994-05-24 10:09:53 +00:00
|
|
|
vap->va_vaflags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines having to do with the management of the vnode table.
|
|
|
|
*/
|
1995-11-09 08:17:23 +00:00
|
|
|
extern vop_t **dead_vnodeop_p;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the next vnode from the free list.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-05-24 10:09:53 +00:00
|
|
|
getnewvnode(tag, mp, vops, vpp)
|
|
|
|
enum vtagtype tag;
|
|
|
|
struct mount *mp;
|
1995-11-09 08:17:23 +00:00
|
|
|
vop_t **vops;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
1998-01-12 01:46:33 +00:00
|
|
|
int s;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
1998-01-12 01:46:33 +00:00
|
|
|
struct vnode *vp, *tvp, *nvp;
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
vm_object_t object;
|
|
|
|
TAILQ_HEAD(freelst, vnode) vnode_tmp_list;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-03-09 20:27:04 +00:00
|
|
|
/*
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
* We take the least recently used vnode from the freelist
|
|
|
|
* if we can get it and it has no cached pages, and no
|
|
|
|
* namecache entries are relative to it.
|
|
|
|
* Otherwise we allocate a new vnode
|
1995-03-09 20:27:04 +00:00
|
|
|
*/
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
|
1998-01-12 01:46:33 +00:00
|
|
|
s = splbio();
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
simple_lock(&vnode_free_list_slock);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
TAILQ_INIT(&vnode_tmp_list);
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
|
1998-01-12 01:46:33 +00:00
|
|
|
for (vp = TAILQ_FIRST(&vnode_tobefree_list); vp; vp = nvp) {
|
|
|
|
nvp = TAILQ_NEXT(vp, v_freelist);
|
1998-01-12 03:15:01 +00:00
|
|
|
TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
|
1998-02-23 06:59:52 +00:00
|
|
|
if (vp->v_flag & VAGE) {
|
|
|
|
TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
|
|
|
|
} else {
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
|
|
|
|
}
|
|
|
|
vp->v_flag &= ~(VTBFREE|VAGE);
|
1998-01-17 09:17:02 +00:00
|
|
|
vp->v_flag |= VFREE;
|
|
|
|
if (vp->v_usecount)
|
|
|
|
panic("tobe free vnode isn't");
|
1998-01-12 03:15:01 +00:00
|
|
|
freevnodes++;
|
1998-01-12 01:46:33 +00:00
|
|
|
}
|
|
|
|
|
1997-09-24 07:46:54 +00:00
|
|
|
if (wantfreevnodes && freevnodes < wantfreevnodes) {
|
|
|
|
vp = NULL;
|
1997-09-26 08:08:58 +00:00
|
|
|
} else if (!wantfreevnodes && freevnodes <= desiredvnodes) {
|
|
|
|
/*
|
|
|
|
* XXX: this is only here to be backwards compatible
|
|
|
|
*/
|
1997-09-24 07:46:54 +00:00
|
|
|
vp = NULL;
|
|
|
|
} else {
|
1998-01-12 01:46:33 +00:00
|
|
|
for (vp = TAILQ_FIRST(&vnode_free_list); vp; vp = nvp) {
|
|
|
|
nvp = TAILQ_NEXT(vp, v_freelist);
|
1997-08-04 07:43:28 +00:00
|
|
|
if (!simple_lock_try(&vp->v_interlock))
|
|
|
|
continue;
|
|
|
|
if (vp->v_usecount)
|
|
|
|
panic("free vnode isn't");
|
|
|
|
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
object = vp->v_object;
|
|
|
|
if (object && (object->resident_page_count || object->ref_count)) {
|
1998-02-23 06:59:52 +00:00
|
|
|
printf("object inconsistant state: RPC: %d, RC: %d\n",
|
|
|
|
object->resident_page_count, object->ref_count);
|
1997-08-04 07:43:28 +00:00
|
|
|
/* Don't recycle if it's caching some pages */
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_tmp_list, vp, v_freelist);
|
1997-08-04 07:43:28 +00:00
|
|
|
continue;
|
|
|
|
} else if (LIST_FIRST(&vp->v_cache_src)) {
|
|
|
|
/* Don't recycle if active in the namecache */
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
1996-01-19 04:00:31 +00:00
|
|
|
}
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
}
|
1997-08-04 07:43:28 +00:00
|
|
|
|
1998-01-12 01:46:33 +00:00
|
|
|
for (tvp = TAILQ_FIRST(&vnode_tmp_list); tvp; tvp = nvp) {
|
|
|
|
nvp = TAILQ_NEXT(tvp, v_freelist);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
TAILQ_REMOVE(&vnode_tmp_list, tvp, v_freelist);
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_free_list, tvp, v_freelist);
|
|
|
|
simple_unlock(&tvp->v_interlock);
|
|
|
|
}
|
|
|
|
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
if (vp) {
|
1997-08-31 07:32:39 +00:00
|
|
|
vp->v_flag |= VDOOMED;
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
|
1995-03-09 20:27:04 +00:00
|
|
|
freevnodes--;
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vnode_free_list_slock);
|
1997-08-31 07:32:39 +00:00
|
|
|
cache_purge(vp);
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_lease = NULL;
|
1997-12-29 00:25:11 +00:00
|
|
|
if (vp->v_type != VBAD) {
|
1997-02-10 02:22:35 +00:00
|
|
|
vgonel(vp, p);
|
1997-12-29 00:25:11 +00:00
|
|
|
} else {
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
}
|
1996-01-19 04:00:31 +00:00
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
#ifdef INVARIANTS
|
1994-10-02 17:35:40 +00:00
|
|
|
{
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int s;
|
|
|
|
|
|
|
|
if (vp->v_data)
|
|
|
|
panic("cleaned vnode isn't");
|
|
|
|
s = splbio();
|
|
|
|
if (vp->v_numoutput)
|
|
|
|
panic("Clean vnode has pending I/O's");
|
|
|
|
splx(s);
|
1994-10-02 17:35:40 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
#endif
|
|
|
|
vp->v_flag = 0;
|
|
|
|
vp->v_lastw = 0;
|
|
|
|
vp->v_lasta = 0;
|
|
|
|
vp->v_cstart = 0;
|
|
|
|
vp->v_clen = 0;
|
|
|
|
vp->v_socket = 0;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
vp->v_writecount = 0; /* XXX */
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
} else {
|
|
|
|
simple_unlock(&vnode_free_list_slock);
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
vp = (struct vnode *) zalloc(vnode_zone);
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
bzero((char *) vp, sizeof *vp);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
simple_lock_init(&vp->v_interlock);
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
vp->v_dd = vp;
|
1997-08-31 07:32:39 +00:00
|
|
|
cache_purge(vp);
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
LIST_INIT(&vp->v_cache_src);
|
|
|
|
TAILQ_INIT(&vp->v_cache_dst);
|
|
|
|
numvnodes++;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
|
1998-10-31 14:20:39 +00:00
|
|
|
TAILQ_INIT(&vp->v_cleanblkhd);
|
|
|
|
TAILQ_INIT(&vp->v_dirtyblkhd);
|
1995-02-27 06:50:08 +00:00
|
|
|
vp->v_type = VNON;
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_tag = tag;
|
|
|
|
vp->v_op = vops;
|
|
|
|
insmntque(vp, mp);
|
|
|
|
*vpp = vp;
|
|
|
|
vp->v_usecount = 1;
|
|
|
|
vp->v_data = 0;
|
1998-01-12 01:46:33 +00:00
|
|
|
splx(s);
|
1998-02-23 06:59:52 +00:00
|
|
|
|
1999-01-05 18:50:03 +00:00
|
|
|
vfs_object_create(vp, p, p->p_ucred);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move a vnode from one mount queue to another.
|
|
|
|
*/
|
1997-11-22 08:35:46 +00:00
|
|
|
static void
|
1994-05-24 10:09:53 +00:00
|
|
|
insmntque(vp, mp)
|
|
|
|
register struct vnode *vp;
|
|
|
|
register struct mount *mp;
|
|
|
|
{
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Delete from old mount point vnode list, if on one.
|
|
|
|
*/
|
|
|
|
if (vp->v_mount != NULL)
|
|
|
|
LIST_REMOVE(vp, v_mntvnodes);
|
|
|
|
/*
|
|
|
|
* Insert into list of vnodes for the new mount point, if available.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((vp->v_mount = mp) == NULL) {
|
|
|
|
simple_unlock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
return;
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
LIST_INSERT_HEAD(&mp->mnt_vnodelist, vp, v_mntvnodes);
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update outstanding I/O count and do wakeup if requested.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1994-05-24 10:09:53 +00:00
|
|
|
vwakeup(bp)
|
|
|
|
register struct buf *bp;
|
|
|
|
{
|
|
|
|
register struct vnode *vp;
|
|
|
|
|
|
|
|
bp->b_flags &= ~B_WRITEINPROG;
|
1994-09-25 19:34:02 +00:00
|
|
|
if ((vp = bp->b_vp)) {
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_numoutput--;
|
|
|
|
if (vp->v_numoutput < 0)
|
|
|
|
panic("vwakeup: neg numoutput");
|
1995-02-22 09:39:22 +00:00
|
|
|
if ((vp->v_numoutput == 0) && (vp->v_flag & VBWAIT)) {
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_flag &= ~VBWAIT;
|
1995-01-10 07:32:52 +00:00
|
|
|
wakeup((caddr_t) &vp->v_numoutput);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush out and invalidate all buffers associated with a vnode.
|
|
|
|
* Called with the underlying object locked.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
|
|
|
|
register struct vnode *vp;
|
|
|
|
int flags;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
int slpflag, slptimeo;
|
|
|
|
{
|
|
|
|
register struct buf *bp;
|
|
|
|
struct buf *nbp, *blist;
|
|
|
|
int s, error;
|
1994-08-29 06:09:15 +00:00
|
|
|
vm_object_t object;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-06-10 18:13:19 +00:00
|
|
|
if (flags & V_SAVE) {
|
|
|
|
s = splbio();
|
|
|
|
while (vp->v_numoutput) {
|
|
|
|
vp->v_flag |= VBWAIT;
|
1998-12-22 00:44:11 +00:00
|
|
|
error = tsleep((caddr_t)&vp->v_numoutput,
|
|
|
|
slpflag | (PRIBIO + 1), "vinvlbuf", slptimeo);
|
|
|
|
if (error) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
1998-06-10 18:13:19 +00:00
|
|
|
}
|
1998-10-31 14:20:39 +00:00
|
|
|
if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
|
1998-06-10 18:13:19 +00:00
|
|
|
splx(s);
|
|
|
|
if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, p)) != 0)
|
|
|
|
return (error);
|
|
|
|
s = splbio();
|
|
|
|
if (vp->v_numoutput > 0 ||
|
1998-10-31 14:20:39 +00:00
|
|
|
!TAILQ_EMPTY(&vp->v_dirtyblkhd))
|
1998-06-10 18:13:19 +00:00
|
|
|
panic("vinvalbuf: dirty bufs");
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
1996-08-21 21:56:23 +00:00
|
|
|
s = splbio();
|
1994-05-24 10:09:53 +00:00
|
|
|
for (;;) {
|
1998-10-31 14:20:39 +00:00
|
|
|
blist = TAILQ_FIRST(&vp->v_cleanblkhd);
|
1998-10-29 09:51:28 +00:00
|
|
|
if (!blist)
|
1998-10-31 14:20:39 +00:00
|
|
|
blist = TAILQ_FIRST(&vp->v_dirtyblkhd);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (!blist)
|
|
|
|
break;
|
|
|
|
|
|
|
|
for (bp = blist; bp; bp = nbp) {
|
1998-10-31 14:20:39 +00:00
|
|
|
nbp = TAILQ_NEXT(bp, b_vnbufs);
|
1999-06-26 02:47:16 +00:00
|
|
|
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
|
|
|
|
error = BUF_TIMELOCK(bp,
|
|
|
|
LK_EXCLUSIVE | LK_SLEEPFAIL,
|
|
|
|
"vinvalbuf", slpflag, slptimeo);
|
|
|
|
if (error == ENOLCK)
|
|
|
|
break;
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* XXX Since there are no node locks for NFS, I
|
|
|
|
* believe there is a slight chance that a delayed
|
|
|
|
* write will occur while sleeping just above, so
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
* check for it. Note that vfs_bio_awrite expects
|
|
|
|
* buffers to reside on a queue, while VOP_BWRITE and
|
|
|
|
* brelse do not.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
if (((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI) &&
|
|
|
|
(flags & V_SAVE)) {
|
|
|
|
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (bp->b_vp == vp) {
|
|
|
|
if (bp->b_flags & B_CLUSTEROK) {
|
1999-06-26 02:47:16 +00:00
|
|
|
BUF_UNLOCK(bp);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
vfs_bio_awrite(bp);
|
|
|
|
} else {
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
bremfree(bp);
|
1999-06-26 02:47:16 +00:00
|
|
|
bp->b_flags |= B_ASYNC;
|
1999-06-16 23:27:55 +00:00
|
|
|
VOP_BWRITE(bp->b_vp, bp);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
bremfree(bp);
|
1999-06-16 23:27:55 +00:00
|
|
|
(void) VOP_BWRITE(bp->b_vp, bp);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
}
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
bremfree(bp);
|
1999-06-26 02:47:16 +00:00
|
|
|
bp->b_flags |= (B_INVAL | B_NOCACHE | B_RELBUF);
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
bp->b_flags &= ~B_ASYNC;
|
1994-05-24 10:09:53 +00:00
|
|
|
brelse(bp);
|
|
|
|
}
|
|
|
|
}
|
1994-08-29 06:09:15 +00:00
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
while (vp->v_numoutput > 0) {
|
|
|
|
vp->v_flag |= VBWAIT;
|
|
|
|
tsleep(&vp->v_numoutput, PVM, "vnvlbv", 0);
|
|
|
|
}
|
1997-03-05 04:54:54 +00:00
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
splx(s);
|
|
|
|
|
1995-03-20 02:08:24 +00:00
|
|
|
/*
|
|
|
|
* Destroy the copy in the VM cache, too.
|
|
|
|
*/
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
simple_lock(&vp->v_interlock);
|
1995-06-28 12:01:13 +00:00
|
|
|
object = vp->v_object;
|
1995-03-21 01:13:16 +00:00
|
|
|
if (object != NULL) {
|
1998-10-29 09:51:28 +00:00
|
|
|
vm_object_page_remove(object, 0, 0,
|
|
|
|
(flags & V_SAVE) ? TRUE : FALSE);
|
1994-08-29 06:09:15 +00:00
|
|
|
}
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
|
1998-10-31 14:20:39 +00:00
|
|
|
if (!TAILQ_EMPTY(&vp->v_dirtyblkhd) || !TAILQ_EMPTY(&vp->v_cleanblkhd))
|
1994-05-24 10:09:53 +00:00
|
|
|
panic("vinvalbuf: flush failed");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
/*
|
|
|
|
* Truncate a file's buffer and pages to a specified length. This
|
|
|
|
* is in lieu of the old vinvalbuf mechanism, which performed unneeded
|
|
|
|
* sync activity.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vtruncbuf(vp, cred, p, length, blksize)
|
|
|
|
register struct vnode *vp;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
off_t length;
|
|
|
|
int blksize;
|
|
|
|
{
|
|
|
|
register struct buf *bp;
|
1998-10-25 17:44:59 +00:00
|
|
|
struct buf *nbp;
|
|
|
|
int s, anyfreed;
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
int trunclbn;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Round up to the *next* lbn.
|
|
|
|
*/
|
1998-03-19 18:46:58 +00:00
|
|
|
trunclbn = (length + blksize - 1) / blksize;
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
restart:
|
|
|
|
anyfreed = 1;
|
|
|
|
for (;anyfreed;) {
|
|
|
|
anyfreed = 0;
|
1998-10-31 14:20:39 +00:00
|
|
|
for (bp = TAILQ_FIRST(&vp->v_cleanblkhd); bp; bp = nbp) {
|
|
|
|
nbp = TAILQ_NEXT(bp, b_vnbufs);
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
if (bp->b_lblkno >= trunclbn) {
|
1999-06-26 02:47:16 +00:00
|
|
|
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
|
|
|
|
BUF_LOCK(bp, LK_EXCLUSIVE|LK_SLEEPFAIL);
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
goto restart;
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
} else {
|
|
|
|
bremfree(bp);
|
1999-06-26 02:47:16 +00:00
|
|
|
bp->b_flags |= (B_INVAL | B_RELBUF);
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
bp->b_flags &= ~B_ASYNC;
|
|
|
|
brelse(bp);
|
|
|
|
anyfreed = 1;
|
|
|
|
}
|
1998-10-31 14:20:39 +00:00
|
|
|
if (nbp && (((nbp->b_xflags & B_VNCLEAN) == 0)||
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
(nbp->b_vp != vp) ||
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
(nbp->b_flags & B_DELWRI))) {
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-31 14:20:39 +00:00
|
|
|
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
|
|
|
nbp = TAILQ_NEXT(bp, b_vnbufs);
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
if (bp->b_lblkno >= trunclbn) {
|
1999-06-26 02:47:16 +00:00
|
|
|
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
|
|
|
|
BUF_LOCK(bp, LK_EXCLUSIVE|LK_SLEEPFAIL);
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
goto restart;
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
} else {
|
|
|
|
bremfree(bp);
|
1999-06-26 02:47:16 +00:00
|
|
|
bp->b_flags |= (B_INVAL | B_RELBUF);
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
bp->b_flags &= ~B_ASYNC;
|
|
|
|
brelse(bp);
|
|
|
|
anyfreed = 1;
|
|
|
|
}
|
1998-10-31 14:20:39 +00:00
|
|
|
if (nbp && (((nbp->b_xflags & B_VNDIRTY) == 0)||
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
(nbp->b_vp != vp) ||
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
(nbp->b_flags & B_DELWRI) == 0)) {
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-03-17 06:30:52 +00:00
|
|
|
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
if (length > 0) {
|
|
|
|
restartsync:
|
1998-10-31 14:20:39 +00:00
|
|
|
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
|
|
|
nbp = TAILQ_NEXT(bp, b_vnbufs);
|
1998-03-17 06:30:52 +00:00
|
|
|
if ((bp->b_flags & B_DELWRI) && (bp->b_lblkno < 0)) {
|
1999-06-26 02:47:16 +00:00
|
|
|
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
|
|
|
|
BUF_LOCK(bp, LK_EXCLUSIVE|LK_SLEEPFAIL);
|
|
|
|
goto restart;
|
1998-03-17 06:30:52 +00:00
|
|
|
} else {
|
|
|
|
bremfree(bp);
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
if (bp->b_vp == vp) {
|
|
|
|
bp->b_flags |= B_ASYNC;
|
|
|
|
} else {
|
|
|
|
bp->b_flags &= ~B_ASYNC;
|
|
|
|
}
|
1999-06-16 23:27:55 +00:00
|
|
|
VOP_BWRITE(bp->b_vp, bp);
|
1998-03-17 06:30:52 +00:00
|
|
|
}
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
goto restartsync;
|
1998-03-17 06:30:52 +00:00
|
|
|
}
|
In kern_physio.c fix tsleep priority messup.
In vfs_bio.c, remove b_generation count usage,
remove redundant reassignbuf,
remove redundant spl(s),
manage page PG_ZERO flags more correctly,
utilize in invalid value for b_offset until it
is properly initialized. Add asserts
for #ifdef DIAGNOSTIC, when b_offset is
improperly used.
when a process is not performing I/O, and just waiting
on a buffer generally, make the sleep priority
low.
only check page validity in getblk for B_VMIO buffers.
In vfs_cluster, add b_offset asserts, correct pointer calculation
for clustered reads. Improve readability of certain parts of
the code. Remove redundant spl(s).
In vfs_subr, correct usage of vfs_bio_awrite (From Andrew Gallatin
<gallatin@cs.duke.edu>). More vtruncbuf problems fixed.
1998-03-19 22:48:16 +00:00
|
|
|
|
1998-03-17 06:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (vp->v_numoutput > 0) {
|
|
|
|
vp->v_flag |= VBWAIT;
|
|
|
|
tsleep(&vp->v_numoutput, PVM, "vbtrunc", 0);
|
|
|
|
}
|
|
|
|
|
Some VM improvements, including elimination of alot of Sig-11
problems. Tor Egge and others have helped with various VM bugs
lately, but don't blame him -- blame me!!!
pmap.c:
1) Create an object for kernel page table allocations. This
fixes a bogus allocation method previously used for such, by
grabbing pages from the kernel object, using bogus pindexes.
(This was a code cleanup, and perhaps a minor system stability
issue.)
pmap.c:
2) Pre-set the modify and accessed bits when prudent. This will
decrease bus traffic under certain circumstances.
vfs_bio.c, vfs_cluster.c:
3) Rather than calculating the beginning virtual byte offset
multiple times, stick the offset into the buffer header, so
that the calculated offset can be reused. (Long long multiplies
are often expensive, and this is a probably unmeasurable performance
improvement, and code cleanup.)
vfs_bio.c:
4) Handle write recursion more intelligently (but not perfectly) so
that it is less likely to cause a system panic, and is also
much more robust.
vfs_bio.c:
5) getblk incorrectly wrote out blocks that are incorrectly sized.
The problem is fixed, and writes blocks out ONLY when B_DELWRI
is true.
vfs_bio.c:
6) Check that already constituted buffers have fully valid pages. If
not, then make sure that the B_CACHE bit is not set. (This was
a major source of Sig-11 type problems.)
vfs_bio.c:
7) Fix a potential system deadlock due to an incorrectly specified
sleep priority while waiting for a buffer write operation. The
change that I made opens the system up to serious problems, and
we need to examine the issue of process sleep priorities.
vfs_cluster.c, vfs_bio.c:
8) Make clustered reads work more correctly (and more completely)
when buffers are already constituted, but not fully valid.
(This was another system reliability issue.)
vfs_subr.c, ffs_inode.c:
9) Create a vtruncbuf function, which is used by filesystems that
can truncate files. The vinvalbuf forced a file sync type operation,
while vtruncbuf only invalidates the buffers past the new end of file,
and also invalidates the appropriate pages. (This was a system reliabiliy
and performance issue.)
10) Modify FFS to use vtruncbuf.
vm_object.c:
11) Make the object rundown mechanism for OBJT_VNODE type objects work
more correctly. Included in that fix, create pager entries for
the OBJT_DEAD pager type, so that paging requests that might slip
in during race conditions are properly handled. (This was a system
reliability issue.)
vm_page.c:
12) Make some of the page validation routines be a little less picky
about arguments passed to them. Also, support page invalidation
change the object generation count so that we handle generation
counts a little more robustly.
vm_pageout.c:
13) Further reduce pageout daemon activity when the system doesn't
need help from it. There should be no additional performance
decrease even when the pageout daemon is running. (This was
a significant performance issue.)
vnode_pager.c:
14) Teach the vnode pager to handle race conditions during vnode
deallocations.
1998-03-16 01:56:03 +00:00
|
|
|
splx(s);
|
|
|
|
|
|
|
|
vnode_pager_setsize(vp, length);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Associate a buffer with a vnode.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1994-05-24 10:09:53 +00:00
|
|
|
bgetvp(vp, bp)
|
|
|
|
register struct vnode *vp;
|
|
|
|
register struct buf *bp;
|
|
|
|
{
|
1994-12-23 04:52:55 +00:00
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
KASSERT(bp->b_vp == NULL, ("bgetvp: not free"));
|
1999-01-10 01:58:29 +00:00
|
|
|
|
1997-08-31 07:32:39 +00:00
|
|
|
vhold(vp);
|
1994-05-24 10:09:53 +00:00
|
|
|
bp->b_vp = vp;
|
1999-08-25 12:24:39 +00:00
|
|
|
bp->b_dev = vn_todev(vp);
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Insert onto list for new vnode.
|
|
|
|
*/
|
1994-12-23 04:52:55 +00:00
|
|
|
s = splbio();
|
1998-10-31 14:20:39 +00:00
|
|
|
bp->b_xflags |= B_VNCLEAN;
|
|
|
|
bp->b_xflags &= ~B_VNDIRTY;
|
|
|
|
TAILQ_INSERT_TAIL(&vp->v_cleanblkhd, bp, b_vnbufs);
|
1994-12-23 04:52:55 +00:00
|
|
|
splx(s);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disassociate a buffer from a vnode.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1994-05-24 10:09:53 +00:00
|
|
|
brelvp(bp)
|
|
|
|
register struct buf *bp;
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
1998-10-31 14:20:39 +00:00
|
|
|
struct buflists *listheadp;
|
1994-12-23 04:52:55 +00:00
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
KASSERT(bp->b_vp != NULL, ("brelvp: NULL"));
|
1997-12-29 00:25:11 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Delete from old vnode list, if on one.
|
|
|
|
*/
|
1998-03-08 09:59:44 +00:00
|
|
|
vp = bp->b_vp;
|
1994-12-23 04:52:55 +00:00
|
|
|
s = splbio();
|
1998-10-31 14:20:39 +00:00
|
|
|
if (bp->b_xflags & (B_VNDIRTY|B_VNCLEAN)) {
|
|
|
|
if (bp->b_xflags & B_VNDIRTY)
|
|
|
|
listheadp = &vp->v_dirtyblkhd;
|
|
|
|
else
|
|
|
|
listheadp = &vp->v_cleanblkhd;
|
|
|
|
TAILQ_REMOVE(listheadp, bp, b_vnbufs);
|
|
|
|
bp->b_xflags &= ~(B_VNDIRTY|B_VNCLEAN);
|
|
|
|
}
|
|
|
|
if ((vp->v_flag & VONWORKLST) && TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
|
1998-03-08 09:59:44 +00:00
|
|
|
vp->v_flag &= ~VONWORKLST;
|
|
|
|
LIST_REMOVE(vp, v_synclist);
|
|
|
|
}
|
1994-12-23 04:52:55 +00:00
|
|
|
splx(s);
|
1994-05-24 10:09:53 +00:00
|
|
|
bp->b_vp = (struct vnode *) 0;
|
1997-08-31 07:32:39 +00:00
|
|
|
vdrop(vp);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1998-03-08 09:59:44 +00:00
|
|
|
/*
|
|
|
|
* The workitem queue.
|
|
|
|
*
|
|
|
|
* It is useful to delay writes of file data and filesystem metadata
|
|
|
|
* for tens of seconds so that quickly created and deleted files need
|
|
|
|
* not waste disk bandwidth being created and removed. To realize this,
|
|
|
|
* we append vnodes to a "workitem" queue. When running with a soft
|
|
|
|
* updates implementation, most pending metadata dependencies should
|
|
|
|
* not wait for more than a few seconds. Thus, mounted on block devices
|
|
|
|
* are delayed only about a half the time that file data is delayed.
|
|
|
|
* Similarly, directory updates are more critical, so are only delayed
|
|
|
|
* about a third the time that file data is delayed. Thus, there are
|
|
|
|
* SYNCER_MAXDELAY queues that are processed round-robin at a rate of
|
1999-07-12 15:02:51 +00:00
|
|
|
* one each second (driven off the filesystem syncer process). The
|
1998-03-08 09:59:44 +00:00
|
|
|
* syncer_delayno variable indicates the next queue that is to be processed.
|
|
|
|
* Items that need to be processed soon are placed in this queue:
|
|
|
|
*
|
|
|
|
* syncer_workitem_pending[syncer_delayno]
|
|
|
|
*
|
|
|
|
* A delay of fifteen seconds is done by placing the request fifteen
|
|
|
|
* entries later in the queue:
|
|
|
|
*
|
|
|
|
* syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add an item to the syncer work queue.
|
|
|
|
*/
|
1999-02-19 17:36:58 +00:00
|
|
|
static void
|
|
|
|
vn_syncer_add_to_worklist(struct vnode *vp, int delay)
|
1998-03-08 09:59:44 +00:00
|
|
|
{
|
|
|
|
int s, slot;
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
if (vp->v_flag & VONWORKLST) {
|
|
|
|
LIST_REMOVE(vp, v_synclist);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (delay > syncer_maxdelay - 2)
|
|
|
|
delay = syncer_maxdelay - 2;
|
|
|
|
slot = (syncer_delayno + delay) & syncer_mask;
|
|
|
|
|
|
|
|
LIST_INSERT_HEAD(&syncer_workitem_pending[slot], vp, v_synclist);
|
|
|
|
vp->v_flag |= VONWORKLST;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1999-03-12 02:24:58 +00:00
|
|
|
struct proc *updateproc;
|
1998-03-08 09:59:44 +00:00
|
|
|
static void sched_sync __P((void));
|
1999-07-01 13:21:46 +00:00
|
|
|
static struct kproc_desc up_kp = {
|
1998-03-08 09:59:44 +00:00
|
|
|
"syncer",
|
|
|
|
sched_sync,
|
|
|
|
&updateproc
|
|
|
|
};
|
1999-07-01 13:21:46 +00:00
|
|
|
SYSINIT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp)
|
1998-03-08 09:59:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* System filesystem synchronizer daemon.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sched_sync(void)
|
|
|
|
{
|
|
|
|
struct synclist *slp;
|
|
|
|
struct vnode *vp;
|
|
|
|
long starttime;
|
|
|
|
int s;
|
|
|
|
struct proc *p = updateproc;
|
|
|
|
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
p->p_flag |= P_BUFEXHAUST;
|
|
|
|
|
1998-03-08 09:59:44 +00:00
|
|
|
for (;;) {
|
1998-03-30 09:56:58 +00:00
|
|
|
starttime = time_second;
|
1998-03-08 09:59:44 +00:00
|
|
|
|
|
|
|
/*
|
1999-02-19 17:36:58 +00:00
|
|
|
* Push files whose dirty time has expired. Be careful
|
|
|
|
* of interrupt race on slp queue.
|
1998-03-08 09:59:44 +00:00
|
|
|
*/
|
|
|
|
s = splbio();
|
|
|
|
slp = &syncer_workitem_pending[syncer_delayno];
|
|
|
|
syncer_delayno += 1;
|
|
|
|
if (syncer_delayno == syncer_maxdelay)
|
|
|
|
syncer_delayno = 0;
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
while ((vp = LIST_FIRST(slp)) != NULL) {
|
1999-03-12 02:24:58 +00:00
|
|
|
if (VOP_ISLOCKED(vp) == 0) {
|
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
|
|
|
|
(void) VOP_FSYNC(vp, p->p_ucred, MNT_LAZY, p);
|
|
|
|
VOP_UNLOCK(vp, 0, p);
|
|
|
|
}
|
1999-02-19 17:36:58 +00:00
|
|
|
s = splbio();
|
1998-03-08 09:59:44 +00:00
|
|
|
if (LIST_FIRST(slp) == vp) {
|
1999-03-12 02:24:58 +00:00
|
|
|
/*
|
|
|
|
* Note: v_tag VT_VFS vps can remain on the
|
|
|
|
* worklist too with no dirty blocks, but
|
|
|
|
* since sync_fsync() moves it to a different
|
|
|
|
* slot we are safe.
|
|
|
|
*/
|
1998-10-31 14:20:39 +00:00
|
|
|
if (TAILQ_EMPTY(&vp->v_dirtyblkhd) &&
|
1998-03-08 09:59:44 +00:00
|
|
|
vp->v_type != VBLK)
|
1999-02-19 17:36:58 +00:00
|
|
|
panic("sched_sync: fsync failed vp %p tag %d", vp, vp->v_tag);
|
1998-03-08 09:59:44 +00:00
|
|
|
/*
|
1999-02-19 17:36:58 +00:00
|
|
|
* Put us back on the worklist. The worklist
|
|
|
|
* routine will remove us from our current
|
|
|
|
* position and then add us back in at a later
|
|
|
|
* position.
|
1998-03-08 09:59:44 +00:00
|
|
|
*/
|
|
|
|
vn_syncer_add_to_worklist(vp, syncdelay);
|
|
|
|
}
|
1999-02-19 17:36:58 +00:00
|
|
|
splx(s);
|
1998-03-08 09:59:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do soft update processing.
|
|
|
|
*/
|
|
|
|
if (bioops.io_sync)
|
|
|
|
(*bioops.io_sync)(NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The variable rushjob allows the kernel to speed up the
|
|
|
|
* processing of the filesystem syncer process. A rushjob
|
|
|
|
* value of N tells the filesystem syncer to process the next
|
|
|
|
* N seconds worth of work on its queue ASAP. Currently rushjob
|
|
|
|
* is used by the soft update code to speed up the filesystem
|
|
|
|
* syncer process when the incore state is getting so far
|
|
|
|
* ahead of the disk that the kernel memory pool is being
|
|
|
|
* threatened with exhaustion.
|
|
|
|
*/
|
|
|
|
if (rushjob > 0) {
|
|
|
|
rushjob -= 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If it has taken us less than a second to process the
|
|
|
|
* current work, then wait. Otherwise start right over
|
|
|
|
* again. We can still lose time if any single round
|
|
|
|
* takes more than two seconds, but it does not really
|
|
|
|
* matter as we are just trying to generally pace the
|
|
|
|
* filesystem activity.
|
|
|
|
*/
|
1998-03-30 09:56:58 +00:00
|
|
|
if (time_second == starttime)
|
1998-03-08 09:59:44 +00:00
|
|
|
tsleep(&lbolt, PPAUSE, "syncer", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-15 23:37:29 +00:00
|
|
|
/*
|
|
|
|
* Request the syncer daemon to speed up its work.
|
|
|
|
* We never push it to speed up more than half of its
|
|
|
|
* normal turn time, otherwise it could take over the cpu.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
speedup_syncer()
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
if (updateproc->p_wchan == &lbolt)
|
|
|
|
setrunnable(updateproc);
|
|
|
|
splx(s);
|
|
|
|
if (rushjob < syncdelay / 2) {
|
|
|
|
rushjob += 1;
|
|
|
|
stat_rush_requests += 1;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
/*
|
|
|
|
* Associate a p-buffer with a vnode.
|
1999-01-21 08:29:12 +00:00
|
|
|
*
|
|
|
|
* Also sets B_PAGING flag to indicate that vnode is not fully associated
|
|
|
|
* with the buffer. i.e. the bp has not been linked into the vnode or
|
|
|
|
* ref-counted.
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
pbgetvp(vp, bp)
|
|
|
|
register struct vnode *vp;
|
|
|
|
register struct buf *bp;
|
|
|
|
{
|
1999-01-10 01:58:29 +00:00
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
KASSERT(bp->b_vp == NULL, ("pbgetvp: not free"));
|
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
bp->b_vp = vp;
|
1999-01-21 08:29:12 +00:00
|
|
|
bp->b_flags |= B_PAGING;
|
1999-08-25 12:24:39 +00:00
|
|
|
bp->b_dev = vn_todev(vp);
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disassociate a p-buffer from a vnode.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pbrelvp(bp)
|
|
|
|
register struct buf *bp;
|
|
|
|
{
|
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
KASSERT(bp->b_vp != NULL, ("pbrelvp: NULL"));
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
1999-01-21 08:29:12 +00:00
|
|
|
#if !defined(MAX_PERF)
|
|
|
|
/* XXX REMOVE ME */
|
|
|
|
if (bp->b_vnbufs.tqe_next != NULL) {
|
|
|
|
panic(
|
|
|
|
"relpbuf(): b_vp was probably reassignbuf()d %p %x",
|
|
|
|
bp,
|
|
|
|
(int)bp->b_flags
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
bp->b_vp = (struct vnode *) 0;
|
1999-01-21 08:29:12 +00:00
|
|
|
bp->b_flags &= ~B_PAGING;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pbreassignbuf(bp, newvp)
|
|
|
|
struct buf *bp;
|
|
|
|
struct vnode *newvp;
|
|
|
|
{
|
|
|
|
#if !defined(MAX_PERF)
|
|
|
|
if ((bp->b_flags & B_PAGING) == 0) {
|
|
|
|
panic(
|
|
|
|
"pbreassignbuf() on non phys bp %p",
|
|
|
|
bp
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bp->b_vp = newvp;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Reassign a buffer from one vnode to another.
|
|
|
|
* Used to assign file specific control information
|
|
|
|
* (indirect blocks) to the vnode to which they belong.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1994-05-24 10:09:53 +00:00
|
|
|
reassignbuf(bp, newvp)
|
|
|
|
register struct buf *bp;
|
|
|
|
register struct vnode *newvp;
|
|
|
|
{
|
1998-03-08 09:59:44 +00:00
|
|
|
struct buflists *listheadp;
|
|
|
|
int delay;
|
1996-08-15 06:45:01 +00:00
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
if (newvp == NULL) {
|
|
|
|
printf("reassignbuf: NULL");
|
|
|
|
return;
|
|
|
|
}
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
++reassignbufcalls;
|
1996-08-15 06:45:01 +00:00
|
|
|
|
1999-01-21 08:29:12 +00:00
|
|
|
#if !defined(MAX_PERF)
|
|
|
|
/*
|
|
|
|
* B_PAGING flagged buffers cannot be reassigned because their vp
|
|
|
|
* is not fully linked in.
|
|
|
|
*/
|
|
|
|
if (bp->b_flags & B_PAGING)
|
|
|
|
panic("cannot reassign paging buffer");
|
|
|
|
#endif
|
|
|
|
|
1996-08-15 06:45:01 +00:00
|
|
|
s = splbio();
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Delete from old vnode list, if on one.
|
|
|
|
*/
|
1998-10-31 14:20:39 +00:00
|
|
|
if (bp->b_xflags & (B_VNDIRTY|B_VNCLEAN)) {
|
|
|
|
if (bp->b_xflags & B_VNDIRTY)
|
1999-03-12 02:24:58 +00:00
|
|
|
listheadp = &bp->b_vp->v_dirtyblkhd;
|
1998-10-31 14:20:39 +00:00
|
|
|
else
|
1999-03-12 02:24:58 +00:00
|
|
|
listheadp = &bp->b_vp->v_cleanblkhd;
|
1998-10-31 14:20:39 +00:00
|
|
|
TAILQ_REMOVE(listheadp, bp, b_vnbufs);
|
|
|
|
bp->b_xflags &= ~(B_VNDIRTY|B_VNCLEAN);
|
1999-03-12 02:24:58 +00:00
|
|
|
if (bp->b_vp != newvp) {
|
|
|
|
vdrop(bp->b_vp);
|
|
|
|
bp->b_vp = NULL; /* for clarification */
|
|
|
|
}
|
1997-08-31 07:32:39 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* If dirty, put on list of dirty buffers; otherwise insert onto list
|
|
|
|
* of clean buffers.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
if (bp->b_flags & B_DELWRI) {
|
|
|
|
struct buf *tbp;
|
|
|
|
|
1998-03-08 09:59:44 +00:00
|
|
|
listheadp = &newvp->v_dirtyblkhd;
|
|
|
|
if ((newvp->v_flag & VONWORKLST) == 0) {
|
|
|
|
switch (newvp->v_type) {
|
|
|
|
case VDIR:
|
1999-06-15 23:37:29 +00:00
|
|
|
delay = dirdelay;
|
1998-03-08 09:59:44 +00:00
|
|
|
break;
|
|
|
|
case VBLK:
|
|
|
|
if (newvp->v_specmountpoint != NULL) {
|
1999-06-15 23:37:29 +00:00
|
|
|
delay = metadelay;
|
1998-03-08 09:59:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
default:
|
1999-06-15 23:37:29 +00:00
|
|
|
delay = filedelay;
|
1998-03-08 09:59:44 +00:00
|
|
|
}
|
|
|
|
vn_syncer_add_to_worklist(newvp, delay);
|
|
|
|
}
|
1998-10-31 14:20:39 +00:00
|
|
|
bp->b_xflags |= B_VNDIRTY;
|
|
|
|
tbp = TAILQ_FIRST(listheadp);
|
|
|
|
if (tbp == NULL ||
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
bp->b_lblkno == 0 ||
|
|
|
|
(bp->b_lblkno > 0 && bp->b_lblkno < tbp->b_lblkno)) {
|
1998-10-31 14:20:39 +00:00
|
|
|
TAILQ_INSERT_HEAD(listheadp, bp, b_vnbufs);
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
++reassignbufsortgood;
|
|
|
|
} else if (bp->b_lblkno < 0) {
|
|
|
|
TAILQ_INSERT_TAIL(listheadp, bp, b_vnbufs);
|
|
|
|
++reassignbufsortgood;
|
|
|
|
} else if (reassignbufmethod == 1) {
|
|
|
|
/*
|
|
|
|
* New sorting algorithm, only handle sequential case,
|
|
|
|
* otherwise guess.
|
|
|
|
*/
|
|
|
|
if ((tbp = gbincore(newvp, bp->b_lblkno - 1)) != NULL &&
|
|
|
|
(tbp->b_xflags & B_VNDIRTY)) {
|
1998-10-31 14:20:39 +00:00
|
|
|
TAILQ_INSERT_AFTER(listheadp, tbp, bp, b_vnbufs);
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
++reassignbufsortgood;
|
1998-10-31 14:20:39 +00:00
|
|
|
} else {
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
TAILQ_INSERT_HEAD(listheadp, bp, b_vnbufs);
|
|
|
|
++reassignbufsortbad;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Old sorting algorithm, scan queue and insert
|
|
|
|
*/
|
|
|
|
struct buf *ttbp;
|
|
|
|
while ((ttbp = TAILQ_NEXT(tbp, b_vnbufs)) &&
|
|
|
|
(ttbp->b_lblkno < bp->b_lblkno)) {
|
|
|
|
++reassignbufloops;
|
|
|
|
tbp = ttbp;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
}
|
The buffer queue mechanism has been reformulated. Instead of having
QUEUE_AGE, QUEUE_LRU, and QUEUE_EMPTY we instead have QUEUE_CLEAN,
QUEUE_DIRTY, QUEUE_EMPTY, and QUEUE_EMPTYKVA. With this patch clean
and dirty buffers have been separated. Empty buffers with KVM
assignments have been separated from truely empty buffers. getnewbuf()
has been rewritten and now operates in a 100% optimal fashion. That is,
it is able to find precisely the right kind of buffer it needs to
allocate a new buffer, defragment KVM, or to free-up an existing buffer
when the buffer cache is full (which is a steady-state situation for
the buffer cache).
Buffer flushing has been reorganized. Previously buffers were flushed
in the context of whatever process hit the conditions forcing buffer
flushing to occur. This resulted in processes blocking on conditions
unrelated to what they were doing. This also resulted in inappropriate
VFS stacking chains due to multiple processes getting stuck trying to
flush dirty buffers or due to a single process getting into a situation
where it might attempt to flush buffers recursively - a situation that
was only partially fixed in prior commits. We have added a new daemon
called the buf_daemon which is responsible for flushing dirty buffers
when the number of dirty buffers exceeds the vfs.hidirtybuffers limit.
This daemon attempts to dynamically adjust the rate at which dirty buffers
are flushed such that getnewbuf() calls (almost) never block.
The number of nbufs and amount of buffer space is now scaled past the
8MB limit that was previously imposed for systems with over 64MB of
memory, and the vfs.{lo,hi}dirtybuffers limits have been relaxed
somewhat. The number of physical buffers has been increased with the
intention that we will manage physical I/O differently in the future.
reassignbuf previously attempted to keep the dirtyblkhd list sorted which
could result in non-deterministic operation under certain conditions,
such as when a large number of dirty buffers are being managed. This
algorithm has been changed. reassignbuf now keeps buffers locally sorted
if it can do so cheaply, and otherwise gives up and adds buffers to
the head of the dirtyblkhd list. The new algorithm is deterministic but
not perfect. The new algorithm greatly reduces problems that previously
occured when write_behind was turned off in the system.
The P_FLSINPROG proc->p_flag bit has been replaced by the more descriptive
P_BUFEXHAUST bit. This bit allows processes working with filesystem
buffers to use available emergency reserves. Normal processes do not set
this bit and are not allowed to dig into emergency reserves. The purpose
of this bit is to avoid low-memory deadlocks.
A small race condition was fixed in getpbuf() in vm/vm_pager.c.
Submitted by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Kirk McKusick <mckusick@mckusick.com>
1999-07-04 00:25:38 +00:00
|
|
|
TAILQ_INSERT_AFTER(listheadp, tbp, bp, b_vnbufs);
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
1998-10-31 14:20:39 +00:00
|
|
|
bp->b_xflags |= B_VNCLEAN;
|
|
|
|
TAILQ_INSERT_TAIL(&newvp->v_cleanblkhd, bp, b_vnbufs);
|
1998-03-08 09:59:44 +00:00
|
|
|
if ((newvp->v_flag & VONWORKLST) &&
|
1998-10-31 14:20:39 +00:00
|
|
|
TAILQ_EMPTY(&newvp->v_dirtyblkhd)) {
|
1998-03-08 09:59:44 +00:00
|
|
|
newvp->v_flag &= ~VONWORKLST;
|
|
|
|
LIST_REMOVE(newvp, v_synclist);
|
|
|
|
}
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
}
|
1999-03-12 02:24:58 +00:00
|
|
|
if (bp->b_vp != newvp) {
|
|
|
|
bp->b_vp = newvp;
|
|
|
|
vhold(bp->b_vp);
|
|
|
|
}
|
1996-08-15 06:45:01 +00:00
|
|
|
splx(s);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a vnode for a block device.
|
1997-09-07 16:21:11 +00:00
|
|
|
* Used for mounting the root file system.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-05-24 10:09:53 +00:00
|
|
|
bdevvp(dev, vpp)
|
|
|
|
dev_t dev;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
|
|
|
register struct vnode *vp;
|
|
|
|
struct vnode *nvp;
|
|
|
|
int error;
|
|
|
|
|
1999-05-31 11:29:30 +00:00
|
|
|
if (dev == NODEV) {
|
1998-10-25 16:11:49 +00:00
|
|
|
*vpp = NULLVP;
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error) {
|
1998-10-25 16:11:49 +00:00
|
|
|
*vpp = NULLVP;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
vp = nvp;
|
1999-07-20 09:47:55 +00:00
|
|
|
vp->v_type = VBLK;
|
1999-08-26 14:53:31 +00:00
|
|
|
addalias(vp, dev);
|
1994-05-24 10:09:53 +00:00
|
|
|
*vpp = vp;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-08-26 14:53:31 +00:00
|
|
|
* Add vnode to the alias list hung off the dev_t.
|
|
|
|
*
|
|
|
|
* The reason for this gunk is that multiple vnodes can reference
|
|
|
|
* the same physical device, so checking vp->v_usecount to see
|
|
|
|
* how many users there are is inadequate; the v_usecount for
|
|
|
|
* the vnodes need to be accumulated. vcount() does that.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1999-08-26 14:53:31 +00:00
|
|
|
void
|
|
|
|
addaliasu(nvp, nvp_rdev)
|
|
|
|
struct vnode *nvp;
|
Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.
Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()
For now they're functions, they will become in-line functions
after one of the next two steps in this process.
Return major/minor/makedev to macro-hood for userland.
Register a name in cdevsw[] for the "filedescriptor" driver.
In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.
In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).
A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.
Without DEVT_FASCIST I belive this patch is a no-op.
Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.
Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
1999-05-11 19:55:07 +00:00
|
|
|
udev_t nvp_rdev;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (nvp->v_type != VBLK && nvp->v_type != VCHR)
|
1999-08-26 14:53:31 +00:00
|
|
|
panic("addaliasu on non-special vnode");
|
1999-09-19 06:24:21 +00:00
|
|
|
addalias(nvp, udev2dev(nvp_rdev, nvp->v_type == VBLK ? 1 : 0));
|
1999-07-20 09:47:55 +00:00
|
|
|
}
|
Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.
Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()
For now they're functions, they will become in-line functions
after one of the next two steps in this process.
Return major/minor/makedev to macro-hood for userland.
Register a name in cdevsw[] for the "filedescriptor" driver.
In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.
In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).
A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.
Without DEVT_FASCIST I belive this patch is a no-op.
Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.
Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
1999-05-11 19:55:07 +00:00
|
|
|
|
1999-08-26 14:53:31 +00:00
|
|
|
void
|
|
|
|
addalias(nvp, dev)
|
|
|
|
struct vnode *nvp;
|
1999-07-20 09:47:55 +00:00
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (nvp->v_type != VBLK && nvp->v_type != VCHR)
|
1999-08-26 14:53:31 +00:00
|
|
|
panic("addalias on non-special vnode");
|
1999-02-25 05:22:30 +00:00
|
|
|
|
1999-08-26 14:53:31 +00:00
|
|
|
nvp->v_rdev = dev;
|
|
|
|
simple_lock(&spechash_slock);
|
|
|
|
SLIST_INSERT_HEAD(&dev->si_hlist, nvp, v_specnext);
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&spechash_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Grab a particular vnode from the free list, increment its
|
1999-07-12 15:02:51 +00:00
|
|
|
* reference count and lock it. The vnode lock bit is set if the
|
1994-05-24 10:09:53 +00:00
|
|
|
* vnode is being eliminated in vgone. The process is awakened
|
|
|
|
* when the transition is completed, and an error returned to
|
|
|
|
* indicate that the vnode is no longer usable (possibly having
|
|
|
|
* been changed to a new file system type).
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1997-02-10 02:22:35 +00:00
|
|
|
vget(vp, flags, p)
|
1994-05-24 10:09:53 +00:00
|
|
|
register struct vnode *vp;
|
1997-02-10 02:22:35 +00:00
|
|
|
int flags;
|
|
|
|
struct proc *p;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
int error;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* If the vnode is in the process of being cleaned out for
|
|
|
|
* another use, we wait for the cleaning to finish and then
|
|
|
|
* return failure. Cleaning is determined by checking that
|
|
|
|
* the VXLOCK flag is set.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((flags & LK_INTERLOCK) == 0) {
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
}
|
|
|
|
if (vp->v_flag & VXLOCK) {
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_flag |= VXWANT;
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
tsleep((caddr_t)vp, PINOD, "vget", 0);
|
|
|
|
return (ENOENT);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-12-29 00:25:11 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_usecount++;
|
1997-12-29 00:25:11 +00:00
|
|
|
|
1997-08-31 07:32:39 +00:00
|
|
|
if (VSHOULDBUSY(vp))
|
|
|
|
vbusy(vp);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (flags & LK_TYPE_MASK) {
|
1998-02-23 06:59:52 +00:00
|
|
|
if ((error = vn_lock(vp, flags | LK_INTERLOCK, p)) != 0) {
|
|
|
|
/*
|
|
|
|
* must expand vrele here because we do not want
|
|
|
|
* to call VOP_INACTIVE if the reference count
|
|
|
|
* drops back to zero since it was never really
|
|
|
|
* active. We must remove it from the free list
|
|
|
|
* before sleeping so that multiple processes do
|
|
|
|
* not try to recycle it.
|
|
|
|
*/
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
vp->v_usecount--;
|
|
|
|
if (VSHOULDFREE(vp))
|
|
|
|
vfree(vp);
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
1996-08-21 21:56:23 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return (0);
|
|
|
|
}
|
1997-12-29 00:25:11 +00:00
|
|
|
|
1997-12-29 16:54:03 +00:00
|
|
|
void
|
|
|
|
vref(struct vnode *vp)
|
|
|
|
{
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
vp->v_usecount++;
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-12-29 00:25:11 +00:00
|
|
|
* Vnode put/release.
|
|
|
|
* If count drops to zero, call inactive routine and return to freelist.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1997-12-29 00:25:11 +00:00
|
|
|
vrele(vp)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
{
|
1997-12-29 00:25:11 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
|
|
|
|
1999-01-10 01:58:29 +00:00
|
|
|
KASSERT(vp != NULL, ("vrele: null vp"));
|
1999-01-08 17:31:30 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&vp->v_interlock);
|
1996-08-21 21:56:23 +00:00
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
if (vp->v_usecount > 1) {
|
1996-09-28 03:36:07 +00:00
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
vp->v_usecount--;
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1997-12-29 00:25:11 +00:00
|
|
|
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vp->v_usecount == 1) {
|
1997-12-29 00:25:11 +00:00
|
|
|
|
|
|
|
vp->v_usecount--;
|
|
|
|
if (VSHOULDFREE(vp))
|
|
|
|
vfree(vp);
|
|
|
|
/*
|
|
|
|
* If we are doing a vput, the node is already locked, and we must
|
|
|
|
* call VOP_INACTIVE with the node locked. So, in the case of
|
|
|
|
* vrele, we explicitly lock the vnode before calling VOP_INACTIVE.
|
|
|
|
*/
|
|
|
|
if (vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, p) == 0) {
|
|
|
|
VOP_INACTIVE(vp, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
vprint("vrele: negative ref count", vp);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1997-12-29 00:25:11 +00:00
|
|
|
#endif
|
|
|
|
panic("vrele: negative ref cnt");
|
1996-08-21 21:56:23 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
void
|
|
|
|
vput(vp)
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
KASSERT(vp != NULL, ("vput: null vp"));
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&vp->v_interlock);
|
1996-08-21 21:56:23 +00:00
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
if (vp->v_usecount > 1) {
|
1997-12-19 09:03:37 +00:00
|
|
|
|
1997-08-31 07:32:39 +00:00
|
|
|
vp->v_usecount--;
|
1997-12-29 00:25:11 +00:00
|
|
|
VOP_UNLOCK(vp, LK_INTERLOCK, p);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
1996-08-21 21:56:23 +00:00
|
|
|
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (vp->v_usecount == 1) {
|
1996-08-21 21:56:23 +00:00
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
vp->v_usecount--;
|
|
|
|
if (VSHOULDFREE(vp))
|
|
|
|
vfree(vp);
|
1997-02-27 02:57:03 +00:00
|
|
|
/*
|
|
|
|
* If we are doing a vput, the node is already locked, and we must
|
|
|
|
* call VOP_INACTIVE with the node locked. So, in the case of
|
|
|
|
* vrele, we explicitly lock the vnode before calling VOP_INACTIVE.
|
|
|
|
*/
|
1997-02-27 05:28:58 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1997-02-10 02:22:35 +00:00
|
|
|
VOP_INACTIVE(vp, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-12-29 00:25:11 +00:00
|
|
|
} else {
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
vprint("vput: negative ref count", vp);
|
|
|
|
#endif
|
|
|
|
panic("vput: negative ref cnt");
|
|
|
|
}
|
1997-02-27 02:57:03 +00:00
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-08-31 07:32:39 +00:00
|
|
|
* Somebody doesn't want the vnode recycled.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
|
|
|
vhold(vp)
|
1994-05-24 10:09:53 +00:00
|
|
|
register struct vnode *vp;
|
|
|
|
{
|
1998-03-14 02:55:01 +00:00
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-03-14 02:55:01 +00:00
|
|
|
s = splbio();
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_holdcnt++;
|
1997-08-31 07:32:39 +00:00
|
|
|
if (VSHOULDBUSY(vp))
|
|
|
|
vbusy(vp);
|
1998-03-14 02:55:01 +00:00
|
|
|
splx(s);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-08-31 07:32:39 +00:00
|
|
|
* One less who cares about this vnode.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1997-08-31 07:32:39 +00:00
|
|
|
vdrop(vp)
|
1994-05-24 10:09:53 +00:00
|
|
|
register struct vnode *vp;
|
|
|
|
{
|
1998-03-14 02:55:01 +00:00
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-03-14 02:55:01 +00:00
|
|
|
s = splbio();
|
1994-05-24 10:09:53 +00:00
|
|
|
if (vp->v_holdcnt <= 0)
|
1998-03-08 09:59:44 +00:00
|
|
|
panic("vdrop: holdcnt");
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_holdcnt--;
|
1997-08-31 07:32:39 +00:00
|
|
|
if (VSHOULDFREE(vp))
|
|
|
|
vfree(vp);
|
1998-03-14 02:55:01 +00:00
|
|
|
splx(s);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove any vnodes in the vnode table belonging to mount point mp.
|
|
|
|
*
|
|
|
|
* If MNT_NOFORCE is specified, there should not be any active ones,
|
|
|
|
* return error if any are found (nb: this is a user error, not a
|
|
|
|
* system error). If MNT_FORCE is specified, detach any active vnodes
|
|
|
|
* that are found.
|
|
|
|
*/
|
|
|
|
#ifdef DIAGNOSTIC
|
1995-12-17 21:23:44 +00:00
|
|
|
static int busyprt = 0; /* print out busy vnodes */
|
1997-04-01 13:05:34 +00:00
|
|
|
SYSCTL_INT(_debug, OID_AUTO, busyprt, CTLFLAG_RW, &busyprt, 0, "");
|
1994-05-24 10:09:53 +00:00
|
|
|
#endif
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-05-24 10:09:53 +00:00
|
|
|
vflush(mp, skipvp, flags)
|
|
|
|
struct mount *mp;
|
|
|
|
struct vnode *skipvp;
|
|
|
|
int flags;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
|
|
|
struct vnode *vp, *nvp;
|
1994-05-24 10:09:53 +00:00
|
|
|
int busy = 0;
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
loop:
|
|
|
|
for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
|
1995-03-11 22:29:07 +00:00
|
|
|
/*
|
|
|
|
* Make sure this vnode wasn't reclaimed in getnewvnode().
|
|
|
|
* Start over if it has (it won't be on the list anymore).
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
if (vp->v_mount != mp)
|
|
|
|
goto loop;
|
|
|
|
nvp = vp->v_mntvnodes.le_next;
|
|
|
|
/*
|
|
|
|
* Skip over a selected vnode.
|
|
|
|
*/
|
|
|
|
if (vp == skipvp)
|
|
|
|
continue;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
simple_lock(&vp->v_interlock);
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Skip over a vnodes marked VSYSTEM.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((flags & SKIPSYSTEM) && (vp->v_flag & VSYSTEM)) {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* If WRITECLOSE is set, only flush out regular file vnodes
|
|
|
|
* open for writing.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if ((flags & WRITECLOSE) &&
|
1997-02-10 02:22:35 +00:00
|
|
|
(vp->v_writecount == 0 || vp->v_type != VREG)) {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1996-08-21 21:56:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* With v_usecount == 0, all we need to do is clear out the
|
|
|
|
* vnode data structures and we are done.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (vp->v_usecount == 0) {
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&mntvnode_slock);
|
|
|
|
vgonel(vp, p);
|
|
|
|
simple_lock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
1996-10-17 02:49:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* If FORCECLOSE is set, forcibly close the vnode. For block
|
|
|
|
* or character devices, revert to an anonymous device. For
|
|
|
|
* all other files, just kill them.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (flags & FORCECLOSE) {
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (vp->v_type != VBLK && vp->v_type != VCHR) {
|
1997-02-10 02:22:35 +00:00
|
|
|
vgonel(vp, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
} else {
|
1997-02-10 02:22:35 +00:00
|
|
|
vclean(vp, 0, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_op = spec_vnodeop_p;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
insmntque(vp, (struct mount *) 0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (busyprt)
|
|
|
|
vprint("vflush: busy vnode", vp);
|
|
|
|
#endif
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-05-24 10:09:53 +00:00
|
|
|
busy++;
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (busy)
|
|
|
|
return (EBUSY);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disassociate the underlying file system from a vnode.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
static void
|
1997-09-16 11:44:05 +00:00
|
|
|
vclean(vp, flags, p)
|
|
|
|
struct vnode *vp;
|
|
|
|
int flags;
|
|
|
|
struct proc *p;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
int active;
|
1998-02-05 03:32:49 +00:00
|
|
|
vm_object_t obj;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* Check to see if the vnode is in use. If so we have to reference it
|
|
|
|
* before we clean it out so that its count cannot fall to zero and
|
|
|
|
* generate a race against ourselves to recycle it.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1994-09-25 19:34:02 +00:00
|
|
|
if ((active = vp->v_usecount))
|
1997-02-10 02:22:35 +00:00
|
|
|
vp->v_usecount++;
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* Prevent the vnode from being recycled or brought into use while we
|
|
|
|
* clean it out.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (vp->v_flag & VXLOCK)
|
|
|
|
panic("vclean: deadlock");
|
|
|
|
vp->v_flag |= VXLOCK;
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Even if the count is zero, the VOP_INACTIVE routine may still
|
|
|
|
* have the object locked while it cleans it out. The VOP_LOCK
|
|
|
|
* ensures that the VOP_INACTIVE routine is done with its work.
|
|
|
|
* For active vnodes, it ensures that no other activity can
|
|
|
|
* occur while the underlying object is being cleaned out.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
VOP_LOCK(vp, LK_DRAIN | LK_INTERLOCK, p);
|
1997-06-22 03:00:24 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Clean out any buffers associated with the vnode.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1998-01-17 09:17:02 +00:00
|
|
|
vinvalbuf(vp, V_SAVE, NOCRED, p, 0, 0);
|
1999-01-28 00:57:57 +00:00
|
|
|
if ((obj = vp->v_object) != NULL) {
|
1998-02-05 03:32:49 +00:00
|
|
|
if (obj->ref_count == 0) {
|
1998-01-17 09:17:02 +00:00
|
|
|
/*
|
1999-09-19 06:24:21 +00:00
|
|
|
* vclean() may be called twice. The first time removes the
|
|
|
|
* primary reference to the object, the second time goes
|
|
|
|
* one further and is a special-case to terminate the object.
|
1998-01-17 09:17:02 +00:00
|
|
|
*/
|
1998-02-05 03:32:49 +00:00
|
|
|
vm_object_terminate(obj);
|
1998-01-17 09:17:02 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Woe to the process that tries to page now :-).
|
|
|
|
*/
|
1998-02-05 03:32:49 +00:00
|
|
|
vm_pager_deallocate(obj);
|
1998-01-17 09:17:02 +00:00
|
|
|
}
|
|
|
|
}
|
1997-06-22 03:00:24 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* If purging an active vnode, it must be closed and
|
|
|
|
* deactivated before being reclaimed. Note that the
|
|
|
|
* VOP_INACTIVE will unlock the vnode.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (active) {
|
|
|
|
if (flags & DOCLOSE)
|
1998-12-24 12:07:16 +00:00
|
|
|
VOP_CLOSE(vp, FNONBLOCK, NOCRED, p);
|
1997-02-10 02:22:35 +00:00
|
|
|
VOP_INACTIVE(vp, p);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Any other processes trying to obtain this lock must first
|
|
|
|
* wait for VXLOCK to clear, then call the new lock operation.
|
|
|
|
*/
|
|
|
|
VOP_UNLOCK(vp, 0, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Reclaim the vnode.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (VOP_RECLAIM(vp, p))
|
1994-05-24 10:09:53 +00:00
|
|
|
panic("vclean: cannot reclaim");
|
1998-02-23 06:59:52 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (active)
|
|
|
|
vrele(vp);
|
1998-02-23 06:59:52 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
cache_purge(vp);
|
|
|
|
if (vp->v_vnlock) {
|
|
|
|
FREE(vp->v_vnlock, M_VNODE);
|
|
|
|
vp->v_vnlock = NULL;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-02-23 06:59:52 +00:00
|
|
|
if (VSHOULDFREE(vp))
|
|
|
|
vfree(vp);
|
1999-08-29 09:09:12 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Done with purge, notify sleepers of the grim news.
|
|
|
|
*/
|
|
|
|
vp->v_op = dead_vnodeop_p;
|
1997-12-15 03:09:59 +00:00
|
|
|
vn_pollgone(vp);
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_tag = VT_NON;
|
|
|
|
vp->v_flag &= ~VXLOCK;
|
|
|
|
if (vp->v_flag & VXWANT) {
|
|
|
|
vp->v_flag &= ~VXWANT;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
wakeup((caddr_t) vp);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Eliminate all activity associated with the requested vnode
|
1994-05-24 10:09:53 +00:00
|
|
|
* and with all vnodes aliased to the requested vnode.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
int
|
|
|
|
vop_revoke(ap)
|
|
|
|
struct vop_revoke_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_flags;
|
|
|
|
} */ *ap;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vp, *vq;
|
1999-08-26 14:53:31 +00:00
|
|
|
dev_t dev;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1999-01-08 17:31:30 +00:00
|
|
|
KASSERT((ap->a_flags & REVOKEALL) != 0, ("vop_revoke"));
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
vp = ap->a_vp;
|
1999-08-26 14:53:31 +00:00
|
|
|
/*
|
|
|
|
* If a vgone (or vclean) is already in progress,
|
|
|
|
* wait until it is done and return.
|
|
|
|
*/
|
|
|
|
if (vp->v_flag & VXLOCK) {
|
|
|
|
vp->v_flag |= VXWANT;
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1999-08-26 14:53:31 +00:00
|
|
|
tsleep((caddr_t)vp, PINOD, "vop_revokeall", 0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
dev = vp->v_rdev;
|
|
|
|
for (;;) {
|
|
|
|
simple_lock(&spechash_slock);
|
|
|
|
vq = SLIST_FIRST(&dev->si_hlist);
|
|
|
|
simple_unlock(&spechash_slock);
|
|
|
|
if (!vq)
|
|
|
|
break;
|
|
|
|
vgone(vq);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Recycle an unused vnode to the front of the free list.
|
|
|
|
* Release the passed interlock if the vnode will be recycled.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vrecycle(vp, inter_lkp, p)
|
|
|
|
struct vnode *vp;
|
|
|
|
struct simplelock *inter_lkp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
if (vp->v_usecount == 0) {
|
|
|
|
if (inter_lkp) {
|
|
|
|
simple_unlock(inter_lkp);
|
|
|
|
}
|
|
|
|
vgonel(vp, p);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Eliminate all activity associated with a vnode
|
|
|
|
* in preparation for reuse.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
|
|
|
vgone(vp)
|
1994-05-24 10:09:53 +00:00
|
|
|
register struct vnode *vp;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
|
|
|
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
vgonel(vp, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vgone, with the vp interlock held.
|
|
|
|
*/
|
1997-04-01 13:05:34 +00:00
|
|
|
static void
|
1997-02-10 02:22:35 +00:00
|
|
|
vgonel(vp, p)
|
|
|
|
struct vnode *vp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1998-01-12 01:46:33 +00:00
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* If a vgone (or vclean) is already in progress,
|
|
|
|
* wait until it is done and return.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (vp->v_flag & VXLOCK) {
|
|
|
|
vp->v_flag |= VXWANT;
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
tsleep((caddr_t)vp, PINOD, "vgone", 0);
|
1994-05-24 10:09:53 +00:00
|
|
|
return;
|
|
|
|
}
|
1996-10-17 02:49:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Clean out the filesystem specific data.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
vclean(vp, DOCLOSE, p);
|
VM level code cleanups.
1) Start using TSM.
Struct procs continue to point to upages structure, after being freed.
Struct vmspace continues to point to pte object and kva space for kstack.
u_map is now superfluous.
2) vm_map's don't need to be reference counted. They always exist either
in the kernel or in a vmspace. The vmspaces are managed by reference
counts.
3) Remove the "wired" vm_map nonsense.
4) No need to keep a cache of kernel stack kva's.
5) Get rid of strange looking ++var, and change to var++.
6) Change more data structures to use our "zone" allocator. Added
struct proc, struct vmspace and struct vnode. This saves a significant
amount of kva space and physical memory. Additionally, this enables
TSM for the zone managed memory.
7) Keep ioopt disabled for now.
8) Remove the now bogus "single use" map concept.
9) Use generation counts or id's for data structures residing in TSM, where
it allows us to avoid unneeded restart overhead during traversals, where
blocking might occur.
10) Account better for memory deficits, so the pageout daemon will be able
to make enough memory available (experimental.)
11) Fix some vnode locking problems. (From Tor, I think.)
12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
(experimental.)
13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c
code. Use generation counts, get rid of unneded collpase operations,
and clean up the cluster code.
14) Make vm_zone more suitable for TSM.
This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)
This is not the infamous, final cleanup of the vnode stuff, but a necessary
step. Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
|
|
|
simple_lock(&vp->v_interlock);
|
1997-12-29 00:25:11 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Delete from old mount point vnode list, if on one.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (vp->v_mount != NULL)
|
|
|
|
insmntque(vp, (struct mount *)0);
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* If special device, remove it from special device alias list
|
|
|
|
* if it is on one.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1999-08-26 14:53:31 +00:00
|
|
|
if ((vp->v_type == VBLK || vp->v_type == VCHR) && vp->v_rdev != NULL) {
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&spechash_slock);
|
1999-08-26 14:53:31 +00:00
|
|
|
SLIST_REMOVE(&vp->v_hashchain, vp, vnode, v_specnext);
|
1999-08-29 09:09:12 +00:00
|
|
|
freedev(vp->v_rdev);
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&spechash_slock);
|
1999-08-13 10:10:12 +00:00
|
|
|
vp->v_rdev = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* If it is on the freelist and not already at the head,
|
|
|
|
* move it to the head of the list. The test of the back
|
|
|
|
* pointer and the reference count of zero is because
|
|
|
|
* it will be removed from the free list by getnewvnode,
|
|
|
|
* but will not have its reference count incremented until
|
|
|
|
* after calling vgone. If the reference count were
|
|
|
|
* incremented first, vgone would (incorrectly) try to
|
|
|
|
* close the previous instance of the underlying object.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-08-31 07:32:39 +00:00
|
|
|
if (vp->v_usecount == 0 && !(vp->v_flag & VDOOMED)) {
|
1998-01-12 01:46:33 +00:00
|
|
|
s = splbio();
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_lock(&vnode_free_list_slock);
|
1998-01-12 01:46:33 +00:00
|
|
|
if (vp->v_flag & VFREE) {
|
|
|
|
TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
|
|
|
|
} else if (vp->v_flag & VTBFREE) {
|
|
|
|
TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
|
|
|
|
vp->v_flag &= ~VTBFREE;
|
1998-01-31 01:17:58 +00:00
|
|
|
freevnodes++;
|
|
|
|
} else
|
|
|
|
freevnodes++;
|
1998-01-12 01:46:33 +00:00
|
|
|
vp->v_flag |= VFREE;
|
1997-08-31 07:32:39 +00:00
|
|
|
TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
|
1997-02-10 02:22:35 +00:00
|
|
|
simple_unlock(&vnode_free_list_slock);
|
1998-01-12 01:46:33 +00:00
|
|
|
splx(s);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
vp->v_type = VBAD;
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup a vnode by device number.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-05-24 10:09:53 +00:00
|
|
|
vfinddev(dev, type, vpp)
|
|
|
|
dev_t dev;
|
|
|
|
enum vtype type;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
1999-08-26 14:53:31 +00:00
|
|
|
struct vnode *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-27 16:08:43 +00:00
|
|
|
simple_lock(&spechash_slock);
|
1999-08-26 14:53:31 +00:00
|
|
|
SLIST_FOREACH(vp, &dev->si_hlist, v_specnext) {
|
|
|
|
if (type == vp->v_type) {
|
|
|
|
*vpp = vp;
|
|
|
|
simple_unlock(&spechash_slock);
|
|
|
|
return (1);
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-27 16:08:43 +00:00
|
|
|
simple_unlock(&spechash_slock);
|
1999-08-26 14:53:31 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the total number of references to a special device.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
1994-05-24 10:09:53 +00:00
|
|
|
vcount(vp)
|
1999-08-26 14:53:31 +00:00
|
|
|
struct vnode *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1999-08-28 19:21:03 +00:00
|
|
|
struct vnode *vq;
|
1994-05-24 10:09:53 +00:00
|
|
|
int count;
|
|
|
|
|
1999-08-26 14:53:31 +00:00
|
|
|
count = 0;
|
1997-02-27 16:08:43 +00:00
|
|
|
simple_lock(&spechash_slock);
|
1999-08-26 14:53:31 +00:00
|
|
|
SLIST_FOREACH(vq, &vp->v_hashchain, v_specnext)
|
1994-05-24 10:09:53 +00:00
|
|
|
count += vq->v_usecount;
|
1997-02-27 16:08:43 +00:00
|
|
|
simple_unlock(&spechash_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (count);
|
|
|
|
}
|
1999-08-26 14:53:31 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Print out a description of a vnode.
|
|
|
|
*/
|
|
|
|
static char *typename[] =
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
{"VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"};
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
void
|
1994-05-24 10:09:53 +00:00
|
|
|
vprint(label, vp)
|
|
|
|
char *label;
|
1999-08-26 14:53:31 +00:00
|
|
|
struct vnode *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1998-12-04 22:54:57 +00:00
|
|
|
char buf[96];
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
if (label != NULL)
|
1998-07-11 07:46:16 +00:00
|
|
|
printf("%s: %p: ", label, (void *)vp);
|
1997-04-04 17:46:21 +00:00
|
|
|
else
|
1998-07-11 07:46:16 +00:00
|
|
|
printf("%p: ", (void *)vp);
|
|
|
|
printf("type %s, usecount %d, writecount %d, refcount %d,",
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
typename[vp->v_type], vp->v_usecount, vp->v_writecount,
|
|
|
|
vp->v_holdcnt);
|
1994-05-24 10:09:53 +00:00
|
|
|
buf[0] = '\0';
|
|
|
|
if (vp->v_flag & VROOT)
|
|
|
|
strcat(buf, "|VROOT");
|
|
|
|
if (vp->v_flag & VTEXT)
|
|
|
|
strcat(buf, "|VTEXT");
|
|
|
|
if (vp->v_flag & VSYSTEM)
|
|
|
|
strcat(buf, "|VSYSTEM");
|
|
|
|
if (vp->v_flag & VXLOCK)
|
|
|
|
strcat(buf, "|VXLOCK");
|
|
|
|
if (vp->v_flag & VXWANT)
|
|
|
|
strcat(buf, "|VXWANT");
|
|
|
|
if (vp->v_flag & VBWAIT)
|
|
|
|
strcat(buf, "|VBWAIT");
|
1997-08-31 07:32:39 +00:00
|
|
|
if (vp->v_flag & VDOOMED)
|
|
|
|
strcat(buf, "|VDOOMED");
|
|
|
|
if (vp->v_flag & VFREE)
|
|
|
|
strcat(buf, "|VFREE");
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (vp->v_flag & VOBJBUF)
|
|
|
|
strcat(buf, "|VOBJBUF");
|
1994-05-24 10:09:53 +00:00
|
|
|
if (buf[0] != '\0')
|
|
|
|
printf(" flags (%s)", &buf[1]);
|
|
|
|
if (vp->v_data == NULL) {
|
|
|
|
printf("\n");
|
|
|
|
} else {
|
|
|
|
printf("\n\t");
|
|
|
|
VOP_PRINT(vp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-16 11:33:33 +00:00
|
|
|
#ifdef DDB
|
1998-10-25 17:44:59 +00:00
|
|
|
#include <ddb/ddb.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* List all of the locked vnodes in the system.
|
|
|
|
* Called when debugging the kernel.
|
|
|
|
*/
|
1998-10-25 17:44:59 +00:00
|
|
|
DB_SHOW_COMMAND(lockedvnodes, lockedvnodes)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-25 19:33:23 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
|
|
|
struct mount *mp, *nmp;
|
|
|
|
struct vnode *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
printf("Locked vnodes\n");
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_lock(&mountlist_slock);
|
|
|
|
for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
|
|
|
|
if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
|
|
|
|
nmp = mp->mnt_list.cqe_next;
|
|
|
|
continue;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
for (vp = mp->mnt_vnodelist.lh_first;
|
1997-02-25 19:33:23 +00:00
|
|
|
vp != NULL;
|
|
|
|
vp = vp->v_mntvnodes.le_next) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (VOP_ISLOCKED(vp))
|
1997-02-25 19:33:23 +00:00
|
|
|
vprint((char *)0, vp);
|
|
|
|
}
|
|
|
|
simple_lock(&mountlist_slock);
|
|
|
|
nmp = mp->mnt_list.cqe_next;
|
|
|
|
vfs_unbusy(mp, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_unlock(&mountlist_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1997-03-03 12:58:20 +00:00
|
|
|
/*
|
|
|
|
* Top level filesystem related information gathering.
|
|
|
|
*/
|
|
|
|
static int sysctl_ovfs_conf __P(SYSCTL_HANDLER_ARGS);
|
|
|
|
|
1997-03-04 18:31:56 +00:00
|
|
|
static int
|
1997-03-03 12:58:20 +00:00
|
|
|
vfs_sysctl SYSCTL_HANDLER_ARGS
|
1997-03-02 11:06:22 +00:00
|
|
|
{
|
1997-03-04 18:31:56 +00:00
|
|
|
int *name = (int *)arg1 - 1; /* XXX */
|
|
|
|
u_int namelen = arg2 + 1; /* XXX */
|
1997-03-02 11:06:22 +00:00
|
|
|
struct vfsconf *vfsp;
|
|
|
|
|
1998-08-29 13:13:10 +00:00
|
|
|
#if 1 || defined(COMPAT_PRELITE2)
|
1997-03-03 12:58:20 +00:00
|
|
|
/* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */
|
1997-03-04 18:31:56 +00:00
|
|
|
if (namelen == 1)
|
1997-03-03 12:58:20 +00:00
|
|
|
return (sysctl_ovfs_conf(oidp, arg1, arg2, req));
|
|
|
|
#endif
|
1997-03-02 11:06:22 +00:00
|
|
|
|
1997-03-04 18:31:56 +00:00
|
|
|
#ifdef notyet
|
1997-03-03 12:58:20 +00:00
|
|
|
/* all sysctl names at this level are at least name and field */
|
|
|
|
if (namelen < 2)
|
|
|
|
return (ENOTDIR); /* overloaded */
|
|
|
|
if (name[0] != VFS_GENERIC) {
|
|
|
|
for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
|
|
|
|
if (vfsp->vfc_typenum == name[0])
|
|
|
|
break;
|
|
|
|
if (vfsp == NULL)
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1,
|
|
|
|
oldp, oldlenp, newp, newlen, p));
|
|
|
|
}
|
1997-03-04 18:31:56 +00:00
|
|
|
#endif
|
1997-03-03 12:58:20 +00:00
|
|
|
switch (name[1]) {
|
|
|
|
case VFS_MAXTYPENUM:
|
|
|
|
if (namelen != 2)
|
|
|
|
return (ENOTDIR);
|
|
|
|
return (SYSCTL_OUT(req, &maxvfsconf, sizeof(int)));
|
|
|
|
case VFS_CONF:
|
|
|
|
if (namelen != 3)
|
|
|
|
return (ENOTDIR); /* overloaded */
|
|
|
|
for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
|
|
|
|
if (vfsp->vfc_typenum == name[2])
|
|
|
|
break;
|
|
|
|
if (vfsp == NULL)
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
return (SYSCTL_OUT(req, vfsp, sizeof *vfsp));
|
|
|
|
}
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
1997-03-02 11:06:22 +00:00
|
|
|
|
1997-03-04 18:31:56 +00:00
|
|
|
SYSCTL_NODE(_vfs, VFS_GENERIC, generic, CTLFLAG_RD, vfs_sysctl,
|
|
|
|
"Generic filesystem");
|
|
|
|
|
1998-08-29 13:13:10 +00:00
|
|
|
#if 1 || defined(COMPAT_PRELITE2)
|
1997-03-02 11:06:22 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
sysctl_ovfs_conf SYSCTL_HANDLER_ARGS
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct vfsconf *vfsp;
|
1997-03-03 12:58:20 +00:00
|
|
|
struct ovfsconf ovfs;
|
1997-03-02 11:06:22 +00:00
|
|
|
|
|
|
|
for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) {
|
|
|
|
ovfs.vfc_vfsops = vfsp->vfc_vfsops; /* XXX used as flag */
|
|
|
|
strcpy(ovfs.vfc_name, vfsp->vfc_name);
|
|
|
|
ovfs.vfc_index = vfsp->vfc_typenum;
|
|
|
|
ovfs.vfc_refcount = vfsp->vfc_refcount;
|
|
|
|
ovfs.vfc_flags = vfsp->vfc_flags;
|
|
|
|
error = SYSCTL_OUT(req, &ovfs, sizeof ovfs);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-08-29 13:13:10 +00:00
|
|
|
#endif /* 1 || COMPAT_PRELITE2 */
|
1997-03-02 11:06:22 +00:00
|
|
|
|
1997-11-07 08:53:44 +00:00
|
|
|
#if 0
|
1994-05-24 10:09:53 +00:00
|
|
|
#define KINFO_VNODESLOP 10
|
|
|
|
/*
|
|
|
|
* Dump vnode list (via sysctl).
|
|
|
|
* Copyout address of vnode followed by vnode.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1995-11-20 12:42:39 +00:00
|
|
|
static int
|
|
|
|
sysctl_vnode SYSCTL_HANDLER_ARGS
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
1997-02-25 19:33:23 +00:00
|
|
|
struct mount *mp, *nmp;
|
|
|
|
struct vnode *nvp, *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
#define VPTRSZ sizeof (struct vnode *)
|
|
|
|
#define VNODESZ sizeof (struct vnode)
|
1995-11-20 12:42:39 +00:00
|
|
|
|
|
|
|
req->lock = 0;
|
1995-11-29 11:28:00 +00:00
|
|
|
if (!req->oldptr) /* Make an estimate */
|
1995-11-20 12:42:39 +00:00
|
|
|
return (SYSCTL_OUT(req, 0,
|
|
|
|
(numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ)));
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_lock(&mountlist_slock);
|
1995-08-11 11:31:18 +00:00
|
|
|
for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
|
1997-02-25 19:33:23 +00:00
|
|
|
if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
|
|
|
|
nmp = mp->mnt_list.cqe_next;
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
1997-02-25 19:33:23 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
again:
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_lock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
for (vp = mp->mnt_vnodelist.lh_first;
|
1997-02-25 19:33:23 +00:00
|
|
|
vp != NULL;
|
|
|
|
vp = nvp) {
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-25 19:33:23 +00:00
|
|
|
* Check that the vp is still associated with
|
|
|
|
* this filesystem. RACE: could have been
|
|
|
|
* recycled onto the same filesystem.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (vp->v_mount != mp) {
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_unlock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
goto again;
|
|
|
|
}
|
1997-02-25 19:33:23 +00:00
|
|
|
nvp = vp->v_mntvnodes.le_next;
|
|
|
|
simple_unlock(&mntvnode_slock);
|
1995-11-20 12:42:39 +00:00
|
|
|
if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) ||
|
1997-02-25 19:33:23 +00:00
|
|
|
(error = SYSCTL_OUT(req, vp, VNODESZ)))
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_lock(&mntvnode_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_unlock(&mntvnode_slock);
|
|
|
|
simple_lock(&mountlist_slock);
|
|
|
|
nmp = mp->mnt_list.cqe_next;
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_unbusy(mp, p);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-25 19:33:23 +00:00
|
|
|
simple_unlock(&mountlist_slock);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
1997-11-07 08:53:44 +00:00
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-06-10 02:48:08 +00:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Exporting the vnode list on large systems causes them to crash.
|
|
|
|
* Exporting the vnode list on medium systems causes sysctl to coredump.
|
|
|
|
*/
|
|
|
|
#if 0
|
1995-12-06 13:27:39 +00:00
|
|
|
SYSCTL_PROC(_kern, KERN_VNODE, vnode, CTLTYPE_OPAQUE|CTLFLAG_RD,
|
|
|
|
0, 0, sysctl_vnode, "S,vnode", "");
|
1997-06-10 02:48:08 +00:00
|
|
|
#endif
|
1995-11-20 12:42:39 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Check to see if a filesystem is mounted on a block device.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vfs_mountedon(vp)
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
|
1998-03-08 09:59:44 +00:00
|
|
|
if (vp->v_specmountpoint != NULL)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EBUSY);
|
1999-08-26 14:53:31 +00:00
|
|
|
return (0);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-26 15:35:42 +00:00
|
|
|
* Unmount all filesystems. The list is traversed in reverse order
|
|
|
|
* of mounting to avoid dependencies.
|
1997-02-10 02:22:35 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
vfs_unmountall()
|
|
|
|
{
|
1997-02-26 15:35:42 +00:00
|
|
|
struct mount *mp, *nmp;
|
1998-05-17 19:38:55 +00:00
|
|
|
struct proc *p;
|
1997-02-10 02:22:35 +00:00
|
|
|
int error;
|
|
|
|
|
1998-05-17 19:38:55 +00:00
|
|
|
if (curproc != NULL)
|
|
|
|
p = curproc;
|
|
|
|
else
|
|
|
|
p = initproc; /* XXX XXX should this be proc0? */
|
1997-02-26 15:35:42 +00:00
|
|
|
/*
|
|
|
|
* Since this only runs when rebooting, it is not interlocked.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
for (mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) {
|
|
|
|
nmp = mp->mnt_list.cqe_prev;
|
1997-02-26 15:35:42 +00:00
|
|
|
error = dounmount(mp, MNT_FORCE, p);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (error) {
|
1997-02-26 15:35:42 +00:00
|
|
|
printf("unmount of %s failed (",
|
|
|
|
mp->mnt_stat.f_mntonname);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (error == EBUSY)
|
|
|
|
printf("BUSY)\n");
|
|
|
|
else
|
|
|
|
printf("%d)\n", error);
|
|
|
|
}
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build hash lists of net addresses and hang them off the mount point.
|
|
|
|
* Called by ufs_mount() to set up the lists of export addresses.
|
|
|
|
*/
|
|
|
|
static int
|
1997-09-16 11:44:05 +00:00
|
|
|
vfs_hang_addrlist(mp, nep, argp)
|
|
|
|
struct mount *mp;
|
|
|
|
struct netexport *nep;
|
|
|
|
struct export_args *argp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
register struct netcred *np;
|
|
|
|
register struct radix_node_head *rnh;
|
|
|
|
register int i;
|
|
|
|
struct radix_node *rn;
|
|
|
|
struct sockaddr *saddr, *smask = 0;
|
|
|
|
struct domain *dom;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (argp->ex_addrlen == 0) {
|
|
|
|
if (mp->mnt_flag & MNT_DEFEXPORTED)
|
|
|
|
return (EPERM);
|
|
|
|
np = &nep->ne_defexported;
|
|
|
|
np->netc_exflags = argp->ex_flags;
|
|
|
|
np->netc_anon = argp->ex_anon;
|
|
|
|
np->netc_anon.cr_ref = 1;
|
|
|
|
mp->mnt_flag |= MNT_DEFEXPORTED;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK);
|
|
|
|
bzero((caddr_t) np, i);
|
|
|
|
saddr = (struct sockaddr *) (np + 1);
|
|
|
|
if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen)))
|
1994-05-24 10:09:53 +00:00
|
|
|
goto out;
|
|
|
|
if (saddr->sa_len > argp->ex_addrlen)
|
|
|
|
saddr->sa_len = argp->ex_addrlen;
|
|
|
|
if (argp->ex_masklen) {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
smask = (struct sockaddr *) ((caddr_t) saddr + argp->ex_addrlen);
|
1997-04-25 06:47:12 +00:00
|
|
|
error = copyin(argp->ex_mask, (caddr_t) smask, argp->ex_masklen);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
if (smask->sa_len > argp->ex_masklen)
|
|
|
|
smask->sa_len = argp->ex_masklen;
|
|
|
|
}
|
|
|
|
i = saddr->sa_family;
|
|
|
|
if ((rnh = nep->ne_rtable[i]) == 0) {
|
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* Seems silly to initialize every AF when most are not used,
|
|
|
|
* do so on demand here
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
for (dom = domains; dom; dom = dom->dom_next)
|
|
|
|
if (dom->dom_family == i && dom->dom_rtattach) {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
dom->dom_rtattach((void **) &nep->ne_rtable[i],
|
|
|
|
dom->dom_rtoffset);
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((rnh = nep->ne_rtable[i]) == 0) {
|
|
|
|
error = ENOBUFS;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
rn = (*rnh->rnh_addaddr) ((caddr_t) saddr, (caddr_t) smask, rnh,
|
|
|
|
np->netc_rnodes);
|
|
|
|
if (rn == 0 || np != (struct netcred *) rn) { /* already exists */
|
1994-05-24 10:09:53 +00:00
|
|
|
error = EPERM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
np->netc_exflags = argp->ex_flags;
|
|
|
|
np->netc_anon = argp->ex_anon;
|
|
|
|
np->netc_anon.cr_ref = 1;
|
|
|
|
return (0);
|
|
|
|
out:
|
|
|
|
free(np, M_NETADDR);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
static int
|
1997-09-16 11:44:05 +00:00
|
|
|
vfs_free_netcred(rn, w)
|
|
|
|
struct radix_node *rn;
|
|
|
|
void *w;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
register struct radix_node_head *rnh = (struct radix_node_head *) w;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
(*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh);
|
|
|
|
free((caddr_t) rn, M_NETADDR);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Free the net address hash lists that are hanging off the mount points.
|
|
|
|
*/
|
|
|
|
static void
|
1997-09-16 11:44:05 +00:00
|
|
|
vfs_free_addrlist(nep)
|
|
|
|
struct netexport *nep;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register struct radix_node_head *rnh;
|
|
|
|
|
|
|
|
for (i = 0; i <= AF_MAX; i++)
|
1994-09-25 19:34:02 +00:00
|
|
|
if ((rnh = nep->ne_rtable[i])) {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
(*rnh->rnh_walktree) (rnh, vfs_free_netcred,
|
|
|
|
(caddr_t) rnh);
|
|
|
|
free((caddr_t) rnh, M_RTABLE);
|
1994-05-24 10:09:53 +00:00
|
|
|
nep->ne_rtable[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
vfs_export(mp, nep, argp)
|
|
|
|
struct mount *mp;
|
|
|
|
struct netexport *nep;
|
|
|
|
struct export_args *argp;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (argp->ex_flags & MNT_DELEXPORT) {
|
1997-07-17 07:17:33 +00:00
|
|
|
if (mp->mnt_flag & MNT_EXPUBLIC) {
|
|
|
|
vfs_setpublicfs(NULL, NULL, NULL);
|
|
|
|
mp->mnt_flag &= ~MNT_EXPUBLIC;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
vfs_free_addrlist(nep);
|
|
|
|
mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED);
|
|
|
|
}
|
|
|
|
if (argp->ex_flags & MNT_EXPORTED) {
|
1997-07-17 07:17:33 +00:00
|
|
|
if (argp->ex_flags & MNT_EXPUBLIC) {
|
|
|
|
if ((error = vfs_setpublicfs(mp, nep, argp)) != 0)
|
|
|
|
return (error);
|
|
|
|
mp->mnt_flag |= MNT_EXPUBLIC;
|
|
|
|
}
|
1994-09-25 19:34:02 +00:00
|
|
|
if ((error = vfs_hang_addrlist(mp, nep, argp)))
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
mp->mnt_flag |= MNT_EXPORTED;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-07-17 07:17:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the publicly exported filesystem (WebNFS). Currently, only
|
|
|
|
* one public filesystem is possible in the spec (RFC 2054 and 2055)
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vfs_setpublicfs(mp, nep, argp)
|
|
|
|
struct mount *mp;
|
|
|
|
struct netexport *nep;
|
|
|
|
struct export_args *argp;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct vnode *rvp;
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mp == NULL -> invalidate the current info, the FS is
|
|
|
|
* no longer exported. May be called from either vfs_export
|
|
|
|
* or unmount, so check if it hasn't already been done.
|
|
|
|
*/
|
|
|
|
if (mp == NULL) {
|
|
|
|
if (nfs_pub.np_valid) {
|
|
|
|
nfs_pub.np_valid = 0;
|
|
|
|
if (nfs_pub.np_index != NULL) {
|
|
|
|
FREE(nfs_pub.np_index, M_TEMP);
|
|
|
|
nfs_pub.np_index = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only one allowed at a time.
|
|
|
|
*/
|
|
|
|
if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount)
|
|
|
|
return (EBUSY);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get real filehandle for root of exported FS.
|
|
|
|
*/
|
|
|
|
bzero((caddr_t)&nfs_pub.np_handle, sizeof(nfs_pub.np_handle));
|
|
|
|
nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsid;
|
|
|
|
|
|
|
|
if ((error = VFS_ROOT(mp, &rvp)))
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if ((error = VFS_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid)))
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
vput(rvp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If an indexfile was specified, pull it in.
|
|
|
|
*/
|
|
|
|
if (argp->ex_indexfile != NULL) {
|
|
|
|
MALLOC(nfs_pub.np_index, char *, MAXNAMLEN + 1, M_TEMP,
|
|
|
|
M_WAITOK);
|
|
|
|
error = copyinstr(argp->ex_indexfile, nfs_pub.np_index,
|
|
|
|
MAXNAMLEN, (size_t *)0);
|
|
|
|
if (!error) {
|
|
|
|
/*
|
|
|
|
* Check for illegal filenames.
|
|
|
|
*/
|
|
|
|
for (cp = nfs_pub.np_index; *cp; cp++) {
|
|
|
|
if (*cp == '/') {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
FREE(nfs_pub.np_index, M_TEMP);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nfs_pub.np_mount = mp;
|
|
|
|
nfs_pub.np_valid = 1;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
struct netcred *
|
|
|
|
vfs_export_lookup(mp, nep, nam)
|
|
|
|
register struct mount *mp;
|
|
|
|
struct netexport *nep;
|
1997-08-16 19:16:27 +00:00
|
|
|
struct sockaddr *nam;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
register struct netcred *np;
|
|
|
|
register struct radix_node_head *rnh;
|
|
|
|
struct sockaddr *saddr;
|
|
|
|
|
|
|
|
np = NULL;
|
|
|
|
if (mp->mnt_flag & MNT_EXPORTED) {
|
|
|
|
/*
|
|
|
|
* Lookup in the export list first.
|
|
|
|
*/
|
|
|
|
if (nam != NULL) {
|
1997-08-16 19:16:27 +00:00
|
|
|
saddr = nam;
|
1994-05-24 10:09:53 +00:00
|
|
|
rnh = nep->ne_rtable[saddr->sa_family];
|
|
|
|
if (rnh != NULL) {
|
|
|
|
np = (struct netcred *)
|
1997-02-10 02:22:35 +00:00
|
|
|
(*rnh->rnh_matchaddr)((caddr_t)saddr,
|
|
|
|
rnh);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (np && np->netc_rnodes->rn_flags & RNF_ROOT)
|
|
|
|
np = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If no address match, use the default if it exists.
|
|
|
|
*/
|
|
|
|
if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED)
|
|
|
|
np = &nep->ne_defexported;
|
|
|
|
}
|
|
|
|
return (np);
|
|
|
|
}
|
1995-05-21 21:39:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* perform msync on all vnodes under a mount point
|
|
|
|
* the mount point must be locked.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vfs_msync(struct mount *mp, int flags) {
|
1995-12-11 04:58:34 +00:00
|
|
|
struct vnode *vp, *nvp;
|
1998-04-18 06:26:16 +00:00
|
|
|
struct vm_object *obj;
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
int anyio, tries;
|
|
|
|
|
|
|
|
tries = 5;
|
1995-05-21 21:39:31 +00:00
|
|
|
loop:
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
anyio = 0;
|
1995-12-11 04:58:34 +00:00
|
|
|
for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
|
1995-05-21 21:39:31 +00:00
|
|
|
|
1995-12-11 04:58:34 +00:00
|
|
|
nvp = vp->v_mntvnodes.le_next;
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
|
|
|
|
if (vp->v_mount != mp) {
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
|
1998-04-18 06:26:16 +00:00
|
|
|
if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
|
1995-05-21 21:39:31 +00:00
|
|
|
continue;
|
1998-04-18 06:26:16 +00:00
|
|
|
|
|
|
|
if (flags != MNT_WAIT) {
|
|
|
|
obj = vp->v_object;
|
|
|
|
if (obj == NULL || (obj->flags & OBJ_MIGHTBEDIRTY) == 0)
|
|
|
|
continue;
|
|
|
|
if (VOP_ISLOCKED(vp))
|
|
|
|
continue;
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simple_lock(&vp->v_interlock);
|
1995-06-28 12:01:13 +00:00
|
|
|
if (vp->v_object &&
|
1996-08-21 21:56:23 +00:00
|
|
|
(vp->v_object->flags & OBJ_MIGHTBEDIRTY)) {
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (!vget(vp,
|
|
|
|
LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) {
|
|
|
|
if (vp->v_object) {
|
1998-10-31 07:42:04 +00:00
|
|
|
vm_object_page_clean(vp->v_object, 0, 0, flags == MNT_WAIT ? OBJPC_SYNC : 0);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
anyio = 1;
|
|
|
|
}
|
|
|
|
vput(vp);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
1995-05-21 21:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (anyio && (--tries > 0))
|
|
|
|
goto loop;
|
1995-05-21 21:39:31 +00:00
|
|
|
}
|
1996-08-21 21:56:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the VM object needed for VMIO and mmap support. This
|
|
|
|
* is done for all VREG files in the system. Some filesystems might
|
|
|
|
* afford the additional metadata buffering capability of the
|
|
|
|
* VMIO code by making the device node be VMIO mode also.
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
*
|
1999-01-05 18:50:03 +00:00
|
|
|
* vp must be locked when vfs_object_create is called.
|
1996-08-21 21:56:23 +00:00
|
|
|
*/
|
|
|
|
int
|
1999-01-05 18:50:03 +00:00
|
|
|
vfs_object_create(vp, p, cred)
|
1996-08-21 21:56:23 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
struct proc *p;
|
|
|
|
struct ucred *cred;
|
|
|
|
{
|
|
|
|
struct vattr vat;
|
|
|
|
vm_object_t object;
|
|
|
|
int error = 0;
|
|
|
|
|
1999-07-26 06:25:53 +00:00
|
|
|
if (vp->v_type != VBLK && vn_canvmio(vp) == FALSE)
|
1997-12-29 00:25:11 +00:00
|
|
|
return 0;
|
|
|
|
|
1996-08-21 21:56:23 +00:00
|
|
|
retry:
|
|
|
|
if ((object = vp->v_object) == NULL) {
|
1999-07-26 06:25:53 +00:00
|
|
|
if (vp->v_type == VREG || vp->v_type == VDIR) {
|
1996-08-21 21:56:23 +00:00
|
|
|
if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0)
|
|
|
|
goto retn;
|
1998-10-13 08:24:45 +00:00
|
|
|
object = vnode_pager_alloc(vp, vat.va_size, 0, 0);
|
1999-08-13 10:29:38 +00:00
|
|
|
} else if (devsw(vp->v_rdev) != NULL) {
|
1996-08-21 21:56:23 +00:00
|
|
|
/*
|
|
|
|
* This simply allocates the biggest object possible
|
|
|
|
* for a VBLK vnode. This should be fixed, but doesn't
|
|
|
|
* cause any problems (yet).
|
|
|
|
*/
|
1998-10-13 08:24:45 +00:00
|
|
|
object = vnode_pager_alloc(vp, IDX_TO_OFF(INT_MAX), 0, 0);
|
1999-02-04 18:25:39 +00:00
|
|
|
} else {
|
|
|
|
goto retn;
|
1996-08-21 21:56:23 +00:00
|
|
|
}
|
1999-02-04 18:25:39 +00:00
|
|
|
/*
|
|
|
|
* Dereference the reference we just created. This assumes
|
|
|
|
* that the object is associated with the vp.
|
|
|
|
*/
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
object->ref_count--;
|
|
|
|
vp->v_usecount--;
|
1996-08-21 21:56:23 +00:00
|
|
|
} else {
|
|
|
|
if (object->flags & OBJ_DEAD) {
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
VOP_UNLOCK(vp, 0, p);
|
1996-08-21 21:56:23 +00:00
|
|
|
tsleep(object, PVM, "vodead", 0);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
|
1996-08-21 21:56:23 +00:00
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
|
1999-02-04 18:25:39 +00:00
|
|
|
KASSERT(vp->v_object != NULL, ("vfs_object_create: NULL object"));
|
|
|
|
vp->v_flag |= VOBJBUF;
|
1996-08-21 21:56:23 +00:00
|
|
|
|
|
|
|
retn:
|
|
|
|
return error;
|
|
|
|
}
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
|
1997-11-22 08:35:46 +00:00
|
|
|
static void
|
1997-08-31 07:32:39 +00:00
|
|
|
vfree(vp)
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
{
|
1998-01-12 01:46:33 +00:00
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splbio();
|
1997-08-31 07:32:39 +00:00
|
|
|
simple_lock(&vnode_free_list_slock);
|
1998-01-12 01:46:33 +00:00
|
|
|
if (vp->v_flag & VTBFREE) {
|
|
|
|
TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
|
|
|
|
vp->v_flag &= ~VTBFREE;
|
|
|
|
}
|
1997-08-31 07:32:39 +00:00
|
|
|
if (vp->v_flag & VAGE) {
|
|
|
|
TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
|
|
|
|
} else {
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
}
|
1997-08-31 07:32:39 +00:00
|
|
|
freevnodes++;
|
|
|
|
simple_unlock(&vnode_free_list_slock);
|
|
|
|
vp->v_flag &= ~VAGE;
|
|
|
|
vp->v_flag |= VFREE;
|
1998-01-12 01:46:33 +00:00
|
|
|
splx(s);
|
1997-08-31 07:32:39 +00:00
|
|
|
}
|
|
|
|
|
1998-01-17 09:17:02 +00:00
|
|
|
void
|
1997-08-31 07:32:39 +00:00
|
|
|
vbusy(vp)
|
|
|
|
struct vnode *vp;
|
|
|
|
{
|
1998-01-12 01:46:33 +00:00
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splbio();
|
1997-08-31 07:32:39 +00:00
|
|
|
simple_lock(&vnode_free_list_slock);
|
1998-01-12 01:46:33 +00:00
|
|
|
if (vp->v_flag & VTBFREE) {
|
|
|
|
TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
|
|
|
|
vp->v_flag &= ~VTBFREE;
|
|
|
|
} else {
|
|
|
|
TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
|
|
|
|
freevnodes--;
|
|
|
|
}
|
1997-08-31 07:32:39 +00:00
|
|
|
simple_unlock(&vnode_free_list_slock);
|
1998-02-23 06:59:52 +00:00
|
|
|
vp->v_flag &= ~(VFREE|VAGE);
|
1998-01-12 01:46:33 +00:00
|
|
|
splx(s);
|
1. Add a {pointer, v_id} pair to the vnode to store the reference to the
".." vnode. This is cheaper storagewise than keeping it in the
namecache, and it makes more sense since it's a 1:1 mapping.
2. Also handle the case of "." more intelligently rather than stuff
the namecache with pointless entries.
3. Add two lists to the vnode and hang namecache entries which go from
or to this vnode. When cleaning a vnode, delete all namecache
entries it invalidates.
4. Never reuse namecache enties, malloc new ones when we need it, free
old ones when they die. No longer a hard limit on how many we can
have.
5. Remove the upper limit on namelength of namecache entries.
6. Make a global list for negative namecache entries, limit their number
to a sysctl'able (debug.ncnegfactor) fraction of the total namecache.
Currently the default fraction is 1/16th. (Suggestions for better
default wanted!)
7. Assign v_id correctly in the face of 32bit rollover.
8. Remove the LRU list for namecache entries, not needed. Remove the
#ifdef NCH_STATISTICS stuff, it's not needed either.
9. Use the vnode freelist as a true LRU list, also for namecache accesses.
10. Reuse vnodes more aggresively but also more selectively, if we can't
reuse, malloc a new one. There is no longer a hard limit on their
number, they grow to the point where we don't reuse potentially
usable vnodes. A vnode will not get recycled if still has pages in
core or if it is the source of namecache entries (Yes, this does
indeed work :-) "." and ".." are not namecache entries any longer...)
11. Do not overload the v_id field in namecache entries with whiteout
information, use a char sized flags field instead, so we can get
rid of the vpid and v_id fields from the namecache struct. Since
we're linked to the vnodes and purged when they're cleaned, we don't
have to check the v_id any more.
12. NFS knew about the limitation on name length in the namecache, it
shouldn't and doesn't now.
Bugs:
The namecache statistics no longer includes the hits for ".."
and "." hits.
Performance impact:
Generally in the +/- 0.5% for "normal" workstations, but
I hope this will allow the system to be selftuning over a
bigger range of "special" applications. The case where
RAM is available but unused for cache because we don't have
any vnodes should be gone.
Future work:
Straighten out the namecache statistics.
"desiredvnodes" is still used to (bogusly ?) size hash
tables in the filesystems.
I have still to find a way to safely free unused vnodes
back so their number can shrink when not needed.
There is a few uses of the v_id field left in the filesystems,
scheduled for demolition at a later time.
Maybe a one slot cache for unused namecache entries should
be implemented to decrease the malloc/free frequency.
1997-05-04 09:17:38 +00:00
|
|
|
}
|
1997-12-15 03:09:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Record a process's interest in events which might happen to
|
|
|
|
* a vnode. Because poll uses the historic select-style interface
|
|
|
|
* internally, this routine serves as both the ``check for any
|
|
|
|
* pending events'' and the ``record my interest in future events''
|
|
|
|
* functions. (These are done together, while the lock is held,
|
|
|
|
* to avoid race conditions.)
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vn_pollrecord(vp, p, events)
|
|
|
|
struct vnode *vp;
|
|
|
|
struct proc *p;
|
|
|
|
short events;
|
|
|
|
{
|
|
|
|
simple_lock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
if (vp->v_pollinfo.vpi_revents & events) {
|
|
|
|
/*
|
|
|
|
* This leaves events we are not interested
|
|
|
|
* in available for the other process which
|
|
|
|
* which presumably had requested them
|
|
|
|
* (otherwise they would never have been
|
|
|
|
* recorded).
|
|
|
|
*/
|
|
|
|
events &= vp->v_pollinfo.vpi_revents;
|
|
|
|
vp->v_pollinfo.vpi_revents &= ~events;
|
|
|
|
|
|
|
|
simple_unlock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
vp->v_pollinfo.vpi_events |= events;
|
|
|
|
selrecord(p, &vp->v_pollinfo.vpi_selinfo);
|
|
|
|
simple_unlock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note the occurrence of an event. If the VN_POLLEVENT macro is used,
|
|
|
|
* it is possible for us to miss an event due to race conditions, but
|
|
|
|
* that condition is expected to be rare, so for the moment it is the
|
|
|
|
* preferred interface.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vn_pollevent(vp, events)
|
|
|
|
struct vnode *vp;
|
|
|
|
short events;
|
|
|
|
{
|
|
|
|
simple_lock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
if (vp->v_pollinfo.vpi_events & events) {
|
|
|
|
/*
|
|
|
|
* We clear vpi_events so that we don't
|
|
|
|
* call selwakeup() twice if two events are
|
|
|
|
* posted before the polling process(es) is
|
|
|
|
* awakened. This also ensures that we take at
|
|
|
|
* most one selwakeup() if the polling process
|
|
|
|
* is no longer interested. However, it does
|
|
|
|
* mean that only one event can be noticed at
|
|
|
|
* a time. (Perhaps we should only clear those
|
|
|
|
* event bits which we note?) XXX
|
|
|
|
*/
|
|
|
|
vp->v_pollinfo.vpi_events = 0; /* &= ~events ??? */
|
|
|
|
vp->v_pollinfo.vpi_revents |= events;
|
|
|
|
selwakeup(&vp->v_pollinfo.vpi_selinfo);
|
|
|
|
}
|
|
|
|
simple_unlock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wake up anyone polling on vp because it is being revoked.
|
|
|
|
* This depends on dead_poll() returning POLLHUP for correct
|
|
|
|
* behavior.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vn_pollgone(vp)
|
|
|
|
struct vnode *vp;
|
|
|
|
{
|
|
|
|
simple_lock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
if (vp->v_pollinfo.vpi_events) {
|
|
|
|
vp->v_pollinfo.vpi_events = 0;
|
|
|
|
selwakeup(&vp->v_pollinfo.vpi_selinfo);
|
|
|
|
}
|
|
|
|
simple_unlock(&vp->v_pollinfo.vpi_lock);
|
|
|
|
}
|
1998-03-08 09:59:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routine to create and manage a filesystem syncer vnode.
|
|
|
|
*/
|
|
|
|
#define sync_close ((int (*) __P((struct vop_close_args *)))nullop)
|
1999-01-05 18:12:29 +00:00
|
|
|
static int sync_fsync __P((struct vop_fsync_args *));
|
|
|
|
static int sync_inactive __P((struct vop_inactive_args *));
|
|
|
|
static int sync_reclaim __P((struct vop_reclaim_args *));
|
1998-03-08 09:59:44 +00:00
|
|
|
#define sync_lock ((int (*) __P((struct vop_lock_args *)))vop_nolock)
|
|
|
|
#define sync_unlock ((int (*) __P((struct vop_unlock_args *)))vop_nounlock)
|
1999-01-05 18:12:29 +00:00
|
|
|
static int sync_print __P((struct vop_print_args *));
|
1998-03-08 09:59:44 +00:00
|
|
|
#define sync_islocked ((int(*) __P((struct vop_islocked_args *)))vop_noislocked)
|
|
|
|
|
1998-12-21 23:38:33 +00:00
|
|
|
static vop_t **sync_vnodeop_p;
|
|
|
|
static struct vnodeopv_entry_desc sync_vnodeop_entries[] = {
|
1998-03-08 09:59:44 +00:00
|
|
|
{ &vop_default_desc, (vop_t *) vop_eopnotsupp },
|
|
|
|
{ &vop_close_desc, (vop_t *) sync_close }, /* close */
|
|
|
|
{ &vop_fsync_desc, (vop_t *) sync_fsync }, /* fsync */
|
|
|
|
{ &vop_inactive_desc, (vop_t *) sync_inactive }, /* inactive */
|
|
|
|
{ &vop_reclaim_desc, (vop_t *) sync_reclaim }, /* reclaim */
|
|
|
|
{ &vop_lock_desc, (vop_t *) sync_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, (vop_t *) sync_unlock }, /* unlock */
|
|
|
|
{ &vop_print_desc, (vop_t *) sync_print }, /* print */
|
|
|
|
{ &vop_islocked_desc, (vop_t *) sync_islocked }, /* islocked */
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
1998-12-21 23:38:33 +00:00
|
|
|
static struct vnodeopv_desc sync_vnodeop_opv_desc =
|
1998-03-08 09:59:44 +00:00
|
|
|
{ &sync_vnodeop_p, sync_vnodeop_entries };
|
|
|
|
|
|
|
|
VNODEOP_SET(sync_vnodeop_opv_desc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new filesystem syncer vnode for the specified mount point.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vfs_allocate_syncvnode(mp)
|
|
|
|
struct mount *mp;
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
|
|
|
static long start, incr, next;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Allocate a new vnode */
|
|
|
|
if ((error = getnewvnode(VT_VFS, mp, sync_vnodeop_p, &vp)) != 0) {
|
|
|
|
mp->mnt_syncer = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
vp->v_type = VNON;
|
|
|
|
/*
|
|
|
|
* Place the vnode onto the syncer worklist. We attempt to
|
|
|
|
* scatter them about on the list so that they will go off
|
|
|
|
* at evenly distributed times even if all the filesystems
|
|
|
|
* are mounted at once.
|
|
|
|
*/
|
|
|
|
next += incr;
|
|
|
|
if (next == 0 || next > syncer_maxdelay) {
|
|
|
|
start /= 2;
|
|
|
|
incr /= 2;
|
|
|
|
if (start == 0) {
|
|
|
|
start = syncer_maxdelay / 2;
|
|
|
|
incr = syncer_maxdelay;
|
|
|
|
}
|
|
|
|
next = start;
|
|
|
|
}
|
|
|
|
vn_syncer_add_to_worklist(vp, syncdelay > 0 ? next % syncdelay : 0);
|
|
|
|
mp->mnt_syncer = vp;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do a lazy sync of the filesystem.
|
|
|
|
*/
|
1998-12-21 23:38:33 +00:00
|
|
|
static int
|
1998-03-08 09:59:44 +00:00
|
|
|
sync_fsync(ap)
|
|
|
|
struct vop_fsync_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
int a_waitfor;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *syncvp = ap->a_vp;
|
|
|
|
struct mount *mp = syncvp->v_mount;
|
|
|
|
struct proc *p = ap->a_p;
|
|
|
|
int asyncflag;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We only need to do something if this is a lazy evaluation.
|
|
|
|
*/
|
|
|
|
if (ap->a_waitfor != MNT_LAZY)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move ourselves to the back of the sync list.
|
|
|
|
*/
|
|
|
|
vn_syncer_add_to_worklist(syncvp, syncdelay);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Walk the list of vnodes pushing all that are dirty and
|
|
|
|
* not already on the sync list.
|
|
|
|
*/
|
|
|
|
simple_lock(&mountlist_slock);
|
1998-04-15 18:37:49 +00:00
|
|
|
if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_slock, p) != 0) {
|
|
|
|
simple_unlock(&mountlist_slock);
|
1998-03-08 09:59:44 +00:00
|
|
|
return (0);
|
1998-04-15 18:37:49 +00:00
|
|
|
}
|
1998-03-08 09:59:44 +00:00
|
|
|
asyncflag = mp->mnt_flag & MNT_ASYNC;
|
|
|
|
mp->mnt_flag &= ~MNT_ASYNC;
|
1998-04-16 03:31:26 +00:00
|
|
|
vfs_msync(mp, MNT_NOWAIT);
|
1998-03-08 09:59:44 +00:00
|
|
|
VFS_SYNC(mp, MNT_LAZY, ap->a_cred, p);
|
|
|
|
if (asyncflag)
|
|
|
|
mp->mnt_flag |= MNT_ASYNC;
|
|
|
|
vfs_unbusy(mp, p);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The syncer vnode is no referenced.
|
|
|
|
*/
|
1998-12-21 23:38:33 +00:00
|
|
|
static int
|
1998-03-08 09:59:44 +00:00
|
|
|
sync_inactive(ap)
|
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
|
|
|
|
vgone(ap->a_vp);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The syncer vnode is no longer needed and is being decommissioned.
|
1999-02-19 17:36:58 +00:00
|
|
|
*
|
|
|
|
* Modifications to the worklist must be protected at splbio().
|
1998-03-08 09:59:44 +00:00
|
|
|
*/
|
1998-12-21 23:38:33 +00:00
|
|
|
static int
|
1998-03-08 09:59:44 +00:00
|
|
|
sync_reclaim(ap)
|
|
|
|
struct vop_reclaim_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
1999-02-19 17:36:58 +00:00
|
|
|
int s;
|
1998-03-08 09:59:44 +00:00
|
|
|
|
1999-02-19 17:36:58 +00:00
|
|
|
s = splbio();
|
1998-03-08 09:59:44 +00:00
|
|
|
vp->v_mount->mnt_syncer = NULL;
|
|
|
|
if (vp->v_flag & VONWORKLST) {
|
|
|
|
LIST_REMOVE(vp, v_synclist);
|
|
|
|
vp->v_flag &= ~VONWORKLST;
|
|
|
|
}
|
1999-02-19 17:36:58 +00:00
|
|
|
splx(s);
|
1998-03-08 09:59:44 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print out a syncer vnode.
|
|
|
|
*/
|
1998-12-21 23:38:33 +00:00
|
|
|
static int
|
1998-03-08 09:59:44 +00:00
|
|
|
sync_print(ap)
|
|
|
|
struct vop_print_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
|
|
|
|
printf("syncer vnode");
|
|
|
|
if (vp->v_vnlock != NULL)
|
|
|
|
lockmgr_printinfo(vp->v_vnlock);
|
|
|
|
printf("\n");
|
|
|
|
return (0);
|
|
|
|
}
|
1999-07-18 14:30:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* extract the dev_t from a VBLK or VCHR
|
|
|
|
*/
|
|
|
|
dev_t
|
|
|
|
vn_todev(vp)
|
|
|
|
struct vnode *vp;
|
|
|
|
{
|
|
|
|
if (vp->v_type != VBLK && vp->v_type != VCHR)
|
|
|
|
return (NODEV);
|
|
|
|
return (vp->v_rdev);
|
|
|
|
}
|
1999-08-25 12:24:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if vnode represents a disk device
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vn_isdisk(vp)
|
|
|
|
struct vnode *vp;
|
|
|
|
{
|
1999-11-09 14:15:33 +00:00
|
|
|
if (vp->v_type != VBLK && vp->v_type != VCHR)
|
1999-08-25 12:24:39 +00:00
|
|
|
return (0);
|
|
|
|
if (!devsw(vp->v_rdev))
|
|
|
|
return (0);
|
|
|
|
if (!(devsw(vp->v_rdev)->d_flags & D_DISK))
|
|
|
|
return (0);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|