vfs_bio.c (18ff64943ecb510f24e09317ed5cb6682080fd1a) | vfs_bio.c (aa8de40ae504c80301d07b7a4cfa74359792cc72) |
---|---|
1/* 2 * Copyright (c) 1994 John S. Dyson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 4 unchanged lines hidden (view full) --- 13 * documentation and/or other materials provided with the distribution. 14 * 3. Absolutely no warranty of function or purpose is made by the author 15 * John S. Dyson. 16 * 4. This work was done expressly for inclusion into FreeBSD. Other use 17 * is allowed if this notation is included. 18 * 5. Modifications may be freely made to this file if the above conditions 19 * are met. 20 * | 1/* 2 * Copyright (c) 1994 John S. Dyson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 4 unchanged lines hidden (view full) --- 13 * documentation and/or other materials provided with the distribution. 14 * 3. Absolutely no warranty of function or purpose is made by the author 15 * John S. Dyson. 16 * 4. This work was done expressly for inclusion into FreeBSD. Other use 17 * is allowed if this notation is included. 18 * 5. Modifications may be freely made to this file if the above conditions 19 * are met. 20 * |
21 * $Id: vfs_bio.c,v 1.87 1996/03/03 01:04:28 dyson Exp $ | 21 * $Id: vfs_bio.c,v 1.88 1996/03/09 06:46:51 dyson Exp $ |
22 */ 23 24/* 25 * this file contains a new buffer I/O scheme implementing a coherent 26 * VM object and buffer cache scheme. Pains have been taken to make 27 * sure that the performance degradation associated with schemes such 28 * as this is not realized. 29 * --- 700 unchanged lines hidden (view full) --- 730 731/* 732 * Find a buffer header which is available for use. 733 */ 734static struct buf * 735getnewbuf(int slpflag, int slptimeo, int doingvmio) 736{ 737 struct buf *bp; | 22 */ 23 24/* 25 * this file contains a new buffer I/O scheme implementing a coherent 26 * VM object and buffer cache scheme. Pains have been taken to make 27 * sure that the performance degradation associated with schemes such 28 * as this is not realized. 29 * --- 700 unchanged lines hidden (view full) --- 730 731/* 732 * Find a buffer header which is available for use. 733 */ 734static struct buf * 735getnewbuf(int slpflag, int slptimeo, int doingvmio) 736{ 737 struct buf *bp; |
738 int s; | |
739 int nbyteswritten = 0; 740 741start: 742 if (bufspace >= maxbufspace) 743 goto trytofreespace; 744 745 /* can we constitute a new buffer? */ 746 if ((bp = bufqueues[QUEUE_EMPTY].tqh_first)) { --- 106 unchanged lines hidden (view full) --- 853 854/* 855 * Check to see if a block is currently memory resident. 856 */ 857struct buf * 858incore(struct vnode * vp, daddr_t blkno) 859{ 860 struct buf *bp; | 738 int nbyteswritten = 0; 739 740start: 741 if (bufspace >= maxbufspace) 742 goto trytofreespace; 743 744 /* can we constitute a new buffer? */ 745 if ((bp = bufqueues[QUEUE_EMPTY].tqh_first)) { --- 106 unchanged lines hidden (view full) --- 852 853/* 854 * Check to see if a block is currently memory resident. 855 */ 856struct buf * 857incore(struct vnode * vp, daddr_t blkno) 858{ 859 struct buf *bp; |
861 struct bufhashhdr *bh; | |
862 863 int s = splbio(); 864 bp = gbincore(vp, blkno); 865 splx(s); 866 return (bp); 867} 868 869/* --- 380 unchanged lines hidden (view full) --- 1250 if (m->pindex != objoff) 1251 panic("allocbuf: page changed offset??!!!?"); 1252#endif 1253 bytesinpage = tinc; 1254 if (tinc > (newbsize - toff)) 1255 bytesinpage = newbsize - toff; 1256 if ((bp->b_flags & B_CACHE) && 1257 !vm_page_is_valid(m, | 860 861 int s = splbio(); 862 bp = gbincore(vp, blkno); 863 splx(s); 864 return (bp); 865} 866 867/* --- 380 unchanged lines hidden (view full) --- 1248 if (m->pindex != objoff) 1249 panic("allocbuf: page changed offset??!!!?"); 1250#endif 1251 bytesinpage = tinc; 1252 if (tinc > (newbsize - toff)) 1253 bytesinpage = newbsize - toff; 1254 if ((bp->b_flags & B_CACHE) && 1255 !vm_page_is_valid(m, |
1258 (vm_offset_t) ((toff + off) & (PAGE_SIZE - 1)), | 1256 (vm_offset_t) ((toff + off) & PAGE_MASK), |
1259 bytesinpage)) { 1260 bp->b_flags &= ~B_CACHE; 1261 } 1262 continue; 1263 } 1264 m = vm_page_lookup(obj, objoff); 1265 if (!m) { 1266 m = vm_page_alloc(obj, objoff, VM_ALLOC_NORMAL); --- 24 unchanged lines hidden (view full) --- 1291 (cnt.v_free_min + cnt.v_cache_min))) { 1292 pagedaemon_wakeup(); 1293 } 1294 bytesinpage = tinc; 1295 if (tinc > (newbsize - toff)) 1296 bytesinpage = newbsize - toff; 1297 if ((bp->b_flags & B_CACHE) && 1298 !vm_page_is_valid(m, | 1257 bytesinpage)) { 1258 bp->b_flags &= ~B_CACHE; 1259 } 1260 continue; 1261 } 1262 m = vm_page_lookup(obj, objoff); 1263 if (!m) { 1264 m = vm_page_alloc(obj, objoff, VM_ALLOC_NORMAL); --- 24 unchanged lines hidden (view full) --- 1289 (cnt.v_free_min + cnt.v_cache_min))) { 1290 pagedaemon_wakeup(); 1291 } 1292 bytesinpage = tinc; 1293 if (tinc > (newbsize - toff)) 1294 bytesinpage = newbsize - toff; 1295 if ((bp->b_flags & B_CACHE) && 1296 !vm_page_is_valid(m, |
1299 (vm_offset_t) ((toff + off) & (PAGE_SIZE - 1)), | 1297 (vm_offset_t) ((toff + off) & PAGE_MASK), |
1300 bytesinpage)) { 1301 bp->b_flags &= ~B_CACHE; 1302 } 1303 vm_page_wire(m); 1304 } 1305 bp->b_pages[pageindex] = m; 1306 curbpnpages = pageindex + 1; 1307 } 1308 bp->b_data = (caddr_t) trunc_page(bp->b_data); 1309 bp->b_npages = curbpnpages; 1310 pmap_qenter((vm_offset_t) bp->b_data, 1311 bp->b_pages, bp->b_npages); | 1298 bytesinpage)) { 1299 bp->b_flags &= ~B_CACHE; 1300 } 1301 vm_page_wire(m); 1302 } 1303 bp->b_pages[pageindex] = m; 1304 curbpnpages = pageindex + 1; 1305 } 1306 bp->b_data = (caddr_t) trunc_page(bp->b_data); 1307 bp->b_npages = curbpnpages; 1308 pmap_qenter((vm_offset_t) bp->b_data, 1309 bp->b_pages, bp->b_npages); |
1312 ((vm_offset_t) bp->b_data) |= off & (PAGE_SIZE - 1); | 1310 ((vm_offset_t) bp->b_data) |= off & PAGE_MASK; |
1313 } 1314 } 1315 } 1316 if (bp->b_flags & B_VMIO) 1317 vmiospace += bp->b_bufsize; 1318 bufspace += (newbsize - bp->b_bufsize); 1319 bp->b_bufsize = newbsize; 1320 bp->b_bcount = size; --- 108 unchanged lines hidden (view full) --- 1429 resid = iosize; 1430 /* 1431 * In the write case, the valid and clean bits are 1432 * already changed correctly, so we only need to do this 1433 * here in the read case. 1434 */ 1435 if ((bp->b_flags & B_READ) && !bogusflag && resid > 0) { 1436 vm_page_set_validclean(m, | 1311 } 1312 } 1313 } 1314 if (bp->b_flags & B_VMIO) 1315 vmiospace += bp->b_bufsize; 1316 bufspace += (newbsize - bp->b_bufsize); 1317 bp->b_bufsize = newbsize; 1318 bp->b_bcount = size; --- 108 unchanged lines hidden (view full) --- 1427 resid = iosize; 1428 /* 1429 * In the write case, the valid and clean bits are 1430 * already changed correctly, so we only need to do this 1431 * here in the read case. 1432 */ 1433 if ((bp->b_flags & B_READ) && !bogusflag && resid > 0) { 1434 vm_page_set_validclean(m, |
1437 (vm_offset_t) (foff & (PAGE_SIZE-1)), resid); | 1435 (vm_offset_t) (foff & PAGE_MASK), resid); |
1438 } 1439 1440 /* 1441 * when debugging new filesystems or buffer I/O methods, this 1442 * is the most common error that pops up. if you see this, you 1443 * have not set the page busy flag correctly!!! 1444 */ 1445 if (m->busy == 0) { 1446 printf("biodone: page busy < 0, " 1447 "pindex: %d, foff: 0x(%x,%x), " 1448 "resid: %d, index: %d\n", 1449 (int) m->pindex, (int)(foff >> 32), 1450 (int) foff & 0xffffffff, resid, i); 1451 if (vp->v_type != VBLK) | 1436 } 1437 1438 /* 1439 * when debugging new filesystems or buffer I/O methods, this 1440 * is the most common error that pops up. if you see this, you 1441 * have not set the page busy flag correctly!!! 1442 */ 1443 if (m->busy == 0) { 1444 printf("biodone: page busy < 0, " 1445 "pindex: %d, foff: 0x(%x,%x), " 1446 "resid: %d, index: %d\n", 1447 (int) m->pindex, (int)(foff >> 32), 1448 (int) foff & 0xffffffff, resid, i); 1449 if (vp->v_type != VBLK) |
1452 printf(" iosize: %d, lblkno: %d, flags: 0x%lx, npages: %d\n", | 1450 printf(" iosize: %ld, lblkno: %d, flags: 0x%lx, npages: %d\n", |
1453 bp->b_vp->v_mount->mnt_stat.f_iosize, 1454 (int) bp->b_lblkno, 1455 bp->b_flags, bp->b_npages); 1456 else 1457 printf(" VDEV, lblkno: %d, flags: 0x%lx, npages: %d\n", 1458 (int) bp->b_lblkno, 1459 bp->b_flags, bp->b_npages); 1460 printf(" valid: 0x%x, dirty: 0x%x, wired: %d\n", --- 148 unchanged lines hidden (view full) --- 1609 resid = iocount; 1610 if ((bp->b_flags & B_CLUSTER) == 0) { 1611 obj->paging_in_progress++; 1612 m->busy++; 1613 } 1614 if (clear_modify) { 1615 vm_page_protect(m, VM_PROT_READ); 1616 vm_page_set_validclean(m, | 1451 bp->b_vp->v_mount->mnt_stat.f_iosize, 1452 (int) bp->b_lblkno, 1453 bp->b_flags, bp->b_npages); 1454 else 1455 printf(" VDEV, lblkno: %d, flags: 0x%lx, npages: %d\n", 1456 (int) bp->b_lblkno, 1457 bp->b_flags, bp->b_npages); 1458 printf(" valid: 0x%x, dirty: 0x%x, wired: %d\n", --- 148 unchanged lines hidden (view full) --- 1607 resid = iocount; 1608 if ((bp->b_flags & B_CLUSTER) == 0) { 1609 obj->paging_in_progress++; 1610 m->busy++; 1611 } 1612 if (clear_modify) { 1613 vm_page_protect(m, VM_PROT_READ); 1614 vm_page_set_validclean(m, |
1617 (vm_offset_t) (foff & (PAGE_SIZE-1)), resid); | 1615 (vm_offset_t) (foff & PAGE_MASK), resid); |
1618 } else if (bp->b_bcount >= PAGE_SIZE) { 1619 if (m->valid && (bp->b_flags & B_CACHE) == 0) { 1620 bp->b_pages[i] = bogus_page; 1621 pmap_qenter(trunc_page(bp->b_data), bp->b_pages, bp->b_npages); 1622 } 1623 } 1624 foff += resid; 1625 iocount -= resid; --- 23 unchanged lines hidden (view full) --- 1649 for (i = 0; i < bp->b_npages; i++) { 1650 vm_page_t m = bp->b_pages[i]; 1651 int resid = IDX_TO_OFF(m->pindex + 1) - foff; 1652 1653 if (resid > iocount) 1654 resid = iocount; 1655 if (resid > 0) { 1656 vm_page_set_validclean(m, | 1616 } else if (bp->b_bcount >= PAGE_SIZE) { 1617 if (m->valid && (bp->b_flags & B_CACHE) == 0) { 1618 bp->b_pages[i] = bogus_page; 1619 pmap_qenter(trunc_page(bp->b_data), bp->b_pages, bp->b_npages); 1620 } 1621 } 1622 foff += resid; 1623 iocount -= resid; --- 23 unchanged lines hidden (view full) --- 1647 for (i = 0; i < bp->b_npages; i++) { 1648 vm_page_t m = bp->b_pages[i]; 1649 int resid = IDX_TO_OFF(m->pindex + 1) - foff; 1650 1651 if (resid > iocount) 1652 resid = iocount; 1653 if (resid > 0) { 1654 vm_page_set_validclean(m, |
1657 ((vm_offset_t) foff & (PAGE_SIZE-1)), resid); | 1655 ((vm_offset_t) foff & PAGE_MASK), resid); |
1658 } 1659 foff += resid; 1660 iocount -= resid; 1661 } 1662 } 1663} 1664 1665void --- 100 unchanged lines hidden --- | 1656 } 1657 foff += resid; 1658 iocount -= resid; 1659 } 1660 } 1661} 1662 1663void --- 100 unchanged lines hidden --- |