diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-02-23 16:42:39 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-02-23 16:42:39 -0500 |
commit | f63e6005bc63acc0a6bc3bdb8f971dcfbd827185 (patch) | |
tree | 22f40e4c70fd9d6fecd36926ae1087d59522098d /fs/ext4/inode.c | |
parent | 8dc207c0e7a259e7122ddfaf56b8bbbc3c92d685 (diff) |
ext4: Simplify delalloc code by removing mpage_da_writepages()
The mpage_da_writepages() function is only used in one place, so
inline it to simplify the call stack and make the code easier to
understand.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 008b28a859d0..24d0f9d2b320 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2242,47 +2242,6 @@ static int __mpage_da_writepage(struct page *page, | |||
2242 | } | 2242 | } |
2243 | 2243 | ||
2244 | /* | 2244 | /* |
2245 | * mpage_da_writepages - walk the list of dirty pages of the given | ||
2246 | * address space, allocates non-allocated blocks, maps newly-allocated | ||
2247 | * blocks to existing bhs and issue IO them | ||
2248 | * | ||
2249 | * @mapping: address space structure to write | ||
2250 | * @wbc: subtract the number of written pages from *@wbc->nr_to_write | ||
2251 | * | ||
2252 | * This is a library function, which implements the writepages() | ||
2253 | * address_space_operation. | ||
2254 | */ | ||
2255 | static int mpage_da_writepages(struct address_space *mapping, | ||
2256 | struct writeback_control *wbc, | ||
2257 | struct mpage_da_data *mpd) | ||
2258 | { | ||
2259 | int ret; | ||
2260 | |||
2261 | mpd->b_size = 0; | ||
2262 | mpd->b_state = 0; | ||
2263 | mpd->b_blocknr = 0; | ||
2264 | mpd->first_page = 0; | ||
2265 | mpd->next_page = 0; | ||
2266 | mpd->io_done = 0; | ||
2267 | mpd->pages_written = 0; | ||
2268 | mpd->retval = 0; | ||
2269 | |||
2270 | ret = write_cache_pages(mapping, wbc, __mpage_da_writepage, mpd); | ||
2271 | /* | ||
2272 | * Handle last extent of pages | ||
2273 | */ | ||
2274 | if (!mpd->io_done && mpd->next_page != mpd->first_page) { | ||
2275 | if (mpage_da_map_blocks(mpd) == 0) | ||
2276 | mpage_da_submit_io(mpd); | ||
2277 | |||
2278 | mpd->io_done = 1; | ||
2279 | ret = MPAGE_DA_EXTENT_TAIL; | ||
2280 | } | ||
2281 | wbc->nr_to_write -= mpd->pages_written; | ||
2282 | return ret; | ||
2283 | } | ||
2284 | |||
2285 | /* | ||
2286 | * this is a special callback for ->write_begin() only | 2245 | * this is a special callback for ->write_begin() only |
2287 | * it's intention is to return mapped block or reserve space | 2246 | * it's intention is to return mapped block or reserve space |
2288 | */ | 2247 | */ |
@@ -2571,7 +2530,38 @@ retry: | |||
2571 | dump_stack(); | 2530 | dump_stack(); |
2572 | goto out_writepages; | 2531 | goto out_writepages; |
2573 | } | 2532 | } |
2574 | ret = mpage_da_writepages(mapping, wbc, &mpd); | 2533 | |
2534 | /* | ||
2535 | * Now call __mpage_da_writepage to find the next | ||
2536 | * contiguous region of logical blocks that need | ||
2537 | * blocks to be allocated by ext4. We don't actually | ||
2538 | * submit the blocks for I/O here, even though | ||
2539 | * write_cache_pages thinks it will, and will set the | ||
2540 | * pages as clean for write before calling | ||
2541 | * __mpage_da_writepage(). | ||
2542 | */ | ||
2543 | mpd.b_size = 0; | ||
2544 | mpd.b_state = 0; | ||
2545 | mpd.b_blocknr = 0; | ||
2546 | mpd.first_page = 0; | ||
2547 | mpd.next_page = 0; | ||
2548 | mpd.io_done = 0; | ||
2549 | mpd.pages_written = 0; | ||
2550 | mpd.retval = 0; | ||
2551 | ret = write_cache_pages(mapping, wbc, __mpage_da_writepage, | ||
2552 | &mpd); | ||
2553 | /* | ||
2554 | * If we have a contigous extent of pages and we | ||
2555 | * haven't done the I/O yet, map the blocks and submit | ||
2556 | * them for I/O. | ||
2557 | */ | ||
2558 | if (!mpd.io_done && mpd.next_page != mpd.first_page) { | ||
2559 | if (mpage_da_map_blocks(&mpd) == 0) | ||
2560 | mpage_da_submit_io(&mpd); | ||
2561 | mpd.io_done = 1; | ||
2562 | ret = MPAGE_DA_EXTENT_TAIL; | ||
2563 | } | ||
2564 | wbc->nr_to_write -= mpd.pages_written; | ||
2575 | 2565 | ||
2576 | ext4_journal_stop(handle); | 2566 | ext4_journal_stop(handle); |
2577 | 2567 | ||