shmem: Convert find_swap_entry to XArray

This is a 1:1 conversion.  The major part of this patch is converting
the test framework from userspace to kernel space and mirroring the
algorithm now used in find_swap_entry().

Signed-off-by: Matthew Wilcox <willy@infradead.org>
这个提交包含在:
Matthew Wilcox
2017-11-22 08:36:00 -05:00
父节点 a12831bf42
当前提交 e21a29552f
修改 5 个文件,包含 66 行新增101 行删除

查看文件

@@ -1100,34 +1100,27 @@ static void shmem_evict_inode(struct inode *inode)
clear_inode(inode);
}
static unsigned long find_swap_entry(struct radix_tree_root *root, void *item)
static unsigned long find_swap_entry(struct xarray *xa, void *item)
{
struct radix_tree_iter iter;
void __rcu **slot;
unsigned long found = -1;
XA_STATE(xas, xa, 0);
unsigned int checked = 0;
void *entry;
rcu_read_lock();
radix_tree_for_each_slot(slot, root, &iter, 0) {
void *entry = radix_tree_deref_slot(slot);
if (radix_tree_deref_retry(entry)) {
slot = radix_tree_iter_retry(&iter);
xas_for_each(&xas, entry, ULONG_MAX) {
if (xas_retry(&xas, entry))
continue;
}
if (entry == item) {
found = iter.index;
if (entry == item)
break;
}
checked++;
if ((checked % 4096) != 0)
if ((checked % XA_CHECK_SCHED) != 0)
continue;
slot = radix_tree_iter_resume(slot, &iter);
xas_pause(&xas);
cond_resched_rcu();
}
rcu_read_unlock();
return found;
return entry ? xas.xa_index : -1;
}
/*