forked from Mirrors/btrfs-progs
btrfs-progs: disk-io: Make super block write error easier to read
When we failed to write super blocks, we just output something like: WARNING: failed to write sb: I/O error Or WARNING: failed to write all sb data There is no info about which device failed and there are two different error message for the same write error. This patch will change it to something more detailed: ERROR: failed to write super block for devid 1: write error: I/O error This provides the basis for later super block flush error handling. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com>master
parent
2437a88079
commit
2644f80611
25
disk-io.c
25
disk-io.c
|
@ -1627,8 +1627,13 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
|
|||
ret = pwrite64(device->fd, fs_info->super_copy,
|
||||
BTRFS_SUPER_INFO_SIZE,
|
||||
fs_info->super_bytenr);
|
||||
if (ret != BTRFS_SUPER_INFO_SIZE)
|
||||
goto write_err;
|
||||
if (ret != BTRFS_SUPER_INFO_SIZE) {
|
||||
errno = EIO;
|
||||
error(
|
||||
"failed to write super block for devid %llu: write error: %m",
|
||||
device->devid);
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1650,18 +1655,16 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
|
|||
*/
|
||||
ret = pwrite64(device->fd, fs_info->super_copy,
|
||||
BTRFS_SUPER_INFO_SIZE, bytenr);
|
||||
if (ret != BTRFS_SUPER_INFO_SIZE)
|
||||
goto write_err;
|
||||
if (ret != BTRFS_SUPER_INFO_SIZE) {
|
||||
errno = EIO;
|
||||
error(
|
||||
"failed to write super block for devid %llu: write error: %m",
|
||||
device->devid);
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
write_err:
|
||||
if (ret > 0)
|
||||
fprintf(stderr, "WARNING: failed to write all sb data\n");
|
||||
else
|
||||
fprintf(stderr, "WARNING: failed to write sb: %m\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue