Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2013 17:50:40 +0700
From:      Alexey Dokuchaev <danfe@nsu.ru>
To:        questions@freebsd.org
Subject:   Re: TRIM support on SSD via ata(4)
Message-ID:  <20130122105039.GA11236@regency.nsu.ru>
In-Reply-To: <20130122051346.GA53833@regency.nsu.ru>
References:  <20130122051346.GA53833@regency.nsu.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130122105039.GA11236>