All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH] btrfs-progs: properly exclude leaves for lowmem
Date: Tue,  5 Jan 2021 16:40:18 -0500	[thread overview]
Message-ID: <845796bfab85f02919d64908b63f3f7201a2abb3.1609882807.git.josef@toxicpanda.com> (raw)

The lowmem mode excludes all referenced blocks from the allocator in
order to avoid accidentally overwriting blocks while fixing the file
system.  However for leaves it wouldn't exclude anything, it would just
pin them down, which gets cleaned up on transaction commit.  We're safe
for the first modification, but subsequent modifications could blow up
in our face.  Fix this by properly excluding leaves as well as all of
the nodes.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/mode-common.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/check/mode-common.c b/check/mode-common.c
index a6489191..ef77b060 100644
--- a/check/mode-common.c
+++ b/check/mode-common.c
@@ -667,8 +667,12 @@ static int traverse_tree_blocks(struct extent_buffer *eb, int tree_root, int pin
 
 			/* If we aren't the tree root don't read the block */
 			if (level == 1 && !tree_root) {
-				btrfs_pin_extent(gfs_info, bytenr,
-						 gfs_info->nodesize);
+				if (pin)
+					btrfs_pin_extent(gfs_info, bytenr,
+							 gfs_info->nodesize);
+				else
+					set_extent_dirty(tree, bytenr,
+							 gfs_info->nodesize);
 				continue;
 			}
 
-- 
2.26.2


             reply	other threads:[~2021-01-05 21:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 21:40 Josef Bacik [this message]
2021-01-06  1:42 ` [PATCH] btrfs-progs: properly exclude leaves for lowmem Su Yue
2021-01-06 16:17 ` 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=845796bfab85f02919d64908b63f3f7201a2abb3.1609882807.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.