[Karmic] file corruption on ext3 filesystem?

Tetsuo Handa from-ubuntu at I-love.SAKURA.ne.jp
Thu Jan 7 14:15:01 UTC 2010


I'm experiencing file corruption problem.
I don't know whether this is a bug of kernel or not.
Can somebody reproduce below result?

My environment:
  VMware Workstation 6.5.3 with 2CPUs / 512MB RAM.
  Ubuntu Karmic with 2.6.31-17-generic-pae kernel.
  Filesystem is ext3 (according to /etc/mtab and dmesg).
  e2fsck 1.41.9 (22-Aug-2009)

Steps to reproduce:

  Compile below program using "gcc -Wall -O3".

#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv[])
	FILE *fp = fopen("/testfile", "a");
	char buffer[4096];
	memset(buffer, 0x20, sizeof(buffer));
	buffer[sizeof(buffer) - 1] = '\n';
	fwrite(buffer, 1, sizeof(buffer), fp);
	fprintf(stderr, "Let power fail after a few seconds.\n");
	while (1) {
		fwrite(buffer, 1, sizeof(buffer), fp);
	return 0;

  Create files with large amount of data (e.g.
  tar -zxf linux_2.6.31.orig.tar.gz ) and wait for more than 5 seconds
  (i.e. longer than kjournald's commit interval) so that the file's data is
  actually written to disk. Then, delete files (e.g. rm -fR linux-2.6.31/ )
  and wait again so that deleted files are actually written to disk.

  Run the above program and let the power fail (i.e. unplug the electric cable
  or do equivalent) after more than 5 seconds (i.e. longer than kjournald's
  commit interval).

  Restart the system (and fsck will be executed).

  Run "cat /testfile". It should contain only lines of 4095 spaces + '\n'.
  But it contains different data.


More information about the kernel-team mailing list