Bug 1274676

Summary: Resize of full thin-pool looses data
Product: Red Hat Enterprise Linux 7 Reporter: Zdenek Kabelac <zkabelac>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Thin Provisioning QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact: Milan Navratil <mnavrati>
Severity: high    
Priority: unspecified CC: agk, cmarthal, dhoward, heinzm, jbrassow, jkurik, lmiksik, msnitzer, prajnoha, prockai, rbednar, slevine, thornber, zkabelac
Version: 7.2Keywords: ZStream
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.02.152-1.el7 Doc Type: Bug Fix
Doc Text:
When using thin-provisioning, buffered writes are no longer lost when the thin pool reaches capacity Previously, a resize operation, even an automated one, attempted to flush outstanding I/O to the storage device prior to the resize being performed. Since there was no room in the thin pool, the I/O operations had to be errored first to allow the grow to succeed. As a consequence, if a thin-pool was filled to capacity, some writes could be lost even if the pool was being grown at that time. With this update, buffered writes are no longer lost to the thin-pool in the described situation.
Story Points: ---
Clone Of:
: 1286737 (view as bug list) Environment:
Last Closed: 2016-11-04 04:11:42 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: 1286737    
Attachments:
Description Flags
https://www.redhat.com/archives/lvm-devel/2015-October/msg00142.html
none
https://www.redhat.com/archives/lvm-devel/2015-October/msg00156.html
none
https://www.redhat.com/archives/lvm-devel/2015-October/msg00143.html
none
https://www.redhat.com/archives/lvm-devel/2015-October/msg00144.html
none
Testing script (for lvm2 test suite) none

Description Zdenek Kabelac 2015-10-23 10:37:17 UTC
Description of problem:

lvm2 design should allow resize of the thin-pool which gets 100% full - however it's not doing it correctly.

It leaves resize on 'dmeventd' - which notices pool is being full and runs 'lvextend --use-policies' - however this resize operation runs 'suspend' with 'flush' - this cannot pass since pool is already full in this case.
But - the existing dmeventd send itself ALRM signal and releases itself from suspend and exits hiddenly, but  pool 60s timeout releases 'preasure' by erroring all 'in-flight' operation - so next retry to resize succeeds.

Pool appears to be 'resize' and working - so the problem of loosing buffer-cached writes is quite well hidden.

Version-Release number of selected component (if applicable):
lvm2  2.02.132

How reproducible:


Steps to Reproduce:
1. fill thin-pool 100% with writes
2. check till pool is resize
3. retest writes

Actual results:


Expected results:


Additional info:

Comment 6 Zdenek Kabelac 2015-11-20 21:14:24 UTC
Attaching 'minimized' patchset which avoid usage of flush with suspend when resizing thin-pool.

It's worth to note here - if the 'extension' of thin-pool data LV is 'big' enough to handle whole 'flush' data will not be lost.

Providing also some example (fits into lvm2 test suite) how to test issue.

Comment 11 Zdenek Kabelac 2015-11-20 21:24:56 UTC
Created attachment 1097321 [details]
Testing script  (for lvm2 test suite)

Testing data-lost during write to pool which needs resize,
and lvextend happens in parallel (e.g. via dmeventd)

Comment 13 Mike McCune 2016-03-28 23:48:44 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 15 Roman Bednář 2016-09-20 15:13:43 UTC
Marking verified. No data loss occured while extending 100% full thin pool.

# bash -x test.sh 
+ vg=vg
+ lv=test_lv
+ vgcreate -s 512K vg /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde
  Volume group "vg" successfully created
+ lvcreate -L1M -V2M -n test_lv vg/pool
  Using default stripesize 64.00 KiB.
  WARNING: Sum of all thin volume sizes (2.00 MiB) exceeds the size of thin pool vg/pool (1.00 MiB)!
  For thin pool auto extension activation/thin_pool_autoextend_threshold should be below 100.
  Logical volume "test_lv" created.
+ seq 0 315465
+ cut -f 1 -d ' '
+ tee MD5
+ md5sum 2M
0ebb1b10c6b3e4ff62d1f2350af86ffb
+ sleep .1
+ dd if=2M of=/dev/mapper/vg-test_lv bs=512K conv=fdatasync
+ lvs -a vg
  LV              VG Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  [lvol0_pmspare] vg ewi------- 2.00m                                                    
  pool            vg twi-aotzD- 1.00m             100.00 1.95                            
  [pool_tdata]    vg Twi-ao---- 1.00m                                                    
  [pool_tmeta]    vg ewi-ao---- 2.00m                                                    
  test_lv         vg Vwi-aotz-- 2.00m pool        50.00                                  
+ lvextend -L+512k vg/pool
  WARNING: Sum of all thin volume sizes (2.00 MiB) exceeds the size of thin pools (1.50 MiB)!
  For thin pool auto extension activation/thin_pool_autoextend_threshold should be below 100.
  Size of logical volume vg/pool_tdata changed from 1.00 MiB (2 extents) to 1.50 MiB (3 extents).
  Logical volume vg/pool_tdata successfully resized.
+ lvextend -L+512k vg/pool
  Size of logical volume vg/pool_tdata changed from 1.50 MiB (3 extents) to 2.00 MiB (4 extents).
4+0 records in
4+0 records out
2097152 bytes (2.1 MB) copied, 0.838726 s, 2.5 MB/s
  Logical volume vg/pool_tdata successfully resized.
+ wait
+ cat log
+ lvs -a vg
  LV              VG Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  [lvol0_pmspare] vg ewi------- 2.00m                                                    
  pool            vg twi-aotz-- 2.00m             100.00 1.95                            
  [pool_tdata]    vg Twi-ao---- 2.00m                                                    
  [pool_tmeta]    vg ewi-ao---- 2.00m                                                    
  test_lv         vg Vwi-a-tz-- 2.00m pool        100.00                                 
+ dd if=/dev/mapper/vg-test_lv of=2M-2 iflag=direct
4096+0 records in
4096+0 records out
2097152 bytes (2.1 MB) copied, 2.13775 s, 981 kB/s
+ cut -f 1 -d ' '
+ tee MD5-2
+ md5sum 2M-2
0ebb1b10c6b3e4ff62d1f2350af86ffb
+ diff MD5 MD5-2
+ vgremove -f vg
  Logical volume "test_lv" successfully removed
  Logical volume "pool" successfully removed
  Volume group "vg" successfully removed




3.10.0-505.el7.x86_64

lvm2-2.02.165-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
lvm2-libs-2.02.165-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
lvm2-cluster-2.02.165-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
device-mapper-1.02.134-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
device-mapper-libs-1.02.134-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
device-mapper-event-1.02.134-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
device-mapper-event-libs-1.02.134-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016
device-mapper-persistent-data-0.6.3-1.el7    BUILT: Fri Jul 22 12:29:13 CEST 2016
cmirror-2.02.165-2.el7    BUILT: Wed Sep 14 16:01:43 CEST 2016

Comment 17 errata-xmlrpc 2016-11-04 04:11:42 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.

https://rhn.redhat.com/errata/RHBA-2016-1445.html