From fd500029eb24e70619ee62ef03b36ad6f3de1536 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Thu, 17 Mar 2022 14:12:50 +0800 Subject: [PATCH] btrfs-progs: check: fix two error messages used in qgroup verification [BUG] There is a weird error message when running btrfs check on a specific image: [7/7] checking quota groups ERROR: out of memory ERROR: Loading qgroups from disk: -2 ERROR: failed to check quota groups [CAUSE] The "Out of memory" one is in load_quota_info(), which is output in two cases: - No memory can be allocated for btrfs_qgroup_list AKA, real -ENOMEM. - No qgroup can be found for either the child or the parent qgroup This returnes -ENOENT. Obvious the image has hit -ENOENT case, but the error message is fixed to ENOMEM case. [FIX] Fix it by using %m to output the real reason of failure. Reported-by: Andrei Borzenkov Link: https://forums.opensuse.org/showthread.php/567851-btrfs-fails-to-load-qgroups-from-disk-with-error-2-(out-of-memory) Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- check/qgroup-verify.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c index 6e012c1f..0b779930 100644 --- a/check/qgroup-verify.c +++ b/check/qgroup-verify.c @@ -977,7 +977,10 @@ loop: ret = add_qgroup_relation(key.objectid, key.offset); if (ret) { - error("out of memory"); + errno = -ret; + error( + "failed to add qgroup relation, member=%llu parent=%llu: %m", + key.objectid, key.offset); goto out; } }