Bug 1390148

Summary: discard operation is not supported on SSD disk
Product: Red Hat Enterprise Linux 7 Reporter: Maurizio Lombardi <mlombard>
Component: kernelAssignee: LVM and device-mapper development team <lvm-team>
kernel sub component: Device Mapper QA Contact: Storage QE <storage-qe>
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, msnitzer
Version: 7.2   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-31 11:43:12 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:

Description Maurizio Lombardi 2016-10-31 10:21:17 UTC
Description of problem:

fstrim fails despite the fact the SSD disk supports TRIM.

# fstrim -v /
fstrim: /: the discard operation is not supported

$ sudo hdparm -I /dev/sda | grep TRIM
*	Data Set Management TRIM supported (limit 8 blocks)

$ lsblk 
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                             8:0    0 465.8G  0 disk  
├─sda1                                          8:1    0   500M  0 part  /boot
└─sda2                                          8:2    0 465.3G  0 part  
  └─luks-87671703-29ad-4572-a663-bda2d7bb1ac7 253:0    0 465.3G  0 crypt 
    ├─rhel_dhcp--27--244-root                 253:1    0    50G  0 lvm   /
    └─rhel_dhcp--27--244-home                 253:2    0 415.3G  0 lvm   /home

$ dmesg |grep SSD
[    1.423002] ata1.00: ATA-9: Samsung SSD 850 EVO 500GB, EMT02B6Q, max UDMA/133
[    1.424294] scsi 0:0:0:0: Direct-Access     ATA      Samsung SSD 850  2B6Q PQ: 0 ANSI: 5

$ uname -a
Linux annapurna 3.10.0-327.36.2.el7.x86_64 #1 SMP Tue Sep 27 16:01:21 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

Comment 1 Ondrej Kozina 2016-10-31 10:36:33 UTC
Hi Maurizio,

dm-crypt doesn't enable discard by default and this is not going to change (in kernel). First due to security reasons and secondly due to fact that you may destroy existing hidden volume in legacy true-crypt containers with discard enabled by default. Single fstrim on such volumes and hidden volume is gone for good:)

On the other hand starting with cryptsetup 2.0 we will change the userspace so that any LUKSv2 containers is by default activated with discard enabled.

Wrt to LUKSv1 you may change the default by adding appropriate discard option in /etc/crypttab.