patch-2.3.17 linux/mm/filemap.c

Next file: linux/mm/mmap.c
Previous file: linux/kernel/sys.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.16/linux/mm/filemap.c linux/mm/filemap.c
@@ -1303,7 +1303,7 @@
 	struct dentry * dentry = file->f_dentry;
 	struct inode * inode = dentry->d_inode;
 	struct page * page, **hash;
-	unsigned long old_page, new_page = 0;
+	unsigned long old_page;
 
 	unsigned long offset = address - area->vm_start + area->vm_offset;
 
@@ -1339,18 +1339,19 @@
 	 * and possibly copy it over to another page..
 	 */
 	old_page = page_address(page);
-	if (!no_share) {
-		flush_page_to_ram(old_page);
-		return old_page;
-	}
+	if (no_share) {
+		unsigned long new_page = page_cache_alloc();
 
-	new_page = page_cache_alloc();
-	if (new_page) {
-		copy_page(new_page, old_page);
-		flush_page_to_ram(new_page);
-	}
-	page_cache_release(page);
-	return new_page;
+		if (new_page) {
+			copy_page(new_page, old_page);
+			flush_page_to_ram(new_page);
+		}
+		page_cache_release(page);
+		return new_page;
+	}
+		
+	flush_page_to_ram(old_page);
+	return old_page;
 
 no_cached_page:
 	/*
@@ -1408,8 +1409,6 @@
 	 * mm layer so, possibly freeing the page cache page first.
 	 */
 	page_cache_release(page);
-	if (new_page)
-		page_cache_free(new_page);
 	return 0;
 }
 

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