Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/vfs_bio.c
Show First 20 Lines • Show All 2,067 Lines • ▼ Show 20 Lines | |||||
* clear BIO_ERROR and B_INVAL prior to initiating I/O . If B_CACHE is set, | * clear BIO_ERROR and B_INVAL prior to initiating I/O . If B_CACHE is set, | ||||
* the buffer is valid and we do not have to do anything. | * the buffer is valid and we do not have to do anything. | ||||
*/ | */ | ||||
static void | static void | ||||
breada(struct vnode * vp, daddr_t * rablkno, int * rabsize, int cnt, | breada(struct vnode * vp, daddr_t * rablkno, int * rabsize, int cnt, | ||||
struct ucred * cred, int flags, void (*ckhashfunc)(struct buf *)) | struct ucred * cred, int flags, void (*ckhashfunc)(struct buf *)) | ||||
{ | { | ||||
struct buf *rabp; | struct buf *rabp; | ||||
struct thread *td; | |||||
int i; | int i; | ||||
td = curthread; | |||||
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) { | ||||
brelse(rabp); | brelse(rabp); | ||||
continue; | continue; | ||||
} | } | ||||
if (!TD_IS_IDLETHREAD(curthread)) { | |||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | if (racct_enable) { | ||||
PROC_LOCK(curproc); | PROC_LOCK(curproc); | ||||
racct_add_buf(curproc, rabp, 0); | racct_add_buf(curproc, rabp, 0); | ||||
PROC_UNLOCK(curproc); | PROC_UNLOCK(curproc); | ||||
} | } | ||||
#endif /* RACCT */ | #endif /* RACCT */ | ||||
curthread->td_ru.ru_inblock++; | td->td_ru.ru_inblock++; | ||||
} | |||||
rabp->b_flags |= B_ASYNC; | rabp->b_flags |= B_ASYNC; | ||||
rabp->b_flags &= ~B_INVAL; | rabp->b_flags &= ~B_INVAL; | ||||
if ((flags & GB_CKHASH) != 0) { | if ((flags & GB_CKHASH) != 0) { | ||||
rabp->b_flags |= B_CKHASH; | rabp->b_flags |= B_CKHASH; | ||||
rabp->b_ckhashcalc = ckhashfunc; | rabp->b_ckhashcalc = ckhashfunc; | ||||
} | } | ||||
rabp->b_ioflags &= ~BIO_ERROR; | rabp->b_ioflags &= ~BIO_ERROR; | ||||
rabp->b_iocmd = BIO_READ; | rabp->b_iocmd = BIO_READ; | ||||
Show All 39 Lines | breadn_flags(struct vnode *vp, daddr_t blkno, int size, daddr_t *rablkno, | ||||
flags &= ~GB_NOSPARSE; | flags &= ~GB_NOSPARSE; | ||||
*bpp = bp; | *bpp = bp; | ||||
/* | /* | ||||
* If not found in cache, do some I/O | * If not found in cache, do some I/O | ||||
*/ | */ | ||||
readwait = 0; | readwait = 0; | ||||
if ((bp->b_flags & B_CACHE) == 0) { | if ((bp->b_flags & B_CACHE) == 0) { | ||||
if (!TD_IS_IDLETHREAD(td)) { | |||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | if (racct_enable) { | ||||
PROC_LOCK(td->td_proc); | PROC_LOCK(td->td_proc); | ||||
racct_add_buf(td->td_proc, bp, 0); | racct_add_buf(td->td_proc, bp, 0); | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
} | } | ||||
#endif /* RACCT */ | #endif /* RACCT */ | ||||
td->td_ru.ru_inblock++; | td->td_ru.ru_inblock++; | ||||
} | |||||
bp->b_iocmd = BIO_READ; | bp->b_iocmd = BIO_READ; | ||||
bp->b_flags &= ~B_INVAL; | bp->b_flags &= ~B_INVAL; | ||||
if ((flags & GB_CKHASH) != 0) { | if ((flags & GB_CKHASH) != 0) { | ||||
bp->b_flags |= B_CKHASH; | bp->b_flags |= B_CKHASH; | ||||
bp->b_ckhashcalc = ckhashfunc; | bp->b_ckhashcalc = ckhashfunc; | ||||
} | } | ||||
bp->b_ioflags &= ~BIO_ERROR; | bp->b_ioflags &= ~BIO_ERROR; | ||||
if (bp->b_rcred == NOCRED && cred != NOCRED) | if (bp->b_rcred == NOCRED && cred != NOCRED) | ||||
▲ Show 20 Lines • Show All 84 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)) { | |||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | if (racct_enable) { | ||||
PROC_LOCK(curproc); | PROC_LOCK(curproc); | ||||
racct_add_buf(curproc, bp, 1); | racct_add_buf(curproc, bp, 1); | ||||
PROC_UNLOCK(curproc); | PROC_UNLOCK(curproc); | ||||
} | } | ||||
#endif /* RACCT */ | #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); | ||||
buf_track(bp, __func__); | buf_track(bp, __func__); | ||||
bstrategy(bp); | bstrategy(bp); | ||||
if ((oldflags & B_ASYNC) == 0) { | if ((oldflags & B_ASYNC) == 0) { | ||||
int rtval = bufwait(bp); | int rtval = bufwait(bp); | ||||
▲ Show 20 Lines • Show All 1,735 Lines • ▼ Show 20 Lines | if (bp != NULL) { | ||||
*/ | */ | ||||
BO_RUNLOCK(bo); | BO_RUNLOCK(bo); | ||||
/* | /* | ||||
* If the user does not want us to create the buffer, bail out | * If the user does not want us to create the buffer, bail out | ||||
* here. | * here. | ||||
*/ | */ | ||||
if (flags & GB_NOCREAT) | if (flags & GB_NOCREAT) | ||||
return (EEXIST); | return (EEXIST); | ||||
if (bdomain[bo->bo_domain].bd_freebuffers == 0 && | |||||
TD_IS_IDLETHREAD(curthread)) | |||||
return (EBUSY); | |||||
bsize = vn_isdisk(vp, NULL) ? DEV_BSIZE : bo->bo_bsize; | bsize = vn_isdisk(vp, NULL) ? DEV_BSIZE : bo->bo_bsize; | ||||
KASSERT(bsize != 0, ("bsize == 0, check bo->bo_bsize")); | KASSERT(bsize != 0, ("bsize == 0, check bo->bo_bsize")); | ||||
offset = blkno * bsize; | offset = blkno * bsize; | ||||
vmio = vp->v_object != NULL; | vmio = vp->v_object != NULL; | ||||
if (vmio) { | if (vmio) { | ||||
maxsize = size + (offset & PAGE_MASK); | maxsize = size + (offset & PAGE_MASK); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 1,473 Lines • Show Last 20 Lines |