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

cleanup: use NAME_LEN

Let's have instant check for max name len when creating
subLV name.
This commit is contained in:
Zdenek Kabelac 2015-11-05 11:58:03 +01:00
parent 5c48ef993b
commit 04f76d9020

View File

@ -3718,8 +3718,7 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
uint32_t i;
uint64_t sub_lv_status = 0;
const char *layer_name;
size_t len = strlen(lv->name) + 32;
char img_name[len];
char img_name[NAME_LEN];
struct lv_segment *mapseg;
if (lv->le_count || !dm_list_empty(&lv->segments)) {
@ -3745,7 +3744,8 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
if (!(mapseg = alloc_lv_segment(segtype, lv, 0, 0, lv->status,
stripe_size, NULL,
devices, 0, 0, region_size, 0, NULL))) {
log_error("Failed to create mapping segment for %s", lv->name);
log_error("Failed to create mapping segment for %s.",
display_lvname(lv));
return 0;
}
@ -3755,44 +3755,49 @@ static int _lv_insert_empty_sublvs(struct logical_volume *lv,
for (i = 0; i < devices; i++) {
/* Data LVs */
if (devices > 1) {
if (dm_snprintf(img_name, len, "%s_%s_%u",
if (dm_snprintf(img_name, sizeof(img_name), "%s_%s_%u",
lv->name, layer_name, i) < 0)
return_0;
goto_bad;
} else {
if (dm_snprintf(img_name, len, "%s_%s",
if (dm_snprintf(img_name, sizeof(img_name), "%s_%s",
lv->name, layer_name) < 0)
return_0;
goto_bad;
}
/* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */
if (!(sub_lv = lv_create_empty(img_name, NULL,
LVM_READ | LVM_WRITE,
lv->alloc, lv->vg)))
return_0;
if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
return_0;
/* Metadata LVs for raid */
if (segtype_is_raid(segtype)) {
if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0)
return_0;
} else
continue;
/* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */
if (!(sub_lv = lv_create_empty(img_name, NULL,
LVM_READ | LVM_WRITE,
lv->alloc, lv->vg)))
return_0;
if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
return_0;
/* Metadata LVs for raid */
if (segtype_is_raid(segtype)) {
if (dm_snprintf(img_name, sizeof(img_name), "%s_rmeta_%u",
lv->name, i) < 0)
goto_bad;
/* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */
if (!(sub_lv = lv_create_empty(img_name, NULL,
LVM_READ | LVM_WRITE,
lv->alloc, lv->vg)))
return_0;
if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
return_0;
}
}
dm_list_add(&lv->segments, &mapseg->list);
return 1;
bad:
log_error("Failed to create sub LV name for LV %s.",
display_lvname(lv));
return 0;
}
static int _lv_extend_layered_lv(struct alloc_handle *ah,
@ -3880,8 +3885,8 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah,
return 0;
}
log_verbose("Clearing metadata area of %s/%s",
meta_lv->vg->name, meta_lv->name);
log_verbose("Clearing metadata area of %s",
display_lvname(meta_lv));
/*
* Rather than wiping meta_lv->size, we can simply
* wipe '1' to remove the superblock of any previous