X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=yaffs_guts.c;h=5218aeab3391faef20b9d85dbbf0800f29e0332f;hb=1ac8445c7e2f516db4a03a9d0715199279f9f134;hp=365fa69636622e601a951a111d0b313808721863;hpb=2a12e648ce34a7f416d55a45041ac010857ecb53;p=yaffs%2F.git diff --git a/yaffs_guts.c b/yaffs_guts.c index 365fa69..5218aea 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -14,7 +14,7 @@ */ //yaffs_guts.c -const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.29 2003-08-29 17:53:05 aleph1 Exp $"; +const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.30 2003-09-16 06:48:38 charles Exp $"; #include "yportenv.h" @@ -1156,6 +1156,8 @@ static int yaffs_SoftDeleteWorker(yaffs_Object *in, yaffs_Tnode *tn, __u32 level { if(tn->level0[i]) { + // Note this does not find the real chunk, only the chunk group. + // We make an assumption that a chunk group is niot larger than a block. theChunk = (tn->level0[i] << in->myDev->chunkGroupBits); T(YAFFS_TRACE_SCAN,(TSTR("soft delete tch %d cgb %d chunk %d" TENDSTR), tn->level0[i],in->myDev->chunkGroupBits,theChunk)); @@ -2864,10 +2866,13 @@ static void yaffs_DeleteChunk(yaffs_Device *dev,int chunkId,int markNAND) { yaffs_SpareInitialise(&spare); +#ifdef CONFIG_MTD_NAND_VERIFY_WRITE + //read data before write, to ensure correct ecc - //and transitions are guaranteed 1->0 + //if we're using MTD verification under Linux yaffs_ReadChunkFromNAND(dev,chunkId,NULL,&spare,0); - +#endif + spare.pageStatus = 0; // To mark it as deleted. @@ -4670,8 +4675,7 @@ int yaffs_GutsInitialise(yaffs_Device *dev) int extraBits; int nBlocks; - if( dev->nBytesPerChunk != YAFFS_BYTES_PER_CHUNK || - + if( dev->nBytesPerChunk != YAFFS_BYTES_PER_CHUNK || dev->nChunksPerBlock < 2 || dev->nReservedBlocks < 2 || dev->startBlock <= 0 || @@ -4738,7 +4742,18 @@ int yaffs_GutsInitialise(yaffs_Device *dev) { dev->chunkGroupBits = bits - 16; } + dev->chunkGroupSize = 1 << dev->chunkGroupBits; + + if(dev->nChunksPerBlock < dev->chunkGroupSize) + { + // We have a problem because the soft delete won't work if + // the chunk group size > chunks per block. + // This can be remedied by using larger "virtual blocks". + + return YAFFS_FAIL; + } +