RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 814766 - Provide configurable discard options for thin volumes
Summary: Provide configurable discard options for thin volumes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2
Version: 6.4
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: 6.4
Assignee: Zdenek Kabelac
QA Contact: Cluster QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-04-20 15:32 UTC by Alasdair Kergon
Modified: 2013-02-21 08:09 UTC (History)
11 users (show)

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.
Clone Of:
Environment:
Last Closed: 2013-02-21 08:09:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:0501 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2013-02-20 21:30:45 UTC

Description Alasdair Kergon 2012-04-20 15:32:51 UTC
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 17:36:57 UTC
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 17:55:19 UTC
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 Program Management 2012-07-10 06:07:34 UTC
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 Program Management 2012-07-10 23:57:14 UTC
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 13:07:18 UTC
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 09:15:06 UTC
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 09:14:36 UTC
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 09:19:22 UTC
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 09:34:46 UTC
Nope - I'll check this

Comment 15 Corey Marthaler 2013-01-23 23:05:12 UTC
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 23:29:43 UTC
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 08:09:26 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


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