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

thin: fix forbidden discards checks

Instead of check for lv_is_active() for thin pool LV,
query the whole pool via new  pool_is_active().

Fixes a problem when we cannot change discards settings
for active pool device where the actual layer for pool
device was inactive, but thin volumes using thin pool
have been active.
This commit is contained in:
Zdenek Kabelac 2013-02-02 12:48:52 +01:00
parent 11eaf1c98c
commit a5b9b4bf02
3 changed files with 21 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 - Version 2.02.99 -
=================================== ===================================
Fix check for some forbidden discards conversion of thin pools.
Add pool_is_active() to check for any pool related active LV. Add pool_is_active() to check for any pool related active LV.
Report blank field if the LV doesn't have an origin instead of 0. Report blank field if the LV doesn't have an origin instead of 0.
Do not take a free lv name argument for lvconvert --thinpool option. Do not take a free lv name argument for lvconvert --thinpool option.

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2012 Red Hat, Inc. All rights reserved. # Copyright (C) 2012-2013 Red Hat, Inc. All rights reserved.
# #
# This copyrighted material is made available to anyone wishing to use, # This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions # modify, copy, or redistribute it subject to the terms and conditions
@ -34,16 +34,30 @@ check lv_field $vg/pool2 discards "passdown"
lvchange --discards nopassdown $vg/pool2 lvchange --discards nopassdown $vg/pool2
# cannot convert active ignore -> passdown lvcreate -V1M -n origin -T $vg/pool
lvcreate -s $vg/origin -n snap
# Cannot convert active nopassdown -> ignore
not lvchange --discards nopassdown $vg/pool
# Cannot convert active ignore -> passdown
not lvchange --discards passdown $vg/pool not lvchange --discards passdown $vg/pool
# cannot convert active nopassdown -> ignore # Cannot convert active nopassdown -> ignore
not lvchange --discards ignore $vg/pool1 not lvchange --discards ignore $vg/pool1
# deactivate # Deactivate pool only
lvchange -an $vg/pool $vg/pool1 lvchange -an $vg/pool $vg/pool1
# Cannot convert, since thin volumes are still active
not lvchange --discards passdown $vg/pool
# Deactive thin volumes
lvchange -an $vg/origin $vg/snap
lvchange --discards passdown $vg/pool lvchange --discards passdown $vg/pool
check lv_field $vg/pool discards "passdown" check lv_field $vg/pool discards "passdown"
lvchange --discards ignore $vg/pool1 lvchange --discards ignore $vg/pool1
check lv_field $vg/pool1 discards "ignore" check lv_field $vg/pool1 discards "ignore"

View File

@ -113,9 +113,9 @@ static int lvchange_pool_update(struct cmd_context *cmd,
if (discards != first_seg(lv)->discards) { if (discards != first_seg(lv)->discards) {
if (((discards == THIN_DISCARDS_IGNORE) || if (((discards == THIN_DISCARDS_IGNORE) ||
(first_seg(lv)->discards == THIN_DISCARDS_IGNORE)) && (first_seg(lv)->discards == THIN_DISCARDS_IGNORE)) &&
lv_is_active(lv)) pool_is_active(first_seg(lv)))
log_error("Cannot change discards state for active " log_error("Cannot change discards state for active "
"logical volume \"%s\".", lv->name); "pool volume \"%s\".", lv->name);
else { else {
first_seg(lv)->discards = discards; first_seg(lv)->discards = discards;
update++; update++;