Skip to content

Commit

Permalink
Btrfs: Fix infinite loop in btrfs_extent_post_op
Browse files Browse the repository at this point in the history
btrfs_extent_post_op calls finish_current_insert and del_pending_extents. They
both may enter infinite loops.

finish_current_insert enters infinite loop if it only finds some backrefs to
update.  The fix is to check for pending backref updates before restarting the
loop.

The infinite loop in del_pending_extents is due to a the skipped variable
not being properly reset before looping around.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
  • Loading branch information
Yan Zheng authored and Chris Mason committed Jan 21, 2009
1 parent 3dfdb93 commit 5a7be51
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,8 @@ static int finish_current_insert(struct btrfs_trans_handle *trans,
ret = find_first_extent_bit(&info->extent_ins, search, &start,
&end, EXTENT_WRITEBACK);
if (ret) {
if (skipped && all && !num_inserts) {
if (skipped && all && !num_inserts &&
list_empty(&update_list)) {
skipped = 0;
search = 0;
continue;
Expand Down Expand Up @@ -2544,6 +2545,7 @@ static int del_pending_extents(struct btrfs_trans_handle *trans,
if (ret) {
if (all && skipped && !nr) {
search = 0;
skipped = 0;
continue;
}
mutex_unlock(&info->extent_ins_mutex);
Expand Down

0 comments on commit 5a7be51

Please sign in to comment.