10 April 2013
I've got a shiny new SSD which I'm playing with in FreeBSD. There doesn't seem to be an easy way to TRIM the device, other than using newfs -E -t
, which leaves a UFS behind, so I wrote my own: trim.c
# ./trim /dev/ada4
Although the SSD reports a sector size of 512 bytes, it won't TRIM a block smaller than 4K, and it won't be efficient about it until about the 2MB mark.
I've also noticed that if I write a block, then immediately TRIM it, it doesn't work. Sleeping for a second and re-issuing the TRIM makes it work.
Sometimes, the SSD silently fails to TRIM. The tool I wrote verifies and reports this.
Here's the SMART data for my SSD:
# smartctl -i /dev/ada4 Model Family: Intel 520 Series SSDs Device Model: INTEL SSDSC2CW120A3 Firmware Version: 400i User Capacity: 120,034,123,776 bytes [120 GB] Sector Size: 512 bytes logical/physical Rotation Rate: Solid State Device Device is: In smartctl database [for details use: -P show] ATA Version is: ACS-2 T13/2015-D revision 3 SATA Version is: SATA 3.0, 3.0 Gb/s (current: 3.0 Gb/s) SMART support is: Available - device has SMART capability. SMART support is: Enabled # camcontrol identify ada4 pass4: <INTEL SSDSC2CW120A3 400i> ATA-9 SATA 2.x device pass4: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes) protocol ATA/ATAPI-9 SATA 2.x device model INTEL SSDSC2CW120A3 firmware revision 400i cylinders 16383 heads 16 sectors/track 63 sector size logical 512, physical 512, offset 0 LBA supported 234441648 sectors LBA48 supported 234441648 sectors PIO supported PIO4 DMA supported WDMA2 UDMA6 media RPM non-rotating Feature Support Enabled Value read ahead yes yes write cache yes yes flush cache yes yes overlap no Tagged Command Queuing (TCQ) no no Native Command Queuing (NCQ) yes 32 tags SMART yes yes microcode download yes yes security yes no power management yes yes advanced power management yes yes 254/0xFE automatic acoustic management no no media status notification no no power-up in Standby yes no write-read-verify no no unload yes yes free-fall no no data set management (TRIM) yes
And some performance estimates:
# diskinfo -ctv /dev/ada4 /dev/ada4 512 # sectorsize 120034123776 # mediasize in bytes (111G) 234441648 # mediasize in sectors 0 # stripesize 0 # stripeoffset 232581 # Cylinders according to firmware. 16 # Heads according to firmware. 63 # Sectors according to firmware. I/O command overhead: time to read 10MB block 0.045524 sec = 0.002 msec/sector time to read 20480 sectors 0.863500 sec = 0.042 msec/sector calculated command overhead = 0.040 msec/sector Seek times: Full stroke: 250 iter in 0.024130 sec = 0.097 msec Half stroke: 250 iter in 0.029164 sec = 0.117 msec Quarter stroke: 500 iter in 0.056782 sec = 0.114 msec Short forward: 400 iter in 0.040810 sec = 0.102 msec Short backward: 400 iter in 0.040303 sec = 0.101 msec Seq outer: 2048 iter in 0.088492 sec = 0.043 msec Seq inner: 2048 iter in 0.087823 sec = 0.043 msec Transfer rates: outside: 102400 kbytes in 0.432411 sec = 236812 kbytes/sec middle: 102400 kbytes in 0.431852 sec = 237118 kbytes/sec inside: 102400 kbytes in 0.422050 sec = 242625 kbytes/sec
Update (Apr 2021): smartctl reports the above SSD as having:
TRIM Command: Available, deterministic
Whereas a newer Samsung has:
TRIM Command: Available, deterministic, zeroed
And doesn't have the problem of ignoring TRIM commands sometimes.