jffs2: filesystem corruption caused by writing and powercycle

Dirk Eibach eibach at gdsys.de
Mon Mar 17 05:42:51 EDT 2008


Hello,

I have  a problem with jffs2 filesystem corruption. 
My environment is kernel 2.6.23.4, running on PPC. 
Flash is Spansion 29GL512 NOR-Flash.

The problem can be reproduced simply by turning off power while writing.
After 3 or 4 powercycles I get errormessages when trying to copy the file I wrote before turning off power:

/ # cp /data/tst /data/tst2
Data CRC ee9173b1 != calculated CRC 6af6806d for node at 0221f108
cp: read error: Input/output error
/ # 


This is my code to reproduce the problem:

#include <cstdlib>
#include <iostream>
#include <fcntl.h>
#include <errno.h>

#define MAXDATASIZE 10000.0
#define MINDATASIZE 10.0

int doStressTest (std::string filename)
{
  std::string data;
  int dataSize;

  int fd;
  fd = open(filename.c_str(), O_CREAT | O_RDWR);
  if ( fd == -1 ) {
    std::cerr << "Open file failed." << std::endl;
    return 1;
  }
  
  data = std::string("");
  // Create random data
  for ( int i=0; i < MAXDATASIZE; i++ )
    data.push_back(1+rand()%255);

  for(;;) {
    dataSize = (int)(MINDATASIZE+(MAXDATASIZE-MINDATASIZE+1)*rand()/RAND_MAX);

    std::cout << "Write " << dataSize << " bytes..." << std::endl;
    if ( write(fd, data.data(), dataSize) != dataSize ) {
      std::cerr << "Write data failed: " << strerror(errno) << std::endl;
      return 1;
    }

  }

  close(fd);
  return 0;
}


int main (int argc, char **argv)
{
  if ( argc < 2 ) {
    std::cerr << "usage: stresstest <FILENAME>" << std::endl;
    exit(EXIT_FAILURE);
  }

  std::cout << "Stresstest running..." << std::endl;

  return doStressTest (std::string(argv[1]));
}


Cheers
-- 
Dirk Eibach
Entwicklung
Guntermann & Drunck GmbH Systementwicklung

Telefon: +49 2739 8901-100
Fax:     +49 2739 8901-120
EMail:   mailto:eibach at gdsys.de

-------------------------------------------------------------------------------
Guntermann & Drunck GmbH Systementwicklung 
Dortmunder Str. 4a 
D-57234 Wilnsdorf - Germany 
Tel: +49 (0) 27 39 / 89 01 - 100  Fax: +49 (0) 27 39 / 89 01 - 120 
E-Mail: mailto:sales at gdsys.de Web: www.gdsys.de
-------------------------------------------------------------------------------
Geschäftsführer: Udo Guntermann - Martin Drunck - Reiner Ruelmann - Klaus Tocke
HRB 2884, Amtsgericht Siegen
USt.-Id.-Nr. DE 126575222 - Steuer-Nr. 342 / 5835 / 1041
-------------------------------------------------------------------------------






More information about the linux-mtd mailing list