Syntax cleanup and documentation, no operational changes.

MFC after:	1 day
This commit is contained in:
Matthew Dillon 2001-10-21 06:12:06 +00:00
parent 08b00f49c3
commit 57601bcb5d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=85272
2 changed files with 64 additions and 15 deletions

View File

@ -353,6 +353,12 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
if (bp == 0)
return tbp;
/*
* We are synthesizing a buffer out of vm_page_t's, but
* if the block size is not page aligned then the starting
* address may not be either. Inherit the b_data offset
* from the original buffer.
*/
bp->b_data = (char *)((vm_offset_t)bp->b_data |
((vm_offset_t)tbp->b_data & PAGE_MASK));
bp->b_flags = B_ASYNC | B_CLUSTER | B_VMIO;
@ -374,17 +380,24 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
for (bn = blkno, i = 0; i < run; ++i, bn += inc) {
if (i != 0) {
if ((bp->b_npages * PAGE_SIZE) +
round_page(size) > vp->v_mount->mnt_iosize_max)
round_page(size) > vp->v_mount->mnt_iosize_max) {
break;
}
/*
* Shortcut some checks and try to avoid buffers that
* would block in the lock. The same checks have to
* be made again after we officially get the buffer.
*/
if ((tbp = incore(vp, lbn + i)) != NULL) {
if (BUF_LOCK(tbp, LK_EXCLUSIVE | LK_NOWAIT))
break;
BUF_UNLOCK(tbp);
for (j = 0; j < tbp->b_npages; j++)
for (j = 0; j < tbp->b_npages; j++) {
if (tbp->b_pages[j]->valid)
break;
}
if (j != tbp->b_npages)
break;
@ -396,10 +409,11 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
tbp = getblk(vp, lbn + i, size, 0, 0);
/*
* If the buffer is already fully valid or locked
* (which could also mean that a background write is
* in progress), or the buffer is not backed by VMIO,
* stop.
* Stop scanning if the buffer is fully valid
* (marked B_CACHE), or locked (may be doing a
* background write), or if the buffer is not
* VMIO backed. The clustering code can only deal
* with VMIO-backed buffers.
*/
if ((tbp->b_flags & (B_CACHE|B_LOCKED)) ||
(tbp->b_flags & B_VMIO) == 0) {
@ -407,18 +421,33 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
break;
}
/*
* The buffer must be completely invalid in order to
* take part in the cluster. If it is partially valid
* then we stop.
*/
for (j = 0;j < tbp->b_npages; j++) {
if (tbp->b_pages[j]->valid)
break;
}
if (j != tbp->b_npages) {
bqrelse(tbp);
break;
}
/*
* Set a read-ahead mark as appropriate
*/
if ((fbp && (i == 1)) || (i == (run - 1)))
tbp->b_flags |= B_RAM;
/*
* Set the buffer up for an async read (XXX should
* we do this only if we do not wind up brelse()ing?).
* Set the block number if it isn't set, otherwise
* if it is make sure it matches the block number we
* expect.
*/
tbp->b_flags |= B_ASYNC;
tbp->b_iocmd = BIO_READ;
if (tbp->b_blkno == tbp->b_lblkno) {
@ -452,10 +481,15 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
bp->b_bufsize += tbp->b_bufsize;
}
for(j=0;j<bp->b_npages;j++) {
/*
* Fully valid pages in the cluster are already good and do not need
* to be re-read from disk. Replace the page with bogus_page
*/
for (j = 0; j < bp->b_npages; j++) {
if ((bp->b_pages[j]->valid & VM_PAGE_BITS_ALL) ==
VM_PAGE_BITS_ALL)
VM_PAGE_BITS_ALL) {
bp->b_pages[j] = bogus_page;
}
}
if (bp->b_bufsize > bp->b_kvasize)
panic("cluster_rbuild: b_bufsize(%ld) > b_kvasize(%d)\n",
@ -780,6 +814,13 @@ cluster_wbuild(vp, size, start_lbn, len)
bp->b_blkno = tbp->b_blkno;
bp->b_lblkno = tbp->b_lblkno;
bp->b_offset = tbp->b_offset;
/*
* We are synthesizing a buffer out of vm_page_t's, but
* if the block size is not page aligned then the starting
* address may not be either. Inherit the b_data offset
* from the original buffer.
*/
bp->b_data = (char *)((vm_offset_t)bp->b_data |
((vm_offset_t)tbp->b_data & PAGE_MASK));
bp->b_flags |= B_CLUSTER |
@ -849,7 +890,11 @@ cluster_wbuild(vp, size, start_lbn, len)
buf_start(tbp);
/*
* If the IO is via the VM then we do some
* special VM hackery. (yuck)
* special VM hackery (yuck). Since the buffer's
* block size may not be page-aligned it is possible
* for a page to be shared between two buffers. We
* have to get rid of the duplication when building
* the cluster.
*/
if (tbp->b_flags & B_VMIO) {
vm_page_t m;

View File

@ -294,8 +294,8 @@ vm_pageout_clean(m)
vm_page_test_dirty(p);
if ((p->dirty & p->valid) == 0 ||
p->queue != PQ_INACTIVE ||
p->wire_count != 0 ||
p->hold_count != 0) {
p->wire_count != 0 || /* may be held by buf cache */
p->hold_count != 0) { /* may be undergoing I/O */
ib = 0;
break;
}
@ -323,8 +323,8 @@ vm_pageout_clean(m)
vm_page_test_dirty(p);
if ((p->dirty & p->valid) == 0 ||
p->queue != PQ_INACTIVE ||
p->wire_count != 0 ||
p->hold_count != 0) {
p->wire_count != 0 || /* may be held by buf cache */
p->hold_count != 0) { /* may be undergoing I/O */
break;
}
mc[page_base + pageout_count] = p;
@ -714,6 +714,9 @@ vm_pageout_scan(int pass)
if (m->flags & PG_MARKER)
continue;
/*
* A held page may be undergoing I/O, so skip it.
*/
if (m->hold_count) {
vm_pageq_requeue(m);
addl_page_shortage++;
@ -904,7 +907,8 @@ vm_pageout_scan(int pass)
}
/*
* If the page has become held, then skip it
* If the page has become held it might
* be undergoing I/O, so skip it
*/
if (m->hold_count) {
vm_pageq_requeue(m);