File btrfs-progs-check-initialize-qgroup_item_count-in-ea.patch of Package btrfsprogs.17950
From b9b5d2c6ef280f15517350c7bbd85963b1cdd2a9 Mon Sep 17 00:00:00 2001
From: Naohiro Aota <naohiro.aota@wdc.com>
Date: Tue, 23 Jul 2019 18:19:11 +0900
Subject: [PATCH] btrfs-progs: check: initialize qgroup_item_count in earlier stage
Git-commit: 8ca6c0c3c718
Patch-mainline: v5.2.1
References: bsc#1158560
"btrfsck -Q" segfaults because it does not call qgroup_set_item_count_ptr()
Properly:
# btrfsck -Q /dev/sdk
Opening filesystem to check...
Checking filesystem on /dev/sdk
UUID: 34a35bbc-43f8-40f0-8043-65ed33f2e6c3
Print quota groups for /dev/sdk
UUID: 34a35bbc-43f8-40f0-8043-65ed33f2e6c3
Segmentation fault (core dumped)
Since "struct task_ctx ctx" is global, we can just move
qgroup_set_item_count_ptr() much earlier stage in the check process to
avoid to forget initializing it.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Acked-by: Libor Pechacek <lpechacek@suse.com>
---
check/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: btrfs-progs-v4.19.1/check/main.c
===================================================================
--- btrfs-progs-v4.19.1.orig/check/main.c
+++ btrfs-progs-v4.19.1/check/main.c
@@ -9688,6 +9688,7 @@ int cmd_check(int argc, char **argv)
radix_tree_init();
cache_tree_init(&root_cache);
+ qgroup_set_item_count_ptr(&ctx.item_count);
ret = check_mounted(argv[optind]);
if (!force) {
@@ -10014,7 +10015,6 @@ int cmd_check(int argc, char **argv)
}
if (info->quota_enabled) {
- qgroup_set_item_count_ptr(&ctx.item_count);
if (!ctx.progress_enabled) {
fprintf(stderr, "[7/7] checking quota groups\n");
} else {