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);
239 int zone, int block, int boffset,
249 if (block == -1) {
270 if (zone == 0 && block == ftl->cis_block && boffset ==
281 ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
285 dbg("read of block %d at zone %d, failed due to error (%d)",
286 block, zone, ret);
303 dbg("read of block %d at zone %d, failed because it is marked"
304 " as bad" , block, zone);
312 dbg("read of block %d at zone %d, failed due to ECC error",
313 block, zone);
322 int zone, int block, int boffset,
331 if (zone == 0 && (block == ftl->cis_block || block == 0)) {
346 ret = mtd_write_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
351 dbg("write to block %d at zone %d, failed with error %d",
352 block, zone, ret);
365 /* ------------------------ block IO ------------------------------------- */
367 /* Write a block using data and lba, and invalid sector bitmap */
369 int zone, int block, int lba,
390 sm_printk("sector %d of block at LBA %d of zone %d"
406 if (!sm_write_sector(ftl, zone, block, boffset,
412 /* If write fails. try to erase the block */
415 This is intended to repair block that are marked
418 if (sm_erase_block(ftl, zone, block, 0))
424 sm_mark_block_bad(ftl, zone, block);
432 /* Mark whole block at offset 'offs' as bad. */
433 static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block)
447 sm_printk("marking block %d of zone %d as bad", block, zone);
453 sm_write_sector(ftl, zone, block, boffset, NULL, &oob);
457 * Erase a block within a zone
458 * If erase succeeds, it updates free block fifo, otherwise marks block as bad
460 static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
467 erase.addr = sm_mkoffset(ftl, zone_num, block, 0);
475 if (zone_num == 0 && (block == ftl->cis_block || block == 0)) {
481 sm_printk("erase of block %d in zone %d failed",
482 block, zone_num);
488 (const unsigned char *)&block, sizeof(block));
492 sm_mark_block_bad(ftl, zone_num, block);
496 /* Thoroughly test that block is valid. */
497 static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
506 /* First just check that block doesn't look fishy */
513 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob))
526 /* If the block is sliced (partially erased usually) erase it */
528 sm_erase_block(ftl, zone, block, 1);
676 int block, boffset;
680 /* Search for first valid block */
681 for (block = 0 ; block < ftl->zone_size - ftl->max_lba ; block++) {
683 if (sm_read_sector(ftl, 0, block, 0, NULL, &oob))
695 /* Search for first valid sector in this block */
699 if (sm_read_sector(ftl, 0, block, boffset, NULL, &oob))
710 ftl->cis_block = block;
722 dbg("CIS block found at offset %x",
723 block * ftl->block_size +
749 uint16_t block;
771 for (block = 0 ; block < ftl->zone_size ; block++) {
774 if (zone_num == 0 && block <= ftl->cis_block)
778 if (sm_read_sector(ftl, zone_num, block, 0, NULL, &oob)) {
784 /* Test to see if block is erased. It is enough to test
788 (unsigned char *)&block, 2);
792 /* If block is marked as bad, skip it */
794 /* However the way the block valid status is defined, ensures
797 dbg("PH %04d <-> <marked bad>", block);
804 /* Invalid LBA means that block is damaged. */
808 dbg("PH %04d <-> LBA %04d(bad)", block, lba);
816 dbg_verbose("PH %04d <-> LBA %04d", block, lba);
817 zone->lba_to_phys_table[lba] = block;
823 lba, zone->lba_to_phys_table[lba], block, zone_num);
825 /* Test that this block is valid*/
826 if (sm_check_block(ftl, zone_num, block))
829 /* Test now the old block */
832 zone->lba_to_phys_table[lba] = block;
841 sm_erase_block(ftl, zone_num, block, 1);
854 /* Randomize first block we write to */
860 (unsigned char *)&block, 2);
862 kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2);
888 /* Initialize the one block cache */
898 /* Put sector in one block cache */
938 /* Try to read all unread areas of the cache block*/
954 /* we could still continue by erasing/writing the current block,
971 /* Write succesfull, so erase and free the old block */
1006 int zone_num, block, boffset;
1008 sm_break_offset(ftl, sect_no << 9, &zone_num, &block, &boffset);
1019 if (ftl->cache_zone == zone_num && ftl->cache_block == block) {
1025 /* Translate the block and return if doesn't exist in the table */
1026 block = zone->lba_to_phys_table[block];
1028 if (block == -1) {
1033 if (sm_read_sector(ftl, zone_num, block, boffset, buf, NULL)) {
1051 int error = 0, zone_num, block, boffset;
1054 sm_break_offset(ftl, sec_no << 9, &zone_num, &block, &boffset);
1067 if (ftl->cache_block != block || ftl->cache_zone != zone_num) {
1073 ftl->cache_block = block;
1192 dbg("each block consists of %d bytes",