From owner-freebsd-hackers@freebsd.org Fri Nov 23 10:49:44 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DFF251142C23 for ; Fri, 23 Nov 2018 10:49:43 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from mail.0x20.net (mail.0x20.net [46.251.251.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "0x20.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52A31832BC for ; Fri, 23 Nov 2018 10:49:43 +0000 (UTC) (envelope-from lars@e.0x20.net) Received: from e.0x20.net (mail.0x20.net [46.251.251.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.0x20.net (Postfix) with ESMTPS id 073DC98744; Fri, 23 Nov 2018 11:42:07 +0100 (CET) Received: (from lars@localhost) by e.0x20.net (8.15.2/8.15.2/Submit) id wANAg5ds023519; Fri, 23 Nov 2018 11:42:05 +0100 (CET) (envelope-from lars) Date: Fri, 23 Nov 2018 11:42:05 +0100 From: Lars Engels To: Eugene Grosbein Cc: Warner Losh , FreeBSD Hackers Subject: Re: TRIM utility Message-ID: <20181123104205.GZ59358@e.0x20.net> References: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net> <6975ff4e-6383-e52c-3a11-d35b95cca114@grosbein.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6975ff4e-6383-e52c-3a11-d35b95cca114@grosbein.net> X-Editor: VIM - Vi IMproved 8.0 User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 52A31832BC X-Spamd-Result: default: False [0.88 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.36)[-0.356,0]; MX_INVALID(0.50)[cached]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; IP_SCORE(-0.12)[asn: 31400(-0.59), country: DE(-0.02)]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[0x20.net]; AUTH_NA(1.00)[]; NEURAL_HAM_LONG(-0.21)[-0.208,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.13)[-0.132,0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[lars.engels@0x20.net,lars@e.0x20.net]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:31400, ipnet:46.251.251.0/24, country:DE]; FROM_NEQ_ENVFROM(0.00)[lars.engels@0x20.net,lars@e.0x20.net] X-Rspamd-Server: mx1.freebsd.org X-Mailman-Approved-At: Fri, 23 Nov 2018 11:47:43 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2018 10:49:44 -0000 On Fri, Nov 23, 2018 at 01:59:31PM +0700, Eugene Grosbein wrote: > 23.11.2018 6:20, Warner Losh wrote: > > >> I found we have no utility capable to perform TRIM for the whole SSD device > >> or arbitrary part of it, so I wrote simple one. I can't think of nice name > >> for it, so proposal are welcome! Draft name is "erase". > >> > >> I ask for pre-commit code review, too. > >> The code is tested with TRIM-capable SSD and non-capable other devices. > >> > >> Currently it has four options, all of them are, hmm, optional: > >> > >> -b: to specify offset from the beginning of the device for trimmed region > >> instead of default 0; > >> -l: to specify offset from the "-b" margin - length - for trimmed region > >> instead of whole device; > >> -r rfile: for alternative way to specify length as length of referenced > >> file; > >> > > > > This seems really obscure and would be better handled by a stat command. > > This is inspired by truncate(1) having same option that saves extra call to stat. > > Forgot to note, that options -b and -l allow suffixes [K|k|M|m|G|g|T|t] > just like truncate's option -s does. > > > "erase" is a really bad name. It's fraught with too many overloaded > > meanings. "trim" is likely the least bad name we can use. > > I'm fine with this, renamed. > > > Linux has a fstrim command, which does something kinda similar (it's a lot > > like fsck -E to erase unused parts of the filesystem), so there is some > > overlap. I couldn't find a dedicated command to do that, but if it does, we > > should follow that convention to reimplement. > > Well, they have http://man7.org/linux/man-pages/man8/blkdiscard.8.html > > I don't like the name, though. It's too complicated to pronounce and too long same time. Would "hdtrim" or "ssdtrim" be better names?