1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-04 09:18:36 +03:00

scan: improve io error checking and reporting

This commit is contained in:
David Teigland 2018-04-06 13:12:26 -05:00
parent 6d05859862
commit 45e5e702c1

View File

@ -466,17 +466,20 @@ static int _scan_list(struct dm_list *devs, int *failed)
struct dm_list done_devs; struct dm_list done_devs;
struct device_list *devl, *devl2; struct device_list *devl, *devl2;
struct block *bb; struct block *bb;
int scan_open_errors = 0;
int scan_read_errors = 0;
int scan_process_errors = 0;
int scan_failed_count = 0; int scan_failed_count = 0;
int scan_lvm_count = 0;
int rem_prefetches; int rem_prefetches;
int scan_failed; int scan_failed;
int is_lvm_device; int is_lvm_device;
int error;
int ret; int ret;
dm_list_init(&wait_devs); dm_list_init(&wait_devs);
dm_list_init(&done_devs); dm_list_init(&done_devs);
log_debug_devs("Scanning %d devices.", dm_list_size(devs)); log_debug_devs("Scanning %d devices for VG info", dm_list_size(devs));
scan_more: scan_more:
rem_prefetches = bcache_max_prefetches(scan_bcache); rem_prefetches = bcache_max_prefetches(scan_bcache);
@ -498,6 +501,7 @@ static int _scan_list(struct dm_list *devs, int *failed)
log_debug_devs("Scan failed to open %s.", dev_name(devl->dev)); log_debug_devs("Scan failed to open %s.", dev_name(devl->dev));
dm_list_del(&devl->list); dm_list_del(&devl->list);
dm_list_add(&done_devs, &devl->list); dm_list_add(&done_devs, &devl->list);
scan_open_errors++;
scan_failed_count++; scan_failed_count++;
continue; continue;
} }
@ -513,11 +517,15 @@ static int _scan_list(struct dm_list *devs, int *failed)
dm_list_iterate_items_safe(devl, devl2, &wait_devs) { dm_list_iterate_items_safe(devl, devl2, &wait_devs) {
bb = NULL; bb = NULL;
error = 0;
scan_failed = 0;
is_lvm_device = 0;
if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb)) { if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb, &error)) {
log_debug_devs("Scan failed to read %s.", dev_name(devl->dev)); log_debug_devs("Scan failed to read %s error %d.", dev_name(devl->dev), error);
scan_failed_count++;
scan_failed = 1; scan_failed = 1;
scan_read_errors++;
scan_failed_count++;
lvmcache_del_dev(devl->dev); lvmcache_del_dev(devl->dev);
} else { } else {
log_debug_devs("Processing data from device %s fd %d block %p", dev_name(devl->dev), devl->dev->bcache_fd, bb); log_debug_devs("Processing data from device %s fd %d block %p", dev_name(devl->dev), devl->dev->bcache_fd, bb);
@ -526,12 +534,10 @@ static int _scan_list(struct dm_list *devs, int *failed)
if (!ret && is_lvm_device) { if (!ret && is_lvm_device) {
log_debug_devs("Scan failed to process %s", dev_name(devl->dev)); log_debug_devs("Scan failed to process %s", dev_name(devl->dev));
scan_failed_count++;
scan_failed = 1; scan_failed = 1;
scan_process_errors++;
scan_failed_count++;
lvmcache_del_dev(devl->dev); lvmcache_del_dev(devl->dev);
} else {
scan_lvm_count++;
scan_failed = 0;
} }
} }
@ -556,8 +562,8 @@ static int _scan_list(struct dm_list *devs, int *failed)
if (!dm_list_empty(devs)) if (!dm_list_empty(devs))
goto scan_more; goto scan_more;
log_debug_devs("Scanned devices: %d lvm, %d failed.", log_debug_devs("Scanned devices: open errors %d read errors %d process errors %d",
scan_lvm_count, scan_failed_count); scan_open_errors, scan_read_errors, scan_process_errors);
if (failed) if (failed)
*failed = scan_failed_count; *failed = scan_failed_count;
@ -649,6 +655,8 @@ int label_scan(struct cmd_context *cmd)
}; };
dev_iter_destroy(iter); dev_iter_destroy(iter);
log_debug_devs("Found %d devices to scan", dm_list_size(&all_devs));
if (!scan_bcache) { if (!scan_bcache) {
/* /*
* FIXME: there should probably be some max number of * FIXME: there should probably be some max number of