mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
metadata: lv_set_name use uniq_insert
With presence of uniq_insert, use this function also here for extra protection and check for duplicate lv_name when inserting a new name into radix_tree.
This commit is contained in:
parent
b66b72b115
commit
9e8bd57e15
@ -1584,6 +1584,8 @@ int lv_set_creation(struct logical_volume *lv,
|
|||||||
*/
|
*/
|
||||||
int lv_set_name(struct logical_volume *lv, const char *lv_name)
|
int lv_set_name(struct logical_volume *lv, const char *lv_name)
|
||||||
{
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
if (lv->vg->lv_names && lv->name &&
|
if (lv->vg->lv_names && lv->name &&
|
||||||
!radix_tree_remove(lv->vg->lv_names, lv->name, strlen(lv->name))) {
|
!radix_tree_remove(lv->vg->lv_names, lv->name, strlen(lv->name))) {
|
||||||
log_error("Cannot remove from lv_names LV %s", lv->name);
|
log_error("Cannot remove from lv_names LV %s", lv->name);
|
||||||
@ -1593,8 +1595,12 @@ int lv_set_name(struct logical_volume *lv, const char *lv_name)
|
|||||||
lv->name = lv_name; /* NULL -> LV is removed from tree */
|
lv->name = lv_name; /* NULL -> LV is removed from tree */
|
||||||
|
|
||||||
if (lv->vg->lv_names && lv->name &&
|
if (lv->vg->lv_names && lv->name &&
|
||||||
!radix_tree_insert_ptr(lv->vg->lv_names, lv->name, strlen(lv->name), lv)) {
|
(1 != (r = radix_tree_uniq_insert_ptr(lv->vg->lv_names, lv->name,
|
||||||
|
strlen(lv->name), lv)))) {
|
||||||
|
if (!r)
|
||||||
log_error("Cannot insert to lv_names LV %s", lv->name);
|
log_error("Cannot insert to lv_names LV %s", lv->name);
|
||||||
|
else
|
||||||
|
log_error("Duplicate LV name %s detected.", lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user