diff options
| author | Mike Kravetz <[email protected]> | 2023-06-21 21:24:03 +0000 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2023-06-23 23:59:32 +0000 |
| commit | fd4aed8d985a3236d0877ff6d0c80ad39d4ce81a (patch) | |
| tree | 01380ababa937d48b99e002c82cea9c6836bee46 /mm/hugetlb.c | |
| parent | Revert "page cache: fix page_cache_next/prev_miss off by one" (diff) | |
| download | kernel-fd4aed8d985a3236d0877ff6d0c80ad39d4ce81a.tar.gz kernel-fd4aed8d985a3236d0877ff6d0c80ad39d4ce81a.zip | |
hugetlb: revert use of page_cache_next_miss()
Ackerley Tng reported an issue with hugetlbfs fallocate as noted in the
Closes tag. The issue showed up after the conversion of hugetlb page
cache lookup code to use page_cache_next_miss. User visible effects are:
- hugetlbfs fallocate incorrectly returns -EEXIST if pages are presnet
in the file.
- hugetlb pages will not be included in core dumps if they need to be
brought in via GUP.
- userfaultfd UFFDIO_COPY will not notice pages already present in the
cache. It may try to allocate a new page and potentially return
ENOMEM as opposed to EEXIST.
Revert the use page_cache_next_miss() in hugetlb code.
IMPORTANT NOTE FOR STABLE BACKPORTS:
This patch will apply cleanly to v6.3. However, due to the change of
filemap_get_folio() return values, it will not function correctly. This
patch must be modified for stable backports.
[[email protected]: fix hugetlbfs_pagecache_present()]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Fixes: d0ce0e47b323 ("mm/hugetlb: convert hugetlb fault paths to use alloc_hugetlb_folio()")
Signed-off-by: Mike Kravetz <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Reported-by: Ackerley Tng <[email protected]>
Closes: https://lore.kernel.org/linux-mm/[email protected]
Reviewed-by: Sidhartha Kumar <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Vishal Annapurve <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'mm/hugetlb.c')
| -rw-r--r-- | mm/hugetlb.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d76574425da3..bce28cca73a1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5728,13 +5728,13 @@ static bool hugetlbfs_pagecache_present(struct hstate *h, { struct address_space *mapping = vma->vm_file->f_mapping; pgoff_t idx = vma_hugecache_offset(h, vma, address); - bool present; - - rcu_read_lock(); - present = page_cache_next_miss(mapping, idx, 1) != idx; - rcu_read_unlock(); + struct folio *folio; - return present; + folio = filemap_get_folio(mapping, idx); + if (IS_ERR(folio)) + return false; + folio_put(folio); + return true; } int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping, |
