Files
i2som-imx-linux/include/linux
Johannes Weiner 0330c992f5 mm: protect set_page_dirty() from ongoing truncation
commit 2d6d7f9828 upstream.

Tejun, while reviewing the code, spotted the following race condition
between the dirtying and truncation of a page:

__set_page_dirty_nobuffers()       __delete_from_page_cache()
  if (TestSetPageDirty(page))
                                     page->mapping = NULL
				     if (PageDirty())
				       dec_zone_page_state(page, NR_FILE_DIRTY);
				       dec_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE);
    if (page->mapping)
      account_page_dirtied(page)
        __inc_zone_page_state(page, NR_FILE_DIRTY);
	__inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE);

which results in an imbalance of NR_FILE_DIRTY and BDI_RECLAIMABLE.

Dirtiers usually lock out truncation, either by holding the page lock
directly, or in case of zap_pte_range(), by pinning the mapcount with
the page table lock held.  The notable exception to this rule, though,
is do_wp_page(), for which this race exists.  However, do_wp_page()
already waits for a locked page to unlock before setting the dirty bit,
in order to prevent a race where clear_page_dirty() misses the page bit
in the presence of dirty ptes.  Upgrade that wait to a fully locked
set_page_dirty() to also cover the situation explained above.

Afterwards, the code in set_page_dirty() dealing with a truncation race
is no longer needed.  Remove it.

Reported-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 3.2:
 - Adjust context
 - Use VM_BUG_ON() rather than VM_BUG_ON_PAGE()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2015-02-20 00:49:35 +00:00
..
2014-01-03 04:33:18 +00:00
2012-11-16 16:46:48 +00:00
2013-09-10 01:57:27 +01:00
2014-12-14 16:23:48 +00:00
2014-12-14 16:23:49 +00:00
2013-01-03 03:32:57 +00:00
2013-03-06 03:23:57 +00:00
2013-08-02 22:14:47 +02:00
2012-08-10 00:11:14 +01:00
2012-07-25 04:11:19 +01:00
2014-08-06 18:07:42 +01:00
2013-03-06 03:24:27 +00:00
2013-04-25 20:25:38 +01:00
2012-10-10 03:30:45 +01:00
2013-07-27 05:34:29 +01:00
2013-04-25 20:25:40 +01:00
2014-02-15 19:20:16 +00:00
2014-04-02 00:58:44 +01:00
2014-07-11 13:33:35 +01:00
2014-08-06 18:07:42 +01:00
2013-01-16 01:13:25 +00:00
2012-07-12 04:31:59 +01:00