From owner-freebsd-hackers@freebsd.org Fri Nov 23 08:34:32 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 222F8113F2BF for ; Fri, 23 Nov 2018 08:34:32 +0000 (UTC) (envelope-from wojtek@puchar.net) Received: from puchar.net (puchar.net [194.1.144.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "puchar.net", Issuer "puchar.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2DE307C4D0 for ; Fri, 23 Nov 2018 08:34:30 +0000 (UTC) (envelope-from wojtek@puchar.net) Received: Received: from 127.0.0.1 (localhost [127.0.0.1]) by puchar.net (8.15.2/8.15.2) with ESMTPS id wAN8YSYW039706 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 23 Nov 2018 09:34:28 +0100 (CET) (envelope-from puchar-wojtek@puchar.net) Received: from localhost (puchar-wojtek@localhost) by puchar.net (8.15.2/8.15.2/Submit) with ESMTP id wAN8YNBZ039703; Fri, 23 Nov 2018 09:34:23 +0100 (CET) (envelope-from puchar-wojtek@puchar.net) Date: Fri, 23 Nov 2018 09:34:23 +0100 (CET) From: Wojciech Puchar To: Eugene Grosbein cc: Freebsd hackers list Subject: Re: TRIM utility In-Reply-To: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net> Message-ID: References: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net> User-Agent: Alpine 2.20 (BSF 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Rspamd-Queue-Id: 2DE307C4D0 X-Spamd-Result: default: False [-1.95 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.66)[-0.659,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-0.33)[-0.325,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[puchar.net]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[puchar.net]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[90.144.1.194.list.dnswl.org : 127.0.10.0]; NEURAL_HAM_SHORT(-0.66)[-0.663,0]; IP_SCORE(0.00)[country: PL(0.02)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:43476, ipnet:194.1.144.0/24, country:PL]; MID_RHS_MATCH_FROM(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 08:34:32 -0000 thanks. very useful tool On Fri, 23 Nov 2018, Eugene Grosbein wrote: > Hi! > > 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; > -v: for verbose mode that shows final values for the beginning offset and length. > > Later options override previous ones. Then it expects a list of device names as arguments: > > erase ada0 > erase /dev/ada0s1 > erase -b 4096 -r file.img -v /dev/da0 /dev/da1 /dev/da2 > > The code: > > http://www.grosbein.net/freebsd/erase.c > http://www.grosbein.net/freebsd/Makefile.erase > > My "mandoc" skills are very poor and English is not my native language, > so any help with manual page creation will be appreciated. > > Eugene Grosbein > > P.S. I realized that our kernel-level TRIM support has no connection to cam(4) nor to geom(4), > so distinct utility instead of addition to camcontrol(8) or geom(8). > >