From owner-freebsd-hackers@freebsd.org Thu Nov 22 20:35:24 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 635DE1106C53 for ; Thu, 22 Nov 2018 20:35:24 +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 7BADA85DDE for ; Thu, 22 Nov 2018 20:35:13 +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 wAMKZ24K007962 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 21:35:03 +0100 (CET) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: 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 wAMKZ2WL071843 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Fri, 23 Nov 2018 03:35:02 +0700 (+07) (envelope-from eugen@grosbein.net) To: Freebsd hackers list From: Eugene Grosbein Subject: TRIM utility Message-ID: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net> Date: Fri, 23 Nov 2018 03:34:49 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BMWLwdDNWBlI0B1KElsFW6Prk6LfFDvG5" 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: 7BADA85DDE X-Spamd-Result: default: False [-7.29 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; MX_INVALID(0.50)[greylisted]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[grosbein.net]; TO_DN_ALL(0.00)[]; R_SPF_PERMFAIL(0.00)[]; NEURAL_HAM_SHORT(-0.95)[-0.954,0]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; IP_SCORE(-2.63)[ip: (-6.79), ipnet: 2a01:4f8::/29(-3.43), asn: 24940(-2.92), 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: Thu, 22 Nov 2018 20:35:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BMWLwdDNWBlI0B1KElsFW6Prk6LfFDvG5 Content-Type: multipart/mixed; boundary="28tQcQm9tUPKBPJWQOQ20J0TXSTHRFKCN"; protected-headers="v1" From: Eugene Grosbein To: Freebsd hackers list Message-ID: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net> Subject: TRIM utility --28tQcQm9tUPKBPJWQOQ20J0TXSTHRFKCN Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: quoted-printable Hi! I found we have no utility capable to perform TRIM for the whole SSD devi= ce or arbitrary part of it, so I wrote simple one. I can't think of nice nam= e 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 f= ile; -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 na= mes 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 c= am(4) nor to geom(4), so distinct utility instead of addition to camcontrol(8) or geom(8). --28tQcQm9tUPKBPJWQOQ20J0TXSTHRFKCN-- --BMWLwdDNWBlI0B1KElsFW6Prk6LfFDvG5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJb9xL0AAoJELDNGvImmIso2SkIAJnHBVSkCE3V9mcSSgrw+D6W q8viJSwMrgqeE/FrWp8XE5nWVEAVff2HcqcC05DRAW0ieuEAj0rCKWwbxrq/xvP0 lyhQc6nS0buX9yz5/FmwKCDOQ3AJ3mn5z9CXtg6aOhVre712eO5qnoIpIYoistsQ Fg/ku4KbKkU9DcfYwWMxhlotkNkcIFDSxisyQY/j5CvYAxjB/i5FfHYtI+ny7ki5 C1JbZoaOMjnGwZuZ05bj0r2cMtVnOZbxrBuKIXh5nf3BWY/6tSp5Sz30M7fcY7ge 3N/J+0/sJQnXLzxNoLb9639bQ/MSyx9mPNNeVTrJZaqVLu2+vZgBStLlF8YKRKU= =v8A5 -----END PGP SIGNATURE----- --BMWLwdDNWBlI0B1KElsFW6Prk6LfFDvG5--