Lines Matching refs:chunk
114 /* Function to calculate chunk and offset */
116 static void yaffs_AddrToChunk(yaffs_Device *dev, loff_t addr, __u32 *chunk, __u32 *offset)
120 *chunk = (__u32)(addr >> dev->chunkShift);
128 *chunk = ((__u32)addr)/dev->crumbsPerChunk;
129 *offset += ((addr - (*chunk * dev->crumbsPerChunk)) << dev->crumbShift);
269 * Chunk bitmap manipulations
291 static Y_INLINE void yaffs_ClearChunkBit(yaffs_Device * dev, int blk, int chunk)
295 blkBits[chunk / 8] &= ~(1 << (chunk & 7));
298 static Y_INLINE void yaffs_SetChunkBit(yaffs_Device * dev, int blk, int chunk)
302 blkBits[chunk / 8] |= (1 << (chunk & 7));
305 static Y_INLINE int yaffs_CheckChunkBit(yaffs_Device * dev, int blk, int chunk)
308 return (blkBits[chunk / 8] & (1 << (chunk & 7))) ? 1 : 0;
380 (TSTR("Chunk %d not erased" TENDSTR), chunkInNAND));
395 int chunk;
405 chunk = yaffs_AllocateChunk(dev, useReserve,&bi);
407 if (chunk >= 0) {
408 /* First check this chunk is erased, if it needs checking.
421 * if there was a partially written chunk due to power loss
428 yaffs_DeleteChunk(dev, chunk, 1, __LINE__);
436 erasedOk = yaffs_CheckChunkErased(dev, chunk);
444 ("**>> yaffs chunk %d was not erased"
445 TENDSTR), chunk));
448 yaffs_WriteChunkWithTagsToNAND(dev, chunk,
460 yaffs_HandleWriteChunkOk(dev, chunk, data, tags);
464 yaffs_HandleWriteChunkError(dev, chunk, erasedOk);
469 } while (chunk >= 0 && !writeOk);
478 return chunk;
545 /* Delete the chunk */
837 /* Check sane level and chunk Id */
1104 static void yaffs_SoftDeleteChunk(yaffs_Device * dev, int chunk)
1109 T(YAFFS_TRACE_DELETION, (TSTR("soft delete chunk %d" TENDSTR), chunk));
1111 theBlock = yaffs_GetBlockInfo(dev, chunk / dev->nChunksPerBlock);
1119 * All soft deleting does is increment the block's softdelete count and pulls the chunk out
1163 /* Note this does not find the real chunk, only the chunk group.
1164 * We make an assumption that a chunk group is not larger than
1395 obj->chunkId = 0; /* Not a valid chunk. */
2160 (">>Block %d erasure supposedly OK, but chunk %d not erased"
2405 /* Data chunk in a deleted file, throw it away
2406 * It's a soft deleted data chunk,
2434 /* It's either a data chunk in a live file or
2473 /* It's a data chunk */
2611 /*Get the Tnode, then get the level 0 offset chunk offset */
2639 /* Get the Tnode, then get the level 0 offset chunk offset */
2680 int chunk;
2701 for (chunk = 1; chunk <= nChunks; chunk++) {
2703 chunk);
2707 theChunk = yaffs_GetChunkGroupBase(dev,tn,chunk);
2717 (tags, in->objectId, chunk, chunkDeleted)) {
2727 /* T(("No level 0 found for %d\n", chunk
2752 /* Just ignore an attempt at putting a chunk into a non-file during scanning
2758 ("yaffs tragedy:attempt to put data chunk into a non-file"
2781 * chunk should ever be affected.
2788 /* NB Right now existing chunk will not be real chunkId if the device >= 32MB
2789 * thus we have to do a FindChunkInFile to get the real chunk id.
2815 ("yaffs tragedy: existing chunk < 0 in scan"
2869 (TSTR("Chunk %d not found zero instead" TENDSTR),
2895 (TSTR("line %d delete of chunk %d" TENDSTR), lyn, chunkId));
2931 /* T(("Bad news deleting chunk %d\n",chunkId)); */
2940 /* Find old chunk Need to do this to get serial number
2955 /* Get the previous chunk at this location in the file if it exists */
3107 /* Create new chunk in NAND */
3124 /* If this was a shrink, then mark the block that the chunk lives on */
3187 /* Find the dirty cache for this object with the lowest chunk id. */
3255 /* Grab us a cache chunk for use.
3346 /* Find a cached chunk */
3365 /* Mark the chunk for the least recently used algorithym */
3505 /* Write chunk bits */
3873 * An incomplete chunk to start with (if the read/write is not chunk-aligned)
3875 * An incomplete chunk to end off with
3877 * Curve-balls: the first chunk might also be the last chunk.
3884 int chunk;
3896 //chunk = offset / dev->nDataBytesPerChunk + 1;
3898 yaffs_AddrToChunk(dev,offset,&chunk,&start);
3899 chunk++;
3902 * the same chunk.
3910 cache = yaffs_FindChunkCache(in, chunk);
3912 /* If the chunk is already in the cache or it is less than a whole chunk
3924 cache->chunkId = chunk;
3927 yaffs_ReadChunkDataFromObject(in, chunk,
3951 yaffs_ReadChunkDataFromObject(in, chunk,
3972 yaffs_ReadChunkDataFromObject(in, chunk, localBuffer);
3985 /* A full chunk. Read directly into the supplied buffer. */
3986 yaffs_ReadChunkDataFromObject(in, chunk, buffer);
4004 int chunk;
4019 //chunk = offset / dev->nDataBytesPerChunk + 1;
4021 yaffs_AddrToChunk(dev,offset,&chunk,&start);
4022 chunk++;
4025 * the same chunk.
4038 ((chunk - 1) * dev->nDataBytesPerChunk);
4054 /* An incomplete start or end chunk (or maybe both start and end chunk) */
4058 cache = yaffs_FindChunkCache(in, chunk);
4065 cache->chunkId = chunk;
4068 yaffs_ReadChunkDataFromObject(in, chunk,
4111 /* An incomplete start or end chunk (or maybe both start and end chunk)
4118 yaffs_ReadChunkDataFromObject(in, chunk,
4131 yaffs_WriteChunkDataToObject(in, chunk,
4156 yaffs_WriteChunkDataToObject(in, chunk, localBuffer,
4161 /* A full chunk. Write directly from the supplied buffer. */
4163 yaffs_WriteChunkDataToObject(in, chunk, buffer,
4168 yaffs_InvalidateChunkCache(in, chunk);
4268 /* Got to read and rewrite the last chunk with its new size and zero pad */
4655 int chunk;
4786 /* For each chunk in each block that needs scanning....*/
4790 chunk = blk * dev->nChunksPerBlock + c;
4792 result = yaffs_ReadChunkWithTagsFromNAND(dev, chunk, NULL,
4795 /* Let's have a good look at this chunk... */
4799 * A deleted chunk
4805 /* An unassigned chunk in the block
4811 /* We're looking at the first chunk in the block so the block is unused */
4842 /* chunkId > 0 so it is a data chunk... */
4855 yaffs_PutChunkIntoFile(in, tags.chunkId, chunk,
4881 result = yaffs_ReadChunkWithTagsFromNAND(dev, chunk,
4928 yaffs_DeleteChunk(dev, chunk, 1,
4956 in->chunkId = chunk;
4980 in->chunkId = chunk;
5187 int chunk;
5353 /* For each chunk in each block that needs scanning.... */
5361 chunk = blk * dev->nChunksPerBlock + c;
5363 result = yaffs_ReadChunkWithTagsFromNAND(dev, chunk, NULL,
5366 /* Let's have a good look at this chunk... */
5369 /* An unassigned chunk in the block.
5371 * it is a chunk that was skipped due to failing the erased
5374 * chunk and his means that either the block is empty or
5380 /* This is a chunk that was skipped due to failing the erased check */
5383 /* We're looking at the first chunk in the block so the block is unused */
5421 /* chunkId > 0 so it is a data chunk... */
5441 chunk, -1);
5463 /* This chunk has been invalidated by a resize, so delete */
5464 yaffs_DeleteChunk(dev, chunk, 1, __LINE__);
5495 /* If we don't have valid info then we need to read the chunk
5496 * TODO In future we can probably defer reading the chunk and
5501 chunk,
5517 "at chunk %d during scan"
5518 TENDSTR), tags.objectId, chunk));
5570 yaffs_DeleteChunk(dev, chunk, 1, __LINE__);
5606 in->chunkId = chunk;
5612 in->chunkId = chunk;
6180 " chunk %d type %d size %d\n"
6282 ("yaffs: NAND geometry problems: chunk size %d, type is yaffs%s "
6325 * Calculate all the chunk size manipulation numbers:
6372 * chunk range we're using is greater than 16 we need
6373 * to figure out chunk shift and chunkGroupSize
6386 * the chunk group size > chunks per block.
6390 (TSTR("yaffs: chunk group too large\n" TENDSTR)));