diff options
author | David Teigland <teigland@redhat.com> | 2019-06-11 16:17:24 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2019-06-21 10:57:49 -0500 |
commit | d16142f90fdcf2aef42a51ecabd0c4ff11733d7c (patch) | |
tree | fb1d4202c96e45e2d37c53514381b888ce04e7b6 /lib/label | |
parent | 8fecd9c14e0b3f62cc4de6ddac0a015db687b335 (diff) | |
download | lvm2-d16142f90fdcf2aef42a51ecabd0c4ff11733d7c.tar.gz |
scanning: open devs rw when rescanning for write
When vg_read rescans devices with the intention of
writing the VG, the label rescan can open the devs
RW so they do not need to be closed and reopened
RW in dev_write_bytes.
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); |