Opened 13 years ago

Closed 9 years ago

#7876 closed enhancement (fixed)

TRIM support for SSDs

Reported by: polari Owned by: axeld
Priority: normal Milestone: R1
Component: File Systems/BFS Version: R1/Development
Keywords: Cc: kallisti5
Blocked By: Blocking:
Platform: All

Description

Haiku/BFS should support the TRIM command for solid state drives. http://en.wikipedia.org/wiki/TRIM

Change History (9)

comment:1 by pulkomandy, 13 years ago

I just bought an SSD to speed up building Haiku sourcecode a bit.

Any hint on where to work on this in Haiku's architecture ? block cache ? file cache ? filesystem ?

comment:2 by bonefish, 13 years ago

Only the file system knows, when it no longer uses a block. So an API must be provided that can be used by the file system. The file cache doesn't know about disks at all, so you don't want to touch that one at all. The block cache does, but its use is optional. So, for convenience, the block cache API can be extended (or maybe doesn't even need to -- there already is a block_cache_discard()), but it cannot be the only API.

What is needed in either case is a new ioctl operation (maybe plus a nicer-to-use wrapper function) that gets propagated to the driver which can issue the command to the hardware. I'm not really familiar with the disk I/O stack (several modules are involved). I believe the simplified call chain is "device -> bus manager -> driver", but since both the ATA and the SCSI stack are involved plus (IIRC) a few helper modules, the chain is probably more than twice as long. Maybe someone who is more familiar with this stuff can give some further hints.

It might also be worthwhile to have a way to query whether trimming is supported, so the invocations can be omitted when not needed. In the case either a second ioctl operation could be added or an existing querying operation could be extended (there isn't any usable padding in the device_geometry structure used by B_GET_GEOMETRY, though).

comment:3 by kallisti5, 13 years ago

Cc: kallisti5 added

For tracking:

  • hrev43845 - PulkoMandy added the ATA "data_set_management_support" (trim) flag to ata_device_infoblock
  • hrev44228 - I added a trace dump of the data_set_management_support to the ahci driver (which seems to be the only add-on using ata_device_infoblock at the moment)

comment:4 by kallisti5, 12 years ago

  • hrev44238 - I added a the SCSI_OP_WRITE_SAME command to the ahci driver to perform a trim request. (doesn't actually perform the trim yet though... just check for support and raise a syslog event)
Last edited 12 years ago by kallisti5 (previous) (diff)

comment:5 by axeld, 11 years ago

I'm working on a support pretty much like fstrim in Linux. I have no idea how to test it, though, as I don't have a spare SSD or partition on it. Anyone has any idea?

comment:6 by axeld, 11 years ago

Status: newin-progress

comment:7 by anevilyak, 11 years ago

I'd be willing to test on my ssd here if you want to supply a patch once ready.

comment:8 by kallisti5, 11 years ago

I have a 24GB PCIe SSD in my Ultrabook that is dedicated to Haiku (and supports TRIM)

As loss of data on the 24GB SSD is a pain but non-catastrophic, count me in as well.

comment:9 by axeld, 9 years ago

Resolution: fixed
Status: in-progressclosed

The feature is already implemented, although it does not work yet -- but we have ticket #10336 for this. The trimming has to be triggered, though, it doesn't happen in the background. If that is desired, we can open a new ticket for this, though.

Note: See TracTickets for help on using tickets.