diff options
author | David Teigland <teigland@redhat.com> | 2016-03-29 13:29:39 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2016-04-08 16:37:12 -0500 |
commit | c1501c7536ce85fe0c69e7b7fffcdd4f82c1c184 (patch) | |
tree | 39d88caf6d8fe1cd55d89ddd7168817abf9e4042 | |
parent | a4b15f014147c1babd738ca3d814d973e14ef34b (diff) | |
download | lvm2-c1501c7536ce85fe0c69e7b7fffcdd4f82c1c184.tar.gz |
lvmcache: prefer duplicate device used by LVs
-rw-r--r-- | lib/cache/lvmcache.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 0d1f66709..53c8b4cc2 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -812,6 +812,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; /* @@ -867,6 +868,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); @@ -879,14 +883,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 */ @@ -912,7 +921,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. @@ -927,8 +936,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)); } /* |