summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-03-29 13:29:39 -0500
committerDavid Teigland <teigland@redhat.com>2016-04-13 14:18:52 -0500
commit7334122494f62d66ab4257f84ea3ca329a06120e (patch)
tree323f494cb0f6d0d065768a5063cbb219d4ad1dda
parent1f05a74f0f19ddd10c491fd2283f3a2be779c63d (diff)
downloadlvm2-7334122494f62d66ab4257f84ea3ca329a06120e.tar.gz
lvmcache: prefer duplicate device used by LVs
-rw-r--r--lib/cache/lvmcache.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 3ad700089..a52482e39 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -813,6 +813,7 @@ static void _choose_preferred_devs(struct cmd_context *cmd,
int in_subsys1, in_subsys2;
int is_dm1, is_dm2;
int has_fs1, has_fs2;
+ int has_lv1, has_lv2;
int change;
/*
@@ -868,6 +869,9 @@ next:
dev2_major = MAJOR(dev2->dev);
dev2_minor = MINOR(dev2->dev);
+ has_lv1 = (dev1->flags & DEV_USED_FOR_LV) ? 1 : 0;
+ has_lv2 = (dev2->flags & DEV_USED_FOR_LV) ? 1 : 0;
+
in_subsys1 = dev_subsystem_part_major(dt, dev1);
in_subsys2 = dev_subsystem_part_major(dt, dev2);
@@ -880,14 +884,19 @@ next:
log_debug_cache("PV %s compare duplicates %s and %s",
devl->dev->pvid, dev_name(dev1), dev_name(dev2));
- log_debug_cache("dup dev1 %s subsys %d dm %d fs %d",
- dev_name(dev1), in_subsys1, is_dm1, has_fs1);
- log_debug_cache("dup dev2 %s subsys %d dm %d fs %d",
- dev_name(dev2), in_subsys2, is_dm2, has_fs2);
+ log_debug_cache("dup dev1 %s subsys %d dm %d fs %d lv %d",
+ dev_name(dev1), in_subsys1, is_dm1, has_fs1, has_lv1);
+ log_debug_cache("dup dev2 %s subsys %d dm %d fs %d lv %d",
+ dev_name(dev2), in_subsys2, is_dm2, has_fs2, has_lv2);
change = 0;
- if (has_fs1 && !has_fs2) {
+ if (has_lv1 && !has_lv2) {
+ /* keep 1 */
+ } else if (has_lv2 && !has_lv1) {
+ /* change to 2 */
+ change = 1;
+ } else if (has_fs1 && !has_fs2) {
/* keep 1 */
} else if (has_fs2 && !has_fs1) {
/* change to 2 */
@@ -913,7 +922,7 @@ next:
id_write_format((const struct id *)info->dev->pvid, uuid, sizeof(uuid));
if (dev1 != info->dev) {
- log_warn("PV %s is using preferred device %s, changed from %s",
+ log_warn("PV %s prefers device %s instead of device %s.",
uuid, dev_name(dev1), dev_name(info->dev));
/*
* Move the preferred device from altdevs to add_cache_devs.
@@ -928,8 +937,7 @@ next:
dm_list_add(del_cache_devs, &del->list);
}
} else {
- log_warn("PV %s is using preferred device %s",
- uuid, dev_name(info->dev));
+ log_warn("PV %s prefers device %s.", uuid, dev_name(info->dev));
}
/*