summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_bio.c
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2000-09-07 01:33:02 +0000
committerjasone <jasone@FreeBSD.org>2000-09-07 01:33:02 +0000
commit769e0f974d8929599ba599ac496510fffc90ff34 (patch)
tree9387522900085835de81e7830e570ef3f6b3ea80 /sys/kern/vfs_bio.c
parentacf1927de02afda4855ec278b1128fd9446405ea (diff)
downloadFreeBSD-src-769e0f974d8929599ba599ac496510fffc90ff34.zip
FreeBSD-src-769e0f974d8929599ba599ac496510fffc90ff34.tar.gz
Major update to the way synchronization is done in the kernel. Highlights
include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r--sys/kern/vfs_bio.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 99c0754..34cff17 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -37,6 +37,7 @@
#include <sys/mount.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
+#include <sys/ktr.h>
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/resourcevar.h>
@@ -52,6 +53,8 @@
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
+#include <machine/mutex.h>
+
static MALLOC_DEFINE(M_BIOBUF, "BIO buffer", "BIO buffer");
struct bio_ops bioops; /* I/O operation notification */
@@ -461,7 +464,7 @@ bread(struct vnode * vp, daddr_t blkno, int size, struct ucred * cred,
/* if not found in cache, do some I/O */
if ((bp->b_flags & B_CACHE) == 0) {
- if (curproc != NULL)
+ if (curproc != idleproc)
curproc->p_stats->p_ru.ru_inblock++;
KASSERT(!(bp->b_flags & B_ASYNC), ("bread: illegal async bp %p", bp));
bp->b_iocmd = BIO_READ;
@@ -498,7 +501,7 @@ breadn(struct vnode * vp, daddr_t blkno, int size,
/* if not found in cache, do some I/O */
if ((bp->b_flags & B_CACHE) == 0) {
- if (curproc != NULL)
+ if (curproc != idleproc)
curproc->p_stats->p_ru.ru_inblock++;
bp->b_iocmd = BIO_READ;
bp->b_flags &= ~B_INVAL;
@@ -519,7 +522,7 @@ breadn(struct vnode * vp, daddr_t blkno, int size,
rabp = getblk(vp, *rablkno, *rabsize, 0, 0);
if ((rabp->b_flags & B_CACHE) == 0) {
- if (curproc != NULL)
+ if (curproc != idleproc)
curproc->p_stats->p_ru.ru_inblock++;
rabp->b_flags |= B_ASYNC;
rabp->b_flags &= ~B_INVAL;
@@ -640,7 +643,7 @@ bwrite(struct buf * bp)
bp->b_vp->v_numoutput++;
vfs_busy_pages(bp, 1);
- if (curproc != NULL)
+ if (curproc != idleproc)
curproc->p_stats->p_ru.ru_oublock++;
splx(s);
if (oldflags & B_ASYNC)
@@ -1420,7 +1423,8 @@ getnewbuf(int slpflag, int slptimeo, int size, int maxsize)
int isspecial;
static int flushingbufs;
- if (curproc && (curproc->p_flag & (P_COWINPROGRESS|P_BUFEXHAUST)) == 0)
+ if (curproc != idleproc &&
+ (curproc->p_flag & (P_COWINPROGRESS|P_BUFEXHAUST)) == 0)
isspecial = 0;
else
isspecial = 1;
@@ -1745,6 +1749,8 @@ buf_daemon()
{
int s;
+ mtx_enter(&Giant, MTX_DEF);
+
/*
* This process needs to be suspended prior to shutdown sync.
*/
@@ -2070,9 +2076,9 @@ loop:
* move it into the else, when gbincore() fails. At the moment
* it isn't a problem.
*/
- if (!curproc || (curproc->p_flag & P_BUFEXHAUST)) {
+ if (curproc == idleproc || (curproc->p_flag & P_BUFEXHAUST)) {
if (numfreebuffers == 0) {
- if (!curproc)
+ if (curproc == idleproc)
return NULL;
needsbuffer |= VFS_BIO_NEED_ANY;
tsleep(&needsbuffer, (PRIBIO + 4) | slpflag, "newbuf",
OpenPOWER on IntegriCloud