inode.c (8dc207c0e7a259e7122ddfaf56b8bbbc3c92d685) | inode.c (f63e6005bc63acc0a6bc3bdb8f971dcfbd827185) |
---|---|
1/* 2 * linux/fs/ext4/inode.c 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 8 * --- 2228 unchanged lines hidden (view full) --- 2237 logical++; 2238 } while ((bh = bh->b_this_page) != head); 2239 } 2240 2241 return 0; 2242} 2243 2244/* | 1/* 2 * linux/fs/ext4/inode.c 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 8 * --- 2228 unchanged lines hidden (view full) --- 2237 logical++; 2238 } while ((bh = bh->b_this_page) != head); 2239 } 2240 2241 return 0; 2242} 2243 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 */ 2255static 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 2287 * it's intention is to return mapped block or reserve space 2288 */ 2289static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, 2290 struct buffer_head *bh_result, int create) 2291{ 2292 int ret = 0; 2293 --- 272 unchanged lines hidden (view full) --- 2566 if (IS_ERR(handle)) { 2567 ret = PTR_ERR(handle); 2568 printk(KERN_CRIT "%s: jbd2_start: " 2569 "%ld pages, ino %lu; err %d\n", __func__, 2570 wbc->nr_to_write, inode->i_ino, ret); 2571 dump_stack(); 2572 goto out_writepages; 2573 } | 2245 * this is a special callback for ->write_begin() only 2246 * it's intention is to return mapped block or reserve space 2247 */ 2248static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, 2249 struct buffer_head *bh_result, int create) 2250{ 2251 int ret = 0; 2252 --- 272 unchanged lines hidden (view full) --- 2525 if (IS_ERR(handle)) { 2526 ret = PTR_ERR(handle); 2527 printk(KERN_CRIT "%s: jbd2_start: " 2528 "%ld pages, ino %lu; err %d\n", __func__, 2529 wbc->nr_to_write, inode->i_ino, ret); 2530 dump_stack(); 2531 goto out_writepages; 2532 } |
2574 ret = mpage_da_writepages(mapping, wbc, &mpd); | |
2575 | 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; 2565 |
|
2576 ext4_journal_stop(handle); 2577 2578 if ((mpd.retval == -ENOSPC) && sbi->s_journal) { 2579 /* commit the transaction which would 2580 * free blocks released in the transaction 2581 * and try again 2582 */ 2583 jbd2_journal_force_commit_nested(sbi->s_journal); --- 2633 unchanged lines hidden --- | 2566 ext4_journal_stop(handle); 2567 2568 if ((mpd.retval == -ENOSPC) && sbi->s_journal) { 2569 /* commit the transaction which would 2570 * free blocks released in the transaction 2571 * and try again 2572 */ 2573 jbd2_journal_force_commit_nested(sbi->s_journal); --- 2633 unchanged lines hidden --- |