GREENMAN BUGFIX KIT
authorDavid Greenman <dg@Root.COM>
Thu, 20 Aug 1992 00:00:00 +0000 (00:00 +0000)
committerDavid Greenman <dg@Root.COM>
Thu, 20 Aug 1992 00:00:00 +0000 (00:00 +0000)
1. Buffers were being immediately aged after read, greatly reducing
file system performance.
2. The file system buffer cache hash calculation resulted in hash
collision occuring 100% of the time.
3. File system buffers were allocated twice.  They were also deallocated
twice, so there was not a memory leak, but freebufspace was incorrect
and too much memory was being used.
4. Unnecessary call to swapout_threads in the vm system.

AUTHOR: David Greenman (davidg@agora.uucp)
386BSD-Patchkit: patch00007

usr/src/sys.386bsd/kern/spec_vnops.c
usr/src/sys.386bsd/kern/vfs__bio.c
usr/src/sys.386bsd/sys/buf.h
usr/src/sys.386bsd/ufs/ufs_vnops.c
usr/src/sys.386bsd/vm/vm_pageout.c

index 7defb37..65c5766 100644 (file)
  * SUCH DAMAGE.
  *
  *     @(#)spec_vnops.c        7.37 (Berkeley) 5/30/91
  * SUCH DAMAGE.
  *
  *     @(#)spec_vnops.c        7.37 (Berkeley) 5/30/91
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00007
+ * --------------------         -----   ----------------------
+ *
+ * 20 Aug 92    David Greenman          Fixed incorrect setting of B_AGE on
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -218,8 +225,10 @@ spec_read(vp, uio, ioflag, cred)
                                return (error);
                        }
                        error = uiomove(bp->b_un.b_addr + on, n, uio);
                                return (error);
                        }
                        error = uiomove(bp->b_un.b_addr + on, n, uio);
+#ifdef OMIT    /* 20 Aug 92*/
                        if (n + on == bsize)
                                bp->b_flags |= B_AGE;
                        if (n + on == bsize)
                                bp->b_flags |= B_AGE;
+#endif /* OMIT*/
                        brelse(bp);
                } while (error == 0 && uio->uio_resid > 0 && n != 0);
                return (error);
                        brelse(bp);
                } while (error == 0 && uio->uio_resid > 0 && n != 0);
                return (error);
index 3e49158..6740098 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00007
+ * --------------------         -----   ----------------------
+ *
+ * 20 Aug 92   David Greenman          Fix getnewbuf() 2xAllocation
  */
 static char rcsid[] = "$Header: /usr/bill/working/sys/kern/RCS/vfs__bio.c,v 1.2 92/01/21 21:30:08 william Exp $";
 
  */
 static char rcsid[] = "$Header: /usr/bill/working/sys/kern/RCS/vfs__bio.c,v 1.2 92/01/21 21:30:08 william Exp $";
 
@@ -344,6 +350,7 @@ start:
                bp->b_flags = B_BUSY | B_INVAL;
                bremfree(bp);
                bp->b_un.b_addr = addr;
                bp->b_flags = B_BUSY | B_INVAL;
                bremfree(bp);
                bp->b_un.b_addr = addr;
+               bp->b_bufsize = sz;     /* 20 Aug 92*/
                goto fillin;
        }
 
                goto fillin;
        }
 
index 7fdef68..c01df7a 100644 (file)
  * SUCH DAMAGE.
  *
  *     @(#)buf.h       7.11 (Berkeley) 5/9/90
  * SUCH DAMAGE.
  *
  *     @(#)buf.h       7.11 (Berkeley) 5/9/90
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00007
+ * --------------------         -----   ----------------------
+ *
+ * 20 Aug 92   David Greenman          Fixed buffer cache hash index
+ *                                     calculation
  */
 
 /*
  */
 
 /*
@@ -110,12 +118,13 @@ struct buf
 #ifdef KERNEL
 #define        BUFHSZ  512
 #define RND    (MAXBSIZE/DEV_BSIZE)
 #ifdef KERNEL
 #define        BUFHSZ  512
 #define RND    (MAXBSIZE/DEV_BSIZE)
+/* 20 Aug 92   BUFHASH*/
 #if    ((BUFHSZ&(BUFHSZ-1)) == 0)
 #define        BUFHASH(dvp, dblkno)    \
 #if    ((BUFHSZ&(BUFHSZ-1)) == 0)
 #define        BUFHASH(dvp, dblkno)    \
-       ((struct buf *)&bufhash[((int)(dvp)+(((int)(dblkno))/RND))&(BUFHSZ-1)])
+       ((struct buf *)&bufhash[((int)(dvp)/sizeof(struct vnode)+(int)(dblkno))&(BUFHSZ-1)])
 #else
 #define        BUFHASH(dvp, dblkno)    \
 #else
 #define        BUFHASH(dvp, dblkno)    \
-       ((struct buf *)&bufhash[((int)(dvp)+(((int)(dblkno))/RND)) % BUFHSZ])
+       ((struct buf *)&bufhash[((int)(dvp)/sizeof(struct vnode)+(int)(dblkno)) % BUFHSZ])
 #endif
 
 struct buf *buf;               /* the buffer pool itself */
 #endif
 
 struct buf *buf;               /* the buffer pool itself */
index 785a6c5..e27a387 100644 (file)
  * SUCH DAMAGE.
  *
  *     @(#)ufs_vnops.c 7.64 (Berkeley) 5/16/91
  * SUCH DAMAGE.
  *
  *     @(#)ufs_vnops.c 7.64 (Berkeley) 5/16/91
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00007
+ * --------------------         -----   ----------------------
+ *
+ * 20 Aug 92   David Greenman          Fixed incorrect setting of B_AGE after
+ *                                     each read to improve cache performance
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -497,8 +505,10 @@ ufs_read(vp, uio, ioflag, cred)
                        return (error);
                }
                error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
                        return (error);
                }
                error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
+#if OMIT       /* 20 Aug 92*/
                if (n + on == fs->fs_bsize || uio->uio_offset == ip->i_size)
                        bp->b_flags |= B_AGE;
                if (n + on == fs->fs_bsize || uio->uio_offset == ip->i_size)
                        bp->b_flags |= B_AGE;
+#endif /* OMIT*/
                brelse(bp);
        } while (error == 0 && uio->uio_resid > 0 && n != 0);
        return (error);
                brelse(bp);
        } while (error == 0 && uio->uio_resid > 0 && n != 0);
        return (error);
index 5270ae3..de7cc30 100644 (file)
  *
  * any improvements or extensions that they make and grant Carnegie the
  * rights to redistribute these changes.
  *
  * any improvements or extensions that they make and grant Carnegie the
  * rights to redistribute these changes.
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00007
+ * --------------------         -----   ----------------------
+ *
+ * 20 Aug 92   David Greenman          Removed un-necessary call to
+ *                                     swapout_thread
  */
 
 /*
  */
 
 /*
@@ -99,7 +107,9 @@ vm_pageout_scan()
        splx(s);
 
        if (free < vm_page_free_target) {
        splx(s);
 
        if (free < vm_page_free_target) {
+#ifdef OMIT
                swapout_threads();
                swapout_threads();
+#endif /* OMIT*/
 
                /*
                 *      Be sure the pmap system is updated so
 
                /*
                 *      Be sure the pmap system is updated so