btrfs: fix race in reada

When inserting into the radix tree returns EEXIST, get the existing
entry without giving up the spinlock in between.
There was a race for both the zones trees and the extent tree.

Signed-off-by: Arne Jansen <sensille@gmx.net>
This commit is contained in:
Arne Jansen
2012-02-25 09:09:30 +01:00
committed by David Sterba
parent 848cce0d41
commit 8c9c2bf7a3
2 changed files with 23 additions and 20 deletions

View File

@@ -4332,7 +4332,13 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
}
no_dentry:
/* is this a reference to our own snapshot? If so
* skip it
* skip it.
*
* In contrast to old kernels, we insert the snapshot's
* dir item and dir index after it has been created, so
* we won't find a reference to our own snapshot. We
* still keep the following code for backward
* compatibility.
*/
if (location.type == BTRFS_ROOT_ITEM_KEY &&
location.objectid == root->root_key.objectid) {