Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 41

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.4 - expire specific submount only

From: Ian Kent <raven@themaw.net>

The submount shutdown at expire assumes that certain locks are not
held but when notifying submounts containing nested submounts not
all locks were being released. This leads to occassional deadlock
when child submounts attempt to shutdown.
---

 lib/master.c |   33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)


--- autofs-5.0.1.orig/lib/master.c
+++ autofs-5.0.1/lib/master.c
@@ -813,7 +813,6 @@ int master_notify_submount(struct autofs
 {
 	struct list_head *head, *p;
 	struct autofs_point *this = NULL;
-	size_t plen = strlen(path);
 	int ret = 1;
 
 	mounts_mutex_lock(ap);
@@ -821,37 +820,19 @@ int master_notify_submount(struct autofs
 	head = &ap->submounts;
 	p = head->prev;
 	while (p != head) {
-		size_t len;
-
 		this = list_entry(p, struct autofs_point, mounts);
 		p = p->prev;
 
 		if (!master_submount_list_empty(this)) {
-			if (!master_notify_submount(this, path, state)) {
-				ret = 0;
-				break;
-			}
+			mounts_mutex_unlock(ap);
+			return master_notify_submount(this, path, state);
 		}
 
-		len = strlen(this->path);
-
-		/* Initial path not the same */
-		if (strncmp(this->path, path, len))
+		/* path not the same */
+		if (strcmp(this->path, path))
 			continue;
 
-		/*
-		 * Part of submount tree?
-		 * We must wait till we get to submount itself.
-		 * If it is tell caller by returning true.
-		 */
-		if (plen > len) {
-			/* Not part of this directory tree */
-			if (path[len] != '/')
-				continue;
-			break;
-		}
-
-		/* Now we have a submount to expire */
+		/* Now we have found the submount we want to expire */
 
 		st_mutex_lock();
 
@@ -880,8 +861,10 @@ int master_notify_submount(struct autofs
 			struct timespec t = { 0, 300000000 };
 			struct timespec r;
 
-			if (this->state != ST_SHUTDOWN)
+			if (this->state != ST_SHUTDOWN) {
+				ret = 0;
 				break;
+			}
 
 			st_mutex_unlock();
 			mounts_mutex_unlock(ap);