diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-04-19 14:37:26 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 15:55:01 -0400 |
commit | 0a3896d0f563d4472c75ab2c26afd8940d24b5a1 (patch) | |
tree | 35106cf7f93687515e9bc90fdfeaf2a71b8b3277 | |
parent | 62dbd7176e196cd042c5542696981b268264fe92 (diff) |
Btrfs: fix possible infinite loop in slow caching
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>
-rw-r--r-- | fs/btrfs/extent-tree.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 8464d369e478..fa57965f60a3 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -419,8 +419,7 @@ again: | |||
419 | if (ret) | 419 | if (ret) |
420 | break; | 420 | break; |
421 | 421 | ||
422 | if (need_resched() || | 422 | if (need_resched()) { |
423 | btrfs_next_leaf(extent_root, path)) { | ||
424 | caching_ctl->progress = last; | 423 | caching_ctl->progress = last; |
425 | btrfs_release_path(path); | 424 | btrfs_release_path(path); |
426 | up_read(&fs_info->extent_commit_sem); | 425 | up_read(&fs_info->extent_commit_sem); |
@@ -428,6 +427,12 @@ again: | |||
428 | cond_resched(); | 427 | cond_resched(); |
429 | goto again; | 428 | goto again; |
430 | } | 429 | } |
430 | |||
431 | ret = btrfs_next_leaf(extent_root, path); | ||
432 | if (ret < 0) | ||
433 | goto err; | ||
434 | if (ret) | ||
435 | break; | ||
431 | leaf = path->nodes[0]; | 436 | leaf = path->nodes[0]; |
432 | nritems = btrfs_header_nritems(leaf); | 437 | nritems = btrfs_header_nritems(leaf); |
433 | continue; | 438 | continue; |