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 <arvidjaar@gmail.com>
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 <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2022-03-17 14:12:50 +08:00 committed by David Sterba
parent e8f7f034af
commit fd500029eb

View File

@ -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;
}
}