Commit 4f622938 authored by Jan Kara's avatar Jan Kara Committed by Ross Zwisler

dax: Allow DAX code to replace exceptional entries

Currently we forbid page_cache_tree_insert() to replace exceptional radix
tree entries for DAX inodes. However to make DAX faults race free we will
lock radix tree entries and when hole is created, we need to replace
such locked radix tree entry with a hole page. So modify
page_cache_tree_insert() to allow that.
Reviewed-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
parent e804315d
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/radix-tree.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
/* We use lowest available exceptional entry bit for locking */ /* We use lowest available exceptional entry bit for locking */
......
...@@ -597,14 +597,21 @@ static int page_cache_tree_insert(struct address_space *mapping, ...@@ -597,14 +597,21 @@ static int page_cache_tree_insert(struct address_space *mapping,
if (!radix_tree_exceptional_entry(p)) if (!radix_tree_exceptional_entry(p))
return -EEXIST; return -EEXIST;
if (WARN_ON(dax_mapping(mapping))) mapping->nrexceptional--;
return -EINVAL; if (!dax_mapping(mapping)) {
if (shadowp) if (shadowp)
*shadowp = p; *shadowp = p;
mapping->nrexceptional--;
if (node) if (node)
workingset_node_shadows_dec(node); workingset_node_shadows_dec(node);
} else {
/* DAX can replace empty locked entry with a hole */
WARN_ON_ONCE(p !=
(void *)(RADIX_TREE_EXCEPTIONAL_ENTRY |
RADIX_DAX_ENTRY_LOCK));
/* DAX accounts exceptional entries as normal pages */
if (node)
workingset_node_pages_dec(node);
}
} }
radix_tree_replace_slot(slot, page); radix_tree_replace_slot(slot, page);
mapping->nrpages++; mapping->nrpages++;
......
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