Lines Matching refs:zone
195 static loff_t sm_mkoffset(struct sm_ftl *ftl, int zone, int block, int boffset) in sm_mkoffset() argument
198 WARN_ON(zone < 0 || zone >= ftl->zone_count); in sm_mkoffset()
205 return (zone * SM_MAX_ZONE_SIZE + block) * ftl->block_size + boffset; in sm_mkoffset()
210 int *zone, int *block, int *boffset) in sm_break_offset() argument
215 *zone = offset >= ftl->zone_count ? -1 : offset; in sm_break_offset()
238 int zone, int block, int boffset, in sm_read_sector() argument
268 if (zone == 0 && block == ftl->cis_block && boffset == in sm_read_sector()
279 ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); in sm_read_sector()
284 block, zone, ret); in sm_read_sector()
302 " as bad" , block, zone); in sm_read_sector()
311 block, zone); in sm_read_sector()
320 int zone, int block, int boffset, in sm_write_sector() argument
329 if (zone == 0 && (block == ftl->cis_block || block == 0)) { in sm_write_sector()
344 ret = mtd_write_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); in sm_write_sector()
350 block, zone, ret); in sm_write_sector()
367 int zone, int block, int lba, in sm_write_block() argument
390 boffset / SM_SECTOR_SIZE, lba, zone); in sm_write_block()
402 if (!sm_write_sector(ftl, zone, block, boffset, in sm_write_block()
414 if (sm_erase_block(ftl, zone, block, 0)) in sm_write_block()
420 sm_mark_block_bad(ftl, zone, block); in sm_write_block()
429 static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block) in sm_mark_block_bad() argument
443 sm_printk("marking block %d of zone %d as bad", block, zone); in sm_mark_block_bad()
449 sm_write_sector(ftl, zone, block, boffset, NULL, &oob); in sm_mark_block_bad()
459 struct ftl_zone *zone = &ftl->zones[zone_num]; in sm_erase_block() local
495 kfifo_in(&zone->free_sectors, in sm_erase_block()
511 static int sm_check_block(struct sm_ftl *ftl, int zone, int block) in sm_check_block() argument
527 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob)) in sm_check_block()
542 sm_erase_block(ftl, zone, block, 1); in sm_check_block()
761 struct ftl_zone *zone = &ftl->zones[zone_num]; in sm_init_zone() local
771 zone->lba_to_phys_table = kmalloc(ftl->max_lba * 2, GFP_KERNEL); in sm_init_zone()
773 if (!zone->lba_to_phys_table) in sm_init_zone()
775 memset(zone->lba_to_phys_table, -1, ftl->max_lba * 2); in sm_init_zone()
779 if (kfifo_alloc(&zone->free_sectors, ftl->zone_size * 2, GFP_KERNEL)) { in sm_init_zone()
780 kfree(zone->lba_to_phys_table); in sm_init_zone()
798 kfifo_in(&zone->free_sectors, in sm_init_zone()
826 if (zone->lba_to_phys_table[lba] < 0) { in sm_init_zone()
828 zone->lba_to_phys_table[lba] = block; in sm_init_zone()
834 lba, zone->lba_to_phys_table[lba], block, zone_num); in sm_init_zone()
842 zone->lba_to_phys_table[lba])) { in sm_init_zone()
843 zone->lba_to_phys_table[lba] = block; in sm_init_zone()
856 zone->initialized = 1; in sm_init_zone()
860 if (!kfifo_len(&zone->free_sectors)) { in sm_init_zone()
867 i %= (kfifo_len(&zone->free_sectors) / 2); in sm_init_zone()
870 len = kfifo_out(&zone->free_sectors, in sm_init_zone()
873 kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2); in sm_init_zone()
881 struct ftl_zone *zone; in sm_get_zone() local
885 zone = &ftl->zones[zone_num]; in sm_get_zone()
887 if (!zone->initialized) { in sm_get_zone()
893 return zone; in sm_get_zone()
931 struct ftl_zone *zone; in sm_cache_flush() local
945 zone = &ftl->zones[zone_num]; in sm_cache_flush()
946 block_num = zone->lba_to_phys_table[ftl->cache_block]; in sm_cache_flush()
968 if (kfifo_out(&zone->free_sectors, in sm_cache_flush()
980 zone->lba_to_phys_table[ftl->cache_block] = write_sector; in sm_cache_flush()
1015 struct ftl_zone *zone; in sm_read() local
1023 zone = sm_get_zone(ftl, zone_num); in sm_read()
1024 if (IS_ERR(zone)) { in sm_read()
1025 error = PTR_ERR(zone); in sm_read()
1037 block = zone->lba_to_phys_table[block]; in sm_read()
1061 struct ftl_zone *zone; in sm_write() local
1071 zone = sm_get_zone(ftl, zone_num); in sm_write()
1072 if (IS_ERR(zone)) { in sm_write()
1073 error = PTR_ERR(zone); in sm_write()