@@ -134,6 +134,13 @@ static inline bool shmem_file(struct file *file)
return shmem_mapping(file->f_mapping);
}
+static inline struct shared_policy *shmem_shared_policy(struct file *file)
+{
+ struct inode *inode = file_inode(file);
+
+ return &SHMEM_I(inode)->policy;
+}
+
/*
* If fallocate(FALLOC_FL_KEEP_SIZE) has been used, there may be pages
* beyond i_size's notion of EOF, which fallocate has committed to reserving:
@@ -2248,20 +2248,22 @@ unsigned long shmem_get_unmapped_area(struct file *file,
}
#ifdef CONFIG_NUMA
+
static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
{
- struct inode *inode = file_inode(vma->vm_file);
- return mpol_set_shared_policy(&SHMEM_I(inode)->policy, vma, mpol);
+ struct shared_policy *info;
+
+ info = shmem_shared_policy(vma->vm_file);
+ return mpol_set_shared_policy(info, vma, mpol);
}
static struct mempolicy *shmem_get_policy(struct vm_area_struct *vma,
unsigned long addr)
{
- struct inode *inode = file_inode(vma->vm_file);
pgoff_t index;
index = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
- return mpol_shared_policy_lookup(&SHMEM_I(inode)->policy, index);
+ return mpol_shared_policy_lookup(shmem_shared_policy(vma->vm_file), index);
}
#endif
Refactor out shmem_shared_policy() to allow reading of a file's shared mempolicy Signed-off-by: Ackerley Tng <ackerleytng@google.com> --- include/linux/shmem_fs.h | 7 +++++++ mm/shmem.c | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)