CF Card wear optimalisation for ext4

Theodore Ts'o tytso at mit.edu
Fri Oct 17 15:43:06 UTC 2014


On Thu, Oct 16, 2014 at 11:01:35PM +0200, Bodo Thiesen wrote:
> 
> Since it never get's updated unless the file system is unmounted, it can
> only be used for a 24 hours test by mounting the file system now,
> unmounting it 24 hours from now and then taking the difference.

It also gets updated if the file system syncfs(2) or sync(2) system
call.  But if you crash, any writes since the last syncfs(2), sync(2),
or umount(2) call on the file system can get lost, yes.

> Also the value is only available in granularity of 1 GB (plus minus
> 512MB) - at least in my case.

This is what dumpe2fs is currently using:

	if (sb->s_kbytes_written) {
		fprintf(f, "Lifetime writes:          ");
		if (sb->s_kbytes_written < POW2(13))
			fprintf(f, "%llu kB\n", sb->s_kbytes_written);
		else if (sb->s_kbytes_written < POW2(23))
			fprintf(f, "%llu MB\n",
				(sb->s_kbytes_written + POW2(9)) >> 10);
		else if (sb->s_kbytes_written < POW2(33))
			fprintf(f, "%llu GB\n",
				(sb->s_kbytes_written + POW2(19)) >> 20);
		else if (sb->s_kbytes_written < POW2(43))
			fprintf(f, "%llu TB\n",
				(sb->s_kbytes_written + POW2(29)) >> 30);
		else
			fprintf(f, "%llu PB\n",
				(sb->s_kbytes_written + POW2(39)) >> 40);
	}

What we are doing was deliberate, in an effort to display things in a
user-friendly fashion that was hopefully still useful.  If you'd like
to propose something different, please send patches and I'll consider it.


> I did test /sys/fs/ext4/sda/lifetime_write_kbytes now, that seems to be
> somewhat less bogus, so *that* might actuall be usable for the 24 hours
> test. But I wasn't talking about that when I said, that this lifetime
> thing is bogus.

Bogus is in the eye of the beholder.  It's not perfect, and if your
system is regularly crashing, then it will be much less perfect.

If it's not helpful enough for your use case, don't use it.  Certainly
if the SSD has information available via S.M.A.R.T., it's better to
use that instead.  But if a crappy CF device doesn't have S.M.A.R.T, then
I'm afraid this is the best that we can offer....

        	   	       	    	    - Ted




More information about the Ext3-users mailing list