All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 6/10] Fix SMP race in truncate
@ 2002-05-05 20:56 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2002-05-05 20:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml



Closes a small race window: testing PageWriteback() outside the page
lock introduces the possibility that page could be redirtied and have
writeback started after we've inspected PageWriteback.


=====================================

--- 2.5.13/mm/filemap.c~truncate-race	Sun May  5 13:32:00 2002
+++ 2.5.13-akpm/mm/filemap.c	Sun May  5 13:32:35 2002
@@ -201,18 +201,18 @@ static int truncate_list_pages(struct ad
 			int failed;
 
 			page_cache_get(page);
-			if (PageWriteback(page)) {
-				/*
-				 * urgggh. This function is utterly foul,
-				 * and this addition doesn't help.  Kill.
-				 */
+			failed = TestSetPageLocked(page);
+			if (!failed && PageWriteback(page)) {
+				unlock_page(page);
+				list_del(head);
+				list_add_tail(head, curr);
 				write_unlock(&mapping->page_lock);
 				wait_on_page_writeback(page);
+				page_cache_release(page);
 				unlocked = 1;
 				write_lock(&mapping->page_lock);
 				goto restart;
 			}
-			failed = TestSetPageLocked(page);
 
 			list_del(head);
 			if (!failed)

-

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-05 20:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-05 20:56 [patch 6/10] Fix SMP race in truncate Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.