1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmetad: more fixes related to bcache

Need to open devs prior to bcache io.
This commit is contained in:
David Teigland 2018-03-09 11:39:12 -06:00
parent e351f8bc66
commit a9b0aa5c17
2 changed files with 29 additions and 8 deletions

View File

@ -515,7 +515,7 @@ static int _scan_list(struct dm_list *devs, int *failed)
bb = NULL;
if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb)) {
log_error("Scan failed to read %s.", dev_name(devl->dev));
log_debug_devs("Scan failed to read %s.", dev_name(devl->dev));
scan_failed_count++;
scan_failed = 1;
lvmcache_del_dev(devl->dev);
@ -525,7 +525,7 @@ static int _scan_list(struct dm_list *devs, int *failed)
ret = _process_block(devl->dev, bb, &is_lvm_device);
if (!ret && is_lvm_device) {
log_error("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;
lvmcache_del_dev(devl->dev);
@ -893,9 +893,12 @@ bool dev_read_bytes(struct device *dev, off_t start, size_t len, void *data)
}
if (dev->bcache_fd <= 0) {
log_error("dev_read_bytes %s with invalid fd %d", dev_name(dev), dev->bcache_fd);
/* This is not often needed, perhaps only with lvmetad. */
if (!label_scan_open(dev)) {
log_error("dev_read_bytes %s cannot open dev", dev_name(dev));
return false;
}
}
if (!bcache_read_bytes(scan_bcache, dev->bcache_fd, start, len, data)) {
log_error("dev_read_bytes %s at %u failed invalidate fd %d",
@ -924,9 +927,12 @@ bool dev_write_bytes(struct device *dev, off_t start, size_t len, void *data)
}
if (dev->bcache_fd <= 0) {
log_error("dev_write_bytes %s with invalid fd %d", dev_name(dev), dev->bcache_fd);
/* This is not often needed, perhaps only with lvmetad. */
if (!label_scan_open(dev)) {
log_error("dev_write_bytes %s cannot open dev", dev_name(dev));
return false;
}
}
if (!bcache_write_bytes(scan_bcache, dev->bcache_fd, start, len, data)) {
log_error("dev_write_bytes %s at %u failed invalidate fd %d",
@ -954,9 +960,12 @@ bool dev_write_zeros(struct device *dev, off_t start, size_t len)
}
if (dev->bcache_fd <= 0) {
log_error("dev_write_zeros %s with invalid fd %d", dev_name(dev), dev->bcache_fd);
/* This is not often needed, perhaps only with lvmetad. */
if (!label_scan_open(dev)) {
log_error("dev_write_zeros %s cannot open dev", dev_name(dev));
return false;
}
}
if (!bcache_write_zeros(scan_bcache, dev->bcache_fd, start, len)) {
log_error("dev_write_zeros %s at %u failed invalidate fd %d",

View File

@ -3809,6 +3809,18 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
release_vg(correct_vg);
return_NULL;
}
/*
* When a command reads the vg from lvmetad, and then
* writes the vg, the write path does some disk reads
* of the devs.
* FIXME: when a command is going to write the vg,
* we should just read the vg from disk entirely
* and skip reading it from lvmetad.
*/
dm_list_iterate_items(pvl, &correct_vg->pvs)
label_scan_open(pvl->pv->dev);
}
return correct_vg;