Lines Matching refs:block
28 unsigned int block, boot_record_count = 0;
48 for (block = 0; block < nftl->nb_blocks; block++) {
53 ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE,
62 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
64 printk(KERN_WARNING "Further failures for this block will not be printed\n");
73 block * nftl->EraseSize, nftl->mbd.mtd->index);
79 ret = nftl_read_oob(mtd, block * nftl->EraseSize +
84 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
94 block * nftl->EraseSize, nftl->mbd.mtd->index,
100 ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE,
104 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
111 block * nftl->EraseSize, nftl->mbd.mtd->index);
123 nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize);
132 nftl->SpareMediaUnit = block;
134 /* Mark this boot record (NFTL MediaHeader) block as reserved */
135 nftl->ReplUnitTable[block] = BLOCK_RESERVED;
213 /* Mark this boot record (NFTL MediaHeader) block as reserved */
214 nftl->ReplUnitTable[block] = BLOCK_RESERVED;
219 The new DiskOnChip driver already scanned the bad block table. Just query it.
223 block * nftl->EraseSize + i +
243 nftl->MediaUnit = block;
246 } /* foreach (block) */
305 int NFTL_formatblock(struct NFTLrecord *nftl, int block)
314 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8,
329 instr->addr = block * nftl->EraseSize;
332 printk("Error while formatting block %d\n", block);
340 /* wrap (almost impossible with current flash) or free block */
352 if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE +
357 /* could not format, update the bad block table (caller is responsible
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;
381 block = first_block;
385 block * nftl->EraseSize + i * SECTORSIZE,
396 check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE,
398 printk("Incorrect free sector %d in block %d: "
400 i, block);
405 nftl_write_oob(mtd, block *
417 block = nftl->ReplUnitTable[block];
418 if (!(block == BLOCK_NIL || block < nftl->nb_blocks))
419 printk("incorrect ReplUnitTable[] : %d\n", block);
420 if (block == BLOCK_NIL || block >= nftl->nb_blocks)
428 unsigned int length = 0, block = first_block;
439 block = nftl->ReplUnitTable[block];
440 if (!(block == BLOCK_NIL || block < nftl->nb_blocks))
441 printk("incorrect ReplUnitTable[] : %d\n", block);
442 if (block == BLOCK_NIL || block >= nftl->nb_blocks)
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;
462 printk("Formatting chain at block %d\n", first_block);
465 block1 = nftl->ReplUnitTable[block];
467 printk("Formatting block %d\n", block);
468 if (NFTL_formatblock(nftl, block) < 0) {
470 nftl->ReplUnitTable[block] = BLOCK_RESERVED;
472 nftl->ReplUnitTable[block] = BLOCK_FREE;
475 /* goto next block on the chain */
476 block = block1;
478 if (!(block == BLOCK_NIL || block < nftl->nb_blocks))
479 printk("incorrect ReplUnitTable[] : %d\n", block);
480 if (block == BLOCK_NIL || block >= nftl->nb_blocks)
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)
499 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
505 /* if no erase mark, the block must be totally free. This is
507 if (check_free_sectors (nftl, block * nftl->EraseSize, nftl->EraseSize, 1) != 0)
510 /* free block : write erase mark */
515 block * nftl->EraseSize + SECTORSIZE + 8, 8,
523 if (check_free_sectors (nftl, block * nftl->EraseSize + i,
527 if (nftl_read_oob(mtd, block * nftl->EraseSize + i,
552 static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block)
558 if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8,
569 unsigned int block, first_block, is_first_block;
587 /* first pass : explore each block chain */
590 /* if the block was not already explored, we can look at it */
592 block = first_block;
597 /* read the block header. If error, we format the chain */
599 block * s->EraseSize + 8, 8,
602 block * s->EraseSize +
605 s->ReplUnitTable[block] = BLOCK_NIL;
617 /* invalid/free block test */
621 if (check_and_mark_free_block(s, block) < 0) {
623 printk("Formatting block %d\n", block);
624 if (NFTL_formatblock(s, block) < 0) {
625 /* could not format: reserve the block */
626 s->ReplUnitTable[block] = BLOCK_RESERVED;
628 s->ReplUnitTable[block] = BLOCK_FREE;
631 /* free block: mark it */
632 s->ReplUnitTable[block] = BLOCK_FREE;
634 /* directly examine the next block. */
637 /* the block was in a chain : this is bad. We
640 block, first_block);
641 s->ReplUnitTable[block] = BLOCK_NIL;
649 /* this block is not the first block in chain :
657 printk("Block %d: incorrect logical block: %d expected: %d\n",
658 block, logical_block, first_logical_block);
664 /* we accept that a block is marked as first
665 block while being last block in a chain
667 if (get_fold_mark(s, block) != FOLD_MARK_IN_PROGRESS ||
669 printk("Block %d: incorrectly marked as first block in chain\n",
670 block);
675 printk("Block %d: folding in progress - ignoring first block flag\n",
676 block);
683 s->ReplUnitTable[block] = BLOCK_NIL;
686 printk("Block %d: referencing invalid block %d\n",
687 block, rep_block);
689 s->ReplUnitTable[block] = BLOCK_NIL;
693 we accept that the last block of a chain has
696 last block appeared first */
701 printk("Block %d: folding in progress - ignoring first block flag\n",
703 s->ReplUnitTable[block] = rep_block;
706 printk("Block %d: referencing block %d already in another chain\n",
707 block, rep_block);
710 s->ReplUnitTable[block] = BLOCK_NIL;
715 s->ReplUnitTable[block] = rep_block;
716 block = rep_block;
733 printk("Could read foldmark at block %d\n", first_block);
766 /* second pass to format unreferenced blocks and init free block count */
770 for (block = 0; block < s->nb_blocks; block++) {
771 if (s->ReplUnitTable[block] == BLOCK_NOTEXPLORED) {
772 printk("Unreferenced block %d, formatting it\n", block);
773 if (NFTL_formatblock(s, block) < 0)
774 s->ReplUnitTable[block] = BLOCK_RESERVED;
776 s->ReplUnitTable[block] = BLOCK_FREE;
778 if (s->ReplUnitTable[block] == BLOCK_FREE) {
780 s->LastFreeEUN = block;