From: Milan Broz <mbroz@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] Fix pvseg report for orphan PVs and other devices.
Date: Tue, 21 Apr 2009 12:56:53 +0200 [thread overview]
Message-ID: <49EDA675.9080902@redhat.com> (raw)
Fix pvseg report for orphan PVs and other devices.
If user requests report attribute from PVSEG type
and PV is orphan (or all devices is set), the report
is empty.
Try for example (when only orphan PV are present)
#pvs
#pvs -o +devices
# pvs /dev/sdb1
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 -- 46.58G 46.58G
# pvs -o +devices /dev/sdb1
(no output)
The problem is caused by empty pv->segments list.
Fix it by providing fake segment here (similar to fake structures
in _pvsegs_sub_single() calls.
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
tools/toollib.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index bdca53f..8df9ed5 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -375,6 +375,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
int ret_max = ECMD_PROCESSED;
int ret;
struct volume_group *old_vg = vg;
+ struct pv_segment _free_pv_segment = { .pv = pv };
if (is_pv(pv) && !vg && !is_orphan(pv)) {
vg_name = pv_vg_name(pv);
@@ -399,13 +400,18 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
pv = pvl->pv;
}
- dm_list_iterate_items(pvseg, &pv->segments) {
- ret = process_single(cmd, vg, pvseg, handle);
+ if (dm_list_empty(&pv->segments)) {
+ ret = process_single(cmd, vg, &_free_pv_segment, handle);
if (ret > ret_max)
ret_max = ret;
- if (sigint_caught())
- break;
- }
+ } else
+ dm_list_iterate_items(pvseg, &pv->segments) {
+ ret = process_single(cmd, vg, pvseg, handle);
+ if (ret > ret_max)
+ ret_max = ret;
+ if (sigint_caught())
+ break;
+ }
if (vg_name)
unlock_vg(cmd, vg_name);
next reply other threads:[~2009-04-21 10:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 10:56 Milan Broz [this message]
2009-04-21 12:31 ` [PATCH v2] Fix pvseg report for orphan PVs and other devices Milan Broz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49EDA675.9080902@redhat.com \
--to=mbroz@redhat.com \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.