Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/ufs/lfs Pull-up of changes made to the trunk on Sun...



details:   https://anonhg.NetBSD.org/src/rev/3f810419f24e
branches:  netbsd-1-4
changeset: 468214:3f810419f24e
user:      perseant <perseant%NetBSD.org@localhost>
date:      Tue Apr 13 21:33:56 1999 +0000

description:
Pull-up of changes made to the trunk on Sunday [1.27-1.28], to wit:

Take out the `#ifdef USE_UFSHASH'; use ufs_hashlock to lock the inode free
list instead of free_lock.

Fix inode reporting in lfs_statfs (the meaning of f_files and f_ffree was
reversed).

Fix "lfs_ifind: dinode xxx not found" panic.  When inodes were freed, then
immediately reloaded, their dinodes were located in an inode block which
was not on disk at the advertized location, nor in the cache (although it
would be flushed to disk next segment write).  Fix this by using getblk()
instead of lfs_newbuf() for inode blocks.

Better checking for held inode locks in lfs_fastvget, for a number of
error conditions.  Also change the default setting of lfs_clean_vnhead to
0, which seems to make the locking problems go away (although this is
difficult to test as I can't reliably reproduce them).

Make sure that the wakeup occurs for vnodes that lfs_update might be
sleeping on (nodes which are not marked IN_MODIFIED/IN_CLEANING, but which
have dirty buffers), by marking them with the appropriate flag if
dirtybuffers were added while the write was in progress.

Fix block counting during file truncation, if not truncating to zero.

Disallow threshold-initiated cache flush when dirops are active.  Also,
make SET_ENDOP use lfs_check instead of inlining most of it.

Improve the debugging printfs in the cleaner syscalls (in particular, make
it obvious that they're coming from lfs).

Check the superblock version field, and refuse to mount the filesystem if
the version number is higher than we know about.  This allows, e.g.,
changes in the format of the ifile, segment size restrictions and
boundaries, etc., which would not affect existing fields in the
superblock, but which would drastically affect the filesystem, to be
smoothly integrated at a later date.

diffstat:

 sys/ufs/lfs/lfs_syscalls.c |  44 +++++++++++++++++++-------------------------
 1 files changed, 19 insertions(+), 25 deletions(-)

diffs (174 lines):

diff -r 91d8ac09e89a -r 3f810419f24e sys/ufs/lfs/lfs_syscalls.c
--- a/sys/ufs/lfs/lfs_syscalls.c        Tue Apr 13 21:33:55 1999 +0000
+++ b/sys/ufs/lfs/lfs_syscalls.c        Tue Apr 13 21:33:56 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_syscalls.c,v 1.26 1999/03/29 22:13:07 perseant Exp $       */
+/*     $NetBSD: lfs_syscalls.c,v 1.26.2.1 1999/04/13 21:33:56 perseant Exp $   */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -218,6 +218,9 @@
        lastino = LFS_UNUSED_INUM;
        for (blkp = start; cnt--; ++blkp)
        {
+               if(blkp->bi_daddr == LFS_FORCE_WRITE)
+                       printf("lfs_markv: warning: force-writing ino %d lbn %d\n",
+                              blkp->bi_inode, blkp->bi_lbn);
 #ifdef LFS_TRACK_IOS
                /*
                 * If there is I/O on this segment that is not yet complete,
@@ -297,7 +300,7 @@
                        }
                        if(error) {
 #ifdef DIAGNOSTIC
-                               printf("lfs_markv: VFS_VGET failed with %d (ino %d, segment %d)\n", 
+                               printf("lfs_markv: lfs_fastvget failed with %d (ino %d, segment %d)\n", 
                                       error, blkp->bi_inode,
                                       datosn(fs, blkp->bi_daddr));
 #endif /* DIAGNOSTIC */
@@ -366,7 +369,7 @@
                                if(datosn(fs,b_daddr)
                                   == datosn(fs,blkp->bi_daddr))
                                {
-                                       printf("Wrong da same seg: %x vs %x\n",
+                                       printf("lfs_markv: wrong da same seg: %x vs %x\n",
                                               blkp->bi_daddr, b_daddr);
                                }
                                continue;
@@ -468,7 +471,7 @@
        return 0;
        
  err2:
-       printf("markv err2\n");
+       printf("lfs_markv err2\n");
        lfs_vunref(vp);
        /* Free up fakebuffers -- have to take these from the LOCKED list */
  again:
@@ -493,7 +496,7 @@
        return (error);
        
  err1: 
-       printf("markv err1\n");
+       printf("lfs_markv err1\n");
        free(start, M_SEGMENT);
        return (error);
 }
@@ -567,7 +570,7 @@
        {
 #ifdef DEBUG
                if (datosn(fs, fs->lfs_curseg) == datosn(fs, blkp->bi_daddr)) {
-                       printf("Hm, attempt to clean current segment? (#%d)\n",
+                       printf("lfs_bmapv: attempt to clean current segment? (#%d)\n",
                               datosn(fs, fs->lfs_curseg));
                        free(start,M_SEGMENT);
                        return (EBUSY);
@@ -633,7 +636,7 @@
                        if (vp != NULL && !(vp->v_flag & VXLOCK)) {
                                ip = VTOI(vp);
                                if(VOP_ISLOCKED(vp)) {
-                                       /* printf("inode %d inlocked in bmapv\n",ip->i_number); */
+                                       /* printf("lfs_bmapv: inode %d inlocked\n",ip->i_number); */
                                        need_unlock = 0;
                                } else {
                                        VOP_LOCK(vp,LK_EXCLUSIVE);
@@ -875,9 +878,7 @@
  * In either case we lfs_vref, and it is the caller's responsibility to
  * lfs_vunref and VOP_UNLOCK (if necessary) when finished.
  */
-#ifdef USE_UFS_HASHLOCK
 extern struct lock ufs_hashlock;
-#endif
 
 int
 lfs_fastvget(mp, ino, daddr, vpp, dinp, need_unlock)
@@ -903,24 +904,19 @@
         * locked, in which case they are going to be distinctly unhappy
         * if we trash something.
         */
-#ifdef USE_UFS_HASHLOCK
        do {
-#endif
                if ((*vpp = ufs_ihashlookup(dev, ino)) != NULL) {
-                       lfs_vref(*vpp);
                        if ((*vpp)->v_flag & VXLOCK) {
-                               printf("vnode VXLOCKed for ino %d\n",ino);
+                               printf("lfs_fastvget: vnode VXLOCKed for ino %d\n",ino);
                                clean_vnlocked++;
 #ifdef LFS_EAGAIN_FAIL
-#if 0 /* XXXX KS */
-                               lfs_vunref(*vpp);
-#endif
                                return EAGAIN;
 #endif
                        }
                        ip = VTOI(*vpp);
+                       lfs_vref(*vpp);
                        if (VOP_ISLOCKED(*vpp)) {
-                               printf("ino %d inlocked by pid %d\n",ip->i_number,
+                               printf("lfs_fastvget: ino %d inlocked by pid %d\n",ip->i_number,
                                       ip->i_lock.lk_lockholder);
                                clean_inlocked++;
 #ifdef LFS_EAGAIN_FAIL
@@ -933,16 +929,12 @@
                        }
                        return (0);
                }
-#ifdef USE_UFS_HASHLOCK
        } while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
-#endif
 
        /* Allocate new vnode/inode. */
        if ((error = lfs_vcreate(mp, ino, &vp)) != 0) {
                *vpp = NULL;
-#ifdef USE_UFS_HASHLOCK
                lockmgr(&ufs_hashlock, LK_RELEASE, 0);
-#endif
                return (error);
        }
        /*
@@ -953,9 +945,7 @@
         */
        ip = VTOI(vp);
        ufs_ihashins(ip);
-#ifdef USE_UFS_HASHLOCK
        lockmgr(&ufs_hashlock, LK_RELEASE, 0);
-#endif
        
        /*
         * XXX
@@ -973,6 +963,7 @@
                        ufs_ihashrem(ip);
 
                        /* Unlock and discard unneeded inode. */
+                       lockmgr(&ip->i_lock, LK_RELEASE, &vp->v_interlock);
                        lfs_vunref(vp);
                        *vpp = NULL;
                        return (error);
@@ -983,7 +974,7 @@
                error = bread(ump->um_devvp, daddr,
                              (int)ump->um_lfs->lfs_bsize, NOCRED, &bp);
                if (error) {
-                       printf("error != 0 at %s:%d\n",__FILE__,__LINE__);
+                       printf("lfs_fastvget: bread failed with %d\n",error);
                        /*
                         * The inode does not contain anything useful, so it
                         * would be misleading to leave it on its hash chain.
@@ -992,6 +983,7 @@
                        ufs_ihashrem(ip);
                        
                        /* Unlock and discard unneeded inode. */
+                       lockmgr(&ip->i_lock, LK_RELEASE, &vp->v_interlock);
                        lfs_vunref(vp);
                        brelse(bp);
                        *vpp = NULL;
@@ -1008,7 +1000,9 @@
         */
        error = ufs_vinit(mp, lfs_specop_p, lfs_fifoop_p, &vp);
        if (error) {
-               printf("ufs_vinit returned %d for ino %d\n", error, ino);
+               /* This CANNOT happen (see ufs_vinit) */
+               printf("lfs_fastvget: ufs_vinit returned %d for ino %d\n", error, ino);
+               lockmgr(&ip->i_lock, LK_RELEASE, &vp->v_interlock);
                lfs_vunref(vp);
                *vpp = NULL;
                return (error);



Home | Main Index | Thread Index | Old Index