Lines Matching refs:block

56 struct block {
79 int reserved_block; /* block next up for reclaim */
80 int current_block; /* block to write to */
87 struct block *blocks;
94 struct block *block = &part->blocks[block_no];
97 block->offset = part->block_size * block_no;
100 block->state = BLOCK_UNUSED;
104 block->state = BLOCK_OK;
115 block->free_sectors++;
138 part->sector_map[entry] = block->offset +
141 block->used_sectors++;
144 if (block->free_sectors == part->data_sectors_per_block)
163 /* each erase block has three bytes header, followed by the map */
187 part->blocks = kcalloc(part->total_blocks, sizeof(struct block),
326 static int erase_block(struct partition *part, int block)
337 erase->addr = part->blocks[block].offset;
341 part->blocks[block].state = BLOCK_ERASING;
342 part->blocks[block].free_sectors = 0;
447 int block, best_block, score, old_sector_block;
460 for (block=0; block<part->total_blocks; block++) {
463 if (block == part->reserved_block)
471 if (part->blocks[block].free_sectors)
474 this_score = part->blocks[block].used_sectors;
476 if (block == old_sector_block)
479 /* no point in moving a full block */
480 if (part->blocks[block].used_sectors ==
485 this_score += part->blocks[block].erases;
488 best_block = block;
499 pr_debug("reclaim_block: reclaiming block #%d with %d used "
513 * IMPROVE: It would be best to choose the block with the most deleted sectors,
519 int block, stop;
521 block = part->current_block == -1 ?
523 stop = block;
526 if (part->blocks[block].free_sectors &&
527 block != part->reserved_block)
528 return block;
530 if (part->blocks[block].state == BLOCK_UNUSED)
531 erase_block(part, block);
533 if (++block >= part->total_blocks)
534 block = 0;
536 } while (block != stop);
543 int rc, block;
546 block = find_free_block(part);
548 if (block == -1) {
554 block = find_free_block(part);
557 if (block == -1) {
563 rc = mtd_read(part->mbd.mtd, part->blocks[block].offset,
573 part->blocks[block].offset);
577 part->current_block = block;
585 int block, offset, rc;
590 block = old_addr / part->block_size;
594 addr = part->blocks[block].offset +
607 if (block == part->current_block)
610 part->blocks[block].used_sectors--;
612 if (!part->blocks[block].used_sectors &&
613 !part->blocks[block].free_sectors)
614 rc = erase_block(part, block);
620 static int find_free_sector(const struct partition *part, const struct block *block)
624 i = stop = part->data_sectors_per_block - block->free_sectors;
642 struct block *block;
657 block = &part->blocks[part->current_block];
659 i = find_free_sector(part, block);
667 block->offset;
686 addr = block->offset + (HEADER_MAP_OFFSET + i) * sizeof(u16);
698 block->used_sectors++;
699 block->free_sectors--;