We have several bug reports of btrfs-convert failure in
btrfs_run_delayed_refs().

The bug turns out to be a incorrect backport of delayed ref handling in
transaction commit.

In kernel we have a loop to exhause both delayed refs and dirty blocks,
as btrfs_write_dirty_block_groups() can generate new delayed refs, while
btrfs_run_delayed_refs() can re-dirty block groups.

This feedback could cause missing delayed refs, and bite later transaction
just like the btrfs-convert report.

Furthermore, such lost delayed refs causes memory leakage and reserved
space leakage, the later one can be detected by commit c31edf610cbe
("btrfs-progs: Fix false ENOSPC alert by tracking used space
correctly").

The first patch will fix the long existing bug.

The second patch will try to reduce the feedback between
btrfs_write_dirty_block_groups() and btrfs_run_delayed_refs().

Changelog:
v2:
- Use a loop to exhaust both delayed refs and dirty block groups
  Thanks Nikolay for pointing out the feedback between them.

- Add a new patch to reduce above feedback 

- Handle the error from btrfs_write_dirty_block_groups()

Qu Wenruo (2):
  btrfs-progs: Exhaust delayed refs and dirty block groups to prevent
    delayed refs lost
  btrfs-progs: Avoid unnecessary block group item COW if the content
    hasn't changed

 extent-tree.c | 26 +++++++++++++++++++++++++-
 transaction.c | 27 +++++++++++++++++++++------
 2 files changed, 46 insertions(+), 7 deletions(-)

-- 
2.22.0

Reply via email to