Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Nov 2018 16:20:10 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Eugene Grosbein <eugen@grosbein.net>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: TRIM utility
Message-ID:  <CANCZdfr4fADoG9OzPC8TXd6CeMkUqYqosx3QkheP08BTB7ajwA@mail.gmail.com>
In-Reply-To: <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net>
References:  <7699de57-d903-1d61-ee42-062ed312b20d@grosbein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Nov 22, 2018, 1:36 PM Eugene Grosbein <eugen@grosbein.net 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;
>

This seems really obscure and would be better handled by a stat command.

-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).
>

"erase" is a really bad name. It's fraught with too many overloaded
meanings. "trim" is likely the least bad name we can use. "delete" is
similarly bad, even though that name is in the ioctl and in BIO_DELETE.
"unmap" is the SCSI term, so it wouldn't be terrible, though the term is
less widely used than "trim" is for this stuff. None of the other command
names for more obscure technologies are general enough or widely enough
known. "discard" is the Linux mount option, which seems less descriptive.

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.

It feels to me to be a dd conv= option, but that isn't reflected in any
implementation I could find, so that suggests I'm nuts (though sparse is a
weak match).

Warner

>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfr4fADoG9OzPC8TXd6CeMkUqYqosx3QkheP08BTB7ajwA>