vfs_bio.c (122031) | vfs_bio.c (122455) |
---|---|
1/* 2 * Copyright (c) 1994,1997 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 --- 12 unchanged lines hidden (view full) --- 21 * Author: John S. Dyson 22 * Significant help during the development and debugging phases 23 * had been provided by David Greenman, also of the FreeBSD core team. 24 * 25 * see man buf(9) for more info. 26 */ 27 28#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1994,1997 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 --- 12 unchanged lines hidden (view full) --- 21 * Author: John S. Dyson 22 * Significant help during the development and debugging phases 23 * had been provided by David Greenman, also of the FreeBSD core team. 24 * 25 * see man buf(9) for more info. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 122031 2003-11-04 06:30:00Z mckusick $"); | 29__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 122455 2003-11-11 04:45:37Z alc $"); |
30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bio.h> 34#include <sys/conf.h> 35#include <sys/buf.h> 36#include <sys/devicestat.h> 37#include <sys/eventhandler.h> --- 1278 unchanged lines hidden (view full) --- 1316 * block sizes less then DEV_BSIZE (usually 512) are not 1317 * supported due to the page granularity bits (m->valid, 1318 * m->dirty, etc...). 1319 * 1320 * See man buf(9) for more information 1321 */ 1322 resid = bp->b_bufsize; 1323 foff = bp->b_offset; | 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bio.h> 34#include <sys/conf.h> 35#include <sys/buf.h> 36#include <sys/devicestat.h> 37#include <sys/eventhandler.h> --- 1278 unchanged lines hidden (view full) --- 1316 * block sizes less then DEV_BSIZE (usually 512) are not 1317 * supported due to the page granularity bits (m->valid, 1318 * m->dirty, etc...). 1319 * 1320 * See man buf(9) for more information 1321 */ 1322 resid = bp->b_bufsize; 1323 foff = bp->b_offset; |
1324 if (obj != NULL) 1325 VM_OBJECT_LOCK(obj); | 1324 VM_OBJECT_LOCK(obj); |
1326 for (i = 0; i < bp->b_npages; i++) { 1327 int had_bogus = 0; 1328 1329 m = bp->b_pages[i]; 1330 vm_page_lock_queues(); 1331 vm_page_flag_clear(m, PG_ZERO); 1332 vm_page_unlock_queues(); 1333 --- 32 unchanged lines hidden (view full) --- 1366 vm_page_set_invalid(m, poffset, presid); 1367 vm_page_unlock_queues(); 1368 if (had_bogus) 1369 printf("avoided corruption bug in bogus_page/brelse code\n"); 1370 } 1371 resid -= PAGE_SIZE - (foff & PAGE_MASK); 1372 foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; 1373 } | 1325 for (i = 0; i < bp->b_npages; i++) { 1326 int had_bogus = 0; 1327 1328 m = bp->b_pages[i]; 1329 vm_page_lock_queues(); 1330 vm_page_flag_clear(m, PG_ZERO); 1331 vm_page_unlock_queues(); 1332 --- 32 unchanged lines hidden (view full) --- 1365 vm_page_set_invalid(m, poffset, presid); 1366 vm_page_unlock_queues(); 1367 if (had_bogus) 1368 printf("avoided corruption bug in bogus_page/brelse code\n"); 1369 } 1370 resid -= PAGE_SIZE - (foff & PAGE_MASK); 1371 foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; 1372 } |
1374 if (obj != NULL) 1375 VM_OBJECT_UNLOCK(obj); | 1373 VM_OBJECT_UNLOCK(obj); |
1376 if (bp->b_flags & (B_INVAL | B_RELBUF)) 1377 vfs_vmio_release(bp); 1378 1379 } else if (bp->b_flags & B_VMIO) { 1380 1381 if (bp->b_flags & (B_INVAL | B_RELBUF)) { 1382 vfs_vmio_release(bp); 1383 } --- 1779 unchanged lines hidden (view full) --- 3163 panic("biodone: vnode is not setup for merged cache"); 3164 } 3165#endif 3166 3167 foff = bp->b_offset; 3168 KASSERT(bp->b_offset != NOOFFSET, 3169 ("biodone: no buffer offset")); 3170 | 1374 if (bp->b_flags & (B_INVAL | B_RELBUF)) 1375 vfs_vmio_release(bp); 1376 1377 } else if (bp->b_flags & B_VMIO) { 1378 1379 if (bp->b_flags & (B_INVAL | B_RELBUF)) { 1380 vfs_vmio_release(bp); 1381 } --- 1779 unchanged lines hidden (view full) --- 3161 panic("biodone: vnode is not setup for merged cache"); 3162 } 3163#endif 3164 3165 foff = bp->b_offset; 3166 KASSERT(bp->b_offset != NOOFFSET, 3167 ("biodone: no buffer offset")); 3168 |
3171 if (obj != NULL) 3172 VM_OBJECT_LOCK(obj); | 3169 VM_OBJECT_LOCK(obj); |
3173#if defined(VFS_BIO_DEBUG) 3174 if (obj->paging_in_progress < bp->b_npages) { 3175 printf("biodone: paging in progress(%d) < bp->b_npages(%d)\n", 3176 obj->paging_in_progress, bp->b_npages); 3177 } 3178#endif 3179 3180 /* --- 72 unchanged lines hidden (view full) --- 3253 panic("biodone: page busy < 0\n"); 3254 } 3255 vm_page_io_finish(m); 3256 vm_object_pip_subtract(obj, 1); 3257 foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; 3258 iosize -= resid; 3259 } 3260 vm_page_unlock_queues(); | 3170#if defined(VFS_BIO_DEBUG) 3171 if (obj->paging_in_progress < bp->b_npages) { 3172 printf("biodone: paging in progress(%d) < bp->b_npages(%d)\n", 3173 obj->paging_in_progress, bp->b_npages); 3174 } 3175#endif 3176 3177 /* --- 72 unchanged lines hidden (view full) --- 3250 panic("biodone: page busy < 0\n"); 3251 } 3252 vm_page_io_finish(m); 3253 vm_object_pip_subtract(obj, 1); 3254 foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; 3255 iosize -= resid; 3256 } 3257 vm_page_unlock_queues(); |
3261 if (obj != NULL) { 3262 vm_object_pip_wakeupn(obj, 0); 3263 VM_OBJECT_UNLOCK(obj); 3264 } | 3258 vm_object_pip_wakeupn(obj, 0); 3259 VM_OBJECT_UNLOCK(obj); |
3265 } 3266 3267 /* 3268 * For asynchronous completions, release the buffer now. The brelse 3269 * will do a wakeup there if necessary - so no need to do a wakeup 3270 * here in the async case. The sync case always needs to do a wakeup. 3271 */ 3272 --- 107 unchanged lines hidden (view full) --- 3380 vm_object_t obj; 3381 vm_ooffset_t foff; 3382 3383 obj = bp->b_object; 3384 foff = bp->b_offset; 3385 KASSERT(bp->b_offset != NOOFFSET, 3386 ("vfs_busy_pages: no buffer offset")); 3387 vfs_setdirty(bp); | 3260 } 3261 3262 /* 3263 * For asynchronous completions, release the buffer now. The brelse 3264 * will do a wakeup there if necessary - so no need to do a wakeup 3265 * here in the async case. The sync case always needs to do a wakeup. 3266 */ 3267 --- 107 unchanged lines hidden (view full) --- 3375 vm_object_t obj; 3376 vm_ooffset_t foff; 3377 3378 obj = bp->b_object; 3379 foff = bp->b_offset; 3380 KASSERT(bp->b_offset != NOOFFSET, 3381 ("vfs_busy_pages: no buffer offset")); 3382 vfs_setdirty(bp); |
3388 if (obj != NULL) 3389 VM_OBJECT_LOCK(obj); | 3383 VM_OBJECT_LOCK(obj); |
3390retry: 3391 vm_page_lock_queues(); 3392 for (i = 0; i < bp->b_npages; i++) { 3393 vm_page_t m = bp->b_pages[i]; 3394 3395 if (vm_page_sleep_if_busy(m, FALSE, "vbpage")) 3396 goto retry; 3397 } --- 27 unchanged lines hidden (view full) --- 3425 else if (m->valid == VM_PAGE_BITS_ALL && 3426 (bp->b_flags & B_CACHE) == 0) { 3427 bp->b_pages[i] = bogus_page; 3428 bogus++; 3429 } 3430 foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; 3431 } 3432 vm_page_unlock_queues(); | 3384retry: 3385 vm_page_lock_queues(); 3386 for (i = 0; i < bp->b_npages; i++) { 3387 vm_page_t m = bp->b_pages[i]; 3388 3389 if (vm_page_sleep_if_busy(m, FALSE, "vbpage")) 3390 goto retry; 3391 } --- 27 unchanged lines hidden (view full) --- 3419 else if (m->valid == VM_PAGE_BITS_ALL && 3420 (bp->b_flags & B_CACHE) == 0) { 3421 bp->b_pages[i] = bogus_page; 3422 bogus++; 3423 } 3424 foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; 3425 } 3426 vm_page_unlock_queues(); |
3433 if (obj != NULL) 3434 VM_OBJECT_UNLOCK(obj); | 3427 VM_OBJECT_UNLOCK(obj); |
3435 if (bogus) 3436 pmap_qenter(trunc_page((vm_offset_t)bp->b_data), bp->b_pages, bp->b_npages); 3437 } 3438} 3439 3440/* 3441 * Tell the VM system that the pages associated with this buffer 3442 * are clean. This is used for delayed writes where the data is --- 377 unchanged lines hidden --- | 3428 if (bogus) 3429 pmap_qenter(trunc_page((vm_offset_t)bp->b_data), bp->b_pages, bp->b_npages); 3430 } 3431} 3432 3433/* 3434 * Tell the VM system that the pages associated with this buffer 3435 * are clean. This is used for delayed writes where the data is --- 377 unchanged lines hidden --- |