master - cleanup: use unsigned 1bit elements
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3b5afac9b433dd...
Commit: 3b5afac9b433dd26f4461d4f59401bbb299219ec
Parent: e5356eeba10858c2bb0f57891c262f77707b19bc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Aug 21 15:37:39 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 26 14:13:06 2014 +0200
cleanup: use unsigned 1bit elements
Avoid using signed 'int' type for 1 bit size.
---
lib/config/config.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/config/config.h b/lib/config/config.h
index 7b1d5b6..d095519 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -139,10 +139,10 @@ struct config_def_tree_spec {
struct cmd_context *cmd; /* command context (for run-time defaults */
cfg_def_tree_t type; /* tree type */
uint16_t version; /* tree at this LVM2 version */
- int ignoreadvanced:1; /* do not include advanced configs */
- int ignoreunsupported:1; /* do not include unsupported configs */
- int withcomments:1; /* include comments */
- int withversions:1; /* include versions */
+ unsigned ignoreadvanced:1; /* do not include advanced configs */
+ unsigned ignoreunsupported:1; /* do not include unsupported configs */
+ unsigned withcomments:1; /* include comments */
+ unsigned withversions:1; /* include versions */
uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */
};
9 years, 7 months
master - cleanup: never return uninitialized buffer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e5356eeba10858...
Commit: e5356eeba10858c2bb0f57891c262f77707b19bc
Parent: 8f518cf1979e4cbfce40f6ae1bed02bd5b9a5b35
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Aug 21 15:35:29 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 26 14:13:06 2014 +0200
cleanup: never return uninitialized buffer
Coverity noticed this function may return untouched buffer,
however in this state can't really happen, but anyway
ensure on error path the buffer will have zero lenght string.
---
lib/config/config.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index a71cbdc..58efb31 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -602,8 +602,10 @@ static int _cfg_def_make_path(char *buf, size_t buf_size, int id, cfg_def_item_t
int parent_id = item->parent;
int count, n;
- if (id == parent_id)
+ if (id == parent_id) {
+ buf[0] = '\0';
return 0;
+ }
count = _cfg_def_make_path(buf, buf_size, parent_id, cfg_def_get_item_p(parent_id), xlate);
if ((n = dm_snprintf(buf + count, buf_size - count, "%s%s%s%s",
9 years, 7 months
master - libdm: add check transaction_id after message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8f518cf1979e4c...
Commit: 8f518cf1979e4cbfce40f6ae1bed02bd5b9a5b35
Parent: 0794a10f91557d58e865faff4c60aef6336ecf22
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Aug 21 15:39:27 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 26 14:12:20 2014 +0200
libdm: add check transaction_id after message
Add extra safety detection for thin pool transaction id
and query pool status after confirmed message.
In case there is a missmatch, immeditelly abort further
processing.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 9f16797..484cb7e 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.89 -
=================================
+ Add extra check for matching transation_id after message submitting.
Add dm_report_field_string_list_unsorted for str. list report without sorting.
Support --deferred with dmsetup remove to defer removal of open devices.
Update dm-ioctl.h to include DM_DEFERRED_REMOVE flag.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 55f061a..0048b1c 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1561,7 +1561,7 @@ static int _node_send_messages(struct dm_tree_node *dnode,
/* Error if there are no stacked messages or id mismatches */
if (trans_id != (seg->transaction_id - have_messages)) {
- log_error("Thin pool transaction_id=%" PRIu64 ", while expected: %" PRIu64 ".",
+ log_error("Thin pool transaction_id is %" PRIu64 ", while expected %" PRIu64 ".",
trans_id, seg->transaction_id - have_messages);
return 0;
}
@@ -1569,9 +1569,21 @@ static int _node_send_messages(struct dm_tree_node *dnode,
if (!send)
return 1; /* transaction_id is matching */
- dm_list_iterate_items(tmsg, &seg->thin_messages)
+ dm_list_iterate_items(tmsg, &seg->thin_messages) {
if (!(_thin_pool_node_message(dnode, tmsg)))
return_0;
+ if (tmsg->message.type == DM_THIN_MESSAGE_SET_TRANSACTION_ID) {
+ if (!_thin_pool_status_transaction_id(dnode, &trans_id))
+ return_0;
+ if (trans_id != tmsg->message.u.m_set_transaction_id.new_id) {
+ log_error("Thin pool transaction_id is %" PRIu64
+ " and does not match expected %" PRIu64 ".",
+ trans_id,
+ tmsg->message.u.m_set_transaction_id.new_id);
+ return 0;
+ }
+ }
+ }
dnode->props.send_messages = 0; /* messages posted */
9 years, 7 months
master - thin: fix volume_list support
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0794a10f91557d...
Commit: 0794a10f91557d58e865faff4c60aef6336ecf22
Parent: 1ee5e18a7b446bc08d99a5638fc4463e459b34d3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 26 12:10:29 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 26 14:10:18 2014 +0200
thin: fix volume_list support
Fixing problem, when user sets volume_list and excludes thin pools
from activation. In this case pool return 'success' for skipped activation.
We need to really check the volume it is actually active to properly
to remove queued pool messages. Otherwise the lvm2 and kernel
metadata started to go async since lvm2 believed, messages were submitted.
Add also better check for threshold when create a new thin volume.
In this case we require local activation of thin pool so we are able
to check pool fullness.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 10 +--------
lib/metadata/thin_manip.c | 50 +++++++++++++++++++++++++++++++++++++++++---
3 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 13e6129..9ddb232 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.110 -
==================================
+ Fix manipulation with thin-pools which are excluded via volume_list.
Support lv/vgremove -ff to remove thin vols from broken/inactive thin pools.
Fix typo breaking configure --with-lvm1=shared.
Modify lvresize code to handle raid/mirrors and physical extents.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5cc0079..e57e7b3 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6816,15 +6816,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (lv_is_active_locally(lvl->lv) &&
- !pool_below_threshold(first_seg(lvl->lv))) {
- log_error("Cannot create thin volume. Pool \"%s/%s\" "
- "is filled over the autoextend threshold.",
- lvl->lv->vg->name, lvl->lv->name);
- return NULL;
- }
-
- if ((lv_is_active(lvl->lv) || is_change_activating(lp->activate)) &&
+ if ((pool_is_active(lvl->lv) || is_change_activating(lp->activate)) &&
!update_pool_lv(lvl->lv, 1))
return_NULL;
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index ae42da1..61e9c6e 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -307,9 +307,36 @@ uint32_t get_free_pool_device_id(struct lv_segment *thin_pool_seg)
return max_id;
}
+static int _check_pool_create(const struct logical_volume *lv)
+{
+ const struct lv_thin_message *lmsg;
+ struct lvinfo info;
+
+ dm_list_iterate_items(lmsg, &first_seg(lv)->thin_messages) {
+ if (lmsg->type != DM_THIN_MESSAGE_CREATE_THIN)
+ continue;
+ /* When creating new thin LV, check for size would be needed */
+ if (!lv_info(lv->vg->cmd, lv, 1, &info, 0, 0) ||
+ !info.exists) {
+ log_error("Pool %s needs to be locally active for threshold check.",
+ display_lvname(lv));
+ return 0;
+ }
+ if (!pool_below_threshold(first_seg(lv))) {
+ log_error("Free space in pool %s is above threshold, new volumes are not allowed.",
+ display_lvname(lv));
+ return 0;
+ }
+ break;
+ }
+
+ return 1;
+}
+
int update_pool_lv(struct logical_volume *lv, int activate)
{
int monitored;
+ int ret = 1;
if (!lv_is_thin_pool(lv)) {
log_error(INTERNAL_ERROR "Updated LV %s is not pool.", lv->name);
@@ -324,10 +351,24 @@ int update_pool_lv(struct logical_volume *lv, int activate)
if (!lv_is_active(lv)) {
monitored = dmeventd_monitor_mode();
init_dmeventd_monitor(DMEVENTD_MONITOR_IGNORE);
- if (!activate_lv_excl(lv->vg->cmd, lv))
+ if (!activate_lv_excl(lv->vg->cmd, lv)) {
+ init_dmeventd_monitor(monitored);
return_0;
- if (!deactivate_lv(lv->vg->cmd, lv))
+ }
+ if (!lv_is_active(lv)) {
+ init_dmeventd_monitor(monitored);
+ log_error("Cannot activate thin pool %s, perhaps skipped in lvm.conf volume_list?",
+ display_lvname(lv));
+ return 0;
+ }
+
+ if (!(ret = _check_pool_create(lv)))
+ stack;
+
+ if (!deactivate_lv(lv->vg->cmd, lv)) {
+ init_dmeventd_monitor(monitored);
return_0;
+ }
init_dmeventd_monitor(monitored);
}
/*
@@ -337,7 +378,8 @@ int update_pool_lv(struct logical_volume *lv, int activate)
else if (!resume_lv_origin(lv->vg->cmd, lv)) {
log_error("Failed to resume %s.", lv->name);
return 0;
- }
+ } else if (!(ret = _check_pool_create(lv)))
+ stack;
}
dm_list_init(&(first_seg(lv)->thin_messages));
@@ -345,7 +387,7 @@ int update_pool_lv(struct logical_volume *lv, int activate)
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- return 1;
+ return ret;
}
int update_thin_pool_params(struct volume_group *vg,
9 years, 7 months
master - thin: more forced ignoring of pool failure
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1ee5e18a7b446b...
Commit: 1ee5e18a7b446bc08d99a5638fc4463e459b34d3
Parent: f4e56b28299680783b8375235bdd2bd48a9934e5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 26 11:53:56 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 26 14:09:04 2014 +0200
thin: more forced ignoring of pool failure
Support also 'vgremove -ff' to properly remove even inactive/broken thin pools.
Update messages to use 'print_unless_silent' for the forced case.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 14 +++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c42d1d5..13e6129 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.110 -
==================================
+ Support lv/vgremove -ff to remove thin vols from broken/inactive thin pools.
Fix typo breaking configure --with-lvm1=shared.
Modify lvresize code to handle raid/mirrors and physical extents.
Allow conversion of raid1 LV into a snapshot LV or snapshot origin LV.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index fa91c4e..5cc0079 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5522,11 +5522,11 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
if (pool_lv && !pool_has_message(first_seg(pool_lv), lv, 0) &&
!update_pool_lv(pool_lv, 1)) {
if (force < DONT_PROMPT_OVERRIDE) {
- log_error("Failed to update thin pool %s.", pool_lv->name);
+ log_error("Failed to update pool %s.", display_lvname(pool_lv));
return 0;
}
- log_warn("WARNING: Forced to ignoring failure of pool metadata update %s.",
- pool_lv->name);
+ log_print_unless_silent("Ignoring update failure of pool %s.",
+ display_lvname(pool_lv));
pool_lv = NULL; /* Do not retry */
}
@@ -5565,8 +5565,12 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* Release unneeded blocks in thin pool */
/* TODO: defer when multiple LVs relased at once */
if (pool_lv && !update_pool_lv(pool_lv, 1)) {
- log_error("Failed to update thin pool %s.", pool_lv->name);
- return 0;
+ if (force < DONT_PROMPT_OVERRIDE) {
+ log_error("Failed to update pool %s.", display_lvname(pool_lv));
+ return 0;
+ }
+ log_print_unless_silent("Ignoring update failure of pool %s.",
+ display_lvname(pool_lv));
}
backup(vg);
9 years, 7 months
master - cleanup: consolidate lv_layout and lv_role reporting
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f4e56b28299680...
Commit: f4e56b28299680783b8375235bdd2bd48a9934e5
Parent: 2d344c2e4509af34df219a0c9727902ab73b219c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 25 10:02:32 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 25 16:14:40 2014 +0200
cleanup: consolidate lv_layout and lv_role reporting
This patch makes the keyword combinations found in "lv_layout" and
"lv_role" much more understandable - there were some ambiguities
for some of the combinations which lead to confusion before.
Now, the scheme used is:
LAYOUTS ("how the LV is laid out"):
===================================
[linear] (all segments have number of stripes = 1)
[striped] (all segments have number of stripes > 1)
[linear,striped] (mixed linear and striped)
raid (raid layout always reported together with raid level, raid layout == image + metadata LVs underneath that make up raid LV)
[raid,raid1]
[raid,raid10]
[raid,raid4]
[raid,raid5] (exact sublayout not specified during creation - default one used - raid5_ls)
[raid,raid5,raid5_ls]
[raid,raid5,raid6_rs]
[raid,raid5,raid5_la]
[raid,raid5,raid5_ra]
[raid6,raid] (exact sublayout not specified during creation - default one used - raid6_zr)
[raid,raid6,raid6_zr]
[raid,raid6,raid6_nc]
[raid,raid6,raid6_ns]
[mirror] (mirror layout == log + image LVs underneath that make up mirror LV)
thin (thin layout always reported together with sublayout)
[thin,sparse] (thin layout == allocated out of thin pool)
[thin,pool] (thin pool layout == data + metadata volumes underneath that make up thin pool LV, not supposed to be used for direct use!!!)
[cache] (cache layout == allocated out of cache pool in conjunction with cache origin)
[cache,pool] (cache pool layout == data + metadata volumes underneath that make up cache pool LV, not supposed to be used for direct use!!!)
[virtual] (virtual layout == not hitting disk underneath, currently this layout denotes only 'zero' device used for origin,thickorigin role)
[unknown] (either error state or missing recognition for such layout)
ROLES ("what's the purpose or use of the LV - what is its role"):
=================================================================
- each LV has either of these two roles at least: [public] (public LV that users may use freely to write their data to)
[public] (public LV that users may use freely to write their data to)
[private] (private LV that LVM maintains; not supposed to be directly used by user to write his data to)
- and then some special-purpose roles in addition to that:
[origin,thickorigin] (origin for thick-style snapshot; "thick" as opposed to "thin")
[origin,multithickorigin] (there are more than 2 thick-style snapshots for this origin)
[origin,thinorigin] (origin for thin snapshot)
[origin,multithinorigin] (there are more than 2 thin snapshots for this origin)
[origin,extorigin] (external origin for thin snapshot)
[origin,multiextoriginl (there are more than 2 thin snapshots using this external origin)
[origin,cacheorigin] (cache origin)
[snapshot,thicksnapshot] (thick-style snapshot; "thick" as opposed to "thin")
[snapshot,thinsnapshot] (thin-style snapshot)
[raid,metadata] (raid metadata LV)
[raid,image] (raid image LV)
[mirror,image] (mirror image LV)
[mirror,log] (mirror log LV)
[pvmove] (pvmove LV)
[thin,pool,data] (thin pool data LV)
[thin,pool,metadata] (thin pool metadata LV)
[cache,pool,data] (cache pool data LV)
[cache,pool,metadata] (cache pool metadata LV)
[pool,spare] (pool spare LV - common role of LV that makes it used for both thin and cache repairs)
---
lib/datastruct/str_list.c | 17 ++-
lib/datastruct/str_list.h | 1 +
lib/metadata/lv_manip.c | 375 +++++++++++++++++++++++++++------------------
3 files changed, 238 insertions(+), 155 deletions(-)
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index 3e429ab..feec8b6 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -30,7 +30,7 @@ struct dm_list *str_list_create(struct dm_pool *mem)
return sl;
}
-int str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const char *str)
+static int _str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const char *str, int as_first)
{
struct dm_str_list *sln;
@@ -41,11 +41,24 @@ int str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const ch
return_0;
sln->str = str;
- dm_list_add(sll, &sln->list);
+ if (as_first)
+ dm_list_add_h(sll, &sln->list);
+ else
+ dm_list_add(sll, &sln->list);
return 1;
}
+int str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const char *str)
+{
+ return _str_list_add_no_dup_check(mem, sll, str, 0);
+}
+
+int str_list_add_h_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const char *str)
+{
+ return _str_list_add_no_dup_check(mem, sll, str, 1);
+}
+
int str_list_add(struct dm_pool *mem, struct dm_list *sll, const char *str)
{
if (!str)
diff --git a/lib/datastruct/str_list.h b/lib/datastruct/str_list.h
index a052df6..0046fe4 100644
--- a/lib/datastruct/str_list.h
+++ b/lib/datastruct/str_list.h
@@ -22,6 +22,7 @@ struct dm_pool;
struct dm_list *str_list_create(struct dm_pool *mem);
int str_list_add(struct dm_pool *mem, struct dm_list *sll, const char *str);
int str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const char *str);
+int str_list_add_h_no_dup_check(struct dm_pool *mem, struct dm_list *sll, const char *str);
void str_list_del(struct dm_list *sll, const char *str);
int str_list_match_item(const struct dm_list *sll, const char *str);
int str_list_match_list(const struct dm_list *sll, const struct dm_list *sll2, const char **tag_matched);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 45ce19c..fa91c4e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -85,104 +85,129 @@ struct pv_and_int {
enum {
LV_TYPE_UNKNOWN,
+ LV_TYPE_PUBLIC,
+ LV_TYPE_PRIVATE,
LV_TYPE_LINEAR,
LV_TYPE_STRIPED,
LV_TYPE_MIRROR,
LV_TYPE_RAID,
LV_TYPE_THIN,
LV_TYPE_CACHE,
+ LV_TYPE_SPARSE,
LV_TYPE_ORIGIN,
- LV_TYPE_MULTIPLE,
+ LV_TYPE_THINORIGIN,
+ LV_TYPE_MULTITHINORIGIN,
+ LV_TYPE_THICKORIGIN,
+ LV_TYPE_MULTITHICKORIGIN,
+ LV_TYPE_CACHEORIGIN,
+ LV_TYPE_EXTTHINORIGIN,
+ LV_TYPE_MULTIEXTTHINORIGIN,
LV_TYPE_SNAPSHOT,
+ LV_TYPE_THINSNAPSHOT,
+ LV_TYPE_THICKSNAPSHOT,
LV_TYPE_PVMOVE,
LV_TYPE_IMAGE,
LV_TYPE_LOG,
LV_TYPE_METADATA,
LV_TYPE_POOL,
LV_TYPE_DATA,
- LV_TYPE_EXTERNAL,
LV_TYPE_SPARE,
LV_TYPE_VIRTUAL,
- LV_TYPE_RAID_LEVEL1,
- LV_TYPE_RAID_LEVEL10,
- LV_TYPE_RAID_LEVEL4,
- LV_TYPE_RAID_LEVEL5,
- LV_TYPE_RAID_LEVEL6,
- LV_TYPE_RAID_LEFT_ASYMMETRIC,
- LV_TYPE_RAID_RIGHT_ASYMMETRIC,
- LV_TYPE_RAID_LEFT_SYMMETRIC,
- LV_TYPE_RAID_RIGHT_SYMMETRIC,
- LV_TYPE_RAID_ZERO_RESTART,
- LV_TYPE_RAID_N_RESTART,
- LV_TYPE_RAID_N_CONTINUE,
+ LV_TYPE_RAID1,
+ LV_TYPE_RAID10,
+ LV_TYPE_RAID4,
+ LV_TYPE_RAID5,
+ LV_TYPE_RAID5_LA,
+ LV_TYPE_RAID5_RA,
+ LV_TYPE_RAID5_LS,
+ LV_TYPE_RAID5_RS,
+ LV_TYPE_RAID6,
+ LV_TYPE_RAID6_ZR,
+ LV_TYPE_RAID6_NR,
+ LV_TYPE_RAID6_NC,
};
static const char *_lv_type_names[] = {
[LV_TYPE_UNKNOWN] = "unknown",
+ [LV_TYPE_PUBLIC] = "public",
+ [LV_TYPE_PRIVATE] = "private",
[LV_TYPE_LINEAR] = "linear",
[LV_TYPE_STRIPED] = "striped",
[LV_TYPE_MIRROR] = "mirror",
[LV_TYPE_RAID] = "raid",
[LV_TYPE_THIN] = "thin",
[LV_TYPE_CACHE] = "cache",
+ [LV_TYPE_SPARSE] = "sparse",
[LV_TYPE_ORIGIN] = "origin",
- [LV_TYPE_MULTIPLE] = "multiple",
+ [LV_TYPE_THINORIGIN] = "thinorigin",
+ [LV_TYPE_MULTITHINORIGIN] = "multithinorigin",
+ [LV_TYPE_THICKORIGIN] = "thickorigin",
+ [LV_TYPE_MULTITHICKORIGIN] = "multithickorigin",
+ [LV_TYPE_CACHEORIGIN] = "cacheorigin",
+ [LV_TYPE_EXTTHINORIGIN] = "extthinorigin",
+ [LV_TYPE_MULTIEXTTHINORIGIN] = "multiextthinorigin",
[LV_TYPE_SNAPSHOT] = "snapshot",
+ [LV_TYPE_THINSNAPSHOT] = "thinsnapshot",
+ [LV_TYPE_THICKSNAPSHOT] = "thicksnapshot",
[LV_TYPE_PVMOVE] = "pvmove",
[LV_TYPE_IMAGE] = "image",
[LV_TYPE_LOG] = "log",
[LV_TYPE_METADATA] = "metadata",
[LV_TYPE_POOL] = "pool",
[LV_TYPE_DATA] = "data",
- [LV_TYPE_EXTERNAL] = "external",
[LV_TYPE_SPARE] = "spare",
[LV_TYPE_VIRTUAL] = "virtual",
- [LV_TYPE_RAID_LEVEL1] = "level1",
- [LV_TYPE_RAID_LEVEL10] = "level10",
- [LV_TYPE_RAID_LEVEL4] = "level4",
- [LV_TYPE_RAID_LEVEL5] = "level5",
- [LV_TYPE_RAID_LEVEL6] = "level6",
- [LV_TYPE_RAID_LEFT_ASYMMETRIC] = "left-asymmetric",
- [LV_TYPE_RAID_RIGHT_ASYMMETRIC] = "right-asymmetric",
- [LV_TYPE_RAID_LEFT_SYMMETRIC] = "left-symmetric",
- [LV_TYPE_RAID_RIGHT_SYMMETRIC] = "right-symmetric",
- [LV_TYPE_RAID_ZERO_RESTART] = "zero-restart",
- [LV_TYPE_RAID_N_RESTART] = "n-restart",
- [LV_TYPE_RAID_N_CONTINUE] = "n-continue",
+ [LV_TYPE_RAID1] = "raid1",
+ [LV_TYPE_RAID10] = "raid10",
+ [LV_TYPE_RAID4] = "raid4",
+ [LV_TYPE_RAID5] = "raid5",
+ [LV_TYPE_RAID5_LA] = "raid5_la",
+ [LV_TYPE_RAID5_RA] = "raid5_ra",
+ [LV_TYPE_RAID5_LS] = "raid5_ls",
+ [LV_TYPE_RAID5_RS] = "raid5_rs",
+ [LV_TYPE_RAID6] = "raid6",
+ [LV_TYPE_RAID6_ZR] = "raid6_zr",
+ [LV_TYPE_RAID6_NR] = "raid6_nr",
+ [LV_TYPE_RAID6_NC] = "raid6_nc",
};
static int _lv_layout_and_role_mirror(struct dm_pool *mem,
const struct logical_volume *lv,
struct dm_list *layout,
- struct dm_list *role)
+ struct dm_list *role,
+ int *public_lv)
{
- int top_level = 1;
+ int top_level = 0;
+ /* non-top-level LVs */
if (lv_is_mirror_image(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_IMAGE]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MIRROR]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_IMAGE]))
goto_bad;
- top_level = 0;
} else if (lv_is_mirror_log(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_LOG]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MIRROR]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_LOG]))
goto_bad;
if (lv_is_mirrored(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
- top_level = 0;
} else if (lv->status & PVMOVE) {
if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_PVMOVE]) ||
- !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MIRROR]))
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
- }
+ } else
+ top_level = 1;
- if (top_level) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
- goto_bad;
- } else {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MIRROR]))
- goto_bad;
+
+ if (!top_level) {
+ *public_lv = 0;
+ return 1;
}
+ /* top-level LVs */
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
+ goto_bad;
+
return 1;
bad:
return 0;
@@ -191,69 +216,75 @@ bad:
static int _lv_layout_and_role_raid(struct dm_pool *mem,
const struct logical_volume *lv,
struct dm_list *layout,
- struct dm_list *role)
+ struct dm_list *role,
+ int *public_lv)
{
- int top_level = 1;
+ int top_level = 0;
const char *seg_name;
+ /* non-top-level LVs */
if (lv_is_raid_image(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_IMAGE]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_RAID]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_IMAGE]))
goto_bad;
- top_level = 0;
} else if (lv_is_raid_metadata(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_RAID]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
- top_level = 0;
- } else if (!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID1)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEVEL1]))
+ } else
+ top_level = 1;
+
+ if (!top_level) {
+ *public_lv = 0;
+ return 1;
+ }
+
+ /* top-level LVs */
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID]))
+ goto_bad;
+
+ if (!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID1)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID1]))
goto_bad;
} else if (!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID10)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEVEL10]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID10]))
goto_bad;
} else if (!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID4)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEVEL4]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID4]))
goto_bad;
} else if (!strncmp(seg_name = first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID5, strlen(SEG_TYPE_NAME_RAID5))) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEVEL5]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5]))
goto_bad;
if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_LA)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEFT_ASYMMETRIC]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_LA]))
goto_bad;
} else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_RA)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_RIGHT_ASYMMETRIC]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_RA]))
goto_bad;
} else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_LS)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEFT_SYMMETRIC]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_LS]))
goto_bad;
} else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID5_RS)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_RIGHT_SYMMETRIC]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID5_RS]))
goto_bad;
}
} else if (!strncmp(seg_name = first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID6, strlen(SEG_TYPE_NAME_RAID6))) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_LEVEL6]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6]))
goto_bad;
if (!strcmp(seg_name, SEG_TYPE_NAME_RAID6_ZR)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_ZERO_RESTART]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6_ZR]))
goto_bad;
} else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID6_NR)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_N_RESTART]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6_NR]))
goto_bad;
} else if (!strcmp(seg_name, SEG_TYPE_NAME_RAID6_NC)) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID_N_CONTINUE]))
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID6_NC]))
goto_bad;
}
}
- if (top_level) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID]))
- goto_bad;
- } else {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_RAID]))
- goto_bad;
- }
-
return 1;
bad:
return 0;
@@ -262,46 +293,62 @@ bad:
static int _lv_layout_and_role_thin(struct dm_pool *mem,
const struct logical_volume *lv,
struct dm_list *layout,
- struct dm_list *role)
+ struct dm_list *role,
+ int *public_lv)
{
- int top_level = 1;
+ int top_level = 0;
unsigned snap_count;
struct lv_segment *seg;
- if (lv_is_thin_pool(lv)) {
+ /* non-top-level LVs */
+ if (lv_is_thin_pool_metadata(lv)) {
if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
- goto_bad;
- } else if (lv_is_thin_pool_metadata(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
- top_level = 0;
} else if (lv_is_thin_pool_data(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_DATA]))
goto_bad;
- top_level = 0;
- } else if (lv_is_thin_volume(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]))
+ } else
+ top_level = 1;
+
+ if (!top_level) {
+ *public_lv = 0;
+ return 1;
+ }
+
+ /* top-level LVs */
+ if (lv_is_thin_volume(lv)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_THIN]) ||
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_SPARSE]))
goto_bad;
- if (lv_is_thin_origin(lv, &snap_count) &&
- !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_ORIGIN]))
+ if (lv_is_thin_origin(lv, &snap_count)) {
+ if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_ORIGIN]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THINORIGIN]))
goto_bad;
- if (snap_count > 1 &&
- !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MULTIPLE]))
- goto_bad;
+ if (snap_count > 1 &&
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MULTITHINORIGIN]))
+ goto_bad;
+ }
if ((seg = first_seg(lv)) && (seg->origin || seg->external_lv))
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_SNAPSHOT]))
+ if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_SNAPSHOT]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THINSNAPSHOT]))
goto_bad;
+ } else if (lv_is_thin_pool(lv)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_THIN]) ||
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
+ goto_bad;
+ *public_lv = 0;
}
- if (top_level) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_THIN]))
+ if (lv_is_external_origin(lv)) {
+ if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_ORIGIN]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_EXTTHINORIGIN]))
goto_bad;
- } else {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]))
+ if (lv->external_count > 1 &&
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MULTIEXTTHINORIGIN]))
goto_bad;
}
@@ -313,35 +360,83 @@ bad:
static int _lv_layout_and_role_cache(struct dm_pool *mem,
const struct logical_volume *lv,
struct dm_list *layout,
- struct dm_list *role)
+ struct dm_list *role,
+ int *public_lv)
{
- int top_level = 1;
+ int top_level = 0;
- if (lv_is_cache_pool(lv)) {
+ /* non-top-level LVs */
+ if (lv_is_cache_pool_metadata(lv)) {
if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_CACHE]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
- goto_bad;
- } else if (lv_is_cache_pool_metadata(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
- top_level = 0;
} else if (lv_is_cache_pool_data(lv)) {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_CACHE]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_DATA]))
goto_bad;
if (lv_is_cache(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
goto_bad;
- top_level = 0;
+ } else if (lv_is_cache_origin(lv)) {
+ if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_CACHE]) ||
+ !str_list_add(mem, role, _lv_type_names[LV_TYPE_ORIGIN]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_CACHEORIGIN]))
+ goto_bad;
+ if (lv_is_cache(lv) &&
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
+ goto_bad;
+ } else
+ top_level = 1;
+
+ if (!top_level) {
+ *public_lv = 0;
+ return 1;
}
- if (top_level) {
- if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
+ /* top-level LVs */
+ if (lv_is_cache(lv) &&
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
+ goto_bad;
+ else if (lv_is_cache_pool(lv)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]) ||
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
goto_bad;
- } else {
- if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_CACHE]))
+ *public_lv = 0;
+ }
+
+ return 1;
+bad:
+ return 0;
+}
+
+static int _lv_layout_and_role_thick_origin_snapshot(struct dm_pool *mem,
+ const struct logical_volume *lv,
+ struct dm_list *layout,
+ struct dm_list *role,
+ int *public_lv)
+{
+ if (lv_is_origin(lv)) {
+ if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_ORIGIN]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THICKORIGIN]))
+ goto_bad;
+ /*
+ * Thin volumes are also marked with virtual flag, but we don't show "virtual"
+ * layout for thin LVs as they have their own keyword for layout - "thin"!
+ * So rule thin LVs out here!
+ */
+ if (lv_is_virtual(lv) && !lv_is_thin_volume(lv)) {
+ if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_VIRTUAL]))
+ goto_bad;
+ *public_lv = 0;
+ }
+ if (lv->origin_count > 1 &&
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MULTITHICKORIGIN]))
+ goto_bad;
+ } else if (lv_is_cow(lv)) {
+ if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_SNAPSHOT]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THICKSNAPSHOT]))
goto_bad;
}
@@ -354,6 +449,7 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
struct dm_list **layout, struct dm_list **role) {
int linear, striped, unknown;
struct lv_segment *seg;
+ int public_lv = 1;
*layout = *role = NULL;
@@ -369,62 +465,35 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
/* Mirrors and related */
if (lv_is_mirror_type(lv) && !lv_is_raid(lv) &&
- !_lv_layout_and_role_mirror(mem, lv, *layout, *role))
+ !_lv_layout_and_role_mirror(mem, lv, *layout, *role, &public_lv))
goto_bad;
/* RAIDs and related */
if (lv_is_raid_type(lv) &&
- !_lv_layout_and_role_raid(mem, lv, *layout, *role))
+ !_lv_layout_and_role_raid(mem, lv, *layout, *role, &public_lv))
goto_bad;
/* Thins and related */
- if (lv_is_thin_type(lv) &&
- !_lv_layout_and_role_thin(mem, lv, *layout, *role))
+ if ((lv_is_thin_type(lv) || lv_is_external_origin(lv)) &&
+ !_lv_layout_and_role_thin(mem, lv, *layout, *role, &public_lv))
goto_bad;
- if (lv_is_external_origin(lv)) {
- if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_ORIGIN]) ||
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_EXTERNAL]))
- goto_bad;
- if (lv->external_count > 1 &&
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_MULTIPLE]))
- goto_bad;
- if (!lv_is_thin_volume(lv) &&
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_THIN]))
- goto_bad;
- }
-
/* Caches and related */
- if (lv_is_cache_type(lv) &&
- !_lv_layout_and_role_cache(mem, lv, *layout, *role))
+ if ((lv_is_cache_type(lv) || lv_is_cache_origin(lv)) &&
+ !_lv_layout_and_role_cache(mem, lv, *layout, *role, &public_lv))
goto_bad;
- if (lv_is_cache_origin(lv)) {
- if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_CACHE]) ||
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_ORIGIN]))
+ /* Pool-specific */
+ if (lv_is_pool_metadata_spare(lv)) {
+ if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_SPARE]))
goto_bad;
+ public_lv = 0;
}
- /* Pool-specific */
- if (lv_is_pool_metadata_spare(lv) &&
- (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_METADATA]) ||
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_SPARE])))
- goto_bad;
-
/* Old-style origins/snapshots, virtual origins */
- if (lv_is_origin(lv)) {
- str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_ORIGIN]);
- if (lv_is_virtual(lv) &&
- !str_list_add_no_dup_check(mem, *layout, _lv_type_names[LV_TYPE_VIRTUAL]))
- goto_bad;
- if (lv->origin_count > 1 &&
- !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_MULTIPLE]))
- goto_bad;
- } else if (lv_is_cow(lv)) {
- if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_SNAPSHOT]))
- goto_bad;
- }
+ if (!_lv_layout_and_role_thick_origin_snapshot(mem, lv, *layout, *role, &public_lv))
+ goto_bad;
/*
* If layout not yet determined, it must be either
@@ -465,14 +534,14 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
goto_bad;
}
- /*
- * If role is not defined here yet, it means this is a pure top-level
- * device that is not combined with any other type. So just copy what
- * we have set for "layout" and use it for "role" too.
- */
- if (dm_list_empty(*role) &&
- !str_list_dup(mem, *role, *layout))
- goto_bad;
+ /* finally, add either 'public' or 'private' role to the LV */
+ if (public_lv) {
+ if (!str_list_add_h_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_PUBLIC]))
+ goto_bad;
+ } else {
+ if (!str_list_add_h_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_PRIVATE]))
+ goto_bad;
+ }
return 1;
bad:
9 years, 8 months
master - report: use dm_report_field_string_list_unordered for reporting lv_layout and lv_role fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2d344c2e4509af...
Commit: 2d344c2e4509af34df219a0c9727902ab73b219c
Parent: 02dc3c773e6c8728b5df1dd7be8e1dc8c5f58e72
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 25 10:05:27 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 25 16:11:40 2014 +0200
report: use dm_report_field_string_list_unordered for reporting lv_layout and lv_role fields
This makes it a bit more readable since we can report more general
layouts/roles first and keywords describing the LV more precisely
afterwards in the list.
---
lib/report/report.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 32aca88..84ca73b 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -140,10 +140,11 @@ static int _field_set_value(struct dm_report_field *field, const void *data, con
}
static int _field_set_string_list(struct dm_report *rh, struct dm_report_field *field,
- const struct dm_list *list, void *private)
+ const struct dm_list *list, void *private, int sorted)
{
struct cmd_context *cmd = (struct cmd_context *) private;
- return dm_report_field_string_list(rh, field, list, cmd->report_list_item_separator);
+ return sorted ? dm_report_field_string_list(rh, field, list, cmd->report_list_item_separator)
+ : dm_report_field_string_list_unsorted(rh, field, list, cmd->report_list_item_separator);
}
/*
@@ -232,7 +233,7 @@ static int _tags_disp(struct dm_report *rh, struct dm_pool *mem,
{
const struct dm_list *tagsl = (const struct dm_list *) data;
- return _field_set_string_list(rh, field, tagsl, private);
+ return _field_set_string_list(rh, field, tagsl, private, 1);
}
static int _modules_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -250,7 +251,7 @@ static int _modules_disp(struct dm_report *rh, struct dm_pool *mem,
if (!(list_lv_modules(mem, lv, modules)))
return_0;
- return _field_set_string_list(rh, field, modules, private);
+ return _field_set_string_list(rh, field, modules, private, 1);
}
static int _lvprofile_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1331,7 +1332,7 @@ static int _lvlayout_disp(struct dm_report *rh, struct dm_pool *mem,
return 0;
}
- return _field_set_string_list(rh, field, lv_layout, private);
+ return _field_set_string_list(rh, field, lv_layout, private, 0);
}
static int _lvrole_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1347,7 +1348,7 @@ static int _lvrole_disp(struct dm_report *rh, struct dm_pool *mem,
return 0;
}
- return _field_set_string_list(rh, field, lv_role, private);
+ return _field_set_string_list(rh, field, lv_role, private, 0);
}
static int _lvinitialimagesync_disp(struct dm_report *rh, struct dm_pool *mem,
9 years, 8 months
master - report: add dm_report_field_string_list_unsorted
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=02dc3c773e6c87...
Commit: 02dc3c773e6c8728b5df1dd7be8e1dc8c5f58e72
Parent: 993f8d1b3f6cd6f04d0b9bfe858c35161e262dc4
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 25 10:04:08 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 25 16:11:40 2014 +0200
report: add dm_report_field_string_list_unsorted
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 2 +
libdm/libdm-report.c | 133 ++++++++++++++++++++++++++++++++++----------------
3 files changed, 94 insertions(+), 42 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 4a2c8b4..9f16797 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.89 -
=================================
+ Add dm_report_field_string_list_unsorted for str. list report without sorting.
Support --deferred with dmsetup remove to defer removal of open devices.
Update dm-ioctl.h to include DM_DEFERRED_REMOVE flag.
Add support for selection to match string list subset, recognize { } operator.
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index bf8a658..31574af 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1755,6 +1755,8 @@ int dm_report_field_string(struct dm_report *rh, struct dm_report_field *field,
const char *const *data);
int dm_report_field_string_list(struct dm_report *rh, struct dm_report_field *field,
const struct dm_list *data, const char *delimiter);
+int dm_report_field_string_list_unsorted(struct dm_report *rh, struct dm_report_field *field,
+ const struct dm_list *data, const char *delimiter);
int dm_report_field_int32(struct dm_report *rh, struct dm_report_field *field,
const int32_t *data);
int dm_report_field_uint32(struct dm_report *rh, struct dm_report_field *field,
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 261b436..cd42b11 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -283,24 +283,6 @@ int dm_report_field_string(struct dm_report *rh,
return 1;
}
-static int _str_cmp(const void *a, const void *b)
-{
- const char **str_a = (const char **) a;
- const char **str_b = (const char **) b;
-
- return strcmp(*str_a, *str_b);
-}
-
-struct str_list_sort_value_item {
- unsigned pos;
- size_t len;
-};
-
-struct str_list_sort_value {
- const char *value;
- struct str_list_sort_value_item *items;
-};
-
int dm_report_field_percent(struct dm_report *rh,
struct dm_report_field *field,
const dm_percent_t *data)
@@ -336,15 +318,39 @@ int dm_report_field_percent(struct dm_report *rh,
return 1;
}
-int dm_report_field_string_list(struct dm_report *rh,
- struct dm_report_field *field,
- const struct dm_list *data,
- const char *delimiter)
+struct str_list_sort_value_item {
+ unsigned pos;
+ size_t len;
+};
+
+struct str_list_sort_value {
+ const char *value;
+ struct str_list_sort_value_item *items;
+};
+
+struct str_list_sort_item {
+ const char *str;
+ struct str_list_sort_value_item item;
+};
+
+static int _str_list_sort_item_cmp(const void *a, const void *b)
+{
+ const struct str_list_sort_item *slsi_a = (const struct str_list_sort_item *) a;
+ const struct str_list_sort_item *slsi_b = (const struct str_list_sort_item *) b;
+
+ return strcmp(slsi_a->str, slsi_b->str);
+}
+
+static int _report_field_string_list(struct dm_report *rh,
+ struct dm_report_field *field,
+ const struct dm_list *data,
+ const char *delimiter,
+ int sort)
{
static const char _string_list_grow_object_failed_msg[] = "dm_report_field_string_list: dm_pool_grow_object_failed";
struct str_list_sort_value *sort_value = NULL;
unsigned int list_size, pos, i;
- const char **arr = NULL;
+ struct str_list_sort_item *arr = NULL;
struct dm_str_list *sl;
size_t delimiter_len, len;
void *object;
@@ -392,14 +398,10 @@ int dm_report_field_string_list(struct dm_report *rh,
}
/* more than one item - sort the list */
- if (!(arr = dm_malloc(sizeof(char *) * list_size))) {
+ if (!(arr = dm_malloc(sizeof(struct str_list_sort_item) * list_size))) {
log_error("dm_report_field_string_list: dm_malloc failed");
goto out;
}
- i = 0;
- dm_list_iterate_items(sl, data)
- arr[i++] = sl->str;
- qsort(arr, i, sizeof(char *), _str_cmp);
if (!(dm_pool_begin_object(rh->mem, 256))) {
log_error(_string_list_grow_object_failed_msg);
@@ -410,21 +412,47 @@ int dm_report_field_string_list(struct dm_report *rh,
delimiter = ",";
delimiter_len = strlen(delimiter);
- /* start from 1 - the item 0 stores the list size! */
- for (i = 1, pos = 0; i <= list_size; i++) {
- len = strlen(arr[i-1]);
- if (!dm_pool_grow_object(rh->mem, arr[i-1], len) ||
- (i != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
+ i = pos = len = 0;
+ dm_list_iterate_items(sl, data) {
+ arr[i].str = sl->str;
+ if (!sort) {
+ /* sorted outpud not required - report the list as it is */
+ len = strlen(sl->str);
+ if (!dm_pool_grow_object(rh->mem, arr[i].str, len) ||
+ (i+1 != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
+ log_error(_string_list_grow_object_failed_msg);
+ goto out;
+ }
+ arr[i].item.pos = pos;
+ arr[i].item.len = len;
+ pos = i+1 == list_size ? pos+len : pos+len+delimiter_len;
+ }
+ i++;
+ }
+
+ qsort(arr, i, sizeof(struct str_list_sort_item), _str_list_sort_item_cmp);
+
+ for (i = 0, pos = 0; i < list_size; i++) {
+ if (sort) {
+ /* sorted output required - report the list as sorted */
+ len = strlen(arr[i].str);
+ if (!dm_pool_grow_object(rh->mem, arr[i].str, len) ||
+ (i+1 != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
+ log_error(_string_list_grow_object_failed_msg);
+ goto out;
+ }
+ /*
+ * Save position and length of the string
+ * element in report_string for sort_value.
+ * Use i+1 here since items[0] stores list size!!!
+ */
+ sort_value->items[i+1].pos = pos;
+ sort_value->items[i+1].len = len;
+ pos = i+1 == list_size ? pos+len : pos+len+delimiter_len;
+ } else {
+ sort_value->items[i+1].pos = arr[i].item.pos;
+ sort_value->items[i+1].len = arr[i].item.len;
}
- /*
- * save position and length of the string
- * element in report_string for sort_value
- */
- sort_value->items[i].pos = pos;
- sort_value->items[i].len = len;
- pos = i == list_size ? pos+len : pos+len+delimiter_len;
}
if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
@@ -445,6 +473,27 @@ out:
return r;
}
+int dm_report_field_string_list(struct dm_report *rh,
+ struct dm_report_field *field,
+ const struct dm_list *data,
+ const char *delimiter)
+{
+ return _report_field_string_list(rh, field, data, delimiter, 1);
+}
+
+int dm_report_field_string_list_unsorted(struct dm_report *rh,
+ struct dm_report_field *field,
+ const struct dm_list *data,
+ const char *delimiter)
+{
+ /*
+ * The raw value is always sorted, just the string reported is unsorted.
+ * Having the raw value always sorted helps when matching selection list
+ * with selection criteria.
+ */
+ return _report_field_string_list(rh, field, data, delimiter, 0);
+}
+
int dm_report_field_int(struct dm_report *rh,
struct dm_report_field *field, const int *data)
{
9 years, 8 months
master - refactor: rename 'lv_type' field to 'lv_role'
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=993f8d1b3f6cd6...
Commit: 993f8d1b3f6cd6f04d0b9bfe858c35161e262dc4
Parent: 66326e2fb8c84b57505f1396d394a96ec25e12c3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 25 09:07:03 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 25 16:11:40 2014 +0200
refactor: rename 'lv_type' field to 'lv_role'
The 'lv_type' field name was a bit misleading. Better one is 'lv_role'
since this fields describes what's the actual use of the LV currently -
its 'role'.
---
WHATS_NEW | 2 +-
lib/metadata/lv_manip.c | 144 +++++++++++++++++++-------------------
lib/metadata/metadata-exported.h | 4 +-
lib/report/columns.h | 2 +-
lib/report/properties.c | 4 +-
lib/report/report.c | 14 ++--
6 files changed, 85 insertions(+), 85 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index af6ced4..c42d1d5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -5,7 +5,7 @@ Version 2.02.110 -
Allow conversion of raid1 LV into a snapshot LV or snapshot origin LV.
Cleanly error when creating RAID with stripe size < PAGE_SIZE.
Print name of LV which on activation triggers delayed snapshot merge.
- Add lv_layout and lv_type LV reporting fields.
+ Add lv_layout and lv_role LV reporting fields.
Properly display lvs lv_attr volume type and target type bit for cache origin.
Fix pvcreate_check() to update cache correctly after signature wiping.
Fix primary device lookup failure for partition when processing mpath filter.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d85f536..45ce19c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -151,27 +151,27 @@ static const char *_lv_type_names[] = {
[LV_TYPE_RAID_N_CONTINUE] = "n-continue",
};
-static int _lv_type_list_mirror(struct dm_pool *mem,
- const struct logical_volume *lv,
- struct dm_list *layout,
- struct dm_list *type)
+static int _lv_layout_and_role_mirror(struct dm_pool *mem,
+ const struct logical_volume *lv,
+ struct dm_list *layout,
+ struct dm_list *role)
{
int top_level = 1;
if (lv_is_mirror_image(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_IMAGE]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_IMAGE]))
goto_bad;
top_level = 0;
} else if (lv_is_mirror_log(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_LOG]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_LOG]))
goto_bad;
if (lv_is_mirrored(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
top_level = 0;
} else if (lv->status & PVMOVE) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_PVMOVE]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_MIRROR]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_PVMOVE]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
}
@@ -179,7 +179,7 @@ static int _lv_type_list_mirror(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
} else {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_MIRROR]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
}
@@ -188,20 +188,20 @@ bad:
return 0;
}
-static int _lv_type_list_raid(struct dm_pool *mem,
- const struct logical_volume *lv,
- struct dm_list *layout,
- struct dm_list *type)
+static int _lv_layout_and_role_raid(struct dm_pool *mem,
+ const struct logical_volume *lv,
+ struct dm_list *layout,
+ struct dm_list *role)
{
int top_level = 1;
const char *seg_name;
if (lv_is_raid_image(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_IMAGE]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_IMAGE]))
goto_bad;
top_level = 0;
} else if (lv_is_raid_metadata(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_METADATA]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
top_level = 0;
} else if (!strcmp(first_seg(lv)->segtype->name, SEG_TYPE_NAME_RAID1)) {
@@ -250,7 +250,7 @@ static int _lv_type_list_raid(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID]))
goto_bad;
} else {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_RAID]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_RAID]))
goto_bad;
}
@@ -259,41 +259,41 @@ bad:
return 0;
}
-static int _lv_type_list_thin(struct dm_pool *mem,
- const struct logical_volume *lv,
- struct dm_list *layout,
- struct dm_list *type)
+static int _lv_layout_and_role_thin(struct dm_pool *mem,
+ const struct logical_volume *lv,
+ struct dm_list *layout,
+ struct dm_list *role)
{
int top_level = 1;
unsigned snap_count;
struct lv_segment *seg;
if (lv_is_thin_pool(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_THIN]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
goto_bad;
} else if (lv_is_thin_pool_metadata(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_METADATA]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
top_level = 0;
} else if (lv_is_thin_pool_data(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_DATA]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_DATA]))
goto_bad;
top_level = 0;
} else if (lv_is_thin_volume(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_THIN]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
if (lv_is_thin_origin(lv, &snap_count) &&
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_ORIGIN]))
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_ORIGIN]))
goto_bad;
if (snap_count > 1 &&
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_MULTIPLE]))
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_MULTIPLE]))
goto_bad;
if ((seg = first_seg(lv)) && (seg->origin || seg->external_lv))
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_SNAPSHOT]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_SNAPSHOT]))
goto_bad;
}
@@ -301,7 +301,7 @@ static int _lv_type_list_thin(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
} else {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_THIN]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
}
@@ -310,26 +310,26 @@ bad:
return 0;
}
-static int _lv_type_list_cache(struct dm_pool *mem,
- const struct logical_volume *lv,
- struct dm_list *layout,
- struct dm_list *type)
+static int _lv_layout_and_role_cache(struct dm_pool *mem,
+ const struct logical_volume *lv,
+ struct dm_list *layout,
+ struct dm_list *role)
{
int top_level = 1;
if (lv_is_cache_pool(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_CACHE]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_CACHE]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
goto_bad;
} else if (lv_is_cache_pool_metadata(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_METADATA]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
top_level = 0;
} else if (lv_is_cache_pool_data(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_DATA]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_DATA]))
goto_bad;
if (lv_is_cache(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
@@ -341,7 +341,7 @@ static int _lv_type_list_cache(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
goto_bad;
} else {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_CACHE]))
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_CACHE]))
goto_bad;
}
@@ -350,79 +350,79 @@ bad:
return 0;
}
-int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
- struct dm_list **layout, struct dm_list **type) {
+int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
+ struct dm_list **layout, struct dm_list **role) {
int linear, striped, unknown;
struct lv_segment *seg;
- *layout = *type = NULL;
+ *layout = *role = NULL;
if (!(*layout = str_list_create(mem))) {
log_error("LV layout list allocation failed");
goto bad;
}
- if (!(*type = str_list_create(mem))) {
- log_error("LV type list allocation failed");
+ if (!(*role = str_list_create(mem))) {
+ log_error("LV role list allocation failed");
goto bad;
}
/* Mirrors and related */
if (lv_is_mirror_type(lv) && !lv_is_raid(lv) &&
- !_lv_type_list_mirror(mem, lv, *layout, *type))
+ !_lv_layout_and_role_mirror(mem, lv, *layout, *role))
goto_bad;
/* RAIDs and related */
if (lv_is_raid_type(lv) &&
- !_lv_type_list_raid(mem, lv, *layout, *type))
+ !_lv_layout_and_role_raid(mem, lv, *layout, *role))
goto_bad;
/* Thins and related */
if (lv_is_thin_type(lv) &&
- !_lv_type_list_thin(mem, lv, *layout, *type))
+ !_lv_layout_and_role_thin(mem, lv, *layout, *role))
goto_bad;
if (lv_is_external_origin(lv)) {
- if (!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_ORIGIN]) ||
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_EXTERNAL]))
+ if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_ORIGIN]) ||
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_EXTERNAL]))
goto_bad;
if (lv->external_count > 1 &&
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_MULTIPLE]))
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_MULTIPLE]))
goto_bad;
if (!lv_is_thin_volume(lv) &&
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_THIN]))
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
}
/* Caches and related */
if (lv_is_cache_type(lv) &&
- !_lv_type_list_cache(mem, lv, *layout, *type))
+ !_lv_layout_and_role_cache(mem, lv, *layout, *role))
goto_bad;
if (lv_is_cache_origin(lv)) {
- if (!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_CACHE]) ||
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_ORIGIN]))
+ if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_CACHE]) ||
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_ORIGIN]))
goto_bad;
}
/* Pool-specific */
if (lv_is_pool_metadata_spare(lv) &&
- (!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_POOL]) ||
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_METADATA]) ||
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_SPARE])))
+ (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_POOL]) ||
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_METADATA]) ||
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_SPARE])))
goto_bad;
/* Old-style origins/snapshots, virtual origins */
if (lv_is_origin(lv)) {
- str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_ORIGIN]);
+ str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_ORIGIN]);
if (lv_is_virtual(lv) &&
!str_list_add_no_dup_check(mem, *layout, _lv_type_names[LV_TYPE_VIRTUAL]))
goto_bad;
if (lv->origin_count > 1 &&
- !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_MULTIPLE]))
+ !str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_MULTIPLE]))
goto_bad;
} else if (lv_is_cow(lv)) {
- if (!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_SNAPSHOT]))
+ if (!str_list_add_no_dup_check(mem, *role, _lv_type_names[LV_TYPE_SNAPSHOT]))
goto_bad;
}
@@ -442,12 +442,12 @@ int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
* This should not happen but if it does
* we'll see that there's "unknown" layout
* present. This means we forgot to detect
- * the type above and we need add proper
- * detection for such type!
+ * the role above and we need add proper
+ * detection for such role!
*/
unknown = 1;
log_error(INTERNAL_ERROR "Failed to properly detect "
- "layout and type for LV %s/%s",
+ "layout and role for LV %s/%s",
lv->vg->name, lv->name);
}
}
@@ -466,18 +466,18 @@ int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
}
/*
- * If type is not defined here yet, it means this is a pure top-level
+ * If role is not defined here yet, it means this is a pure top-level
* device that is not combined with any other type. So just copy what
- * we have set for "layout" and use it for "type" too.
+ * we have set for "layout" and use it for "role" too.
*/
- if (dm_list_empty(*type) &&
- !str_list_dup(mem, *type, *layout))
+ if (dm_list_empty(*role) &&
+ !str_list_dup(mem, *role, *layout))
goto_bad;
return 1;
bad:
- if (*type)
- dm_pool_free(mem, *type);
+ if (*role)
+ dm_pool_free(mem, *role);
if (*layout)
dm_pool_free(mem, *layout);
return 0;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index ff24911..0db4334 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -191,8 +191,8 @@
#define lv_is_pool_metadata(lv) (((lv)->status & (CACHE_POOL_METADATA | THIN_POOL_METADATA)) ? 1 : 0)
#define lv_is_pool_metadata_spare(lv) (((lv)->status & (POOL_METADATA_SPARE)) ? 1 : 0)
-int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
- struct dm_list **layout, struct dm_list **type);
+int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
+ struct dm_list **layout, struct dm_list **role);
/* Ordered list - see lv_manip.c */
typedef enum {
diff --git a/lib/report/columns.h b/lib/report/columns.h
index d203f3d..78f5832 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -40,7 +40,7 @@ FIELD(LVS, lv, STR, "DMPath", lvid, 6, lvdmpath, lv_dm_path, "Internal device-ma
FIELD(LVS, lv, STR, "Parent", lvid, 6, lvparent, lv_parent, "For LVs that are components of another LV, the parent LV.", 0)
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
FIELD(LVS, lv, STR_LIST, "Layout", lvid, 10, lvlayout, lv_layout, "LV layout.", 0)
-FIELD(LVS, lv, STR_LIST, "Type", lvid, 10, lvtype, lv_type, "LV type.", 0)
+FIELD(LVS, lv, STR_LIST, "Role", lvid, 10, lvrole, lv_role, "LV role.", 0)
FIELD(LVS, lv, BIN, "InitImgSync", lvid, 10, lvinitialimagesync, lv_initial_image_sync, "Set if mirror/RAID images underwent initial resynchronization.", 0)
FIELD(LVS, lv, BIN, "ImgSynced", lvid, 10, lvimagesynced, lv_image_synced, "Set if mirror/RAID image is synchronized.", 0)
FIELD(LVS, lv, BIN, "Merging", lvid, 10, lvmerging, lv_merging, "Set if snapshot LV is being merged to origin.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index eac8c2c..e0092db 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -181,8 +181,8 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)
#define _lv_layout_set prop_not_implemented_set
#define _lv_layout_get prop_not_implemented_get
-#define _lv_type_set prop_not_implemented_set
-#define _lv_type_get prop_not_implemented_get
+#define _lv_role_set prop_not_implemented_set
+#define _lv_role_get prop_not_implemented_get
#define _lv_initial_image_sync_set prop_not_implemented_set
#define _lv_initial_image_sync_get prop_not_implemented_get
#define _lv_image_synced_get prop_not_implemented_get
diff --git a/lib/report/report.c b/lib/report/report.c
index 69151e0..32aca88 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1324,9 +1324,9 @@ static int _lvlayout_disp(struct dm_report *rh, struct dm_pool *mem,
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct dm_list *lv_layout;
- struct dm_list *lv_type;
+ struct dm_list *lv_role;
- if (!lv_layout_and_type(mem, lv, &lv_layout, &lv_type)) {
+ if (!lv_layout_and_role(mem, lv, &lv_layout, &lv_role)) {
log_error("Failed to display layout for LV %s/%s.", lv->vg->name, lv->name);
return 0;
}
@@ -1334,20 +1334,20 @@ static int _lvlayout_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_string_list(rh, field, lv_layout, private);
}
-static int _lvtype_disp(struct dm_report *rh, struct dm_pool *mem,
+static int _lvrole_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct dm_list *lv_layout;
- struct dm_list *lv_type;
+ struct dm_list *lv_role;
- if (!lv_layout_and_type(mem, lv, &lv_layout, &lv_type)) {
- log_error("Failed to display type for LV %s/%s.", lv->vg->name, lv->name);
+ if (!lv_layout_and_role(mem, lv, &lv_layout, &lv_role)) {
+ log_error("Failed to display role for LV %s/%s.", lv->vg->name, lv->name);
return 0;
}
- return _field_set_string_list(rh, field, lv_type, private);
+ return _field_set_string_list(rh, field, lv_role, private);
}
static int _lvinitialimagesync_disp(struct dm_report *rh, struct dm_pool *mem,
9 years, 8 months
master - autoreconf
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=66326e2fb8c84b...
Commit: 66326e2fb8c84b57505f1396d394a96ec25e12c3
Parent: 83b5cb3ed52b14d1bbe522168bbc63aba1c84475
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Aug 22 23:47:44 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Aug 22 23:47:44 2014 +0100
autoreconf
---
configure | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/configure b/configure
index 40ab256..be3d34d 100755
--- a/configure
+++ b/configure
@@ -7136,7 +7136,7 @@ fi
$as_echo "$LVM1" >&6; }
case "$LVM1" in
- none|share) ;;
+ none|shared) ;;
internal)
$as_echo "#define LVM1_INTERNAL 1" >>confdefs.h
;;
9 years, 8 months