aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/buffer.c25
-rw-r--r--mm/page-writeback.c88
2 files changed, 55 insertions, 58 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 517860f2d75b..865570fe0d39 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -724,20 +724,19 @@ int __set_page_dirty_buffers(struct page *page)
724 } 724 }
725 spin_unlock(&mapping->private_lock); 725 spin_unlock(&mapping->private_lock);
726 726
727 if (!TestSetPageDirty(page)) { 727 if (TestSetPageDirty(page))
728 write_lock_irq(&mapping->tree_lock); 728 return 0;
729 if (page->mapping) { /* Race with truncate? */ 729
730 if (mapping_cap_account_dirty(mapping)) 730 write_lock_irq(&mapping->tree_lock);
731 __inc_zone_page_state(page, NR_FILE_DIRTY); 731 if (page->mapping) { /* Race with truncate? */
732 radix_tree_tag_set(&mapping->page_tree, 732 if (mapping_cap_account_dirty(mapping))
733 page_index(page), 733 __inc_zone_page_state(page, NR_FILE_DIRTY);
734 PAGECACHE_TAG_DIRTY); 734 radix_tree_tag_set(&mapping->page_tree,
735 } 735 page_index(page), PAGECACHE_TAG_DIRTY);
736 write_unlock_irq(&mapping->tree_lock);
737 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
738 return 1;
739 } 736 }
740 return 0; 737 write_unlock_irq(&mapping->tree_lock);
738 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
739 return 1;
741} 740}
742EXPORT_SYMBOL(__set_page_dirty_buffers); 741EXPORT_SYMBOL(__set_page_dirty_buffers);
743 742
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 8d9b19f239c3..59ffcdbde8b3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -761,23 +761,22 @@ int __set_page_dirty_nobuffers(struct page *page)
761 struct address_space *mapping = page_mapping(page); 761 struct address_space *mapping = page_mapping(page);
762 struct address_space *mapping2; 762 struct address_space *mapping2;
763 763
764 if (mapping) { 764 if (!mapping)
765 write_lock_irq(&mapping->tree_lock); 765 return 1;
766 mapping2 = page_mapping(page); 766
767 if (mapping2) { /* Race with truncate? */ 767 write_lock_irq(&mapping->tree_lock);
768 BUG_ON(mapping2 != mapping); 768 mapping2 = page_mapping(page);
769 if (mapping_cap_account_dirty(mapping)) 769 if (mapping2) { /* Race with truncate? */
770 __inc_zone_page_state(page, 770 BUG_ON(mapping2 != mapping);
771 NR_FILE_DIRTY); 771 if (mapping_cap_account_dirty(mapping))
772 radix_tree_tag_set(&mapping->page_tree, 772 __inc_zone_page_state(page, NR_FILE_DIRTY);
773 page_index(page), PAGECACHE_TAG_DIRTY); 773 radix_tree_tag_set(&mapping->page_tree,
774 } 774 page_index(page), PAGECACHE_TAG_DIRTY);
775 write_unlock_irq(&mapping->tree_lock); 775 }
776 if (mapping->host) { 776 write_unlock_irq(&mapping->tree_lock);
777 /* !PageAnon && !swapper_space */ 777 if (mapping->host) {
778 __mark_inode_dirty(mapping->host, 778 /* !PageAnon && !swapper_space */
779 I_DIRTY_PAGES); 779 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
780 }
781 } 780 }
782 return 1; 781 return 1;
783 } 782 }
@@ -851,27 +850,26 @@ int test_clear_page_dirty(struct page *page)
851 struct address_space *mapping = page_mapping(page); 850 struct address_space *mapping = page_mapping(page);
852 unsigned long flags; 851 unsigned long flags;
853 852
854 if (mapping) { 853 if (!mapping)
855 write_lock_irqsave(&mapping->tree_lock, flags); 854 return TestClearPageDirty(page);
856 if (TestClearPageDirty(page)) { 855
857 radix_tree_tag_clear(&mapping->page_tree, 856 write_lock_irqsave(&mapping->tree_lock, flags);
858 page_index(page), 857 if (TestClearPageDirty(page)) {
859 PAGECACHE_TAG_DIRTY); 858 radix_tree_tag_clear(&mapping->page_tree,
860 write_unlock_irqrestore(&mapping->tree_lock, flags); 859 page_index(page), PAGECACHE_TAG_DIRTY);
861 /*
862 * We can continue to use `mapping' here because the
863 * page is locked, which pins the address_space
864 */
865 if (mapping_cap_account_dirty(mapping)) {
866 page_mkclean(page);
867 dec_zone_page_state(page, NR_FILE_DIRTY);
868 }
869 return 1;
870 }
871 write_unlock_irqrestore(&mapping->tree_lock, flags); 860 write_unlock_irqrestore(&mapping->tree_lock, flags);
872 return 0; 861 /*
862 * We can continue to use `mapping' here because the
863 * page is locked, which pins the address_space
864 */
865 if (mapping_cap_account_dirty(mapping)) {
866 page_mkclean(page);
867 dec_zone_page_state(page, NR_FILE_DIRTY);
868 }
869 return 1;
873 } 870 }
874 return TestClearPageDirty(page); 871 write_unlock_irqrestore(&mapping->tree_lock, flags);
872 return 0;
875} 873}
876EXPORT_SYMBOL(test_clear_page_dirty); 874EXPORT_SYMBOL(test_clear_page_dirty);
877 875
@@ -893,17 +891,17 @@ int clear_page_dirty_for_io(struct page *page)
893{ 891{
894 struct address_space *mapping = page_mapping(page); 892 struct address_space *mapping = page_mapping(page);
895 893
896 if (mapping) { 894 if (!mapping)
897 if (TestClearPageDirty(page)) { 895 return TestClearPageDirty(page);
898 if (mapping_cap_account_dirty(mapping)) { 896
899 page_mkclean(page); 897 if (TestClearPageDirty(page)) {
900 dec_zone_page_state(page, NR_FILE_DIRTY); 898 if (mapping_cap_account_dirty(mapping)) {
901 } 899 page_mkclean(page);
902 return 1; 900 dec_zone_page_state(page, NR_FILE_DIRTY);
903 } 901 }
904 return 0; 902 return 1;
905 } 903 }
906 return TestClearPageDirty(page); 904 return 0;
907} 905}
908EXPORT_SYMBOL(clear_page_dirty_for_io); 906EXPORT_SYMBOL(clear_page_dirty_for_io);
909 907