master - metadata: fix ALLOCATABLE_PV for lvm1 format
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5c3d8940136f39...
Commit: 5c3d8940136f39a017ab434651789647161350b1
Parent: fd5912762b4815deb7a58fc4c5971801888e0ed3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jul 11 12:24:15 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jul 11 12:24:15 2014 +0200
metadata: fix ALLOCATABLE_PV for lvm1 format
This is addendum for commit 6dc7b783c80c6834aa724df49b5d47b9b5601506.
LVM1 format stores the ALLOCATABLE flag directly in PV header, not
in VG metadata. So the code needs to be fixed further to work
properly for lvm1 format so that the correct PV header is written
(the flag is set only if the PV is in some VG, unset otherwise).
---
lib/format1/format1.c | 6 +++++-
lib/metadata/metadata.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 16746e3..8ee2f48 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -381,6 +381,7 @@ static int _format1_pv_setup(const struct format_type *fmt,
struct physical_volume *pv,
struct volume_group *vg)
{
+ int r;
struct pvcreate_restorable_params rp = {.restorefile = NULL,
.id = {{0}},
.idp = NULL,
@@ -390,7 +391,10 @@ static int _format1_pv_setup(const struct format_type *fmt,
.extent_count = 0,
.extent_size = vg->extent_size};
- return _format1_pv_initialise(fmt, -1, 0, 0, &rp, pv);
+ if ((r = _format1_pv_initialise(fmt, -1, 0, 0, &rp, pv)))
+ pv->status |= ALLOCATABLE_PV;
+
+ return r;
}
static int _format1_lv_setup(struct format_instance *fid, struct logical_volume *lv)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 2d69714..0832750 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -602,7 +602,7 @@ int vg_remove(struct volume_group *vg)
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", pv_dev_name(pv), vg->name);
pv->vg_name = vg->fid->fmt->orphan_vg_name;
- pv->status = ALLOCATABLE_PV;
+ pv->status &= ~ALLOCATABLE_PV;
if (!dev_get_size(pv_dev(pv), &pv->size)) {
log_error("%s: Couldn't get size.", pv_dev_name(pv));
9 years, 9 months
master - report: display 'unknown' value for lv_active_remotely field if the LV is also active locally
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd5912762b4815...
Commit: fd5912762b4815deb7a58fc4c5971801888e0ed3
Parent: c9ae21798e1fa94e56c0f07ece1527377cbf1623
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jul 11 11:56:50 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jul 11 11:56:50 2014 +0200
report: display 'unknown' value for lv_active_remotely field if the LV is also active locally
Currently, we can't determine whether the LV is active remotely
or not in that case.
---
lib/report/report.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index e9f379a..91dfac0 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1478,7 +1478,28 @@ static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
if (vg_is_clustered(lv->vg)) {
lv = lv_lock_holder(lv);
- active_remotely = lv_is_active_but_not_locally(lv);
+ /* FIXME: It seems we have no way to get this info correctly
+ * with current interface - we'd need to check number
+ * of responses from the cluster:
+ * - if number of nodes that responded == 1
+ * - and LV is active on local node
+ * ..then we may say that LV is *not* active remotely.
+ *
+ * Otherwise ((responses > 1 && LV active locally) ||
+ * (responses == 1 && LV not active locally)), it's
+ * active remotely.
+ *
+ * We have this info, but hidden underneath the
+ * locking interface (locking_type.query_resource fn).
+ *
+ * For now, let's use 'unknown' for remote status if
+ * the LV is found active locally until we find a way to
+ * smuggle the proper information out of the interface.
+ */
+ if (lv_is_active_locally(lv))
+ return _binary_undef_disp(rh, mem, field, private);
+ else
+ active_remotely = lv_is_active_but_not_locally(lv);
} else
active_remotely = 0;
9 years, 9 months
master - report: display 'unknown' value for active/active_locally/active_remotely/active_exclusively if info bypassed
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c9ae21798e1fa9...
Commit: c9ae21798e1fa94e56c0f07ece1527377cbf1623
Parent: 52af0dfbc0ebc442d3f1163e944e9ad88d05d46e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jul 11 11:15:06 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jul 11 11:15:06 2014 +0200
report: display 'unknown' value for active/active_locally/active_remotely/active_exclusively if info bypassed
Before the patch:
$ lvs -o name,active vg/lvol1 --driverloaded n
WARNING: Activation disabled. No device-mapper interaction will beattempted.
LV Active
lvol1 active
With this patch applied:
$ lvs -o name,active vg/lvol1 --driverloaded n
WARNING: Activation disabled. No device-mapper interaction will be attempted.
LV Active
lvol1 unknown
The same for active_{locally,remotely,exclusively} fields.
Also, rename headings for these fields (ActLocal/ActRemote/ActExcl).
---
lib/metadata/lv.c | 7 ++++++-
lib/report/columns.h | 6 +++---
lib/report/report.c | 9 +++++++++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 1ede9d6..d8fd320 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -910,6 +910,11 @@ char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
const char *s;
+ if (!activation()) {
+ s = "unknown";
+ goto out;
+ }
+
if (vg_is_clustered(lv->vg)) {
//const struct logical_volume *lvo = lv;
lv = lv_lock_holder(lv);
@@ -927,7 +932,7 @@ char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv)
else /* locally active */
s = lv_is_active_but_not_locally(lv) ?
"remotely" : "locally";
-
+out:
return dm_pool_strdup(mem, s);
}
diff --git a/lib/report/columns.h b/lib/report/columns.h
index dd5aa9e..af39008 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -53,9 +53,9 @@ FIELD(LVS, lv, STR, "TargetType", lvid, 10, lvtargettype, lv_target_type, "Kerne
FIELD(LVS, lv, STR, "Health", lvid, 15, lvhealthstatus, lv_health_status, "LV health status.", 0)
FIELD(LVS, lv, BIN, "SkipAct", lvid, 15, lvskipactivation, lv_skip_activation, "Set if LV is skipped on activation.", 0)
FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
-FIELD(LVS, lv, BIN, "ActiveLoc", lvid, 10, lvactivelocally, lv_active_locally, "Set if the LV is active locally.", 0)
-FIELD(LVS, lv, BIN, "ActiveRem", lvid, 10, lvactiveremotely, lv_active_remotely, "Set if the LV is active remotely.", 0)
-FIELD(LVS, lv, BIN, "ActiveExcl", lvid, 10, lvactiveexclusively, lv_active_exclusively, "Set if the LV is active exclusively.", 0)
+FIELD(LVS, lv, BIN, "ActLocal", lvid, 10, lvactivelocally, lv_active_locally, "Set if the LV is active locally.", 0)
+FIELD(LVS, lv, BIN, "ActRemote", lvid, 10, lvactiveremotely, lv_active_remotely, "Set if the LV is active remotely.", 0)
+FIELD(LVS, lv, BIN, "ActExcl", lvid, 10, lvactiveexclusively, lv_active_exclusively, "Set if the LV is active exclusively.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0)
FIELD(LVS, lv, SIZ, "Rahead", lvid, 6, lvreadahead, lv_read_ahead, "Read ahead setting in current units.", 0)
diff --git a/lib/report/report.c b/lib/report/report.c
index 061e39e..e9f379a 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1454,6 +1454,9 @@ static int _lvactivelocally_disp(struct dm_report *rh, struct dm_pool *mem,
const struct logical_volume *lv = (const struct logical_volume *) data;
int active_locally;
+ if (!activation())
+ return _binary_undef_disp(rh, mem, field, private);
+
if (vg_is_clustered(lv->vg)) {
lv = lv_lock_holder(lv);
active_locally = lv_is_active_locally(lv);
@@ -1470,6 +1473,9 @@ static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
const struct logical_volume *lv = (const struct logical_volume *) data;
int active_remotely;
+ if (!activation())
+ return _binary_undef_disp(rh, mem, field, private);
+
if (vg_is_clustered(lv->vg)) {
lv = lv_lock_holder(lv);
active_remotely = lv_is_active_but_not_locally(lv);
@@ -1486,6 +1492,9 @@ static int _lvactiveexclusively_disp(struct dm_report *rh, struct dm_pool *mem,
const struct logical_volume *lv = (const struct logical_volume *) data;
int active_exclusively;
+ if (!activation())
+ return _binary_undef_disp(rh, mem, field, private);
+
if (vg_is_clustered(lv->vg)) {
lv = lv_lock_holder(lv);
active_exclusively = lv_is_active_exclusive(lv);
9 years, 9 months
master - report: display 'unknown' value for LVSINFO fields if unable to get info
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=52af0dfbc0ebc4...
Commit: 52af0dfbc0ebc442d3f1163e944e9ad88d05d46e
Parent: f33d75e2e586a88ddeb20d860765f091098b8ab5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jul 11 10:18:59 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jul 11 10:18:59 2014 +0200
report: display 'unknown' value for LVSINFO fields if unable to get info
If the lv_info call fails for whatever reason/INFO dm ioctl fails or
the dm driver communication is disabled (--driverloaded n), make
sure we always display "unknown" for LVSINFO fields as that's exactly
what happens - we don't know the state.
Before the patch:
$ lvs -o name,device_open --driverloaded n
WARNING: Activation disabled. No device-mapper interaction will be attempted.
Command failed with status code 5.
With this patch applied:
$ lvs -o name,device_open --driverloaded n
WARNING: Activation disabled. No device-mapper interaction will be attempted.
LV DevOpen
lvol1 unknown
---
lib/report/report.c | 4 +++-
tools/reporter.c | 22 +++++++++++++---------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index d193c47..061e39e 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1394,7 +1394,9 @@ static int _lvpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
if (!(lvi->lv->status & PVMOVE)) {
if (lvi->lv->status & LVM_WRITE) {
- if (lvi->info->read_only)
+ if (!lvi->info->exists)
+ perms = _str_unknown;
+ else if (lvi->info->read_only)
perms = FIRST_NAME(lv_permissions_r_override);
else
perms = FIRST_NAME(lv_permissions_rw);
diff --git a/tools/reporter.c b/tools/reporter.c
index 0780283..462ca8a 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -48,14 +48,20 @@ static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_PROCESSED;
}
+static void _get_lv_info_for_report(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct lvinfo *lvinfo)
+{
+ if (!lv_info(cmd, lv, 0, lvinfo, 1, 1))
+ lvinfo->exists = 0;
+}
+
static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
struct lvinfo lvinfo;
- if (!lv_info(cmd, lv, 0, &lvinfo, 1, 1))
- return_ECMD_FAILED;
-
+ _get_lv_info_for_report(cmd, lv, &lvinfo);
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL, &lvinfo, NULL))
return_ECMD_FAILED;
@@ -76,8 +82,8 @@ static int _segs_with_lv_info_single(struct cmd_context *cmd __attribute__((unus
{
struct lvinfo lvinfo;
- if (!lv_info(cmd, seg->lv, 0, &lvinfo, 1, 1) ||
- !report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL, &lvinfo, NULL))
+ _get_lv_info_for_report(cmd, seg->lv, &lvinfo);
+ if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL, &lvinfo, NULL))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -137,10 +143,8 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
dm_list_init(&_free_logical_volume.snapshot_segs);
lvinfo.exists = 0;
- if (seg && lv_info_needed && !lv_info(cmd, seg->lv, 0, &lvinfo, 1, 1)) {
- ret = ECMD_FAILED;
- goto_out;
- }
+ if (seg && lv_info_needed)
+ _get_lv_info_for_report(cmd, seg->lv, &lvinfo);
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
seg ? : &_free_lv_segment, pvseg, &lvinfo, pv_label(pvseg->pv))) {
9 years, 9 months
master - test: Test failing due to too few PVs
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f33d75e2e586a8...
Commit: f33d75e2e586a88ddeb20d860765f091098b8ab5
Parent: 3063b48602220b0aa5e1ad7a91dc4ca60d717e36
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Thu Jul 10 18:52:55 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Thu Jul 10 18:53:46 2014 -0500
test: Test failing due to too few PVs
Commit 33d69162e4b45e7926d4c0e4a425fedb4246088e reduced the number of
PVs to a level where the test could not function. (It is impossible
to replace 3 PVs of a 4-way RAID1 LV if there are only 5 PVs.)
---
test/shell/lvconvert-raid.sh | 2 +-
test/shell/lvconvert-raid456.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh
index 6f17303..bcf3874 100644
--- a/test/shell/lvconvert-raid.sh
+++ b/test/shell/lvconvert-raid.sh
@@ -24,7 +24,7 @@ get_image_pvs() {
########################################################
aux have_raid 1 3 0 || skip
-aux prepare_pvs 5
+aux prepare_pvs 9
vgcreate -s 256k $vg $(cat DEVICES)
###########################################
diff --git a/test/shell/lvconvert-raid456.sh b/test/shell/lvconvert-raid456.sh
index 1ead128..833b10e 100644
--- a/test/shell/lvconvert-raid456.sh
+++ b/test/shell/lvconvert-raid456.sh
@@ -25,7 +25,7 @@ get_image_pvs() {
aux raid456_replace_works || skip
aux have_raid 1 3 0 || skip
-aux prepare_pvs 6
+aux prepare_pvs 7 # 7 devices for 2 dev replacement of 5-dev RAID6
vgcreate -s 256k $vg $(cat DEVICES)
# RAID 4/5/6 (can replace up to 'parity' devices)
9 years, 9 months
master - report: also report linear and striped for lv_target_type
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3063b48602220b...
Commit: 3063b48602220b0aa5e1ad7a91dc4ca60d717e36
Parent: d169ff1e039ecdfb1efac0a6464ca149d71d8767
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 16:41:42 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 16:41:42 2014 +0200
report: also report linear and striped for lv_target_type
---
lib/report/report.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 6dc792b..d193c47 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1590,6 +1590,10 @@ static int _lvtargettype_disp(struct dm_report *rh, struct dm_pool *mem,
target_type = "snapshot";
else if (lv_is_virtual(lv))
target_type = "virtual";
+ else if (lv_is_linear(lv))
+ target_type = "linear";
+ else if (lv_is_striped(lv))
+ target_type = "striped";
return _string_disp(rh, mem, field, &target_type, private);
}
9 years, 9 months
master - conf: add report/list_item_separator lvm.conf option
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d169ff1e039ecd...
Commit: d169ff1e039ecdfb1efac0a6464ca149d71d8767
Parent: e38af4e28fba0c6854f4bc2dc3842d74a11d199e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 16:18:45 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 16:18:45 2014 +0200
conf: add report/list_item_separator lvm.conf option
For example:
$ lvm dumpconfig report/list_item_separator
list_item_separator=","
$ lvs -o name,tags vg/lvol1
LV LV Tags
lvol1 a,x,y
$ lvm dumpconfig report/list_item_separator
list_item_separator=":"
$ lvs -o name,tags vg/lvol1
LV LV Tags
lvol1 a:x:y
---
conf/command_profile_template.profile.in | 1 +
conf/example.conf.in | 3 +++
lib/commands/toolcontext.c | 1 +
lib/commands/toolcontext.h | 1 +
lib/config/config_settings.h | 1 +
lib/config/defaults.h | 1 +
lib/report/report.c | 13 ++++++++++---
7 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/conf/command_profile_template.profile.in b/conf/command_profile_template.profile.in
index 7401aa5..0c1e6f0 100644
--- a/conf/command_profile_template.profile.in
+++ b/conf/command_profile_template.profile.in
@@ -22,6 +22,7 @@ report {
buffered=1
headings=1
separator=" "
+ list_item_separator=","
prefixes=0
quoted=1
colums_as_rows=0
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 11f50f0..91768fb 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1057,6 +1057,9 @@ activation {
# A separator to use on report after each field.
# separator=" "
+ # A separator to use for list items when reported.
+ # list_item_separator=","
+
# Use a field name prefix for each field reported.
# prefixes=0
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 6ac4a42..fe79a81 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -299,6 +299,7 @@ int process_profilable_config(struct cmd_context *cmd) {
cmd->si_unit_consistency = find_config_tree_bool(cmd, global_si_unit_consistency_CFG, NULL);
cmd->report_binary_values_as_numeric = find_config_tree_bool(cmd, report_binary_values_as_numeric_CFG, NULL);
cmd->default_settings.suffix = find_config_tree_bool(cmd, global_suffix_CFG, NULL);
+ cmd->report_list_item_separator = find_config_tree_str(cmd, report_list_item_separator_CFG, NULL);
return 1;
}
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index d06dd7d..57c51d2 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -119,6 +119,7 @@ struct cmd_context {
/* List of defined tags */
struct dm_list tags;
+ const char *report_list_item_separator;
int hosttags;
const char *lib_dir; /* Cache value global/library_dir */
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 7289a04..455eb4f 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -231,6 +231,7 @@ cfg(report_aligned_CFG, "aligned", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_
cfg(report_buffered_CFG, "buffered", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_REP_BUFFERED, vsn(1, 0, 0), NULL)
cfg(report_headings_CFG, "headings", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_REP_HEADINGS, vsn(1, 0, 0), NULL)
cfg(report_separator_CFG, "separator", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_STRING, DEFAULT_REP_SEPARATOR, vsn(1, 0, 0), NULL)
+cfg(report_list_item_separator_CFG, "list_item_separator", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_STRING, DEFAULT_REP_LIST_ITEM_SEPARATOR, vsn(2, 2, 108), NULL)
cfg(report_prefixes_CFG, "prefixes", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_REP_PREFIXES, vsn(2, 2, 36), NULL)
cfg(report_quoted_CFG, "quoted", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_REP_QUOTED, vsn(2, 2, 39), NULL)
cfg(report_colums_as_rows_CFG, "colums_as_rows", report_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_REP_COLUMNS_AS_ROWS, vsn(1, 0, 0), NULL)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 086f7fd..815d6a3 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -180,6 +180,7 @@
#define DEFAULT_REP_PREFIXES 0
#define DEFAULT_REP_QUOTED 1
#define DEFAULT_REP_SEPARATOR " "
+#define DEFAULT_REP_LIST_ITEM_SEPARATOR ","
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,move_pv,mirror_log,copy_percent,convert_lv"
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
diff --git a/lib/report/report.c b/lib/report/report.c
index 5931021..6dc792b 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -139,6 +139,13 @@ static int _field_set_value(struct dm_report_field *field, const void *data, con
return 1;
}
+static int _field_set_string_list(struct dm_report *rh, struct dm_report_field *field,
+ const struct dm_list *list, void *private)
+{
+ struct cmd_context *cmd = (struct cmd_context *) private;
+ return dm_report_field_string_list(rh, field, list, cmd->report_list_item_separator);
+}
+
/*
* Data-munging functions to prepare each data type for display and sorting
*/
@@ -221,11 +228,11 @@ static int _peranges_disp(struct dm_report *rh __attribute__((unused)), struct d
static int _tags_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
- const void *data, void *private __attribute__((unused)))
+ const void *data, void *private)
{
const struct dm_list *tagsl = (const struct dm_list *) data;
- return dm_report_field_string_list(rh, field, tagsl, NULL);
+ return _field_set_string_list(rh, field, tagsl, private);
}
static int _modules_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -243,7 +250,7 @@ static int _modules_disp(struct dm_report *rh, struct dm_pool *mem,
if (!(list_lv_modules(mem, lv, modules)))
return_0;
- return dm_report_field_string_list(rh, field, modules, NULL);
+ return _field_set_string_list(rh, field, modules, private);
}
static int _lvprofile_disp(struct dm_report *rh, struct dm_pool *mem,
9 years, 9 months
master - libdm: report: fix string list internal representation if delimiter is composed of more than one char
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e38af4e28fba0c...
Commit: e38af4e28fba0c6854f4bc2dc3842d74a11d199e
Parent: 1e5ec893c7d9cf243a6ecb17ed6320d37e9a147c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 16:09:58 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 16:18:05 2014 +0200
libdm: report: fix string list internal representation if delimiter is composed of more than one char
---
WHATS_NEW_DM | 1 +
libdm/libdm-report.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 852d313..ab94bc4 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.87 -
================================
+ Fix dm_report_field_string_list to handle delimiter with multiple chars.
Add dm_report_field_reserved_value for per-field reserved value definition.
Version 1.02.86 - 23rd June 2014
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 9b4ea87..b94cc00 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -420,7 +420,7 @@ int dm_report_field_string_list(struct dm_report *rh,
*/
sort_value->items[i].pos = pos;
sort_value->items[i].len = len;
- pos = i == list_size ? pos+len : pos+len+1;
+ pos = i == list_size ? pos+len : pos+len+delimiter_len;
}
if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
9 years, 9 months
master - tests: LV's zero field now reported as binary field
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1e5ec893c7d9cf...
Commit: 1e5ec893c7d9cf243a6ecb17ed6320d37e9a147c
Parent: e2448bb0dcfa63b2a8fae24b989393a821917120
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 15:30:28 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 15:30:28 2014 +0200
tests: LV's zero field now reported as binary field
---
test/shell/profiles-thin.sh | 6 +++---
test/shell/thin-defaults.sh | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/shell/profiles-thin.sh b/test/shell/profiles-thin.sh
index 704ef2d..3519985 100644
--- a/test/shell/profiles-thin.sh
+++ b/test/shell/profiles-thin.sh
@@ -34,7 +34,7 @@ vgcreate $vg "$dev1"
lvcreate -L8m -T $vg/pool_generic
check lv_field $vg/pool_generic profile ""
check lv_field $vg/pool_generic chunk_size 64.00k
-check lv_field $vg/pool_generic zero 1
+check lv_field $vg/pool_generic zero "zero"
# If "thin-performance" profile is used, the "performance"
# policy is used to calculate chunk size which is 512KiB
@@ -44,7 +44,7 @@ check lv_field $vg/pool_generic zero 1
lvcreate --profile thin-performance -L8m -T $vg/pool_performance
check lv_field $vg/pool_performance profile "thin-performance"
check lv_field $vg/pool_performance chunk_size 1.00m
-check lv_field $vg/pool_performance zero 0
+check lv_field $vg/pool_performance zero ""
vgremove -ff $vg
@@ -56,4 +56,4 @@ lvcreate -L8m -T $vg/pool_performance_inherited
check vg_field $vg profile "thin-performance"
check lv_field $vg/pool_performance_inherited profile ""
check lv_field $vg/pool_performance_inherited chunk_size 1.00m
-check lv_field $vg/pool_performance_inherited zero 0
+check lv_field $vg/pool_performance_inherited zero ""
diff --git a/test/shell/thin-defaults.sh b/test/shell/thin-defaults.sh
index 4f873cc..3a681a1 100644
--- a/test/shell/thin-defaults.sh
+++ b/test/shell/thin-defaults.sh
@@ -30,6 +30,6 @@ lvcreate -T -L8M $vg/pool1
check lv_field $vg/pool1 chunksize "128.00k"
check lv_field $vg/pool1 discards "ignore"
-check lv_field $vg/pool1 zero 0
+check lv_field $vg/pool1 zero ""
vgremove -f $vg
9 years, 9 months
master - report: report LV's zero field as binary field
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e2448bb0dcfa63...
Commit: e2448bb0dcfa63b2a8fae24b989393a821917120
Parent: e31ec38d8e657d5f6d6efca6eade083357675276
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 15:23:56 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 15:25:01 2014 +0200
report: report LV's zero field as binary field
Like other binary fields we already have:
$ lvs -o name,zero vg/lvx vg/pool vg/pool1
LV Zero
lvx unknown
pool
pool1 zero
$ lvs -o name,zero vg/lvx vg/pool vg/pool1 --binary
LV Zero
lvx -1
pool 0
pool1 1
---
lib/report/columns.h | 2 +-
lib/report/report.c | 4 ++--
lib/report/values.h | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 3d3d76e..dd5aa9e 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -158,7 +158,7 @@ FIELD(SEGS, seg, SIZ, "Chunk", list, 5, chunksize, chunksize, "For snapshots, th
FIELD(SEGS, seg, SIZ, "Chunk", list, 5, chunksize, chunk_size, "For snapshots, the unit of data used when tracking changes.", 0)
FIELD(SEGS, seg, NUM, "#Thins", list, 4, thincount, thin_count, "For thin pools, the number of thin volumes in this pool.", 0)
FIELD(SEGS, seg, STR, "Discards", list, 8, discards, discards, "For thin pools, how discards are handled.", 0)
-FIELD(SEGS, seg, NUM, "Zero", list, 4, thinzero, zero, "For thin pools, if zeroing is enabled.", 0)
+FIELD(SEGS, seg, BIN, "Zero", list, 4, thinzero, zero, "For thin pools, if zeroing is enabled.", 0)
FIELD(SEGS, seg, NUM, "TransId", list, 4, transactionid, transaction_id, "For thin pools, the transaction id.", 0)
FIELD(SEGS, seg, NUM, "ThId", list, 4, thinid, thin_id, "For thin volume, the thin device id.", 0)
FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, seg_start, "Offset within the LV to the start of the segment in current units.", 0)
diff --git a/lib/report/report.c b/lib/report/report.c
index 63b1647..5931021 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1594,9 +1594,9 @@ static int _thinzero_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_segment *seg = (const struct lv_segment *) data;
if (seg_is_thin_pool(seg))
- return _uint32_disp(rh, mem, field, &seg->zero_new_blocks, private);
+ return _binary_disp(rh, mem, field, seg->zero_new_blocks, FIRST_NAME(zero_y), private);
- return _field_set_value(field, "", &RESERVED(number_undef_64));
+ return _binary_undef_disp(rh, mem, field, private);
}
static int _lvhealthstatus_disp(struct dm_report *rh, struct dm_pool *mem,
diff --git a/lib/report/values.h b/lib/report/values.h
index d8de665..7425bc6 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -75,6 +75,7 @@ FIELD_RESERVED_BINARY_VALUE(lv_live_table, lv_live_table, "", "live table presen
FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "", "inactive table present", "inactive table", "inactive")
FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "", "open")
FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "", "skip activation", "skip")
+FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", FIRST_NAME(lv_permissions_r), "", "read-only", "r", "ro")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", FIRST_NAME(lv_permissions_r_override), "", "read-only-override", "ro-override", "r-override", "R")
9 years, 9 months