summaryrefslogtreecommitdiffstats
path: root/sys/fs/autofs
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-03-07 19:32:19 +0000
committertrasz <trasz@FreeBSD.org>2015-03-07 19:32:19 +0000
commit97710cbe33ec6723cc9fca56b97045a54a06e1a7 (patch)
tree5afa96ec0d4d07d8940b04369fd1954eb8a1cd56 /sys/fs/autofs
parentdaec60ce10a3358229beb0a5762a9fc19a579272 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/fs/autofs/autofs.c48
-rw-r--r--sys/fs/autofs/autofs.h2
-rw-r--r--sys/fs/autofs/autofs_ioctl.h29
3 files changed, 73 insertions, 6 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));
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..92d7314 100644
--- a/sys/fs/autofs/autofs_ioctl.h
+++ b/sys/fs/autofs/autofs_ioctl.h
@@ -71,6 +71,21 @@ struct autofs_daemon_request {
char adr_options[MAXPATHLEN];
};
+/*
+ * Compatibility with 10.1-RELEASE automountd(8).
+ */
+struct autofs_daemon_done_101 {
+ /*
+ * Identifier, copied from adr_id.
+ */
+ int add_id;
+
+ /*
+ * Error number, possibly returned to userland.
+ */
+ int add_error;
+};
+
struct autofs_daemon_done {
/*
* Identifier, copied from adr_id.
@@ -78,12 +93,24 @@ 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;
+
+ /*
+ * Reserved for future use.
+ */
+ int add_spare[7];
};
#define AUTOFSREQUEST _IOR('I', 0x01, struct autofs_daemon_request)
-#define AUTOFSDONE _IOW('I', 0x02, struct autofs_daemon_done)
+#define AUTOFSDONE101 _IOW('I', 0x02, struct autofs_daemon_done_101)
+#define AUTOFSDONE _IOW('I', 0x03, struct autofs_daemon_done)
#endif /* !AUTOFS_IOCTL_H */
OpenPOWER on IntegriCloud