Merge branch 'akpm' (patches from Andrew)
[platform/kernel/linux-rpi.git] / mm / vmscan.c
index ef4a6dc..fb95846 100644 (file)
@@ -1205,6 +1205,8 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
        BUG_ON(!PageLocked(page));
        BUG_ON(mapping != page_mapping(page));
 
+       if (!PageSwapCache(page))
+               spin_lock(&mapping->host->i_lock);
        xa_lock_irq(&mapping->i_pages);
        /*
         * The non racy check for a busy page.
@@ -1273,6 +1275,9 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
                        shadow = workingset_eviction(page, target_memcg);
                __delete_from_page_cache(page, shadow);
                xa_unlock_irq(&mapping->i_pages);
+               if (mapping_shrinkable(mapping))
+                       inode_add_lru(mapping->host);
+               spin_unlock(&mapping->host->i_lock);
 
                if (freepage != NULL)
                        freepage(page);
@@ -1282,6 +1287,8 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
 
 cannot_free:
        xa_unlock_irq(&mapping->i_pages);
+       if (!PageSwapCache(page))
+               spin_unlock(&mapping->host->i_lock);
        return 0;
 }