summaryrefslogtreecommitdiff
path: root/tools/pvmove.c
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2018-01-11 13:21:08 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2018-01-17 14:44:31 +0100
commit7c6fb63041cd5c1fb899cc468d0a5cf23a01abbe (patch)
tree9d4178b16f20e31fe08303e35ee942e32c1dc15e /tools/pvmove.c
parente86910b052ef50dfdaad104d17bda679f698e31f (diff)
downloadlvm2-7c6fb63041cd5c1fb899cc468d0a5cf23a01abbe.tar.gz
pvmove: fix _remove_sibling_pvs_from_trim_list
Fix the function to really check it sibling raid image LV. For LV_rmeta_0 check for LV_rimage_0 instead of LV_rmeta_0rimage_0.
Diffstat (limited to 'tools/pvmove.c')
-rw-r--r--tools/pvmove.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 7bf1713c8..39cf25f2d 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -145,6 +145,7 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
struct dm_list *trim_list)
{
char *idx, *suffix;
+ const char *sibling;
char sublv_name[NAME_LEN];
struct logical_volume *sublv;
struct dm_list untrim_list, *pvh1, *pvh2;
@@ -159,7 +160,16 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
dm_list_init(&untrim_list);
- if (!(suffix = first_substring(lv_name, "_rimage_", "_rmeta_", NULL))) {
+ if (!dm_strncpy(sublv_name, lv_name, sizeof(sublv_name))) {
+ log_error(INTERNAL_ERROR "LV name %s is too long.", lv_name);
+ return 0;
+ }
+
+ if ((suffix = strstr(sublv_name, "_rimage_")))
+ sibling = "meta";
+ else if ((suffix = strstr(sublv_name, "_rmeta_")))
+ sibling = "image";
+ else {
log_error("Can't find rimage or rmeta suffix.");
return 0;
}
@@ -171,8 +181,8 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
idx++;
/* Create the siblings name (e.g. "raidlv_rmeta_N" -> "raidlv_rimage_N" */
- if (dm_snprintf(sublv_name, sizeof(sublv_name), "%s_r%s_%s", lv_name,
- strstr(suffix, "_rimage_") ? "meta" : "image", idx) < 0) {
+ if (dm_snprintf(suffix + 2, sizeof(sublv_name) - 2 - (suffix - sublv_name),
+ "%s_%s", sibling, idx) < 0) {
log_error("Raid sublv for name %s too long.", lv_name);
return 0;
}