This issue was found when testing in-band dedupe enospc behaviour, sometimes run_one_delayed_ref() may fail for enospc reason, then __btrfs_run_delayed_refs()will return, but forget to add num_heads_read back, which will trigger "WARN_ON(delayed_refs->num_heads_ready == 0)" in btrfs_select_ref_head().
Unified · Split
| @@ -2647,7 +2647,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, · 2646 unmodified lines | ||
| 2647 | 2647 | |
| 2648 | 2648 | btrfs_free_delayed_extent_op(extent_op); |
| 2649 | 2649 | if (ret) { |
| 2650 | + spin_lock(&delayed_refs->lock); | |
| 2650 | 2651 | locked_ref->processing = 0; |
| 2652 | + delayed_refs->num_heads_ready++; | |
| 2653 | + spin_unlock(&delayed_refs->lock); | |
| 2651 | 2654 | btrfs_delayed_ref_unlock(locked_ref); |
| 2652 | 2655 | btrfs_put_delayed_ref(ref); |
| 2653 | 2656 | btrfs_debug(fs_info, "run_one_delayed_ref returned %d", |