@@ -1799,7 +1799,7 @@ static int __ext4_journalled_writepage(struct page *page,
17991799 * lock so we have to do some magic.
18001800 *
18011801 * This function can get called via...
1802- * - ext4_da_writepages after taking page lock (have journal handle)
1802+ * - ext4_writepages after taking page lock (have journal handle)
18031803 * - journal_submit_inode_data_buffers (no journal handle)
18041804 * - shrink_page_list via the kswapd/direct reclaim (no journal handle)
18051805 * - grab_page_cache when doing write_begin (have journal handle)
@@ -2217,7 +2217,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
22172217
22182218/*
22192219 * Calculate the total number of credits to reserve for one writepages
2220- * iteration. This is called from ext4_da_writepages (). We map an extent of
2220+ * iteration. This is called from ext4_writepages (). We map an extent of
22212221 * upto MAX_WRITEPAGES_EXTENT_LEN blocks and then we go on and finish mapping
22222222 * the last partial page. So in total we can map MAX_WRITEPAGES_EXTENT_LEN +
22232223 * bpp - 1 blocks in bpp different extents.
@@ -2349,8 +2349,17 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
23492349 return err ;
23502350}
23512351
2352- static int ext4_da_writepages (struct address_space * mapping ,
2353- struct writeback_control * wbc )
2352+ static int __writepage (struct page * page , struct writeback_control * wbc ,
2353+ void * data )
2354+ {
2355+ struct address_space * mapping = data ;
2356+ int ret = ext4_writepage (page , wbc );
2357+ mapping_set_error (mapping , ret );
2358+ return ret ;
2359+ }
2360+
2361+ static int ext4_writepages (struct address_space * mapping ,
2362+ struct writeback_control * wbc )
23542363{
23552364 pgoff_t writeback_index = 0 ;
23562365 long nr_to_write = wbc -> nr_to_write ;
@@ -2364,7 +2373,7 @@ static int ext4_da_writepages(struct address_space *mapping,
23642373 bool done ;
23652374 struct blk_plug plug ;
23662375
2367- trace_ext4_da_writepages (inode , wbc );
2376+ trace_ext4_writepages (inode , wbc );
23682377
23692378 /*
23702379 * No pages to write? This is mainly a kludge to avoid starting
@@ -2374,13 +2383,23 @@ static int ext4_da_writepages(struct address_space *mapping,
23742383 if (!mapping -> nrpages || !mapping_tagged (mapping , PAGECACHE_TAG_DIRTY ))
23752384 return 0 ;
23762385
2386+ if (ext4_should_journal_data (inode )) {
2387+ struct blk_plug plug ;
2388+ int ret ;
2389+
2390+ blk_start_plug (& plug );
2391+ ret = write_cache_pages (mapping , wbc , __writepage , mapping );
2392+ blk_finish_plug (& plug );
2393+ return ret ;
2394+ }
2395+
23772396 /*
23782397 * If the filesystem has aborted, it is read-only, so return
23792398 * right away instead of dumping stack traces later on that
23802399 * will obscure the real source of the problem. We test
23812400 * EXT4_MF_FS_ABORTED instead of sb->s_flag's MS_RDONLY because
23822401 * the latter could be true if the filesystem is mounted
2383- * read-only, and in that case, ext4_da_writepages should
2402+ * read-only, and in that case, ext4_writepages should
23842403 * *never* be called, so if that ever happens, we would want
23852404 * the stack trace.
23862405 */
@@ -2520,8 +2539,8 @@ static int ext4_da_writepages(struct address_space *mapping,
25202539 mapping -> writeback_index = mpd .first_page ;
25212540
25222541out_writepages :
2523- trace_ext4_da_writepages_result (inode , wbc , ret ,
2524- nr_to_write - wbc -> nr_to_write );
2542+ trace_ext4_writepages_result (inode , wbc , ret ,
2543+ nr_to_write - wbc -> nr_to_write );
25252544 return ret ;
25262545}
25272546
@@ -2769,7 +2788,7 @@ int ext4_alloc_da_blocks(struct inode *inode)
27692788 * laptop_mode, not even desirable). However, to do otherwise
27702789 * would require replicating code paths in:
27712790 *
2772- * ext4_da_writepages () ->
2791+ * ext4_writepages () ->
27732792 * write_cache_pages() ---> (via passed in callback function)
27742793 * __mpage_da_writepage() -->
27752794 * mpage_add_bh_to_extent()
@@ -3213,6 +3232,7 @@ static const struct address_space_operations ext4_aops = {
32133232 .readpage = ext4_readpage ,
32143233 .readpages = ext4_readpages ,
32153234 .writepage = ext4_writepage ,
3235+ .writepages = ext4_writepages ,
32163236 .write_begin = ext4_write_begin ,
32173237 .write_end = ext4_write_end ,
32183238 .bmap = ext4_bmap ,
@@ -3228,6 +3248,7 @@ static const struct address_space_operations ext4_journalled_aops = {
32283248 .readpage = ext4_readpage ,
32293249 .readpages = ext4_readpages ,
32303250 .writepage = ext4_writepage ,
3251+ .writepages = ext4_writepages ,
32313252 .write_begin = ext4_write_begin ,
32323253 .write_end = ext4_journalled_write_end ,
32333254 .set_page_dirty = ext4_journalled_set_page_dirty ,
@@ -3243,7 +3264,7 @@ static const struct address_space_operations ext4_da_aops = {
32433264 .readpage = ext4_readpage ,
32443265 .readpages = ext4_readpages ,
32453266 .writepage = ext4_writepage ,
3246- .writepages = ext4_da_writepages ,
3267+ .writepages = ext4_writepages ,
32473268 .write_begin = ext4_da_write_begin ,
32483269 .write_end = ext4_da_write_end ,
32493270 .bmap = ext4_bmap ,
0 commit comments