summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_bio.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2009-05-17 23:25:53 +0000
committeralc <alc@FreeBSD.org>2009-05-17 23:25:53 +0000
commitc8b00d493e4cb30d131643c1e481e34b358aa198 (patch)
tree480aa98b87d2682b650efb9fbb5d87b89622cd30 /sys/kern/vfs_bio.c
parentf0d016550feee579b48b741fce35d050dfcdefda (diff)
downloadFreeBSD-src-c8b00d493e4cb30d131643c1e481e34b358aa198.zip
FreeBSD-src-c8b00d493e4cb30d131643c1e481e34b358aa198.tar.gz
Several changes to vfs_bio_clrbuf():
Provide a more descriptive comment. Eliminate dead code. The page cannot possibly have PG_ZERO set. Eliminate unnecessary blank lines. Reviewed by: tegge
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r--sys/kern/vfs_bio.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index e5a947b..16df889 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -3706,24 +3706,25 @@ vfs_bio_set_validclean(struct buf *bp, int base, int size)
/*
* vfs_bio_clrbuf:
*
- * clear a buffer. This routine essentially fakes an I/O, so we need
- * to clear BIO_ERROR and B_INVAL.
+ * If the specified buffer is a non-VMIO buffer, clear the entire
+ * buffer. If the specified buffer is a VMIO buffer, clear and
+ * validate only the previously invalid portions of the buffer.
+ * This routine essentially fakes an I/O, so we need to clear
+ * BIO_ERROR and B_INVAL.
*
* Note that while we only theoretically need to clear through b_bcount,
* we go ahead and clear through b_bufsize.
*/
-
void
vfs_bio_clrbuf(struct buf *bp)
{
- int i, j, mask = 0;
+ int i, j, mask;
caddr_t sa, ea;
if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) {
clrbuf(bp);
return;
}
-
bp->b_flags &= ~B_INVAL;
bp->b_ioflags &= ~BIO_ERROR;
VM_OBJECT_LOCK(bp->b_bufobj->bo_object);
@@ -3735,8 +3736,7 @@ vfs_bio_clrbuf(struct buf *bp)
VM_OBJECT_LOCK_ASSERT(bp->b_pages[0]->object, MA_OWNED);
if ((bp->b_pages[0]->valid & mask) == mask)
goto unlock;
- if (((bp->b_pages[0]->flags & PG_ZERO) == 0) &&
- ((bp->b_pages[0]->valid & mask) == 0)) {
+ if ((bp->b_pages[0]->valid & mask) == 0) {
bzero(bp->b_data, bp->b_bufsize);
bp->b_pages[0]->valid |= mask;
goto unlock;
@@ -3755,13 +3755,11 @@ vfs_bio_clrbuf(struct buf *bp)
VM_OBJECT_LOCK_ASSERT(bp->b_pages[i]->object, MA_OWNED);
if ((bp->b_pages[i]->valid & mask) == mask)
continue;
- if ((bp->b_pages[i]->valid & mask) == 0) {
- if ((bp->b_pages[i]->flags & PG_ZERO) == 0)
- bzero(sa, ea - sa);
- } else {
+ if ((bp->b_pages[i]->valid & mask) == 0)
+ bzero(sa, ea - sa);
+ else {
for (; sa < ea; sa += DEV_BSIZE, j++) {
- if (((bp->b_pages[i]->flags & PG_ZERO) == 0) &&
- (bp->b_pages[i]->valid & (1 << j)) == 0)
+ if ((bp->b_pages[i]->valid & (1 << j)) == 0)
bzero(sa, DEV_BSIZE);
}
}
OpenPOWER on IntegriCloud