vfs_bio.c (207534) | vfs_bio.c (207573) |
---|---|
1/*- 2 * Copyright (c) 2004 Poul-Henning Kamp 3 * Copyright (c) 1994,1997 John S. Dyson 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 25 unchanged lines hidden (view full) --- 34 * Author: John S. Dyson 35 * Significant help during the development and debugging phases 36 * had been provided by David Greenman, also of the FreeBSD core team. 37 * 38 * see man buf(9) for more info. 39 */ 40 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004 Poul-Henning Kamp 3 * Copyright (c) 1994,1997 John S. Dyson 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 25 unchanged lines hidden (view full) --- 34 * Author: John S. Dyson 35 * Significant help during the development and debugging phases 36 * had been provided by David Greenman, also of the FreeBSD core team. 37 * 38 * see man buf(9) for more info. 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 207534 2010-05-02 19:10:27Z alc $"); | 42__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 207573 2010-05-03 16:41:11Z alc $"); |
43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/bio.h> 47#include <sys/conf.h> 48#include <sys/buf.h> 49#include <sys/devicestat.h> 50#include <sys/eventhandler.h> --- 2886 unchanged lines hidden (view full) --- 2937 * DEV_BSIZE aligned new buffer size is less then the 2938 * DEV_BSIZE aligned existing buffer size. Figure out 2939 * if we have to remove any pages. 2940 */ 2941 if (desiredpages < bp->b_npages) { 2942 vm_page_t m; 2943 2944 VM_OBJECT_LOCK(bp->b_bufobj->bo_object); | 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/bio.h> 47#include <sys/conf.h> 48#include <sys/buf.h> 49#include <sys/devicestat.h> 50#include <sys/eventhandler.h> --- 2886 unchanged lines hidden (view full) --- 2937 * DEV_BSIZE aligned new buffer size is less then the 2938 * DEV_BSIZE aligned existing buffer size. Figure out 2939 * if we have to remove any pages. 2940 */ 2941 if (desiredpages < bp->b_npages) { 2942 vm_page_t m; 2943 2944 VM_OBJECT_LOCK(bp->b_bufobj->bo_object); |
2945 vm_page_lock_queues(); | |
2946 for (i = desiredpages; i < bp->b_npages; i++) { 2947 /* 2948 * the page is not freed here -- it 2949 * is the responsibility of 2950 * vnode_pager_setsize 2951 */ 2952 m = bp->b_pages[i]; 2953 KASSERT(m != bogus_page, 2954 ("allocbuf: bogus page found")); | 2945 for (i = desiredpages; i < bp->b_npages; i++) { 2946 /* 2947 * the page is not freed here -- it 2948 * is the responsibility of 2949 * vnode_pager_setsize 2950 */ 2951 m = bp->b_pages[i]; 2952 KASSERT(m != bogus_page, 2953 ("allocbuf: bogus page found")); |
2955 while (vm_page_sleep_if_busy(m, TRUE, "biodep")) 2956 vm_page_lock_queues(); | 2954 while (vm_page_sleep_if_busy(m, TRUE, 2955 "biodep")) 2956 continue; |
2957 2958 bp->b_pages[i] = NULL; | 2957 2958 bp->b_pages[i] = NULL; |
2959 vm_page_lock(m); 2960 vm_page_lock_queues(); |
|
2959 vm_page_unwire(m, 0); | 2961 vm_page_unwire(m, 0); |
2962 vm_page_unlock_queues(); 2963 vm_page_unlock(m); |
|
2960 } | 2964 } |
2961 vm_page_unlock_queues(); | |
2962 VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object); 2963 pmap_qremove((vm_offset_t) trunc_page((vm_offset_t)bp->b_data) + 2964 (desiredpages << PAGE_SHIFT), (bp->b_npages - desiredpages)); 2965 bp->b_npages = desiredpages; 2966 } 2967 } else if (size > bp->b_bcount) { 2968 /* 2969 * We are growing the buffer, possibly in a --- 64 unchanged lines hidden (view full) --- 3034 vm_page_flag_set(m, PG_REFERENCED); 3035 vm_page_sleep(m, "pgtblk"); 3036 continue; 3037 } 3038 3039 /* 3040 * We have a good page. 3041 */ | 2965 VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object); 2966 pmap_qremove((vm_offset_t) trunc_page((vm_offset_t)bp->b_data) + 2967 (desiredpages << PAGE_SHIFT), (bp->b_npages - desiredpages)); 2968 bp->b_npages = desiredpages; 2969 } 2970 } else if (size > bp->b_bcount) { 2971 /* 2972 * We are growing the buffer, possibly in a --- 64 unchanged lines hidden (view full) --- 3037 vm_page_flag_set(m, PG_REFERENCED); 3038 vm_page_sleep(m, "pgtblk"); 3039 continue; 3040 } 3041 3042 /* 3043 * We have a good page. 3044 */ |
3045 vm_page_lock(m); |
|
3042 vm_page_lock_queues(); 3043 vm_page_wire(m); 3044 vm_page_unlock_queues(); | 3046 vm_page_lock_queues(); 3047 vm_page_wire(m); 3048 vm_page_unlock_queues(); |
3049 vm_page_unlock(m); |
|
3045 bp->b_pages[bp->b_npages] = m; 3046 ++bp->b_npages; 3047 } 3048 3049 /* 3050 * Step 2. We've loaded the pages into the buffer, 3051 * we have to figure out if we can still have B_CACHE 3052 * set. Note that B_CACHE is set according to the --- 1071 unchanged lines hidden --- | 3050 bp->b_pages[bp->b_npages] = m; 3051 ++bp->b_npages; 3052 } 3053 3054 /* 3055 * Step 2. We've loaded the pages into the buffer, 3056 * we have to figure out if we can still have B_CACHE 3057 * set. Note that B_CACHE is set according to the --- 1071 unchanged lines hidden --- |