Commit Graph

77 Commits

Author SHA1 Message Date
simonb b5d0e6bf06 Initialise (most) pools from a link set instead of explicit calls
to pool_init.  Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

 Convert struct session, ucred and lockf to pools.
2004-04-25 16:42:40 +00:00
yamt 392d6f9af1 nfs_inactive: inactive the vp before doing sillyrename works.
vp can be reclaimed soon after it's unlocked.
2004-04-20 11:51:28 +00:00
yamt d1a0f61a77 nfs_readdirplusrpc: fix a deadlock problem.
don't wait for vnode lock to load attributes.
otherwise, because READDIRPLUS returns DOTDOT entry as well,
we violate locking order.
2004-04-05 10:44:09 +00:00
yamt 9ec3dce770 don't issue VOP_GETATTR blindly in nfs_nget().
in many cases, GETATTR RPCs here is redundant because the caller has
postop_attr.  instead, make sure the resulted vnode have a valid
attribute in nfs_lookup().
2004-04-05 10:40:56 +00:00
yamt c819fadc97 shrink sizeof struct nfsnode by putting exclusive members into union. 2004-03-12 16:52:37 +00:00
wrstuden b5053f07a1 Adjust sillyrename cleanup code to deal with the parent vnode
already being locked by our thread. VOP_INACTIVATE() makes no
statement as to the lock state of the parent, yet this code assumed
we had it unlocked.

With this change, we let vn_lock() fail with EDEADLK if we already
have the parent locked. We then handle the rename cleanup, and on
the way out just vrele() the parent vnode, not vput() it.

Fixes a case seen by Steve Woodford at Wasabisystems dot com where
we'd panic while running a pkgsrc configure test that verified
fork() functionality. I expect the problem is a result of the recent
exit() changes and the performance of the machines he tested on.

Specifically we would crash during an nfs_remove(). As best I can
tell, when nfs_remove() tested to see if we should rename or we
should remove, v_usecount was > 1 and vattr.va_nlink was 1. Thus
we did the sillyrename in nfs_remove(). However by the time we got
down to the vput(vp), v_usecount had dropped to one and thus vput()
triggered the VOP_INACTIVATE() code path. nfs_inactive() tries to
lock the parent to undo the sillyrename, and deadlocks as we still
have it locked.
2004-01-23 22:20:20 +00:00
fvdl b916f59963 Unix semantics dictate that access checks for files are done when it
is opened. An open file can always be read from and/or written to,
depending on how it was opened.

Therefore, the read/write/commit RPCs should never return EACCESS,
as they are only performed on files that have been successfully opened
already.

This change improves the current situation and works in most cases.
It simply always uses the most recently known owner/group of the file,
iff the authentication mechanism is AUTH_UNIX (in other cases, the
creds for a succesful open are used, but note that no other cases
are currently implemented).

A retry mechanism can be used to catch a few more cases, but this is
a good improvement for now.
2003-12-07 21:15:46 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
yamt 33164bffc6 vrecycle removed nfs vnodes.
not perfect, but enough for most cases.
2003-07-30 12:25:39 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
thorpej a06b275edc Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget().  Turns out
  that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
  and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
  above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
  just to appease the above.
2003-06-29 18:43:21 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
yamt b24da550a0 avoid double free with xlatecookie. 2003-05-22 14:14:02 +00:00
yamt 08bf5aae7b remove local definitions of TRUE and FALSE. 2003-05-21 13:50:54 +00:00
yamt 8a4e0a8444 use hashdone to free hashinit'ed memory. 2003-05-07 13:16:35 +00:00
yamt a14f444335 use queue manipulation macros. 2003-04-02 15:14:19 +00:00
perseant b397c875ae Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon.  To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:

* Create a writer daemon kernel thread whose purpose is to handle page
  writes for the pagedaemon, but which also takes over some of the
  functions of lfs_check().  This thread is started the first time an
  LFS is mounted.

* Add a "flags" parameter to GOP_SIZE.  Current values are
  GOP_SIZE_READ, meaning that the call should return the size of the
  in-core version of the file, and GOP_SIZE_WRITE, meaning that it
  should return the on-disk size.  One of GOP_SIZE_READ or
  GOP_SIZE_WRITE must be specified.

* Instead of using malloc(...M_WAITOK) for everything, reserve enough
  resources to get by and use malloc(...M_NOWAIT), using the reserves if
  necessary.  Use the pool subsystem for structures small enough that
  this is feasible.  This also obsoletes LFS_THROTTLE.

And a few that are not strictly necessary:

* Moves the LFS inode extensions off onto a separately allocated
  structure; getting closer to LFS as an LKM.  "Welcome to 1.6O."

* Unified GOP_ALLOC between FFS and LFS.

* Update LFS copyright headers to correct values.

* Actually cast to unsigned in lfs_shellsort, like the comment says.

* Keep track of which segments were empty before the previous
  checkpoint; any segments that pass two checkpoints both dirty and
  empty can be summarily cleaned.  Do this.  Right now lfs_segclean
  still works, but this should be turned into an effectless
  compatibility syscall.
2003-02-17 23:48:08 +00:00
drochner 7707c16daa Don't remove the nfsnode from the hash chain in nfs_inactive.
It will never get back... it will not be found in nfs_nget, a new
nfsnode+vnode is allocated instead, which causes a node leak, and
also makes the mountpointness of the vnode to be forgotten, breaking
filesystem crossing lookups through this vnode.
2003-02-15 18:00:25 +00:00
fvdl 2be3d82860 Move purging the dircache and removing a vnode from the nqnfs timer queue
into nfs_inactive, this is a better place for it.

This doesn't actually solve the actual problem, which appears to be a race
condition with unmounting and vnode recycling somewhere, but it fixes
it in the sense that nfs_reclaim will not reference a bad v_mount anymore.
2003-02-12 14:50:52 +00:00
christos 49d7e33c00 move the MALLOC decl for DIROFFS to nfs_subs.c 2003-02-10 17:31:01 +00:00
thorpej b193480908 Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant.  Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
2003-02-01 06:23:35 +00:00
matt 9bd0cc2bb9 Make sure these all agree on the same definitons of various variables. 2002-12-01 23:02:10 +00:00
christos 7b0d38f045 back out previous. the problem is not the v_mount is null, but it appears
corrupted.
2002-10-01 14:59:21 +00:00
christos da8db7611e deal with v_mount == NULL in nfs_reclaim(). We should not be touching this
anyway, but nq-nfs wants us to.
2002-09-30 20:55:55 +00:00
chs b4b7853b08 make sure that if NMODIFIED is clear, all pages attached to the vnode are
clean and without writable mappings.  if we try to flush dirty pages past
EOF to the server when NMODIFIED is clear, we'll update the attrcache before
doing the write, which will try to free the pages past EOF and deadlock.
to deal with this, we write-protect pages before we send them to the server,
and restrict ourselves to creating read-only mappings if NMODIFIED isn't set.
score another one for enami.
2002-03-16 23:05:25 +00:00
thorpej a180cee23b Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map).  Try to deal with this:

* Group all information about the backend allocator for a pool in a
  separate structure.  The pool references this structure, rather than
  the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
  to become available, but will still fail if it cannot callocate KVA
  space for the pages.  If this happens, carefully drain all pools using
  the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
  some pages, and use that information to make draining easier and more
  efficient.
* Get rid of PR_URGENT.  There was only one use of it, and it could be
  dealt with by the caller.

From art@openbsd.org.
2002-03-08 20:48:27 +00:00
chs 2a8b52def1 re-enable NFSv3 commit RPCs by abandoning my new approach in favor of
frank's scheme, with one new twist:  don't wait until we've totally run
out of free pages before committing, but instead notice when we've built
up a largish range of uncommitted pages and commit only the older half of
the range, which is likely to already be on disk on the server.
2002-01-26 02:52:19 +00:00
fvdl e4701eef88 VOP_UNLOCK + vgone --> vput, since the vnode will already have
a reference.
2002-01-21 13:48:51 +00:00
fvdl 9e4014046f Unlock vnode before calling vgone() in case of getattr failure during
nfs_nget. Fixes problem reported by Chuck Cranor.
2002-01-18 18:59:24 +00:00
lukem 1546835120 Replace nfs_hash() (with its extremely bad hash) with a macro to call
hash32_buf() to obtain a 32 bit hash.  On some tests I ran I obtained
a 30x improvement in hash distribution and a 6x reduction in time spent
in nfs_nget().
2001-12-06 01:26:36 +00:00
lukem 0ffad69384 add RCSIDs 2001-11-10 10:59:08 +00:00
chs 64c6d1d2dc a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps.  this is
   required now, since I've removed the globals that expose the address range.
   pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
   no longer any need to special-case it.
 - eliminate struct uvm_vnode by moving its fields into struct vnode.
 - rewrite the pageout path.  the pager is now responsible for handling the
   high-level requests instead of only getting control after a bunch of work
   has already been done on its behalf.  this will allow us to UBCify LFS,
   which needs tighter control over its pages than other filesystems do.
   writing a page to disk no longer requires making it read-only, which
   allows us to write wired pages without causing all kinds of havoc.
 - use a new PG_PAGEOUT flag to indicate that a page should be freed
   on behalf of the pagedaemon when it's unlocked.  this flag is very similar
   to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
   pageout fails due to eg. an indirect-block buffer being locked.
   this allows us to remove the "version" field from struct vm_page,
   and together with shrinking "loan_count" from 32 bits to 16,
   struct vm_page is now 4 bytes smaller.
 - no longer use PG_RELEASED for swap-backed pages.  if the page is busy
   because it's being paged out, we can't release the swap slot to be
   reallocated until that write is complete, but unlike with vnodes we
   don't keep a count of in-progress writes so there's no good way to
   know when the write is done.  instead, when we need to free a busy
   swap-backed page, just sleep until we can get it busy ourselves.
 - implement a fast-path for extending writes which allows us to avoid
   zeroing new pages.  this substantially reduces cpu usage.
 - encapsulate the data used by the genfs code in a struct genfs_node,
   which must be the first element of the filesystem-specific vnode data
   for filesystems which use genfs_{get,put}pages().
 - eliminate many of the UVM pagerops, since they aren't needed anymore
   now that the pager "put" operation is a higher-level operation.
 - enhance the genfs code to allow NFS to use the genfs_{get,put}pages
   instead of a modified copy.
 - clean up struct vnode by removing all the fields that used to be used by
   the vfs_cluster.c code (which we don't use anymore with UBC).
 - remove kmem_object and mb_object since they were useless.
   instead of allocating pages to these objects, we now just allocate
   pages with no object.  such pages are mapped in the kernel until they
   are freed, so we can use the mapping to find the page to free it.
   this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-15 20:36:31 +00:00
chs adf5d360a7 add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl.  file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value.  the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.
2001-09-15 16:12:54 +00:00
fvdl bf714cf896 Drop vnode lock before removing the sillyrename file, to avoid a
lock-o-death.
2001-05-03 15:53:04 +00:00
fvdl a4c70394dc On VOP_GETATTR failure in nfs_nget, call vgone() to get rid
of the vnode that was just created. Suggested by Enami.
2001-04-20 11:19:16 +00:00
fvdl e5a7af16e9 Unlock the hash lock before returning an error in nfs_nget.
From IWAMOTO Toshihiro.
2001-04-20 07:58:04 +00:00
tsutsui ec8b1c000e Fix nested extern declaration of prtactive. 2001-02-07 12:40:43 +00:00
fvdl c18aae5b9f In nfs_inactive there's no need anymore for an extra refcount around
nfs_vinvalbuf, since it has a real lock on the vnode now, so getnewvnode
will not hijack it.
2001-02-06 16:25:48 +00:00
fvdl d4e6a2c4e1 Do actual vnode locking for NFS. 2001-02-06 11:40:02 +00:00
chs aeda8d3b77 Initial integration of the Unified Buffer Cache project. 2000-11-27 08:39:39 +00:00
ad 642267bcc7 Update for hashinit() change. 2000-11-08 14:28:12 +00:00
fvdl 45460eabe0 Initialize the lock needed to serialize commits for one NFS node. 2000-09-19 22:13:01 +00:00
bjh21 33daa8de6b New kernel option, NFS_V2_ONLY, which aims to reduce the NFS client to just
that required to support NFSv2 mounts.  Not finished yet, but already
provides some 44k of saving in code size on arm26.  More savings, and some
documentation, are still to come.
2000-09-19 17:04:50 +00:00
thorpej d07efbc8b8 MALLOC()/FREE() are not to be used for variable size allocations. 2000-08-03 06:15:02 +00:00
augustss 8529438fe6 Remove register declarations. 2000-03-30 12:51:13 +00:00
simonb 515481f1ce Delete redundant decl of nfsv2_vnodeop_p, it's in <nfs/nfsnode.h>. 2000-03-30 02:40:37 +00:00
jdolecek 89015c4648 Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.
2000-03-16 18:08:17 +00:00
fvdl 5a7300902c Insert an extra VOP_ACCESS check in nfs_lookup, to avoid cached access
mishaps for lookup and getattr. Closes PR 8884.

While at it, cache access RPCs.
1999-11-29 23:34:00 +00:00
wrstuden 379a26972f Modify file systems to deal with struct lock in struct vnode. All leaf
fs's other than nfs use genfs_lock() for locking.

Modify lookup routines to set PDIRUNLOCK when they unlock the parrent.
1999-07-08 01:05:58 +00:00
thorpej 9a3664eccf Use the pool allocator and the "nointr" pool page allocator for NFS nodes
and vattr structures.
1998-09-01 03:11:36 +00:00