Source-Changes-HG archive

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

[src/trunk]: src/sys/nfs nfs_readdirplusrpc: fix a deadlock problem.



details:   https://anonhg.NetBSD.org/src/rev/7f22cd079367
branches:  trunk
changeset: 565371:7f22cd079367
user:      yamt <yamt%NetBSD.org@localhost>
date:      Mon Apr 05 10:44:09 2004 +0000

description:
nfs_readdirplusrpc: fix a deadlock problem.
don't wait for vnode lock to load attributes.
otherwise, because READDIRPLUS returns DOTDOT entry as well,
we violate locking order.

diffstat:

 sys/nfs/nfs_node.c  |  12 ++++++++----
 sys/nfs/nfs_var.h   |   6 ++++--
 sys/nfs/nfs_vnops.c |   8 ++++----
 3 files changed, 16 insertions(+), 10 deletions(-)

diffs (93 lines):

diff -r 7d39b7bc0a75 -r 7f22cd079367 sys/nfs/nfs_node.c
--- a/sys/nfs/nfs_node.c        Mon Apr 05 10:41:45 2004 +0000
+++ b/sys/nfs/nfs_node.c        Mon Apr 05 10:44:09 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_node.c,v 1.74 2004/04/05 10:40:56 yamt Exp $       */
+/*     $NetBSD: nfs_node.c,v 1.75 2004/04/05 10:44:09 yamt Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.74 2004/04/05 10:40:56 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.75 2004/04/05 10:44:09 yamt Exp $");
 
 #include "opt_nfs.h"
 
@@ -150,11 +150,12 @@
  * nfsnode structure is returned.
  */
 int
-nfs_nget(mntp, fhp, fhsize, npp)
+nfs_nget1(mntp, fhp, fhsize, npp, lkflags)
        struct mount *mntp;
        nfsfh_t *fhp;
        int fhsize;
        struct nfsnode **npp;
+       int lkflags;
 {
        struct nfsnode *np;
        struct nfsnodehashhead *nhpp;
@@ -168,7 +169,10 @@
                    memcmp(fhp, np->n_fhp, fhsize))
                        continue;
                vp = NFSTOV(np);
-               if (vget(vp, LK_EXCLUSIVE))
+               error = vget(vp, LK_EXCLUSIVE | lkflags);
+               if (error == EBUSY)
+                       return error;
+               if (error)
                        goto loop;
                *npp = np;
                return(0);
diff -r 7d39b7bc0a75 -r 7f22cd079367 sys/nfs/nfs_var.h
--- a/sys/nfs/nfs_var.h Mon Apr 05 10:41:45 2004 +0000
+++ b/sys/nfs/nfs_var.h Mon Apr 05 10:44:09 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_var.h,v 1.42 2003/07/23 13:52:25 yamt Exp $        */
+/*     $NetBSD: nfs_var.h,v 1.43 2004/04/05 10:44:09 yamt Exp $        */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -100,7 +100,9 @@
 void nfs_nhinit __P((void));
 void nfs_nhreinit __P((void));
 void nfs_nhdone __P((void));
-int nfs_nget __P((struct mount *, nfsfh_t *, int, struct nfsnode **));
+int nfs_nget1 __P((struct mount *, nfsfh_t *, int, struct nfsnode **, int));
+#define        nfs_nget(mp, fhp, fhsize, npp) \
+       nfs_nget1((mp), (fhp), (fhsize), (npp), 0)
 
 /* nfs_vnops.c */
 int nfs_null __P((struct vnode *, struct ucred *, struct proc *));
diff -r 7d39b7bc0a75 -r 7f22cd079367 sys/nfs/nfs_vnops.c
--- a/sys/nfs/nfs_vnops.c       Mon Apr 05 10:41:45 2004 +0000
+++ b/sys/nfs/nfs_vnops.c       Mon Apr 05 10:44:09 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_vnops.c,v 1.190 2004/04/05 10:40:56 yamt Exp $     */
+/*     $NetBSD: nfs_vnops.c,v 1.191 2004/04/05 10:44:09 yamt Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.190 2004/04/05 10:40:56 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.191 2004/04/05 10:44:09 yamt Exp $");
 
 #include "opt_nfs.h"
 #include "opt_uvmhist.h"
@@ -2724,8 +2724,8 @@
                                    newvp = vp;
                                    np = dnp;
                                } else {
-                                   error = nfs_nget(vp->v_mount, fhp,
-                                       fhsize, &np);
+                                   error = nfs_nget1(vp->v_mount, fhp,
+                                       fhsize, &np, LK_NOWAIT);
                                    if (!error)
                                        newvp = NFSTOV(np);
                                }



Home | Main Index | Thread Index | Old Index