1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

thin: fix link validation for unused thin-pool

This patch fixes link validation for used thin-pool.
Udev rules correctly creates symlinks only for unused new thin-pool.
Such thin-pool can be used by foreing apps (like Docker) thus
has  /dev/vg/lv link.
However when thin-pool becomes used by thinLV - this link is no
longer exposed to user - but internal verfication missed this
and caused messages like this to be printed upon 'vgchange -ay':

The link /dev/vg/pool should have been created by udev but it was not
found. Falling back to direct link creation.

And same with 'vgchange -an':
The link /dev/vg/pool should have been removed by udev but it is still
present. Falling back to direct link removal.

This patch ensures only unused thin-pool has this link.
This commit is contained in:
Zdenek Kabelac 2016-06-30 15:54:27 +02:00
parent 2f638e07e8
commit 458918b319
3 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.159 -
=================================
Fix created link for a used pool for vgmknode.
Introduce and use is_power_of_2 macro.
Support conversions between striped and raid0 segment types.
Add infrastructure for raid takeover lvconvert options.

View File

@ -1599,6 +1599,12 @@ static int _dev_manager_lv_rmnodes(const struct logical_volume *lv)
return fs_del_lv(lv);
}
static int _lv_has_mknode(const struct logical_volume *lv)
{
return (lv_is_visible(lv) &&
(!lv_is_thin_pool(lv) || lv_is_new_thin_pool(lv)));
}
int dev_manager_mknodes(const struct logical_volume *lv)
{
struct dm_info dminfo;
@ -1610,7 +1616,7 @@ int dev_manager_mknodes(const struct logical_volume *lv)
if ((r = _info_run(MKNODES, name, NULL, &dminfo, NULL, NULL, 0, 0, 0, 0))) {
if (dminfo.exists) {
if (lv_is_visible(lv))
if (_lv_has_mknode(lv))
r = _dev_manager_lv_mknodes(lv);
} else
r = _dev_manager_lv_rmnodes(lv);
@ -2993,7 +2999,7 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
r = 0;
continue;
}
if (lv_is_visible(lvlayer->lv)) {
if (_lv_has_mknode(lvlayer->lv)) {
if (!_dev_manager_lv_mknodes(lvlayer->lv))
r = 0;
continue;

View File

@ -24,6 +24,8 @@ aux have_thin 1 3 0 || skip
aux prepare_vg 2 33
lvcreate -L32 -T $vg/pool
# check there is link node for UNUSED thin-pool
test -e "$DM_DEV_DIR/$vg/pool"
# leave 12M free space
lvcreate -an -n $lv1 -L16 $vg 2>&1 | tee out
@ -31,6 +33,8 @@ vgs $vg
lvcreate -n thin1 -V30 $vg/pool 2>&1 | tee out
not grep "WARNING: Sum" out
# check again link node is now gone for a USED thin-pool
test ! -e "$DM_DEV_DIR/$vg/pool"
# Pool gets overprovisioned
lvcreate -an -n thin2 -V4 $vg/pool 2>&1 | tee out