Bug 814766 - Provide configurable discard options for thin volumes
Provide configurable discard options for thin volumes
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2 (Show other bugs)
6.4
Unspecified Linux
medium Severity medium
: rc
: 6.4
Assigned To: Zdenek Kabelac
Cluster QE
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-20 11:32 EDT by Alasdair Kergon
Modified: 2013-02-21 03:09 EST (History)
11 users (show)

See Also:
Fixed In Version: lvm2-2.02.98-1.el6
Doc Type: Enhancement
Doc Text:
Thin pool support has been enhanced with configurable discards support. A user may select from 3 types of behavior. "passdown" is default and allows to pass-through discards requests to the thin pool backing device. "nopassdown" is processing discards only on thin pool level, they are not passed to the backed device. "ignore" simply ignores any discard request. No default behavior might be useful to fine-tune performance for some workloads.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-21 03:09:26 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alasdair Kergon 2012-04-20 11:32:51 EDT
Recent upstream kernel patches for the thin target support discards with optional 'passthrough' to underlying devices.

Expose this functionality in LVM.
Comment 1 Alasdair Kergon 2012-06-20 13:36:57 EDT
Scope: Initially the LVM support should map directly onto the kernel support.  (Further extensions like checking sysfs in advance and dmeventd fstrim will be considered later on a different bugzilla.)

Kernel options (on the pool target) are:
      ignore_discard: Disable discard support.

      no_discard_passdown: Don't pass discards down to the underlying
                           data device, but just remove the mapping.

LVM already has in lvm.conf
devices {

    # Issue discards to a logical volumes's underlying physical volume(s) when
    # the logical volume is no longer using the physical volumes' space (e.g.
    # lvremove, lvreduce, etc).  Discards inform the storage that a region is
    # no longer in use.  Storage that supports discards advertise the protocol
    # specific way discards should be issued by the kernel (TRIM, UNMAP, or
    # WRITE SAME with UNMAP bit set).  Not all storage will support or benefit
    # from discards but SSDs and thinly provisioned LUNs generally do.  If set
    # to 1, discards will only be issued if both the storage and kernel provide
    # support.
    # 1 enables; 0 disables.
    issue_discards = 0
}
Comment 2 Alasdair Kergon 2012-06-20 13:55:19 EDT
1. lvm.conf activation setting
2. VG metadata LV segment parameter
3. lvcreate/lvchange cmdline option - writes into the VG metadata

Two separate parameters or combined?
Defaults?
Precedence?
Comment 3 RHEL Product and Program Management 2012-07-10 02:07:34 EDT
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.
Comment 4 RHEL Product and Program Management 2012-07-10 19:57:14 EDT
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.
Comment 7 Zdenek Kabelac 2012-10-08 09:07:18 EDT
Support for discard is uptream:

Initial patch for this support starts here:

https://www.redhat.com/archives/lvm-devel/2012-July/msg00034.html

Several more patches followed which reordered some enum values and fixed default behavior for thin target drivers with and without discard support.

Supported command line options for this:

lvcreate --discards  {ignore|nopassdown|passdown}

For pre-discard thins the default is   'ignore'
For discard-enabled thins the default is  'passdown' 

lvchange --discards  {ignore|nopassdown|passdown}
Comment 8 Zdenek Kabelac 2012-10-12 05:15:06 EDT
Here is unit test for this feature:


# Create named pool only
lvcreate -l1 --discards ignore -T vg/pool

check lv_field vg/pool discards "ignore"

lvcreate -l1 --discards nopassdown -T vg/pool1

check lv_field vg/pool1 discards "nopassdown"

lvcreate -l1 --discards passdown -T vg/pool2

check lv_field vg/pool2 discards "passdown"

lvchange --discards nopassdown vg/pool2

# cannot convert active  ignore -> passdown
not lvchange --discards passdown vg/pool

# cannot convert active  nopassdown -> ignore
not lvchange --discards ignore vg/pool1

# deactivate

lvchange -an vg/pool vg/pool1
lvchange --discards passdown vg/pool

check lv_field $vg/pool discards "passdown"

lvchange --discards ignore vg/pool1

check lv_field vg/pool1 discards "ignore"
Comment 12 Nenad Peric 2013-01-11 04:14:36 EST
The creation of thin pools and a thin LV with discards support was successful as far as lv_fields goes:

(03:05:42) [root@r6-node01:~]$ lvs -o +discards
  LV      VG       Attr      LSize  Pool  Origin Data%  Move Log Cpy%Sync Convert Discards  
  lv_root VolGroup -wi-ao---  7.54g                                                         
  lv_swap VolGroup -wi-ao---  1.97g                                                         
  pool    vg       twi-a-tz-  4.00m                0.00                           ignore    
  pool1   vg       twi-a-tz-  4.00m                0.00                           nopassdown
  pool2   vg       twi-a-tz-  4.00m                0.00                           passdown  
  thinlv0 vg       Vwi-a-tz- 12.00m pool           0.00                           ignore    
  thinlv1 vg       Vwi-a-tz- 12.00m pool1          0.00                           nopassdown
  thinlv2 vg       Vwi-a-tz- 12.00m pool2          0.00                           passdown
Comment 13 Nenad Peric 2013-01-11 04:19:22 EST
Is it expected that an activation of thin pool LV which was changed from ignore -> passdown is not successful?


(03:12:55) [root@r6-node01:~]$ lvcreate -l5 --discards ignore -T vg/pool
  Logical volume "pool" created
(03:13:40) [root@r6-node01:~]$ lvs -o +discards
  LV      VG       Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert Discards
  lv_root VolGroup -wi-ao---  7.54g                                                      
  lv_swap VolGroup -wi-ao---  1.97g                                                      
  pool    vg       twi-a-tz- 20.00m               0.00                           ignore  
(03:13:50) [root@r6-node01:~]$ lvcreate -T -V10M --name=thinlv0 vg/pool
  Rounding up size to full physical extent 12.00 MiB
  Logical volume "thinlv0" created
(03:14:06) [root@r6-node01:~]$ lvs -o +discards
  LV      VG       Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert Discards
  lv_root VolGroup -wi-ao---  7.54g                                                      
  lv_swap VolGroup -wi-ao---  1.97g                                                      
  pool    vg       twi-a-tz- 20.00m               0.00                           ignore  
  thinlv0 vg       Vwi-a-tz- 12.00m pool          0.00                           ignore  

(03:14:09) [root@r6-node01:~]$ lvchange --discards passdown vg/pool
  Cannot change discards state for active logical volume "pool".
(03:14:21) [root@r6-node01:~]$ lvchange -an vg/pool
(03:14:31) [root@r6-node01:~]$ lvchange --discards passdown vg/pool
  Logical volume "pool" changed
(03:14:40) [root@r6-node01:~]$ lvs -o +discards
  LV      VG       Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert Discards
  lv_root VolGroup -wi-ao---  7.54g                                                      
  lv_swap VolGroup -wi-ao---  1.97g                                                      
  pool    vg       twi---tz- 20.00m               0.00                           passdown
  thinlv0 vg       Vwi-a-tz- 12.00m pool          0.00                           passdown

(03:14:50) [root@r6-node01:~]$ lvchange -ay vg/pool
  device-mapper: reload ioctl on  failed: Invalid argument


(03:16:31) [root@r6-node01:~]$ dmsetup ls --tree
VolGroup-lv_swap (253:1)
 └─ (252:2)
VolGroup-lv_root (253:0)
 └─ (252:2)
vg-thinlv0 (253:6)
 └─vg-pool-tpool (253:4)
    ├─vg-pool_tdata (253:3)
    │  └─ (8:1)
    └─vg-pool_tmeta (253:2)
       └─ (8:129)




vgchange -an vg && vgchange -ay vg works without issues though:

(03:16:36) [root@r6-node01:~]$ vgchange -an vg && vgchange -ay vg
  0 logical volume(s) in volume group "vg" now active
  2 logical volume(s) in volume group "vg" now active
Comment 14 Zdenek Kabelac 2013-01-11 04:34:46 EST
Nope - I'll check this
Comment 15 Corey Marthaler 2013-01-23 18:05:12 EST
I filed bug 903411 for the issue Nenad saw in comment #13. I can reproduce it as well with the new discard options test cases.
Comment 16 Corey Marthaler 2013-01-23 18:29:43 EST
All the discard create/change combinations pass, marking this verified (SanityOnly) as I don't think bug 903411 is enough to block this feature.  


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



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
Removing [nopassdown] thinpool and corresponding thin virtual volume and thin snapshot

Creating [ignore] discards thinpool volume and converting it to [passdown] 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 passdown snapper_thinp/POOL
Removing [passdown] thinpool and corresponding thin virtual volume and thin snapshot

Creating [nopassdown] discards thinpool volume and converting it to [ignore] discards
lvcreate --thinpool POOL --discards nopassdown -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 ignore snapper_thinp/POOL
Removing [ignore] thinpool and corresponding thin virtual volume and thin snapshot

Creating [nopassdown] discards thinpool volume and converting it to [passdown] discards
lvcreate --thinpool POOL --discards nopassdown -L 2G snapper_thinp
lvcreate --virtualsize 500M --thinpool snapper_thinp/POOL -n origin
lvcreate -s /dev/snapper_thinp/origin -n snap
lvchange --discards passdown snapper_thinp/POOL
Removing [passdown] thinpool and corresponding thin virtual volume and thin snapshot

Creating [passdown] discards thinpool volume and converting it to [ignore] discards
lvcreate --thinpool POOL --discards passdown -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 ignore snapper_thinp/POOL
Removing [ignore] thinpool and corresponding thin virtual volume and thin snapshot

Creating [passdown] discards thinpool volume and converting it to [nopassdown] discards
lvcreate --thinpool POOL --discards passdown -L 2G snapper_thinp
lvcreate --virtualsize 500M --thinpool snapper_thinp/POOL -n origin
lvcreate -s /dev/snapper_thinp/origin -n snap
lvchange --discards nopassdown snapper_thinp/POOL
Removing [nopassdown] thinpool and corresponding thin virtual volume and thin snapshot
Comment 18 errata-xmlrpc 2013-02-21 03:09:26 EST
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

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