diff options
Diffstat (limited to 'lib/label')
-rw-r--r-- | lib/label/label.c | 32 | ||||
-rw-r--r-- | lib/label/label.h | 1 |
2 files changed, 32 insertions, 1 deletions
diff --git a/lib/label/label.c b/lib/label/label.c index a8d87ec16..185e51b0c 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -1118,7 +1118,37 @@ int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_lis _scan_list(cmd, f, devs, NULL); - /* FIXME: this function should probably fail if any devs couldn't be scanned */ + return 1; +} + +/* + * This function is used when the caller plans to write to the devs, so opening + * them RW during rescan avoids needing to close and reopen with WRITE in + * dev_write_bytes. + */ + +int label_scan_devs_rw(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs) +{ + struct device_list *devl; + + if (!scan_bcache) { + if (!_setup_bcache(0)) + return 0; + } + + dm_list_iterate_items(devl, devs) { + if (_in_bcache(devl->dev)) { + bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd); + _scan_dev_close(devl->dev); + } + /* + * With this flag set, _scan_dev_open() done by + * _scan_list() will do open RW + */ + devl->dev->flags |= DEV_BCACHE_WRITE; + } + + _scan_list(cmd, f, devs, NULL); return 1; } diff --git a/lib/label/label.h b/lib/label/label.h index 07bb77d88..f06b7df63 100644 --- a/lib/label/label.h +++ b/lib/label/label.h @@ -104,6 +104,7 @@ extern struct bcache *scan_bcache; int label_scan(struct cmd_context *cmd); int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs); +int label_scan_devs_rw(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs); int label_scan_devs_excl(struct dm_list *devs); void label_scan_invalidate(struct device *dev); void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv); |