Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Dec 2010 16:21:36 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Oliver Fromme <olli@lurza.secnetix.de>
Cc:        freebsd-fs@FreeBSD.ORG, Kirk McKusick <mckusick@mckusick.com>
Subject:   Re: TRIM support for UFS?
Message-ID:  <20101208152136.GG1692@garage.freebsd.pl>
In-Reply-To: <201012071531.oB7FVEhb047727@lurza.secnetix.de>
References:  <201012071531.oB7FVEhb047727@lurza.secnetix.de>

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

--j2AXaZ4YhVcLc+PQ
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,
>=20
> 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.
>=20
> Now, the only thing missing would be TRIM support for UFS.
> I did some research and found the following patch:
>=20
> http://people.freebsd.org/~pjd/patches/ufsdel.patch
>=20
> 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@).
>=20
> 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
NO_MAN=3D
WARNS?=3D 6

=2Einclude <bsd.prog.mk>

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

#include <libgeom.h>

int
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()");
	g_close(fd);
	exit(0);
}

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd@FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

--j2AXaZ4YhVcLc+PQ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAkz/ooAACgkQForvXbEpPzQxgACdFFOUklSHI6O8E+cOZEW2ZSVs
9RcAnjQvx+GY87DCOrnLuVPh1Qz09w/2
=eezJ
-----END PGP SIGNATURE-----

--j2AXaZ4YhVcLc+PQ--



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20101208152136.GG1692>