summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>2014-06-20 19:09:07 +0800
committerDavid Sterba <dsterba@suse.cz>2014-08-22 14:43:11 +0200
commit5e943194067b1da56717bc57f75be17cc00ee87f (patch)
tree2edbd23eb22ff85bd408d6477c910a4b0b805328
parent72ced9950a37f217a6f2377d7c557332185c413b (diff)
Btrfs-progs: fsck: reduce memory usage for extents check
Steps to reproduce: # mkfs.btrfs -f /dev/sda9 -b 2g # mount /dev/sda9 /mnt # dd if=/dev/zero of=/mnt/data bs=4k oflag=direct # btrfs file df /mnt Data, single: total=1.66GiB, used=1.66GiB System, single: total=4.00MiB, used=16.00KiB Metadata, single: total=200.00MiB, used=67.88MiB For a filesystem without snapshots, 70M metadata, extent checking eats max memory about 110M, this is a nightmare for some system with low memory. It is very likely that extent record can be freed quickly for a filesystem without snapshots, improve this by trying if it can free memory after adding data/tree backrefs. This patch reduces max memory cost from 110M to 40M for extents checking for the above case. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--cmds-check.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmds-check.c b/cmds-check.c
index df4af9a1..b2e69672 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2829,6 +2829,7 @@ static int add_tree_backref(struct cache_tree *extent_cache, u64 bytenr,
}
back->node.found_extent_tree = 1;
}
+ maybe_free_extent_rec(extent_cache, rec);
return 0;
}
@@ -2895,6 +2896,7 @@ static int add_data_backref(struct cache_tree *extent_cache, u64 bytenr,
back->num_refs = num_refs;
back->node.found_extent_tree = 1;
}
+ maybe_free_extent_rec(extent_cache, rec);
return 0;
}