Lines Matching refs:zone
35 struct nullb_zone *zone) in null_init_zone_lock() argument
38 spin_lock_init(&zone->spinlock); in null_init_zone_lock()
40 mutex_init(&zone->mutex); in null_init_zone_lock()
44 struct nullb_zone *zone) in null_lock_zone() argument
47 spin_lock_irq(&zone->spinlock); in null_lock_zone()
49 mutex_lock(&zone->mutex); in null_lock_zone()
53 struct nullb_zone *zone) in null_unlock_zone() argument
56 spin_unlock_irq(&zone->spinlock); in null_unlock_zone()
58 mutex_unlock(&zone->mutex); in null_unlock_zone()
64 struct nullb_zone *zone; in null_init_zoned_dev() local
125 zone = &dev->zones[i]; in null_init_zoned_dev()
127 null_init_zone_lock(dev, zone); in null_init_zoned_dev()
128 zone->start = sector; in null_init_zoned_dev()
129 zone->len = dev->zone_size_sects; in null_init_zoned_dev()
130 zone->capacity = zone->len; in null_init_zoned_dev()
131 zone->wp = zone->start + zone->len; in null_init_zoned_dev()
132 zone->type = BLK_ZONE_TYPE_CONVENTIONAL; in null_init_zoned_dev()
133 zone->cond = BLK_ZONE_COND_NOT_WP; in null_init_zoned_dev()
139 zone = &dev->zones[i]; in null_init_zoned_dev()
141 null_init_zone_lock(dev, zone); in null_init_zoned_dev()
142 zone->start = zone->wp = sector; in null_init_zoned_dev()
143 if (zone->start + dev->zone_size_sects > dev_capacity_sects) in null_init_zoned_dev()
144 zone->len = dev_capacity_sects - zone->start; in null_init_zoned_dev()
146 zone->len = dev->zone_size_sects; in null_init_zoned_dev()
147 zone->capacity = in null_init_zoned_dev()
148 min_t(sector_t, zone->len, zone_capacity_sects); in null_init_zoned_dev()
149 zone->type = BLK_ZONE_TYPE_SEQWRITE_REQ; in null_init_zoned_dev()
150 zone->cond = BLK_ZONE_COND_EMPTY; in null_init_zoned_dev()
196 struct nullb_zone *zone; in null_report_zones() local
208 zone = &dev->zones[first_zone]; in null_report_zones()
209 for (i = 0; i < nr_zones; i++, zone++) { in null_report_zones()
216 null_lock_zone(dev, zone); in null_report_zones()
217 blkz.start = zone->start; in null_report_zones()
218 blkz.len = zone->len; in null_report_zones()
219 blkz.wp = zone->wp; in null_report_zones()
220 blkz.type = zone->type; in null_report_zones()
221 blkz.cond = zone->cond; in null_report_zones()
222 blkz.capacity = zone->capacity; in null_report_zones()
223 null_unlock_zone(dev, zone); in null_report_zones()
241 struct nullb_zone *zone = &dev->zones[null_zone_no(dev, sector)]; in null_zone_valid_read_len() local
245 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL || in null_zone_valid_read_len()
246 sector + nr_sectors <= zone->wp) in null_zone_valid_read_len()
249 if (sector > zone->wp) in null_zone_valid_read_len()
252 return (zone->wp - sector) << SECTOR_SHIFT; in null_zone_valid_read_len()
256 struct nullb_zone *zone) in __null_close_zone() argument
258 switch (zone->cond) { in __null_close_zone()
274 if (zone->wp == zone->start) { in __null_close_zone()
275 zone->cond = BLK_ZONE_COND_EMPTY; in __null_close_zone()
277 zone->cond = BLK_ZONE_COND_CLOSED; in __null_close_zone()
286 struct nullb_zone *zone; in null_close_imp_open_zone() local
294 zone = &dev->zones[zno]; in null_close_imp_open_zone()
299 if (zone->cond == BLK_ZONE_COND_IMP_OPEN) { in null_close_imp_open_zone()
300 __null_close_zone(dev, zone); in null_close_imp_open_zone()
351 struct nullb_zone *zone) in null_check_zone_resources() argument
355 switch (zone->cond) { in null_check_zone_resources()
375 struct nullb_zone *zone = &dev->zones[zno]; in null_zone_write() local
378 trace_nullb_zone_op(cmd, zno, zone->cond); in null_zone_write()
380 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { in null_zone_write()
386 null_lock_zone(dev, zone); in null_zone_write()
388 if (zone->cond == BLK_ZONE_COND_FULL) { in null_zone_write()
401 sector = zone->wp; in null_zone_write()
406 } else if (sector != zone->wp) { in null_zone_write()
411 if (zone->wp + nr_sectors > zone->start + zone->capacity) { in null_zone_write()
416 if (zone->cond == BLK_ZONE_COND_CLOSED || in null_zone_write()
417 zone->cond == BLK_ZONE_COND_EMPTY) { in null_zone_write()
420 ret = null_check_zone_resources(dev, zone); in null_zone_write()
425 if (zone->cond == BLK_ZONE_COND_CLOSED) { in null_zone_write()
428 } else if (zone->cond == BLK_ZONE_COND_EMPTY) { in null_zone_write()
432 if (zone->cond != BLK_ZONE_COND_EXP_OPEN) in null_zone_write()
433 zone->cond = BLK_ZONE_COND_IMP_OPEN; in null_zone_write()
442 zone->wp += nr_sectors; in null_zone_write()
443 if (zone->wp == zone->start + zone->capacity) { in null_zone_write()
445 if (zone->cond == BLK_ZONE_COND_EXP_OPEN) in null_zone_write()
447 else if (zone->cond == BLK_ZONE_COND_IMP_OPEN) in null_zone_write()
449 zone->cond = BLK_ZONE_COND_FULL; in null_zone_write()
456 null_unlock_zone(dev, zone); in null_zone_write()
462 struct nullb_zone *zone) in null_open_zone() argument
466 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_open_zone()
471 switch (zone->cond) { in null_open_zone()
476 ret = null_check_zone_resources(dev, zone); in null_open_zone()
484 ret = null_check_zone_resources(dev, zone); in null_open_zone()
495 zone->cond = BLK_ZONE_COND_EXP_OPEN; in null_open_zone()
505 struct nullb_zone *zone) in null_close_zone() argument
509 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_close_zone()
513 ret = __null_close_zone(dev, zone); in null_close_zone()
520 struct nullb_zone *zone) in null_finish_zone() argument
524 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_finish_zone()
529 switch (zone->cond) { in null_finish_zone()
534 ret = null_check_zone_resources(dev, zone); in null_finish_zone()
545 ret = null_check_zone_resources(dev, zone); in null_finish_zone()
555 zone->cond = BLK_ZONE_COND_FULL; in null_finish_zone()
556 zone->wp = zone->start + zone->len; in null_finish_zone()
565 struct nullb_zone *zone) in null_reset_zone() argument
567 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_reset_zone()
572 switch (zone->cond) { in null_reset_zone()
593 zone->cond = BLK_ZONE_COND_EMPTY; in null_reset_zone()
594 zone->wp = zone->start; in null_reset_zone()
599 return null_handle_discard(dev, zone->start, zone->len); in null_reset_zone()
609 struct nullb_zone *zone; in null_zone_mgmt() local
615 zone = &dev->zones[i]; in null_zone_mgmt()
616 null_lock_zone(dev, zone); in null_zone_mgmt()
617 if (zone->cond != BLK_ZONE_COND_EMPTY) { in null_zone_mgmt()
618 null_reset_zone(dev, zone); in null_zone_mgmt()
619 trace_nullb_zone_op(cmd, i, zone->cond); in null_zone_mgmt()
621 null_unlock_zone(dev, zone); in null_zone_mgmt()
627 zone = &dev->zones[zone_no]; in null_zone_mgmt()
629 null_lock_zone(dev, zone); in null_zone_mgmt()
633 ret = null_reset_zone(dev, zone); in null_zone_mgmt()
636 ret = null_open_zone(dev, zone); in null_zone_mgmt()
639 ret = null_close_zone(dev, zone); in null_zone_mgmt()
642 ret = null_finish_zone(dev, zone); in null_zone_mgmt()
650 trace_nullb_zone_op(cmd, zone_no, zone->cond); in null_zone_mgmt()
652 null_unlock_zone(dev, zone); in null_zone_mgmt()
661 struct nullb_zone *zone; in null_process_zoned_cmd() local
677 zone = &dev->zones[null_zone_no(dev, sector)]; in null_process_zoned_cmd()
679 null_lock_zone(dev, zone); in null_process_zoned_cmd()
681 null_unlock_zone(dev, zone); in null_process_zoned_cmd()