Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs Include the space taken by inodes in the count m...



details:   https://anonhg.NetBSD.org/src/rev/5c5abd509678
branches:  trunk
changeset: 522060:5c5abd509678
user:      perseant <perseant%NetBSD.org@localhost>
date:      Mon Feb 11 02:47:29 2002 +0000

description:
Include the space taken by inodes in the count made by lfs_check();
make VOP_SETATTR call lfs_check.  This prevents large numbers of inode
changes (say, at the end of tar(1)) from filling the buffer cache.

diffstat:

 sys/ufs/lfs/lfs_bio.c    |  23 +++++++++++++----------
 sys/ufs/lfs/lfs_extern.h |   3 ++-
 sys/ufs/lfs/lfs_vnops.c  |  29 ++++++++++++++++++++++++-----
 3 files changed, 39 insertions(+), 16 deletions(-)

diffs (160 lines):

diff -r f77bc77d28d4 -r 5c5abd509678 sys/ufs/lfs/lfs_bio.c
--- a/sys/ufs/lfs/lfs_bio.c     Mon Feb 11 00:57:58 2002 +0000
+++ b/sys/ufs/lfs/lfs_bio.c     Mon Feb 11 02:47:29 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_bio.c,v 1.40 2001/11/23 21:44:26 chs Exp $ */
+/*     $NetBSD: lfs_bio.c,v 1.41 2002/02/11 02:47:29 perseant Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.40 2001/11/23 21:44:26 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.41 2002/02/11 02:47:29 perseant Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -389,6 +389,9 @@
        lfs_writing = 0;
 }
 
+#define INOCOUNT(fs) howmany((fs)->lfs_uinodes, INOPB(fs))
+#define INOBYTES(fs) ((fs)->lfs_uinodes * DINODE_SIZE)
+
 int
 lfs_check(struct vnode *vp, ufs_daddr_t blkno, int flags)
 {
@@ -415,8 +418,8 @@
         * Note that a dirop cannot ever reach this code!
         */
        while (fs->lfs_dirops > 0 &&
-              (locked_queue_count > LFS_MAX_BUFS ||
-                locked_queue_bytes > LFS_MAX_BYTES ||
+              (locked_queue_count + INOCOUNT(fs) > LFS_MAX_BUFS ||
+                locked_queue_bytes + INOBYTES(fs) > LFS_MAX_BYTES ||
                 lfs_dirvcount > LFS_MAXDIROP || fs->lfs_diropwait > 0))
        {
                ++fs->lfs_diropwait;
@@ -424,8 +427,8 @@
                --fs->lfs_diropwait;
        }
 
-       if (locked_queue_count > LFS_MAX_BUFS ||
-           locked_queue_bytes > LFS_MAX_BYTES ||
+       if (locked_queue_count + INOCOUNT(fs) > LFS_MAX_BUFS ||
+           locked_queue_bytes + INOBYTES(fs) > LFS_MAX_BYTES ||
            lfs_dirvcount > LFS_MAXDIROP || fs->lfs_diropwait > 0)
        {
                ++fs->lfs_writer;
@@ -434,8 +437,8 @@
                        wakeup(&fs->lfs_dirops);
        }
 
-       while (locked_queue_count > LFS_WAIT_BUFS
-              || locked_queue_bytes > LFS_WAIT_BYTES)
+       while (locked_queue_count + INOCOUNT(fs) > LFS_WAIT_BUFS
+              || locked_queue_bytes + INOBYTES(fs) > LFS_WAIT_BYTES)
        {
                if (lfs_dostats)
                        ++lfs_stats.wait_exceeded;
@@ -453,8 +456,8 @@
                 * and we weren't asked to checkpoint.  Try flushing again
                 * to keep us from blocking indefinitely.
                 */
-               if (locked_queue_count > LFS_MAX_BUFS ||
-                   locked_queue_bytes > LFS_MAX_BYTES)
+               if (locked_queue_count + INOCOUNT(fs) > LFS_MAX_BUFS ||
+                   locked_queue_bytes + INOBYTES(fs) > LFS_MAX_BYTES)
                {
                        ++fs->lfs_writer;
                        lfs_flush(fs, flags | SEGM_CKP);
diff -r f77bc77d28d4 -r 5c5abd509678 sys/ufs/lfs/lfs_extern.h
--- a/sys/ufs/lfs/lfs_extern.h  Mon Feb 11 00:57:58 2002 +0000
+++ b/sys/ufs/lfs/lfs_extern.h  Mon Feb 11 02:47:29 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_extern.h,v 1.27 2001/12/18 07:51:17 chs Exp $      */
+/*     $NetBSD: lfs_extern.h,v 1.28 2002/02/11 02:47:29 perseant Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -219,6 +219,7 @@
 int lfs_link   (void *);
 int lfs_rename (void *);
 int lfs_getattr        (void *);
+int lfs_setattr        (void *);
 int lfs_close  (void *);
 int lfs_inactive(void *);
 int lfs_reclaim        (void *);
diff -r f77bc77d28d4 -r 5c5abd509678 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Mon Feb 11 00:57:58 2002 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Mon Feb 11 02:47:29 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vnops.c,v 1.60 2001/12/18 07:51:18 chs Exp $       */
+/*     $NetBSD: lfs_vnops.c,v 1.61 2002/02/11 02:47:29 perseant Exp $  */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.60 2001/12/18 07:51:18 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.61 2002/02/11 02:47:29 perseant Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -113,7 +113,7 @@
        { &vop_close_desc, lfs_close },                 /* close */
        { &vop_access_desc, ufs_access },               /* access */
        { &vop_getattr_desc, lfs_getattr },             /* getattr */
-       { &vop_setattr_desc, ufs_setattr },             /* setattr */
+       { &vop_setattr_desc, lfs_setattr },             /* setattr */
        { &vop_read_desc, lfs_read },                   /* read */
        { &vop_write_desc, lfs_write },                 /* write */
        { &vop_lease_desc, ufs_lease_check },           /* lease */
@@ -167,7 +167,7 @@
        { &vop_close_desc, ufsspec_close },             /* close */
        { &vop_access_desc, ufs_access },               /* access */
        { &vop_getattr_desc, lfs_getattr },             /* getattr */
-       { &vop_setattr_desc, ufs_setattr },             /* setattr */
+       { &vop_setattr_desc, lfs_setattr },             /* setattr */
        { &vop_read_desc, ufsspec_read },               /* read */
        { &vop_write_desc, ufsspec_write },             /* write */
        { &vop_lease_desc, spec_lease_check },          /* lease */
@@ -220,7 +220,7 @@
        { &vop_close_desc, ufsfifo_close },             /* close */
        { &vop_access_desc, ufs_access },               /* access */
        { &vop_getattr_desc, lfs_getattr },             /* getattr */
-       { &vop_setattr_desc, ufs_setattr },             /* setattr */
+       { &vop_setattr_desc, lfs_setattr },             /* setattr */
        { &vop_read_desc, ufsfifo_read },               /* read */
        { &vop_write_desc, ufsfifo_write },             /* write */
        { &vop_lease_desc, fifo_lease_check },          /* lease */
@@ -807,6 +807,25 @@
 }
 
 /*
+ * Check to make sure the inode blocks won't choke the buffer
+ * cache, then call ufs_setattr as usual.
+ */
+int
+lfs_setattr(void *v)
+{
+       struct vop_getattr_args /* {
+               struct vnode *a_vp;
+               struct vattr *a_vap;
+               struct ucred *a_cred;
+               struct proc *a_p;
+       } */ *ap = v;
+       struct vnode *vp = ap->a_vp;
+
+       lfs_check(vp, LFS_UNUSED_LBN, 0);
+       return ufs_setattr(v);
+}
+
+/*
  * Close called
  *
  * XXX -- we were using ufs_close, but since it updates the



Home | Main Index | Thread Index | Old Index