From owner-freebsd-hackers@freebsd.org Fri Nov 23 06:59:58 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 2F5CD113D17E for ; Fri, 23 Nov 2018 06:59:58 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [IPv6:2a01:4f8:d12:604::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 24978795A7 for ; Fri, 23 Nov 2018 06:59:46 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [IPv6:2a03:3100:c:13:0:0:0:5]) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id wAN6xX39012927 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Nov 2018 07:59:34 +0100 (CET) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: imp@bsdimp.com Received: from [10.58.0.4] (dadv@[10.58.0.4]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTPS id wAN6xWqk078040 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 23 Nov 2018 13:59:32 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: TRIM utility To: Warner Losh References: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net> Cc: FreeBSD Hackers From: Eugene Grosbein Message-ID: <6975ff4e-6383-e52c-3a11-d35b95cca114@grosbein.net> Date: Fri, 23 Nov 2018 13:59:31 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,LOCAL_FROM,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.0 SPF_PASS SPF: sender matches SPF record * 2.6 LOCAL_FROM From my domains X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hz.grosbein.net X-Rspamd-Queue-Id: 24978795A7 X-Spamd-Result: default: False [-5.17 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; MX_INVALID(0.50)[greylisted]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[grosbein.net]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; R_SPF_PERMFAIL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; IP_SCORE(-2.60)[ip: (-6.60), ipnet: 2a01:4f8::/29(-3.48), asn: 24940(-2.90), country: DE(-0.01)]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Server: mx1.freebsd.org 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 06:59:58 -0000 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. I can rename -b option to -o to match blkdiscard's, if this matters.