vnode_pager.c (a316d390bda3e185e04632e807a012a345492935) vnode_pager.c (f708ef1b9ebe2f38fc7e454e6594efd5a98a2124)
1/*
2 * Copyright (c) 1990 University of Utah.
3 * Copyright (c) 1991 The Regents of the University of California.
4 * All rights reserved.
5 * Copyright (c) 1993, 1994 John S. Dyson
6 * Copyright (c) 1995, David Greenman
7 *
8 * This code is derived from software contributed to Berkeley by

--- 24 unchanged lines hidden (view full) ---

33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91
1/*
2 * Copyright (c) 1990 University of Utah.
3 * Copyright (c) 1991 The Regents of the University of California.
4 * All rights reserved.
5 * Copyright (c) 1993, 1994 John S. Dyson
6 * Copyright (c) 1995, David Greenman
7 *
8 * This code is derived from software contributed to Berkeley by

--- 24 unchanged lines hidden (view full) ---

33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91
41 * $Id: vnode_pager.c,v 1.54 1995/12/07 12:48:31 davidg Exp $
41 * $Id: vnode_pager.c,v 1.55 1995/12/11 04:58:32 dyson Exp $
42 */
43
44/*
45 * Page to/from files (vnodes).
46 */
47
48/*
49 * TODO:

--- 16 unchanged lines hidden (view full) ---

66#include <vm/vm_param.h>
67#include <vm/vm_prot.h>
68#include <vm/vm_object.h>
69#include <vm/vm_page.h>
70#include <vm/vm_pager.h>
71#include <vm/vnode_pager.h>
72#include <vm/vm_extern.h>
73
42 */
43
44/*
45 * Page to/from files (vnodes).
46 */
47
48/*
49 * TODO:

--- 16 unchanged lines hidden (view full) ---

66#include <vm/vm_param.h>
67#include <vm/vm_prot.h>
68#include <vm/vm_object.h>
69#include <vm/vm_page.h>
70#include <vm/vm_pager.h>
71#include <vm/vnode_pager.h>
72#include <vm/vm_extern.h>
73
74extern vm_offset_t vnode_pager_addr __P((struct vnode *vp, vm_ooffset_t address,
74static vm_offset_t vnode_pager_addr __P((struct vnode *vp, vm_ooffset_t address,
75 int *run));
75 int *run));
76extern void vnode_pager_iodone __P((struct buf *bp));
77extern int vnode_pager_input_smlfs __P((vm_object_t object, vm_page_t m));
78extern int vnode_pager_input_old __P((vm_object_t object, vm_page_t m));
76static void vnode_pager_iodone __P((struct buf *bp));
77static int vnode_pager_input_smlfs __P((vm_object_t object, vm_page_t m));
78static int vnode_pager_input_old __P((vm_object_t object, vm_page_t m));
79static void vnode_pager_dealloc __P((vm_object_t));
80static int vnode_pager_getpages __P((vm_object_t, vm_page_t *, int, int));
81static int vnode_pager_putpages __P((vm_object_t, vm_page_t *, int, boolean_t, int *));
82static boolean_t vnode_pager_haspage __P((vm_object_t, vm_pindex_t, int *, int *));
79
80struct pagerops vnodepagerops = {
81 NULL,
82 vnode_pager_alloc,
83 vnode_pager_dealloc,
84 vnode_pager_getpages,
85 vnode_pager_putpages,
86 vnode_pager_haspage,

--- 75 unchanged lines hidden (view full) ---

162 vp->v_flag &= ~VOLOCK;
163 if (vp->v_flag & VOWANT) {
164 vp->v_flag &= ~VOWANT;
165 wakeup(vp);
166 }
167 return (object);
168}
169
83
84struct pagerops vnodepagerops = {
85 NULL,
86 vnode_pager_alloc,
87 vnode_pager_dealloc,
88 vnode_pager_getpages,
89 vnode_pager_putpages,
90 vnode_pager_haspage,

--- 75 unchanged lines hidden (view full) ---

166 vp->v_flag &= ~VOLOCK;
167 if (vp->v_flag & VOWANT) {
168 vp->v_flag &= ~VOWANT;
169 wakeup(vp);
170 }
171 return (object);
172}
173
170void
174static void
171vnode_pager_dealloc(object)
172 vm_object_t object;
173{
174 register struct vnode *vp = object->handle;
175
176 if (vp == NULL)
177 panic("vnode_pager_dealloc: pager already dealloced");
178

--- 9 unchanged lines hidden (view full) ---

188 object->handle = NULL;
189
190 vp->v_object = NULL;
191 vp->v_flag &= ~(VTEXT | VVMIO);
192 vp->v_flag |= VAGE;
193 vrele(vp);
194}
195
175vnode_pager_dealloc(object)
176 vm_object_t object;
177{
178 register struct vnode *vp = object->handle;
179
180 if (vp == NULL)
181 panic("vnode_pager_dealloc: pager already dealloced");
182

--- 9 unchanged lines hidden (view full) ---

192 object->handle = NULL;
193
194 vp->v_object = NULL;
195 vp->v_flag &= ~(VTEXT | VVMIO);
196 vp->v_flag |= VAGE;
197 vrele(vp);
198}
199
196boolean_t
200static boolean_t
197vnode_pager_haspage(object, pindex, before, after)
198 vm_object_t object;
199 vm_pindex_t pindex;
200 int *before;
201 int *after;
202{
203 struct vnode *vp = object->handle;
204 daddr_t bn;

--- 160 unchanged lines hidden (view full) ---

365 PAGE_WAKEUP(m);
366 vm_page_free(m);
367}
368
369/*
370 * calculate the linear (byte) disk address of specified virtual
371 * file address
372 */
201vnode_pager_haspage(object, pindex, before, after)
202 vm_object_t object;
203 vm_pindex_t pindex;
204 int *before;
205 int *after;
206{
207 struct vnode *vp = object->handle;
208 daddr_t bn;

--- 160 unchanged lines hidden (view full) ---

369 PAGE_WAKEUP(m);
370 vm_page_free(m);
371}
372
373/*
374 * calculate the linear (byte) disk address of specified virtual
375 * file address
376 */
373vm_offset_t
377static vm_offset_t
374vnode_pager_addr(vp, address, run)
375 struct vnode *vp;
376 vm_ooffset_t address;
377 int *run;
378{
379 int rtaddress;
380 int bsize;
381 daddr_t block;

--- 26 unchanged lines hidden (view full) ---

408 }
409
410 return rtaddress;
411}
412
413/*
414 * interrupt routine for I/O completion
415 */
378vnode_pager_addr(vp, address, run)
379 struct vnode *vp;
380 vm_ooffset_t address;
381 int *run;
382{
383 int rtaddress;
384 int bsize;
385 daddr_t block;

--- 26 unchanged lines hidden (view full) ---

412 }
413
414 return rtaddress;
415}
416
417/*
418 * interrupt routine for I/O completion
419 */
416void
420static void
417vnode_pager_iodone(bp)
418 struct buf *bp;
419{
420 bp->b_flags |= B_DONE;
421 wakeup(bp);
422}
423
424/*
425 * small block file system vnode pager input
426 */
421vnode_pager_iodone(bp)
422 struct buf *bp;
423{
424 bp->b_flags |= B_DONE;
425 wakeup(bp);
426}
427
428/*
429 * small block file system vnode pager input
430 */
427int
431static int
428vnode_pager_input_smlfs(object, m)
429 vm_object_t object;
430 vm_page_t m;
431{
432 int i;
433 int s;
434 struct vnode *dp, *vp;
435 struct buf *bp;

--- 73 unchanged lines hidden (view full) ---

509 return VM_PAGER_OK;
510
511}
512
513
514/*
515 * old style vnode pager output routine
516 */
432vnode_pager_input_smlfs(object, m)
433 vm_object_t object;
434 vm_page_t m;
435{
436 int i;
437 int s;
438 struct vnode *dp, *vp;
439 struct buf *bp;

--- 73 unchanged lines hidden (view full) ---

513 return VM_PAGER_OK;
514
515}
516
517
518/*
519 * old style vnode pager output routine
520 */
517int
521static int
518vnode_pager_input_old(object, m)
519 vm_object_t object;
520 vm_page_t m;
521{
522 struct uio auio;
523 struct iovec aiov;
524 int error;
525 int size;

--- 43 unchanged lines hidden (view full) ---

569 m->flags &= ~PG_ZERO;
570 return error ? VM_PAGER_ERROR : VM_PAGER_OK;
571}
572
573/*
574 * generic vnode pager input routine
575 */
576
522vnode_pager_input_old(object, m)
523 vm_object_t object;
524 vm_page_t m;
525{
526 struct uio auio;
527 struct iovec aiov;
528 int error;
529 int size;

--- 43 unchanged lines hidden (view full) ---

573 m->flags &= ~PG_ZERO;
574 return error ? VM_PAGER_ERROR : VM_PAGER_OK;
575}
576
577/*
578 * generic vnode pager input routine
579 */
580
577int
581static int
578vnode_pager_getpages(object, m, count, reqpage)
579 vm_object_t object;
580 vm_page_t *m;
581 int count;
582 int reqpage;
583{
584 int rtval;
585 struct vnode *vp;

--- 225 unchanged lines hidden (view full) ---

811 }
812 }
813 if (error) {
814 printf("vnode_pager_getpages: I/O read error\n");
815 }
816 return (error ? VM_PAGER_ERROR : VM_PAGER_OK);
817}
818
582vnode_pager_getpages(object, m, count, reqpage)
583 vm_object_t object;
584 vm_page_t *m;
585 int count;
586 int reqpage;
587{
588 int rtval;
589 struct vnode *vp;

--- 225 unchanged lines hidden (view full) ---

815 }
816 }
817 if (error) {
818 printf("vnode_pager_getpages: I/O read error\n");
819 }
820 return (error ? VM_PAGER_ERROR : VM_PAGER_OK);
821}
822
819int
823static int
820vnode_pager_putpages(object, m, count, sync, rtvals)
821 vm_object_t object;
822 vm_page_t *m;
823 int count;
824 boolean_t sync;
825 int *rtvals;
826{
827 int rtval;

--- 78 unchanged lines hidden (view full) ---

906 error = VOP_WRITE(vp, &auio, IO_VMIO|(sync?IO_SYNC:0), curproc->p_ucred);
907 cnt.v_vnodeout++;
908 cnt.v_vnodepgsout += ncount;
909
910 if (error) {
911 printf("vnode_pager_putpages: I/O error %d\n", error);
912 }
913 if (auio.uio_resid) {
824vnode_pager_putpages(object, m, count, sync, rtvals)
825 vm_object_t object;
826 vm_page_t *m;
827 int count;
828 boolean_t sync;
829 int *rtvals;
830{
831 int rtval;

--- 78 unchanged lines hidden (view full) ---

910 error = VOP_WRITE(vp, &auio, IO_VMIO|(sync?IO_SYNC:0), curproc->p_ucred);
911 cnt.v_vnodeout++;
912 cnt.v_vnodepgsout += ncount;
913
914 if (error) {
915 printf("vnode_pager_putpages: I/O error %d\n", error);
916 }
917 if (auio.uio_resid) {
914 printf("vnode_pager_putpages: residual I/O %d at %d\n",
918 printf("vnode_pager_putpages: residual I/O %d at %ld\n",
915 auio.uio_resid, m[0]->pindex);
916 }
917 for (i = 0; i < count; i++) {
918 m[i]->busy--;
919 if (i < ncount) {
920 rtvals[i] = VM_PAGER_OK;
921 }
922 if ((m[i]->busy == 0) && (m[i]->flags & PG_WANTED))

--- 18 unchanged lines hidden ---
919 auio.uio_resid, m[0]->pindex);
920 }
921 for (i = 0; i < count; i++) {
922 m[i]->busy--;
923 if (i < ncount) {
924 rtvals[i] = VM_PAGER_OK;
925 }
926 if ((m[i]->busy == 0) && (m[i]->flags & PG_WANTED))

--- 18 unchanged lines hidden ---