@@ -951,52 +951,36 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
*/
static struct inode *find_next_inode(struct btrfs_root *root, u64 objectid)
{
- struct rb_node *node;
- struct rb_node *prev;
- struct btrfs_inode *entry;
- struct inode *inode;
+ struct rb_node *node = NULL;
+ struct inode *inode = NULL;
spin_lock(&root->inode_lock);
-again:
- node = root->inode_tree.rb_node;
- prev = NULL;
- while (node) {
- prev = node;
- entry = rb_entry(node, struct btrfs_inode, rb_node);
- if (objectid < btrfs_ino(entry))
- node = node->rb_left;
- else if (objectid > btrfs_ino(entry))
- node = node->rb_right;
- else
- break;
- }
- if (!node) {
- while (prev) {
- entry = rb_entry(prev, struct btrfs_inode, rb_node);
- if (objectid <= btrfs_ino(entry)) {
- node = prev;
+ do {
+ struct btrfs_inode *entry;
+
+ if (!node) {
+ node = btrfs_find_inode(root, objectid);
+ if (!node)
break;
- }
- prev = rb_next(prev);
}
- }
- while (node) {
+
entry = rb_entry(node, struct btrfs_inode, rb_node);
+ objectid = btrfs_ino(entry) + 1;
inode = igrab(&entry->vfs_inode);
- if (inode) {
- spin_unlock(&root->inode_lock);
- return inode;
- }
+ if (inode)
+ break;
- objectid = btrfs_ino(entry) + 1;
- if (cond_resched_lock(&root->inode_lock))
- goto again;
+ if (cond_resched_lock(&root->inode_lock)) {
+ node = NULL;
+ continue;
+ }
node = rb_next(node);
- }
+ } while(node);
+
spin_unlock(&root->inode_lock);
- return NULL;
+ return inode;
}
/*
Start using btrfs_find_inode in find_next_inode, now that the common logic has been encapsulated in the former function. This simplifies the body of find_next_inode. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- fs/btrfs/relocation.c | 54 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 35 deletions(-)