Bug 83181 - TRIM/discard fails when using TRIM enabled USB memory sticks (and USB3-SATA2 adaptors)
Summary: TRIM/discard fails when using TRIM enabled USB memory sticks (and USB3-SATA2 ...
Status: NEW
Alias: None
Product: IO/Storage
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: io_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-25 16:25 UTC by John
Modified: 2018-08-18 10:47 UTC (History)
3 users (show)

See Also:
Kernel Version: 3.15.10-200.fc20.x86_64
Tree: Fedora
Regression: No


Attachments

Description John 2014-08-25 16:25:45 UTC
On a fully updated F20 machine hdparm shows that TRIM is supported on this Corsair
USB stick but both "fstrim" and "mount -o discard" commands fail
I have replicated the problem using an Addonics eSATAp to USB3 adaptor and a modern SSD.
ioctl/FITRIM problem

Details
ja@paxos ~ 1$ uname -a
Linux paxos 3.15.10-200.fc20.x86_64 #1 SMP Thu Aug 14 15:39:24 UTC 2014
x86_64 x86_64 x86_64 GNU/Linux

[root@paxos:~]$ hdparm -I /dev/sdb
ATA device, with non-removable media
        Model Number:       Voyager GTX                             
        Serial Number:      FF1807470C0800110923
        Firmware Revision:  S9FM01.7
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II
Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
...
           *    Data Set Management TRIM supported (limit 8 blocks)
...
------------------------------------------------------------------------
root@paxos:~]$ mount |grep sdb
/dev/sdb1 on /media/gtx type ext4 (rw,nosuid,nodev,noexec,noatime,seclabel,discard,data=ordered)
//-----------------------------------------------------------------
dmesg -ew
[Aug23 08:45] EXT4-fs (sdb1): mounting with "discard" option, but the device does not support discard
[  +0.000002] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: discard
[  +0.000004] SELinux: initialized (dev sdb1, type ext4), uses xattr
//-----------------------------------------------------------------
[root@paxos:~]$ cat /sys/block/sdb/queue/rotational
0
//-----------------------------------------------------------------
[root@paxos:~]$ fstrim -v /media/gtx
fstrim: /media/gtx: discard operation not supported.
//-----------------------------------------------------------------
[root@paxos:~]$ strace fstrim /media/gtx
...
stat("/media/gtx", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
open("/media/gtx", O_RDONLY)            = 3
ioctl(3, FITRIM, 0x7fffee2fb700)        = -1 EOPNOTSUPP (Operation not supported)
...

The latest references to the problem that I can find are given here
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1336541
http://askubuntu.com/questions/262154/trim-and-ssd-with-usb-3-0-enclosure-does-not-work-uasp-not-supported
but I can find no reference to a likely, timely solution
Comment 1 Ralph Corderoy 2018-08-18 10:47:35 UTC
The referenced launchpad bug suggests hdparm(8)'s --trim-sector-ranges works because it uses ATA commands directly.  fstrim(8) fails, even with ATA-passthrough SCSI command that lets smartctl(8) work, due to lack of usb-storage driver support.  Interesting comments start at #18 (no anchor available!) at https://bugs.launchpad.net/ubuntu/+source/linux-lts-xenial/+bug/1336541

Could someone knowledgeable in the this area take a look and the comments and give a summary of the problem.  Perhaps it can then be moved off the `io_other' component.

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