Lines Matching defs:block

144  * Read LBA associated with block
145 * returns -1, if block is erased
156 /* First test for erased block */
192 static loff_t sm_mkoffset(struct sm_ftl *ftl, int zone, int block, int boffset)
196 WARN_ON(block >= ftl->zone_size);
199 if (block == -1)
202 return (zone * SM_MAX_ZONE_SIZE + block) * ftl->block_size + boffset;
207 int *zone, int *block, int *boffset)
211 *block = do_div(offset, ftl->max_lba);
238 int zone, int block, int boffset,
248 if (block == -1) {
270 if (zone == 0 && block == ftl->cis_block && boffset ==
282 ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
286 dbg("read of block %d at zone %d, failed due to error (%d)",
287 block, zone, ret);
304 dbg("read of block %d at zone %d, failed because it is marked"
305 " as bad" , block, zone);
313 dbg("read of block %d at zone %d, failed due to ECC error",
314 block, zone);
323 int zone, int block, int boffset,
332 if (zone == 0 && (block == ftl->cis_block || block == 0)) {
347 ret = mtd_write_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
352 dbg("write to block %d at zone %d, failed with error %d",
353 block, zone, ret);
366 /* ------------------------ block IO ------------------------------------- */
368 /* Write a block using data and lba, and invalid sector bitmap */
370 int zone, int block, int lba,
392 sm_printk("sector %d of block at LBA %d of zone %d"
408 if (!sm_write_sector(ftl, zone, block, boffset,
414 /* If write fails. try to erase the block */
417 * This is intended to repair block that are marked
421 if (sm_erase_block(ftl, zone, block, 0))
427 sm_mark_block_bad(ftl, zone, block);
435 /* Mark whole block at offset 'offs' as bad. */
436 static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block)
450 sm_printk("marking block %d of zone %d as bad", block, zone);
457 sm_write_sector(ftl, zone, block, boffset, NULL, &oob);
461 * Erase a block within a zone
462 * If erase succeeds, it updates free block fifo, otherwise marks block as bad
464 static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
471 erase.addr = sm_mkoffset(ftl, zone_num, block, 0);
479 if (zone_num == 0 && (block == ftl->cis_block || block == 0)) {
485 sm_printk("erase of block %d in zone %d failed",
486 block, zone_num);
492 (const unsigned char *)&block, sizeof(block));
496 sm_mark_block_bad(ftl, zone_num, block);
500 /* Thoroughly test that block is valid. */
501 static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
510 /* First just check that block doesn't look fishy */
518 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob))
531 /* If the block is sliced (partially erased usually) erase it */
533 sm_erase_block(ftl, zone, block, 1);
683 int block, boffset;
687 /* Search for first valid block */
688 for (block = 0 ; block < ftl->zone_size - ftl->max_lba ; block++) {
690 if (sm_read_sector(ftl, 0, block, 0, NULL, &oob))
702 /* Search for first valid sector in this block */
706 if (sm_read_sector(ftl, 0, block, boffset, NULL, &oob))
717 ftl->cis_block = block;
729 dbg("CIS block found at offset %x",
730 block * ftl->block_size +
756 uint16_t block;
778 for (block = 0 ; block < ftl->zone_size ; block++) {
781 if (zone_num == 0 && block <= ftl->cis_block)
785 if (sm_read_sector(ftl, zone_num, block, 0, NULL, &oob)) {
791 /* Test to see if block is erased. It is enough to test
796 (unsigned char *)&block, 2);
800 /* If block is marked as bad, skip it */
802 /* However the way the block valid status is defined, ensures
806 dbg("PH %04d <-> <marked bad>", block);
813 /* Invalid LBA means that block is damaged. */
818 dbg("PH %04d <-> LBA %04d(bad)", block, lba);
827 dbg_verbose("PH %04d <-> LBA %04d", block, lba);
828 zone->lba_to_phys_table[lba] = block;
834 lba, zone->lba_to_phys_table[lba], block, zone_num);
836 /* Test that this block is valid*/
837 if (sm_check_block(ftl, zone_num, block))
840 /* Test now the old block */
843 zone->lba_to_phys_table[lba] = block;
852 sm_erase_block(ftl, zone_num, block, 1);
866 /* Randomize first block we write to */
872 (unsigned char *)&block, 2);
874 kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2);
900 /* Initialize the one block cache */
910 /* Put sector in one block cache */
950 /* Try to read all unread areas of the cache block*/
966 /* we could still continue by erasing/writing the current block,
984 /* Write successful, so erase and free the old block */
1019 int zone_num, block, boffset;
1021 sm_break_offset(ftl, sect_no << 9, &zone_num, &block, &boffset);
1032 if (ftl->cache_zone == zone_num && ftl->cache_block == block) {
1038 /* Translate the block and return if doesn't exist in the table */
1039 block = zone->lba_to_phys_table[block];
1041 if (block == -1) {
1046 if (sm_read_sector(ftl, zone_num, block, boffset, buf, NULL)) {
1064 int error = 0, zone_num, block, boffset;
1067 sm_break_offset(ftl, sec_no << 9, &zone_num, &block, &boffset);
1080 if (ftl->cache_block != block || ftl->cache_zone != zone_num) {
1086 ftl->cache_block = block;
1205 dbg("each block consists of %d bytes",