linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 24/27] fix invalidate_inode_pages2() race
@ 2002-07-04 23:55 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2002-07-04 23:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml



Fix a buglet in invalidate_list_pages2(): there is a small window in
which writeback could start against the page before this function locks
it.

The patch closes the race by performing the PageWriteback test inside
PageLocked.

Testing PageWriteback inside PageLocked is "definitive" - when a page
is locked, writeback cannot start against it.




 filemap.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

--- 2.5.24/mm/filemap.c~invalidate-race	Thu Jul  4 16:17:32 2002
+++ 2.5.24-akpm/mm/filemap.c	Thu Jul  4 16:17:32 2002
@@ -367,16 +367,18 @@ static int invalidate_list_pages2(struct
 	while (curr != head) {
 		page = list_entry(curr, struct page, list);
 
-		if (PageWriteback(page)) {
-			write_unlock(&mapping->page_lock);
-			wait_on_page_writeback(page);
-			unlocked = 1;
-			write_lock(&mapping->page_lock);
-			goto restart;
-		}
 		if (!TestSetPageLocked(page)) {
 			int __unlocked;
 
+			if (PageWriteback(page)) {
+				write_unlock(&mapping->page_lock);
+				wait_on_page_writeback(page);
+				unlocked = 1;
+				write_lock(&mapping->page_lock);
+				unlock_page(page);
+				goto restart;
+			}
+
 			__unlocked = invalidate_this_page2(mapping, page, curr, head);
 			unlock_page(page);
 			unlocked |= __unlocked;

-

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

only message in thread, other threads:[~2002-07-04 23:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-04 23:55 [patch 24/27] fix invalidate_inode_pages2() race Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).