]> sourceware.org Git - lvm2.git/commitdiff
scan: always setup bcache for commands using lvmetad
authorDavid Teigland <teigland@redhat.com>
Wed, 14 Feb 2018 22:21:27 +0000 (16:21 -0600)
committerDavid Teigland <teigland@redhat.com>
Fri, 20 Apr 2018 16:22:46 +0000 (11:22 -0500)
Do this at the start of the command so that it doesn't
need to be checked and set up in every function that
could need it.

lib/cache/lvmcache.c
lib/label/label.c
lib/label/label.h

index 87bcc3723ab24e38230655896e6a066eb9df4b90..53254f4762a00bafa968c34bd2eeb9b766450047 100644 (file)
@@ -1241,8 +1241,11 @@ int lvmcache_label_scan(struct cmd_context *cmd)
 
        int r = 0;
 
-       if (lvmetad_used())
+       if (lvmetad_used()) {
+               if (!label_scan_setup_bcache())
+                       return 0;
                return 1;
+       }
 
        /* Avoid recursion when a PVID can't be found! */
        if (_scanning_in_progress)
index 3359b4dbe690c4d97f227850348c75a80463f5a6..dc14bebc391c8c10525eae053d65752e09b5808e 100644 (file)
@@ -678,18 +678,6 @@ int label_scan_devs(struct cmd_context *cmd, struct dm_list *devs)
 {
        struct device_list *devl;
 
-       if (!scan_bcache) {
-               /*
-                * This is only needed when commands are using lvmetad, in
-                * which case they don't do an initial label_scan, but may
-                * later need to rescan certain devs from disk and call this
-                * function.
-                * FIXME: is there some better number to choose here?
-                */
-               if (!_setup_bcache(32))
-                       return 0;
-       }
-
        dm_list_iterate_items(devl, devs) {
                if (_in_bcache(devl->dev)) {
                        bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
@@ -841,3 +829,20 @@ void label_scan_confirm(struct device *dev)
                label_read(dev, NULL, 0);
 }
 
+/*
+ * This is only needed when commands are using lvmetad, in which case they
+ * don't do an initial label_scan, but may later need to rescan certain devs
+ * from disk and call this function.  FIXME: is there some better number to
+ * choose here?
+ */
+
+int label_scan_setup_bcache(void)
+{
+       if (!scan_bcache) {
+               if (!_setup_bcache(32))
+                       return 0;
+       }
+
+       return 1;
+}
+
index e265a6b9bb784d2cdc2338b1e5686d7765e23281..107bd30f7b6ba7e4de1df7d213dd64cde00fe528 100644 (file)
@@ -110,5 +110,6 @@ void label_scan_destroy(struct cmd_context *cmd);
 int label_read(struct device *dev, struct label **labelp, uint64_t unused_sector);
 int label_read_sector(struct device *dev, struct label **labelp, uint64_t scan_sector);
 void label_scan_confirm(struct device *dev);
+int label_scan_setup_bcache(void);
 
 #endif
This page took 0.045317 seconds and 5 git commands to generate.