Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/lfs Fix miscalculation in lfs_fits found by Trevin B...



details:   https://anonhg.NetBSD.org/src/rev/11ad9c74e640
branches:  trunk
changeset: 533087:11ad9c74e640
user:      perseant <perseant%NetBSD.org@localhost>
date:      Thu Jun 20 22:10:24 2002 +0000

description:
Fix miscalculation in lfs_fits found by Trevin Beattie <trevin%xmission.com@localhost>.
Change some of the variable names from "nb", "db" to "fsb" to reflect their
calling conventions.

diffstat:

 sys/ufs/lfs/lfs_bio.c |  32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diffs (102 lines):

diff -r 51255f11842d -r 11ad9c74e640 sys/ufs/lfs/lfs_bio.c
--- a/sys/ufs/lfs/lfs_bio.c     Thu Jun 20 22:02:32 2002 +0000
+++ b/sys/ufs/lfs/lfs_bio.c     Thu Jun 20 22:10:24 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_bio.c,v 1.43 2002/05/14 20:03:53 perseant Exp $    */
+/*     $NetBSD: lfs_bio.c,v 1.44 2002/06/20 22:10:24 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.43 2002/05/14 20:03:53 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.44 2002/06/20 22:10:24 perseant Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -113,24 +113,24 @@
  * requires the vnode lock to be honored.  If there is not enough space, give
  * up the vnode lock temporarily and wait for the space to become available.
  *
- * Called with vp locked.  (Note nowever that if nb < 0, vp is ignored.)
+ * Called with vp locked.  (Note nowever that if fsb < 0, vp is ignored.)
  */
 int
-lfs_reserve(struct lfs *fs, struct vnode *vp, int nb)
+lfs_reserve(struct lfs *fs, struct vnode *vp, int fsb)
 {
        CLEANERINFO *cip;
        struct buf *bp;
        int error, slept;
 
        slept = 0;
-       while (nb > 0 && !lfs_fits(fs, nb + fs->lfs_ravail)) {
+       while (fsb > 0 && !lfs_fits(fs, fsb + fs->lfs_ravail)) {
                VOP_UNLOCK(vp, 0);
 
                if (!slept) {
 #ifdef DEBUG
                        printf("lfs_reserve: waiting for %ld (bfree = %d,"
                               " est_bfree = %d)\n",
-                              nb + fs->lfs_ravail, fs->lfs_bfree,
+                              fsb + fs->lfs_ravail, fs->lfs_bfree,
                               LFS_EST_BFREE(fs));
 #endif
                }
@@ -148,9 +148,11 @@
                if (error)
                        return error;
        }
+#ifdef DEBUG
        if (slept)
                printf("lfs_reserve: woke up\n");
-       fs->lfs_ravail += nb;
+#endif
+       fs->lfs_ravail += fsb;
        return 0;
 }
 
@@ -183,10 +185,10 @@
 }
 
 /* 
- * Determine if there is enough room currently available to write db
- * disk blocks.  We need enough blocks for the new blocks, the current
- * inode blocks, a summary block, plus potentially the ifile inode and
- * the segment usage table, plus an ifile page.
+ * Determine if there is enough room currently available to write fsb
+ * blocks.  We need enough blocks for the new blocks, the current
+ * inode blocks (including potentially the ifile inode), a summary block,
+ * and the segment usage table, plus an ifile block.
  */
 int
 lfs_fits(struct lfs *fs, int fsb)
@@ -194,8 +196,8 @@
        int needed;
 
        needed = fsb + btofsb(fs, fs->lfs_sumsize) +
-               fsbtodb(fs, howmany(fs->lfs_uinodes + 1, INOPB(fs)) +
-                           fs->lfs_segtabsz + btofsb(fs, fs->lfs_sumsize));
+                ((howmany(fs->lfs_uinodes + 1, INOPB(fs)) + fs->lfs_segtabsz +
+                  1) << (fs->lfs_blktodb - fs->lfs_fsbtodb));
 
        if (needed >= fs->lfs_avail) {
 #ifdef DEBUG
@@ -209,13 +211,13 @@
 }
 
 int
-lfs_availwait(struct lfs *fs, int db)
+lfs_availwait(struct lfs *fs, int fsb)
 {
        int error;
        CLEANERINFO *cip;
        struct buf *cbp;
 
-       while (!lfs_fits(fs, db)) {
+       while (!lfs_fits(fs, fsb)) {
                /*
                 * Out of space, need cleaner to run.
                 * Update the cleaner info, then wake it up.



Home | Main Index | Thread Index | Old Index