tmpfs: change shmem_mapping() to test shmem_aops
Subsystems (2)
Hugh Dickins
maintainerPATCH 1/1 tmpfs: change shmem_mapping() to test shmem_aops
Callers of shmem_mapping() are interested in whether the mapping is swap backed - except for uprobes, which is interested in whether it should use shmem_read_mapping_page(). All these callers are better served by a shmem_mapping() which checks for shmem_aops, than the current version which goes through several indirections to find where the inode lives - and has the surprising effect that a private mmap of /dev/zero satisfies both vma_is_anonymous() and shmem_mapping(), when that device node is on devtmpfs. I don't think anything in the tree suffers from that surprise, but it caught me out, and is better fixed.
---
mm/shmem.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/shmem.c +1 -4
@@ -2131,10 +2131,7 @@ static struct inode *shmem_get_inode(strbool shmem_mapping (struct address_space *mapping) { -if (!mapping->host) -return false; - -return mapping->host->i_sb->s_op == &shmem_ops; +return mapping->a_ops == &shmem_aops; }#ifdef CONFIG_TMPFS
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Hugh Dickins
Callers of
shmem_mapping()are interested in whether the mapping is swap backed - except for uprobes, which is interested in whether it should useshmem_read_mapping_page(). All these callers are better served by ashmem_mapping()which checks forshmem_aops, than the current version which goes through several indirections to find where the inode lives - and has the surprising effect that a private mmap of/dev/zerosatisfies bothvma_is_anonymous()andshmem_mapping(), when that device node is on devtmpfs. I don't think anything in the tree suffers from that surprise, but it caught me out, and is better fixed.Signed-off-by Hugh Dickins <[email protected]>
There are actually some existing sites that check for shmemness this way. Do you see value in converting them?
---