patch-2.4.0-test3 linux/fs/autofs4/expire.c

Next file: linux/fs/autofs4/root.c
Previous file: linux/fs/autofs/root.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test2/linux/fs/autofs4/expire.c linux/fs/autofs4/expire.c
@@ -22,6 +22,7 @@
 	struct list_head *next;
 	int count;
 
+	spin_lock(&dcache_lock);
 	count = atomic_read(&mnt->mnt_count);
 repeat:
 	next = this_parent->mnt_mounts.next;
@@ -38,8 +39,10 @@
 			goto repeat;
 		}
 		/* root is busy if any leaf is busy */
-		if (atomic_read(&p->mnt_count) > 1)
+		if (atomic_read(&p->mnt_count) > 1) {
+			spin_unlock(&dcache_lock);
 			return 1;
+		}
 	}
 	/*
 	 * All done at this level ... ascend and resume the search.
@@ -49,6 +52,7 @@
 		this_parent = this_parent->mnt_parent;
 		goto resume;
 	}
+	spin_unlock(&dcache_lock);
 
 	DPRINTK(("is_tree_busy: count=%d\n", count));
 	return count != 0; /* remaining users? */
@@ -77,6 +81,7 @@
 
 	timeout = sbi->exp_timeout;
 
+	spin_lock(&dcache_lock);
 	for(tmp = root->d_subdirs.next;
 	    tmp != &root->d_subdirs; 
 	    tmp = tmp->next) {
@@ -110,6 +115,7 @@
 		}
 		p = mntget(mnt);
 		d = dget(dentry);
+		spin_unlock(&dcache_lock);
 		while(d_mountpoint(d) && follow_down(&p, &d))
 			;
 
@@ -119,13 +125,17 @@
 			DPRINTK(("autofs_expire: returning %p %.*s\n",
 				 dentry, dentry->d_name.len, dentry->d_name.name));
 			/* Start from here next time */
+			spin_lock(&dcache_lock);
 			list_del(&root->d_subdirs);
 			list_add(&root->d_subdirs, &dentry->d_child);
+			spin_unlock(&dcache_lock);
 			return dentry;
 		}
 		dput(d);
 		mntput(p);
+		spin_lock(&dcache_lock);
 	}
+	spin_unlock(&dcache_lock);
 
 	return NULL;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)