Deleted Added
full compact
vm_pager.c (43129) vm_pager.c (44739)
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
64 * $Id: vm_pager.c,v 1.42 1999/01/21 10:15:24 dillon Exp $
64 * $Id: vm_pager.c,v 1.43 1999/01/24 02:32:15 dillon Exp $
65 */
66
67/*
68 * Paging space routine stubs. Emulates a matchmaker-like interface
69 * for builtin pagers.
70 */
71
72#include <sys/param.h>
73#include <sys/systm.h>
74#include <sys/kernel.h>
65 */
66
67/*
68 * Paging space routine stubs. Emulates a matchmaker-like interface
69 * for builtin pagers.
70 */
71
72#include <sys/param.h>
73#include <sys/systm.h>
74#include <sys/kernel.h>
75#include <sys/vnode.h>
75#include <sys/buf.h>
76#include <sys/ucred.h>
77#include <sys/malloc.h>
76#include <sys/buf.h>
77#include <sys/ucred.h>
78#include <sys/malloc.h>
79#include <sys/proc.h>
78
79#include <vm/vm.h>
80#include <vm/vm_param.h>
81#include <vm/vm_prot.h>
82#include <vm/vm_object.h>
83#include <vm/vm_page.h>
84#include <vm/vm_pager.h>
85#include <vm/vm_extern.h>

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

247void
248vm_pager_deallocate(object)
249 vm_object_t object;
250{
251 (*pagertab[object->type]->pgo_dealloc) (object);
252}
253
254/*
80
81#include <vm/vm.h>
82#include <vm/vm_param.h>
83#include <vm/vm_prot.h>
84#include <vm/vm_object.h>
85#include <vm/vm_page.h>
86#include <vm/vm_pager.h>
87#include <vm/vm_extern.h>

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

249void
250vm_pager_deallocate(object)
251 vm_object_t object;
252{
253 (*pagertab[object->type]->pgo_dealloc) (object);
254}
255
256/*
257 * vm_pager_strategy:
258 *
259 * called with no specific spl
260 * Execute strategy routine directly to pager.
261 */
262
263void
264vm_pager_strategy(vm_object_t object, struct buf *bp)
265{
266 if (pagertab[object->type]->pgo_strategy) {
267 (*pagertab[object->type]->pgo_strategy)(object, bp);
268 } else {
269 bp->b_flags |= B_ERROR;
270 bp->b_error = ENXIO;
271 biodone(bp);
272 }
273}
274
275/*
255 * vm_pager_get_pages() - inline, see vm/vm_pager.h
256 * vm_pager_put_pages() - inline, see vm/vm_pager.h
257 * vm_pager_has_page() - inline, see vm/vm_pager.h
258 * vm_pager_page_inserted() - inline, see vm/vm_pager.h
259 * vm_pager_page_removed() - inline, see vm/vm_pager.h
260 */
261
262#if 0

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

437 wakeup(&bswneeded);
438 }
439 if (pfreecnt) {
440 if (++*pfreecnt == 1)
441 wakeup(pfreecnt);
442 }
443 splx(s);
444}
276 * vm_pager_get_pages() - inline, see vm/vm_pager.h
277 * vm_pager_put_pages() - inline, see vm/vm_pager.h
278 * vm_pager_has_page() - inline, see vm/vm_pager.h
279 * vm_pager_page_inserted() - inline, see vm/vm_pager.h
280 * vm_pager_page_removed() - inline, see vm/vm_pager.h
281 */
282
283#if 0

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

458 wakeup(&bswneeded);
459 }
460 if (pfreecnt) {
461 if (++*pfreecnt == 1)
462 wakeup(pfreecnt);
463 }
464 splx(s);
465}
466
467/********************************************************
468 * CHAINING FUNCTIONS *
469 ********************************************************
470 *
471 * These functions support recursion of I/O operations
472 * on bp's, typically by chaining one or more 'child' bp's
473 * to the parent. Synchronous, asynchronous, and semi-synchronous
474 * chaining is possible.
475 */
476
477/*
478 * vm_pager_chain_iodone:
479 *
480 * io completion routine for child bp. Currently we fudge a bit
481 * on dealing with b_resid. Since users of these routines may issue
482 * multiple children simultaniously, sequencing of the error can be lost.
483 */
484
485static void
486vm_pager_chain_iodone(struct buf *nbp)
487{
488 struct buf *bp;
489
490 if ((bp = nbp->b_chain.parent) != NULL) {
491 if (nbp->b_flags & B_ERROR) {
492 bp->b_flags |= B_ERROR;
493 bp->b_error = nbp->b_error;
494 } else if (nbp->b_resid != 0) {
495 bp->b_flags |= B_ERROR;
496 bp->b_error = EINVAL;
497 } else {
498 bp->b_resid -= nbp->b_bcount;
499 }
500 nbp->b_chain.parent = NULL;
501 --bp->b_chain.count;
502 if (bp->b_flags & B_WANTED) {
503 bp->b_flags &= ~B_WANTED;
504 wakeup(bp);
505 }
506 if (!bp->b_chain.count && (bp->b_flags & B_AUTOCHAINDONE)) {
507 bp->b_flags &= ~B_AUTOCHAINDONE;
508 if (bp->b_resid != 0 && !(bp->b_flags & B_ERROR)) {
509 bp->b_flags |= B_ERROR;
510 bp->b_error = EINVAL;
511 }
512 biodone(bp);
513 }
514 }
515 nbp->b_flags |= B_DONE;
516 nbp->b_flags &= ~(B_ASYNC|B_WANTED);
517 relpbuf(nbp, NULL);
518}
519
520/*
521 * getchainbuf:
522 *
523 * Obtain a physical buffer and chain it to its parent buffer. When
524 * I/O completes, the parent buffer will be B_SIGNAL'd. Errors are
525 * automatically propogated to the parent
526 */
527
528struct buf *
529getchainbuf(struct buf *bp, struct vnode *vp, int flags)
530{
531 struct buf *nbp = getpbuf(NULL);
532
533 nbp->b_chain.parent = bp;
534 ++bp->b_chain.count;
535
536 if (bp->b_chain.count > 4)
537 waitchainbuf(bp, 4, 0);
538
539 nbp->b_flags = B_BUSY | B_CALL | (bp->b_flags & B_ORDERED) | flags;
540 nbp->b_proc = &proc0;
541 nbp->b_rcred = nbp->b_proc->p_ucred;
542 nbp->b_wcred = nbp->b_proc->p_ucred;
543 nbp->b_iodone = vm_pager_chain_iodone;
544
545 crhold(nbp->b_rcred);
546 crhold(nbp->b_wcred);
547
548 if (vp)
549 pbgetvp(vp, nbp);
550 return(nbp);
551}
552
553void
554flushchainbuf(struct buf *nbp)
555{
556 if (nbp->b_bcount) {
557 nbp->b_bufsize = nbp->b_bcount;
558 if ((nbp->b_flags & B_READ) == 0)
559 nbp->b_dirtyend = nbp->b_bcount;
560 VOP_STRATEGY(nbp->b_vp, nbp);
561 } else {
562 biodone(nbp);
563 }
564}
565
566void
567waitchainbuf(struct buf *bp, int count, int done)
568{
569 int s;
570
571 s = splbio();
572 while (bp->b_chain.count > count) {
573 bp->b_flags |= B_WANTED;
574 tsleep(bp, PRIBIO + 4, "bpchain", 0);
575 }
576 if (done) {
577 if (bp->b_resid != 0 && !(bp->b_flags & B_ERROR)) {
578 bp->b_flags |= B_ERROR;
579 bp->b_error = EINVAL;
580 }
581 biodone(bp);
582 }
583 splx(s);
584}
585
586void
587autochaindone(struct buf *bp)
588{
589 int s;
590
591 s = splbio();
592 if (bp->b_chain.count == 0)
593 biodone(bp);
594 else
595 bp->b_flags |= B_AUTOCHAINDONE;
596 splx(s);
597}
598