aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/inode.c41
-rw-r--r--include/trace/events/ext4.h4
2 files changed, 33 insertions, 12 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 442c5d2e0978..0db830d541ec 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1799,7 +1799,7 @@ out:
1799 * lock so we have to do some magic. 1799 * lock so we have to do some magic.
1800 * 1800 *
1801 * This function can get called via... 1801 * 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)
1803 * - journal_submit_inode_data_buffers (no journal handle) 1803 * - journal_submit_inode_data_buffers (no journal handle)
1804 * - shrink_page_list via the kswapd/direct reclaim (no journal handle) 1804 * - shrink_page_list via the kswapd/direct reclaim (no journal handle)
1805 * - grab_page_cache when doing write_begin (have journal handle) 1805 * - grab_page_cache when doing write_begin (have journal handle)
@@ -2217,7 +2217,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2217 2217
2218/* 2218/*
2219 * Calculate the total number of credits to reserve for one writepages 2219 * 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
2221 * upto MAX_WRITEPAGES_EXTENT_LEN blocks and then we go on and finish mapping 2221 * upto MAX_WRITEPAGES_EXTENT_LEN blocks and then we go on and finish mapping
2222 * the last partial page. So in total we can map MAX_WRITEPAGES_EXTENT_LEN + 2222 * the last partial page. So in total we can map MAX_WRITEPAGES_EXTENT_LEN +
2223 * bpp - 1 blocks in bpp different extents. 2223 * bpp - 1 blocks in bpp different extents.
@@ -2349,8 +2349,17 @@ out:
2349 return err; 2349 return err;
2350} 2350}
2351 2351
2352static int ext4_da_writepages(struct address_space *mapping, 2352static int __writepage(struct page *page, struct writeback_control *wbc,
2353 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
2361static int ext4_writepages(struct address_space *mapping,
2362 struct writeback_control *wbc)
2354{ 2363{
2355 pgoff_t writeback_index = 0; 2364 pgoff_t writeback_index = 0;
2356 long nr_to_write = wbc->nr_to_write; 2365 long nr_to_write = wbc->nr_to_write;
@@ -2364,7 +2373,7 @@ static int ext4_da_writepages(struct address_space *mapping,
2364 bool done; 2373 bool done;
2365 struct blk_plug plug; 2374 struct blk_plug plug;
2366 2375
2367 trace_ext4_da_writepages(inode, wbc); 2376 trace_ext4_writepages(inode, wbc);
2368 2377
2369 /* 2378 /*
2370 * No pages to write? This is mainly a kludge to avoid starting 2379 * 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,
2374 if (!mapping->nrpages || !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) 2383 if (!mapping->nrpages || !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
2375 return 0; 2384 return 0;
2376 2385
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
2377 /* 2396 /*
2378 * If the filesystem has aborted, it is read-only, so return 2397 * If the filesystem has aborted, it is read-only, so return
2379 * right away instead of dumping stack traces later on that 2398 * right away instead of dumping stack traces later on that
2380 * will obscure the real source of the problem. We test 2399 * will obscure the real source of the problem. We test
2381 * EXT4_MF_FS_ABORTED instead of sb->s_flag's MS_RDONLY because 2400 * EXT4_MF_FS_ABORTED instead of sb->s_flag's MS_RDONLY because
2382 * the latter could be true if the filesystem is mounted 2401 * 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
2384 * *never* be called, so if that ever happens, we would want 2403 * *never* be called, so if that ever happens, we would want
2385 * the stack trace. 2404 * the stack trace.
2386 */ 2405 */
@@ -2520,8 +2539,8 @@ retry:
2520 mapping->writeback_index = mpd.first_page; 2539 mapping->writeback_index = mpd.first_page;
2521 2540
2522out_writepages: 2541out_writepages:
2523 trace_ext4_da_writepages_result(inode, wbc, ret, 2542 trace_ext4_writepages_result(inode, wbc, ret,
2524 nr_to_write - wbc->nr_to_write); 2543 nr_to_write - wbc->nr_to_write);
2525 return ret; 2544 return ret;
2526} 2545}
2527 2546
@@ -2769,7 +2788,7 @@ int ext4_alloc_da_blocks(struct inode *inode)
2769 * laptop_mode, not even desirable). However, to do otherwise 2788 * laptop_mode, not even desirable). However, to do otherwise
2770 * would require replicating code paths in: 2789 * would require replicating code paths in:
2771 * 2790 *
2772 * ext4_da_writepages() -> 2791 * ext4_writepages() ->
2773 * write_cache_pages() ---> (via passed in callback function) 2792 * write_cache_pages() ---> (via passed in callback function)
2774 * __mpage_da_writepage() --> 2793 * __mpage_da_writepage() -->
2775 * mpage_add_bh_to_extent() 2794 * mpage_add_bh_to_extent()
@@ -3213,6 +3232,7 @@ static const struct address_space_operations ext4_aops = {
3213 .readpage = ext4_readpage, 3232 .readpage = ext4_readpage,
3214 .readpages = ext4_readpages, 3233 .readpages = ext4_readpages,
3215 .writepage = ext4_writepage, 3234 .writepage = ext4_writepage,
3235 .writepages = ext4_writepages,
3216 .write_begin = ext4_write_begin, 3236 .write_begin = ext4_write_begin,
3217 .write_end = ext4_write_end, 3237 .write_end = ext4_write_end,
3218 .bmap = ext4_bmap, 3238 .bmap = ext4_bmap,
@@ -3228,6 +3248,7 @@ static const struct address_space_operations ext4_journalled_aops = {
3228 .readpage = ext4_readpage, 3248 .readpage = ext4_readpage,
3229 .readpages = ext4_readpages, 3249 .readpages = ext4_readpages,
3230 .writepage = ext4_writepage, 3250 .writepage = ext4_writepage,
3251 .writepages = ext4_writepages,
3231 .write_begin = ext4_write_begin, 3252 .write_begin = ext4_write_begin,
3232 .write_end = ext4_journalled_write_end, 3253 .write_end = ext4_journalled_write_end,
3233 .set_page_dirty = ext4_journalled_set_page_dirty, 3254 .set_page_dirty = ext4_journalled_set_page_dirty,
@@ -3243,7 +3264,7 @@ static const struct address_space_operations ext4_da_aops = {
3243 .readpage = ext4_readpage, 3264 .readpage = ext4_readpage,
3244 .readpages = ext4_readpages, 3265 .readpages = ext4_readpages,
3245 .writepage = ext4_writepage, 3266 .writepage = ext4_writepage,
3246 .writepages = ext4_da_writepages, 3267 .writepages = ext4_writepages,
3247 .write_begin = ext4_da_write_begin, 3268 .write_begin = ext4_da_write_begin,
3248 .write_end = ext4_da_write_end, 3269 .write_end = ext4_da_write_end,
3249 .bmap = ext4_bmap, 3270 .bmap = ext4_bmap,
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 832a412e6515..72f523eb82e0 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -281,7 +281,7 @@ DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
281 TP_ARGS(inode, pos, len, copied) 281 TP_ARGS(inode, pos, len, copied)
282); 282);
283 283
284TRACE_EVENT(ext4_da_writepages, 284TRACE_EVENT(ext4_writepages,
285 TP_PROTO(struct inode *inode, struct writeback_control *wbc), 285 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
286 286
287 TP_ARGS(inode, wbc), 287 TP_ARGS(inode, wbc),
@@ -379,7 +379,7 @@ TRACE_EVENT(ext4_da_write_pages_extent,
379 __entry->flags) 379 __entry->flags)
380); 380);
381 381
382TRACE_EVENT(ext4_da_writepages_result, 382TRACE_EVENT(ext4_writepages_result,
383 TP_PROTO(struct inode *inode, struct writeback_control *wbc, 383 TP_PROTO(struct inode *inode, struct writeback_control *wbc,
384 int ret, int pages_written), 384 int ret, int pages_written),
385 385