Lines Matching full:block
41 unsigned int block, boot_record_count = 0; in find_boot_record() local
61 for (block = 0; block < nftl->nb_blocks; block++) { in find_boot_record()
66 ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE, in find_boot_record()
74 printk(KERN_WARNING "Block read at 0x%x of mtd%d failed: %d\n", in find_boot_record()
75 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
77 printk(KERN_WARNING "Further failures for this block will not be printed\n"); in find_boot_record()
86 block * nftl->EraseSize, nftl->mbd.mtd->index); in find_boot_record()
92 if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize + in find_boot_record()
96 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
106 block * nftl->EraseSize, nftl->mbd.mtd->index, in find_boot_record()
112 if ((ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, in find_boot_record()
115 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
122 block * nftl->EraseSize, nftl->mbd.mtd->index); in find_boot_record()
135 nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize); in find_boot_record()
144 nftl->SpareMediaUnit = block; in find_boot_record()
146 /* Mark this boot record (NFTL MediaHeader) block as reserved */ in find_boot_record()
147 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in find_boot_record()
222 /* Mark this boot record (NFTL MediaHeader) block as reserved */ in find_boot_record()
223 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in find_boot_record()
228 The new DiskOnChip driver already scanned the bad block table. Just query it. in find_boot_record()
231 if ((ret = mtd->read(nftl->mbd.mtd, block * nftl->EraseSize + in find_boot_record()
250 nftl->MediaUnit = block; in find_boot_record()
253 } /* foreach (block) */ in find_boot_record()
303 int NFTL_formatblock(struct NFTLrecord *nftl, int block) in NFTL_formatblock() argument
312 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, in NFTL_formatblock()
328 instr->addr = block * nftl->EraseSize; in NFTL_formatblock()
333 printk("Error while formatting block %d\n", block); in NFTL_formatblock()
341 /* wrap (almost impossible with current flash) or free block */ in NFTL_formatblock()
352 if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE + in NFTL_formatblock()
357 /* could not format, update the bad block table (caller is responsible in NFTL_formatblock()
368 * situation that after writing the Data area, the Block Control Information is
369 * not updated according (due to power failure or something) which leaves the block
370 * in an inconsistent state. So we have to check if a block is really FREE in this
375 unsigned int block, i, status; in check_sectors_in_chain() local
381 block = first_block; in check_sectors_in_chain()
385 block * nftl->EraseSize + i * SECTORSIZE, in check_sectors_in_chain()
396 check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE, in check_sectors_in_chain()
398 printk("Incorrect free sector %d in block %d: " in check_sectors_in_chain()
400 i, block); in check_sectors_in_chain()
405 nftl_write_oob(mtd, block * in check_sectors_in_chain()
417 block = nftl->ReplUnitTable[block]; in check_sectors_in_chain()
418 if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) in check_sectors_in_chain()
419 printk("incorrect ReplUnitTable[] : %d\n", block); in check_sectors_in_chain()
420 if (block == BLOCK_NIL || block >= nftl->nb_blocks) in check_sectors_in_chain()
428 unsigned int length = 0, block = first_block; in calc_chain_length() local
439 block = nftl->ReplUnitTable[block]; in calc_chain_length()
440 if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) in calc_chain_length()
441 printk("incorrect ReplUnitTable[] : %d\n", block); in calc_chain_length()
442 if (block == BLOCK_NIL || block >= nftl->nb_blocks) in calc_chain_length()
451 * It is not strictly correct to begin from the first block of the chain because
453 * flag in a block inside it. But is it really a problem ?
460 unsigned int block = first_block, block1; in format_chain() local
462 printk("Formatting chain at block %d\n", first_block); in format_chain()
465 block1 = nftl->ReplUnitTable[block]; in format_chain()
467 printk("Formatting block %d\n", block); in format_chain()
468 if (NFTL_formatblock(nftl, block) < 0) { in format_chain()
470 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in format_chain()
472 nftl->ReplUnitTable[block] = BLOCK_FREE; in format_chain()
475 /* goto next block on the chain */ in format_chain()
476 block = block1; in format_chain()
478 if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) in format_chain()
479 printk("incorrect ReplUnitTable[] : %d\n", block); in format_chain()
480 if (block == BLOCK_NIL || block >= nftl->nb_blocks) in format_chain()
485 /* check_and_mark_free_block: Verify that a block is free in the NFTL sense (valid erase mark) or
491 static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) in check_and_mark_free_block() argument
499 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, in check_and_mark_free_block()
505 /* if no erase mark, the block must be totally free. This is in check_and_mark_free_block()
507 if (check_free_sectors (nftl, block * nftl->EraseSize, nftl->EraseSize, 1) != 0) in check_and_mark_free_block()
510 /* free block : write erase mark */ in check_and_mark_free_block()
515 block * nftl->EraseSize + SECTORSIZE + 8, 8, in check_and_mark_free_block()
523 if (check_free_sectors (nftl, block * nftl->EraseSize + i, in check_and_mark_free_block()
527 if (nftl_read_oob(mtd, block * nftl->EraseSize + i, in check_and_mark_free_block()
552 static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block) in get_fold_mark() argument
558 if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8, in get_fold_mark()
569 unsigned int block, first_block, is_first_block; in NFTL_mount() local
587 /* first pass : explore each block chain */ in NFTL_mount()
590 /* if the block was not already explored, we can look at it */ in NFTL_mount()
592 block = first_block; in NFTL_mount()
597 /* read the block header. If error, we format the chain */ in NFTL_mount()
599 block * s->EraseSize + 8, 8, in NFTL_mount()
602 block * s->EraseSize + in NFTL_mount()
605 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
618 /* invalid/free block test */ in NFTL_mount()
622 if (check_and_mark_free_block(s, block) < 0) { in NFTL_mount()
624 printk("Formatting block %d\n", block); in NFTL_mount()
625 if (NFTL_formatblock(s, block) < 0) { in NFTL_mount()
626 /* could not format: reserve the block */ in NFTL_mount()
627 s->ReplUnitTable[block] = BLOCK_RESERVED; in NFTL_mount()
629 s->ReplUnitTable[block] = BLOCK_FREE; in NFTL_mount()
632 /* free block: mark it */ in NFTL_mount()
633 s->ReplUnitTable[block] = BLOCK_FREE; in NFTL_mount()
635 /* directly examine the next block. */ in NFTL_mount()
638 /* the block was in a chain : this is bad. We in NFTL_mount()
640 printk("Block %d: free but referenced in chain %d\n", in NFTL_mount()
641 block, first_block); in NFTL_mount()
642 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
650 /* this block is not the first block in chain : in NFTL_mount()
658 printk("Block %d: incorrect logical block: %d expected: %d\n", in NFTL_mount()
659 block, logical_block, first_logical_block); in NFTL_mount()
665 /* we accept that a block is marked as first in NFTL_mount()
666 block while being last block in a chain in NFTL_mount()
668 if (get_fold_mark(s, block) != FOLD_MARK_IN_PROGRESS || in NFTL_mount()
670 printk("Block %d: incorrectly marked as first block in chain\n", in NFTL_mount()
671 block); in NFTL_mount()
676 printk("Block %d: folding in progress - ignoring first block flag\n", in NFTL_mount()
677 block); in NFTL_mount()
684 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
687 printk("Block %d: referencing invalid block %d\n", in NFTL_mount()
688 block, rep_block); in NFTL_mount()
690 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
694 we accept that the last block of a chain has in NFTL_mount()
697 last block appeared first */ in NFTL_mount()
702 printk("Block %d: folding in progress - ignoring first block flag\n", in NFTL_mount()
704 s->ReplUnitTable[block] = rep_block; in NFTL_mount()
707 printk("Block %d: referencing block %d already in another chain\n", in NFTL_mount()
708 block, rep_block); in NFTL_mount()
711 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
716 s->ReplUnitTable[block] = rep_block; in NFTL_mount()
717 block = rep_block; in NFTL_mount()
734 printk("Could read foldmark at block %d\n", first_block); in NFTL_mount()
767 /* second pass to format unreferenced blocks and init free block count */ in NFTL_mount()
771 for (block = 0; block < s->nb_blocks; block++) { in NFTL_mount()
772 if (s->ReplUnitTable[block] == BLOCK_NOTEXPLORED) { in NFTL_mount()
773 printk("Unreferenced block %d, formatting it\n", block); in NFTL_mount()
774 if (NFTL_formatblock(s, block) < 0) in NFTL_mount()
775 s->ReplUnitTable[block] = BLOCK_RESERVED; in NFTL_mount()
777 s->ReplUnitTable[block] = BLOCK_FREE; in NFTL_mount()
779 if (s->ReplUnitTable[block] == BLOCK_FREE) { in NFTL_mount()
781 s->LastFreeEUN = block; in NFTL_mount()