dax: Convert __dax_invalidate_entry to XArray
Avoids walking the radix tree multiple times looking for tags. Signed-off-by: Matthew Wilcox <willy@infradead.org>
This commit is contained in:
parent
084a899008
commit
07f2d89cc2
17
fs/dax.c
17
fs/dax.c
@ -777,27 +777,28 @@ EXPORT_SYMBOL_GPL(dax_layout_busy_page);
|
|||||||
static int __dax_invalidate_entry(struct address_space *mapping,
|
static int __dax_invalidate_entry(struct address_space *mapping,
|
||||||
pgoff_t index, bool trunc)
|
pgoff_t index, bool trunc)
|
||||||
{
|
{
|
||||||
|
XA_STATE(xas, &mapping->i_pages, index);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
void *entry;
|
void *entry;
|
||||||
struct radix_tree_root *pages = &mapping->i_pages;
|
|
||||||
|
|
||||||
xa_lock_irq(pages);
|
xas_lock_irq(&xas);
|
||||||
entry = get_unlocked_mapping_entry(mapping, index, NULL);
|
entry = get_unlocked_entry(&xas);
|
||||||
if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
|
if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
|
||||||
goto out;
|
goto out;
|
||||||
if (!trunc &&
|
if (!trunc &&
|
||||||
(radix_tree_tag_get(pages, index, PAGECACHE_TAG_DIRTY) ||
|
(xas_get_mark(&xas, PAGECACHE_TAG_DIRTY) ||
|
||||||
radix_tree_tag_get(pages, index, PAGECACHE_TAG_TOWRITE)))
|
xas_get_mark(&xas, PAGECACHE_TAG_TOWRITE)))
|
||||||
goto out;
|
goto out;
|
||||||
dax_disassociate_entry(entry, mapping, trunc);
|
dax_disassociate_entry(entry, mapping, trunc);
|
||||||
radix_tree_delete(pages, index);
|
xas_store(&xas, NULL);
|
||||||
mapping->nrexceptional--;
|
mapping->nrexceptional--;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
out:
|
out:
|
||||||
put_unlocked_mapping_entry(mapping, index, entry);
|
put_unlocked_entry(&xas, entry);
|
||||||
xa_unlock_irq(pages);
|
xas_unlock_irq(&xas);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete DAX entry at @index from @mapping. Wait for it
|
* Delete DAX entry at @index from @mapping. Wait for it
|
||||||
* to be unlocked before deleting it.
|
* to be unlocked before deleting it.
|
||||||
|
Loading…
Reference in New Issue
Block a user