--------------------- PatchSet 843 Date: 2002/05/17 18:27:50 Author: sct Log: Performance tweak: when we truncate a file but encounter pages which are still being journaled from a previous transaction, we can't evict the page from memory immediately. This patch just makes it a little easier for the VM to evict the page later on: the page is marked unreferenced while we're committing the transaction which pins it, and the commit logic tries to free the page completely once the transaction has committed. Members: fs/jbd/commit.c:1.46.2.3->1.46.2.4 [ext3-1_0-branch] fs/jbd/transaction.c:1.64.2.9->1.64.2.10 [ext3-1_0-branch] --- linux-ext3-2.4merge/fs/jbd/transaction.c.=K0011=.orig Sat Aug 17 20:23:21 2002 +++ linux-ext3-2.4merge/fs/jbd/transaction.c Sat Aug 17 20:23:21 2002 @@ -1902,8 +1902,29 @@ unlock_journal(journal); if (!offset) { - if (!may_free || !try_to_free_buffers(page, 0)) + if (!may_free || !try_to_free_buffers(page, 0)) { + if (!offset) { + /* We are still using the page, but only + because a transaction is pinning the + page. Once it commits, we want to + encourage the page to be reaped as + quickly as possible. */ + ClearPageReferenced(page); + +#if 0 + /* Ugh, this is not exactly portable + between VMs: we need a modular + solution for this some day.. */ + if (PageActive(page)) { + spin_lock(&pagemap_lru_lock); + del_page_from_active_list(page); + add_page_to_inactive_list(page); + spin_unlock(&pagemap_lru_lock); + } +#endif + } return 0; + } J_ASSERT(page->buffers == NULL); } return 1; --- linux-ext3-2.4merge/fs/jbd/commit.c.=K0011=.orig Sat Aug 17 20:09:01 2002 +++ linux-ext3-2.4merge/fs/jbd/commit.c Sat Aug 17 20:23:20 2002 @@ -669,13 +669,23 @@ JBUFFER_TRACE(jh, "refile for checkpoint writeback"); __journal_refile_buffer(jh); } else { + struct page *page = bh->b_page; + J_ASSERT_BH(bh, !buffer_dirty(bh)); J_ASSERT_JH(jh, jh->b_next_transaction == NULL); __journal_unfile_buffer(jh); jh->b_transaction = 0; __journal_remove_journal_head(bh); - __brelse(bh); + + if (TryLockPage(page)) { + __brelse(bh); + } else { + __brelse(bh); + try_to_free_buffers(page, 0); + unlock_page(page); + } } + spin_unlock(&journal_datalist_lock); }