Bug 1043527 - devicemapper thin provisioning doesn't DISCARD when removing devices
Summary: devicemapper thin provisioning doesn't DISCARD when removing devices
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 20
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Joe Thornber
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: 1045300 1060381 1083263
TreeView+ depends on / blocked
Reported: 2013-12-16 14:55 UTC by Alexander Larsson
Modified: 2019-07-23 21:32 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1045300 1083263 (view as bug list)
Last Closed: 2014-03-17 18:43:45 UTC
Type: Bug

Attachments (Terms of Use)
Example script (1.25 KB, application/x-shellscript)
2013-12-16 15:00 UTC, Alexander Larsson
no flags Details
Script trying to workaround this (1.68 KB, application/x-shellscript)
2013-12-16 16:35 UTC, Alexander Larsson
no flags Details

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:

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: 

Comment 5 Mike Snitzer 2013-12-18 13:55:17 UTC
Please try this commit:

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.

Note You need to log in before you can comment on or make changes to this bug.