Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/puffs Fix a race condition where the filesystem looku...



details:   https://anonhg.NetBSD.org/src/rev/8fafe1a09419
branches:  trunk
changeset: 772866:8fafe1a09419
user:      manu <manu%NetBSD.org@localhost>
date:      Thu Jan 19 08:14:41 2012 +0000

description:
Fix a race condition where the filesystem lookups a vnode that is
being recycled, producing ENOENT while the file does exist.

Approved by yamt

diffstat:

 sys/fs/puffs/puffs_node.c |  21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diffs (58 lines):

diff -r a2f5dd61bb09 -r 8fafe1a09419 sys/fs/puffs/puffs_node.c
--- a/sys/fs/puffs/puffs_node.c Thu Jan 19 07:38:05 2012 +0000
+++ b/sys/fs/puffs/puffs_node.c Thu Jan 19 08:14:41 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_node.c,v 1.22 2011/10/19 01:39:29 manu Exp $     */
+/*     $NetBSD: puffs_node.c,v 1.23 2012/01/19 08:14:41 manu Exp $     */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.22 2011/10/19 01:39:29 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.23 2012/01/19 08:14:41 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/hash.h>
@@ -321,8 +321,14 @@
        if (vp) {
                mutex_enter(vp->v_interlock);
                mutex_exit(&pmp->pmp_lock);
-               if (vget(vp, 0) == 0)
+               switch (vget(vp, 0)) {
+               case ENOENT:
+                       goto retry;
+               case 0:
                        return 0;
+               default:
+                       break;
+               }
        } else
                mutex_exit(&pmp->pmp_lock);
 
@@ -387,6 +393,7 @@
                return 0;
        }
 
+ retry:
        mutex_enter(&pmp->pmp_lock);
        pnode = puffs_cookie2pnode(pmp, ck);
        if (pnode == NULL) {
@@ -406,8 +413,14 @@
        vgetflags = 0;
        if (lock)
                vgetflags |= LK_EXCLUSIVE;
-       if ((rv = vget(vp, vgetflags)))
+       switch (rv = vget(vp, vgetflags)) {
+       case ENOENT:
+               goto retry;
+       case 0:
+               break;
+       default:
                return rv;
+       }
 
        *vpp = vp;
        return 0;



Home | Main Index | Thread Index | Old Index