Lines Matching defs:zone

192 static loff_t sm_mkoffset(struct sm_ftl *ftl, int zone, int block, int boffset)
195 WARN_ON(zone < 0 || zone >= ftl->zone_count);
202 return (zone * SM_MAX_ZONE_SIZE + block) * ftl->block_size + boffset;
207 int *zone, int *block, int *boffset)
212 *zone = offset >= ftl->zone_count ? -1 : offset;
238 int zone, int block, int boffset,
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);
370 int zone, int block, int lba,
392 sm_printk("sector %d of block at LBA %d of zone %d"
394 boffset / SM_SECTOR_SIZE, lba, zone);
408 if (!sm_write_sector(ftl, zone, block, boffset,
421 if (sm_erase_block(ftl, zone, block, 0))
427 sm_mark_block_bad(ftl, zone, block);
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
467 struct ftl_zone *zone = &ftl->zones[zone_num];
485 sm_printk("erase of block %d in zone %d failed",
491 kfifo_in(&zone->free_sectors,
501 static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
518 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob))
533 sm_erase_block(ftl, zone, block, 1);
615 /* Minimum xD size is 16MiB. Also, all xD cards have standard zone
751 /* Initialize a FTL zone */
754 struct ftl_zone *zone = &ftl->zones[zone_num];
761 dbg("initializing zone %d", zone_num);
764 zone->lba_to_phys_table = kmalloc_array(ftl->max_lba, 2, GFP_KERNEL);
766 if (!zone->lba_to_phys_table)
768 memset(zone->lba_to_phys_table, -1, ftl->max_lba * 2);
772 if (kfifo_alloc(&zone->free_sectors, ftl->zone_size * 2, GFP_KERNEL)) {
773 kfree(zone->lba_to_phys_table);
777 /* Now scan the zone */
786 kfifo_free(&zone->free_sectors);
787 kfree(zone->lba_to_phys_table);
795 kfifo_in(&zone->free_sectors,
826 if (zone->lba_to_phys_table[lba] < 0) {
828 zone->lba_to_phys_table[lba] = block;
833 " of LBA %d between blocks %d and %d in zone %d",
834 lba, zone->lba_to_phys_table[lba], block, zone_num);
842 zone->lba_to_phys_table[lba])) {
843 zone->lba_to_phys_table[lba] = block;
855 dbg("zone initialized");
856 zone->initialized = 1;
858 /* No free sectors, means that the zone is heavily damaged, write won't
861 if (!kfifo_len(&zone->free_sectors)) {
862 sm_printk("no free blocks in zone %d", zone_num);
868 i %= (kfifo_len(&zone->free_sectors) / 2);
871 len = kfifo_out(&zone->free_sectors,
874 kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2);
879 /* Get and automatically initialize an FTL mapping for one zone */
882 struct ftl_zone *zone;
886 zone = &ftl->zones[zone_num];
888 if (!zone->initialized) {
894 return zone;
932 struct ftl_zone *zone;
946 zone = &ftl->zones[zone_num];
947 block_num = zone->lba_to_phys_table[ftl->cache_block];
970 if (kfifo_out(&zone->free_sectors,
982 zone->lba_to_phys_table[ftl->cache_block] = write_sector;
1017 struct ftl_zone *zone;
1025 zone = sm_get_zone(ftl, zone_num);
1026 if (IS_ERR(zone)) {
1027 error = PTR_ERR(zone);
1039 block = zone->lba_to_phys_table[block];
1063 struct ftl_zone *zone;
1073 zone = sm_get_zone(ftl, zone_num);
1074 if (IS_ERR(zone)) {
1075 error = PTR_ERR(zone);
1159 /* Allocate zone array, it will be initialized on demand */
1202 dbg("%d zone(s), each consists of %d blocks (+%d spares)",