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
135 zone = &dev->zones[i]; in null_init_zoned_dev()
137 null_init_zone_lock(dev, zone); in null_init_zoned_dev()
138 zone->start = sector; in null_init_zoned_dev()
139 zone->len = dev->zone_size_sects; in null_init_zoned_dev()
140 zone->capacity = zone->len; in null_init_zoned_dev()
141 zone->wp = zone->start + zone->len; in null_init_zoned_dev()
142 zone->type = BLK_ZONE_TYPE_CONVENTIONAL; in null_init_zoned_dev()
143 zone->cond = BLK_ZONE_COND_NOT_WP; in null_init_zoned_dev()
149 zone = &dev->zones[i]; in null_init_zoned_dev()
151 null_init_zone_lock(dev, zone); in null_init_zoned_dev()
152 zone->start = zone->wp = sector; in null_init_zoned_dev()
153 if (zone->start + dev->zone_size_sects > dev_capacity_sects) in null_init_zoned_dev()
154 zone->len = dev_capacity_sects - zone->start; in null_init_zoned_dev()
156 zone->len = dev->zone_size_sects; in null_init_zoned_dev()
157 zone->capacity = in null_init_zoned_dev()
158 min_t(sector_t, zone->len, zone_capacity_sects); in null_init_zoned_dev()
159 zone->type = BLK_ZONE_TYPE_SEQWRITE_REQ; in null_init_zoned_dev()
160 zone->cond = BLK_ZONE_COND_EMPTY; in null_init_zoned_dev()
200 struct nullb_zone *zone; in null_report_zones() local
212 zone = &dev->zones[first_zone]; in null_report_zones()
213 for (i = 0; i < nr_zones; i++, zone++) { in null_report_zones()
220 null_lock_zone(dev, zone); in null_report_zones()
221 blkz.start = zone->start; in null_report_zones()
222 blkz.len = zone->len; in null_report_zones()
223 blkz.wp = zone->wp; in null_report_zones()
224 blkz.type = zone->type; in null_report_zones()
225 blkz.cond = zone->cond; in null_report_zones()
226 blkz.capacity = zone->capacity; in null_report_zones()
227 null_unlock_zone(dev, zone); in null_report_zones()
245 struct nullb_zone *zone = &dev->zones[null_zone_no(dev, sector)]; in null_zone_valid_read_len() local
249 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL || in null_zone_valid_read_len()
250 sector + nr_sectors <= zone->wp) in null_zone_valid_read_len()
253 if (sector > zone->wp) in null_zone_valid_read_len()
256 return (zone->wp - sector) << SECTOR_SHIFT; in null_zone_valid_read_len()
260 struct nullb_zone *zone) in __null_close_zone() argument
262 switch (zone->cond) { in __null_close_zone()
278 if (zone->wp == zone->start) { in __null_close_zone()
279 zone->cond = BLK_ZONE_COND_EMPTY; in __null_close_zone()
281 zone->cond = BLK_ZONE_COND_CLOSED; in __null_close_zone()
290 struct nullb_zone *zone; in null_close_imp_open_zone() local
298 zone = &dev->zones[zno]; in null_close_imp_open_zone()
303 if (zone->cond == BLK_ZONE_COND_IMP_OPEN) { in null_close_imp_open_zone()
304 __null_close_zone(dev, zone); in null_close_imp_open_zone()
355 struct nullb_zone *zone) in null_check_zone_resources() argument
359 switch (zone->cond) { in null_check_zone_resources()
379 struct nullb_zone *zone = &dev->zones[zno]; in null_zone_write() local
382 trace_nullb_zone_op(cmd, zno, zone->cond); in null_zone_write()
384 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { in null_zone_write()
390 null_lock_zone(dev, zone); in null_zone_write()
392 if (zone->cond == BLK_ZONE_COND_FULL || in null_zone_write()
393 zone->cond == BLK_ZONE_COND_READONLY || in null_zone_write()
394 zone->cond == BLK_ZONE_COND_OFFLINE) { in null_zone_write()
407 sector = zone->wp; in null_zone_write()
412 } else if (sector != zone->wp) { in null_zone_write()
417 if (zone->wp + nr_sectors > zone->start + zone->capacity) { in null_zone_write()
422 if (zone->cond == BLK_ZONE_COND_CLOSED || in null_zone_write()
423 zone->cond == BLK_ZONE_COND_EMPTY) { in null_zone_write()
426 ret = null_check_zone_resources(dev, zone); in null_zone_write()
431 if (zone->cond == BLK_ZONE_COND_CLOSED) { in null_zone_write()
434 } else if (zone->cond == BLK_ZONE_COND_EMPTY) { in null_zone_write()
438 if (zone->cond != BLK_ZONE_COND_EXP_OPEN) in null_zone_write()
439 zone->cond = BLK_ZONE_COND_IMP_OPEN; in null_zone_write()
448 zone->wp += nr_sectors; in null_zone_write()
449 if (zone->wp == zone->start + zone->capacity) { in null_zone_write()
451 if (zone->cond == BLK_ZONE_COND_EXP_OPEN) in null_zone_write()
453 else if (zone->cond == BLK_ZONE_COND_IMP_OPEN) in null_zone_write()
455 zone->cond = BLK_ZONE_COND_FULL; in null_zone_write()
462 null_unlock_zone(dev, zone); in null_zone_write()
468 struct nullb_zone *zone) in null_open_zone() argument
472 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_open_zone()
477 switch (zone->cond) { in null_open_zone()
482 ret = null_check_zone_resources(dev, zone); in null_open_zone()
490 ret = null_check_zone_resources(dev, zone); in null_open_zone()
501 zone->cond = BLK_ZONE_COND_EXP_OPEN; in null_open_zone()
511 struct nullb_zone *zone) in null_close_zone() argument
515 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_close_zone()
519 ret = __null_close_zone(dev, zone); in null_close_zone()
526 struct nullb_zone *zone) in null_finish_zone() argument
530 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_finish_zone()
535 switch (zone->cond) { in null_finish_zone()
540 ret = null_check_zone_resources(dev, zone); in null_finish_zone()
551 ret = null_check_zone_resources(dev, zone); in null_finish_zone()
561 zone->cond = BLK_ZONE_COND_FULL; in null_finish_zone()
562 zone->wp = zone->start + zone->len; in null_finish_zone()
571 struct nullb_zone *zone) in null_reset_zone() argument
573 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) in null_reset_zone()
578 switch (zone->cond) { in null_reset_zone()
599 zone->cond = BLK_ZONE_COND_EMPTY; in null_reset_zone()
600 zone->wp = zone->start; in null_reset_zone()
605 return null_handle_discard(dev, zone->start, zone->len); in null_reset_zone()
615 struct nullb_zone *zone; in null_zone_mgmt() local
621 zone = &dev->zones[i]; in null_zone_mgmt()
622 null_lock_zone(dev, zone); in null_zone_mgmt()
623 if (zone->cond != BLK_ZONE_COND_EMPTY && in null_zone_mgmt()
624 zone->cond != BLK_ZONE_COND_READONLY && in null_zone_mgmt()
625 zone->cond != BLK_ZONE_COND_OFFLINE) { in null_zone_mgmt()
626 null_reset_zone(dev, zone); in null_zone_mgmt()
627 trace_nullb_zone_op(cmd, i, zone->cond); in null_zone_mgmt()
629 null_unlock_zone(dev, zone); in null_zone_mgmt()
635 zone = &dev->zones[zone_no]; in null_zone_mgmt()
637 null_lock_zone(dev, zone); in null_zone_mgmt()
639 if (zone->cond == BLK_ZONE_COND_READONLY || in null_zone_mgmt()
640 zone->cond == BLK_ZONE_COND_OFFLINE) { in null_zone_mgmt()
647 ret = null_reset_zone(dev, zone); in null_zone_mgmt()
650 ret = null_open_zone(dev, zone); in null_zone_mgmt()
653 ret = null_close_zone(dev, zone); in null_zone_mgmt()
656 ret = null_finish_zone(dev, zone); in null_zone_mgmt()
664 trace_nullb_zone_op(cmd, zone_no, zone->cond); in null_zone_mgmt()
667 null_unlock_zone(dev, zone); in null_zone_mgmt()
676 struct nullb_zone *zone; in null_process_zoned_cmd() local
692 zone = &dev->zones[null_zone_no(dev, sector)]; in null_process_zoned_cmd()
693 if (zone->cond == BLK_ZONE_COND_OFFLINE) in null_process_zoned_cmd()
696 null_lock_zone(dev, zone); in null_process_zoned_cmd()
698 null_unlock_zone(dev, zone); in null_process_zoned_cmd()
707 struct nullb_zone *zone, enum blk_zone_cond cond) in null_set_zone_cond() argument
713 null_lock_zone(dev, zone); in null_set_zone_cond()
722 if (zone->cond == cond) { in null_set_zone_cond()
723 zone->cond = BLK_ZONE_COND_EMPTY; in null_set_zone_cond()
724 zone->wp = zone->start; in null_set_zone_cond()
726 null_handle_discard(dev, zone->start, zone->len); in null_set_zone_cond()
728 if (zone->cond != BLK_ZONE_COND_READONLY && in null_set_zone_cond()
729 zone->cond != BLK_ZONE_COND_OFFLINE) in null_set_zone_cond()
730 null_finish_zone(dev, zone); in null_set_zone_cond()
731 zone->cond = cond; in null_set_zone_cond()
732 zone->wp = (sector_t)-1; in null_set_zone_cond()
735 null_unlock_zone(dev, zone); in null_set_zone_cond()