Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux-2.6-microblaze.git] / fs / buffer.c
index 0cb7ffd..6290c3a 100644 (file)
@@ -588,31 +588,6 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
 }
 EXPORT_SYMBOL(mark_buffer_dirty_inode);
 
-/*
- * 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);
-}
-EXPORT_SYMBOL_GPL(__set_page_dirty);
-
 /*
  * Add a page to the dirty page list.
  *
@@ -1020,11 +995,7 @@ grow_buffers(struct block_device *bdev, sector_t block, int size, gfp_t gfp)
        pgoff_t index;
        int sizebits;
 
-       sizebits = -1;
-       do {
-               sizebits++;
-       } while ((size << sizebits) < PAGE_SIZE);
-
+       sizebits = PAGE_SHIFT - __ffs(size);
        index = block >> sizebits;
 
        /*
@@ -1264,6 +1235,15 @@ static void bh_lru_install(struct buffer_head *bh)
        int i;
 
        check_irqs_on();
+       /*
+        * the refcount of buffer_head in bh_lru prevents dropping the
+        * attached page(i.e., try_to_free_buffers) so it could cause
+        * failing page migration.
+        * Skip putting upcoming bh into bh_lru until migration is done.
+        */
+       if (lru_cache_disabled())
+               return;
+
        bh_lru_lock();
 
        b = this_cpu_ptr(&bh_lrus);
@@ -1404,6 +1384,15 @@ __bread_gfp(struct block_device *bdev, sector_t block,
 }
 EXPORT_SYMBOL(__bread_gfp);
 
+static void __invalidate_bh_lrus(struct bh_lru *b)
+{
+       int i;
+
+       for (i = 0; i < BH_LRU_SIZE; i++) {
+               brelse(b->bhs[i]);
+               b->bhs[i] = NULL;
+       }
+}
 /*
  * invalidate_bh_lrus() is called rarely - but not only at unmount.
  * This doesn't race because it runs in each cpu either in irq
@@ -1412,16 +1401,12 @@ EXPORT_SYMBOL(__bread_gfp);
 static void invalidate_bh_lru(void *arg)
 {
        struct bh_lru *b = &get_cpu_var(bh_lrus);
-       int i;
 
-       for (i = 0; i < BH_LRU_SIZE; i++) {
-               brelse(b->bhs[i]);
-               b->bhs[i] = NULL;
-       }
+       __invalidate_bh_lrus(b);
        put_cpu_var(bh_lrus);
 }
 
-static bool has_bh_in_lru(int cpu, void *dummy)
+bool has_bh_in_lru(int cpu, void *dummy)
 {
        struct bh_lru *b = per_cpu_ptr(&bh_lrus, cpu);
        int i;
@@ -1440,6 +1425,16 @@ void invalidate_bh_lrus(void)
 }
 EXPORT_SYMBOL_GPL(invalidate_bh_lrus);
 
+void invalidate_bh_lrus_cpu(int cpu)
+{
+       struct bh_lru *b;
+
+       bh_lru_lock();
+       b = per_cpu_ptr(&bh_lrus, cpu);
+       __invalidate_bh_lrus(b);
+       bh_lru_unlock();
+}
+
 void set_bh_page(struct buffer_head *bh,
                struct page *page, unsigned long offset)
 {