Commit 8fa8e538 authored by Matthew Wilcox's avatar Matthew Wilcox

page cache: Convert filemap_range_has_page to XArray

Instead of calling find_get_pages_range() and putting any reference,
use xas_find() to iterate over any entries in the range, skipping the
shadow/swap entries.
Signed-off-by: default avatarMatthew Wilcox <>
parent 22ecdb4f
......@@ -455,20 +455,31 @@ EXPORT_SYMBOL(filemap_flush);
bool filemap_range_has_page(struct address_space *mapping,
loff_t start_byte, loff_t end_byte)
pgoff_t index = start_byte >> PAGE_SHIFT;
pgoff_t end = end_byte >> PAGE_SHIFT;
struct page *page;
XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT);
pgoff_t max = end_byte >> PAGE_SHIFT;
if (end_byte < start_byte)
return false;
if (mapping->nrpages == 0)
return false;
for (;;) {
page = xas_find(&xas, max);
if (xas_retry(&xas, page))
/* Shadow entries don't count */
if (xa_is_value(page))
* We don't need to try to pin this page; we're about to
* release the RCU lock anyway. It is enough to know that
* there was a page here recently.
if (!find_get_pages_range(mapping, &index, end, 1, &page))
return false;
return true;
return page != NULL;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment