summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2009-02-25 23:29:06 +0000
committerMilan Broz <mbroz@redhat.com>2009-02-25 23:29:06 +0000
commit7b1c853bd901477a99161a4f6e05bee461c490dc (patch)
tree4d5d6d740f46535c500a41ebad88114d6e04aa3d
parentedf47283de397e86055086e19d3012d0c02602d0 (diff)
downloadlvm2-7b1c853bd901477a99161a4f6e05bee461c490dc.tar.gz
lvm2-7b1c853bd901477a99161a4f6e05bee461c490dc.tar.xz
lvm2-7b1c853bd901477a99161a4f6e05bee461c490dc.zip
Try to avoid full rescan if label scan is enough.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/format1/format1.c3
-rw-r--r--lib/format_pool/format_pool.c3
-rw-r--r--lib/format_text/format-text.c12
-rw-r--r--lib/metadata/metadata-exported.h2
-rw-r--r--lib/metadata/metadata.c19
-rw-r--r--lib/metadata/metadata.h3
-rwxr-xr-xtest/t-pvcreate-usage.sh2
-rw-r--r--tools/pvchange.c6
-rw-r--r--tools/pvcreate.c4
-rw-r--r--tools/pvremove.c4
-rw-r--r--tools/pvresize.c2
-rw-r--r--tools/toollib.c7
13 files changed, 38 insertions, 30 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 07361c96..dc0ca6a0 100644
--- 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.
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 01892e15..a679c098 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -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;
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index ba89d961..aa227224 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -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;
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index d6032dc5..768446fb 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -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)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c14213e0..2850bb43 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -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 */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index a0c9eaac..81a7fe28 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -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);
}
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 855ff822..fbcf82b6 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -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
diff --git a/test/t-pvcreate-usage.sh b/test/t-pvcreate-usage.sh
index 7436b914..5f902111 100755
--- a/test/t-pvcreate-usage.sh
+++ b/test/t-pvcreate-usage.sh
@@ -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
diff --git a/tools/pvchange.c b/tools/pvchange.c
index d1f7fd08..1ca73638 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -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);
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 28522139..8ec95f45 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -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. */
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 9912711c..3d754807 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -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;
}
diff --git a/tools/pvresize.c b/tools/pvresize.c
index f0a6471b..1ff0a92a 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -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;
diff --git a/tools/toollib.c b/tools/toollib.c
index c51bc95e..1a2fd01e 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -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]);