* [PATCH] btrfs-progs: properly exclude leaves for lowmem
@ 2021-01-05 21:40 Josef Bacik
2021-01-06 1:42 ` Su Yue
2021-01-06 16:17 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2021-01-05 21:40 UTC (permalink / raw)
To: linux-btrfs, kernel-team
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: properly exclude leaves for lowmem
2021-01-05 21:40 [PATCH] btrfs-progs: properly exclude leaves for lowmem Josef Bacik
@ 2021-01-06 1:42 ` Su Yue
2021-01-06 16:17 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Su Yue @ 2021-01-06 1:42 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, kernel-team
On Wed 06 Jan 2021 at 05:40, Josef Bacik <josef@toxicpanda.com>
wrote:
> 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>
>
LGTM.
Reviewed-by: Su Yue <l@damenly.su>
> ---
> 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;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: properly exclude leaves for lowmem
2021-01-05 21:40 [PATCH] btrfs-progs: properly exclude leaves for lowmem Josef Bacik
2021-01-06 1:42 ` Su Yue
@ 2021-01-06 16:17 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-01-06 16:17 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, kernel-team
On Tue, Jan 05, 2021 at 04:40:18PM -0500, Josef Bacik wrote:
> 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.
This sounds like a test case can be easily written.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-06 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-05 21:40 [PATCH] btrfs-progs: properly exclude leaves for lowmem Josef Bacik
2021-01-06 1:42 ` Su Yue
2021-01-06 16:17 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox