Lines Matching full:block
28 unsigned int block, boot_record_count = 0; in find_boot_record() local
48 for (block = 0; block < nftl->nb_blocks; block++) { in find_boot_record()
53 ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE, in find_boot_record()
61 printk(KERN_WARNING "Block read at 0x%x of mtd%d failed: %d\n", in find_boot_record()
62 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
64 printk(KERN_WARNING "Further failures for this block will not be printed\n"); in find_boot_record()
73 block * nftl->EraseSize, nftl->mbd.mtd->index); in find_boot_record()
79 ret = nftl_read_oob(mtd, block * nftl->EraseSize + in find_boot_record()
84 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
94 block * nftl->EraseSize, nftl->mbd.mtd->index, in find_boot_record()
100 ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, in find_boot_record()
104 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
111 block * nftl->EraseSize, nftl->mbd.mtd->index); in find_boot_record()
123 nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize); in find_boot_record()
132 nftl->SpareMediaUnit = block; in find_boot_record()
134 /* Mark this boot record (NFTL MediaHeader) block as reserved */ in find_boot_record()
135 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in find_boot_record()
213 /* Mark this boot record (NFTL MediaHeader) block as reserved */ in find_boot_record()
214 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in find_boot_record()
219 The new DiskOnChip driver already scanned the bad block table. Just query it. in find_boot_record()
223 block * nftl->EraseSize + i + in find_boot_record()
243 nftl->MediaUnit = block; in find_boot_record()
246 } /* foreach (block) */ in find_boot_record()
305 int NFTL_formatblock(struct NFTLrecord *nftl, int block) in NFTL_formatblock() argument
314 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, in NFTL_formatblock()
329 instr->addr = block * nftl->EraseSize; in NFTL_formatblock()
332 printk("Error while formatting block %d\n", block); in NFTL_formatblock()
340 /* 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()
617 /* invalid/free block test */ in NFTL_mount()
621 if (check_and_mark_free_block(s, block) < 0) { in NFTL_mount()
623 printk("Formatting block %d\n", block); in NFTL_mount()
624 if (NFTL_formatblock(s, block) < 0) { in NFTL_mount()
625 /* could not format: reserve the block */ in NFTL_mount()
626 s->ReplUnitTable[block] = BLOCK_RESERVED; in NFTL_mount()
628 s->ReplUnitTable[block] = BLOCK_FREE; in NFTL_mount()
631 /* free block: mark it */ in NFTL_mount()
632 s->ReplUnitTable[block] = BLOCK_FREE; in NFTL_mount()
634 /* directly examine the next block. */ in NFTL_mount()
637 /* the block was in a chain : this is bad. We in NFTL_mount()
639 printk("Block %d: free but referenced in chain %d\n", in NFTL_mount()
640 block, first_block); in NFTL_mount()
641 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
649 /* this block is not the first block in chain : in NFTL_mount()
657 printk("Block %d: incorrect logical block: %d expected: %d\n", in NFTL_mount()
658 block, logical_block, first_logical_block); in NFTL_mount()
664 /* we accept that a block is marked as first in NFTL_mount()
665 block while being last block in a chain in NFTL_mount()
667 if (get_fold_mark(s, block) != FOLD_MARK_IN_PROGRESS || in NFTL_mount()
669 printk("Block %d: incorrectly marked as first block in chain\n", in NFTL_mount()
670 block); in NFTL_mount()
675 printk("Block %d: folding in progress - ignoring first block flag\n", in NFTL_mount()
676 block); in NFTL_mount()
683 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
686 printk("Block %d: referencing invalid block %d\n", in NFTL_mount()
687 block, rep_block); in NFTL_mount()
689 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
693 we accept that the last block of a chain has in NFTL_mount()
696 last block appeared first */ in NFTL_mount()
701 printk("Block %d: folding in progress - ignoring first block flag\n", in NFTL_mount()
703 s->ReplUnitTable[block] = rep_block; in NFTL_mount()
706 printk("Block %d: referencing block %d already in another chain\n", in NFTL_mount()
707 block, rep_block); in NFTL_mount()
710 s->ReplUnitTable[block] = BLOCK_NIL; in NFTL_mount()
715 s->ReplUnitTable[block] = rep_block; in NFTL_mount()
716 block = rep_block; in NFTL_mount()
733 printk("Could read foldmark at block %d\n", first_block); in NFTL_mount()
766 /* second pass to format unreferenced blocks and init free block count */ in NFTL_mount()
770 for (block = 0; block < s->nb_blocks; block++) { in NFTL_mount()
771 if (s->ReplUnitTable[block] == BLOCK_NOTEXPLORED) { in NFTL_mount()
772 printk("Unreferenced block %d, formatting it\n", block); in NFTL_mount()
773 if (NFTL_formatblock(s, block) < 0) in NFTL_mount()
774 s->ReplUnitTable[block] = BLOCK_RESERVED; in NFTL_mount()
776 s->ReplUnitTable[block] = BLOCK_FREE; in NFTL_mount()
778 if (s->ReplUnitTable[block] == BLOCK_FREE) { in NFTL_mount()
780 s->LastFreeEUN = block; in NFTL_mount()