Bug 832392

Summary: pvmove cannot be used with lvm.conf option issue_discards
Product: Red Hat Enterprise Linux 6 Reporter: Zdenek Kabelac <zkabelac>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.3CC: agk, cmarthal, coughlan, dwysocha, heinzm, jbrassow, mbroz, msnitzer, nperic, prajnoha, prockai, thornber, zkabelac
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.02.97-2.el6 Doc Type: Bug Fix
Doc Text:
Without this fix, when issue_discards=1 is configured in the /etc/lvm/lvm.conf file, moving physical volumes via the pvmove command results in data loss.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:10:41 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: 852438    

Description Zdenek Kabelac 2012-06-15 10:07:58 UTC
Description of problem:

If user enables issue_discards=1  and runs PV move command, and underlaying devices supports discard  he will loose data from move chunks.

Here is short log of what is going on:
(chunk is release and discarded prior it's move)

#metadata/lv_manip.c:3013   Creating logical volume pvmove0
#metadata/lv_manip.c:3938     Inserting layer pvmove0 for segments of lvol0 on /dev/loop0
#metadata/lv_manip.c:3852       Matched PE range /dev/loop0:0-126 against /dev/loop0 0 len 1
#metadata/lv_manip.c:3798     Inserting /dev/loop0:0-0 of test/lvol0
#libdm-config.c:853     Setting devices/issue_discards to 1
#device/device.c:428     Device /dev/loop0 queue/discard_max_bytes is 4294966784 bytes.
#device/device.c:428     Device /dev/loop0 queue/discard_granularity is 4096 bytes.
#metadata/pv_manip.c:223       Discarding 1 extents offset 2048 sectors on /dev/loop0.
#device/dev-io.c:577       Closed /dev/loop0
#device/dev-io.c:524       Opened /dev/loop0 RW O_DIRECT
#device/dev-io.c:318       Discarding 4194304 bytes offset 1048576 bytes on /dev/loop0.
#metadata/lv_manip.c:432     Stack lvol0:0[0] on LV pvmove0:0
#metadata/lv_manip.c:86     Adding lvol0:0 as an user of pvmove0
#pvmove.c:164   Moving 1 extents of logical volume test/lvol0
#mm/pool-fast.c:59       Created fast mempool allocation at 0x16f1810
#libdm-config.c:866     allocation/mirror_logs_require_separate_pvs not found in config: defaulting to 0
#libdm-config.c:866     allocation/maximise_cling not found in config: defaulting to 1
#metadata/pv_map.c:55       Allowing allocation on /dev/loop1 start PE 0 length 127
#metadata/lv_manip.c:967       Parallel PVs at LE 0 length 1: /dev/loop0 
#metadata/lv_manip.c:2023       Trying allocation using contiguous policy.
#metadata/lv_manip.c:1635       Still need 1 total extents:
#metadata/lv_manip.c:1638         1 (1 data/0 parity) parallel areas of 1 extents each
#metadata/lv_manip.c:1640         0 mirror logs of 0 extents each
#metadata/lv_manip.c:1329       Considering allocation area 0 as /dev/loop1 start PE 0 length 1 leaving 126.
#metadata/lv_manip.c:1112       Allocating parallel area 0 on /dev/loop1 start PE 0 length 1.


Version-Release number of selected component (if applicable):
lvm 2.02.96

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

As a workaround - set issue_discards=0

Comment 2 Milan Broz 2012-06-15 10:21:47 UTC
This is critical bug btw, it means that you will lose your data completely if using pvmove with issue_discards=1.

Comment 3 Zdenek Kabelac 2012-06-15 13:33:16 UTC
Original report from lvm-devel list:

https://www.redhat.com/archives/lvm-devel/2012-June/msg00025.html

Comment 5 Alasdair Kergon 2012-06-15 13:39:12 UTC
Note that issue_discards is NOT enabled by default.  So this only affects people who explicitly turned it on.

Comment 7 Martin Prpič 2012-06-15 14:22:53 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When issue_discards=1 is configured in the /etc/lvm/lvm.conf file, moving physical volumes via the pvmove command results in data loss. To work around this issue, ensure that issue_discards=0 is set in your lvm.conf file before moving any physical volumes.

Comment 8 Alasdair Kergon 2012-06-15 18:46:35 UTC
Discards are issued when releasing a PV segment.  But this code is used both when deleting the space AND when moving it elsewhere.  (Need to check whether or not some lvconvert code paths are affected too.)

The code was added in 2.02.85, so RHEL6.2 might be affected too.

Comment 10 Corey Marthaler 2012-07-27 15:58:52 UTC
Adding QA ack for 6.4. 

Devel will need to provide unit testing results however before this bug can be
ultimately verified by QA.

Comment 11 Tom Coughlan 2012-08-13 14:43:57 UTC
If I understand correctly, if this patch goes in, then the current Technical Note 

("...issue_discards=1...results in data loss...ensure that issue_discards=0 is set in your lvm.conf file before moving any physical volumes.")

is not needed in 6.4. 

It is needed in earlier releases. (Should we propose the fix for 6.3.z?)

Comment 13 Alasdair Kergon 2012-08-13 19:08:34 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-When issue_discards=1 is configured in the /etc/lvm/lvm.conf file, moving physical volumes via the pvmove command results in data loss. To work around this issue, ensure that issue_discards=0 is set in your lvm.conf file before moving any physical volumes.+Without this fix, when issue_discards=1 is configured in the /etc/lvm/lvm.conf file, moving physical volumes via the pvmove command results in data loss.

Comment 16 Nenad Peric 2012-10-23 06:17:40 UTC
Moving to Verified (SanityOnly).

All single machine pvmove regression tests passed.

kernel-2.6.32-330.el6.x86_64
lvm2-2.02.98-2.el6.x86_64
device-mapper-1.02.77-2.el6.x86_64

Comment 17 errata-xmlrpc 2013-02-21 08:10:41 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-0501.html