Jan Kara 08142579b6 mm: fix assertion mapping->nrpages == 0 in end_writeback()
Under heavy memory and filesystem load, users observe the assertion
mapping->nrpages == 0 in end_writeback() trigger.  This can be caused by
page reclaim reclaiming the last page from a mapping in the following
race:

	CPU0				CPU1
  ...
  shrink_page_list()
    __remove_mapping()
      __delete_from_page_cache()
        radix_tree_delete()
					evict_inode()
					  truncate_inode_pages()
					    truncate_inode_pages_range()
					      pagevec_lookup() - finds nothing
					  end_writeback()
					    mapping->nrpages != 0 -> BUG
        page->mapping = NULL
        mapping->nrpages--

Fix the problem by doing a reliable check of mapping->nrpages under
mapping->tree_lock in end_writeback().

Analyzed by Jay <jinshan.xiong@whamcloud.com>, lost in LKML, and dug out
by Miklos Szeredi <mszeredi@suse.de>.

Cc: Jay <jinshan.xiong@whamcloud.com>
Cc: Miklos Szeredi <mszeredi@suse.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-06-27 18:00:13 -07:00
..
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-06-07 21:36:45 -07:00
2011-05-19 16:55:28 +09:30
2011-03-10 08:52:07 +01:00
2011-06-06 09:51:52 -04:00
2011-06-03 18:24:58 -04:00
2011-01-07 17:50:26 +11:00
2011-06-20 17:53:24 -05:00
2011-06-21 11:54:07 -04:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-06-03 18:24:58 -04:00
2011-01-07 17:50:26 +11:00
2011-03-10 08:52:07 +01:00
2011-04-14 16:06:56 -07:00
2010-10-29 04:16:28 -04:00
2011-03-31 11:26:23 -03:00
2011-03-21 00:16:08 -04:00
2011-05-26 07:26:50 -04:00
2011-05-26 10:01:43 -06:00
2011-06-20 10:45:56 -04:00
2011-03-21 01:10:41 -04:00
2011-01-07 17:50:33 +11:00
2011-05-23 19:58:53 +02:00
2011-03-14 09:15:28 -04:00
2011-06-03 18:24:58 -04:00