summaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r--mm/hugetlb.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index cab38ef30238..81718c56b8f5 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -740,7 +740,15 @@ void resv_map_release(struct kref *ref)
740 740
741static inline struct resv_map *inode_resv_map(struct inode *inode) 741static inline struct resv_map *inode_resv_map(struct inode *inode)
742{ 742{
743 return inode->i_mapping->private_data; 743 /*
744 * At inode evict time, i_mapping may not point to the original
745 * address space within the inode. This original address space
746 * contains the pointer to the resv_map. So, always use the
747 * address space embedded within the inode.
748 * The VERY common case is inode->mapping == &inode->i_data but,
749 * this may not be true for device special inodes.
750 */
751 return (struct resv_map *)(&inode->i_data)->private_data;
744} 752}
745 753
746static struct resv_map *vma_resv_map(struct vm_area_struct *vma) 754static struct resv_map *vma_resv_map(struct vm_area_struct *vma)
@@ -4518,6 +4526,11 @@ int hugetlb_reserve_pages(struct inode *inode,
4518 * called to make the mapping read-write. Assume !vma is a shm mapping 4526 * called to make the mapping read-write. Assume !vma is a shm mapping
4519 */ 4527 */
4520 if (!vma || vma->vm_flags & VM_MAYSHARE) { 4528 if (!vma || vma->vm_flags & VM_MAYSHARE) {
4529 /*
4530 * resv_map can not be NULL as hugetlb_reserve_pages is only
4531 * called for inodes for which resv_maps were created (see
4532 * hugetlbfs_get_inode).
4533 */
4521 resv_map = inode_resv_map(inode); 4534 resv_map = inode_resv_map(inode);
4522 4535
4523 chg = region_chg(resv_map, from, to); 4536 chg = region_chg(resv_map, from, to);
@@ -4609,6 +4622,10 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
4609 struct hugepage_subpool *spool = subpool_inode(inode); 4622 struct hugepage_subpool *spool = subpool_inode(inode);
4610 long gbl_reserve; 4623 long gbl_reserve;
4611 4624
4625 /*
4626 * Since this routine can be called in the evict inode path for all
4627 * hugetlbfs inodes, resv_map could be NULL.
4628 */
4612 if (resv_map) { 4629 if (resv_map) {
4613 chg = region_del(resv_map, start, end); 4630 chg = region_del(resv_map, start, end);
4614 /* 4631 /*