- u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
-
- yaffs_verify_blk(dev, bi, block);
-
- max_copies = (whole_block) ? dev->param.chunks_per_block : 5;
- old_chunk = block * dev->param.chunks_per_block + dev->gc_chunk;
-
- for ( /* init already done */ ;
- ret_val == YAFFS_OK &&
- dev->gc_chunk < dev->param.chunks_per_block &&
- (bi->block_state == YAFFS_BLOCK_STATE_COLLECTING) &&
- max_copies > 0; dev->gc_chunk++, old_chunk++) {
- if (yaffs_check_chunk_bit(dev, block, dev->gc_chunk)) {
-
- /* This page is in use and might need to be copied off */
-
- max_copies--;
-
- mark_flash = 1;
-
- yaffs_init_tags(&tags);
-
- yaffs_rd_chunk_tags_nand(dev, old_chunk,
- buffer, &tags);
-
- object = yaffs_find_by_number(dev, tags.obj_id);
-
- T(YAFFS_TRACE_GC_DETAIL,
- (TSTR
- ("Collecting chunk in block %d, %d %d %d "
- TENDSTR), dev->gc_chunk, tags.obj_id,
- tags.chunk_id, tags.n_bytes));
-
- if (object && !yaffs_skip_verification(dev)) {
- if (tags.chunk_id == 0)
- matching_chunk =
- object->hdr_chunk;
- else if (object->soft_del)
- matching_chunk = old_chunk; /* Defeat the test */
- else
- matching_chunk =
- yaffs_find_chunk_in_file
- (object, tags.chunk_id,
- NULL);
-
- if (old_chunk != matching_chunk)
- T(YAFFS_TRACE_ERROR,
- (TSTR
- ("gc: page in gc mismatch: %d %d %d %d"
- TENDSTR), old_chunk,
- matching_chunk, tags.obj_id,
- tags.chunk_id));
-
- }
-
- if (!object) {
- T(YAFFS_TRACE_ERROR,
- (TSTR
- ("page %d in gc has no object: %d %d %d "
- TENDSTR), old_chunk,
- tags.obj_id, tags.chunk_id,
- tags.n_bytes));
- }
-
- if (object &&
- object->deleted &&
- object->soft_del && tags.chunk_id != 0) {
- /* Data chunk in a soft deleted file, throw it away
- * It's a soft deleted data chunk,
- * No need to copy this, just forget about it and
- * fix up the object.
- */
-
- /* Free chunks already includes softdeleted chunks.
- * How ever this chunk is going to soon be really deleted
- * which will increment free chunks.
- * We have to decrement free chunks so this works out properly.
- */
- dev->n_free_chunks--;
- bi->soft_del_pages--;
-
- object->n_data_chunks--;