diff options
author | trasz <trasz@FreeBSD.org> | 2015-03-07 19:32:19 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2015-03-07 19:32:19 +0000 |
commit | 97710cbe33ec6723cc9fca56b97045a54a06e1a7 (patch) | |
tree | 5afa96ec0d4d07d8940b04369fd1954eb8a1cd56 /sys/fs/autofs/autofs.c | |
parent | daec60ce10a3358229beb0a5762a9fc19a579272 (diff) | |
download | FreeBSD-src-97710cbe33ec6723cc9fca56b97045a54a06e1a7.zip FreeBSD-src-97710cbe33ec6723cc9fca56b97045a54a06e1a7.tar.gz |
MFC r273127:
Make automountd(8) inform autofs(4) whether directory being handled can
have wildcards. This makes it possible for autofs(4) to avoid requesting
automountd(8) action on access to nonexistent nodes - unless wildcards
are actually used.
Note that this change breaks ABI for automountd(8).
MFC r278521:
Restore ABI compatibility, broken in r273127. Note that while this fixes
ABI with 10.1, it breaks ABI for 11-CURRENT, so rebuild of automountd(8)
is neccessary.
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/fs/autofs/autofs.c')
-rw-r--r-- | sys/fs/autofs/autofs.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/sys/fs/autofs/autofs.c b/sys/fs/autofs/autofs.c index 09f3c62..0393d13 100644 --- a/sys/fs/autofs/autofs.c +++ b/sys/fs/autofs/autofs.c @@ -274,6 +274,7 @@ autofs_task(void *context, int pending) * XXX: EIO perhaps? */ ar->ar_error = ETIMEDOUT; + ar->ar_wildcards = true; ar->ar_done = true; ar->ar_in_progress = false; cv_broadcast(&autofs_softc->sc_cv); @@ -291,12 +292,13 @@ autofs_cached(struct autofs_node *anp, const char *component, int componentlen) AUTOFS_ASSERT_UNLOCKED(amp); /* - * For top-level nodes we need to request automountd(8) - * assistance even if the node is marked as cached, - * but the requested subdirectory does not exist. This - * is necessary for wildcard indirect map keys to work. + * For root node we need to request automountd(8) assistance even + * if the node is marked as cached, but the requested top-level + * directory does not exist. This is necessary for wildcard indirect + * map keys to work. We don't do this if we know that there are + * no wildcards. */ - if (anp->an_parent == NULL && componentlen != 0) { + if (anp->an_parent == NULL && componentlen != 0 && anp->an_wildcards) { AUTOFS_SLOCK(amp); error = autofs_node_find(anp, component, componentlen, NULL); AUTOFS_SUNLOCK(amp); @@ -366,6 +368,7 @@ autofs_trigger_one(struct autofs_node *anp, struct autofs_request *ar; char *key, *path; int error = 0, request_error, last; + bool wildcards; amp = anp->an_mount; @@ -455,6 +458,8 @@ autofs_trigger_one(struct autofs_node *anp, ar->ar_path, request_error); } + wildcards = ar->ar_wildcards; + last = refcount_release(&ar->ar_refcount); if (last) { TAILQ_REMOVE(&autofs_softc->sc_requests, ar, ar_next); @@ -475,6 +480,7 @@ autofs_trigger_one(struct autofs_node *anp, */ if (error == 0 && request_error == 0 && autofs_cache > 0) { anp->an_cached = true; + anp->an_wildcards = wildcards; callout_reset(&anp->an_callout, autofs_cache * hz, autofs_cache_callout, anp); } @@ -577,6 +583,34 @@ autofs_ioctl_request(struct autofs_daemon_request *adr) } static int +autofs_ioctl_done_101(struct autofs_daemon_done_101 *add) +{ + struct autofs_request *ar; + + sx_xlock(&autofs_softc->sc_lock); + TAILQ_FOREACH(ar, &autofs_softc->sc_requests, ar_next) { + if (ar->ar_id == add->add_id) + break; + } + + if (ar == NULL) { + sx_xunlock(&autofs_softc->sc_lock); + AUTOFS_DEBUG("id %d not found", add->add_id); + return (ESRCH); + } + + ar->ar_error = add->add_error; + ar->ar_wildcards = true; + ar->ar_done = true; + ar->ar_in_progress = false; + cv_broadcast(&autofs_softc->sc_cv); + + sx_xunlock(&autofs_softc->sc_lock); + + return (0); +} + +static int autofs_ioctl_done(struct autofs_daemon_done *add) { struct autofs_request *ar; @@ -594,6 +628,7 @@ autofs_ioctl_done(struct autofs_daemon_done *add) } ar->ar_error = add->add_error; + ar->ar_wildcards = add->add_wildcards; ar->ar_done = true; ar->ar_in_progress = false; cv_broadcast(&autofs_softc->sc_cv); @@ -650,6 +685,9 @@ autofs_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode, case AUTOFSREQUEST: return (autofs_ioctl_request( (struct autofs_daemon_request *)arg)); + case AUTOFSDONE101: + return (autofs_ioctl_done_101( + (struct autofs_daemon_done_101 *)arg)); case AUTOFSDONE: return (autofs_ioctl_done( (struct autofs_daemon_done *)arg)); |