Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/ufs/lfs Pull up revision 1.67 (requested by persean...



details:   https://anonhg.NetBSD.org/src/rev/bb0f2b2cd77a
branches:  netbsd-1-6
changeset: 528020:bb0f2b2cd77a
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Jun 20 03:51:59 2002 +0000

description:
Pull up revision 1.67 (requested by perseant in ticket #325):
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread).  lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it.  (Formerly it was extended to the "correct"
size.)  This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them.  Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more.  Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.

diffstat:

 sys/ufs/lfs/lfs_syscalls.c |  39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diffs (118 lines):

diff -r 22c06092beb7 -r bb0f2b2cd77a sys/ufs/lfs/lfs_syscalls.c
--- a/sys/ufs/lfs/lfs_syscalls.c        Thu Jun 20 03:51:47 2002 +0000
+++ b/sys/ufs/lfs/lfs_syscalls.c        Thu Jun 20 03:51:59 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_syscalls.c,v 1.65 2002/05/14 20:03:54 perseant Exp $       */
+/*     $NetBSD: lfs_syscalls.c,v 1.65.4.1 2002/06/20 03:51:59 lukem Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.65 2002/05/14 20:03:54 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.65.4.1 2002/06/20 03:51:59 lukem Exp $");
 
 #define LFS            /* for prototypes in syscallargs.h */
 
@@ -282,7 +282,7 @@
         * any Ifile blocks that we might be asked to clean will never get
         * to the disk.
         */
-       lfs_seglock(fs, SEGM_SYNC|SEGM_CLEAN|SEGM_CKP);
+       lfs_seglock(fs, SEGM_CLEAN | SEGM_CKP | SEGM_SYNC);
        
        /* Mark blocks/inodes dirty.  */
        error = 0;
@@ -444,6 +444,7 @@
                                        printf("lfs_markv: wrong da same seg: %x vs %x\n",
                                               blkp->bi_daddr, dbtofsb(fs, b_daddr));
                                }
+                               do_again++;
                                continue;
                        }
                }
@@ -465,9 +466,13 @@
                        s = splbio();
                        bp = incore(vp, blkp->bi_lbn);
                        if (bp && bp->b_bcount > blkp->bi_size) {
-                               printf("lfs_markv: %ld > %d (fixed)\n",
-                                      bp->b_bcount, blkp->bi_size);
-                               blkp->bi_size = bp->b_bcount;
+                               splx(s);
+                               printf("lfs_markv: ino %d lbn %d fragment size changed (%ld > %d), try again\n",
+                                       blkp->bi_inode, blkp->bi_lbn,
+                                       bp->b_bcount, blkp->bi_size);
+                               do_again++;
+                               continue;
+                               /* blkp->bi_size = bp->b_bcount; */
                        }
                        splx(s);
                }
@@ -524,7 +529,7 @@
         * over the newly cleaned data contained in a checkpoint, and then
         * we'd be unhappy at recovery time.
         */
-       lfs_segwrite(mntp, SEGM_SYNC|SEGM_CLEAN|SEGM_CKP);
+       lfs_segwrite(mntp, SEGM_CLEAN | SEGM_CKP | SEGM_SYNC);
        
        lfs_segunlock(fs);
 
@@ -882,6 +887,7 @@
        struct lfs *fs;
        fsid_t fsid;
        int error;
+       unsigned long segnum;
        
        if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
                return (error);
@@ -892,8 +898,9 @@
                return (ENOENT);
        
        fs = VFSTOUFS(mntp)->um_lfs;
+       segnum = SCARG(uap, segment);
        
-       if (dtosn(fs, fs->lfs_curseg) == SCARG(uap, segment))
+       if (dtosn(fs, fs->lfs_curseg) == segnum)
                return (EBUSY);
        
        if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0) 
@@ -901,7 +908,17 @@
 #ifdef LFS_AGGRESSIVE_SEGLOCK
        lfs_seglock(fs, SEGM_PROT);
 #endif
-       LFS_SEGENTRY(sup, fs, SCARG(uap, segment), bp);
+       LFS_SEGENTRY(sup, fs, segnum, bp);
+       if (sup->su_nbytes) {
+               printf("lfs_segclean: not cleaning segment %lu: %d live bytes\n",
+                       segnum, sup->su_nbytes);
+               brelse(bp);
+#ifdef LFS_AGGRESSIVE_SEGLOCK
+               lfs_segunlock(fs);
+#endif
+               vfs_unbusy(mntp);
+               return (EBUSY);
+       }
        if (sup->su_flags & SEGUSE_ACTIVE) {
                brelse(bp);
 #ifdef LFS_AGGRESSIVE_SEGLOCK
@@ -922,7 +939,7 @@
        fs->lfs_avail += segtod(fs, 1);
        if (sup->su_flags & SEGUSE_SUPERBLOCK)
                fs->lfs_avail -= btofsb(fs, LFS_SBPAD);
-       if (fs->lfs_version > 1 && SCARG(uap, segment) == 0 &&
+       if (fs->lfs_version > 1 && segnum == 0 &&
            fs->lfs_start < btofsb(fs, LFS_LABELPAD))
                fs->lfs_avail -= btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
        fs->lfs_bfree += sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
@@ -1238,9 +1255,7 @@
 #endif
 #if 0
        bp->b_saveaddr = (caddr_t)fs;
-       s = splbio();
        ++fs->lfs_iocount;
-       splx(s);
 #endif
        bp->b_bufsize = size;
        bp->b_bcount = size;



Home | Main Index | Thread Index | Old Index