# ReZNS: Energy and Performance-Optimal Mapping Mechanism for ZNS SSD
## 3 Design and Implementation
### Overall Architecture of ReZNS  
**Zone-reset and Renewable-zones:** Unlike the traditional ZNS SSD, ReZNS does not immediately handle a zone-reset command from the host because the corresponding zone can be reused in the future. Of course, this operation may have a negative effect on space utilization. Thus, ReZNS employs ReGC to address the problem (we will describe ReGC in more detail). When ZNS SSD needs to service a zone-reset command issued from the host, ReZNS first investigates whether the corresponding zone can be renewable or not based on the remaining capacity, and then it categorizes it into two types: normal zone (Nzone) and renewable zone (Rzone). If the remaining capacity in the zone to be reset is more than 25%, ReZNS marks it as Rzone and inserts it in the auxiliary list (called \"_spare-list_\") instead of performing the zone-reset command. Consequently, ReZNS delays a costly zone-reset command for the zone whose capacity remains at more than 25%; it should have a positive effect on the lifespan of the ZNS SSD. Otherwise, ReZNS marks the zone as Nzone to inherit the design philosophy of ZNS SSDs (i.e., \"one workload per zone\"). This means that a zone marked as Nzone is serviced the same as traditional ZNS SSDs for the zone-reset command. **Recycling and Allocation:** Once a Rzone is inserted in the _spare-list_, ReZNS resorts the list according to the remaining capacity in descending order (i.e., from high to low). This helps to improve both reuse possibility and space efficiency in ReZNS when a zone creation is needed. In ReZNS, it prefers to recycle a zone in the _spare-list_ rather than the creation of a new zone. This is for two reasons. First, reusing Rzone is suitable for resource management because it gives applications more opportunities to create their own zones. Note that ZNSSSDs are limited by the maximum number of zones that can be physically created. Second, workloads requiring small writes and short lifetimes efficiently share the remaining space in Rzone; thus, it improves the total usable capacity of ZNS SSD. In summary, when a request for a zone creation is received from the host, ReZNS assigns one of the Rzones with the largest remaining capacity in the _spare-list_ to the corresponding zone ID. If there are no more zones in the list to allocate, ReZNS creates a new zone according to the basic rules of the traditional ZNS SSD. Meanwhile, reusing the Rzone belonging to the _spare-list_ can be considered harmful in terms of isolation in that the application's data can be scattered throughout the zones. However, because ReZNS prioritizes candidates by sorting the available free space in descending order, it is unlikely that data will be severely scattered during runtime. **Zombie-zones:** Triggering the zone-reset command is explicitly performed by host applications. Therefore, if an application is terminated without the zone-reset command, one or more zones allocated to the application unintentionally leave open zones with an idle state on the ZNS SSD (we call this open zone a \"_zombie zone_\"). To reclaim zombie zones, ReZNS employs a daemon that is periodically triggered based on a time threshold to scan _open zones_, and it inserts the zones into the _spare-list_ if some zones are no longer used and exceed the time threshold. Meanwhile, the daemon rarely impacts the overall performance and is negligible because it performs a background thread. Note that since a lower threshold triggers the daemon too quickly and unnecessarily inserts open zones into the _spare-list_, we empirically set the threshold to 1 h, which is enough to match the changes in write patterns from applications. **Renewable-zone Garbage Collection (ReGC):** If too many Rzones exist in the _spare-list_ and they are not used for a long time, ReZNS releases some of the Rzones asynchronously from the list because they can be harmful in terms of management costs (we call this ReGC). For example, it may increase the time for sorting operations and violate the above design philosophy of the ZNS SSD.