Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_bio.c
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/kthread.h> | #include <sys/kthread.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/racct.h> | |||||
#include <sys/resourcevar.h> | #include <sys/resourcevar.h> | ||||
#include <sys/rwlock.h> | #include <sys/rwlock.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sysproto.h> | #include <sys/sysproto.h> | ||||
#include <sys/vmem.h> | #include <sys/vmem.h> | ||||
#include <sys/vmmeter.h> | #include <sys/vmmeter.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
▲ Show 20 Lines • Show All 1,707 Lines • ▼ Show 20 Lines | breada(struct vnode * vp, daddr_t * rablkno, int * rabsize, | ||||
int i; | int i; | ||||
for (i = 0; i < cnt; i++, rablkno++, rabsize++) { | for (i = 0; i < cnt; i++, rablkno++, rabsize++) { | ||||
if (inmem(vp, *rablkno)) | if (inmem(vp, *rablkno)) | ||||
continue; | continue; | ||||
rabp = getblk(vp, *rablkno, *rabsize, 0, 0, 0); | rabp = getblk(vp, *rablkno, *rabsize, 0, 0, 0); | ||||
if ((rabp->b_flags & B_CACHE) == 0) { | if ((rabp->b_flags & B_CACHE) == 0) { | ||||
if (!TD_IS_IDLETHREAD(curthread)) | if (!TD_IS_IDLETHREAD(curthread)) { | ||||
#ifdef RACCT | |||||
if (racct_enable) { | |||||
PROC_LOCK(curproc); | |||||
racct_add_buf(curproc, rabp, 0); | |||||
PROC_UNLOCK(curproc); | |||||
} | |||||
#endif /* RACCT */ | |||||
curthread->td_ru.ru_inblock++; | curthread->td_ru.ru_inblock++; | ||||
} | |||||
rabp->b_flags |= B_ASYNC; | rabp->b_flags |= B_ASYNC; | ||||
rabp->b_flags &= ~B_INVAL; | rabp->b_flags &= ~B_INVAL; | ||||
rabp->b_ioflags &= ~BIO_ERROR; | rabp->b_ioflags &= ~BIO_ERROR; | ||||
rabp->b_iocmd = BIO_READ; | rabp->b_iocmd = BIO_READ; | ||||
if (rabp->b_rcred == NOCRED && cred != NOCRED) | if (rabp->b_rcred == NOCRED && cred != NOCRED) | ||||
rabp->b_rcred = crhold(cred); | rabp->b_rcred = crhold(cred); | ||||
vfs_busy_pages(rabp, 0); | vfs_busy_pages(rabp, 0); | ||||
BUF_KERNPROC(rabp); | BUF_KERNPROC(rabp); | ||||
Show All 25 Lines | breadn_flags(struct vnode *vp, daddr_t blkno, int size, daddr_t *rablkno, | ||||
* Can only return NULL if GB_LOCK_NOWAIT flag is specified. | * Can only return NULL if GB_LOCK_NOWAIT flag is specified. | ||||
*/ | */ | ||||
*bpp = bp = getblk(vp, blkno, size, 0, 0, flags); | *bpp = bp = getblk(vp, blkno, size, 0, 0, flags); | ||||
if (bp == NULL) | if (bp == NULL) | ||||
return (EBUSY); | return (EBUSY); | ||||
/* if not found in cache, do some I/O */ | /* if not found in cache, do some I/O */ | ||||
if ((bp->b_flags & B_CACHE) == 0) { | if ((bp->b_flags & B_CACHE) == 0) { | ||||
if (!TD_IS_IDLETHREAD(curthread)) | if (!TD_IS_IDLETHREAD(curthread)) { | ||||
#ifdef RACCT | |||||
if (racct_enable) { | |||||
PROC_LOCK(curproc); | |||||
racct_add_buf(curproc, bp, 0); | |||||
PROC_UNLOCK(curproc); | |||||
} | |||||
#endif /* RACCT */ | |||||
curthread->td_ru.ru_inblock++; | curthread->td_ru.ru_inblock++; | ||||
} | |||||
bp->b_iocmd = BIO_READ; | bp->b_iocmd = BIO_READ; | ||||
bp->b_flags &= ~B_INVAL; | bp->b_flags &= ~B_INVAL; | ||||
bp->b_ioflags &= ~BIO_ERROR; | bp->b_ioflags &= ~BIO_ERROR; | ||||
if (bp->b_rcred == NOCRED && cred != NOCRED) | if (bp->b_rcred == NOCRED && cred != NOCRED) | ||||
bp->b_rcred = crhold(cred); | bp->b_rcred = crhold(cred); | ||||
vfs_busy_pages(bp, 0); | vfs_busy_pages(bp, 0); | ||||
bp->b_iooffset = dbtob(bp->b_blkno); | bp->b_iooffset = dbtob(bp->b_blkno); | ||||
bstrategy(bp); | bstrategy(bp); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | bufwrite(struct buf *bp) | ||||
vfs_busy_pages(bp, 1); | vfs_busy_pages(bp, 1); | ||||
/* | /* | ||||
* Normal bwrites pipeline writes | * Normal bwrites pipeline writes | ||||
*/ | */ | ||||
bp->b_runningbufspace = bp->b_bufsize; | bp->b_runningbufspace = bp->b_bufsize; | ||||
space = atomic_fetchadd_long(&runningbufspace, bp->b_runningbufspace); | space = atomic_fetchadd_long(&runningbufspace, bp->b_runningbufspace); | ||||
if (!TD_IS_IDLETHREAD(curthread)) | if (!TD_IS_IDLETHREAD(curthread)) { | ||||
#ifdef RACCT | |||||
if (racct_enable) { | |||||
PROC_LOCK(curproc); | |||||
racct_add_buf(curproc, bp, 1); | |||||
PROC_UNLOCK(curproc); | |||||
} | |||||
#endif /* RACCT */ | |||||
curthread->td_ru.ru_oublock++; | curthread->td_ru.ru_oublock++; | ||||
} | |||||
if (oldflags & B_ASYNC) | if (oldflags & B_ASYNC) | ||||
BUF_KERNPROC(bp); | BUF_KERNPROC(bp); | ||||
bp->b_iooffset = dbtob(bp->b_blkno); | bp->b_iooffset = dbtob(bp->b_blkno); | ||||
bstrategy(bp); | bstrategy(bp); | ||||
if ((oldflags & B_ASYNC) == 0) { | if ((oldflags & B_ASYNC) == 0) { | ||||
int rtval = bufwait(bp); | int rtval = bufwait(bp); | ||||
brelse(bp); | brelse(bp); | ||||
▲ Show 20 Lines • Show All 2,829 Lines • Show Last 20 Lines |