patch-2.3.11 linux/fs/buffer.c

Next file: linux/fs/exec.c
Previous file: linux/fs/binfmt_elf.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.10/linux/fs/buffer.c linux/fs/buffer.c
@@ -757,9 +757,9 @@
 
 	free = test_and_clear_bit(PG_free_after, &page->flags);
 
-	if (page->owner != -1)
+	if (page->owner != (void *)-1)
 		PAGE_BUG(page);
-	page->owner = (int)current;
+	page->owner = current;
 	UnlockPage(page);
 
 	if (free)
@@ -1195,7 +1195,7 @@
 
 	if (!PageLocked(page))
 		BUG();
-	if (page->owner != (int)current)
+	if (page->owner != current)
 		PAGE_BUG(page);
 	/*
 	 * Allocate async buffer heads pointing to this page, just for I/O.
@@ -1270,6 +1270,7 @@
 				mark_buffer_clean(bh);
 				clear_bit(BH_Uptodate, &bh->b_state);
 				clear_bit(BH_Mapped, &bh->b_state);
+				clear_bit(BH_Req, &bh->b_state);
 				bh->b_blocknr = 0;
 				atomic_dec(&bh->b_count);
 			}
@@ -1556,7 +1557,7 @@
 	}
 	if (!page->buffers)
 		BUG();
-	page->owner = -1;
+	page->owner = (void *)-1;
 
 	head = page->buffers;
 	bh = head;
@@ -1605,7 +1606,7 @@
 	} else {
 		if (!nr && rw == READ) {
 			SetPageUptodate(page);
-			page->owner = (int)current;
+			page->owner = current;
 			UnlockPage(page);
 		}
 		if (nr && (rw == WRITE))
@@ -1639,7 +1640,7 @@
 
 	blocks = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
 	iblock = page->offset >> inode->i_sb->s_blocksize_bits;
-	page->owner = -1;
+	page->owner = (void *)-1;
 	head = page->buffers;
 	bh = head;
 	nr = 0;
@@ -1674,7 +1675,7 @@
 		 * uptodate as well.
 		 */
 		SetPageUptodate(page);
-		page->owner = (int)current;
+		page->owner = current;
 		UnlockPage(page);
 	}
 	return 0;
@@ -1968,8 +1969,25 @@
 		goto out;
 
 	if (func == 1) {
-		 error = sync_old_buffers();
-		 goto out;
+		struct mm_struct *user_mm;
+		/*
+		 * bdflush will spend all of it's time in kernel-space,
+		 * without touching user-space, so we can switch it into
+		 * 'lazy TLB mode' to reduce the cost of context-switches
+		 * to and from bdflush.
+		 */
+		user_mm = current->mm;
+		atomic_inc(&user_mm->mm_count);
+		current->mm = NULL;
+		/* active_mm is still 'user_mm' */
+
+		error = sync_old_buffers();
+
+		current->mm = user_mm;
+		mmdrop(current->active_mm);
+		current->active_mm = user_mm;
+
+		goto out;
 	}
 
 	/* Basically func 1 means read param 1, 2 means write param 1, etc */

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