stylistic polishing.

This commit is contained in:
Poul-Henning Kamp 2004-09-15 20:54:23 +00:00
parent 76ff6dcf46
commit ab19cad78e

@ -76,13 +76,13 @@ struct buf *buf; /* buffer header pool */
static struct proc *bufdaemonproc; static struct proc *bufdaemonproc;
static void vm_hold_free_pages(struct buf * bp, vm_offset_t from, static void vm_hold_free_pages(struct buf *bp, vm_offset_t from,
vm_offset_t to); vm_offset_t to);
static void vm_hold_load_pages(struct buf * bp, vm_offset_t from, static void vm_hold_load_pages(struct buf *bp, vm_offset_t from,
vm_offset_t to); vm_offset_t to);
static void vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, static void vfs_page_set_valid(struct buf *bp, vm_ooffset_t off,
int pageno, vm_page_t m); int pageno, vm_page_t m);
static void vfs_clean_pages(struct buf * bp); static void vfs_clean_pages(struct buf *bp);
static void vfs_setdirty(struct buf *bp); static void vfs_setdirty(struct buf *bp);
static void vfs_vmio_release(struct buf *bp); static void vfs_vmio_release(struct buf *bp);
static void vfs_backgroundwritedone(struct buf *bp); static void vfs_backgroundwritedone(struct buf *bp);
@ -90,7 +90,7 @@ static int vfs_bio_clcheck(struct vnode *vp, int size,
daddr_t lblkno, daddr_t blkno); daddr_t lblkno, daddr_t blkno);
static int flushbufqueues(int flushdeps); static int flushbufqueues(int flushdeps);
static void buf_daemon(void); static void buf_daemon(void);
void bremfreel(struct buf * bp); void bremfreel(struct buf *bp);
int vmiodirenable = TRUE; int vmiodirenable = TRUE;
SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0, SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0,
@ -266,6 +266,7 @@ extern void ffs_rawread_setup(void);
static __inline void static __inline void
numdirtywakeup(int level) numdirtywakeup(int level)
{ {
if (numdirtybuffers <= level) { if (numdirtybuffers <= level) {
mtx_lock(&nblock); mtx_lock(&nblock);
if (needsbuffer & VFS_BIO_NEED_DIRTYFLUSH) { if (needsbuffer & VFS_BIO_NEED_DIRTYFLUSH) {
@ -288,6 +289,7 @@ numdirtywakeup(int level)
static __inline void static __inline void
bufspacewakeup(void) bufspacewakeup(void)
{ {
/* /*
* If someone is waiting for BUF space, wake them up. Even * If someone is waiting for BUF space, wake them up. Even
* though we haven't freed the kva space yet, the waiting * though we haven't freed the kva space yet, the waiting
@ -308,6 +310,7 @@ bufspacewakeup(void)
static __inline void static __inline void
runningbufwakeup(struct buf *bp) runningbufwakeup(struct buf *bp)
{ {
if (bp->b_runningbufspace) { if (bp->b_runningbufspace) {
atomic_subtract_int(&runningbufspace, bp->b_runningbufspace); atomic_subtract_int(&runningbufspace, bp->b_runningbufspace);
bp->b_runningbufspace = 0; bp->b_runningbufspace = 0;
@ -332,6 +335,7 @@ runningbufwakeup(struct buf *bp)
static __inline void static __inline void
bufcountwakeup(void) bufcountwakeup(void)
{ {
atomic_add_int(&numfreebuffers, 1); atomic_add_int(&numfreebuffers, 1);
mtx_lock(&nblock); mtx_lock(&nblock);
if (needsbuffer) { if (needsbuffer) {
@ -361,6 +365,7 @@ bufcountwakeup(void)
static __inline void static __inline void
waitrunningbufspace(void) waitrunningbufspace(void)
{ {
mtx_lock(&rbreqlock); mtx_lock(&rbreqlock);
while (runningbufspace > hirunningspace) { while (runningbufspace > hirunningspace) {
++runningbufreq; ++runningbufreq;
@ -383,6 +388,7 @@ vfs_buf_test_cache(struct buf *bp,
vm_ooffset_t foff, vm_offset_t off, vm_offset_t size, vm_ooffset_t foff, vm_offset_t off, vm_offset_t size,
vm_page_t m) vm_page_t m)
{ {
GIANT_REQUIRED; GIANT_REQUIRED;
VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
@ -398,6 +404,7 @@ static __inline
void void
bd_wakeup(int dirtybuflevel) bd_wakeup(int dirtybuflevel)
{ {
mtx_lock(&bdlock); mtx_lock(&bdlock);
if (bd_request == 0 && numdirtybuffers >= dirtybuflevel) { if (bd_request == 0 && numdirtybuffers >= dirtybuflevel) {
bd_request = 1; bd_request = 1;
@ -414,6 +421,7 @@ static __inline
void void
bd_speedup(void) bd_speedup(void)
{ {
bd_wakeup(1); bd_wakeup(1);
} }
@ -426,6 +434,7 @@ bd_speedup(void)
caddr_t caddr_t
kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est) kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
{ {
/* /*
* physmem_est is in pages. Convert it to kilobytes (assumes * physmem_est is in pages. Convert it to kilobytes (assumes
* PAGE_SIZE is >= 1K) * PAGE_SIZE is >= 1K)
@ -603,8 +612,9 @@ bufinit(void)
* Since this call frees up buffer space, we call bufspacewakeup(). * Since this call frees up buffer space, we call bufspacewakeup().
*/ */
static void static void
bfreekva(struct buf * bp) bfreekva(struct buf *bp)
{ {
GIANT_REQUIRED; GIANT_REQUIRED;
if (bp->b_kvasize) { if (bp->b_kvasize) {
@ -625,15 +635,16 @@ bfreekva(struct buf * bp)
* Remove the buffer from the appropriate free list. * Remove the buffer from the appropriate free list.
*/ */
void void
bremfree(struct buf * bp) bremfree(struct buf *bp)
{ {
mtx_lock(&bqlock); mtx_lock(&bqlock);
bremfreel(bp); bremfreel(bp);
mtx_unlock(&bqlock); mtx_unlock(&bqlock);
} }
void void
bremfreel(struct buf * bp) bremfreel(struct buf *bp)
{ {
int s = splbio(); int s = splbio();
int old_qindex = bp->b_qindex; int old_qindex = bp->b_qindex;
@ -678,7 +689,7 @@ bremfreel(struct buf * bp)
*/ */
int int
bread(struct vnode * vp, daddr_t blkno, int size, struct ucred * cred, bread(struct vnode * vp, daddr_t blkno, int size, struct ucred * cred,
struct buf ** bpp) struct buf **bpp)
{ {
return (breadn(vp, blkno, size, 0, 0, 0, cred, bpp)); return (breadn(vp, blkno, size, 0, 0, 0, cred, bpp));
@ -693,7 +704,7 @@ bread(struct vnode * vp, daddr_t blkno, int size, struct ucred * cred,
int int
breadn(struct vnode * vp, daddr_t blkno, int size, breadn(struct vnode * vp, daddr_t blkno, int size,
daddr_t * rablkno, int *rabsize, daddr_t * rablkno, int *rabsize,
int cnt, struct ucred * cred, struct buf ** bpp) int cnt, struct ucred * cred, struct buf **bpp)
{ {
struct buf *bp, *rabp; struct buf *bp, *rabp;
int i; int i;
@ -763,7 +774,7 @@ breadn(struct vnode * vp, daddr_t blkno, int size,
* here. * here.
*/ */
int int
bwrite(struct buf * bp) bwrite(struct buf *bp)
{ {
KASSERT(bp->b_op != NULL && bp->b_op->bop_write != NULL, KASSERT(bp->b_op != NULL && bp->b_op->bop_write != NULL,
@ -772,7 +783,7 @@ bwrite(struct buf * bp)
} }
static int static int
ibwrite(struct buf * bp) ibwrite(struct buf *bp)
{ {
int oldflags, s; int oldflags, s;
struct buf *newbp; struct buf *newbp;
@ -918,8 +929,7 @@ ibwrite(struct buf * bp)
* Complete a background write started from bwrite. * Complete a background write started from bwrite.
*/ */
static void static void
vfs_backgroundwritedone(bp) vfs_backgroundwritedone(struct buf *bp)
struct buf *bp;
{ {
struct buf *origbp; struct buf *origbp;
@ -974,7 +984,7 @@ vfs_backgroundwritedone(bp)
* out synchronously. * out synchronously.
*/ */
void void
bdwrite(struct buf * bp) bdwrite(struct buf *bp)
{ {
struct thread *td = curthread; struct thread *td = curthread;
struct vnode *vp; struct vnode *vp;
@ -1099,9 +1109,9 @@ bdwrite(struct buf * bp)
* The buffer must be on QUEUE_NONE. * The buffer must be on QUEUE_NONE.
*/ */
void void
bdirty(bp) bdirty(struct buf *bp)
struct buf *bp;
{ {
KASSERT(bp->b_qindex == QUEUE_NONE, KASSERT(bp->b_qindex == QUEUE_NONE,
("bdirty: buffer %p still on queue %d", bp, bp->b_qindex)); ("bdirty: buffer %p still on queue %d", bp, bp->b_qindex));
bp->b_flags &= ~(B_RELBUF); bp->b_flags &= ~(B_RELBUF);
@ -1128,9 +1138,9 @@ bdirty(bp)
*/ */
void void
bundirty(bp) bundirty(struct buf *bp)
struct buf *bp;
{ {
KASSERT(bp->b_qindex == QUEUE_NONE, KASSERT(bp->b_qindex == QUEUE_NONE,
("bundirty: buffer %p still on queue %d", bp, bp->b_qindex)); ("bundirty: buffer %p still on queue %d", bp, bp->b_qindex));
@ -1156,8 +1166,9 @@ bundirty(bp)
* B_INVAL buffers. Not us. * B_INVAL buffers. Not us.
*/ */
void void
bawrite(struct buf * bp) bawrite(struct buf *bp)
{ {
bp->b_flags |= B_ASYNC; bp->b_flags |= B_ASYNC;
(void) bwrite(bp); (void) bwrite(bp);
} }
@ -1175,6 +1186,7 @@ bawrite(struct buf * bp)
void void
bwillwrite(void) bwillwrite(void)
{ {
if (numdirtybuffers >= hidirtybuffers) { if (numdirtybuffers >= hidirtybuffers) {
int s; int s;
@ -1199,6 +1211,7 @@ bwillwrite(void)
int int
buf_dirty_count_severe(void) buf_dirty_count_severe(void)
{ {
return(numdirtybuffers >= hidirtybuffers); return(numdirtybuffers >= hidirtybuffers);
} }
@ -1210,7 +1223,7 @@ buf_dirty_count_severe(void)
* to be accessed later as a cache entity or reused for other purposes. * to be accessed later as a cache entity or reused for other purposes.
*/ */
void void
brelse(struct buf * bp) brelse(struct buf *bp)
{ {
int s; int s;
@ -1357,11 +1370,13 @@ brelse(struct buf * bp)
} }
if ((bp->b_flags & B_INVAL) == 0) { if ((bp->b_flags & B_INVAL) == 0) {
pmap_qenter(trunc_page((vm_offset_t)bp->b_data), bp->b_pages, bp->b_npages); pmap_qenter(
trunc_page((vm_offset_t)bp->b_data), bp->b_pages, bp->b_npages);
} }
m = bp->b_pages[i]; m = bp->b_pages[i];
} }
if ((bp->b_flags & B_NOCACHE) || (bp->b_ioflags & BIO_ERROR)) { if ((bp->b_flags & B_NOCACHE) ||
(bp->b_ioflags & BIO_ERROR)) {
int poffset = foff & PAGE_MASK; int poffset = foff & PAGE_MASK;
int presid = resid > (PAGE_SIZE - poffset) ? int presid = resid > (PAGE_SIZE - poffset) ?
(PAGE_SIZE - poffset) : resid; (PAGE_SIZE - poffset) : resid;
@ -1485,13 +1500,14 @@ brelse(struct buf * bp)
* XXX we should be able to leave the B_RELBUF hint set on completion. * XXX we should be able to leave the B_RELBUF hint set on completion.
*/ */
void void
bqrelse(struct buf * bp) bqrelse(struct buf *bp)
{ {
int s; int s;
s = splbio(); s = splbio();
KASSERT(!(bp->b_flags & (B_CLUSTER|B_PAGING)), ("bqrelse: inappropriate B_PAGING or B_CLUSTER bp %p", bp)); KASSERT(!(bp->b_flags & (B_CLUSTER|B_PAGING)),
("bqrelse: inappropriate B_PAGING or B_CLUSTER bp %p", bp));
if (bp->b_qindex != QUEUE_NONE) if (bp->b_qindex != QUEUE_NONE)
panic("bqrelse: free buffer onto another queue???"); panic("bqrelse: free buffer onto another queue???");
@ -1552,8 +1568,7 @@ bqrelse(struct buf * bp)
/* Give pages used by the bp back to the VM system (where possible) */ /* Give pages used by the bp back to the VM system (where possible) */
static void static void
vfs_vmio_release(bp) vfs_vmio_release(struct buf *bp)
struct buf *bp;
{ {
int i; int i;
vm_page_t m; vm_page_t m;
@ -1657,7 +1672,7 @@ done:
* correct order, so we search for the cluster in both directions. * correct order, so we search for the cluster in both directions.
*/ */
int int
vfs_bio_awrite(struct buf * bp) vfs_bio_awrite(struct buf *bp)
{ {
int i; int i;
int j; int j;
@ -2139,6 +2154,7 @@ buf_daemon()
int flushwithdeps = 0; int flushwithdeps = 0;
SYSCTL_INT(_vfs, OID_AUTO, flushwithdeps, CTLFLAG_RW, &flushwithdeps, SYSCTL_INT(_vfs, OID_AUTO, flushwithdeps, CTLFLAG_RW, &flushwithdeps,
0, "Number of buffers flushed with dependecies that require rollbacks"); 0, "Number of buffers flushed with dependecies that require rollbacks");
static int static int
flushbufqueues(int flushdeps) flushbufqueues(int flushdeps)
{ {
@ -2992,6 +3008,7 @@ allocbuf(struct buf *bp, int size)
void void
biodone(struct bio *bp) biodone(struct bio *bp)
{ {
mtx_lock(&bdonelock); mtx_lock(&bdonelock);
bp->bio_flags |= BIO_DONE; bp->bio_flags |= BIO_DONE;
if (bp->bio_done == NULL) if (bp->bio_done == NULL)
@ -3043,7 +3060,7 @@ biofinish(struct bio *bp, struct devstat *stat, int error)
* error and cleared. * error and cleared.
*/ */
int int
bufwait(register struct buf * bp) bufwait(struct buf *bp)
{ {
int s; int s;
@ -3284,7 +3301,7 @@ bufdone(struct buf *bp)
* consistant. * consistant.
*/ */
void void
vfs_unbusy_pages(struct buf * bp) vfs_unbusy_pages(struct buf *bp)
{ {
int i; int i;
@ -3366,7 +3383,7 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, int pageno, vm_page_t m)
* and should be ignored. * and should be ignored.
*/ */
void void
vfs_busy_pages(struct buf * bp, int clear_modify) vfs_busy_pages(struct buf *bp, int clear_modify)
{ {
int i, bogus; int i, bogus;
@ -3437,7 +3454,7 @@ retry:
* just go ahead and clean through to b_bufsize. * just go ahead and clean through to b_bufsize.
*/ */
static void static void
vfs_clean_pages(struct buf * bp) vfs_clean_pages(struct buf *bp)
{ {
int i; int i;
@ -3477,6 +3494,7 @@ vfs_clean_pages(struct buf * bp)
void void
vfs_bio_set_validclean(struct buf *bp, int base, int size) vfs_bio_set_validclean(struct buf *bp, int base, int size)
{ {
if (bp->b_flags & B_VMIO) { if (bp->b_flags & B_VMIO) {
int i; int i;
int n; int n;
@ -3585,7 +3603,7 @@ unlock:
* not associated with a file object. * not associated with a file object.
*/ */
static void static void
vm_hold_load_pages(struct buf * bp, vm_offset_t from, vm_offset_t to) vm_hold_load_pages(struct buf *bp, vm_offset_t from, vm_offset_t to)
{ {
vm_offset_t pg; vm_offset_t pg;
vm_page_t p; vm_page_t p;
@ -3627,7 +3645,7 @@ tryagain:
/* Return pages associated with this buf to the vm system */ /* Return pages associated with this buf to the vm system */
static void static void
vm_hold_free_pages(struct buf * bp, vm_offset_t from, vm_offset_t to) vm_hold_free_pages(struct buf *bp, vm_offset_t from, vm_offset_t to)
{ {
vm_offset_t pg; vm_offset_t pg;
vm_page_t p; vm_page_t p;
@ -3685,8 +3703,9 @@ vmapbuf(struct buf *bp)
if (bp->b_bufsize < 0) if (bp->b_bufsize < 0)
return (-1); return (-1);
prot = (bp->b_iocmd == BIO_READ) ? VM_PROT_READ | VM_PROT_WRITE : prot = VM_PROT_READ;
VM_PROT_READ; if (bp->b_iocmd == BIO_READ)
prot |= VM_PROT_WRITE; /* Less backwards than it looks */
for (addr = (caddr_t)trunc_page((vm_offset_t)bp->b_data), pidx = 0; for (addr = (caddr_t)trunc_page((vm_offset_t)bp->b_data), pidx = 0;
addr < bp->b_data + bp->b_bufsize; addr < bp->b_data + bp->b_bufsize;
addr += PAGE_SIZE, pidx++) { addr += PAGE_SIZE, pidx++) {
@ -3736,8 +3755,7 @@ vunmapbuf(struct buf *bp)
int npages; int npages;
npages = bp->b_npages; npages = bp->b_npages;
pmap_qremove(trunc_page((vm_offset_t)bp->b_data), pmap_qremove(trunc_page((vm_offset_t)bp->b_data), npages);
npages);
vm_page_lock_queues(); vm_page_lock_queues();
for (pidx = 0; pidx < npages; pidx++) for (pidx = 0; pidx < npages; pidx++)
vm_page_unhold(bp->b_pages[pidx]); vm_page_unhold(bp->b_pages[pidx]);
@ -3749,6 +3767,7 @@ vunmapbuf(struct buf *bp)
void void
bdone(struct buf *bp) bdone(struct buf *bp)
{ {
mtx_lock(&bdonelock); mtx_lock(&bdonelock);
bp->b_flags |= B_DONE; bp->b_flags |= B_DONE;
wakeup(bp); wakeup(bp);
@ -3758,6 +3777,7 @@ bdone(struct buf *bp)
void void
bwait(struct buf *bp, u_char pri, const char *wchan) bwait(struct buf *bp, u_char pri, const char *wchan)
{ {
mtx_lock(&bdonelock); mtx_lock(&bdonelock);
while ((bp->b_flags & B_DONE) == 0) while ((bp->b_flags & B_DONE) == 0)
msleep(bp, &bdonelock, pri, wchan, 0); msleep(bp, &bdonelock, pri, wchan, 0);