Commit Graph

82 Commits

Author SHA1 Message Date
thorpej 139cdc3125 Make nbuf, nswbuf, and bufpages unsigned. Make all operations on these
variables unsigned, and update places where their values are printed.
2002-08-25 20:21:33 +00:00
matt 0cb85bc7b9 Eliminate commons. 2002-05-12 23:06:27 +00:00
chs 4d4825010d fix bread() to return errors from reading past the end of the device.
back in rev. 1.51, bread() and breadn() were changed to assume that
if B_DONE is set on a buffer returned by bio_doread(), that the buffer
must have already been in the cache, and thus the overall bread() should
return success.  but if the requested buffer is not in the cache and
is past the end of the device, bounds_check_with_label() will set B_ERROR
on the buffer and the caller will call biodone(), which will cause bread()
to think the buffer was already in the cache and thus return success.
to fix this, undo rev. 1.51 and instead have biowait() treat both B_DONE
and B_DELWRI as indicators that it doesn't need to sleep waiting for an
i/o to complete.
2002-03-16 23:49:59 +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 9784635eb6 getblk()'s "block size invariant" isn't valid for VBLK vnodes
since bounds_check_with_label() will truncate a buffer that crosses
the end of the partition.  adjust the assertion to account for this.
fixes PRs 7938, 12156, 12698, 13076, 13210 and 13288.
2002-02-10 23:14:18 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
chs 702fa72b16 in bwrite(), when deciding whether to convert sync writes into delayed writes,
examine the filesystem contained in a block device rather than the filesystem
containing the block device vnode.  fixes PR 12484.
2001-04-01 16:16:56 +00:00
chs 941da355cf in getnewbuf(), when we need to write a buffer before reusing it,
return NULL instead of restarting the loop since we might sleep
while starting the i/o.  this tells getblk() to check if someone else
created the buffer while we slept.  from OpenBSD.
2001-03-10 18:43:55 +00:00
jdolecek 03354da279 this doesn't need <sys/trace.h> 2000-12-13 17:48:46 +00:00
chs aeda8d3b77 Initial integration of the Unified Buffer Cache project. 2000-11-27 08:39:39 +00:00
simonb 3f9e6ed0b8 Don't use alloca() - breaks compile on alpha (alloca is not prototyped
anywhere).
2000-11-18 15:58:13 +00:00
thorpej e39f7bbe1c NBPG -> PAGE_SIZE 2000-11-14 22:16:38 +00:00
ad 642267bcc7 Update for hashinit() change. 2000-11-08 14:28:12 +00:00
chs ff1e758c8c use round_page(...) instead of roundup(..., NBPG). 2000-11-08 05:53:10 +00:00
mrg 32aa199ccf remove include of <vm/vm.h> 2000-06-27 17:41:07 +00:00
fvdl ea3e5a38b8 Fix from Ethan Solomita <ethan@geocast.com> to avoid a livelock problem
where the buffer cache code would be recycling B_AGE buffers with
dependencies.
2000-04-12 11:33:43 +00:00
augustss 264f1d27c6 Get rid of register declarations. 2000-03-30 09:27:11 +00:00
thorpej 445e42d77a One small piece from UBC: create a pool for I/O buffers. One small piece
not from UBC: make physio use it instead of its own home-grown thing.
2000-02-14 20:12:02 +00:00
thorpej fe551f0e64 Fix a bug in disksort_*() which caused non-optimal ordering when multiple
active partitions were on a single spindle.  Add a b_rawblkno member to
struct buf which contains the non-partition-relative block number to sort
by.
2000-02-07 20:16:47 +00:00
thorpej 0ef111e8ee - Implement bowrite() -- perform an asynchronous, ordered write. 2000-01-21 23:22:24 +00:00
ragge 184f8b2c39 First round of discarding the CL* macros. 1999-12-03 21:43:19 +00:00
fvdl 2aea14c604 Clear B_AGE in bdirty(), this buffer must go through the LRU again
to be back on the AGE queue. Otherwise we risk recycling a set
of buffers with (soft) dependencies on the AGE list, which may
last forever if the vnode they belong to is locked (i.e. the syncer
won't get to the buffers they depend on, so their dependencies
are never flushed).
1999-11-26 17:18:15 +00:00
fvdl d901f6eae0 Be more careful to block bio interrupts for some data structures. There
were at least a few missed cases where vp->v_{clean,dirty}blkhd were
unprotected since the softdep/trickle sync merge.
1999-11-23 23:52:40 +00:00
fvdl 0b1963121a Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O
1999-11-15 18:49:07 +00:00
mycroft d4026f6eb5 GC the B_CACHE bit. 1998-11-09 01:18:34 +00:00
mycroft 13daec0fb1 Several things:
* Change the usage of B_DONE so that it is only set when a buffer is in sync
  with the data on disk.
* If a buffer is being waited for, don't put it on the age queue.
* Make sure to clear B_DONE when pages are stolen from a buffer.
* Make sure to clear B_CACHE after each use.
* If we find a buffer for the block we want with valid data, but it is too
  small, panic.  (This isn't supposed to happen.)
Fixes potential file corruption problems with clustering.
1998-10-27 23:48:22 +00:00
eeh a2dd74ed79 Merge paddr_t changes into the main branch. 1998-08-13 02:10:37 +00:00
perry 275d1554aa Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) ->  memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
   bcmp(x, y, z) ->  memcmp(x, y, z)
  bzero(x, y)    ->  memset(x, 0, y)
1998-08-04 04:03:10 +00:00
perry 730baa7431 fix sizeofs so they comply with the KNF style guide. yes, it is pedantic. 1998-07-31 22:50:48 +00:00
chs f64abc7b4c add flags arg to hashinit(), to pass to malloc(). 1998-02-07 02:44:44 +00:00
pk 37d77087e8 Check `b_dev' field in bdwrite() before using it as an index into bdevsw[].
`b_dev' value of NODEV happens and is normal if the buffer is on its way
to the underlying device strategy function for the first time.

Also, MFS sillily uses a major device number (255) which cannot be used
to index bdevsw[]. Check marked with XXXs.
1997-07-08 22:03:30 +00:00
pk b7b1073fd0 In bread() and breadn(): if getblk() returns a DELWRI buffer, don't
call biowait() but return `success' immediately. We can return `success'
because buffers with recorded errors are not returned by getblk().
(Takes care of PR#3694).
1997-07-08 21:42:59 +00:00
mycroft 6911ff7d13 Fix two performance issues:
* When a delayed write buffer falls off the LRU queue, arrange for it to go on
  the AGE queue after being flushed out to disk.
* When a delayed write buffer is synced, leave it in its relative position in
  the LRU queue.
1997-04-09 21:12:10 +00:00
cgd c8e4c454f2 curproc was being used directly for ru_{in,ou}block counting. Instead
of using it directly, use a local, and set that local to be curproc
if curproc is not NULL else a pointer to process 0's proc struct.
If syncing disks while handling a panic that occurred while 'curproc'
was NULL, the old code would dereference NULL and die.
1996-10-15 23:06:27 +00:00
christos f443b89c92 backout previous kprintf change 1996-10-13 02:32:29 +00:00
christos 60d201973e printf -> kprintf, sprintf -> ksprintf 1996-10-10 22:46:11 +00:00
mycroft 506cefab8c In the sync case of bwrite(), move the accounting earlier so that so that the
delayed write is logically converted to a sync write, mirroring the async case.
In bdwrite(), move the tape case earlier to avoid needless reassignbuf()s.
1996-06-18 20:50:23 +00:00
pk b298c40fbe Call reassignbuf() at splbio in bdwrite(). 1996-06-17 22:21:31 +00:00
pk 50e7d72655 Protect vnode when updating for started IO on buffers. 1996-06-11 11:15:36 +00:00
christos 4ef330b934 remove include of <sys/cpu.h> 1996-04-22 01:38:12 +00:00
fvdl 56a654e17f Changes for NVSv3 code: pull in more NFS include files into kern_time.c
to get types right (overkill for just one function call, but oh well).
Clear B_NEEDCOMMIT in bdwrite().
1996-02-18 11:57:06 +00:00
christos 09afd77655 More proto fixes 1996-02-09 18:59:18 +00:00
christos e630447d8c First pass at prototyping 1996-02-04 02:17:43 +00:00
cgd 32b4385a97 fix bug pointed out by, and do the cleanup suggested by
Alasdair Baird <alasdair@wildcat.demon.co.uk>.  From pr 1301.
1995-08-02 22:01:46 +00:00
cgd f5bbdfba41 bdwrite() should upgrade writes to tape devices by sending them to
bawrite().  it's logically more correct (doesn't return an error code,
because it's async; bdwrite is also async), it still writes things
in-order, it makes sure the proper accountins is done (see the
wasdelayed cases in bwrite()), and it allows writes to vnodes on volumes
mountd with the MNT_ASYNC to be converted into delayed writes the way
God, err, Kirk intended.  Convert synchronous bwrite()s on MNT_ASYNC
file systems to delayed writes.
1995-07-12 07:56:31 +00:00
cgd 9c3fe30d92 fix long-standing XXX in getblk(): NFS does funky things (somewhat
explained in comments), which can cause a race condition.  amazingly,
the _only_ time i've ever seen or heard of this problem was in some
comments and sources by Rick Macklem, and when running against the
a DEC OSF/1 NFS server running on an Alpha.
1995-07-12 07:39:00 +00:00
cgd 3176641085 fix pr 1128; change vfs_bufstats defn from DIAGNOSTIC - > DEBUG 1995-06-20 10:42:33 +00:00
mycroft 04a0a9a518 Use the new d_type field. 1995-04-10 00:46:51 +00:00
mycroft 642eb11a86 Various code rearrangement. 1994-11-22 01:31:02 +00:00
cgd 6ac2bbfc35 be more careful with types, also pull in headers where necessary. 1994-10-30 21:43:03 +00:00