* jffs2: filesystem corruption caused by writing and powercycle
@ 2008-03-17 9:42 Dirk Eibach
0 siblings, 0 replies; only message in thread
From: Dirk Eibach @ 2008-03-17 9:42 UTC (permalink / raw)
To: linux-mtd; +Cc: dwmw2
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@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@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
-------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-03-17 9:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-17 9:42 jffs2: filesystem corruption caused by writing and powercycle Dirk Eibach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).