]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Remove PageSwapBacked (!page_is_file_cache) cases from
authorHugh Dickins <hughd@google.com>
Tue, 26 Jul 2011 10:14:55 +0000 (20:14 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 1 Aug 2011 03:36:37 +0000 (13:36 +1000)
add_to_page_cache_locked() and add_to_page_cache_lru(): those pages now go
through shmem_add_to_page_cache().

Remove a comment on maximum tmpfs size from fsstack_copy_inode_size(), and
add a comment on swap entries to invalidate_mapping_pages().

And mincore_page() uses find_get_page() on what might be shmem or a tmpfs
file: allow for a radix_tree_exceptional_entry(), and proceed to
find_get_page() on swapper_space if so (oh, swapper_space needs #ifdef).

Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/stack.c
mm/filemap.c
mm/mincore.c
mm/truncate.c

index 4a6f7f440658d4461a1f441a78516efe13a2c855..b4f2ab48a61f0b7c31cdfe3201d1f4bdded5ca50 100644 (file)
@@ -29,10 +29,7 @@ void fsstack_copy_inode_size(struct inode *dst, struct inode *src)
         *
         * We don't actually know what locking is used at the lower level;
         * but if it's a filesystem that supports quotas, it will be using
-        * i_lock as in inode_add_bytes().  tmpfs uses other locking, and
-        * its 32-bit is (just) able to exceed 2TB i_size with the aid of
-        * holes; but its i_blocks cannot carry into the upper long without
-        * almost 2TB swap - let's ignore that case.
+        * i_lock as in inode_add_bytes().
         */
        if (sizeof(i_blocks) > sizeof(long))
                spin_lock(&src->i_lock);
index 76bfb6460f5799e1dcb99b63138ca2b2e8712ee6..96778faf82d5b70974781836e6b7ae85150e55ad 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/cpuset.h>
 #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */
 #include <linux/memcontrol.h>
-#include <linux/mm_inline.h> /* for page_is_file_cache() */
 #include <linux/cleancache.h>
 #include "internal.h"
 
@@ -462,6 +461,7 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
        int error;
 
        VM_BUG_ON(!PageLocked(page));
+       VM_BUG_ON(PageSwapBacked(page));
 
        error = mem_cgroup_cache_charge(page, current->mm,
                                        gfp_mask & GFP_RECLAIM_MASK);
@@ -479,8 +479,6 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
                if (likely(!error)) {
                        mapping->nrpages++;
                        __inc_zone_page_state(page, NR_FILE_PAGES);
-                       if (PageSwapBacked(page))
-                               __inc_zone_page_state(page, NR_SHMEM);
                        spin_unlock_irq(&mapping->tree_lock);
                } else {
                        page->mapping = NULL;
@@ -502,22 +500,9 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 {
        int ret;
 
-       /*
-        * Splice_read and readahead add shmem/tmpfs pages into the page cache
-        * before shmem_readpage has a chance to mark them as SwapBacked: they
-        * need to go on the anon lru below, and mem_cgroup_cache_charge
-        * (called in add_to_page_cache) needs to know where they're going too.
-        */
-       if (mapping_cap_swap_backed(mapping))
-               SetPageSwapBacked(page);
-
        ret = add_to_page_cache(page, mapping, offset, gfp_mask);
-       if (ret == 0) {
-               if (page_is_file_cache(page))
-                       lru_cache_add_file(page);
-               else
-                       lru_cache_add_anon(page);
-       }
+       if (ret == 0)
+               lru_cache_add_file(page);
        return ret;
 }
 EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
index a4e6b9d75c76198be4f04d41e996f2067a97db27..8ad3e90711bdd7153fa9e0a4d180f677b38b502a 100644 (file)
@@ -69,13 +69,15 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t pgoff)
         * file will not get a swp_entry_t in its pte, but rather it is like
         * any other file mapping (ie. marked !present and faulted in with
         * tmpfs's .fault). So swapped out tmpfs mappings are tested here.
-        *
-        * However when tmpfs moves the page from pagecache and into swapcache,
-        * it is still in core, but the find_get_page below won't find it.
-        * No big deal, but make a note of it.
         */
        page = find_get_page(mapping, pgoff);
        if (page) {
+#ifdef CONFIG_SWAP
+               if (radix_tree_exceptional_entry(page)) {
+                       swp_entry_t swap = radix_to_swp_entry(page);
+                       page = find_get_page(&swapper_space, swap.val);
+               }
+#endif
                present = PageUptodate(page);
                page_cache_release(page);
        }
index 232eb2736a79624eeccfc1387e9360e78fdb0404..b40ac6d4e86e7ea7d1df670e709452948a1dcb74 100644 (file)
@@ -336,6 +336,14 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
        unsigned long count = 0;
        int i;
 
+       /*
+        * Note: this function may get called on a shmem/tmpfs mapping:
+        * pagevec_lookup() might then return 0 prematurely (because it
+        * got a gangful of swap entries); but it's hardly worth worrying
+        * about - it can rarely have anything to free from such a mapping
+        * (most pages are dirty), and already skips over any difficulties.
+        */
+
        pagevec_init(&pvec, 0);
        while (index <= end && pagevec_lookup(&pvec, mapping, index,
                        min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {