From owner-freebsd-questions@FreeBSD.ORG Tue Jan 22 10:50:08 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 475373AF for ; Tue, 22 Jan 2013 10:50:08 +0000 (UTC) (envelope-from danfe@regency.nsu.ru) Received: from mx.nsu.ru (mx.nsu.ru [84.237.50.39]) by mx1.freebsd.org (Postfix) with ESMTP id E72438CC for ; Tue, 22 Jan 2013 10:50:07 +0000 (UTC) Received: from regency.nsu.ru ([193.124.210.26]) by mx.nsu.ru with esmtp (Exim 4.69) (envelope-from ) id 1TxbQG-0000yY-UP for questions@freebsd.org; Tue, 22 Jan 2013 17:49:44 +0700 Received: from regency.nsu.ru (localhost [127.0.0.1]) by regency.nsu.ru (8.14.2/8.14.2) with ESMTP id r0MAp1Z1015397 for ; Tue, 22 Jan 2013 17:51:02 +0700 (NOVT) (envelope-from danfe@regency.nsu.ru) Received: (from danfe@localhost) by regency.nsu.ru (8.14.2/8.14.2/Submit) id r0MAoebu015355 for questions@freebsd.org; Tue, 22 Jan 2013 17:50:40 +0700 (NOVT) (envelope-from danfe) Date: Tue, 22 Jan 2013 17:50:40 +0700 From: Alexey Dokuchaev To: questions@freebsd.org Subject: Re: TRIM support on SSD via ata(4) Message-ID: <20130122105039.GA11236@regency.nsu.ru> References: <20130122051346.GA53833@regency.nsu.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130122051346.GA53833@regency.nsu.ru> User-Agent: Mutt/1.4.2.1i X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2013 10:50:08 -0000 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