All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naohiro Aota <naohiro.aota@wdc.com>
To: linux-btrfs@vger.kernel.org
Cc: Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH] btrfs-progs: check: initialize qgroup_item_count in earlier stage
Date: Tue, 23 Jul 2019 18:19:11 +0900	[thread overview]
Message-ID: <20190723091911.19598-1-naohiro.aota@wdc.com> (raw)

"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>
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check/main.c b/check/main.c
index bb57933b83fc..7248a8209532 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9965,6 +9965,7 @@ static int cmd_check(const struct cmd_struct *cmd, 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) {
@@ -10291,7 +10292,6 @@ static int cmd_check(const struct cmd_struct *cmd, 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 {
-- 
2.22.0


             reply	other threads:[~2019-07-23  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23  9:19 Naohiro Aota [this message]
2019-07-23  9:27 ` [PATCH] btrfs-progs: check: initialize qgroup_item_count in earlier stage Qu Wenruo
2019-07-24 11:01 ` 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=20190723091911.19598-1-naohiro.aota@wdc.com \
    --to=naohiro.aota@wdc.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.