Bug 1043527

Summary: devicemapper thin provisioning doesn't DISCARD when removing devices
Product: [Fedora] Fedora Reporter: Alexander Larsson <alexl>
Component: kernelAssignee: Joe Thornber <thornber>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: agk, alexl, gansalmon, itamar, jonathan, kernel-maint, kheal, madhu.chinakonda, mclasen, msnitzer, sct
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1045300 1083263 (view as bug list) Environment:
Last Closed: 2014-03-17 18:43:45 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: 1045300, 1060381, 1083263    
Attachments:
Description Flags
Example script
none
Script trying to workaround this none

Description Alexander Larsson 2013-12-16 14:55:26 UTC
Description of problem:


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Alexander Larsson 2013-12-16 14:58:31 UTC
Ugh, sorry about that, pressed enter early. 

Anyway, if i remove a file on a thinly provisioned device we correctly
pass down DISCARDS to the underlying device. However, we don't do this
when entire thin provisioning devices are deleted.

This is currenly hurting the docker devicemapper backend, but I'll be adding 
a workaround for it. However, it may still be a problem for others.

Attaching a test script that shows this using a loopback mount.

Comment 2 Alexander Larsson 2013-12-16 15:00:27 UTC
Created attachment 837255 [details]
Example script

This script creates a loopback based thinp device to show off the bug.
Remove the comment on the blkdiscard line to demo a workaround

Comment 3 Alexander Larsson 2013-12-16 16:35:45 UTC
Created attachment 837331 [details]
Script trying to workaround this

The workaround of calling blkdiscard on the device before deleting the thin partition device only works on an unshared device. If you ever had any snapshots of the device it doesn't work.

Attached here is an example script that (if you pass it an argument) creates a single device, snapshots it and then deletes first the snapshot then the base, blkdiscarding both, it doesn't free any data in the loopback file. If you don't pass it an argument it creates/destroys only the base image and we fully regain all space.

Any idea how we can regain all space in the snapshoted case?

Comment 4 Alexander Larsson 2013-12-17 08:54:39 UTC
For reference, here is the upstream Docker issue: 
https://github.com/dotcloud/docker/issues/3182

Comment 5 Mike Snitzer 2013-12-18 13:55:17 UTC
Please try this commit:
http://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=for-next&id=6d03f6ac888f2cfc9c840db0b965436d32f1816d

It should work for the case described in comment#3 (with or without argument).  Please respond with your test results.

In the near-term, DM thin provisioning will not be automatically issuing discards when mappings are removed or thin devices deleted.  We can look to do it but it isn't a high priority.  thinp relies on upper layers to initiate discards.

Comment 7 Josh Boyer 2014-01-08 21:28:31 UTC
Alex, do you need someone to build a scratch kernel with the patch Mike pointed to or can you build your own for testing?

Comment 8 Justin M. Forbes 2014-03-17 18:43:45 UTC
*********** MASS BUG UPDATE **************

This bug has been in a needinfo state for several weeks and is being closed with insufficient data due to inactivity. If this is still an issue with Fedora 20, please feel free to reopen the bug and provide the additional information requested.