Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Dec 2010 16:21:36 +0100
From:      Pawel Jakub Dawidek <>
To:        Oliver Fromme <>
Cc:        freebsd-fs@FreeBSD.ORG, Kirk McKusick <>
Subject:   Re: TRIM support for UFS?
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Dec 07, 2010 at 04:31:14PM +0100, Oliver Fromme wrote:
> Hi,
> I've bought an OCZ Vertex2 E (120 GB SSD) and installed
> FreeBSD i386 stable/8 on it, using UFS (UFS2, to be exact).
> I've made sure that the partitions are aligned properly,
> and used newfs with 4k fragsize and 32k blocksize.
> It works very well so far.
> Now, the only thing missing would be TRIM support for UFS.
> I did some research and found the following patch:
> Apparently that patch is supposed to make UFS use TRIM,
> among other things.  However, the patch seems to be rather
> old (time stamp says 2007-02-03), and nothing has been
> comitted to current or stable so far (I've grepped through
> the past 12 months of SVN logs, after TRIM support was
> added to ada(4) by mav@).
> So, my question is, are there plans to add TRIM support
> to UFS?  Is anyone working on it?  Or is it already there
> and I just overlooked it?

I hacked up this patch mostly for Kris and md(4) memory-backed UFS, so
on file remove space can be returned to the system.

I think you should ask Kirk what to do about that, but I'm afraid my
patch can break SU - what if we TRIM, but then panic and on fsck decide
to actually use the block?

BTW. Have you actually observed any performance degradation without
TRIM? I've similar SSDs and from what I tested it somehow can handle
wear leveling internally. You can to TRIM entire disk using this simple
program below, newfs it and test it. Then fill it with random data,
newfs it again, test it and compare results.

=3D=3D=3D Makefile:
PROG=3D   trim
LDADD=3D  -lgeom

=2Einclude <>

=3D=3D=3D trim.c:
#include <err.h>
#include <stdlib.h>

#include <libgeom.h>

main(int argc, char *argv[])
	off_t mediasize;
	int fd;

	if (argc !=3D 2)
		errx(1, "usage: %s disk", getprogname());
	if ((fd =3D g_open(argv[1], 1)) < 0)
		err(2, "g_open(%s)", argv[1]);
	if ((mediasize =3D g_mediasize(fd)) < 0)
		err(3, "g_mediasize()");
	if (g_delete(fd, 0, mediasize) < 0)
		err(4, "g_delete()");

Pawel Jakub Dawidek                              
FreeBSD committer                         Am I Evil? Yes, I Am!

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v2.0.14 (FreeBSD)



Want to link to this message? Use this URL: <>