提交 c5502451 编写于 作者: Q Qu Wenruo 提交者: David Sterba

btrfs: Enhance message when a device is missing during mount

For a missing device, btrfs will just refuse to mount with almost
meaningless kernel message like:

 BTRFS info (device vdb6): disk space caching is enabled
 BTRFS info (device vdb6): has skinny extents
 BTRFS error (device vdb6): failed to read the system array: -5
 BTRFS error (device vdb6): open_ctree failed

This patch will print a new message about the missing device:

 BTRFS info (device vdb6): disk space caching is enabled
 BTRFS info (device vdb6): has skinny extents
 BTRFS warning (device vdb6): devid 2 uuid 80470722-cad2-4b90-b7c3-fee294552f1b is missing
 BTRFS error (device vdb6): failed to read the system array: -5
 BTRFS error (device vdb6): open_ctree failed
Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: NAnand Jain <anand.jain@oracle.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 bc3cce23
...@@ -6492,6 +6492,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key, ...@@ -6492,6 +6492,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
if (!map->stripes[i].dev && if (!map->stripes[i].dev &&
!btrfs_test_opt(fs_info, DEGRADED)) { !btrfs_test_opt(fs_info, DEGRADED)) {
free_extent_map(em); free_extent_map(em);
btrfs_report_missing_device(fs_info, devid, uuid);
return -EIO; return -EIO;
} }
if (!map->stripes[i].dev) { if (!map->stripes[i].dev) {
...@@ -6502,8 +6503,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key, ...@@ -6502,8 +6503,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
free_extent_map(em); free_extent_map(em);
return -EIO; return -EIO;
} }
btrfs_warn(fs_info, "devid %llu uuid %pU is missing", btrfs_report_missing_device(fs_info, devid, uuid);
devid, uuid);
} }
map->stripes[i].dev->in_fs_metadata = 1; map->stripes[i].dev->in_fs_metadata = 1;
} }
...@@ -6620,17 +6620,21 @@ static int read_one_dev(struct btrfs_fs_info *fs_info, ...@@ -6620,17 +6620,21 @@ static int read_one_dev(struct btrfs_fs_info *fs_info,
device = btrfs_find_device(fs_info, devid, dev_uuid, fs_uuid); device = btrfs_find_device(fs_info, devid, dev_uuid, fs_uuid);
if (!device) { if (!device) {
if (!btrfs_test_opt(fs_info, DEGRADED)) if (!btrfs_test_opt(fs_info, DEGRADED)) {
btrfs_report_missing_device(fs_info, devid, dev_uuid);
return -EIO; return -EIO;
}
device = add_missing_dev(fs_devices, devid, dev_uuid); device = add_missing_dev(fs_devices, devid, dev_uuid);
if (!device) if (!device)
return -ENOMEM; return -ENOMEM;
btrfs_warn(fs_info, "devid %llu uuid %pU missing", btrfs_report_missing_device(fs_info, devid, dev_uuid);
devid, dev_uuid);
} else { } else {
if (!device->bdev && !btrfs_test_opt(fs_info, DEGRADED)) if (!device->bdev) {
return -EIO; btrfs_report_missing_device(fs_info, devid, dev_uuid);
if (!btrfs_test_opt(fs_info, DEGRADED))
return -EIO;
}
if(!device->bdev && !device->missing) { if(!device->bdev && !device->missing) {
/* /*
...@@ -6796,6 +6800,12 @@ int btrfs_read_sys_array(struct btrfs_fs_info *fs_info) ...@@ -6796,6 +6800,12 @@ int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
return -EIO; return -EIO;
} }
void btrfs_report_missing_device(struct btrfs_fs_info *fs_info, u64 devid,
u8 *uuid)
{
btrfs_warn_rl(fs_info, "devid %llu uuid %pU is missing", devid, uuid);
}
/* /*
* Check if all chunks in the fs are OK for read-write degraded mount * Check if all chunks in the fs are OK for read-write degraded mount
* *
......
...@@ -544,5 +544,7 @@ void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info); ...@@ -544,5 +544,7 @@ void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info);
void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info); void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info);
bool btrfs_check_rw_degradable(struct btrfs_fs_info *fs_info); bool btrfs_check_rw_degradable(struct btrfs_fs_info *fs_info);
void btrfs_report_missing_device(struct btrfs_fs_info *fs_info, u64 devid,
u8 *uuid);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册