diff options
-rw-r--r-- | fs/buffer.c | 10 | ||||
-rw-r--r-- | fs/fs-writeback.c | 161 | ||||
-rw-r--r-- | mm/page-writeback.c | 30 | ||||
-rw-r--r-- | mm/shmem.c | 5 | ||||
-rw-r--r-- | mm/vmscan.c | 8 |
5 files changed, 142 insertions, 72 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index 24afd7422ae8..6fa530256bfd 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -280,7 +280,7 @@ void invalidate_bdev(struct block_device *bdev) | |||
280 | EXPORT_SYMBOL(invalidate_bdev); | 280 | EXPORT_SYMBOL(invalidate_bdev); |
281 | 281 | ||
282 | /* | 282 | /* |
283 | * Kick pdflush then try to free up some ZONE_NORMAL memory. | 283 | * Kick the writeback threads then try to free up some ZONE_NORMAL memory. |
284 | */ | 284 | */ |
285 | static void free_more_memory(void) | 285 | static void free_more_memory(void) |
286 | { | 286 | { |
@@ -1709,9 +1709,9 @@ static int __block_write_full_page(struct inode *inode, struct page *page, | |||
1709 | /* | 1709 | /* |
1710 | * If it's a fully non-blocking write attempt and we cannot | 1710 | * If it's a fully non-blocking write attempt and we cannot |
1711 | * lock the buffer then redirty the page. Note that this can | 1711 | * lock the buffer then redirty the page. Note that this can |
1712 | * potentially cause a busy-wait loop from pdflush and kswapd | 1712 | * potentially cause a busy-wait loop from writeback threads |
1713 | * activity, but those code paths have their own higher-level | 1713 | * and kswapd activity, but those code paths have their own |
1714 | * throttling. | 1714 | * higher-level throttling. |
1715 | */ | 1715 | */ |
1716 | if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) { | 1716 | if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) { |
1717 | lock_buffer(bh); | 1717 | lock_buffer(bh); |
@@ -3208,7 +3208,7 @@ EXPORT_SYMBOL(block_sync_page); | |||
3208 | * still running obsolete flush daemons, so we terminate them here. | 3208 | * still running obsolete flush daemons, so we terminate them here. |
3209 | * | 3209 | * |
3210 | * Use of bdflush() is deprecated and will be removed in a future kernel. | 3210 | * Use of bdflush() is deprecated and will be removed in a future kernel. |
3211 | * The `pdflush' kernel threads fully replace bdflush daemons and this call. | 3211 | * The `flush-X' kernel threads fully replace bdflush daemons and this call. |
3212 | */ | 3212 | */ |
3213 | SYSCALL_DEFINE2(bdflush, int, func, long, data) | 3213 | SYSCALL_DEFINE2(bdflush, int, func, long, data) |
3214 | { | 3214 | { |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 8e1e5e19d21e..fb61178c86e3 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -41,8 +41,9 @@ struct wb_writeback_args { | |||
41 | long nr_pages; | 41 | long nr_pages; |
42 | struct super_block *sb; | 42 | struct super_block *sb; |
43 | enum writeback_sync_modes sync_mode; | 43 | enum writeback_sync_modes sync_mode; |
44 | int for_kupdate; | 44 | int for_kupdate:1; |
45 | int range_cyclic; | 45 | int range_cyclic:1; |
46 | int for_background:1; | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | /* | 49 | /* |
@@ -257,6 +258,15 @@ void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages) | |||
257 | .range_cyclic = 1, | 258 | .range_cyclic = 1, |
258 | }; | 259 | }; |
259 | 260 | ||
261 | /* | ||
262 | * We treat @nr_pages=0 as the special case to do background writeback, | ||
263 | * ie. to sync pages until the background dirty threshold is reached. | ||
264 | */ | ||
265 | if (!nr_pages) { | ||
266 | args.nr_pages = LONG_MAX; | ||
267 | args.for_background = 1; | ||
268 | } | ||
269 | |||
260 | bdi_alloc_queue_work(bdi, &args); | 270 | bdi_alloc_queue_work(bdi, &args); |
261 | } | 271 | } |
262 | 272 | ||
@@ -310,7 +320,7 @@ static bool inode_dirtied_after(struct inode *inode, unsigned long t) | |||
310 | * For inodes being constantly redirtied, dirtied_when can get stuck. | 320 | * For inodes being constantly redirtied, dirtied_when can get stuck. |
311 | * It _appears_ to be in the future, but is actually in distant past. | 321 | * It _appears_ to be in the future, but is actually in distant past. |
312 | * This test is necessary to prevent such wrapped-around relative times | 322 | * This test is necessary to prevent such wrapped-around relative times |
313 | * from permanently stopping the whole pdflush writeback. | 323 | * from permanently stopping the whole bdi writeback. |
314 | */ | 324 | */ |
315 | ret = ret && time_before_eq(inode->dirtied_when, jiffies); | 325 | ret = ret && time_before_eq(inode->dirtied_when, jiffies); |
316 | #endif | 326 | #endif |
@@ -324,13 +334,38 @@ static void move_expired_inodes(struct list_head *delaying_queue, | |||
324 | struct list_head *dispatch_queue, | 334 | struct list_head *dispatch_queue, |
325 | unsigned long *older_than_this) | 335 | unsigned long *older_than_this) |
326 | { | 336 | { |
337 | LIST_HEAD(tmp); | ||
338 | struct list_head *pos, *node; | ||
339 | struct super_block *sb = NULL; | ||
340 | struct inode *inode; | ||
341 | int do_sb_sort = 0; | ||
342 | |||
327 | while (!list_empty(delaying_queue)) { | 343 | while (!list_empty(delaying_queue)) { |
328 | struct inode *inode = list_entry(delaying_queue->prev, | 344 | inode = list_entry(delaying_queue->prev, struct inode, i_list); |
329 | struct inode, i_list); | ||
330 | if (older_than_this && | 345 | if (older_than_this && |
331 | inode_dirtied_after(inode, *older_than_this)) | 346 | inode_dirtied_after(inode, *older_than_this)) |
332 | break; | 347 | break; |
333 | list_move(&inode->i_list, dispatch_queue); | 348 | if (sb && sb != inode->i_sb) |
349 | do_sb_sort = 1; | ||
350 | sb = inode->i_sb; | ||
351 | list_move(&inode->i_list, &tmp); | ||
352 | } | ||
353 | |||
354 | /* just one sb in list, splice to dispatch_queue and we're done */ | ||
355 | if (!do_sb_sort) { | ||
356 | list_splice(&tmp, dispatch_queue); | ||
357 | return; | ||
358 | } | ||
359 | |||
360 | /* Move inodes from one superblock together */ | ||
361 | while (!list_empty(&tmp)) { | ||
362 | inode = list_entry(tmp.prev, struct inode, i_list); | ||
363 | sb = inode->i_sb; | ||
364 | list_for_each_prev_safe(pos, node, &tmp) { | ||
365 | inode = list_entry(pos, struct inode, i_list); | ||
366 | if (inode->i_sb == sb) | ||
367 | list_move(&inode->i_list, dispatch_queue); | ||
368 | } | ||
334 | } | 369 | } |
335 | } | 370 | } |
336 | 371 | ||
@@ -439,8 +474,18 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
439 | spin_lock(&inode_lock); | 474 | spin_lock(&inode_lock); |
440 | inode->i_state &= ~I_SYNC; | 475 | inode->i_state &= ~I_SYNC; |
441 | if (!(inode->i_state & (I_FREEING | I_CLEAR))) { | 476 | if (!(inode->i_state & (I_FREEING | I_CLEAR))) { |
442 | if (!(inode->i_state & I_DIRTY) && | 477 | if ((inode->i_state & I_DIRTY_PAGES) && wbc->for_kupdate) { |
443 | mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { | 478 | /* |
479 | * More pages get dirtied by a fast dirtier. | ||
480 | */ | ||
481 | goto select_queue; | ||
482 | } else if (inode->i_state & I_DIRTY) { | ||
483 | /* | ||
484 | * At least XFS will redirty the inode during the | ||
485 | * writeback (delalloc) and on io completion (isize). | ||
486 | */ | ||
487 | redirty_tail(inode); | ||
488 | } else if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { | ||
444 | /* | 489 | /* |
445 | * We didn't write back all the pages. nfs_writepages() | 490 | * We didn't write back all the pages. nfs_writepages() |
446 | * sometimes bales out without doing anything. Redirty | 491 | * sometimes bales out without doing anything. Redirty |
@@ -462,6 +507,7 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
462 | * soon as the queue becomes uncongested. | 507 | * soon as the queue becomes uncongested. |
463 | */ | 508 | */ |
464 | inode->i_state |= I_DIRTY_PAGES; | 509 | inode->i_state |= I_DIRTY_PAGES; |
510 | select_queue: | ||
465 | if (wbc->nr_to_write <= 0) { | 511 | if (wbc->nr_to_write <= 0) { |
466 | /* | 512 | /* |
467 | * slice used up: queue for next turn | 513 | * slice used up: queue for next turn |
@@ -484,12 +530,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
484 | inode->i_state |= I_DIRTY_PAGES; | 530 | inode->i_state |= I_DIRTY_PAGES; |
485 | redirty_tail(inode); | 531 | redirty_tail(inode); |
486 | } | 532 | } |
487 | } else if (inode->i_state & I_DIRTY) { | ||
488 | /* | ||
489 | * Someone redirtied the inode while were writing back | ||
490 | * the pages. | ||
491 | */ | ||
492 | redirty_tail(inode); | ||
493 | } else if (atomic_read(&inode->i_count)) { | 533 | } else if (atomic_read(&inode->i_count)) { |
494 | /* | 534 | /* |
495 | * The inode is clean, inuse | 535 | * The inode is clean, inuse |
@@ -506,6 +546,17 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
506 | return ret; | 546 | return ret; |
507 | } | 547 | } |
508 | 548 | ||
549 | static void unpin_sb_for_writeback(struct super_block **psb) | ||
550 | { | ||
551 | struct super_block *sb = *psb; | ||
552 | |||
553 | if (sb) { | ||
554 | up_read(&sb->s_umount); | ||
555 | put_super(sb); | ||
556 | *psb = NULL; | ||
557 | } | ||
558 | } | ||
559 | |||
509 | /* | 560 | /* |
510 | * For WB_SYNC_NONE writeback, the caller does not have the sb pinned | 561 | * For WB_SYNC_NONE writeback, the caller does not have the sb pinned |
511 | * before calling writeback. So make sure that we do pin it, so it doesn't | 562 | * before calling writeback. So make sure that we do pin it, so it doesn't |
@@ -515,11 +566,20 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
515 | * 1 if we failed. | 566 | * 1 if we failed. |
516 | */ | 567 | */ |
517 | static int pin_sb_for_writeback(struct writeback_control *wbc, | 568 | static int pin_sb_for_writeback(struct writeback_control *wbc, |
518 | struct inode *inode) | 569 | struct inode *inode, struct super_block **psb) |
519 | { | 570 | { |
520 | struct super_block *sb = inode->i_sb; | 571 | struct super_block *sb = inode->i_sb; |
521 | 572 | ||
522 | /* | 573 | /* |
574 | * If this sb is already pinned, nothing more to do. If not and | ||
575 | * *psb is non-NULL, unpin the old one first | ||
576 | */ | ||
577 | if (sb == *psb) | ||
578 | return 0; | ||
579 | else if (*psb) | ||
580 | unpin_sb_for_writeback(psb); | ||
581 | |||
582 | /* | ||
523 | * Caller must already hold the ref for this | 583 | * Caller must already hold the ref for this |
524 | */ | 584 | */ |
525 | if (wbc->sync_mode == WB_SYNC_ALL) { | 585 | if (wbc->sync_mode == WB_SYNC_ALL) { |
@@ -532,7 +592,7 @@ static int pin_sb_for_writeback(struct writeback_control *wbc, | |||
532 | if (down_read_trylock(&sb->s_umount)) { | 592 | if (down_read_trylock(&sb->s_umount)) { |
533 | if (sb->s_root) { | 593 | if (sb->s_root) { |
534 | spin_unlock(&sb_lock); | 594 | spin_unlock(&sb_lock); |
535 | return 0; | 595 | goto pinned; |
536 | } | 596 | } |
537 | /* | 597 | /* |
538 | * umounted, drop rwsem again and fall through to failure | 598 | * umounted, drop rwsem again and fall through to failure |
@@ -543,24 +603,15 @@ static int pin_sb_for_writeback(struct writeback_control *wbc, | |||
543 | sb->s_count--; | 603 | sb->s_count--; |
544 | spin_unlock(&sb_lock); | 604 | spin_unlock(&sb_lock); |
545 | return 1; | 605 | return 1; |
546 | } | 606 | pinned: |
547 | 607 | *psb = sb; | |
548 | static void unpin_sb_for_writeback(struct writeback_control *wbc, | 608 | return 0; |
549 | struct inode *inode) | ||
550 | { | ||
551 | struct super_block *sb = inode->i_sb; | ||
552 | |||
553 | if (wbc->sync_mode == WB_SYNC_ALL) | ||
554 | return; | ||
555 | |||
556 | up_read(&sb->s_umount); | ||
557 | put_super(sb); | ||
558 | } | 609 | } |
559 | 610 | ||
560 | static void writeback_inodes_wb(struct bdi_writeback *wb, | 611 | static void writeback_inodes_wb(struct bdi_writeback *wb, |
561 | struct writeback_control *wbc) | 612 | struct writeback_control *wbc) |
562 | { | 613 | { |
563 | struct super_block *sb = wbc->sb; | 614 | struct super_block *sb = wbc->sb, *pin_sb = NULL; |
564 | const int is_blkdev_sb = sb_is_blkdev_sb(sb); | 615 | const int is_blkdev_sb = sb_is_blkdev_sb(sb); |
565 | const unsigned long start = jiffies; /* livelock avoidance */ | 616 | const unsigned long start = jiffies; /* livelock avoidance */ |
566 | 617 | ||
@@ -619,7 +670,7 @@ static void writeback_inodes_wb(struct bdi_writeback *wb, | |||
619 | if (inode_dirtied_after(inode, start)) | 670 | if (inode_dirtied_after(inode, start)) |
620 | break; | 671 | break; |
621 | 672 | ||
622 | if (pin_sb_for_writeback(wbc, inode)) { | 673 | if (pin_sb_for_writeback(wbc, inode, &pin_sb)) { |
623 | requeue_io(inode); | 674 | requeue_io(inode); |
624 | continue; | 675 | continue; |
625 | } | 676 | } |
@@ -628,7 +679,6 @@ static void writeback_inodes_wb(struct bdi_writeback *wb, | |||
628 | __iget(inode); | 679 | __iget(inode); |
629 | pages_skipped = wbc->pages_skipped; | 680 | pages_skipped = wbc->pages_skipped; |
630 | writeback_single_inode(inode, wbc); | 681 | writeback_single_inode(inode, wbc); |
631 | unpin_sb_for_writeback(wbc, inode); | ||
632 | if (wbc->pages_skipped != pages_skipped) { | 682 | if (wbc->pages_skipped != pages_skipped) { |
633 | /* | 683 | /* |
634 | * writeback is not making progress due to locked | 684 | * writeback is not making progress due to locked |
@@ -648,6 +698,8 @@ static void writeback_inodes_wb(struct bdi_writeback *wb, | |||
648 | wbc->more_io = 1; | 698 | wbc->more_io = 1; |
649 | } | 699 | } |
650 | 700 | ||
701 | unpin_sb_for_writeback(&pin_sb); | ||
702 | |||
651 | spin_unlock(&inode_lock); | 703 | spin_unlock(&inode_lock); |
652 | /* Leave any unwritten inodes on b_io */ | 704 | /* Leave any unwritten inodes on b_io */ |
653 | } | 705 | } |
@@ -706,6 +758,7 @@ static long wb_writeback(struct bdi_writeback *wb, | |||
706 | }; | 758 | }; |
707 | unsigned long oldest_jif; | 759 | unsigned long oldest_jif; |
708 | long wrote = 0; | 760 | long wrote = 0; |
761 | struct inode *inode; | ||
709 | 762 | ||
710 | if (wbc.for_kupdate) { | 763 | if (wbc.for_kupdate) { |
711 | wbc.older_than_this = &oldest_jif; | 764 | wbc.older_than_this = &oldest_jif; |
@@ -719,20 +772,16 @@ static long wb_writeback(struct bdi_writeback *wb, | |||
719 | 772 | ||
720 | for (;;) { | 773 | for (;;) { |
721 | /* | 774 | /* |
722 | * Don't flush anything for non-integrity writeback where | 775 | * Stop writeback when nr_pages has been consumed |
723 | * no nr_pages was given | ||
724 | */ | 776 | */ |
725 | if (!args->for_kupdate && args->nr_pages <= 0 && | 777 | if (args->nr_pages <= 0) |
726 | args->sync_mode == WB_SYNC_NONE) | ||
727 | break; | 778 | break; |
728 | 779 | ||
729 | /* | 780 | /* |
730 | * If no specific pages were given and this is just a | 781 | * For background writeout, stop when we are below the |
731 | * periodic background writeout and we are below the | 782 | * background dirty threshold |
732 | * background dirty threshold, don't do anything | ||
733 | */ | 783 | */ |
734 | if (args->for_kupdate && args->nr_pages <= 0 && | 784 | if (args->for_background && !over_bground_thresh()) |
735 | !over_bground_thresh()) | ||
736 | break; | 785 | break; |
737 | 786 | ||
738 | wbc.more_io = 0; | 787 | wbc.more_io = 0; |
@@ -744,13 +793,32 @@ static long wb_writeback(struct bdi_writeback *wb, | |||
744 | wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write; | 793 | wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write; |
745 | 794 | ||
746 | /* | 795 | /* |
747 | * If we ran out of stuff to write, bail unless more_io got set | 796 | * If we consumed everything, see if we have more |
748 | */ | 797 | */ |
749 | if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) { | 798 | if (wbc.nr_to_write <= 0) |
750 | if (wbc.more_io && !wbc.for_kupdate) | 799 | continue; |
751 | continue; | 800 | /* |
801 | * Didn't write everything and we don't have more IO, bail | ||
802 | */ | ||
803 | if (!wbc.more_io) | ||
752 | break; | 804 | break; |
805 | /* | ||
806 | * Did we write something? Try for more | ||
807 | */ | ||
808 | if (wbc.nr_to_write < MAX_WRITEBACK_PAGES) | ||
809 | continue; | ||
810 | /* | ||
811 | * Nothing written. Wait for some inode to | ||
812 | * become available for writeback. Otherwise | ||
813 | * we'll just busyloop. | ||
814 | */ | ||
815 | spin_lock(&inode_lock); | ||
816 | if (!list_empty(&wb->b_more_io)) { | ||
817 | inode = list_entry(wb->b_more_io.prev, | ||
818 | struct inode, i_list); | ||
819 | inode_wait_for_writeback(inode); | ||
753 | } | 820 | } |
821 | spin_unlock(&inode_lock); | ||
754 | } | 822 | } |
755 | 823 | ||
756 | return wrote; | 824 | return wrote; |
@@ -1060,9 +1128,6 @@ EXPORT_SYMBOL(__mark_inode_dirty); | |||
1060 | * If older_than_this is non-NULL, then only write out inodes which | 1128 | * If older_than_this is non-NULL, then only write out inodes which |
1061 | * had their first dirtying at a time earlier than *older_than_this. | 1129 | * had their first dirtying at a time earlier than *older_than_this. |
1062 | * | 1130 | * |
1063 | * If we're a pdlfush thread, then implement pdflush collision avoidance | ||
1064 | * against the entire list. | ||
1065 | * | ||
1066 | * If `bdi' is non-zero then we're being asked to writeback a specific queue. | 1131 | * If `bdi' is non-zero then we're being asked to writeback a specific queue. |
1067 | * This function assumes that the blockdev superblock's inodes are backed by | 1132 | * This function assumes that the blockdev superblock's inodes are backed by |
1068 | * a variety of queues, so all inodes are searched. For other superblocks, | 1133 | * a variety of queues, so all inodes are searched. For other superblocks, |
@@ -1141,7 +1206,7 @@ void writeback_inodes_sb(struct super_block *sb) | |||
1141 | nr_to_write = nr_dirty + nr_unstable + | 1206 | nr_to_write = nr_dirty + nr_unstable + |
1142 | (inodes_stat.nr_inodes - inodes_stat.nr_unused); | 1207 | (inodes_stat.nr_inodes - inodes_stat.nr_unused); |
1143 | 1208 | ||
1144 | bdi_writeback_all(sb, nr_to_write); | 1209 | bdi_start_writeback(sb->s_bdi, nr_to_write); |
1145 | } | 1210 | } |
1146 | EXPORT_SYMBOL(writeback_inodes_sb); | 1211 | EXPORT_SYMBOL(writeback_inodes_sb); |
1147 | 1212 | ||
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d99664e8607e..69b5fbabc8bd 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -44,18 +44,21 @@ static long ratelimit_pages = 32; | |||
44 | /* | 44 | /* |
45 | * When balance_dirty_pages decides that the caller needs to perform some | 45 | * When balance_dirty_pages decides that the caller needs to perform some |
46 | * non-background writeback, this is how many pages it will attempt to write. | 46 | * non-background writeback, this is how many pages it will attempt to write. |
47 | * It should be somewhat larger than RATELIMIT_PAGES to ensure that reasonably | 47 | * It should be somewhat larger than dirtied pages to ensure that reasonably |
48 | * large amounts of I/O are submitted. | 48 | * large amounts of I/O are submitted. |
49 | */ | 49 | */ |
50 | static inline long sync_writeback_pages(void) | 50 | static inline long sync_writeback_pages(unsigned long dirtied) |
51 | { | 51 | { |
52 | return ratelimit_pages + ratelimit_pages / 2; | 52 | if (dirtied < ratelimit_pages) |
53 | dirtied = ratelimit_pages; | ||
54 | |||
55 | return dirtied + dirtied / 2; | ||
53 | } | 56 | } |
54 | 57 | ||
55 | /* The following parameters are exported via /proc/sys/vm */ | 58 | /* The following parameters are exported via /proc/sys/vm */ |
56 | 59 | ||
57 | /* | 60 | /* |
58 | * Start background writeback (via pdflush) at this percentage | 61 | * Start background writeback (via writeback threads) at this percentage |
59 | */ | 62 | */ |
60 | int dirty_background_ratio = 10; | 63 | int dirty_background_ratio = 10; |
61 | 64 | ||
@@ -474,10 +477,11 @@ get_dirty_limits(unsigned long *pbackground, unsigned long *pdirty, | |||
474 | * balance_dirty_pages() must be called by processes which are generating dirty | 477 | * balance_dirty_pages() must be called by processes which are generating dirty |
475 | * data. It looks at the number of dirty pages in the machine and will force | 478 | * data. It looks at the number of dirty pages in the machine and will force |
476 | * the caller to perform writeback if the system is over `vm_dirty_ratio'. | 479 | * the caller to perform writeback if the system is over `vm_dirty_ratio'. |
477 | * If we're over `background_thresh' then pdflush is woken to perform some | 480 | * If we're over `background_thresh' then the writeback threads are woken to |
478 | * writeout. | 481 | * perform some writeout. |
479 | */ | 482 | */ |
480 | static void balance_dirty_pages(struct address_space *mapping) | 483 | static void balance_dirty_pages(struct address_space *mapping, |
484 | unsigned long write_chunk) | ||
481 | { | 485 | { |
482 | long nr_reclaimable, bdi_nr_reclaimable; | 486 | long nr_reclaimable, bdi_nr_reclaimable; |
483 | long nr_writeback, bdi_nr_writeback; | 487 | long nr_writeback, bdi_nr_writeback; |
@@ -485,7 +489,6 @@ static void balance_dirty_pages(struct address_space *mapping) | |||
485 | unsigned long dirty_thresh; | 489 | unsigned long dirty_thresh; |
486 | unsigned long bdi_thresh; | 490 | unsigned long bdi_thresh; |
487 | unsigned long pages_written = 0; | 491 | unsigned long pages_written = 0; |
488 | unsigned long write_chunk = sync_writeback_pages(); | ||
489 | unsigned long pause = 1; | 492 | unsigned long pause = 1; |
490 | 493 | ||
491 | struct backing_dev_info *bdi = mapping->backing_dev_info; | 494 | struct backing_dev_info *bdi = mapping->backing_dev_info; |
@@ -579,7 +582,7 @@ static void balance_dirty_pages(struct address_space *mapping) | |||
579 | bdi->dirty_exceeded = 0; | 582 | bdi->dirty_exceeded = 0; |
580 | 583 | ||
581 | if (writeback_in_progress(bdi)) | 584 | if (writeback_in_progress(bdi)) |
582 | return; /* pdflush is already working this queue */ | 585 | return; |
583 | 586 | ||
584 | /* | 587 | /* |
585 | * In laptop mode, we wait until hitting the higher threshold before | 588 | * In laptop mode, we wait until hitting the higher threshold before |
@@ -590,10 +593,10 @@ static void balance_dirty_pages(struct address_space *mapping) | |||
590 | * background_thresh, to keep the amount of dirty memory low. | 593 | * background_thresh, to keep the amount of dirty memory low. |
591 | */ | 594 | */ |
592 | if ((laptop_mode && pages_written) || | 595 | if ((laptop_mode && pages_written) || |
593 | (!laptop_mode && ((nr_writeback = global_page_state(NR_FILE_DIRTY) | 596 | (!laptop_mode && ((global_page_state(NR_FILE_DIRTY) |
594 | + global_page_state(NR_UNSTABLE_NFS)) | 597 | + global_page_state(NR_UNSTABLE_NFS)) |
595 | > background_thresh))) | 598 | > background_thresh))) |
596 | bdi_start_writeback(bdi, nr_writeback); | 599 | bdi_start_writeback(bdi, 0); |
597 | } | 600 | } |
598 | 601 | ||
599 | void set_page_dirty_balance(struct page *page, int page_mkwrite) | 602 | void set_page_dirty_balance(struct page *page, int page_mkwrite) |
@@ -640,9 +643,10 @@ void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, | |||
640 | p = &__get_cpu_var(bdp_ratelimits); | 643 | p = &__get_cpu_var(bdp_ratelimits); |
641 | *p += nr_pages_dirtied; | 644 | *p += nr_pages_dirtied; |
642 | if (unlikely(*p >= ratelimit)) { | 645 | if (unlikely(*p >= ratelimit)) { |
646 | ratelimit = sync_writeback_pages(*p); | ||
643 | *p = 0; | 647 | *p = 0; |
644 | preempt_enable(); | 648 | preempt_enable(); |
645 | balance_dirty_pages(mapping); | 649 | balance_dirty_pages(mapping, ratelimit); |
646 | return; | 650 | return; |
647 | } | 651 | } |
648 | preempt_enable(); | 652 | preempt_enable(); |
diff --git a/mm/shmem.c b/mm/shmem.c index 98631c26c200..ccf446a9faa1 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1046,8 +1046,9 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
1046 | * sync from ever calling shmem_writepage; but a stacking filesystem | 1046 | * sync from ever calling shmem_writepage; but a stacking filesystem |
1047 | * may use the ->writepage of its underlying filesystem, in which case | 1047 | * may use the ->writepage of its underlying filesystem, in which case |
1048 | * tmpfs should write out to swap only in response to memory pressure, | 1048 | * tmpfs should write out to swap only in response to memory pressure, |
1049 | * and not for pdflush or sync. However, in those cases, we do still | 1049 | * and not for the writeback threads or sync. However, in those cases, |
1050 | * want to check if there's a redundant swappage to be discarded. | 1050 | * we do still want to check if there's a redundant swappage to be |
1051 | * discarded. | ||
1051 | */ | 1052 | */ |
1052 | if (wbc->for_reclaim) | 1053 | if (wbc->for_reclaim) |
1053 | swap = get_swap_page(); | 1054 | swap = get_swap_page(); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 1219ceb8a9b2..64e438898832 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1709,10 +1709,10 @@ static void shrink_zones(int priority, struct zonelist *zonelist, | |||
1709 | * | 1709 | * |
1710 | * If the caller is !__GFP_FS then the probability of a failure is reasonably | 1710 | * If the caller is !__GFP_FS then the probability of a failure is reasonably |
1711 | * high - the zone may be full of dirty or under-writeback pages, which this | 1711 | * high - the zone may be full of dirty or under-writeback pages, which this |
1712 | * caller can't do much about. We kick pdflush and take explicit naps in the | 1712 | * caller can't do much about. We kick the writeback threads and take explicit |
1713 | * hope that some of these pages can be written. But if the allocating task | 1713 | * naps in the hope that some of these pages can be written. But if the |
1714 | * holds filesystem locks which prevent writeout this might not work, and the | 1714 | * allocating task holds filesystem locks which prevent writeout this might not |
1715 | * allocation attempt will fail. | 1715 | * work, and the allocation attempt will fail. |
1716 | * | 1716 | * |
1717 | * returns: 0, if no pages reclaimed | 1717 | * returns: 0, if no pages reclaimed |
1718 | * else, the number of pages reclaimed | 1718 | * else, the number of pages reclaimed |