Skip to content

Commit 07f2d89

Browse files
author
Matthew Wilcox
committed
dax: Convert __dax_invalidate_entry to XArray
Avoids walking the radix tree multiple times looking for tags. Signed-off-by: Matthew Wilcox <[email protected]>
1 parent 084a899 commit 07f2d89

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

fs/dax.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -777,27 +777,28 @@ EXPORT_SYMBOL_GPL(dax_layout_busy_page);
777777
static int __dax_invalidate_entry(struct address_space *mapping,
778778
pgoff_t index, bool trunc)
779779
{
780+
XA_STATE(xas, &mapping->i_pages, index);
780781
int ret = 0;
781782
void *entry;
782-
struct radix_tree_root *pages = &mapping->i_pages;
783783

784-
xa_lock_irq(pages);
785-
entry = get_unlocked_mapping_entry(mapping, index, NULL);
784+
xas_lock_irq(&xas);
785+
entry = get_unlocked_entry(&xas);
786786
if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
787787
goto out;
788788
if (!trunc &&
789-
(radix_tree_tag_get(pages, index, PAGECACHE_TAG_DIRTY) ||
790-
radix_tree_tag_get(pages, index, PAGECACHE_TAG_TOWRITE)))
789+
(xas_get_mark(&xas, PAGECACHE_TAG_DIRTY) ||
790+
xas_get_mark(&xas, PAGECACHE_TAG_TOWRITE)))
791791
goto out;
792792
dax_disassociate_entry(entry, mapping, trunc);
793-
radix_tree_delete(pages, index);
793+
xas_store(&xas, NULL);
794794
mapping->nrexceptional--;
795795
ret = 1;
796796
out:
797-
put_unlocked_mapping_entry(mapping, index, entry);
798-
xa_unlock_irq(pages);
797+
put_unlocked_entry(&xas, entry);
798+
xas_unlock_irq(&xas);
799799
return ret;
800800
}
801+
801802
/*
802803
* Delete DAX entry at @index from @mapping. Wait for it
803804
* to be unlocked before deleting it.

0 commit comments

Comments
 (0)