TRIM support on SSD via ata(4)
Alexey Dokuchaev
danfe at nsu.ru
Tue Jan 22 10:50:08 UTC 2013
On Tue, Jan 22, 2013 at 12:13:46PM +0700, Alexey Dokuchaev wrote:
> Unfortunately, I cannot use ahci(4) and limited to atacontrol(8), which
> does not have "identify" command like camcontrol(8). Shall I recompile the
> kernel with ATA_CAM option?
I've switched to ATA_CAM and removed atadisk from /boot/loader.conf. CAM
driver reported flags 0x896, which includes ADA_FLAG_CAN_TRIM (0x080). In
adaregister() of /sys/cam/ata/ata_da.c, this is enough to in turn enable
DISKFLAG_CANDELETE disk flag:
if ((softc->flags & ADA_FLAG_CAN_TRIM) ||
((softc->flags & ADA_FLAG_CAN_CFA) &&
!(softc->flags & ADA_FLAG_CAN_48BIT)))
softc->disk->d_flags |= DISKFLAG_CANDELETE;
In /sys/dev/ata/ata-disk.c, this check is different:
if ((atadev->param.support.command2 & ATA_SUPPORT_CFA) ||
atadev->param.config == ATA_PROTO_CFA)
adp->disk->d_flags |= DISKFLAG_CANDELETE;
Since this disk evidently does not support CFA, ata(4) was not raising
DISKFLAG_CANDELETE flag.
With CAM_ATA, I can now use camcontrol(8) to talk to my disks:
# camcontrol identify ada0 | egrep TRIM\|Feature
Feature Support Enabled Value Vendor
data set management (TRIM) yes
"TRIM on fs but drive does not have it" warning is gone. I wonder why
legacy ata(4) did not enable TRIM though.
./danfe
More information about the freebsd-questions
mailing list