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/ufs Pull up revision 1.61 (requested by wrstuden):



details:   https://anonhg.NetBSD.org/src/rev/3c6176f2c00c
branches:  netbsd-1-4
changeset: 469866:3c6176f2c00c
user:      he <he%NetBSD.org@localhost>
date:      Thu Dec 16 23:11:46 1999 +0000

description:
Pull up revision 1.61 (requested by wrstuden):
  Fix PR#8491: two simultaneous and identical renames would cause
  a kernel panic.

diffstat:

 sys/ufs/ufs/ufs_vnops.c |  33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diffs (87 lines):

diff -r 66897f2e8ceb -r 3c6176f2c00c sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c   Thu Dec 16 23:06:15 1999 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c   Thu Dec 16 23:11:46 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_vnops.c,v 1.57 1999/03/24 05:51:31 mrg Exp $       */
+/*     $NetBSD: ufs_vnops.c,v 1.57.2.1 1999/12/16 23:11:46 he Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993, 1995
@@ -839,14 +839,14 @@
                vput(tvp);
 
                /* Delete source. */
-               vrele(fdvp);
                vrele(fvp);
-               fcnp->cn_flags &= ~MODMASK;
+               fcnp->cn_flags &= ~(MODMASK | SAVESTART);
                fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
-               if ((fcnp->cn_flags & SAVESTART) == 0)
-                       panic("ufs_rename: lost from startdir");
                fcnp->cn_nameiop = DELETE;
-               (void) relookup(fdvp, &fvp, fcnp);
+               if ((error = relookup(fdvp, &fvp, fcnp))){
+                       /* relookup blew away fdvp */
+                       return (error);
+               }
                return (VOP_REMOVE(fdvp, fvp, fcnp));
        }
        if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0)
@@ -881,7 +881,7 @@
                oldparent = dp->i_number;
                doingdirectory++;
        }
-       vrele(fdvp);
+       /* vrele(fdvp); */
 
        /*
         * When the target exists, both the directory
@@ -924,10 +924,12 @@
                        goto bad;
                if (xp != NULL)
                        vput(tvp);
-               if ((error = ufs_checkpath(ip, dp, tcnp->cn_cred)) != 0)
+               vref(tdvp);     /* compensate for the ref checkpath looses */
+               if ((error = ufs_checkpath(ip, dp, tcnp->cn_cred)) != 0) {
+                       vrele(tdvp);
                        goto out;
-               if ((tcnp->cn_flags & SAVESTART) == 0)
-                       panic("ufs_rename: lost to startdir");
+               }
+               tcnp->cn_flags &= ~SAVESTART;
                if ((error = relookup(tdvp, &tvp, tcnp)) != 0)
                        goto out;
                dp = VTOI(tdvp);
@@ -1047,11 +1049,12 @@
        /*
         * 3) Unlink the source.
         */
-       fcnp->cn_flags &= ~MODMASK;
+       fcnp->cn_flags &= ~(MODMASK | SAVESTART);
        fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
-       if ((fcnp->cn_flags & SAVESTART) == 0)
-               panic("ufs_rename: lost from startdir");
-       (void) relookup(fdvp, &fvp, fcnp);
+       if ((error = relookup(fdvp, &fvp, fcnp))) {
+               vrele(ap->a_fvp);
+               return (error);
+       }
        if (fvp != NULL) {
                xp = VTOI(fvp);
                dp = VTOI(fdvp);
@@ -1138,6 +1141,7 @@
        vrele(ap->a_fvp);
        return (error);
 
+       /* exit routines from steps 1 & 2 */
 bad:
        if (xp)
                vput(ITOV(xp));
@@ -1151,6 +1155,7 @@
                vput(fvp);
        } else
                vrele(fvp);
+       vrele(fdvp);
        return (error);
 }
 



Home | Main Index | Thread Index | Old Index