Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern description:
details: https://anonhg.NetBSD.org/src/rev/1a7cade4c535
branches: trunk
changeset: 764084:1a7cade4c535
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Apr 11 02:20:00 2011 +0000
description:
description:
Simplify refcount handling/cleanup in three places.
diffstat:
sys/kern/vfs_lookup.c | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
diffs (90 lines):
diff -r 4feb0fa6eb2d -r 1a7cade4c535 sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c Mon Apr 11 02:19:42 2011 +0000
+++ b/sys/kern/vfs_lookup.c Mon Apr 11 02:20:00 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_lookup.c,v 1.169 2011/04/11 02:19:42 dholland Exp $ */
+/* $NetBSD: vfs_lookup.c,v 1.170 2011/04/11 02:20:00 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.169 2011/04/11 02:19:42 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.170 2011/04/11 02:20:00 dholland Exp $");
#include "opt_magiclinks.h"
@@ -1228,12 +1228,13 @@
* matches that returned for "/" and loop
* forever. So convert it to the real root.
*/
- if (searchdir == foundobj)
- vrele(foundobj);
- else
- if (searchdir != NULL)
+ if (searchdir != NULL) {
+ if (searchdir == foundobj)
+ vrele(searchdir);
+ else
vput(searchdir);
- searchdir = NULL;
+ searchdir = NULL;
+ }
vput(foundobj);
foundobj = ndp->ni_rootdir;
vref(foundobj);
@@ -1249,6 +1250,15 @@
if (cnp->cn_nameiop != LOOKUP &&
(searchdir == NULL ||
searchdir->v_mount != foundobj->v_mount)) {
+ if (searchdir) {
+ vput(searchdir);
+ }
+ vput(foundobj);
+ foundobj = NULL;
+ ndp->ni_dvp = NULL;
+ ndp->ni_vp = NULL;
+ state->attempt_retry = 1;
+
switch (cnp->cn_nameiop) {
case CREATE:
error = EEXIST;
@@ -1260,14 +1270,6 @@
default:
KASSERT(0);
}
- if (searchdir) {
- vput(searchdir);
- }
- vput(foundobj);
- foundobj = NULL;
- ndp->ni_dvp = NULL;
- ndp->ni_vp = NULL;
- state->attempt_retry = 1;
return (error);
}
@@ -1278,12 +1280,16 @@
if (state->rdonly &&
(cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) {
error = EROFS;
- if (foundobj != searchdir) {
- vput(foundobj);
+ if (searchdir) {
+ if (foundobj != searchdir) {
+ vput(searchdir);
+ } else {
+ vrele(searchdir);
+ }
+ searchdir = NULL;
}
- if (searchdir) {
- vput(searchdir);
- }
+ vput(foundobj);
+ foundobj = NULL;
ndp->ni_dvp = NULL;
ndp->ni_vp = NULL;
state->attempt_retry = 1;
Home |
Main Index |
Thread Index |
Old Index