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 revision 1.26 (requested by perseant):



details:   https://anonhg.NetBSD.org/src/rev/45221fbd48b8
branches:  netbsd-1-4
changeset: 469888:45221fbd48b8
user:      he <he%NetBSD.org@localhost>
date:      Fri Dec 17 23:53:41 1999 +0000

description:
Pull up revision 1.26 (requested by perseant):
  Address locking protocol error for inode hash, and make the
  maximum number of active dirops a global quantity.

diffstat:

 sys/ufs/lfs/lfs_alloc.c |  20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (68 lines):

diff -r 03f1a414cff9 -r 45221fbd48b8 sys/ufs/lfs/lfs_alloc.c
--- a/sys/ufs/lfs/lfs_alloc.c   Fri Dec 17 23:53:17 1999 +0000
+++ b/sys/ufs/lfs/lfs_alloc.c   Fri Dec 17 23:53:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_alloc.c,v 1.18.2.4 1999/09/03 08:57:52 he Exp $    */
+/*     $NetBSD: lfs_alloc.c,v 1.18.2.5 1999/12/17 23:53:41 he Exp $    */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -117,16 +117,16 @@
        ino_t new_ino;
        u_long i, max;
        int error;
+       extern int lfs_dirvcount;
 
        fs = VTOI(ap->a_pvp)->i_lfs;
        
        /*
-        * Prevent a race getting lfs_free - XXX - KS
-        * (this should be a proper lock, in struct lfs)
+        * Prevent a race getting lfs_free.  We use
+        * the ufs_hashlock here because we need that anyway for
+        * the hash insertion later.
         */
-
-       while(lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0))
-               ;
+       lockmgr(&ufs_hashlock, LK_EXCLUSIVE, 0);
 
        /* Get the head of the freelist. */
        new_ino = fs->lfs_free;
@@ -184,7 +184,6 @@
                        return (error);
                }
        }
-       lockmgr(&ufs_hashlock, LK_RELEASE, 0);
 
 #ifdef DIAGNOSTIC
        if(fs->lfs_free == LFS_UNUSED_INUM)
@@ -192,8 +191,10 @@
 #endif /* DIAGNOSTIC */
        
        /* Create a vnode to associate with the inode. */
-       if ((error = lfs_vcreate(ap->a_pvp->v_mount, new_ino, &vp)) != 0)
+       if ((error = lfs_vcreate(ap->a_pvp->v_mount, new_ino, &vp)) != 0) {
+               lockmgr(&ufs_hashlock, LK_RELEASE, 0);
                return (error);
+       }
        
        ip = VTOI(vp);
        /* Zero out the direct and indirect block addresses. */
@@ -205,6 +206,7 @@
        
        /* Insert into the inode hash table. */
        ufs_ihashins(ip);
+       lockmgr(&ufs_hashlock, LK_RELEASE, 0);
        
        error = ufs_vinit(vp->v_mount, lfs_specop_p, lfs_fifoop_p, &vp);
        if (error) {
@@ -216,7 +218,7 @@
        *ap->a_vpp = vp;
        if(!(vp->v_flag & VDIROP)) {
                lfs_vref(vp);
-               ++fs->lfs_dirvcount;
+               ++lfs_dirvcount;
        }
        vp->v_flag |= VDIROP;
        VREF(ip->i_devvp);



Home | Main Index | Thread Index | Old Index