TRIM support for UFS?

Kirk McKusick mckusick at mckusick.com
Fri Dec 10 05:45:52 UTC 2010


> Date: Thu, 09 Dec 2010 21:19:52 -0800
> From: Julian Elischer <julian at freebsd.org>
> To: Pawel Jakub Dawidek <pjd at freebsd.org>
> CC: Bakul Shah <bakul at bitblocks.com>, Kirk McKusick <mckusick at mckusick.com>,
>         Oliver Fromme <olli at lurza.secnetix.de>, freebsd-fs at freebsd.org
> Subject: Re: TRIM support for UFS?
> 
> One of the things that has not been mentioned is that releasing
> space in a file is not really 'free' (at least not for us) if you
> want things to remain trimmed after a reboot.  So if I were
> implementing it I'd want a couple of parameters.
> 
> 1/ don't bother trimming free space under some size.
>
> 2/ does it matter if the trimmed space comes back as garbage
> after an unclean shutdown? (a hint to the driver, and no, I don't
> know anyone that supports this yet)
> (there are security implications to that one but cheap trim (that
> may come back) is way cheaper than persistent trim to impliment).
> 
> With these parameters we (fusion-io) could tune our behaviour
> which can save performance, and also the file system could tune
> it's min-trim value to see what gives best performance.

The above is one of the reasons that we never implemented the
`release' system call. To be stable after a crash requires either
a lot of synchronous writes or a bunch more soft update dependencies.
Many of the same issues relate to stability of snapshots across
system crashes. In the end we added the dopersistence flag:

/*
 * To ensure the consistency of snapshots across crashes, we must
 * synchronously write out copied blocks before allowing the
 * originals to be modified. Because of the rather severe speed
 * penalty that this imposes, the following flag allows this
 * crash persistence to be disabled.
 */
int dopersistence = 0;
         
#ifdef DEBUG
#include <sys/sysctl.h>
SYSCTL_INT(_debug, OID_AUTO, dopersistence, CTLFLAG_RW, &dopersistence, 0, "");
#endif /* DEBUG */

As you can see it defaults to off.

	Kirk McKusick


More information about the freebsd-fs mailing list