aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-02-26 14:08:01 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-02-26 14:08:01 -0500
commit9749895644a817cfd28a535bc3ae60e4267bdc50 (patch)
treea0958777287906320aba461690125d8786ceb565 /fs/ext4/inode.c
parent4f01b02c8c4e4111bd1adbcafb5741e8e991f5fd (diff)
ext4: clear the dirty bit for a page in writeback at the last minute
Move when we call clear_page_dirty_for_io() to just before we actually write the page. This simplifies the code somewhat, and avoids marking pages as clean and then needing to remark them as dirty later. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 1e718e87f466..ae6e2f43d873 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2060,7 +2060,7 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
2060 if (nr_pages == 0) 2060 if (nr_pages == 0)
2061 break; 2061 break;
2062 for (i = 0; i < nr_pages; i++) { 2062 for (i = 0; i < nr_pages; i++) {
2063 int commit_write = 0, redirty_page = 0; 2063 int commit_write = 0, skip_page = 0;
2064 struct page *page = pvec.pages[i]; 2064 struct page *page = pvec.pages[i];
2065 2065
2066 index = page->index; 2066 index = page->index;
@@ -2086,14 +2086,12 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
2086 * If the page does not have buffers (for 2086 * If the page does not have buffers (for
2087 * whatever reason), try to create them using 2087 * whatever reason), try to create them using
2088 * __block_write_begin. If this fails, 2088 * __block_write_begin. If this fails,
2089 * redirty the page and move on. 2089 * skip the page and move on.
2090 */ 2090 */
2091 if (!page_has_buffers(page)) { 2091 if (!page_has_buffers(page)) {
2092 if (__block_write_begin(page, 0, len, 2092 if (__block_write_begin(page, 0, len,
2093 noalloc_get_block_write)) { 2093 noalloc_get_block_write)) {
2094 redirty_page: 2094 skip_page:
2095 redirty_page_for_writepage(mpd->wbc,
2096 page);
2097 unlock_page(page); 2095 unlock_page(page);
2098 continue; 2096 continue;
2099 } 2097 }
@@ -2104,7 +2102,7 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
2104 block_start = 0; 2102 block_start = 0;
2105 do { 2103 do {
2106 if (!bh) 2104 if (!bh)
2107 goto redirty_page; 2105 goto skip_page;
2108 if (map && (cur_logical >= map->m_lblk) && 2106 if (map && (cur_logical >= map->m_lblk) &&
2109 (cur_logical <= (map->m_lblk + 2107 (cur_logical <= (map->m_lblk +
2110 (map->m_len - 1)))) { 2108 (map->m_len - 1)))) {
@@ -2120,22 +2118,23 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
2120 clear_buffer_unwritten(bh); 2118 clear_buffer_unwritten(bh);
2121 } 2119 }
2122 2120
2123 /* redirty page if block allocation undone */ 2121 /* skip page if block allocation undone */
2124 if (buffer_delay(bh) || buffer_unwritten(bh)) 2122 if (buffer_delay(bh) || buffer_unwritten(bh))
2125 redirty_page = 1; 2123 skip_page = 1;
2126 bh = bh->b_this_page; 2124 bh = bh->b_this_page;
2127 block_start += bh->b_size; 2125 block_start += bh->b_size;
2128 cur_logical++; 2126 cur_logical++;
2129 pblock++; 2127 pblock++;
2130 } while (bh != page_bufs); 2128 } while (bh != page_bufs);
2131 2129
2132 if (redirty_page) 2130 if (skip_page)
2133 goto redirty_page; 2131 goto skip_page;
2134 2132
2135 if (commit_write) 2133 if (commit_write)
2136 /* mark the buffer_heads as dirty & uptodate */ 2134 /* mark the buffer_heads as dirty & uptodate */
2137 block_commit_write(page, 0, len); 2135 block_commit_write(page, 0, len);
2138 2136
2137 clear_page_dirty_for_io(page);
2139 /* 2138 /*
2140 * Delalloc doesn't support data journalling, 2139 * Delalloc doesn't support data journalling,
2141 * but eventually maybe we'll lift this 2140 * but eventually maybe we'll lift this
@@ -2277,9 +2276,8 @@ static void mpage_da_map_and_submit(struct mpage_da_data *mpd)
2277 err = blks; 2276 err = blks;
2278 /* 2277 /*
2279 * If get block returns EAGAIN or ENOSPC and there 2278 * If get block returns EAGAIN or ENOSPC and there
2280 * appears to be free blocks we will call 2279 * appears to be free blocks we will just let
2281 * ext4_writepage() for all of the pages which will 2280 * mpage_da_submit_io() unlock all of the pages.
2282 * just redirty the pages.
2283 */ 2281 */
2284 if (err == -EAGAIN) 2282 if (err == -EAGAIN)
2285 goto submit_io; 2283 goto submit_io;
@@ -2777,7 +2775,6 @@ static int write_cache_pages_da(struct address_space *mapping,
2777 (PageWriteback(page) && 2775 (PageWriteback(page) &&
2778 (wbc->sync_mode == WB_SYNC_NONE)) || 2776 (wbc->sync_mode == WB_SYNC_NONE)) ||
2779 unlikely(page->mapping != mapping)) { 2777 unlikely(page->mapping != mapping)) {
2780 continue_unlock:
2781 unlock_page(page); 2778 unlock_page(page);
2782 continue; 2779 continue;
2783 } 2780 }
@@ -2786,8 +2783,6 @@ static int write_cache_pages_da(struct address_space *mapping,
2786 wait_on_page_writeback(page); 2783 wait_on_page_writeback(page);
2787 2784
2788 BUG_ON(PageWriteback(page)); 2785 BUG_ON(PageWriteback(page));
2789 if (!clear_page_dirty_for_io(page))
2790 goto continue_unlock;
2791 2786
2792 /* 2787 /*
2793 * Can we merge this page to current extent? 2788 * Can we merge this page to current extent?
@@ -2803,7 +2798,6 @@ static int write_cache_pages_da(struct address_space *mapping,
2803 /* 2798 /*
2804 * skip rest of the page in the page_vec 2799 * skip rest of the page in the page_vec
2805 */ 2800 */
2806 redirty_page_for_writepage(wbc, page);
2807 unlock_page(page); 2801 unlock_page(page);
2808 goto ret_extent_tail; 2802 goto ret_extent_tail;
2809 } 2803 }