aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fs-writeback.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fs-writeback.c')
-rw-r--r--fs/fs-writeback.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index e0259a163f98..d754e3cf99a8 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -40,18 +40,13 @@
40struct wb_writeback_work { 40struct wb_writeback_work {
41 long nr_pages; 41 long nr_pages;
42 struct super_block *sb; 42 struct super_block *sb;
43 /* 43 unsigned long *older_than_this;
44 * Write only inodes dirtied before this time. Don't forget to set
45 * older_than_this_is_set when you set this.
46 */
47 unsigned long older_than_this;
48 enum writeback_sync_modes sync_mode; 44 enum writeback_sync_modes sync_mode;
49 unsigned int tagged_writepages:1; 45 unsigned int tagged_writepages:1;
50 unsigned int for_kupdate:1; 46 unsigned int for_kupdate:1;
51 unsigned int range_cyclic:1; 47 unsigned int range_cyclic:1;
52 unsigned int for_background:1; 48 unsigned int for_background:1;
53 unsigned int for_sync:1; /* sync(2) WB_SYNC_ALL writeback */ 49 unsigned int for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
54 unsigned int older_than_this_is_set:1;
55 enum wb_reason reason; /* why was writeback initiated? */ 50 enum wb_reason reason; /* why was writeback initiated? */
56 51
57 struct list_head list; /* pending work list */ 52 struct list_head list; /* pending work list */
@@ -252,10 +247,10 @@ static int move_expired_inodes(struct list_head *delaying_queue,
252 int do_sb_sort = 0; 247 int do_sb_sort = 0;
253 int moved = 0; 248 int moved = 0;
254 249
255 WARN_ON_ONCE(!work->older_than_this_is_set);
256 while (!list_empty(delaying_queue)) { 250 while (!list_empty(delaying_queue)) {
257 inode = wb_inode(delaying_queue->prev); 251 inode = wb_inode(delaying_queue->prev);
258 if (inode_dirtied_after(inode, work->older_than_this)) 252 if (work->older_than_this &&
253 inode_dirtied_after(inode, *work->older_than_this))
259 break; 254 break;
260 list_move(&inode->i_wb_list, &tmp); 255 list_move(&inode->i_wb_list, &tmp);
261 moved++; 256 moved++;
@@ -742,8 +737,6 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
742 .sync_mode = WB_SYNC_NONE, 737 .sync_mode = WB_SYNC_NONE,
743 .range_cyclic = 1, 738 .range_cyclic = 1,
744 .reason = reason, 739 .reason = reason,
745 .older_than_this = jiffies,
746 .older_than_this_is_set = 1,
747 }; 740 };
748 741
749 spin_lock(&wb->list_lock); 742 spin_lock(&wb->list_lock);
@@ -802,13 +795,12 @@ static long wb_writeback(struct bdi_writeback *wb,
802{ 795{
803 unsigned long wb_start = jiffies; 796 unsigned long wb_start = jiffies;
804 long nr_pages = work->nr_pages; 797 long nr_pages = work->nr_pages;
798 unsigned long oldest_jif;
805 struct inode *inode; 799 struct inode *inode;
806 long progress; 800 long progress;
807 801
808 if (!work->older_than_this_is_set) { 802 oldest_jif = jiffies;
809 work->older_than_this = jiffies; 803 work->older_than_this = &oldest_jif;
810 work->older_than_this_is_set = 1;
811 }
812 804
813 spin_lock(&wb->list_lock); 805 spin_lock(&wb->list_lock);
814 for (;;) { 806 for (;;) {
@@ -842,10 +834,10 @@ static long wb_writeback(struct bdi_writeback *wb,
842 * safe. 834 * safe.
843 */ 835 */
844 if (work->for_kupdate) { 836 if (work->for_kupdate) {
845 work->older_than_this = jiffies - 837 oldest_jif = jiffies -
846 msecs_to_jiffies(dirty_expire_interval * 10); 838 msecs_to_jiffies(dirty_expire_interval * 10);
847 } else if (work->for_background) 839 } else if (work->for_background)
848 work->older_than_this = jiffies; 840 oldest_jif = jiffies;
849 841
850 trace_writeback_start(wb->bdi, work); 842 trace_writeback_start(wb->bdi, work);
851 if (list_empty(&wb->b_io)) 843 if (list_empty(&wb->b_io))
@@ -1357,21 +1349,18 @@ EXPORT_SYMBOL(try_to_writeback_inodes_sb);
1357 1349
1358/** 1350/**
1359 * sync_inodes_sb - sync sb inode pages 1351 * sync_inodes_sb - sync sb inode pages
1360 * @sb: the superblock 1352 * @sb: the superblock
1361 * @older_than_this: timestamp
1362 * 1353 *
1363 * This function writes and waits on any dirty inode belonging to this 1354 * This function writes and waits on any dirty inode belonging to this
1364 * superblock that has been dirtied before given timestamp. 1355 * super_block.
1365 */ 1356 */
1366void sync_inodes_sb(struct super_block *sb, unsigned long older_than_this) 1357void sync_inodes_sb(struct super_block *sb)
1367{ 1358{
1368 DECLARE_COMPLETION_ONSTACK(done); 1359 DECLARE_COMPLETION_ONSTACK(done);
1369 struct wb_writeback_work work = { 1360 struct wb_writeback_work work = {
1370 .sb = sb, 1361 .sb = sb,
1371 .sync_mode = WB_SYNC_ALL, 1362 .sync_mode = WB_SYNC_ALL,
1372 .nr_pages = LONG_MAX, 1363 .nr_pages = LONG_MAX,
1373 .older_than_this = older_than_this,
1374 .older_than_this_is_set = 1,
1375 .range_cyclic = 0, 1364 .range_cyclic = 0,
1376 .done = &done, 1365 .done = &done,
1377 .reason = WB_REASON_SYNC, 1366 .reason = WB_REASON_SYNC,