diff options
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r-- | sys/kern/vfs_bio.c | 20 |
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", |