Bug 903411

Summary: lvchange activation issues when dealing w/ thin pool volumes and discard options
Product: Red Hat Enterprise Linux 6 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.4CC: agk, coughlan, dwysocha, heinzm, jbrassow, msnitzer, nperic, prajnoha, prockai, slevine, thornber, zkabelac
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.02.100-1.el6 Doc Type: Known Issue
Doc Text:
Activating a logical volume can fail if the --thinpool and --discards options are specified on logical-volume creation. To work around this problem, manually deactive all thin volumes related to the changed thin pool prior to running the lvchange command.
Story Points: ---
Clone Of:
: 969168 (view as bug list) Environment:
Last Closed: 2013-11-21 23:19:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 960054, 969168    

Description Corey Marthaler 2013-01-23 23:03:42 UTC
Description of problem:
SCENARIO - [convert_pool_discard_opts]
Creating [ignore] discards thinpool volume and converting it to [nopassdown] discards
lvcreate --thinpool POOL --discards ignore -L 2G snapper_thinp
lvcreate --virtualsize 500M --thinpool snapper_thinp/POOL -n origin
lvcreate -s /dev/snapper_thinp/origin -n snap
Deactivating LV before conversion
lvchange --discards nopassdown snapper_thinp/POOL
  device-mapper: reload ioctl on  failed: Invalid argument
LV activation failed

Jan 23 17:00:15 qalvm-01 kernel: device-mapper: table: 253:4: thin-pool: Discard support cannot be disabled once enabled
Jan 23 17:00:15 qalvm-01 kernel: device-mapper: ioctl: error adding target to table


vgchange however works:
[root@qalvm-01 ~]# vgchange -an snapper_thinp
  0 logical volume(s) in volume group "snapper_thinp" now active

Version-Release number of selected component (if applicable):
2.6.32-354.el6.x86_64
lvm2-2.02.98-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
lvm2-libs-2.02.98-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
lvm2-cluster-2.02.98-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
udev-147-2.43.el6    BUILT: Thu Oct 11 05:59:38 CDT 2012
device-mapper-1.02.77-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
device-mapper-libs-1.02.77-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
device-mapper-event-1.02.77-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
device-mapper-event-libs-1.02.77-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013
cmirror-2.02.98-9.el6    BUILT: Wed Jan 23 10:06:55 CST 2013


How reproducible:
Everytime

Comment 1 Mike Snitzer 2013-01-24 00:06:15 UTC
(In reply to comment #0)
> Description of problem:
> SCENARIO - [convert_pool_discard_opts]
> Creating [ignore] discards thinpool volume and converting it to [nopassdown]
> discards
> lvcreate --thinpool POOL --discards ignore -L 2G snapper_thinp
> lvcreate --virtualsize 500M --thinpool snapper_thinp/POOL -n origin
> lvcreate -s /dev/snapper_thinp/origin -n snap
> Deactivating LV before conversion
> lvchange --discards nopassdown snapper_thinp/POOL
>   device-mapper: reload ioctl on  failed: Invalid argument
> LV activation failed
> 
> Jan 23 17:00:15 qalvm-01 kernel: device-mapper: table: 253:4: thin-pool:
> Discard support cannot be disabled once enabled
> Jan 23 17:00:15 qalvm-01 kernel: device-mapper: ioctl: error adding target
> to table

The kernel error speaks to the pool having been activated with discards enabled and, without first being deactivated, the discard mode change was attempted via reload.

Such a transition is not allowed by the kernel.

So if you're attempting to first deactivate the pool, then change the discard mode, then reactivate the pool I'd start with verifying the pool is no longer active in the kernel (via dmsetup table) when you expect it to not be active.

I cannot be more precise with my guidance because I don't understand the implicit deactivations that are associated with the lvm commands you've listed (Zdenek should be able to).  But none of the commands clearly and explicitly deactivate the pool before you attempt to change the discard mode.

Comment 2 Zdenek Kabelac 2013-01-24 10:04:57 UTC
Yep - bug which needs some thinking - cluster supports makes it harder.

For now there is an 'incorrect' check for having  vg/pool active - but the 'real' pool is in the table with -tpool.  So if there is just deactivated pool - the LV/lock representing pool is deactivated - however other thin volumes using pool keeps the 'real' -tpool active.  So the lvchange allows the 'change' of discard, since it thinks pool is inactive - but an next activation of committed metadata will face the troubles with unacceptable ioctl whatever command it will be.

Current workaround is to manually deactivate all thin volumes related to the changed thin pool in front of lvchange command.

Comment 3 Zdenek Kabelac 2013-02-05 20:21:21 UTC
Fixed upstream with these patches:

https://www.redhat.com/archives/lvm-devel/2013-February/msg00037.html
https://www.redhat.com/archives/lvm-devel/2013-February/msg00038.html
https://www.redhat.com/archives/lvm-devel/2013-February/msg00048.html

All thin pool thin volumes are checked prior some variant of discards are allowed.

Comment 10 Nenad Peric 2013-10-09 15:00:44 UTC
Ran the test multiple times, with different configuration without a hitch (raid1/raid10 as origins as well)
Tested with:

snapper_thinp -o virt-011 -e convert_pool_discard_opts -i 3 
(and -t raid1 and raid10)

Marking this VERIFIED with:

lvm2-2.02.100-4.el6.x86_64

Comment 11 errata-xmlrpc 2013-11-21 23:19:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1704.html