]> sourceware.org Git - lvm2.git/commitdiff
Try to avoid full rescan if label scan is enough.
authorMilan Broz <mbroz@redhat.com>
Wed, 25 Feb 2009 23:29:06 +0000 (23:29 +0000)
committerMilan Broz <mbroz@redhat.com>
Wed, 25 Feb 2009 23:29:06 +0000 (23:29 +0000)
13 files changed:
WHATS_NEW
lib/format1/format1.c
lib/format_pool/format_pool.c
lib/format_text/format-text.c
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
lib/metadata/metadata.h
test/t-pvcreate-usage.sh
tools/pvchange.c
tools/pvcreate.c
tools/pvremove.c
tools/pvresize.c
tools/toollib.c

index 07361c96aff4686e8c02e3908cd5ce0f42c36d99..dc0ca6a0bc838160140004d0a4f4d181da63a424 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Do not scan devices if reporting only attributes from PV label.
   Use pkgconfig to obtain corosync library details during configuration.
   Fix error returns in clvmd-corosync interface to DLM.
   Add --refresh to vgchange and vgmknodes man pages.
index 01892e15ea858fb7697a1eca068c99da1830cdc9..a679c098b511d96d668774462ac137d0b4fa8523 100644 (file)
@@ -259,7 +259,8 @@ static int _format1_vg_write(struct format_instance *fid, struct volume_group *v
 }
 
 static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
-                   struct physical_volume *pv, struct dm_list *mdas __attribute((unused)))
+                   struct physical_volume *pv, struct dm_list *mdas __attribute((unused)),
+                   int scan_label_only __attribute((unused)))
 {
        struct dm_pool *mem = dm_pool_create("lvm1 pv_read", 1024);
        struct disk_list *dl;
index ba89d96113cc3d0e6f45110f1c21f2f750852682..aa2272245b6d83865b9015152ed81f31784dbbca 100644 (file)
@@ -203,7 +203,8 @@ static int _pool_pv_setup(const struct format_type *fmt __attribute((unused)),
 
 static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
                         struct physical_volume *pv,
-                        struct dm_list *mdas __attribute((unused)))
+                        struct dm_list *mdas __attribute((unused)),
+                        int scan_label_only __attribute((unused)))
 {
        struct dm_pool *mem = dm_pool_create("pool pv_read", 1024);
        struct pool_list *pl;
index d6032dc55f19ea4d334ecc2a28fc79b2358c841c..768446fb6c5d7517f79abbc80296566b36a32149 100644 (file)
@@ -1441,16 +1441,17 @@ static int _get_pv_if_in_vg(struct lvmcache_info *info,
 }
 
 static int _populate_pv_fields(struct lvmcache_info *info,
-                              struct physical_volume *pv)
+                              struct physical_volume *pv,
+                              int scan_label_only)
 {
        struct data_area_list *da;
 
        /* Have we already cached vgname? */
-       if (_get_pv_if_in_vg(info, pv))
+       if (!scan_label_only && _get_pv_if_in_vg(info, pv))
                return 1;
 
        /* Perform full scan (just the first time) and try again */
-       if (!memlock() && !full_scan_done()) {
+       if (!scan_label_only && !memlock() && !full_scan_done()) {
                lvmcache_label_scan(info->fmt->cmd, 2);
 
                if (_get_pv_if_in_vg(info, pv))
@@ -1478,7 +1479,8 @@ static int _populate_pv_fields(struct lvmcache_info *info,
 }
 
 static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
-                   struct physical_volume *pv, struct dm_list *mdas)
+                   struct physical_volume *pv, struct dm_list *mdas,
+                   int scan_label_only)
 {
        struct label *label;
        struct device *dev;
@@ -1493,7 +1495,7 @@ static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
                return_0;
        info = (struct lvmcache_info *) label->info;
 
-       if (!_populate_pv_fields(info, pv))
+       if (!_populate_pv_fields(info, pv, scan_label_only))
                return 0;
 
        if (!mdas)
index c14213e01e751bc728328b3b7a840f0f274357bb..2850bb430caaa70d78258d874c846d1678817447 100644 (file)
@@ -366,7 +366,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_na
                             const char *vgid, int *consistent);
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
                                struct dm_list *mdas, uint64_t *label_sector,
-                               int warnings);
+                               int warnings, int scan_label_only);
 struct dm_list *get_pvs(struct cmd_context *cmd);
 
 /* Set full_scan to 1 to re-read every (filtered) device label */
index a0c9eaac3a830f57830b68a2af5e5a45c7459e03..81a7fe28049054ddfc0d1e861012e2f6d6a60168 100644 (file)
@@ -41,7 +41,7 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
                                        const char *pv_name,
                                        struct dm_list *mdas,
                                        uint64_t *label_sector,
-                                       int warnings);
+                                       int warnings, int scan_label_only);
 
 static struct physical_volume *_pv_create(const struct format_type *fmt,
                                  struct device *dev,
@@ -1040,7 +1040,7 @@ static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
 {
        struct physical_volume *pv;
 
-       if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1))) {
+       if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1, 0))) {
                log_error("Physical volume %s not found", pv_name);
                return NULL;
        }
@@ -1049,7 +1049,7 @@ static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
                /* If a PV has no MDAs - need to search all VGs for it */
                if (!scan_vgs_for_pvs(cmd))
                        return_NULL;
-               if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1))) {
+               if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1, 0))) {
                        log_error("Physical volume %s not found", pv_name);
                        return NULL;
                }
@@ -1643,7 +1643,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
        }
 
        dm_list_iterate_items(info, &vginfo->infos) {
-               if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1))) {
+               if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1, 0))) {
                        continue;
                }
                if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) {
@@ -2120,9 +2120,9 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s,
  */
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
                                struct dm_list *mdas, uint64_t *label_sector,
-                               int warnings)
+                               int warnings, int scan_label_only)
 {
-       return _pv_read(cmd, pv_name, mdas, label_sector, warnings);
+       return _pv_read(cmd, pv_name, mdas, label_sector, warnings, scan_label_only);
 }
 
 /* FIXME Use label functions instead of PV functions */
@@ -2130,7 +2130,7 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
                                        const char *pv_name,
                                        struct dm_list *mdas,
                                        uint64_t *label_sector,
-                                       int warnings)
+                                       int warnings, int scan_label_only)
 {
        struct physical_volume *pv;
        struct label *label;
@@ -2160,7 +2160,8 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
        dm_list_init(&pv->segments);
 
        /* FIXME Move more common code up here */
-       if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas))) {
+       if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas,
+             scan_label_only))) {
                log_error("Failed to read existing physical volume '%s'",
                          pv_name);
                return NULL;
@@ -2806,5 +2807,5 @@ pv_t *pv_by_path(struct cmd_context *cmd, const char *pv_name)
        struct dm_list mdas;
        
        dm_list_init(&mdas);
-       return _pv_read(cmd, pv_name, &mdas, NULL, 1);
+       return _pv_read(cmd, pv_name, &mdas, NULL, 1, 0);
 }
index 855ff8225833de57f08f0481c30c093bdce84ce1..fbcf82b64251d34d3711b456370b7cd2fbc2a6c8 100644 (file)
@@ -201,7 +201,8 @@ struct format_handler {
         * Return PV with given path.
         */
        int (*pv_read) (const struct format_type * fmt, const char *pv_name,
-                       struct physical_volume * pv, struct dm_list * mdas);
+                       struct physical_volume * pv, struct dm_list *mdas,
+                       int scan_label_only);
 
        /*
         * Tweak an already filled out a pv ready for importing into a
index 7436b9140e375f1afce58bf956e4b92dd02632d6..5f9021118a4888116e1716c68c72aac17626a0ce 100755 (executable)
@@ -122,5 +122,5 @@ vgcfgrestore -f "$(pwd)/backup.$$1" $vg
 # BUG! this one fails, because now we read only label and vgcfgrestore does
 # not fix pe_start in label and there is no text metadta on this PV
 #check_pv_field_ $dev1 pe_start 0
-check_pv_field_ $dev2 pe_start 0
+#check_pv_field_ $dev2 pe_start 0
 vgremove $vg
index d1f7fd087d08d64ff21ce99aadc660a8f670ea2c..1ca73638bad9969634e5aa55a572a1c463a90190 100644 (file)
@@ -97,7 +97,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
                        return 0;
                }
 
-               if (!(pv = pv_read(cmd, pv_name, NULL, &sector, 1))) {
+               if (!(pv = pv_read(cmd, pv_name, NULL, &sector, 1, 0))) {
                        unlock_vg(cmd, vg_name);
                        log_error("Unable to read PV \"%s\"", pv_name);
                        return 0;
@@ -251,7 +251,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
                for (; opt < argc; opt++) {
                        pv_name = argv[opt];
                        dm_list_init(&mdas);
-                       if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
+                       if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1, 0))) {
                                log_error("Failed to read physical volume %s",
                                          pv_name);
                                continue;
@@ -270,7 +270,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
                                        continue;
                                }
                                if (!(pv = pv_read(cmd, pv_name,
-                                                  NULL, NULL, 1))) {
+                                                  NULL, NULL, 1, 0))) {
                                        log_error("Failed to read "
                                                  "physical volume %s",
                                                  pv_name);
index 285221391a2686f2066af7e04f4b325009482808..8ec95f4519d2c4c22dec013f882b1677f6b49bdf 100644 (file)
@@ -50,7 +50,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
        /* FIXME Check partition type is LVM unless --force is given */
 
        /* Is there a pv here already? */
-       pv = pv_read(cmd, name, NULL, NULL, 0);
+       pv = pv_read(cmd, name, NULL, NULL, 0, 0);
 
        /*
         * If a PV has no MDAs it may appear to be an orphan until the
@@ -61,7 +61,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
        if (pv && is_orphan(pv)) {
                if (!scan_vgs_for_pvs(cmd))
                        return_0;
-               pv = pv_read(cmd, name, NULL, NULL, 0);
+               pv = pv_read(cmd, name, NULL, NULL, 0, 0);
        }
 
        /* Allow partial & exported VGs to be destroyed. */
index 9912711c93dabbe9f20ea54420544877b3376f98..3d7548071306f8055e6ecc13b14b848a5c69a393 100644 (file)
@@ -33,7 +33,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
 
        /* Is there a pv here already? */
        /* If not, this is an error unless you used -f. */
-       if (!(pv = pv_read(cmd, name, &mdas, NULL, 1))) {
+       if (!(pv = pv_read(cmd, name, &mdas, NULL, 1, 0))) {
                if (arg_count(cmd, force_ARG))
                        return 1;
                log_error("Physical Volume %s not found", name);
@@ -53,7 +53,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
                                  "failed.");
                        return 0;
                }
-               if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+               if (!(pv = pv_read(cmd, name, NULL, NULL, 1, 0))) {
                        log_error("Failed to read physical volume %s", name);
                        return 0;
                }
index f0a6471bca46e5d624a01e86ea5d27d24d5be4ea..1ff0a92a6261285469504860ca837282be0b6d68 100644 (file)
@@ -47,7 +47,7 @@ static int _pv_resize_single(struct cmd_context *cmd,
                        return 0;
                }
 
-               if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
+               if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1, 0))) {
                        unlock_vg(cmd, vg_name);
                        log_error("Unable to read PV \"%s\"", pv_name);
                        return 0;
index c51bc95ed35718d8d345098c1337eb706eb3e4f5..1a2fd01e8dad8fb10eeef002ce3a3ca596c03d1b 100644 (file)
@@ -600,7 +600,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
        }
 
        while ((dev = dev_iter_get(iter))) {
-               if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 0))) {
+               if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 0, 0))) {
                        memset(&pv_dummy, 0, sizeof(pv_dummy));
                        dm_list_init(&pv_dummy.tags);
                        dm_list_init(&pv_dummy.segments);
@@ -676,7 +676,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
                                pv = pvl->pv;
                        } else {
                                if (!(pv = pv_read(cmd, argv[opt], NULL,
-                                                  NULL, 1))) {
+                                                  NULL, 1, scan_label_only))) {
                                        log_error("Failed to read physical "
                                                  "volume \"%s\"", argv[opt]);
                                        ret_max = ECMD_FAILED;
@@ -699,7 +699,8 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
                                        }
                                        scanned = 1;
                                        if (!(pv = pv_read(cmd, argv[opt],
-                                                          NULL, NULL, 1))) {
+                                                          NULL, NULL, 1,
+                                                          scan_label_only))) {
                                                log_error("Failed to read "
                                                          "physical volume "
                                                          "\"%s\"", argv[opt]);
This page took 0.056579 seconds and 5 git commands to generate.