mm: replace CONFIG_NEED_MULTIPLE_NODES with CONFIG_NUMA
[linux-2.6-microblaze.git] / mm / page-writeback.c
index c2a849d..e5b38ff 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/sysctl.h>
 #include <linux/cpu.h>
 #include <linux/syscalls.h>
-#include <linux/buffer_head.h> /* __set_page_dirty_buffers */
 #include <linux/pagevec.h>
 #include <linux/timer.h>
 #include <linux/sched/rt.h>
@@ -2418,6 +2417,7 @@ int __set_page_dirty_no_writeback(struct page *page)
                return !TestSetPageDirty(page);
        return 0;
 }
+EXPORT_SYMBOL(__set_page_dirty_no_writeback);
 
 /*
  * Helper function for set_page_dirty family.
@@ -2426,7 +2426,8 @@ int __set_page_dirty_no_writeback(struct page *page)
  *
  * NOTE: This relies on being atomic wrt interrupts.
  */
-void account_page_dirtied(struct page *page, struct address_space *mapping)
+static void account_page_dirtied(struct page *page,
+               struct address_space *mapping)
 {
        struct inode *inode = mapping->host;
 
@@ -2467,6 +2468,30 @@ void account_page_cleaned(struct page *page, struct address_space *mapping,
        }
 }
 
+/*
+ * Mark the page dirty, and set it dirty in the page cache, and mark the inode
+ * dirty.
+ *
+ * If warn is true, then emit a warning if the page is not uptodate and has
+ * not been truncated.
+ *
+ * The caller must hold lock_page_memcg().
+ */
+void __set_page_dirty(struct page *page, struct address_space *mapping,
+                            int warn)
+{
+       unsigned long flags;
+
+       xa_lock_irqsave(&mapping->i_pages, flags);
+       if (page->mapping) {    /* Race with truncate? */
+               WARN_ON_ONCE(warn && !PageUptodate(page));
+               account_page_dirtied(page, mapping);
+               __xa_set_mark(&mapping->i_pages, page_index(page),
+                               PAGECACHE_TAG_DIRTY);
+       }
+       xa_unlock_irqrestore(&mapping->i_pages, flags);
+}
+
 /*
  * For address_spaces which do not use buffers.  Just tag the page as dirty in
  * the xarray.
@@ -2484,20 +2509,12 @@ int __set_page_dirty_nobuffers(struct page *page)
        lock_page_memcg(page);
        if (!TestSetPageDirty(page)) {
                struct address_space *mapping = page_mapping(page);
-               unsigned long flags;
 
                if (!mapping) {
                        unlock_page_memcg(page);
                        return 1;
                }
-
-               xa_lock_irqsave(&mapping->i_pages, flags);
-               BUG_ON(page_mapping(page) != mapping);
-               WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
-               account_page_dirtied(page, mapping);
-               __xa_set_mark(&mapping->i_pages, page_index(page),
-                                  PAGECACHE_TAG_DIRTY);
-               xa_unlock_irqrestore(&mapping->i_pages, flags);
+               __set_page_dirty(page, mapping, !PagePrivate(page));
                unlock_page_memcg(page);
 
                if (mapping->host) {
@@ -2555,13 +2572,9 @@ EXPORT_SYMBOL(redirty_page_for_writepage);
 /*
  * Dirty a page.
  *
- * For pages with a mapping this should be done under the page lock
- * for the benefit of asynchronous memory errors who prefer a consistent
- * dirty state. This rule can be broken in some special cases,
- * but should be better not to.
- *
- * If the mapping doesn't provide a set_page_dirty a_op, then
- * just fall through and assume that it wants buffer_heads.
+ * For pages with a mapping this should be done under the page lock for the
+ * benefit of asynchronous memory errors who prefer a consistent dirty state.
+ * This rule can be broken in some special cases, but should be better not to.
  */
 int set_page_dirty(struct page *page)
 {
@@ -2569,7 +2582,6 @@ int set_page_dirty(struct page *page)
 
        page = compound_head(page);
        if (likely(mapping)) {
-               int (*spd)(struct page *) = mapping->a_ops->set_page_dirty;
                /*
                 * readahead/lru_deactivate_page could remain
                 * PG_readahead/PG_reclaim due to race with end_page_writeback
@@ -2582,11 +2594,7 @@ int set_page_dirty(struct page *page)
                 */
                if (PageReclaim(page))
                        ClearPageReclaim(page);
-#ifdef CONFIG_BLOCK
-               if (!spd)
-                       spd = __set_page_dirty_buffers;
-#endif
-               return (*spd)(page);
+               return mapping->a_ops->set_page_dirty(page);
        }
        if (!PageDirty(page)) {
                if (!TestSetPageDirty(page))