master - report: Print UUIDs for missing PVs when possible.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ae337d472eb973...
Commit: ae337d472eb973bbde80d641da9567acfa7874ff
Parent: ecc296311ff2a251aa254353b0a0fb3ee97be97c
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Nov 17 22:36:13 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 22:36:13 2013 +0100
report: Print UUIDs for missing PVs when possible.
---
test/shell/listings.sh | 3 +++
tools/reporter.c | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/test/shell/listings.sh b/test/shell/listings.sh
index 0d4c83f..e5a3954 100644
--- a/test/shell/listings.sh
+++ b/test/shell/listings.sh
@@ -69,3 +69,6 @@ vgs -o pv_name,vg_name $vg
pvdisplay $(cat DEVICES) >out
pvdisplay --maps $(cat DEVICES) >out2
not diff out out2
+
+aux disable_dev $dev1
+pvs -o +pv_uuid | grep BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
diff --git a/tools/reporter.c b/tools/reporter.c
index fb01686..dccd785 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -142,6 +142,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
char uuid[64] __attribute__((aligned(8)));
struct label *label;
struct label _dummy_label = { 0 };
+ struct device _dummy_device = { 0 };
if (is_pv(pv) && !is_orphan(pv) && !vg) {
vg_name = pv_vg_name(pv);
@@ -182,7 +183,12 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
/* FIXME workaround for pv_label going through cache; remove once struct
* physical_volume gains a proper "label" pointer */
if (!(label = pv_label(pv))) {
- _dummy_label.dev = pv->dev;
+ if (pv->dev)
+ _dummy_label.dev = pv->dev;
+ else {
+ _dummy_label.dev = &_dummy_device;
+ memcpy(_dummy_device.pvid, &pv->id, ID_LEN);
+ }
label = &_dummy_label;
}
10 years, 4 months
master - metadata: Do not throw an error in pv_label for missing PVs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ecc296311ff2a2...
Commit: ecc296311ff2a251aa254353b0a0fb3ee97be97c
Parent: a5bb1b48eea704c5970a719d2e77577dccd82bb9
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Nov 17 22:35:16 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 22:35:16 2013 +0100
metadata: Do not throw an error in pv_label for missing PVs.
---
lib/metadata/pv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c
index 1d608f2..349048e 100644
--- a/lib/metadata/pv.c
+++ b/lib/metadata/pv.c
@@ -355,7 +355,7 @@ struct label *pv_label(const struct physical_volume *pv)
struct lvmcache_info *info =
lvmcache_info_from_pvid((const char *)&pv->id.uuid, 0);
if (!info) {
- if (pv->vg) /* process_each_pv will create PVs that are dummy
+ if (pv->vg && pv->dev) /* process_each_pv will create PVs that are dummy
* and that have no label associated */
log_error(INTERNAL_ERROR "PV %s unexpectedly not in cache.",
dev_name(pv->dev));
10 years, 4 months
master - dev-cache.c: Make dev_name a little more robust.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5bb1b48eea704...
Commit: a5bb1b48eea704c5970a719d2e77577dccd82bb9
Parent: 71b6565529028fcc075c52595fde380c96065cc9
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Nov 17 22:34:56 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 22:34:56 2013 +0100
dev-cache.c: Make dev_name a little more robust.
---
lib/device/dev-cache.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 46e5d65..9451314 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1036,6 +1036,6 @@ int dev_fd(struct device *dev)
const char *dev_name(const struct device *dev)
{
- return (dev) ? dm_list_item(dev->aliases.n, struct str_list)->str :
+ return (dev && dev->aliases.n) ? dm_list_item(dev->aliases.n, struct str_list)->str :
"unknown device";
}
10 years, 4 months
master - report: Convert pv_mda_size to a type "label" field.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=71b6565529028f...
Commit: 71b6565529028fcc075c52595fde380c96065cc9
Parent: 14ffc9d4df952346ce4338939b3ed869b8b491b4
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Nov 17 21:04:07 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
report: Convert pv_mda_size to a type "label" field.
---
lib/report/columns.h | 2 +-
lib/report/report.c | 5 ++---
test/shell/pvcreate-usage.sh | 1 +
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 0617605..93b5575 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -71,7 +71,7 @@ FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifie
FIELD(LABEL, label, NUM, "DevSize", dev, 7, devsize, dev_size, "Size of underlying device in current units.", 0)
FIELD(LABEL, label, STR, "PV", dev, 10, dev_name, pv_name, "Name.", 0)
FIELD(LABEL, label, NUM, "PMdaFree", type, 9, pvmdafree, pv_mda_free, "Free metadata area space on this device in current units.", 0)
-FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, pv_mda_size, "Size of smallest metadata area on this device in current units.", 0)
+FIELD(LABEL, label, NUM, "PMdaSize", type, 9, pvmdasize, pv_mda_size, "Size of smallest metadata area on this device in current units.", 0)
FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, pe_start, "Offset to the start of data on the underlying device.", 0)
FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, pv_size, "Size of PV in current units.", 0)
diff --git a/lib/report/report.c b/lib/report/report.c
index e4ad2c3..9cb2298 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -820,9 +820,8 @@ static int _pvmdasize_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
- const struct physical_volume *pv =
- (const struct physical_volume *) data;
- uint64_t min_mda_size = pv_mda_size(pv);
+ const struct label *label = (const struct label *) data;
+ uint64_t min_mda_size = lvmcache_smallest_mda_size(label->info);
return _size64_disp(rh, mem, field, &min_mda_size, private);
}
diff --git a/test/shell/pvcreate-usage.sh b/test/shell/pvcreate-usage.sh
index c78e4bd..251746d 100644
--- a/test/shell/pvcreate-usage.sh
+++ b/test/shell/pvcreate-usage.sh
@@ -34,6 +34,7 @@ pvremove "$dev1"
pvcreate --metadatasize 512k "$dev1"
pvcreate --metadatasize 96k "$dev2"
vgcreate $vg "$dev1" "$dev2"
+pvs -o +pv_mda_size
check compare_fields vgs $vg vg_mda_size pvs "$dev2" pv_mda_size
vgremove $vg
10 years, 4 months
master - reporter: Adapt pvseg reporting to label-type fields.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=14ffc9d4df9523...
Commit: 14ffc9d4df952346ce4338939b3ed869b8b491b4
Parent: 22942821841da6e84f3fd6c988ed6a3a37401ba6
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Aug 28 14:11:59 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
reporter: Adapt pvseg reporting to label-type fields.
---
lib/report/report.c | 11 ++++++++---
tools/reporter.c | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 9fd75bb..e4ad2c3 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -727,10 +727,15 @@ static int _pvuuid_disp(struct dm_report *rh __attribute__((unused)), struct dm_
const struct label *label = (const struct label *) data;
char *repstr = NULL;
- if (!(repstr = id_format_and_copy(mem, label->dev->pvid)))
- return_0;
+ if (!label->dev)
+ dm_report_field_set_value(field, "", NULL);
+ else {
+ if (!(repstr = id_format_and_copy(mem, label->dev->pvid)))
+ return_0;
+
+ dm_report_field_set_value(field, repstr, NULL);
+ }
- dm_report_field_set_value(field, repstr, NULL);
return 1;
}
diff --git a/tools/reporter.c b/tools/reporter.c
index 28e178c..fb01686 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -107,7 +107,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd,
dm_list_init(&_free_logical_volume.snapshot_segs);
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
- seg ? : &_free_lv_segment, pvseg, NULL)) {
+ seg ? : &_free_lv_segment, pvseg, pv_label(pvseg->pv))) {
ret = ECMD_FAILED;
goto_out;
}
10 years, 4 months
master - reporter: Deal correctly with dummy PVs/labels.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22942821841da6...
Commit: 22942821841da6e84f3fd6c988ed6a3a37401ba6
Parent: d5095222fa4f8cea89b721dcb12adad89176413e
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Aug 28 14:07:26 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
reporter: Deal correctly with dummy PVs/labels.
---
lib/report/report.c | 2 +-
tools/reporter.c | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index dee4ea2..9fd75bb 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -184,7 +184,7 @@ static int _pvfmt_disp(struct dm_report *rh, struct dm_pool *mem,
const struct label *l =
(const struct label *) data;
- if (!l->labeller->fmt) {
+ if (!l->labeller || !l->labeller->fmt) {
dm_report_field_set_value(field, "", NULL);
return 1;
}
diff --git a/tools/reporter.c b/tools/reporter.c
index a15f8ef..28e178c 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -141,6 +141,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
struct volume_group *old_vg = vg;
char uuid[64] __attribute__((aligned(8)));
struct label *label;
+ struct label _dummy_label = { 0 };
if (is_pv(pv) && !is_orphan(pv) && !vg) {
vg_name = pv_vg_name(pv);
@@ -178,9 +179,14 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
pv = pvl->pv;
}
- if ((!(label = pv_label(pv))) ||
- (!report_object(handle, vg, NULL, pv, NULL, NULL, label)))
- {
+ /* FIXME workaround for pv_label going through cache; remove once struct
+ * physical_volume gains a proper "label" pointer */
+ if (!(label = pv_label(pv))) {
+ _dummy_label.dev = pv->dev;
+ label = &_dummy_label;
+ }
+
+ if (!report_object(handle, vg, NULL, pv, NULL, NULL, label)) {
stack;
ret = ECMD_FAILED;
}
10 years, 4 months
master - toollib: Report errors on non-PV arguments to process_each_label.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d5095222fa4f8c...
Commit: d5095222fa4f8cea89b721dcb12adad89176413e
Parent: 67c563ac2b643f97602686dc07cee4a8bdb5bc34
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Aug 21 01:32:51 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
toollib: Report errors on non-PV arguments to process_each_label.
---
tools/toollib.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 529088c..9a33e55 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1821,8 +1821,12 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv, void *han
continue;
}
- if (!label_read(dev, &label, 0))
+ if (!label_read(dev, &label, 0)) {
+ log_error("No physical volume label read from %s",
+ argv[opt]);
+ ret_max = ECMD_FAILED;
continue;
+ }
ret = process_single_label(cmd, label, handle);
10 years, 4 months
master - pv_label: NULL result is not always an internal error.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=67c563ac2b643f...
Commit: 67c563ac2b643f97602686dc07cee4a8bdb5bc34
Parent: a8aa8d4b5c5722cab871c3243a203d26d6f5ac83
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Aug 21 01:30:38 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
pv_label: NULL result is not always an internal error.
---
lib/metadata/pv.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c
index 0288f07..1d608f2 100644
--- a/lib/metadata/pv.c
+++ b/lib/metadata/pv.c
@@ -355,7 +355,10 @@ struct label *pv_label(const struct physical_volume *pv)
struct lvmcache_info *info =
lvmcache_info_from_pvid((const char *)&pv->id.uuid, 0);
if (!info) {
- log_error(INTERNAL_ERROR "PV %s unexpectedly not in cache.", dev_name(pv->dev));
+ if (pv->vg) /* process_each_pv will create PVs that are dummy
+ * and that have no label associated */
+ log_error(INTERNAL_ERROR "PV %s unexpectedly not in cache.",
+ dev_name(pv->dev));
return NULL;
}
return lvmcache_get_label(info);
10 years, 4 months
master - report: Make PV UUID into a "label" type field.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a8aa8d4b5c5722...
Commit: a8aa8d4b5c5722cab871c3243a203d26d6f5ac83
Parent: 67a7b7a87da65b2350f975272e581be5f41976e0
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jul 29 19:15:31 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
report: Make PV UUID into a "label" type field.
---
lib/report/columns.h | 2 +-
lib/report/report.c | 14 ++++++++++++++
test/shell/listings.sh | 4 +++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 8a87d11..0617605 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -66,8 +66,8 @@ FIELD(LVS, lv, STR, "Time", lvid, 26, lvtime, lv_time, "Creation time of the LV,
FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0)
-FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, pv_uuid, "Unique identifier.", 0)
FIELD(LABEL, label, STR, "Fmt", type, 3, pvfmt, pv_fmt, "Type of metadata.", 0)
+FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifier.", 0)
FIELD(LABEL, label, NUM, "DevSize", dev, 7, devsize, dev_size, "Size of underlying device in current units.", 0)
FIELD(LABEL, label, STR, "PV", dev, 10, dev_name, pv_name, "Name.", 0)
FIELD(LABEL, label, NUM, "PMdaFree", type, 9, pvmdafree, pv_mda_free, "Free metadata area space on this device in current units.", 0)
diff --git a/lib/report/report.c b/lib/report/report.c
index 3f716b5..dee4ea2 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -720,6 +720,20 @@ static int _uuid_disp(struct dm_report *rh __attribute__((unused)), struct dm_po
return _field_set_value(field, repstr, NULL);
}
+static int _pvuuid_disp(struct dm_report *rh __attribute__((unused)), struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private __attribute__((unused)))
+{
+ const struct label *label = (const struct label *) data;
+ char *repstr = NULL;
+
+ if (!(repstr = id_format_and_copy(mem, label->dev->pvid)))
+ return_0;
+
+ dm_report_field_set_value(field, repstr, NULL);
+ return 1;
+}
+
static int _pvmdas_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
diff --git a/test/shell/listings.sh b/test/shell/listings.sh
index 30df79f..0d4c83f 100644
--- a/test/shell/listings.sh
+++ b/test/shell/listings.sh
@@ -17,7 +17,7 @@
aux prepare_devs 5
-pvcreate "$dev1"
+pvcreate --uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE --norestorefile "$dev1"
pvcreate --metadatacopies 0 "$dev2"
pvcreate --metadatacopies 0 "$dev3"
pvcreate "$dev4"
@@ -31,6 +31,8 @@ test $(pvs --noheadings -o seg_all,pv_all,lv_all,vg_all $(cat DEVICES) | wc -l)
vgcreate $vg $(cat DEVICES)
+check pv_field $dev1 pv_uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
+
#COMM pvs and vgs report mda_count, mda_free (bz202886, bz247444)
pvs -o +pv_mda_count,pv_mda_free $(cat DEVICES)
for I in "$dev2" "$dev3" "$dev5"; do
10 years, 4 months
master - report: Iterate over labels instead of PVs for label-only reports.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=67a7b7a87da65b...
Commit: 67a7b7a87da65b2350f975272e581be5f41976e0
Parent: 99214c51eb815806c4a4a4711fa3562546479751
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jul 29 19:14:51 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:43:06 2013 +0100
report: Iterate over labels instead of PVs for label-only reports.
---
tools/reporter.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 8b2a7c7..a15f8ef 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -391,8 +391,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
report_handle, &_vgs_single);
break;
case LABEL:
- r = process_each_pv(cmd, argc, argv, NULL, READ_WITHOUT_LOCK,
- 1, report_handle, &_label_single);
+ r = process_each_label(cmd, argc, argv,
+ report_handle, &_label_single);
break;
case PVS:
if (args_are_pvs)
10 years, 4 months