Deleted Added
full compact
vfs_bio.c (15583) vfs_bio.c (15809)
1/*
2 * Copyright (c) 1994 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

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

13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. This work was done expressly for inclusion into FreeBSD. Other use
17 * is allowed if this notation is included.
18 * 5. Modifications may be freely made to this file if the above conditions
19 * are met.
20 *
1/*
2 * Copyright (c) 1994 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

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

13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. This work was done expressly for inclusion into FreeBSD. Other use
17 * is allowed if this notation is included.
18 * 5. Modifications may be freely made to this file if the above conditions
19 * are met.
20 *
21 * $Id: vfs_bio.c,v 1.88 1996/03/09 06:46:51 dyson Exp $
21 * $Id: vfs_bio.c,v 1.89 1996/05/03 21:01:26 phk Exp $
22 */
23
24/*
25 * this file contains a new buffer I/O scheme implementing a coherent
26 * VM object and buffer cache scheme. Pains have been taken to make
27 * sure that the performance degradation associated with schemes such
28 * as this is not realized.
29 *

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

504 }
505 if (bp->b_qindex != QUEUE_NONE)
506 panic("brelse: free buffer onto another queue???");
507
508 /* enqueue */
509 /* buffers with no memory */
510 if (bp->b_bufsize == 0) {
511 bp->b_qindex = QUEUE_EMPTY;
22 */
23
24/*
25 * this file contains a new buffer I/O scheme implementing a coherent
26 * VM object and buffer cache scheme. Pains have been taken to make
27 * sure that the performance degradation associated with schemes such
28 * as this is not realized.
29 *

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

504 }
505 if (bp->b_qindex != QUEUE_NONE)
506 panic("brelse: free buffer onto another queue???");
507
508 /* enqueue */
509 /* buffers with no memory */
510 if (bp->b_bufsize == 0) {
511 bp->b_qindex = QUEUE_EMPTY;
512 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_EMPTY], bp, b_freelist);
512 TAILQ_INSERT_HEAD(&bufqueues[QUEUE_EMPTY], bp, b_freelist);
513 LIST_REMOVE(bp, b_hash);
514 LIST_INSERT_HEAD(&invalhash, bp, b_hash);
515 bp->b_dev = NODEV;
516 if (needsbuffer) {
517 wakeup(&needsbuffer);
518 needsbuffer=0;
519 }
520 /* buffers with junk contents */

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

737 struct buf *bp;
738 int nbyteswritten = 0;
739
740start:
741 if (bufspace >= maxbufspace)
742 goto trytofreespace;
743
744 /* can we constitute a new buffer? */
513 LIST_REMOVE(bp, b_hash);
514 LIST_INSERT_HEAD(&invalhash, bp, b_hash);
515 bp->b_dev = NODEV;
516 if (needsbuffer) {
517 wakeup(&needsbuffer);
518 needsbuffer=0;
519 }
520 /* buffers with junk contents */

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

737 struct buf *bp;
738 int nbyteswritten = 0;
739
740start:
741 if (bufspace >= maxbufspace)
742 goto trytofreespace;
743
744 /* can we constitute a new buffer? */
745 if ((bp = bufqueues[QUEUE_EMPTY].tqh_first)) {
745 if ((bp = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY]))) {
746 if (bp->b_qindex != QUEUE_EMPTY)
747 panic("getnewbuf: inconsistent EMPTY queue, qindex=%d",
748 bp->b_qindex);
749 bp->b_flags |= B_BUSY;
750 bremfree(bp);
751 goto fillbuf;
752 }
753trytofreespace:
754 /*
755 * We keep the file I/O from hogging metadata I/O
756 * This is desirable because file data is cached in the
757 * VM/Buffer cache even if a buffer is freed.
758 */
746 if (bp->b_qindex != QUEUE_EMPTY)
747 panic("getnewbuf: inconsistent EMPTY queue, qindex=%d",
748 bp->b_qindex);
749 bp->b_flags |= B_BUSY;
750 bremfree(bp);
751 goto fillbuf;
752 }
753trytofreespace:
754 /*
755 * We keep the file I/O from hogging metadata I/O
756 * This is desirable because file data is cached in the
757 * VM/Buffer cache even if a buffer is freed.
758 */
759 if ((bp = bufqueues[QUEUE_AGE].tqh_first)) {
759 if ((bp = TAILQ_FIRST(&bufqueues[QUEUE_AGE]))) {
760 if (bp->b_qindex != QUEUE_AGE)
761 panic("getnewbuf: inconsistent AGE queue, qindex=%d",
762 bp->b_qindex);
760 if (bp->b_qindex != QUEUE_AGE)
761 panic("getnewbuf: inconsistent AGE queue, qindex=%d",
762 bp->b_qindex);
763 } else if ((bp = bufqueues[QUEUE_LRU].tqh_first)) {
763 } else if ((bp = TAILQ_FIRST(&bufqueues[QUEUE_LRU]))) {
764 if (bp->b_qindex != QUEUE_LRU)
765 panic("getnewbuf: inconsistent LRU queue, qindex=%d",
766 bp->b_qindex);
767 }
768 if (!bp) {
769 /* wait for a free buffer of any kind */
770 needsbuffer = 1;
771 tsleep(&needsbuffer,

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

778 * the buffering is intact without buffer headers, there is not
779 * much loss. We gain by maintaining non-VMIOed metadata in buffers.
780 */
781 if ((bp->b_qindex == QUEUE_LRU) && (bp->b_usecount > 0)) {
782 if ((bp->b_flags & B_VMIO) == 0 ||
783 (vmiospace < maxvmiobufspace)) {
784 --bp->b_usecount;
785 TAILQ_REMOVE(&bufqueues[QUEUE_LRU], bp, b_freelist);
764 if (bp->b_qindex != QUEUE_LRU)
765 panic("getnewbuf: inconsistent LRU queue, qindex=%d",
766 bp->b_qindex);
767 }
768 if (!bp) {
769 /* wait for a free buffer of any kind */
770 needsbuffer = 1;
771 tsleep(&needsbuffer,

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

778 * the buffering is intact without buffer headers, there is not
779 * much loss. We gain by maintaining non-VMIOed metadata in buffers.
780 */
781 if ((bp->b_qindex == QUEUE_LRU) && (bp->b_usecount > 0)) {
782 if ((bp->b_flags & B_VMIO) == 0 ||
783 (vmiospace < maxvmiobufspace)) {
784 --bp->b_usecount;
785 TAILQ_REMOVE(&bufqueues[QUEUE_LRU], bp, b_freelist);
786 if (bufqueues[QUEUE_LRU].tqh_first != NULL) {
786 if (TAILQ_FIRST(&bufqueues[QUEUE_LRU]) != NULL) {
787 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_LRU], bp, b_freelist);
788 goto start;
789 }
790 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_LRU], bp, b_freelist);
791 }
792 }
793
794 /* if we are a delayed write, convert to an async write */

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

1493
1494int
1495count_lock_queue()
1496{
1497 int count;
1498 struct buf *bp;
1499
1500 count = 0;
787 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_LRU], bp, b_freelist);
788 goto start;
789 }
790 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_LRU], bp, b_freelist);
791 }
792 }
793
794 /* if we are a delayed write, convert to an async write */

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

1493
1494int
1495count_lock_queue()
1496{
1497 int count;
1498 struct buf *bp;
1499
1500 count = 0;
1501 for (bp = bufqueues[QUEUE_LOCKED].tqh_first;
1501 for (bp = TAILQ_FIRST(&bufqueues[QUEUE_LOCKED]);
1502 bp != NULL;
1502 bp != NULL;
1503 bp = bp->b_freelist.tqe_next)
1503 bp = TAILQ_NEXT(bp, b_freelist))
1504 count++;
1505 return (count);
1506}
1507
1508int vfs_update_interval = 30;
1509
1510static void
1511vfs_update()

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

1658 iocount -= resid;
1659 }
1660 }
1661}
1662
1663void
1664vfs_bio_clrbuf(struct buf *bp) {
1665 int i;
1504 count++;
1505 return (count);
1506}
1507
1508int vfs_update_interval = 30;
1509
1510static void
1511vfs_update()

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

1658 iocount -= resid;
1659 }
1660 }
1661}
1662
1663void
1664vfs_bio_clrbuf(struct buf *bp) {
1665 int i;
1666 int remapbuffer = 0;
1667 if( bp->b_flags & B_VMIO) {
1668 if( (bp->b_npages == 1) && (bp->b_bufsize < PAGE_SIZE)) {
1669 int mask;
1670 mask = 0;
1671 for(i=0;i<bp->b_bufsize;i+=DEV_BSIZE)
1672 mask |= (1 << (i/DEV_BSIZE));
1673 if( bp->b_pages[0]->valid != mask) {
1674 bzero(bp->b_data, bp->b_bufsize);

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

1686 }
1687 } else {
1688 int j;
1689 for(j=0;j<PAGE_SIZE/DEV_BSIZE;j++) {
1690 if( (bp->b_pages[i]->valid & (1<<j)) == 0)
1691 bzero(bp->b_data + (i << PAGE_SHIFT) + j * DEV_BSIZE, DEV_BSIZE);
1692 }
1693 }
1666 if( bp->b_flags & B_VMIO) {
1667 if( (bp->b_npages == 1) && (bp->b_bufsize < PAGE_SIZE)) {
1668 int mask;
1669 mask = 0;
1670 for(i=0;i<bp->b_bufsize;i+=DEV_BSIZE)
1671 mask |= (1 << (i/DEV_BSIZE));
1672 if( bp->b_pages[0]->valid != mask) {
1673 bzero(bp->b_data, bp->b_bufsize);

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

1685 }
1686 } else {
1687 int j;
1688 for(j=0;j<PAGE_SIZE/DEV_BSIZE;j++) {
1689 if( (bp->b_pages[i]->valid & (1<<j)) == 0)
1690 bzero(bp->b_data + (i << PAGE_SHIFT) + j * DEV_BSIZE, DEV_BSIZE);
1691 }
1692 }
1694 bp->b_pages[i]->valid = VM_PAGE_BITS_ALL;
1693 /* bp->b_pages[i]->valid = VM_PAGE_BITS_ALL; */
1695 }
1696 bp->b_resid = 0;
1697 } else {
1698 clrbuf(bp);
1699 }
1694 }
1695 bp->b_resid = 0;
1696 } else {
1697 clrbuf(bp);
1698 }
1700 if (remapbuffer)
1701 pmap_qenter(trunc_page(bp->b_data), bp->b_pages, bp->b_npages);
1702}
1703
1704/*
1705 * vm_hold_load_pages and vm_hold_unload pages get pages into
1706 * a buffers address space. The pages are anonymous and are
1707 * not associated with a file object.
1708 */
1709void

--- 54 unchanged lines hidden ---
1699}
1700
1701/*
1702 * vm_hold_load_pages and vm_hold_unload pages get pages into
1703 * a buffers address space. The pages are anonymous and are
1704 * not associated with a file object.
1705 */
1706void

--- 54 unchanged lines hidden ---