vnode_pager.c (f993ed2fbd3c307200ed9a6351e649f0904b39c5) | vnode_pager.c (0012f373e43db2341c20329163ed2d5ad3b0f341) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1991 The Regents of the University of California. 6 * All rights reserved. 7 * Copyright (c) 1993, 1994 John S. Dyson 8 * Copyright (c) 1995, David Greenman --- 457 unchanged lines hidden (view full) --- 466 /* 467 * this gets rid of garbage at the end of a page that is now 468 * only partially backed by the vnode. 469 * 470 * XXX for some reason (I don't know yet), if we take a 471 * completely invalid page and mark it partially valid 472 * it can screw up NFS reads, so we don't allow the case. 473 */ | 1/*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1991 The Regents of the University of California. 6 * All rights reserved. 7 * Copyright (c) 1993, 1994 John S. Dyson 8 * Copyright (c) 1995, David Greenman --- 457 unchanged lines hidden (view full) --- 466 /* 467 * this gets rid of garbage at the end of a page that is now 468 * only partially backed by the vnode. 469 * 470 * XXX for some reason (I don't know yet), if we take a 471 * completely invalid page and mark it partially valid 472 * it can screw up NFS reads, so we don't allow the case. 473 */ |
474 if ((nsize & PAGE_MASK) && 475 (m = vm_page_lookup(object, OFF_TO_IDX(nsize))) != NULL && 476 m->valid != 0) { | 474 if (!(nsize & PAGE_MASK)) 475 goto out; 476 m = vm_page_grab(object, OFF_TO_IDX(nsize), VM_ALLOC_NOCREAT); 477 if (m == NULL) 478 goto out; 479 if (!vm_page_none_valid(m)) { |
477 int base = (int)nsize & PAGE_MASK; 478 int size = PAGE_SIZE - base; 479 480 /* 481 * Clear out partial-page garbage in case 482 * the page has been mapped. 483 */ 484 pmap_zero_page_area(m, base, size); --- 16 unchanged lines hidden (view full) --- 501 * Clear out partial-page dirty bits. 502 * 503 * note that we do not clear out the valid 504 * bits. This would prevent bogus_page 505 * replacement from working properly. 506 */ 507 vm_page_clear_dirty(m, base, PAGE_SIZE - base); 508 } | 480 int base = (int)nsize & PAGE_MASK; 481 int size = PAGE_SIZE - base; 482 483 /* 484 * Clear out partial-page garbage in case 485 * the page has been mapped. 486 */ 487 pmap_zero_page_area(m, base, size); --- 16 unchanged lines hidden (view full) --- 504 * Clear out partial-page dirty bits. 505 * 506 * note that we do not clear out the valid 507 * bits. This would prevent bogus_page 508 * replacement from working properly. 509 */ 510 vm_page_clear_dirty(m, base, PAGE_SIZE - base); 511 } |
512 vm_page_xunbusy(m); |
|
509 } | 513 } |
514out: |
|
510 object->un_pager.vnp.vnp_size = nsize; 511 object->size = nobjsize; 512 VM_OBJECT_WUNLOCK(object); 513} 514 515/* 516 * calculate the linear (byte) disk address of specified virtual 517 * file address --- 178 unchanged lines hidden (view full) --- 696 PAGE_SIZE - count); 697 } 698 sf_buf_free(sf); 699 700 VM_OBJECT_WLOCK(object); 701 } 702 KASSERT(m->dirty == 0, ("vnode_pager_input_old: page %p is dirty", m)); 703 if (!error) | 515 object->un_pager.vnp.vnp_size = nsize; 516 object->size = nobjsize; 517 VM_OBJECT_WUNLOCK(object); 518} 519 520/* 521 * calculate the linear (byte) disk address of specified virtual 522 * file address --- 178 unchanged lines hidden (view full) --- 701 PAGE_SIZE - count); 702 } 703 sf_buf_free(sf); 704 705 VM_OBJECT_WLOCK(object); 706 } 707 KASSERT(m->dirty == 0, ("vnode_pager_input_old: page %p is dirty", m)); 708 if (!error) |
704 m->valid = VM_PAGE_BITS_ALL; | 709 vm_page_valid(m); |
705 return error ? VM_PAGER_ERROR : VM_PAGER_OK; 706} 707 708/* 709 * generic vnode pager input routine 710 */ 711 712/* --- 92 unchanged lines hidden (view full) --- 805 KASSERT(count <= nitems(bp->b_pages), 806 ("%s: requested %d pages", __func__, count)); 807 808 /* 809 * The last page has valid blocks. Invalid part can only 810 * exist at the end of file, and the page is made fully valid 811 * by zeroing in vm_pager_get_pages(). 812 */ | 710 return error ? VM_PAGER_ERROR : VM_PAGER_OK; 711} 712 713/* 714 * generic vnode pager input routine 715 */ 716 717/* --- 92 unchanged lines hidden (view full) --- 810 KASSERT(count <= nitems(bp->b_pages), 811 ("%s: requested %d pages", __func__, count)); 812 813 /* 814 * The last page has valid blocks. Invalid part can only 815 * exist at the end of file, and the page is made fully valid 816 * by zeroing in vm_pager_get_pages(). 817 */ |
813 if (m[count - 1]->valid != 0 && --count == 0) { | 818 if (!vm_page_none_valid(m[count - 1]) && --count == 0) { |
814 if (iodone != NULL) 815 iodone(arg, m, 1, 0); 816 return (VM_PAGER_OK); 817 } 818 819 bp = uma_zalloc(vnode_pbuf_zone, M_WAITOK); 820 821 /* --- 43 unchanged lines hidden (view full) --- 865 KASSERT(count == 1, 866 ("%s: array[%d] request to a sparse file %p", __func__, 867 count, vp)); 868 uma_zfree(vnode_pbuf_zone, bp); 869 pmap_zero_page(m[0]); 870 KASSERT(m[0]->dirty == 0, ("%s: page %p is dirty", 871 __func__, m[0])); 872 VM_OBJECT_WLOCK(object); | 819 if (iodone != NULL) 820 iodone(arg, m, 1, 0); 821 return (VM_PAGER_OK); 822 } 823 824 bp = uma_zalloc(vnode_pbuf_zone, M_WAITOK); 825 826 /* --- 43 unchanged lines hidden (view full) --- 870 KASSERT(count == 1, 871 ("%s: array[%d] request to a sparse file %p", __func__, 872 count, vp)); 873 uma_zfree(vnode_pbuf_zone, bp); 874 pmap_zero_page(m[0]); 875 KASSERT(m[0]->dirty == 0, ("%s: page %p is dirty", 876 __func__, m[0])); 877 VM_OBJECT_WLOCK(object); |
873 m[0]->valid = VM_PAGE_BITS_ALL; | 878 vm_page_valid(m[0]); |
874 VM_OBJECT_WUNLOCK(object); 875 return (VM_PAGER_OK); 876 } 877 878#ifdef INVARIANTS 879 blkno0 = bp->b_blkno; 880#endif 881 bp->b_blkno += (foff % bsize) / DEV_BSIZE; --- 249 unchanged lines hidden (view full) --- 1131 1132 nextoff = tfoff + PAGE_SIZE; 1133 mt = bp->b_pages[i]; 1134 1135 if (nextoff <= object->un_pager.vnp.vnp_size) { 1136 /* 1137 * Read filled up entire page. 1138 */ | 879 VM_OBJECT_WUNLOCK(object); 880 return (VM_PAGER_OK); 881 } 882 883#ifdef INVARIANTS 884 blkno0 = bp->b_blkno; 885#endif 886 bp->b_blkno += (foff % bsize) / DEV_BSIZE; --- 249 unchanged lines hidden (view full) --- 1136 1137 nextoff = tfoff + PAGE_SIZE; 1138 mt = bp->b_pages[i]; 1139 1140 if (nextoff <= object->un_pager.vnp.vnp_size) { 1141 /* 1142 * Read filled up entire page. 1143 */ |
1139 mt->valid = VM_PAGE_BITS_ALL; | 1144 vm_page_valid(mt); |
1140 KASSERT(mt->dirty == 0, 1141 ("%s: page %p is dirty", __func__, mt)); 1142 KASSERT(!pmap_page_is_mapped(mt), 1143 ("%s: page %p is mapped", __func__, mt)); 1144 } else { 1145 /* 1146 * Read did not fill up entire page. 1147 * --- 439 unchanged lines hidden --- | 1145 KASSERT(mt->dirty == 0, 1146 ("%s: page %p is dirty", __func__, mt)); 1147 KASSERT(!pmap_page_is_mapped(mt), 1148 ("%s: page %p is mapped", __func__, mt)); 1149 } else { 1150 /* 1151 * Read did not fill up entire page. 1152 * --- 439 unchanged lines hidden --- |