aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-02-26 14:09:14 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-02-26 14:09:14 -0500
commit78aaced3408141bb7c836f2db0ca435790399da5 (patch)
treec761d397605095d4d895ede9fc5e6a6548723cad /fs/ext4/inode.c
parentee6ecbcc5d73672217fdea420d182ecb0cdf310c (diff)
ext4: don't lock the next page in write_cache_pages if not needed
If we have accumulated a contiguous region of memory to be written out, and the next page can added to this region, don't bother locking (and then unlocking the page) before writing out the memory. In the unlikely event that the next page was being written back by some other CPU, we can also skip waiting that page to finish writeback. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 617c9cbba182..c2e6af338234 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2761,6 +2761,16 @@ static int write_cache_pages_da(struct address_space *mapping,
2761 2761
2762 *done_index = page->index + 1; 2762 *done_index = page->index + 1;
2763 2763
2764 /*
2765 * If we can't merge this page, and we have
2766 * accumulated an contiguous region, write it
2767 */
2768 if ((mpd->next_page != page->index) &&
2769 (mpd->next_page != mpd->first_page)) {
2770 mpage_da_map_and_submit(mpd);
2771 goto ret_extent_tail;
2772 }
2773
2764 lock_page(page); 2774 lock_page(page);
2765 2775
2766 /* 2776 /*
@@ -2784,25 +2794,8 @@ static int write_cache_pages_da(struct address_space *mapping,
2784 2794
2785 BUG_ON(PageWriteback(page)); 2795 BUG_ON(PageWriteback(page));
2786 2796
2787 /*
2788 * Can we merge this page to current extent?
2789 */
2790 if (mpd->next_page != page->index) { 2797 if (mpd->next_page != page->index) {
2791 /* 2798 /*
2792 * Nope, we can't. So, we map
2793 * non-allocated blocks and start IO
2794 * on them
2795 */
2796 if (mpd->next_page != mpd->first_page) {
2797 mpage_da_map_and_submit(mpd);
2798 /*
2799 * skip rest of the page in the page_vec
2800 */
2801 unlock_page(page);
2802 goto ret_extent_tail;
2803 }
2804
2805 /*
2806 * Start next extent of pages and blocks 2799 * Start next extent of pages and blocks
2807 */ 2800 */
2808 mpd->first_page = page->index; 2801 mpd->first_page = page->index;