summaryrefslogtreecommitdiff
path: root/lib/label/label.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2019-06-11 16:17:24 -0500
committerDavid Teigland <teigland@redhat.com>2019-06-21 10:57:49 -0500
commitd16142f90fdcf2aef42a51ecabd0c4ff11733d7c (patch)
treefb1d4202c96e45e2d37c53514381b888ce04e7b6 /lib/label/label.c
parent8fecd9c14e0b3f62cc4de6ddac0a015db687b335 (diff)
downloadlvm2-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/label.c')
-rw-r--r--lib/label/label.c32
1 files changed, 31 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;
}