mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Check max_lv on only place and force the check only for new volume.
We can temporarily violate max_lv during mirror conversion etc. (If the operation fails, orphan mirror images are visible to administrator for manual remove for example. Not that this should ever happen:-) Force limit only for lvcreate (and vg merge) command. Patch also adds simple max_lv tests into testsuite
This commit is contained in:
parent
82cf926094
commit
970f241c52
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.46 -
|
Version 2.02.46 -
|
||||||
================================
|
================================
|
||||||
|
Force max_lv restriction only for newly created LV.
|
||||||
Remove unneeded import parameter from lv_create_empty.
|
Remove unneeded import parameter from lv_create_empty.
|
||||||
Merge lv_is_displayable and lv_is_visible functions.
|
Merge lv_is_displayable and lv_is_visible functions.
|
||||||
Introduce lv_set_visible & lv_set_invisible functions.
|
Introduce lv_set_visible & lv_set_invisible functions.
|
||||||
|
@ -1804,6 +1804,20 @@ char *generate_lv_name(struct volume_group *vg, const char *format,
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vg_max_lv_reached(struct volume_group *vg)
|
||||||
|
{
|
||||||
|
if (!vg->max_lv)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (vg->max_lv > vg_visible_lvs(vg))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
log_verbose("Maximum number of logical volumes (%u) reached "
|
||||||
|
"in volume group %s", vg->max_lv, vg->name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new empty LV.
|
* Create a new empty LV.
|
||||||
*/
|
*/
|
||||||
@ -1817,11 +1831,8 @@ struct logical_volume *lv_create_empty(const char *name,
|
|||||||
struct logical_volume *lv;
|
struct logical_volume *lv;
|
||||||
char dname[NAME_LEN];
|
char dname[NAME_LEN];
|
||||||
|
|
||||||
if (vg->max_lv && (vg->max_lv == vg_visible_lvs(vg))) {
|
if (vg_max_lv_reached(vg))
|
||||||
log_error("Maximum number of logical volumes (%u) reached "
|
stack;
|
||||||
"in volume group %s", vg->max_lv, vg->name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strstr(name, "%d") &&
|
if (strstr(name, "%d") &&
|
||||||
!(name = generate_lv_name(vg, name, dname, sizeof(dname)))) {
|
!(name = generate_lv_name(vg, name, dname, sizeof(dname)))) {
|
||||||
@ -1936,6 +1947,9 @@ int link_lv_to_vg(struct volume_group *vg, struct logical_volume *lv)
|
|||||||
{
|
{
|
||||||
struct lv_list *lvl;
|
struct lv_list *lvl;
|
||||||
|
|
||||||
|
if (vg_max_lv_reached(vg))
|
||||||
|
stack;
|
||||||
|
|
||||||
if (!(lvl = dm_pool_zalloc(vg->vgmem, sizeof(*lvl))))
|
if (!(lvl = dm_pool_zalloc(vg->vgmem, sizeof(*lvl))))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
|
@ -564,6 +564,11 @@ int vg_check_status(const struct volume_group *vg, uint32_t status);
|
|||||||
*/
|
*/
|
||||||
unsigned vg_visible_lvs(const struct volume_group *vg);
|
unsigned vg_visible_lvs(const struct volume_group *vg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the VG reached maximal LVs count (if set)
|
||||||
|
*/
|
||||||
|
int vg_max_lv_reached(struct volume_group *vg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mirroring functions
|
* Mirroring functions
|
||||||
*/
|
*/
|
||||||
|
@ -1528,12 +1528,8 @@ int vg_validate(struct volume_group *vg)
|
|||||||
r = 0;
|
r = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->max_lv && (vg->max_lv < vg_visible_lvs(vg))) {
|
if (vg_max_lv_reached(vg))
|
||||||
log_error("Internal error: Volume group %s contains %u volumes"
|
stack;
|
||||||
" but the limit is set to %u.",
|
|
||||||
vg->name, vg_visible_lvs(vg), vg->max_lv);
|
|
||||||
r = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,33 @@ grep "^ Invalid stripe size 3\.00 KB\$" err
|
|||||||
case $(lvdisplay $vg) in "") true ;; *) false ;; esac
|
case $(lvdisplay $vg) in "") true ;; *) false ;; esac
|
||||||
|
|
||||||
# Setting max_lv works. (bz490298)
|
# Setting max_lv works. (bz490298)
|
||||||
vgchange -l 4 $vg
|
lvremove -ff $vg
|
||||||
|
vgchange -l 3 $vg
|
||||||
lvcreate -l1 -n $lv1 $vg
|
lvcreate -l1 -n $lv1 $vg
|
||||||
lvcreate -l1 -s -n $lv2 $vg/$lv1
|
lvcreate -l1 -s -n $lv2 $vg/$lv1
|
||||||
lvcreate -l1 -n $lv3 $vg
|
lvcreate -l1 -n $lv3 $vg
|
||||||
not lvcreate -l1 -n $lv4 $vg
|
not lvcreate -l1 -n $lv4 $vg
|
||||||
|
|
||||||
|
lvremove -ff $vg/$lv3
|
||||||
|
lvcreate -l1 -s -n $lv3 $vg/$lv1
|
||||||
|
not lvcreate -l1 -n $lv4 $vg
|
||||||
|
not lvcreate -l1 -m1 -n $lv4 $vg
|
||||||
|
|
||||||
|
lvremove -ff $vg/$lv3
|
||||||
|
lvcreate -l1 -m1 -n $lv3 $vg
|
||||||
|
lvs
|
||||||
|
vgs -o +max_lv
|
||||||
|
not lvcreate -l1 -n $lv4 $vg
|
||||||
|
not lvcreate -l1 -m1 -n $lv4 $vg
|
||||||
|
|
||||||
|
lvconvert -m0 $vg/$lv3
|
||||||
|
lvconvert -m2 -i 1 $vg/$lv3
|
||||||
|
lvconvert -m1 $vg/$lv3
|
||||||
|
|
||||||
|
not vgchange -l 2
|
||||||
|
vgchange -l 4
|
||||||
vgs $vg
|
vgs $vg
|
||||||
|
|
||||||
lvremove -ff $vg
|
lvremove -ff $vg
|
||||||
vgchange -l 0 $vg
|
vgchange -l 0 $vg
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ prepare_devs() {
|
|||||||
lv1=LV1
|
lv1=LV1
|
||||||
lv2=LV2
|
lv2=LV2
|
||||||
lv3=LV3
|
lv3=LV3
|
||||||
|
lv4=LV4
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_dev() {
|
disable_dev() {
|
||||||
|
@ -613,6 +613,12 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vg_max_lv_reached(vg)) {
|
||||||
|
log_error("Maximum number of logical volumes (%u) reached "
|
||||||
|
"in volume group %s", vg->max_lv, vg->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (lp->mirrors > 1 && !(vg->fid->fmt->features & FMT_SEGMENTS)) {
|
if (lp->mirrors > 1 && !(vg->fid->fmt->features & FMT_SEGMENTS)) {
|
||||||
log_error("Metadata does not support mirroring.");
|
log_error("Metadata does not support mirroring.");
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user