From fbf7adfafae19dd118facbbfe011510ba6aa8315 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 12 Apr 2004 00:54:31 -0700 Subject: [PATCH] rmap 3 arches + mapping_mapped From: Hugh Dickins Some arches refer to page->mapping for their dcache flushing: use page_mapping(page) for safety, to avoid confusion on anon pages, which will store a different pointer there - though in most cases flush_dcache_page is being applied to pagecache pages. arm has a useful mapping_mapped macro: move that to generic, and add mapping_writably_mapped, to avoid explicit list_empty checks on i_mmap and i_mmap_shared in several places. Very tempted to add page_mapped(page) tests, perhaps along with the mapping_writably_mapped tests in do_generic_mapping_read and do_shmem_file_read, to cut down on wasted flush_dcache effort; but the serialization is not obvious, too unsafe to do in a hurry. --- include/linux/fs.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/linux') diff --git a/include/linux/fs.h b/include/linux/fs.h index c7f0052b4abd..3d7c320d675e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -373,6 +373,26 @@ struct block_device { int mapping_tagged(struct address_space *mapping, int tag); +/* + * Might pages of this file be mapped into userspace? + */ +static inline int mapping_mapped(struct address_space *mapping) +{ + return !list_empty(&mapping->i_mmap) || + !list_empty(&mapping->i_mmap_shared); +} + +/* + * Might pages of this file have been modified in userspace? + * Note that i_mmap_shared holds all the VM_SHARED vmas: do_mmap_pgoff + * marks vma as VM_SHARED if it is shared, and the file was opened for + * writing i.e. vma may be mprotected writable even if now readonly. + */ +static inline int mapping_writably_mapped(struct address_space *mapping) +{ + return !list_empty(&mapping->i_mmap_shared); +} + /* * Use sequence counter to get consistent i_size on 32-bit processors. */ -- cgit v1.2.3