Lines Matching refs:block

147  * Read LBA associated with block
148 * returns -1, if block is erased
159 /* First test for erased block */
195 static loff_t sm_mkoffset(struct sm_ftl *ftl, int zone, int block, int boffset)
199 WARN_ON(block >= ftl->zone_size);
202 if (block == -1)
205 return (zone * SM_MAX_ZONE_SIZE + block) * ftl->block_size + boffset;
210 int *zone, int *block, int *boffset)
213 *block = do_div(offset, ftl->max_lba);
237 int zone, int block, int boffset,
247 if (block == -1) {
267 if (zone == 0 && block == ftl->cis_block && boffset ==
278 ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
282 dbg("read of block %d at zone %d, failed due to error (%d)",
283 block, zone, ret);
300 dbg("read of block %d at zone %d, failed because it is marked"
301 " as bad" , block, zone);
309 dbg("read of block %d at zone %d, failed due to ECC error",
310 block, zone);
319 int zone, int block, int boffset,
328 if (zone == 0 && (block == ftl->cis_block || block == 0)) {
343 ret = mtd_write_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
348 dbg("write to block %d at zone %d, failed with error %d",
349 block, zone, ret);
362 /* ------------------------ block IO ------------------------------------- */
364 /* Write a block using data and lba, and invalid sector bitmap */
366 int zone, int block, int lba,
387 sm_printk("sector %d of block at LBA %d of zone %d"
401 if (!sm_write_sector(ftl, zone, block, boffset,
407 /* If write fails. try to erase the block */
410 This is intended to repair block that are marked
413 if (sm_erase_block(ftl, zone, block, 0))
419 sm_mark_block_bad(ftl, zone, block);
427 /* Mark whole block at offset 'offs' as bad. */
428 static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block)
442 sm_printk("marking block %d of zone %d as bad", block, zone);
448 sm_write_sector(ftl, zone, block, boffset, NULL, &oob);
452 * Erase a block within a zone
453 * If erase succeeds, it updates free block fifo, otherwise marks block as bad
455 static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
464 erase.addr = sm_mkoffset(ftl, zone_num, block, 0);
473 if (zone_num == 0 && (block == ftl->cis_block || block == 0)) {
479 sm_printk("erase of block %d in zone %d failed",
480 block, zone_num);
488 sm_printk("erase of block %d in zone %d failed after wait",
489 block, zone_num);
495 (const unsigned char *)&block, sizeof(block));
499 sm_mark_block_bad(ftl, zone_num, block);
509 /* Thoroughly test that block is valid. */
510 static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
519 /* First just check that block doesn't look fishy */
526 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob))
539 /* If the block is sliced (partially erased usually) erase it */
541 sm_erase_block(ftl, zone, block, 1);
689 int block, boffset;
693 /* Search for first valid block */
694 for (block = 0 ; block < ftl->zone_size - ftl->max_lba ; block++) {
696 if (sm_read_sector(ftl, 0, block, 0, NULL, &oob))
708 /* Search for first valid sector in this block */
712 if (sm_read_sector(ftl, 0, block, boffset, NULL, &oob))
723 ftl->cis_block = block;
735 dbg("CIS block found at offset %x",
736 block * ftl->block_size +
762 uint16_t block;
784 for (block = 0 ; block < ftl->zone_size ; block++) {
787 if (zone_num == 0 && block <= ftl->cis_block)
791 if (sm_read_sector(ftl, zone_num, block, 0, NULL, &oob))
794 /* Test to see if block is erased. It is enough to test
798 (unsigned char *)&block, 2);
802 /* If block is marked as bad, skip it */
804 /* However the way the block valid status is defined, ensures
807 dbg("PH %04d <-> <marked bad>", block);
814 /* Invalid LBA means that block is damaged. */
818 dbg("PH %04d <-> LBA %04d(bad)", block, lba);
826 dbg_verbose("PH %04d <-> LBA %04d", block, lba);
827 zone->lba_to_phys_table[lba] = block;
833 lba, zone->lba_to_phys_table[lba], block, zone_num);
835 /* Test that this block is valid*/
836 if (sm_check_block(ftl, zone_num, block))
839 /* Test now the old block */
842 zone->lba_to_phys_table[lba] = block;
851 sm_erase_block(ftl, zone_num, block, 1);
864 /* Randomize first block we write to */
870 (unsigned char *)&block, 2);
872 kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2);
898 /* Initialize the one block cache */
908 /* Put sector in one block cache */
948 /* Try to read all unread areas of the cache block*/
964 /* we could still continue by erasing/writing the current block,
981 /* Write succesfull, so erase and free the old block */
1016 int zone_num, block, boffset;
1018 sm_break_offset(ftl, sect_no << 9, &zone_num, &block, &boffset);
1029 if (ftl->cache_zone == zone_num && ftl->cache_block == block) {
1035 /* Translate the block and return if doesn't exist in the table */
1036 block = zone->lba_to_phys_table[block];
1038 if (block == -1) {
1043 if (sm_read_sector(ftl, zone_num, block, boffset, buf, NULL)) {
1061 int error = 0, zone_num, block, boffset;
1064 sm_break_offset(ftl, sec_no << 9, &zone_num, &block, &boffset);
1077 if (ftl->cache_block != block || ftl->cache_zone != zone_num) {
1083 ftl->cache_block = block;
1203 dbg("each block consists of %d bytes",