Skip to content

Commit

Permalink
tmpfs: change shmem_mapping() to test shmem_aops
Browse files Browse the repository at this point in the history
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.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Hugh Dickins <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hugh Dickins authored and torvalds committed Feb 23, 2017
1 parent 1663f26 commit f800545
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2175,10 +2175,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode

bool 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
Expand Down

0 comments on commit f800545

Please sign in to comment.