Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/ufs/lfs Pull up revisions 1.26-1.27 (requested by p...



details:   https://anonhg.NetBSD.org/src/rev/71001121c9ae
branches:  netbsd-1-5
changeset: 490626:71001121c9ae
user:      he <he%NetBSD.org@localhost>
date:      Sat Feb 03 21:50:51 2001 +0000

description:
Pull up revisions 1.26-1.27 (requested by perseant):
  o Close up accounting holes in LFS' accounting of immediately-
    available-space, number of clean segments, and amount of dirty
    space taken up by metadata (PR#11468, PR#11470, PR#11534).

diffstat:

 sys/ufs/lfs/lfs_balloc.c |  36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)

diffs (77 lines):

diff -r 58e5d8d0624b -r 71001121c9ae sys/ufs/lfs/lfs_balloc.c
--- a/sys/ufs/lfs/lfs_balloc.c  Sat Feb 03 21:50:12 2001 +0000
+++ b/sys/ufs/lfs/lfs_balloc.c  Sat Feb 03 21:50:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_balloc.c,v 1.18.2.1 2000/09/14 18:50:17 perseant Exp $     */
+/*     $NetBSD: lfs_balloc.c,v 1.18.2.2 2001/02/03 21:50:51 he Exp $   */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -348,6 +348,7 @@
        int error;
        extern long locked_queue_bytes;
        struct buf *ibp;
+       size_t obufsize;
        SEGUSE *sup;
 
        ip = VTOI(vp);
@@ -359,6 +360,7 @@
         * Get the seglock so we don't enlarge blocks or change the segment
         * accounting information while a segment is being written.
         */
+    top:
        lfs_seglock(fs, SEGM_PROT);
 
        if (!ISSPACE(fs, bb, curproc->p_ucred)) {
@@ -376,23 +378,47 @@
        }
 #endif
        /*
+        * Adjust accounting for lfs_avail.  If there's not enough room,
+        * we will have to wait for the cleaner, which we can't do while
+        * holding a block busy or while holding the seglock.  In that case,
+        * release both and start over after waiting.
+        */
+       if ((*bpp)->b_flags & B_DELWRI) {
+               if (!lfs_fits(fs, bb)) {
+                       brelse(*bpp);
+#ifdef QUOTA
+                       chkdq(ip, -bb, curproc->p_ucred, 0);
+#endif
+                       lfs_segunlock(fs);
+                       lfs_availwait(fs, bb);
+                       goto top;
+               }
+               fs->lfs_avail -= bb;
+       }
+
+       /*
         * Fix the allocation for this fragment so that it looks like the
          * source segment contained a block of the new size.  This overcounts;
         * but the overcount only lasts until the block in question
         * is written, so the on-disk live bytes count is always correct.
         */
        if ((*bpp)->b_blkno > 0) {
-               LFS_SEGENTRY(sup, fs, datosn(fs,(*bpp)->b_blkno), ibp);
-               sup->su_nbytes += (nsize-osize);
+               LFS_SEGENTRY(sup, fs, datosn(fs, (*bpp)->b_blkno), ibp);
+               sup->su_nbytes += (nsize - osize);
                VOP_BWRITE(ibp);
                ip->i_ffs_blocks += bb;
        }
        fs->lfs_bfree -= bb;
        ip->i_lfs_effnblks += bb;
        ip->i_flag |= IN_CHANGE | IN_UPDATE;
-       if((*bpp)->b_flags & B_LOCKED)
-               locked_queue_bytes += (nsize - osize);
+
+       obufsize = (*bpp)->b_bufsize;
        allocbuf(*bpp, nsize);
+
+       /* Adjust locked-list accounting */
+       if (((*bpp)->b_flags & (B_LOCKED | B_CALL)) == B_LOCKED)
+               locked_queue_bytes += (*bpp)->b_bufsize - obufsize;
+
        bzero((char *)((*bpp)->b_data) + osize, (u_int)(nsize - osize));
 
     out:



Home | Main Index | Thread Index | Old Index