summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_lookup.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2016-03-12 07:54:42 +0000
committertrasz <trasz@FreeBSD.org>2016-03-12 07:54:42 +0000
commitfaec271eeb32354a7197494b5b1b6ebf76fa9fe5 (patch)
tree356e34e2718bdff932d4944afc16befc22b14933 /sys/kern/vfs_lookup.c
parent8313320e6ece61884835ebe7679de2975aed3909 (diff)
downloadFreeBSD-src-faec271eeb32354a7197494b5b1b6ebf76fa9fe5.zip
FreeBSD-src-faec271eeb32354a7197494b5b1b6ebf76fa9fe5.tar.gz
Fix autofs triggering problem. Assume you have an NFS server,
192.168.1.1, with share "share". This commit fixes a problem where "mkdir /net/192.168.1.1/share/meh" would return spurious error instead of creating the directory if the target filesystem wasn't mounted yet; subsequent attempts would work correctly. The failure scenario is kind of complicated to explain, but it all boils down to calling VOP_MKDIR() for the target filesystem (NFS) with wrong dvp - the autofs vnode instead of the filesystem root mounted over it. Reviewed by: kib@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D5442
Diffstat (limited to 'sys/kern/vfs_lookup.c')
-rw-r--r--sys/kern/vfs_lookup.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 9a2a1db..536dfbc 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -495,6 +495,7 @@ lookup(struct nameidata *ndp)
int rdonly; /* lookup read-only flag bit */
int error = 0;
int dpunlocked = 0; /* dp has already been unlocked */
+ int relookup = 0; /* do not consume the path component */
struct componentname *cnp = &ndp->ni_cnd;
int lkflags_save;
int ni_dvp_unlocked;
@@ -745,6 +746,14 @@ unionlookup:
goto unionlookup;
}
+ if (error == ERELOOKUP) {
+ vref(dp);
+ ndp->ni_vp = dp;
+ error = 0;
+ relookup = 1;
+ goto good;
+ }
+
if (error != EJUSTRETURN)
goto bad;
/*
@@ -777,6 +786,8 @@ unionlookup:
goto success;
} else
cnp->cn_lkflags = lkflags_save;
+
+good:
#ifdef NAMEI_DIAGNOSTIC
printf("found\n");
#endif
@@ -856,6 +867,14 @@ nextname:
*/
KASSERT((cnp->cn_flags & ISLASTCN) || *ndp->ni_next == '/',
("lookup: invalid path state."));
+ if (relookup) {
+ relookup = 0;
+ if (ndp->ni_dvp != dp)
+ vput(ndp->ni_dvp);
+ else
+ vrele(ndp->ni_dvp);
+ goto dirloop;
+ }
if (*ndp->ni_next == '/') {
cnp->cn_nameptr = ndp->ni_next;
while (*cnp->cn_nameptr == '/') {
OpenPOWER on IntegriCloud