public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/2] btrfs-progs: Fix delayed ref leakage
Date: Mon,  8 Jul 2019 15:33:50 +0800	[thread overview]
Message-ID: <20190708073352.6095-1-wqu@suse.com> (raw)

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	other threads:[~2019-07-08  7:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08  7:33 Qu Wenruo [this message]
2019-07-08  7:33 ` [PATCH v2 1/2] btrfs-progs: Exhaust delayed refs and dirty block groups to prevent delayed refs lost Qu Wenruo
2019-07-08 10:44   ` Nikolay Borisov
2019-07-22 12:59   ` David Sterba
2019-07-08  7:33 ` [PATCH v2 2/2] btrfs-progs: Avoid unnecessary block group item COW if the content hasn't changed Qu Wenruo
2019-07-08 10:43   ` Nikolay Borisov
2019-07-08 12:50     ` Qu Wenruo
2019-07-08 13:07       ` Nikolay Borisov
2019-07-08 13:30         ` Qu Wenruo
2019-07-22 12:59           ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190708073352.6095-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox