Btrfs: add inodes before dropping the extent lock in find_all_leafs

We must build up the inode list with the extent lock held after following
indirect refs.

This also requires an extension to ulists, which allows to modify the stored
aux value in case a key already exists in the list.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
This commit is contained in:
Jan Schmidt
2012-05-30 18:05:21 +02:00
parent 95a06077f7
commit 3301958b7c
3 changed files with 43 additions and 6 deletions

View File

@@ -145,12 +145,21 @@ EXPORT_SYMBOL(ulist_free);
*/
int ulist_add(struct ulist *ulist, u64 val, unsigned long aux,
unsigned long gfp_mask)
{
return ulist_add_merge(ulist, val, aux, NULL, gfp_mask);
}
int ulist_add_merge(struct ulist *ulist, u64 val, unsigned long aux,
unsigned long *old_aux, unsigned long gfp_mask)
{
int i;
for (i = 0; i < ulist->nnodes; ++i) {
if (ulist->nodes[i].val == val)
if (ulist->nodes[i].val == val) {
if (old_aux)
*old_aux = ulist->nodes[i].aux;
return 0;
}
}
if (ulist->nnodes >= ulist->nodes_alloced) {