patch-2.2.16 linux/mm/page_io.c

Next file: linux/mm/vmscan.c
Previous file: linux/mm/page_alloc.c
Back to the patch index
Back to the overall index

diff -urN v2.2.15/linux/mm/page_io.c linux/mm/page_io.c
@@ -86,9 +86,22 @@
 
 	if (PageSwapCache(page)) {
 		/* Make sure we are the only process doing I/O with this swap page. */
-		while (test_and_set_bit(offset,p->swap_lockmap)) {
-			run_task_queue(&tq_disk);
-			sleep_on(&lock_queue);
+		if (test_and_set_bit(offset, p->swap_lockmap))
+		{
+			struct wait_queue __wait;
+			
+			__wait.task = current;
+			add_wait_queue(&lock_queue, &__wait);
+			for (;;) {
+				current->state = TASK_UNINTERRUPTIBLE;
+				mb();
+				if (!test_and_set_bit(offset, p->swap_lockmap))
+					break;
+				run_task_queue(&tq_disk);
+				schedule();
+			}
+			current->state = TASK_RUNNING;
+			remove_wait_queue(&lock_queue, &__wait);
 		}
 
 		/* 

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