summaryrefslogtreecommitdiffstats
path: root/sys/fs/autofs
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2014-10-15 09:28:45 +0000
committertrasz <trasz@FreeBSD.org>2014-10-15 09:28:45 +0000
commit1687a6636a8d7f8fb6caea9f4fb08d2fc1c00e87 (patch)
tree8c5710ac13bd44c30a67c2ecf3060bbf6453b873 /sys/fs/autofs
parent9be332cf608782a9676fabe18d0f97094c9c9dc9 (diff)
downloadFreeBSD-src-1687a6636a8d7f8fb6caea9f4fb08d2fc1c00e87.zip
FreeBSD-src-1687a6636a8d7f8fb6caea9f4fb08d2fc1c00e87.tar.gz
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). Tested by: dhw@ MFC after: 1 month Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/fs/autofs')
-rw-r--r--sys/fs/autofs/autofs.c17
-rw-r--r--sys/fs/autofs/autofs.h2
-rw-r--r--sys/fs/autofs/autofs_ioctl.h6
3 files changed, 20 insertions, 5 deletions
diff --git a/sys/fs/autofs/autofs.c b/sys/fs/autofs/autofs.c
index a2aa6c1..029d254 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;
@@ -450,6 +453,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);
@@ -470,6 +475,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);
}
@@ -584,6 +590,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);
diff --git a/sys/fs/autofs/autofs.h b/sys/fs/autofs/autofs.h
index dc33eef..6ea198c 100644
--- a/sys/fs/autofs/autofs.h
+++ b/sys/fs/autofs/autofs.h
@@ -74,6 +74,7 @@ struct autofs_node {
struct vnode *an_vnode;
struct sx an_vnode_lock;
bool an_cached;
+ bool an_wildcards;
struct callout an_callout;
int an_retries;
struct timespec an_ctime;
@@ -97,6 +98,7 @@ struct autofs_request {
int ar_id;
bool ar_done;
int ar_error;
+ bool ar_wildcards;
bool ar_in_progress;
char ar_from[MAXPATHLEN];
char ar_path[MAXPATHLEN];
diff --git a/sys/fs/autofs/autofs_ioctl.h b/sys/fs/autofs/autofs_ioctl.h
index 8d03ef7..328dd9c 100644
--- a/sys/fs/autofs/autofs_ioctl.h
+++ b/sys/fs/autofs/autofs_ioctl.h
@@ -78,6 +78,12 @@ struct autofs_daemon_done {
int add_id;
/*
+ * Set to 1 if the map may contain wildcard entries;
+ * otherwise autofs will do negative caching.
+ */
+ int add_wildcards;
+
+ /*
* Error number, possibly returned to userland.
*/
int add_error;
OpenPOWER on IntegriCloud