Fixing invalidate_inode_pages() and mmapped files...

From: Trond Myklebust (trond.myklebust@fys.uio.no)
Date: Mon May 15 2000 - 04:17:44 EST


Hi,

Would the following compromise be acceptable? It differs from Andreas
previous attempt by the extra line which clears PG_uptodate on the
page.

This means that unlocked, unreferenced pages are thrown out of the
page cache.

Locked, and/or referenced pages are marked as not being uptodate, and
hence will be reread the next time we call generic_file_read() unless
somebody resets PageUptodate after the call (see
nfs_readpage_result()).

Cheers,
  Trond

diff -u --recursive --new-file linux-2.3.99-pre8/mm/filemap.c linux-2.3.99-pre8-inval/mm/filemap.c
--- linux-2.3.99-pre8/mm/filemap.c Fri May 12 04:10:53 2000
+++ linux-2.3.99-pre8-inval/mm/filemap.c Mon May 15 10:26:29 2000
@@ -110,10 +110,10 @@
 }
 
 /**
- * invalidate_inode_pages - Invalidate all the unlocked pages of one inode
+ * invalidate_inode_pages - Invalidate all the pages of one inode
  * @inode: the inode which pages we want to invalidate
  *
- * This function only removes the unlocked pages, if you want to
+ * This function only removes the unreferenced pages, if you want to
  * remove all the pages of one inode, you must call truncate_inode_pages.
  */
 
@@ -132,7 +132,18 @@
                 page = list_entry(curr, struct page, list);
                 curr = curr->next;
 
- /* We cannot invalidate a locked page */
+ /*
+ * All pages are marked as being not up to date
+ * even locked ones (otherwise we have a race with
+ * generic_file_write()).
+ */
+ ClearPageUptodate(page);
+
+ /* We cannot remove an mmapped page */
+ if (atomic_read(&page->count) > 1)
+ continue;
+
+ /* We cannot remove a locked page */
                 if (TryLockPage(page))
                         continue;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:25 EST