1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

pvmove: simplify name generation

This commit is contained in:
Zdenek Kabelac 2017-10-31 20:51:11 +01:00
parent bc29785d09
commit 0ba3939542

View File

@ -154,8 +154,8 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
const char *lv_name, const char *lv_name,
struct dm_list *trim_list) struct dm_list *trim_list)
{ {
char *idx, *suffix, *sublv_name; char *idx, *suffix;
size_t len; char sublv_name[NAME_LEN];
struct logical_volume *sublv; struct logical_volume *sublv;
struct dm_list untrim_list, *pvh1, *pvh2; struct dm_list untrim_list, *pvh1, *pvh2;
struct pv_list *pvl1, *pvl2; struct pv_list *pvl1, *pvl2;
@ -172,18 +172,18 @@ static int _remove_sibling_pvs_from_trim_list(struct logical_volume *lv,
if (!(suffix = first_substring(lv_name, "_rimage_", "_rmeta_", NULL))) if (!(suffix = first_substring(lv_name, "_rimage_", "_rmeta_", NULL)))
return 0; return 0;
if (!(idx = strstr(suffix + 1, "_"))) if (!(idx = strchr(suffix + 1, '_'))) {
log_error("Can't find '_' after suffix %s.", suffix);
return 0; return 0;
}
idx++; idx++;
/* + 2 for the longer rimage string */
if (!(sublv_name = dm_pool_alloc(lv->vg->cmd->mem, strlen(lv_name + 2))))
return_0;
/* Create the siblings name (e.g. "raidlv_rmeta_N" -> "raidlv_rimage_N" */ /* Create the siblings name (e.g. "raidlv_rmeta_N" -> "raidlv_rimage_N" */
len = suffix - lv_name; if (dm_snprintf(sublv_name, sizeof(sublv_name), "%s_r%s_%s", lv_name,
strncpy(sublv_name, lv_name, len); strstr(suffix, "_rimage_") ? "meta" : "image", idx) < 0) {
sprintf(sublv_name + len, strstr(suffix, "_rimage_") ? "_rmeta_%s" : "_rimage_%s", idx); log_error("Raid sublv for name %s too long.", lv_name);
return 0;
}
if (!(sublv = find_lv(lv->vg, sublv_name))) { if (!(sublv = find_lv(lv->vg, sublv_name))) {
log_error("Can't find sub LV %s?", sublv_name); log_error("Can't find sub LV %s?", sublv_name);