FSTRIM is not working for SSD + Quad SATA Hat

Manual invocation of fstrim fails like this.

   root@vault:/dev/disk# mount -t ext4 /dev/sdc1 /mnt/sdc1
   root@vault:/dev/disk# fstrim -v /mnt/sdc1
   fstrim: /mnt/sdc1: the discard operation is not supported

My goal is to setup a new Quad SATA Hat with 3 brand new Samsung EVO 860 1TB SSDs in RAID 5 with OMV. Following the instructions that all went reasonably well. While tweaking /lib/udev/rules.d/60-persistent-storage.rules, I did find my vendor string is “ACASIS”, not “JMicron”.

I was able to build the array and make a file-system… Just one last step that I know is necessary for SSDs, that is to ensure fstrim is working. lbdroidman provides an excellent description here: <
USB 3.0 pendrive > of the motivation for fstrim and the eventual consequences of not getting this right.

My guess is that the problem is with the USB implementation on the Quad SATA Hat. Curious thing I found while debugging… hdparm -I /dev/sda1 gives dramatically different results when using the QSH vs an old reliable NexStar USB enclosure… Note the “bad/missing sense data”, and truncated list of supported features. Support for TRIM appears in the list from NexStar, but not from QSH.

QSH results:

ATA device, with non-removable media
        Model Number:       Samsung SSD 860 EVO 1TB
        Serial Number:      S599NJ0N320089Y
        Firmware Revision:  80003040
Standards:
        Supported: 7 6 5 4
        Likely used: 7
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:    16514064
        LBA    user addressable sectors:   268435455
        LBA48  user addressable sectors:  1953525168
SG_IO: bad/missing sense data, sb[]:  70 00 0b 00 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        Logical  Sector size:                   512 bytes
        Physical Sector size:                   512 bytes
        device size with M = 1024*1024:      953869 MBytes
        device size with M = 1000*1000:     1000204 MBytes (1000 GB)
        cache/buffer size  = unknown
Capabilities:
        LBA, IORDY(can be disabled)
        Standby timer values: spec'd by Vendor, no device specific minimum
        R/W multiple sector transfer: Max = 1   Current = 1
        Advanced power management level: 1
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=240ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
                Write cache
                Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    NOP cmd
           *    Advanced Power Management feature set
                SET_MAX security extension
           *    48-bit Address feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Gen3 signaling speed (6.0Gb/s)
           *    Software settings preservation
Security:
                supported
        not     enabled
        not     locked
                frozen
        not     expired: security count
        not     supported: enhanced erase
        more than 508min for SECURITY ERASE UNIT.
Checksum: correct

NexStar results:

ATA device, with non-removable media
        Model Number:       Samsung SSD 860 EVO 1TB
        Serial Number:      S599NJ0N320089Y
        Firmware Revision:  RVT04B6Q
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
        Used: unknown (minor revision code 0x005e)
        Supported: 11 8 7 6 5
        Likely used: 11
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:    16514064
        LBA    user addressable sectors:   268435455
        LBA48  user addressable sectors:  1953525168
        Logical  Sector size:                   512 bytes
        Physical Sector size:                   512 bytes
        Logical Sector-0 offset:                  0 bytes
        device size with M = 1024*1024:      953869 MBytes
        device size with M = 1000*1000:     1000204 MBytes (1000 GB)
        cache/buffer size  = unknown
        Form Factor: 2.5 inch
        Nominal Media Rotation Rate: Solid State Device
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 1   Current = 1
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 udma6
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
           *    Write cache
           *    Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    NOP cmd
           *    DOWNLOAD_MICROCODE
                SET_MAX security extension
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
                Write-Read-Verify feature set
           *    WRITE_UNCORRECTABLE_EXT command
           *    {READ,WRITE}_DMA_EXT_GPL commands
           *    Segmented DOWNLOAD_MICROCODE
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Gen3 signaling speed (6.0Gb/s)
           *    Native Command Queueing (NCQ)
           *    Phy event counters
           *    READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
                DMA Setup Auto-Activate optimization
                Device-initiated interface power management
           *    Asynchronous notification (eg. media change)
           *    Software settings preservation
                Device Sleep (DEVSLP)
           *    SMART Command Transport (SCT) feature set
           *    SCT Write Same (AC2)
           *    SCT Error Recovery Control (AC3)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
           *    reserved 69[4]
           *    DOWNLOAD MICROCODE DMA command
           *    SET MAX SETPASSWORD/UNLOCK DMA commands
           *    WRITE BUFFER DMA command
           *    READ BUFFER DMA command
           *    Data Set Management TRIM supported (limit 8 blocks)
           *    Deterministic read ZEROs after TRIM
Security:
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
                supported: enhanced erase
        4min for SECURITY ERASE UNIT. 8min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5002538e30332bd5
        NAA             : 5
        IEEE OUI        : 002538
        Unique ID       : e30332bd5
Device Sleep:
        DEVSLP Exit Timeout (DETO): 50 ms (drive)
        Minimum DEVSLP Assertion Time (MDAT): 30 ms (drive)
Checksum: correct

We have consulted the chip supplier and learned that the chip does not support fstrim.

Sorry to hear that, as it goes strongly against the claimed support for SSD.
Is there a plan to remedy this in the next version of the hardware?

I really do hope that is the plan, and would not mind waiting a few months for it.

We are considering replacing the chip, and we still need time to evaluate it.

Great. Hope that you will allow me to contribute to any future QA and Beta-Test of FSTRIM support.
With it, as Quad-Sata-Hat fully delivers on the datasheet promise, we’ll have a most excellent widget.

Till then I will load up some HDD, and leave you with the recommendation that Radxa caution against use of Quad-Sata-Hat with SSD. -OR- provide a method to reactivate “lost blocks” by putting them back on the free list inside the SSD.

Ralph P
Mountain View, California