vfs_bio.c (120328) | vfs_bio.c (120762) |
---|---|
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 120328 2003-09-22 04:58:09Z alc $"); | 29__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 120762 2003-10-04 19:23:29Z alc $"); |
30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bio.h> 34#include <sys/buf.h> 35#include <sys/devicestat.h> 36#include <sys/eventhandler.h> 37#include <sys/lock.h> --- 337 unchanged lines hidden (view full) --- 375static __inline__ 376void 377vfs_buf_test_cache(struct buf *bp, 378 vm_ooffset_t foff, vm_offset_t off, vm_offset_t size, 379 vm_page_t m) 380{ 381 GIANT_REQUIRED; 382 | 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bio.h> 34#include <sys/buf.h> 35#include <sys/devicestat.h> 36#include <sys/eventhandler.h> 37#include <sys/lock.h> --- 337 unchanged lines hidden (view full) --- 375static __inline__ 376void 377vfs_buf_test_cache(struct buf *bp, 378 vm_ooffset_t foff, vm_offset_t off, vm_offset_t size, 379 vm_page_t m) 380{ 381 GIANT_REQUIRED; 382 |
383 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); |
|
383 if (bp->b_flags & B_CACHE) { 384 int base = (foff + off) & PAGE_MASK; 385 if (vm_page_is_valid(m, base, size) == 0) 386 bp->b_flags &= ~B_CACHE; 387 } 388} 389 390/* Wake up the buffer deamon if necessary */ --- 1839 unchanged lines hidden (view full) --- 2230 if (VOP_GETVOBJECT(vp, &obj) != 0 || (vp->v_vflag & VV_OBJBUF) == 0) 2231 return 0; 2232 2233 size = PAGE_SIZE; 2234 if (size > vp->v_mount->mnt_stat.f_iosize) 2235 size = vp->v_mount->mnt_stat.f_iosize; 2236 off = (vm_ooffset_t)blkno * (vm_ooffset_t)vp->v_mount->mnt_stat.f_iosize; 2237 | 384 if (bp->b_flags & B_CACHE) { 385 int base = (foff + off) & PAGE_MASK; 386 if (vm_page_is_valid(m, base, size) == 0) 387 bp->b_flags &= ~B_CACHE; 388 } 389} 390 391/* Wake up the buffer deamon if necessary */ --- 1839 unchanged lines hidden (view full) --- 2231 if (VOP_GETVOBJECT(vp, &obj) != 0 || (vp->v_vflag & VV_OBJBUF) == 0) 2232 return 0; 2233 2234 size = PAGE_SIZE; 2235 if (size > vp->v_mount->mnt_stat.f_iosize) 2236 size = vp->v_mount->mnt_stat.f_iosize; 2237 off = (vm_ooffset_t)blkno * (vm_ooffset_t)vp->v_mount->mnt_stat.f_iosize; 2238 |
2239 VM_OBJECT_LOCK(obj); |
|
2238 for (toff = 0; toff < vp->v_mount->mnt_stat.f_iosize; toff += tinc) { | 2240 for (toff = 0; toff < vp->v_mount->mnt_stat.f_iosize; toff += tinc) { |
2239 VM_OBJECT_LOCK(obj); | |
2240 m = vm_page_lookup(obj, OFF_TO_IDX(off + toff)); | 2241 m = vm_page_lookup(obj, OFF_TO_IDX(off + toff)); |
2241 VM_OBJECT_UNLOCK(obj); | |
2242 if (!m) 2243 goto notinmem; 2244 tinc = size; 2245 if (tinc > PAGE_SIZE - ((toff + off) & PAGE_MASK)) 2246 tinc = PAGE_SIZE - ((toff + off) & PAGE_MASK); 2247 if (vm_page_is_valid(m, 2248 (vm_offset_t) ((toff + off) & PAGE_MASK), tinc) == 0) 2249 goto notinmem; 2250 } | 2242 if (!m) 2243 goto notinmem; 2244 tinc = size; 2245 if (tinc > PAGE_SIZE - ((toff + off) & PAGE_MASK)) 2246 tinc = PAGE_SIZE - ((toff + off) & PAGE_MASK); 2247 if (vm_page_is_valid(m, 2248 (vm_offset_t) ((toff + off) & PAGE_MASK), tinc) == 0) 2249 goto notinmem; 2250 } |
2251 VM_OBJECT_UNLOCK(obj); |
|
2251 return 1; 2252 2253notinmem: | 2252 return 1; 2253 2254notinmem: |
2255 VM_OBJECT_UNLOCK(obj); |
|
2254 return (0); 2255} 2256 2257/* 2258 * vfs_setdirty: 2259 * 2260 * Sets the dirty range for a buffer based on the status of the dirty 2261 * bits in the pages comprising the buffer. --- 635 unchanged lines hidden (view full) --- 2897 pagedaemon_wakeup(); 2898 } 2899 vm_page_flag_clear(m, PG_ZERO); 2900 vm_page_wire(m); 2901 vm_page_unlock_queues(); 2902 bp->b_pages[bp->b_npages] = m; 2903 ++bp->b_npages; 2904 } | 2256 return (0); 2257} 2258 2259/* 2260 * vfs_setdirty: 2261 * 2262 * Sets the dirty range for a buffer based on the status of the dirty 2263 * bits in the pages comprising the buffer. --- 635 unchanged lines hidden (view full) --- 2899 pagedaemon_wakeup(); 2900 } 2901 vm_page_flag_clear(m, PG_ZERO); 2902 vm_page_wire(m); 2903 vm_page_unlock_queues(); 2904 bp->b_pages[bp->b_npages] = m; 2905 ++bp->b_npages; 2906 } |
2905 VM_OBJECT_UNLOCK(obj); | |
2906 2907 /* 2908 * Step 2. We've loaded the pages into the buffer, 2909 * we have to figure out if we can still have B_CACHE 2910 * set. Note that B_CACHE is set according to the 2911 * byte-granular range ( bcount and size ), new the 2912 * aligned range ( newbsize ). 2913 * --- 22 unchanged lines hidden (view full) --- 2936 bp->b_offset, 2937 toff, 2938 tinc, 2939 bp->b_pages[pi] 2940 ); 2941 toff += tinc; 2942 tinc = PAGE_SIZE; 2943 } | 2907 2908 /* 2909 * Step 2. We've loaded the pages into the buffer, 2910 * we have to figure out if we can still have B_CACHE 2911 * set. Note that B_CACHE is set according to the 2912 * byte-granular range ( bcount and size ), new the 2913 * aligned range ( newbsize ). 2914 * --- 22 unchanged lines hidden (view full) --- 2937 bp->b_offset, 2938 toff, 2939 tinc, 2940 bp->b_pages[pi] 2941 ); 2942 toff += tinc; 2943 tinc = PAGE_SIZE; 2944 } |
2945 VM_OBJECT_UNLOCK(obj); |
|
2944 2945 /* 2946 * Step 3, fixup the KVM pmap. Remember that 2947 * bp->b_data is relative to bp->b_offset, but 2948 * bp->b_offset may be offset into the first page. 2949 */ 2950 2951 bp->b_data = (caddr_t) --- 838 unchanged lines hidden --- | 2946 2947 /* 2948 * Step 3, fixup the KVM pmap. Remember that 2949 * bp->b_data is relative to bp->b_offset, but 2950 * bp->b_offset may be offset into the first page. 2951 */ 2952 2953 bp->b_data = (caddr_t) --- 838 unchanged lines hidden --- |