vfs_bio.c (7090) | vfs_bio.c (7399) |
---|---|
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.35 1995/03/07 19:53:27 davidg Exp $ | 21 * $Id: vfs_bio.c,v 1.36 1995/03/16 18:12:47 bde 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 * --- 404 unchanged lines hidden (view full) --- 434 m = bp->b_pages[i]; 435 --m->bmapped; 436 if (m->bmapped == 0) { 437 PAGE_WAKEUP(m); 438 if (m->valid == 0) { 439 vm_page_protect(m, VM_PROT_NONE); 440 vm_page_free(m); 441 } | 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 * --- 404 unchanged lines hidden (view full) --- 434 m = bp->b_pages[i]; 435 --m->bmapped; 436 if (m->bmapped == 0) { 437 PAGE_WAKEUP(m); 438 if (m->valid == 0) { 439 vm_page_protect(m, VM_PROT_NONE); 440 vm_page_free(m); 441 } |
442#if 1 | |
443 else if ((m->dirty & m->valid) == 0 && 444 (m->flags & PG_REFERENCED) == 0 && 445 !pmap_is_referenced(VM_PAGE_TO_PHYS(m))) 446 vm_page_cache(m); | 442 else if ((m->dirty & m->valid) == 0 && 443 (m->flags & PG_REFERENCED) == 0 && 444 !pmap_is_referenced(VM_PAGE_TO_PHYS(m))) 445 vm_page_cache(m); |
447#endif | |
448 else if ((m->flags & PG_ACTIVE) == 0) { 449 vm_page_activate(m); 450 m->act_count = 0; 451 } 452 } 453 } 454 bufspace -= bp->b_bufsize; 455 pmap_qremove(trunc_page((vm_offset_t) bp->b_data), bp->b_npages); --- 167 unchanged lines hidden (view full) --- 623 if (bp->b_wcred != NOCRED) 624 crfree(bp->b_wcred); 625fillbuf: 626 bp->b_flags |= B_BUSY; 627 LIST_REMOVE(bp, b_hash); 628 LIST_INSERT_HEAD(&invalhash, bp, b_hash); 629 splx(s); 630 if (bp->b_bufsize) { | 446 else if ((m->flags & PG_ACTIVE) == 0) { 447 vm_page_activate(m); 448 m->act_count = 0; 449 } 450 } 451 } 452 bufspace -= bp->b_bufsize; 453 pmap_qremove(trunc_page((vm_offset_t) bp->b_data), bp->b_npages); --- 167 unchanged lines hidden (view full) --- 621 if (bp->b_wcred != NOCRED) 622 crfree(bp->b_wcred); 623fillbuf: 624 bp->b_flags |= B_BUSY; 625 LIST_REMOVE(bp, b_hash); 626 LIST_INSERT_HEAD(&invalhash, bp, b_hash); 627 splx(s); 628 if (bp->b_bufsize) { |
631 allocbuf(bp, 0, 0); | 629 allocbuf(bp, 0); |
632 } 633 bp->b_flags = B_BUSY; 634 bp->b_dev = NODEV; 635 bp->b_vp = NULL; 636 bp->b_blkno = bp->b_lblkno = 0; 637 bp->b_iodone = 0; 638 bp->b_error = 0; 639 bp->b_resid = 0; --- 164 unchanged lines hidden (view full) --- 804 if (vp->v_type != VREG) 805 printf("getblk: vmioing file type %d???\n", vp->v_type); 806#endif 807 } else { 808 bp->b_flags &= ~B_VMIO; 809 } 810 splx(s); 811 | 630 } 631 bp->b_flags = B_BUSY; 632 bp->b_dev = NODEV; 633 bp->b_vp = NULL; 634 bp->b_blkno = bp->b_lblkno = 0; 635 bp->b_iodone = 0; 636 bp->b_error = 0; 637 bp->b_resid = 0; --- 164 unchanged lines hidden (view full) --- 802 if (vp->v_type != VREG) 803 printf("getblk: vmioing file type %d???\n", vp->v_type); 804#endif 805 } else { 806 bp->b_flags &= ~B_VMIO; 807 } 808 splx(s); 809 |
812 if (!allocbuf(bp, size, 1)) { | 810 if (!allocbuf(bp, size)) { |
813 s = splbio(); 814 goto loop; 815 } 816 return (bp); 817 } 818} 819 820/* 821 * Get an empty, disassociated buffer of given size. 822 */ 823struct buf * 824geteblk(int size) 825{ 826 struct buf *bp; 827 828 while ((bp = getnewbuf(0, 0, 0)) == 0); | 811 s = splbio(); 812 goto loop; 813 } 814 return (bp); 815 } 816} 817 818/* 819 * Get an empty, disassociated buffer of given size. 820 */ 821struct buf * 822geteblk(int size) 823{ 824 struct buf *bp; 825 826 while ((bp = getnewbuf(0, 0, 0)) == 0); |
829 allocbuf(bp, size, 0); | 827 allocbuf(bp, size); |
830 bp->b_flags |= B_INVAL; 831 return (bp); 832} 833 834/* 835 * This code constitutes the buffer memory from either anonymous system 836 * memory (in the case of non-VMIO operations) or from an associated 837 * VM object (in the case of VMIO operations). 838 * 839 * Note that this code is tricky, and has many complications to resolve 840 * deadlock or inconsistant data situations. Tread lightly!!! 841 * 842 * Modify the length of a buffer's underlying buffer storage without 843 * destroying information (unless, of course the buffer is shrinking). 844 */ 845int | 828 bp->b_flags |= B_INVAL; 829 return (bp); 830} 831 832/* 833 * This code constitutes the buffer memory from either anonymous system 834 * memory (in the case of non-VMIO operations) or from an associated 835 * VM object (in the case of VMIO operations). 836 * 837 * Note that this code is tricky, and has many complications to resolve 838 * deadlock or inconsistant data situations. Tread lightly!!! 839 * 840 * Modify the length of a buffer's underlying buffer storage without 841 * destroying information (unless, of course the buffer is shrinking). 842 */ 843int |
846allocbuf(struct buf * bp, int size, int vmio) | 844allocbuf(struct buf * bp, int size) |
847{ 848 849 int s; 850 int newbsize, mbsize; 851 int i; | 845{ 846 847 int s; 848 int newbsize, mbsize; 849 int i; |
850 int vmio = (bp->b_flags & B_VMIO) != 0; |
|
852 | 851 |
853 if ((bp->b_flags & B_VMIO) == 0) { | 852 if (!vmio) { |
854 /* 855 * Just get anonymous memory from the kernel 856 */ 857 mbsize = ((size + DEV_BSIZE - 1) / DEV_BSIZE) * DEV_BSIZE; 858 newbsize = round_page(size); 859 860 if (newbsize == bp->b_bufsize) { 861 bp->b_bcount = size; --- 563 unchanged lines hidden --- | 853 /* 854 * Just get anonymous memory from the kernel 855 */ 856 mbsize = ((size + DEV_BSIZE - 1) / DEV_BSIZE) * DEV_BSIZE; 857 newbsize = round_page(size); 858 859 if (newbsize == bp->b_bufsize) { 860 bp->b_bcount = size; --- 563 unchanged lines hidden --- |