fs-writeback.c: unify some common code

The btrfs merge looks like hell, because it changes fs-writeback.c, and
the crazy code has this repeated "estimate number of dirty pages"
counting that involves three different helper functions. And it's done
in two different places.

Just unify that whole calculation as a "get_nr_dirty_pages()" helper
function, and the merge result will look half-way decent.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+13 -10
+13 -10
fs/fs-writeback.c
··· 707 return work; 708 } 709 710 static long wb_check_old_data_flush(struct bdi_writeback *wb) 711 { 712 unsigned long expired; ··· 735 return 0; 736 737 wb->last_old_flush = jiffies; 738 - /* 739 - * Add in the number of potentially dirty inodes, because each inode 740 - * write can dirty pagecache in the underlying blockdev. 741 - */ 742 - nr_pages = global_page_state(NR_FILE_DIRTY) + 743 - global_page_state(NR_UNSTABLE_NFS) + 744 - get_nr_dirty_inodes(); 745 746 if (nr_pages) { 747 struct wb_writeback_work work = { ··· 1091 */ 1092 void writeback_inodes_sb(struct super_block *sb) 1093 { 1094 - unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); 1095 - unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS); 1096 DECLARE_COMPLETION_ONSTACK(done); 1097 struct wb_writeback_work work = { 1098 .sb = sb, ··· 1100 1101 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 1102 1103 - work.nr_pages = nr_dirty + nr_unstable + get_nr_dirty_inodes(); 1104 1105 bdi_queue_work(sb->s_bdi, &work); 1106 wait_for_completion(&done);
··· 707 return work; 708 } 709 710 + /* 711 + * Add in the number of potentially dirty inodes, because each inode 712 + * write can dirty pagecache in the underlying blockdev. 713 + */ 714 + static unsigned long get_nr_dirty_pages(void) 715 + { 716 + return global_page_state(NR_FILE_DIRTY) + 717 + global_page_state(NR_UNSTABLE_NFS) + 718 + get_nr_dirty_inodes(); 719 + } 720 + 721 static long wb_check_old_data_flush(struct bdi_writeback *wb) 722 { 723 unsigned long expired; ··· 724 return 0; 725 726 wb->last_old_flush = jiffies; 727 + nr_pages = get_nr_dirty_pages(); 728 729 if (nr_pages) { 730 struct wb_writeback_work work = { ··· 1086 */ 1087 void writeback_inodes_sb(struct super_block *sb) 1088 { 1089 DECLARE_COMPLETION_ONSTACK(done); 1090 struct wb_writeback_work work = { 1091 .sb = sb, ··· 1097 1098 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 1099 1100 + work.nr_pages = get_nr_dirty_pages(); 1101 1102 bdi_queue_work(sb->s_bdi, &work); 1103 wait_for_completion(&done);