summaryrefslogtreecommitdiff
path: root/check/main.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2018-03-08 15:02:31 +0800
committerDavid Sterba <dsterba@suse.com>2018-03-30 22:15:53 +0200
commit4c7094e046dc7875af2e7f65eb80b256b6232fd7 (patch)
tree3d369ec5be3b1135965dbbfe4ecb3c53d05df0b1 /check/main.c
parentfd5767a574958624828149687e76a5f0276f1dc8 (diff)
btrfs-progs: free-space-cache: Enhance free space cache free space check
When we found free space difference between free space cache and block group item, we just discard this free space cache. Normally such difference is caused by btrfs_reserve_extent() called by delalloc which is out of a transaction. And since all btrfs_release_extent() is called with a transaction, under heavy race free space cache can have less free space than block group item. Normally kernel will detect such difference and just discard that cache. However we must be more careful if free space cache has more free space cache, and if that happens, paried with above race one invalid free space cache can be loaded into kernel. So if we find any free space cache who has more free space then block group item, we report it as an error other than ignoring it. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'check/main.c')
-rw-r--r--check/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/check/main.c b/check/main.c
index 8ad7ab03..5c1f9814 100644
--- a/check/main.c
+++ b/check/main.c
@@ -5339,7 +5339,9 @@ static int check_space_cache(struct btrfs_root *root)
error += ret;
} else {
ret = load_free_space_cache(root->fs_info, cache);
- if (!ret)
+ if (ret < 0)
+ error++;
+ if (ret <= 0)
continue;
}