Lines Matching refs:zone_info
182 struct btrfs_zoned_device_info *zone_info) in zone_start_physical() argument
184 return (u64)zone_number << zone_info->zone_size_shift; in zone_start_physical()
220 struct btrfs_zoned_device_info *zinfo = device->zone_info; in btrfs_get_dev_zones()
246 struct blk_zone *zone_info; in btrfs_get_dev_zones() local
248 zone_info = &zinfo->zone_cache[zno + i]; in btrfs_get_dev_zones()
249 if (!zone_info->len) in btrfs_get_dev_zones()
354 struct btrfs_zoned_device_info *zone_info = NULL; in btrfs_get_dev_zone_info() local
373 if (device->zone_info) in btrfs_get_dev_zone_info()
376 zone_info = kzalloc(sizeof(*zone_info), GFP_KERNEL); in btrfs_get_dev_zone_info()
377 if (!zone_info) in btrfs_get_dev_zone_info()
380 device->zone_info = zone_info; in btrfs_get_dev_zone_info()
397 zone_info->zone_size = zone_sectors << SECTOR_SHIFT; in btrfs_get_dev_zone_info()
400 if (zone_info->zone_size > BTRFS_MAX_ZONE_SIZE) { in btrfs_get_dev_zone_info()
404 zone_info->zone_size, BTRFS_MAX_ZONE_SIZE); in btrfs_get_dev_zone_info()
407 } else if (zone_info->zone_size < BTRFS_MIN_ZONE_SIZE) { in btrfs_get_dev_zone_info()
411 zone_info->zone_size, BTRFS_MIN_ZONE_SIZE); in btrfs_get_dev_zone_info()
417 zone_info->zone_size_shift = ilog2(zone_info->zone_size); in btrfs_get_dev_zone_info()
418 zone_info->nr_zones = nr_sectors >> ilog2(zone_sectors); in btrfs_get_dev_zone_info()
431 zone_info->max_zone_append_size = min_t(u64, in btrfs_get_dev_zone_info()
435 zone_info->max_zone_append_size = in btrfs_get_dev_zone_info()
439 zone_info->nr_zones++; in btrfs_get_dev_zone_info()
450 zone_info->max_active_zones = max_active_zones; in btrfs_get_dev_zone_info()
452 zone_info->seq_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL); in btrfs_get_dev_zone_info()
453 if (!zone_info->seq_zones) { in btrfs_get_dev_zone_info()
458 zone_info->empty_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL); in btrfs_get_dev_zone_info()
459 if (!zone_info->empty_zones) { in btrfs_get_dev_zone_info()
464 zone_info->active_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL); in btrfs_get_dev_zone_info()
465 if (!zone_info->active_zones) { in btrfs_get_dev_zone_info()
482 zone_info->zone_cache = vzalloc(sizeof(struct blk_zone) * in btrfs_get_dev_zone_info()
483 zone_info->nr_zones); in btrfs_get_dev_zone_info()
484 if (!zone_info->zone_cache) { in btrfs_get_dev_zone_info()
504 __set_bit(nreported, zone_info->seq_zones); in btrfs_get_dev_zone_info()
507 __set_bit(nreported, zone_info->empty_zones); in btrfs_get_dev_zone_info()
512 __set_bit(nreported, zone_info->active_zones); in btrfs_get_dev_zone_info()
521 if (nreported != zone_info->nr_zones) { in btrfs_get_dev_zone_info()
525 zone_info->nr_zones); in btrfs_get_dev_zone_info()
539 atomic_set(&zone_info->active_zones_left, in btrfs_get_dev_zone_info()
552 sb_zone = sb_zone_number(zone_info->zone_size_shift, i); in btrfs_get_dev_zone_info()
553 if (sb_zone + 1 >= zone_info->nr_zones) in btrfs_get_dev_zone_info()
557 zone_start_physical(sb_zone, zone_info), in btrfs_get_dev_zone_info()
558 &zone_info->sb_zones[sb_pos], in btrfs_get_dev_zone_info()
575 if (zone_info->sb_zones[BTRFS_NR_SB_LOG_ZONES * i].type == in btrfs_get_dev_zone_info()
580 &zone_info->sb_zones[sb_pos], &sb_wp); in btrfs_get_dev_zone_info()
617 model, rcu_str_deref(device->name), zone_info->nr_zones, in btrfs_get_dev_zone_info()
618 emulated, zone_info->zone_size); in btrfs_get_dev_zone_info()
632 struct btrfs_zoned_device_info *zone_info = device->zone_info; in btrfs_destroy_dev_zone_info() local
634 if (!zone_info) in btrfs_destroy_dev_zone_info()
637 bitmap_free(zone_info->active_zones); in btrfs_destroy_dev_zone_info()
638 bitmap_free(zone_info->seq_zones); in btrfs_destroy_dev_zone_info()
639 bitmap_free(zone_info->empty_zones); in btrfs_destroy_dev_zone_info()
640 vfree(zone_info->zone_cache); in btrfs_destroy_dev_zone_info()
641 kfree(zone_info); in btrfs_destroy_dev_zone_info()
642 device->zone_info = NULL; in btrfs_destroy_dev_zone_info()
647 struct btrfs_zoned_device_info *zone_info; in btrfs_clone_dev_zone_info() local
649 zone_info = kmemdup(orig_dev->zone_info, sizeof(*zone_info), GFP_KERNEL); in btrfs_clone_dev_zone_info()
650 if (!zone_info) in btrfs_clone_dev_zone_info()
653 zone_info->seq_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL); in btrfs_clone_dev_zone_info()
654 if (!zone_info->seq_zones) in btrfs_clone_dev_zone_info()
657 bitmap_copy(zone_info->seq_zones, orig_dev->zone_info->seq_zones, in btrfs_clone_dev_zone_info()
658 zone_info->nr_zones); in btrfs_clone_dev_zone_info()
660 zone_info->empty_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL); in btrfs_clone_dev_zone_info()
661 if (!zone_info->empty_zones) in btrfs_clone_dev_zone_info()
664 bitmap_copy(zone_info->empty_zones, orig_dev->zone_info->empty_zones, in btrfs_clone_dev_zone_info()
665 zone_info->nr_zones); in btrfs_clone_dev_zone_info()
667 zone_info->active_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL); in btrfs_clone_dev_zone_info()
668 if (!zone_info->active_zones) in btrfs_clone_dev_zone_info()
671 bitmap_copy(zone_info->active_zones, orig_dev->zone_info->active_zones, in btrfs_clone_dev_zone_info()
672 zone_info->nr_zones); in btrfs_clone_dev_zone_info()
673 zone_info->zone_cache = NULL; in btrfs_clone_dev_zone_info()
675 return zone_info; in btrfs_clone_dev_zone_info()
678 bitmap_free(zone_info->seq_zones); in btrfs_clone_dev_zone_info()
679 bitmap_free(zone_info->empty_zones); in btrfs_clone_dev_zone_info()
680 bitmap_free(zone_info->active_zones); in btrfs_clone_dev_zone_info()
681 kfree(zone_info); in btrfs_clone_dev_zone_info()
730 struct btrfs_zoned_device_info *zone_info = device->zone_info; in btrfs_check_zoned_mode() local
736 zone_size = zone_info->zone_size; in btrfs_check_zoned_mode()
737 } else if (zone_info->zone_size != zone_size) { in btrfs_check_zoned_mode()
740 zone_info->zone_size, zone_size); in btrfs_check_zoned_mode()
744 (zone_info->max_zone_append_size && in btrfs_check_zoned_mode()
745 zone_info->max_zone_append_size < max_zone_append_size)) in btrfs_check_zoned_mode()
746 max_zone_append_size = zone_info->max_zone_append_size; in btrfs_check_zoned_mode()
908 struct btrfs_zoned_device_info *zinfo = device->zone_info; in btrfs_sb_log_location()
951 struct btrfs_zoned_device_info *zinfo = device->zone_info; in btrfs_advance_sb_log()
1037 struct btrfs_zoned_device_info *zinfo = device->zone_info; in btrfs_find_allocatable_zones()
1095 struct btrfs_zoned_device_info *zone_info = device->zone_info; in btrfs_dev_set_active_zone() local
1096 unsigned int zno = (pos >> zone_info->zone_size_shift); in btrfs_dev_set_active_zone()
1099 if (zone_info->max_active_zones == 0) in btrfs_dev_set_active_zone()
1102 if (!test_bit(zno, zone_info->active_zones)) { in btrfs_dev_set_active_zone()
1104 if (atomic_dec_if_positive(&zone_info->active_zones_left) < 0) in btrfs_dev_set_active_zone()
1106 if (test_and_set_bit(zno, zone_info->active_zones)) { in btrfs_dev_set_active_zone()
1108 atomic_inc(&zone_info->active_zones_left); in btrfs_dev_set_active_zone()
1117 struct btrfs_zoned_device_info *zone_info = device->zone_info; in btrfs_dev_clear_active_zone() local
1118 unsigned int zno = (pos >> zone_info->zone_size_shift); in btrfs_dev_clear_active_zone()
1121 if (zone_info->max_active_zones == 0) in btrfs_dev_clear_active_zone()
1124 if (test_and_clear_bit(zno, zone_info->active_zones)) in btrfs_dev_clear_active_zone()
1125 atomic_inc(&zone_info->active_zones_left); in btrfs_dev_clear_active_zone()
1144 physical += device->zone_info->zone_size; in btrfs_reset_device_zone()
1145 length -= device->zone_info->zone_size; in btrfs_reset_device_zone()
1153 struct btrfs_zoned_device_info *zinfo = device->zone_info; in btrfs_ensure_empty_zones()
1369 if (!device->zone_info->max_active_zones) in btrfs_load_block_group_zone_info()
1421 physical[i] >> device->zone_info->zone_size_shift, in btrfs_load_block_group_zone_info()
1906 if (device->zone_info->max_active_zones == 0) in btrfs_zone_activate()
2047 if (device->zone_info->max_active_zones == 0) in do_zone_finish()
2052 device->zone_info->zone_size >> SECTOR_SHIFT, in do_zone_finish()
2097 struct btrfs_zoned_device_info *zinfo = device->zone_info; in btrfs_can_activate_zone()
2195 if (device->zone_info) { in btrfs_free_zone_cache()
2196 vfree(device->zone_info->zone_cache); in btrfs_free_zone_cache()
2197 device->zone_info->zone_cache = NULL; in btrfs_free_zone_cache()