Bug 95751

Summary: SSD discard granularity (erase unit size) and "deterministic read zero" are not detected by kernel
Product: IO/Storage Reporter: Ivan Shapovalov (intelfx)
Component: Serial ATAAssignee: Tejun Heo (tj)
Status: NEW ---    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.19.2 Subsystem:
Regression: No Bisected commit-id:

Description Ivan Shapovalov 2015-03-28 05:02:59 UTC
At least with some SATA SSDs (OCZ Vertex 4 and Lite-on LSS-16L6G), when using the AHCI SATA driver, kernel cannot detect TRIM granularity and "deterministic read zero after TRIM" property, although both are correctly read by hdparm.

Following commands illustrate the bug:

$ lsblk -D /dev/disk/by-id/ata-LITEONIT_LSS-16L6G_S0C41154Z1ZSCA185984
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sdb           0      512B       2G         0
├─sdb1        0      512B       2G         0
├─sdb2        0      512B       2G         0
└─sdb3        0      512B       2G         0

# hdparm -I /dev/disk/by-id/ata-LITEONIT_LSS-16L6G_S0C41154Z1ZSCA185984 | grep TRIM
	   *	Data Set Management TRIM supported (limit 8 blocks)
	   *	Deterministic read ZEROs after TRIM

In lsblk output, columns DISC-GRAN and DISC-ZERO in all rows should have values 4K and 1, respectively.

Direct testing with `hdparm --trim-sector-ranges` and `hdparm --read-sector` demonstrates that hdparm output is the correct one.