Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ufs Avoid nasal demons. Code of the form



details:   https://anonhg.NetBSD.org/src/rev/0d0f9ad852a5
branches:  trunk
changeset: 747711:0d0f9ad852a5
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Sep 28 00:39:03 2009 +0000

description:
Avoid nasal demons. Code of the form

   vput(vp);
   error = VFS_VGET(vp->v_mount, ...);

just isn't right. Because of vnode caching this *probably* never bit
anyone, except maybe under very heavy load, but still.

diffstat:

 sys/ufs/ufs/ufs_lookup.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r df4c35d6ef1d -r 0d0f9ad852a5 sys/ufs/ufs/ufs_lookup.c
--- a/sys/ufs/ufs/ufs_lookup.c  Sun Sep 27 22:02:41 2009 +0000
+++ b/sys/ufs/ufs/ufs_lookup.c  Mon Sep 28 00:39:03 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_lookup.c,v 1.101 2009/02/22 20:28:07 ad Exp $      */
+/*     $NetBSD: ufs_lookup.c,v 1.102 2009/09/28 00:39:03 dholland Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.101 2009/02/22 20:28:07 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.102 2009/09/28 00:39:03 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -1176,7 +1176,7 @@
 int
 ufs_checkpath(struct inode *source, struct inode *target, kauth_cred_t cred)
 {
-       struct vnode *vp = ITOV(target);
+       struct vnode *nextvp, *vp;
        int error, rootino, namlen;
        struct dirtemplate dirbuf;
        const int needswap = UFS_MPNEEDSWAP(target->i_ump);
@@ -1224,13 +1224,15 @@
                }
                if (ufs_rw32(dirbuf.dotdot_ino, needswap) == rootino)
                        break;
-               vput(vp);
+               VOP_UNLOCK(vp, 0);
                error = VFS_VGET(vp->v_mount,
-                   ufs_rw32(dirbuf.dotdot_ino, needswap), &vp);
+                   ufs_rw32(dirbuf.dotdot_ino, needswap), &nextvp);
+               vrele(vp);
                if (error) {
                        vp = NULL;
                        break;
                }
+               vp = nextvp;
        }
 
 out:



Home | Main Index | Thread Index | Old Index