checkpoint
[unix-history] / usr / src / sys / miscfs / union / union_vfsops.c
index dfd9791..85d1957 100644 (file)
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)union_vfsops.c      1.1 (Berkeley) %G%
+ *     @(#)union_vfsops.c      1.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -161,10 +161,14 @@ union_unmount(mp, mntflags, p)
 
        if (error = union_root(mp, &um_rootvp))
                return (error);
 
        if (error = union_root(mp, &um_rootvp))
                return (error);
-       if (um_rootvp->v_usecount > 1)
+       if (um_rootvp->v_usecount > 1) {
+               vput(um_rootvp);
                return (EBUSY);
                return (EBUSY);
-       if (error = vflush(mp, um_rootvp, flags))
+       }
+       if (error = vflush(mp, um_rootvp, flags)) {
+               vput(um_rootvp);
                return (error);
                return (error);
+       }
 
 #ifdef UNION_DIAGNOSTIC
        vprint("alias root of lower", um_rootvp);
 
 #ifdef UNION_DIAGNOSTIC
        vprint("alias root of lower", um_rootvp);
@@ -178,7 +182,7 @@ union_unmount(mp, mntflags, p)
        /*
         * Release reference on underlying root vnode
         */
        /*
         * Release reference on underlying root vnode
         */
-       vrele(um_rootvp);
+       vput(um_rootvp);
        /*
         * And blow it away for future re-use
         */
        /*
         * And blow it away for future re-use
         */
@@ -208,12 +212,21 @@ union_root(mp, vpp)
        /*
         * Return locked reference to root.
         */
        /*
         * Return locked reference to root.
         */
-       error = union_allocvp(vpp, mp, (struct vnode *) 0,
+       VREF(um->um_uppervp);
+       VREF(um->um_lowervp);
+       error = union_allocvp(vpp, mp,
+                             (struct vnode *) 0,
+                             (struct vnode *) 0,
                              (struct componentname *) 0,
                              um->um_uppervp,
                              um->um_lowervp);
                              (struct componentname *) 0,
                              um->um_uppervp,
                              um->um_lowervp);
-       if (error == 0)
+
+       if (error) {
+               vrele(um->um_uppervp);
+               vrele(um->um_lowervp);
+       } else {
                (*vpp)->v_flag |= VROOT;
                (*vpp)->v_flag |= VROOT;
+       }
 
        return (error);
 }
 
        return (error);
 }