xarray: Replace exceptional entries

Introduce xarray value entries and tagged pointers to replace radix
tree exceptional entries.  This is a slight change in encoding to allow
the use of an extra bit (we can now store BITS_PER_LONG - 1 bits in a
value entry).  It is also a change in emphasis; exceptional entries are
intimidating and different.  As the comment explains, you can choose
to store values or pointers in the xarray and they are both first-class
citizens.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Josef Bacik <jbacik@fb.com>
This commit is contained in:
Matthew Wilcox 2017-11-03 13:30:42 -04:00
parent 66ee620f06
commit 3159f943aa
26 changed files with 278 additions and 232 deletions

View file

@ -70,7 +70,7 @@ static void truncate_exceptional_pvec_entries(struct address_space *mapping,
return;
for (j = 0; j < pagevec_count(pvec); j++)
if (radix_tree_exceptional_entry(pvec->pages[j]))
if (xa_is_value(pvec->pages[j]))
break;
if (j == pagevec_count(pvec))
@ -85,7 +85,7 @@ static void truncate_exceptional_pvec_entries(struct address_space *mapping,
struct page *page = pvec->pages[i];
pgoff_t index = indices[i];
if (!radix_tree_exceptional_entry(page)) {
if (!xa_is_value(page)) {
pvec->pages[j++] = page;
continue;
}
@ -347,7 +347,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
if (index >= end)
break;
if (radix_tree_exceptional_entry(page))
if (xa_is_value(page))
continue;
if (!trylock_page(page))
@ -442,7 +442,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
break;
}
if (radix_tree_exceptional_entry(page))
if (xa_is_value(page))
continue;
lock_page(page);
@ -561,7 +561,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
if (index > end)
break;
if (radix_tree_exceptional_entry(page)) {
if (xa_is_value(page)) {
invalidate_exceptional_entry(mapping, index,
page);
continue;
@ -692,7 +692,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
if (index > end)
break;
if (radix_tree_exceptional_entry(page)) {
if (xa_is_value(page)) {
if (!invalidate_exceptional_entry2(mapping,
index, page))
ret = -EBUSY;