btrfs-progs: dump-super: improve error message on failed read

Add more error information to help debugging:

  $ ./btrfs inspect-internal dump-super -Ffa /dev/vdb10

  Before:
  ERROR: failed to read the superblock on /dev/vdb10 at 274877906944

  After:
  ERROR: failed to read the superblock on /dev/vdb10 at 274877906944 read 0/4096 bytes

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain 2023-06-27 16:53:13 +08:00 committed by David Sterba
parent b51117d68e
commit 4ab083175a

View File

@ -41,7 +41,8 @@ static int load_and_dump_sb(char *filename, int fd, u64 sb_bytenr, int full,
if (ret == 0 && errno == 0)
return 0;
error("failed to read the superblock on %s at %llu", filename, sb_bytenr);
error("failed to read the superblock on %s at %llu read %llu/%d bytes",
filename, sb_bytenr, ret, BTRFS_SUPER_INFO_SIZE);
error("error = '%m', errno = %d", errno);
return 1;
}