diff options
author | Mike Kravetz <mike.kravetz@oracle.com> | 2019-05-13 20:22:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-14 12:47:50 -0400 |
commit | f27a5136f70a8c90e8b30a983b6f54540742f849 (patch) | |
tree | d8c614cbaa67b50e754c37ff250e9d9722293772 /fs/hugetlbfs/inode.c | |
parent | 1f862989b04ade61d3aab49184c50e9957f84c7d (diff) |
hugetlbfs: always use address space in inode for resv_map pointer
Continuing discussion about 58b6e5e8f1ad ("hugetlbfs: fix memory leak for
resv_map") brought up the issue that inode->i_mapping may not point to the
address space embedded within the inode at inode eviction time. The
hugetlbfs truncate routine handles this by explicitly using inode->i_data.
However, code cleaning up the resv_map will still use the address space
pointed to by inode->i_mapping. Luckily, private_data is NULL for address
spaces in all such cases today but, there is no guarantee this will
continue.
Change all hugetlbfs code getting a resv_map pointer to explicitly get it
from the address space embedded within the inode. In addition, add more
comments in the code to indicate why this is being done.
Link: http://lkml.kernel.org/r/20190419204435.16984-1-mike.kravetz@oracle.com
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Reported-by: Yufen Yu <yuyufen@huawei.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r-- | fs/hugetlbfs/inode.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index f23237135163..1dcc57189382 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -497,8 +497,15 @@ static void hugetlbfs_evict_inode(struct inode *inode) | |||
497 | struct resv_map *resv_map; | 497 | struct resv_map *resv_map; |
498 | 498 | ||
499 | remove_inode_hugepages(inode, 0, LLONG_MAX); | 499 | remove_inode_hugepages(inode, 0, LLONG_MAX); |
500 | resv_map = (struct resv_map *)inode->i_mapping->private_data; | 500 | |
501 | /* root inode doesn't have the resv_map, so we should check it */ | 501 | /* |
502 | * Get the resv_map from the address space embedded in the inode. | ||
503 | * This is the address space which points to any resv_map allocated | ||
504 | * at inode creation time. If this is a device special inode, | ||
505 | * i_mapping may not point to the original address space. | ||
506 | */ | ||
507 | resv_map = (struct resv_map *)(&inode->i_data)->private_data; | ||
508 | /* Only regular and link inodes have associated reserve maps */ | ||
502 | if (resv_map) | 509 | if (resv_map) |
503 | resv_map_release(&resv_map->refs); | 510 | resv_map_release(&resv_map->refs); |
504 | clear_inode(inode); | 511 | clear_inode(inode); |