master - conf: add report/mark_invisible_devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e168b5de75204a...
Commit: e168b5de75204a554fcb6f9a3bd25dada2561c86
Parent: 7f74a995029caa41ee3cf9aec0bd024a34bfd89a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jan 13 11:30:07 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 12:01:10 2016 +0100
conf: add report/mark_invisible_devices
---
lib/commands/toolcontext.c | 1 +
lib/commands/toolcontext.h | 1 +
lib/config/config_settings.h | 3 +++
lib/metadata/lv.c | 15 ++++++++-------
lib/report/report.c | 3 ++-
5 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index a2f21b8..a8bf187 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -478,6 +478,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->report_mark_invisible_devices = find_config_tree_bool(cmd, report_mark_invisible_devices_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);
if (!(cmd->time_format = _set_time_format(cmd)))
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index cd55348..5a7b3af 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -121,6 +121,7 @@ struct cmd_context {
unsigned auto_set_activation_skip:1;
unsigned si_unit_consistency:1;
unsigned report_binary_values_as_numeric:1;
+ unsigned report_mark_invisible_devices:1;
unsigned metadata_read_only:1;
unsigned ignore_clustered_vgs:1;
unsigned threaded:1; /* set if running within a thread e.g. clvmd */
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 52954d5..bb5d7d9 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1671,6 +1671,9 @@ cfg(report_pvsegs_cols_verbose_CFG, "pvsegs_cols_verbose", report_CFG_SECTION, C
"List of columns to sort by when reporting 'pvs --segments' command in verbose mode.\n"
"See 'pvs --segments -o help' for the list of possible fields.\n")
+cfg(report_mark_invisible_devices_CFG, "mark_invisible_devices", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 2, 140), NULL, 0, NULL,
+ "Use brackets [] to mark invisible devices.\n")
+
cfg(dmeventd_mirror_library_CFG, "mirror_library", dmeventd_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DMEVENTD_MIRROR_LIB, vsn(1, 2, 3), NULL, 0, NULL,
"The library dmeventd uses when monitoring a mirror device.\n"
"libdevmapper-event-lvm2mirror.so attempts to recover from\n"
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index d591f24..44db4df 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -29,7 +29,8 @@ static struct utsname _utsname;
static int _utsinit = 0;
static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
- int range_format, int metadata_areas_only)
+ int range_format, int metadata_areas_only,
+ int mark_invisible)
{
static const char pool_grow_object_failed_msg[] = "dm_pool_grow_object failed";
unsigned int s;
@@ -71,7 +72,7 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
- if (!visible && !dm_pool_grow_object(mem, "[", 1)) {
+ if (!visible && mark_invisible && !dm_pool_grow_object(mem, "[", 1)) {
log_error(pool_grow_object_failed_msg);
return NULL;
}
@@ -81,7 +82,7 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
- if (!visible && !dm_pool_grow_object(mem, "]", 1)) {
+ if (!visible && mark_invisible && !dm_pool_grow_object(mem, "]", 1)) {
log_error(pool_grow_object_failed_msg);
return NULL;
}
@@ -128,22 +129,22 @@ out:
char *lvseg_devices(struct dm_pool *mem, const struct lv_segment *seg)
{
- return _format_pvsegs(mem, seg, 0, 0);
+ return _format_pvsegs(mem, seg, 0, 0, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_metadata_devices(struct dm_pool *mem, const struct lv_segment *seg)
{
- return _format_pvsegs(mem, seg, 0, 1);
+ return _format_pvsegs(mem, seg, 0, 1, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_seg_pe_ranges(struct dm_pool *mem, const struct lv_segment *seg)
{
- return _format_pvsegs(mem, seg, 1, 0);
+ return _format_pvsegs(mem, seg, 1, 0, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_seg_metadata_le_ranges(struct dm_pool *mem, const struct lv_segment *seg)
{
- return _format_pvsegs(mem, seg, 1, 1);
+ return _format_pvsegs(mem, seg, 1, 1, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_tags_dup(const struct lv_segment *seg)
diff --git a/lib/report/report.c b/lib/report/report.c
index 4b2c0c0..3c73a2f 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1581,11 +1581,12 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
+ struct cmd_context *cmd = (struct cmd_context *) private;
const struct logical_volume *lv = (const struct logical_volume *) data;
char *repstr, *lvname;
size_t len;
- if (lv_is_visible(lv))
+ if (lv_is_visible(lv) || !cmd->report_mark_invisible_devices)
return _string_disp(rh, mem, field, &lv->name, private);
len = strlen(lv->name) + 3;
8 years, 3 months
master - lv: use brackets for invisible devices when formatting device segments
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7f74a995029caa...
Commit: 7f74a995029caa41ee3cf9aec0bd024a34bfd89a
Parent: f1fe7af014003b6a4b1000eaf3f78a61885f8182
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 14:49:56 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:20:04 2016 +0100
lv: use brackets for invisible devices when formatting device segments
Include brackets for the name if the dev is invisible.
This change applies to all callers of _format_pvsegs fn:
- lvseg_devices (the "lvs -o devices")
- lvseg_metadata_devices (the "lvs -o metadata_devices)
- lvseg_seg_pe_ranges (the "lvs -o seg_pe_ranges")
- lvseg_seg_metadata_le_ranges (the "lvs -o seg_metadata_le_ranges")
---
lib/metadata/lv.c | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 368ba19..d591f24 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -31,10 +31,13 @@ static int _utsinit = 0;
static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
int range_format, int metadata_areas_only)
{
+ static const char pool_grow_object_failed_msg[] = "dm_pool_grow_object failed";
unsigned int s;
const char *name = NULL;
uint32_t extent = 0;
char extent_str[32];
+ struct logical_volume *lv;
+ int visible = 1;
if (!dm_pool_begin_object(mem, 256)) {
log_error("dm_pool_begin_object failed");
@@ -47,7 +50,9 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
for (s = 0; s < seg->area_count; s++) {
switch (metadata_areas_only ? seg_metatype(seg, s) : seg_type(seg, s)) {
case AREA_LV:
- name = metadata_areas_only ? seg_metalv(seg, s)->name : seg_lv(seg, s)->name;
+ lv = metadata_areas_only ? seg_metalv(seg, s) : seg_lv(seg, s);
+ visible = lv_is_visible(lv);
+ name = lv->name;
extent = metadata_areas_only ? seg_le(seg, s) : 0;
break;
case AREA_PV:
@@ -66,8 +71,18 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
+ if (!visible && !dm_pool_grow_object(mem, "[", 1)) {
+ log_error(pool_grow_object_failed_msg);
+ return NULL;
+ }
+
if (!dm_pool_grow_object(mem, name, strlen(name))) {
- log_error("dm_pool_grow_object failed");
+ log_error(pool_grow_object_failed_msg);
+ return NULL;
+ }
+
+ if (!visible && !dm_pool_grow_object(mem, "]", 1)) {
+ log_error(pool_grow_object_failed_msg);
return NULL;
}
@@ -79,7 +94,7 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
if (!dm_pool_grow_object(mem, extent_str, strlen(extent_str))) {
- log_error("dm_pool_grow_object failed");
+ log_error(pool_grow_object_failed_msg);
return NULL;
}
@@ -90,14 +105,14 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
if (!dm_pool_grow_object(mem, extent_str, strlen(extent_str))) {
- log_error("dm_pool_grow_object failed");
+ log_error(pool_grow_object_failed_msg);
return NULL;
}
}
if ((s != seg->area_count - 1) &&
!dm_pool_grow_object(mem, range_format ? " " : ",", 1)) {
- log_error("dm_pool_grow_object failed");
+ log_error(pool_grow_object_failed_msg);
return NULL;
}
}
8 years, 3 months
master - lv: add common lv_pool_lv fn for use in report and dup, use brackets for invisible devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1fe7af014003b...
Commit: f1fe7af014003b6a4b1000eaf3f78a61885f8182
Parent: 42fcbc1fd4acd4dc239ef8f24b02fd45f9783567
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 11:53:39 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:20:01 2016 +0100
lv: add common lv_pool_lv fn for use in report and dup, use brackets for invisible devices
The common lv_pool_lv fn avoids code duplication and also
the reporting part now uses _lvname_disp and _uuid_disp to display
name and uuid respectively, including brackets for the name if the
dev is invisible.
---
lib/metadata/lv.c | 27 ++++++++++++++++-----------
lib/metadata/lv.h | 1 +
lib/report/report.c | 16 +++++++---------
3 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index f308395..368ba19 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -370,22 +370,27 @@ char *lv_mirror_log_uuid_dup(struct dm_pool *mem, const struct logical_volume *l
return _do_lv_mirror_log_dup(mem, lv, 1);
}
+struct logical_volume *lv_pool_lv(const struct logical_volume *lv)
+{
+ struct lv_segment *seg = (lv_is_thin_volume(lv) || lv_is_cache(lv)) ?
+ first_seg(lv) : NULL;
+ struct logical_volume *pool_lv = seg ? seg->pool_lv : NULL;
+
+ return pool_lv;
+}
+
static char *_do_lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
int uuid)
{
- struct lv_segment *seg;
+ struct logical_volume *pool_lv = lv_pool_lv(lv);
- dm_list_iterate_items(seg, &lv->segments) {
- if (seg->pool_lv &&
- (seg_is_thin_volume(seg) || seg_is_cache(seg))) {
- if (uuid)
- return lv_uuid_dup(mem, seg->pool_lv);
- else
- return lv_name_dup(mem, seg->pool_lv);
- }
- }
+ if (!pool_lv)
+ return NULL;
- return NULL;
+ if (uuid)
+ return lv_uuid_dup(mem, pool_lv);
+ else
+ return lv_name_dup(mem, pool_lv);
}
char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index d1c95ed..2834ae5 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -95,6 +95,7 @@ struct logical_volume *lv_origin(const struct logical_volume *lv);
struct logical_volume *lv_mirror_log(const struct logical_volume *lv);
struct logical_volume *lv_data(const struct logical_volume *lv);
struct logical_volume *lv_metadata_lv(const struct logical_volume *lv);
+struct logical_volume *lv_pool_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index a170bfa..4b2c0c0 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1732,17 +1732,15 @@ static int _do_poollv_disp(struct dm_report *rh, struct dm_pool *mem,
int uuid)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- struct lv_segment *seg = (lv_is_thin_volume(lv) || lv_is_cache(lv)) ?
- first_seg(lv) : NULL;
+ struct logical_volume *pool_lv = lv_pool_lv(lv);
- if (seg) {
- if (uuid)
- return _uuid_disp(rh, mem, field, &seg->pool_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, seg->pool_lv, private);
- }
+ if (!pool_lv)
+ return _field_set_value(field, "", NULL);
- return _field_set_value(field, "", NULL);
+ if (uuid)
+ return _uuid_disp(rh, mem, field, &pool_lv->lvid.id[1], private);
+ else
+ return _lvname_disp(rh, mem, field, pool_lv, private);
}
static int _poollv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
8 years, 3 months
master - lv: add common lv_metadata_lv fn for use in report and dup, use brackets for invisible devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42fcbc1fd4acd4...
Commit: 42fcbc1fd4acd4dc239ef8f24b02fd45f9783567
Parent: cdbf76b2f0c12d6ab12c3d4b2253e60f9f5420d3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 11:23:56 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:19:58 2016 +0100
lv: add common lv_metadata_lv fn for use in report and dup, use brackets for invisible devices
The common lv_metadata_lv fn avoids code duplication and also
the reporting part now uses _lvname_disp and _uuid_disp to display
name and uuid respectively, including brackets for the name if the
dev is invisible.
---
lib/metadata/lv.c | 24 +++++++++++++++---------
lib/metadata/lv.h | 5 +++++
lib/report/report.c | 15 +++++++--------
3 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index e8b5ada..f308395 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -431,21 +431,27 @@ char *lv_data_lv_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv)
return _do_lv_data_lv_dup(mem, lv, 1);
}
+struct logical_volume *lv_metadata_lv(const struct logical_volume *lv)
+{
+ struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
+ first_seg(lv) : NULL;
+ struct logical_volume *metadata_lv = seg ? seg->metadata_lv : NULL;
+
+ return metadata_lv;
+}
static char *_do_lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
int uuid)
{
- struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
- first_seg(lv) : NULL;
+ struct logical_volume *metadata_lv = lv_metadata_lv(lv);
- if (seg) {
- if (uuid)
- return lv_uuid_dup(mem, seg->metadata_lv);
- else
- return lv_name_dup(mem, seg->metadata_lv);
- }
+ if (!metadata_lv)
+ return NULL;
- return NULL;
+ if (uuid)
+ return lv_uuid_dup(mem, metadata_lv);
+ else
+ return lv_name_dup(mem, metadata_lv);
}
char *lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 44f7fda..d1c95ed 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -90,6 +90,11 @@ struct logical_volume *lv_convert_lv(const struct logical_volume *lv);
struct logical_volume *lv_origin_lv(const struct logical_volume *lv);
struct logical_volume *lv_mirror_log_lv(const struct logical_volume *lv);
struct logical_volume *lv_data_lv(const struct logical_volume *lv);
+struct logical_volume *lv_convert(const struct logical_volume *lv);
+struct logical_volume *lv_origin(const struct logical_volume *lv);
+struct logical_volume *lv_mirror_log(const struct logical_volume *lv);
+struct logical_volume *lv_data(const struct logical_volume *lv);
+struct logical_volume *lv_metadata_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index 467cf85..a170bfa 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1701,16 +1701,15 @@ static int _do_metadatalv_disp(struct dm_report *rh, struct dm_pool *mem __attri
int uuid)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- const struct lv_segment *seg = (lv_is_pool(lv)) ? first_seg(lv) : NULL;
+ struct logical_volume *metadata_lv = lv_metadata_lv(lv);
- if (seg) {
- if (uuid)
- return _uuid_disp(rh, mem, field, &seg->metadata_lv->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, seg->metadata_lv, private);
- }
+ if (!metadata_lv)
+ return _field_set_value(field, "", NULL);
- return _field_set_value(field, "", NULL);
+ if (uuid)
+ return _uuid_disp(rh, mem, field, &metadata_lv->lvid.id[1], private);
+ else
+ return _lvname_disp(rh, mem, field, metadata_lv, private);
}
static int _metadatalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
8 years, 3 months
master - lv: add common lv_data_lv fn for use in report and dup, use brackets for invisible devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cdbf76b2f0c12d...
Commit: cdbf76b2f0c12d6ab12c3d4b2253e60f9f5420d3
Parent: d50cd9d8d766671e89f24f7fd0e23dc96f883ea3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 11:15:22 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:19:55 2016 +0100
lv: add common lv_data_lv fn for use in report and dup, use brackets for invisible devices
The common lv_data_lv fn avoids code duplication and also
the reporting part now uses _lvname_disp and _uuid_disp to display
name and uuid respectively, including brackets for the name if the
dev is invisible.
---
lib/metadata/lv.c | 25 ++++++++++++++++---------
lib/metadata/lv.h | 1 +
lib/report/report.c | 15 +++++++--------
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index ab8a7c4..e8b5ada 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -398,20 +398,27 @@ char *lv_pool_lv_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv)
return _do_lv_pool_lv_dup(mem, lv, 1);
}
+struct logical_volume *lv_data_lv(const struct logical_volume *lv)
+{
+ struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
+ first_seg(lv) : NULL;
+ struct logical_volume *data_lv = seg ? seg_lv(seg, 0) : NULL;
+
+ return data_lv;
+}
+
static char *_do_lv_data_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
int uuid)
{
- struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
- first_seg(lv) : NULL;
+ struct logical_volume *data_lv = lv_data_lv(lv);
- if (seg) {
- if (uuid)
- return lv_uuid_dup(mem, seg_lv(seg, 0));
- else
- return lv_name_dup(mem, seg_lv(seg, 0));
- }
+ if (!data_lv)
+ return NULL;
- return NULL;
+ if (uuid)
+ return lv_uuid_dup(mem, data_lv);
+ else
+ return lv_name_dup(mem, data_lv);
}
char *lv_data_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index b37cc4e..44f7fda 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -89,6 +89,7 @@ struct logical_volume *lv_parent(const struct logical_volume *lv);
struct logical_volume *lv_convert_lv(const struct logical_volume *lv);
struct logical_volume *lv_origin_lv(const struct logical_volume *lv);
struct logical_volume *lv_mirror_log_lv(const struct logical_volume *lv);
+struct logical_volume *lv_data_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index 80896b3..467cf85 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1670,16 +1670,15 @@ static int _do_datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute
int uuid)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- const struct lv_segment *seg = (lv_is_pool(lv)) ? first_seg(lv) : NULL;
+ struct logical_volume *data_lv = lv_data_lv(lv);
- if (seg) {
- if (uuid)
- return _uuid_disp(rh, mem, field, &seg_lv(seg, 0)->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, seg_lv(seg, 0), private);
- }
+ if (!data_lv)
+ return _field_set_value(field, "", NULL);
- return _field_set_value(field, "", NULL);
+ if (uuid)
+ return _uuid_disp(rh, mem, field, &data_lv->lvid.id[1], private);
+ else
+ return _lvname_disp(rh, mem, field, data_lv, private);
}
static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
8 years, 3 months
master - lv: add common lv_mirror_log_lv for use in report and dup, use brackets for invisible devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d50cd9d8d76667...
Commit: d50cd9d8d766671e89f24f7fd0e23dc96f883ea3
Parent: aae45a1f21b94c2f025fdb55e9b8546b5973a107
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 11:05:16 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:19:51 2016 +0100
lv: add common lv_mirror_log_lv for use in report and dup, use brackets for invisible devices
The common lv_mirror_log_lv fn avoids code duplication and also
the reporting part now uses _lvname_disp and _uuid_disp to display
name and uuid respectively, including brackets for the name if the
dev is invisible.
---
lib/metadata/lv.c | 25 +++++++++++++------
lib/metadata/lv.h | 1 +
lib/report/report.c | 64 ++++++++++++++++++++++++--------------------------
3 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index a190ae0..ab8a7c4 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -334,23 +334,32 @@ char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv)
return tags_format_and_copy(mem, modules);
}
-static char *_do_lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv,
- int uuid)
+struct logical_volume *lv_mirror_log_lv(const struct logical_volume *lv)
{
struct lv_segment *seg;
dm_list_iterate_items(seg, &lv->segments) {
- if (seg_is_mirrored(seg) && seg->log_lv) {
- if (uuid)
- return lv_uuid_dup(mem, seg->log_lv);
- else
- return lv_name_dup(mem, seg->log_lv);
- }
+ if (seg_is_mirrored(seg) && seg->log_lv)
+ return seg->log_lv;
}
return NULL;
}
+static char *_do_lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv,
+ int uuid)
+{
+ struct logical_volume *mirror_log_lv = lv_mirror_log_lv(lv);
+
+ if (!mirror_log_lv)
+ return NULL;
+
+ if (uuid)
+ return lv_uuid_dup(mem, mirror_log_lv);
+ else
+ return lv_name_dup(mem, mirror_log_lv);
+}
+
char *lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
return _do_lv_mirror_log_dup(mem, lv, 0);
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index e346059..b37cc4e 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -88,6 +88,7 @@ char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
struct logical_volume *lv_parent(const struct logical_volume *lv);
struct logical_volume *lv_convert_lv(const struct logical_volume *lv);
struct logical_volume *lv_origin_lv(const struct logical_volume *lv);
+struct logical_volume *lv_mirror_log_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index 9ffaf73..80896b3 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1577,39 +1577,6 @@ static int _segtype_disp(struct dm_report *rh __attribute__((unused)),
return _field_set_value(field, name, NULL);
}
-static int _do_loglv_disp(struct dm_report *rh, struct dm_pool *mem,
- struct dm_report_field *field,
- const void *data, void *private,
- int uuid)
-{
- const struct logical_volume *lv = (const struct logical_volume *) data;
- const char *repstr = NULL;
-
- if (uuid)
- repstr = lv_mirror_log_uuid_dup(mem, lv);
- else
- repstr = lv_mirror_log_dup(mem, lv);
-
- if (repstr)
- return _string_disp(rh, mem, field, &repstr, private);
-
- return _field_set_value(field, "", NULL);
-}
-
-static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
- struct dm_report_field *field,
- const void *data, void *private __attribute__((unused)))
-{
- return _do_loglv_disp(rh, mem, field, data, private, 0);
-}
-
-static int _loglvuuid_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
- struct dm_report_field *field,
- const void *data, void *private __attribute__((unused)))
-{
- return _do_loglv_disp(rh, mem, field, data, private, 1);
-}
-
static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
@@ -1640,6 +1607,37 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, lvname);
}
+static int _do_loglv_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private,
+ int uuid)
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ struct logical_volume *mirror_log_lv = lv_mirror_log_lv(lv);
+
+ if (!mirror_log_lv)
+ return _field_set_value(field, "", NULL);
+
+ if (uuid)
+ return _uuid_disp(rh, mem, field, &mirror_log_lv->lvid.id[1], private);
+ else
+ return _lvname_disp(rh, mem, field, mirror_log_lv, private);
+}
+
+static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
+ struct dm_report_field *field,
+ const void *data, void *private __attribute__((unused)))
+{
+ return _do_loglv_disp(rh, mem, field, data, private, 0);
+}
+
+static int _loglvuuid_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
+ struct dm_report_field *field,
+ const void *data, void *private __attribute__((unused)))
+{
+ return _do_loglv_disp(rh, mem, field, data, private, 1);
+}
+
static int _lvfullname_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))
8 years, 3 months
master - lv: add common lv_origin_lv fn for use in report and dup, use brackets for invisible devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aae45a1f21b94c...
Commit: aae45a1f21b94c2f025fdb55e9b8546b5973a107
Parent: 1bd83814ce53f07cf93f6f55629f9a81da5aaca3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 10:52:34 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:19:45 2016 +0100
lv: add common lv_origin_lv fn for use in report and dup, use brackets for invisible devices
The common lv_origin_lv fn avoids code duplication and also
the reporting part now uses _lvname_disp and _uuid_disp to display
name and uuid respectively, including brackets for the name if the
dev is invisible.
---
lib/metadata/lv.c | 21 ++++++++++++++-------
lib/metadata/lv.h | 1 +
lib/report/report.c | 19 +++++--------------
3 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index e1cf5cd..a190ae0 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -236,11 +236,9 @@ uint32_t lv_kernel_read_ahead(const struct logical_volume *lv)
return info.read_ahead;
}
-static char *_do_lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv,
- int uuid)
+struct logical_volume *lv_origin_lv(const struct logical_volume *lv)
{
- struct logical_volume *origin;
-
+ struct logical_volume *origin = NULL;
if (lv_is_cow(lv))
origin = origin_from_cow(lv);
@@ -250,13 +248,22 @@ static char *_do_lv_origin_dup(struct dm_pool *mem, const struct logical_volume
origin = first_seg(lv)->origin;
else if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv)
origin = first_seg(lv)->external_lv;
- else
+
+ return origin;
+}
+
+static char *_do_lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv,
+ int uuid)
+{
+ struct logical_volume *origin_lv = lv_origin_lv(lv);
+
+ if (!lv)
return NULL;
if (uuid)
- return lv_uuid_dup(mem, origin);
+ return lv_uuid_dup(mem, origin_lv);
else
- return lv_name_dup(mem, origin);
+ return lv_name_dup(mem, origin_lv);
}
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index afecd0a..e346059 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -87,6 +87,7 @@ char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
struct logical_volume *lv_parent(const struct logical_volume *lv);
struct logical_volume *lv_convert_lv(const struct logical_volume *lv);
+struct logical_volume *lv_origin_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index dad163b..9ffaf73 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1795,24 +1795,15 @@ static int _do_origin_disp(struct dm_report *rh, struct dm_pool *mem,
int uuid)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- const struct lv_segment *seg = first_seg(lv);
- struct logical_volume *origin;
+ struct logical_volume *origin_lv = lv_origin_lv(lv);
- if (lv_is_cow(lv))
- origin = origin_from_cow(lv);
- else if (lv_is_cache(lv) && !lv_is_pending_delete(lv))
- origin = seg_lv(seg, 0);
- else if (lv_is_thin_volume(lv) && first_seg(lv)->origin)
- origin = first_seg(lv)->origin;
- else if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv)
- origin = first_seg(lv)->external_lv;
- else
+ if (!origin_lv)
return _field_set_value(field, "", NULL);
if (uuid)
- return _uuid_disp(rh, mem, field, &origin->lvid.id[1], private);
+ return _uuid_disp(rh, mem, field, &origin_lv->lvid.id[1], private);
else
- return _lvname_disp(rh, mem, field, origin, private);
+ return _lvname_disp(rh, mem, field, origin_lv, private);
}
static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
8 years, 3 months
master - lv: add common lv_convert_lv fn for use in report and dup, use brackets for invisible devices
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1bd83814ce53f0...
Commit: 1bd83814ce53f07cf93f6f55629f9a81da5aaca3
Parent: 9e336582f4c9ba185ff7c9ba1031066fbeed863e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 12 10:44:59 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 13 11:16:37 2016 +0100
lv: add common lv_convert_lv fn for use in report and dup, use brackets for invisible devices
The common lv_convert_lv fn avoids code duplication and also
the reporting part now uses _lvname_disp and _uuid_disp to display
name and uuid respectively, including brackets for the name if the
dev is invisible.
---
lib/metadata/lv.c | 27 +++++++++++++++++++--------
lib/metadata/lv.h | 1 +
lib/report/report.c | 18 ++++++++----------
3 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 0310e70..e1cf5cd 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -462,8 +462,7 @@ int lv_kernel_major(const struct logical_volume *lv)
return -1;
}
-static char *_do_lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
- int uuid)
+struct logical_volume *lv_convert_lv(const struct logical_volume *lv)
{
struct lv_segment *seg;
@@ -472,13 +471,25 @@ static char *_do_lv_convert_lv_dup(struct dm_pool *mem, const struct logical_vol
/* Temporary mirror is always area_num == 0 */
if (seg_type(seg, 0) == AREA_LV &&
- is_temporary_mirror_layer(seg_lv(seg, 0))) {
- if (uuid)
- return lv_uuid_dup(mem, seg_lv(seg, 0));
- else
- return lv_name_dup(mem, seg_lv(seg, 0));
- }
+ is_temporary_mirror_layer(seg_lv(seg, 0)))
+ return seg_lv(seg, 0);
}
+
+ return NULL;
+}
+
+static char *_do_lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
+ int uuid)
+{
+ struct logical_volume *convert_lv = lv_convert_lv(lv);
+
+ if (convert_lv) {
+ if (uuid)
+ return lv_uuid_dup(mem, convert_lv);
+ else
+ return lv_name_dup(mem, convert_lv);
+ }
+
return NULL;
}
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 2f1e4f9..afecd0a 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -86,6 +86,7 @@ char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
struct logical_volume *lv_parent(const struct logical_volume *lv);
+struct logical_volume *lv_convert_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index 9f44212..dad163b 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1271,9 +1271,9 @@ static int _chars_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((
return dm_report_field_string(rh, field, (const char * const *) &data);
}
-static int _uuid_disp(struct dm_report *rh __attribute__((unused)), struct dm_pool *mem,
+static int _uuid_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)
{
char *repstr;
@@ -1968,17 +1968,15 @@ static int _do_convertlv_disp(struct dm_report *rh, struct dm_pool *mem,
int uuid)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- const char *repstr;
+ const struct logical_volume *convert_lv = lv_convert_lv(lv);
+
+ if (!convert_lv)
+ return _field_set_value(field, "", NULL);
if (uuid)
- repstr = lv_convert_lv_uuid_dup(mem, lv);
+ return _uuid_disp(rh, mem, field, &convert_lv->lvid.id[1], private);
else
- repstr = lv_convert_lv_dup(mem, lv);
-
- if (repstr)
- return _string_disp(rh, mem, field, &repstr, private);
-
- return _field_set_value(field, "", NULL);
+ return _lvname_disp(rh, mem, field, convert_lv, private);
}
static int _convertlv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
8 years, 3 months
master - man lvmlockd: mention pvmove restriction
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9e336582f4c9ba...
Commit: 9e336582f4c9ba185ff7c9ba1031066fbeed863e
Parent: 0c6946b4ce2fc664a66cd68a4fb2324bfb69b5ab
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 12 12:01:53 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 12 12:01:53 2016 -0600
man lvmlockd: mention pvmove restriction
---
man/lvmlockd.8.in | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/man/lvmlockd.8.in b/man/lvmlockd.8.in
index 4e7abdf..f01c695 100644
--- a/man/lvmlockd.8.in
+++ b/man/lvmlockd.8.in
@@ -566,7 +566,8 @@ where the GL lock must be manually enabled after a vgremove.
A sanlock VG contains a hidden LV called "lvmlock" that holds the sanlock
locks. vgreduce cannot yet remove the PV holding the lvmlock LV. To
remove this PV, change the VG lock type to "none", run vgreduce, then
-change the VG lock type back to "sanlock".
+change the VG lock type back to "sanlock". Similarly, pvmove cannot be
+used on a PV used by the lvmlock LV.
To place the lvmlock LV on a specific device, create the VG with only that
device, then use vgextend to add other devices.
@@ -852,8 +853,8 @@ stopped the VG lockspace. Stop the VG on all hosts using vgchange
\-\-lock-stop.
.IP \[bu] 2
-vgreduce of a PV in a sanlock VG may fail if it holds the internal
-"lvmlock" LV that holds the sanlock locks.
+vgreduce or pvmove of a PV in a sanlock VG will fail if it holds the
+internal "lvmlock" LV that holds the sanlock locks.
.IP \[bu] 2
lvmlockd uses lock retries instead of lock queueing, so high lock
8 years, 3 months
master - pvmove: disallow moving PVs under sanlock leases
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0c6946b4ce2fc6...
Commit: 0c6946b4ce2fc664a66cd68a4fb2324bfb69b5ab
Parent: 176b4aaebeb8b885d5df16172a5bc32481beda59
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 12 11:51:12 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 12 11:53:33 2016 -0600
pvmove: disallow moving PVs under sanlock leases
Fail with an error message if pvmove tries to move PVs
under the lvmlock LV.
---
tools/pvmove.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index a7943fa..d3eb1ab 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -643,6 +643,28 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
goto out_ret;
}
+ /*
+ * We cannot move blocks from under the sanlock leases, so disallow
+ * pvmoving any PVs used by the lvmlock LV.
+ */
+ if (vg->lock_type && !strcmp(vg->lock_type, "sanlock")) {
+ struct lv_segment *lvseg;
+ struct physical_volume *sanlock_pv;
+ unsigned s;
+
+ dm_list_iterate_items(lvseg, &vg->sanlock_lv->segments) {
+ for (s = 0; s < lvseg->area_count; s++) {
+ if (seg_type(lvseg, s) == AREA_PV) {
+ sanlock_pv = seg_pv(lvseg, s);
+ if (sanlock_pv->dev == pv->dev) {
+ log_error("Cannot pvmove device %s used for sanlock leases.", pv_dev_name(pv));
+ goto out;
+ }
+ }
+ }
+ }
+ }
+
exclusive = _pvmove_is_exclusive(cmd, vg);
if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
@@ -894,6 +916,12 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
+ /*
+ * FIXME: use process_each_pv() where the "single" function
+ * depends on the abort arg. The single functions would not
+ * need to use find_pv_by_name() (which includes a hidden
+ * equivalent of process_each_pv), or vg_read().
+ */
if (!arg_count(cmd, abort_ARG)) {
if ((ret = _set_up_pvmove(cmd, pv_name, argc, argv, lvid, &vg_name, &lv_name)) != ECMD_PROCESSED) {
stack;
8 years, 3 months