Skip to content

Commit

Permalink
Btrfs: fix possible infinite loop in slow caching
Browse files Browse the repository at this point in the history
So I noticed there is an infinite loop in the slow caching code.  If we return 1
when we hit the end of the tree, so we could end up caching the last block group
the slow way and suddenly we're looping forever because we just keep
re-searching and trying again.  Fix this by only doing btrfs_next_leaf() if we
don't need_resched().  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
  • Loading branch information
Josef Bacik committed May 6, 2013
1 parent 62dbd71 commit 0a3896d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,20 @@ static noinline void caching_thread(struct btrfs_work *work)
if (ret)
break;

if (need_resched() ||
btrfs_next_leaf(extent_root, path)) {
if (need_resched()) {
caching_ctl->progress = last;
btrfs_release_path(path);
up_read(&fs_info->extent_commit_sem);
mutex_unlock(&caching_ctl->mutex);
cond_resched();
goto again;
}

ret = btrfs_next_leaf(extent_root, path);
if (ret < 0)
goto err;
if (ret)
break;
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);
continue;
Expand Down

0 comments on commit 0a3896d

Please sign in to comment.