--- test/mm/filemap.c	Tue Jan 15 04:52:47 2002
+++ old.test/mm/filemap.c	Tue Jan 15 02:58:12 2002
@@ -2890,6 +2889,7 @@
 		int nr, struct page **pages,
 		int *nr_newp, struct page **new_pages)
 {
+	spinlock_t *lock;
 	struct page *cached_page = NULL;
 	int nr_new = 0;
 	int ret;
@@ -2900,7 +2900,8 @@
 
 	ret = 0;
 
-	spin_lock(&pagecache_lock);
+	lock = __PAGECACHE_LOCK(as, index);
+	spin_lock(lock);
 
 	while (nr > 0) {
 		struct page **hash = page_hash(as, index);
@@ -2913,6 +2914,9 @@
 			pages[ret++] = page;
 			index++;
 			nr--;
+			spin_unlock(lock);
+			lock = __PAGECACHE_LOCK(as, index);
+			spin_lock(lock);
 			continue;
 		}
 
@@ -2923,7 +2927,7 @@
 			cached_page = NULL;
 			goto got_page;
 		}
-		spin_unlock(&pagecache_lock);
+		spin_unlock(lock);
 
 		cached_page = page_cache_alloc(as);
 		if (!cached_page)
@@ -2931,10 +2935,10 @@
 
 		/* Okay, we now have an allocated page.  Retry
 		 * the search and add. */
-		spin_lock(&pagecache_lock);
+		spin_lock(lock);
 	}
 
-	spin_unlock(&pagecache_lock);
+	spin_unlock(lock);
 
 out:
 	if (cached_page)