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 707 return work; 708 708 } 709 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 + 710 721 static long wb_check_old_data_flush(struct bdi_writeback *wb) 711 722 { 712 723 unsigned long expired; ··· 735 724 return 0; 736 725 737 726 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(); 727 + nr_pages = get_nr_dirty_pages(); 745 728 746 729 if (nr_pages) { 747 730 struct wb_writeback_work work = { ··· 1091 1086 */ 1092 1087 void writeback_inodes_sb(struct super_block *sb) 1093 1088 { 1094 - unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); 1095 - unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS); 1096 1089 DECLARE_COMPLETION_ONSTACK(done); 1097 1090 struct wb_writeback_work work = { 1098 1091 .sb = sb, ··· 1100 1097 1101 1098 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 1102 1099 1103 - work.nr_pages = nr_dirty + nr_unstable + get_nr_dirty_inodes(); 1100 + work.nr_pages = get_nr_dirty_pages(); 1104 1101 1105 1102 bdi_queue_work(sb->s_bdi, &work); 1106 1103 wait_for_completion(&done);