Method and system for reducing write amplification and storage medium
By calculating command intervals and delaying commands to align data writes, the method addresses write amplification issues in SSDs, maintaining their lifespan by managing flush and FUA commands.
Patent Information
- Application Number
- CN202510189115.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-05-13
AI Technical Summary
Solid-state drives (SSDs) experience write amplification issues due to frequent unaligned data flushes and Flush or Force Unit Access (FUA) commands, leading to reduced lifespan when used as system disks, especially under operating systems that frequently execute these commands to ensure data integrity.
Implement a method to calculate command interval times and produce flush indices, delaying commands when necessary to align data writes, thereby reducing write amplification by managing flush and FUA commands based on SSD lifespan expectations.
The method effectively reduces write amplification by controlling command frequency and data alignment, ensuring SSDs maintain their lifespan by minimizing the impact of frequent flush and FUA commands.
Smart Images

Figure CN119987681A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of solid state hard disks, and in particular to a method, system and storage medium for reducing write amplification. Background Art
[0002] The characteristic of SSD hard disk is that it must be written in full pages (16K). Under normal circumstances, the data sent from the upper layer is in units of 4K, and then aggregated and cached by the firmware layer. After the page cache is full, it is flushed. In this way, there will be no write amplification problem. However, in some cases, due to the requirements of the upper host, the data must be written to the disk. At this time, since the whole page is not fully written before it is flushed, the actual flushed data is greater than the valid data, resulting in a write amplification problem and reducing the service life of the SSD.
[0003] When writing data, the solid-state drive must perform page alignment. If the valid data is less than one page, and the host sends a Flush or a write command with Fua at this time, it needs to be written to the disk immediately. At this time, a fill operation is required, and then the flush can be performed after the fill. Occasional flushes or writes with Fua will not cause a big problem for write amplification, but when the disk is used as a system disk, some operating systems will execute flushes or write commands with fua at a certain frequency to ensure that all data in the cache is written to the disk. As time accumulates, the frequent misaligned flushing brings about the problem of write amplification, causing the SSD to reach the end of its service life ahead of schedule within its service life. Summary of the invention
[0004] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method, system and storage medium for reducing write amplification.
[0005] The objective of the present invention is achieved through the following technical solutions: The first aspect of the present invention provides: a method for reducing write amplification, comprising the following steps: Calculate the command interval time of the target command; Produce refresh indicators according to command intervals; Each execution of the target command consumes a refresh indicator. When the refresh indicator is less than or equal to 0, the target command waits for the preset time; when the existing refresh indicator is greater than the required refresh indicator, no delay is performed; when the existing refresh indicator is less than or equal to the required refresh indicator, delay is performed and aggregation is performed at the same time. When the delay time is up, a unified refresh is performed.
[0006] Preferably, the command interval time is calculated by the following steps: According to the write amplification caused by the minimum unit write of the target command, the maximum number of target commands issued within the service life cycle is calculated and converted into the command interval time.
[0007] Preferably, the step of producing the refresh index according to the command interval time comprises the following steps: Based on the production and consumer model, a refresh indicator is generated every command interval from the time the disk is powered on. If it is detected that the refresh indicator is less than or equal to 0, the host system is responded to with a delay.
[0008] Preferably, the maximum number of target commands issued within the service life period is calculated by the following steps: Assume that the factory expected life of the SSD disk is T, the expected Flash write volume is N, and the data size flushed by flush or fua is K. The maximum number of target commands issued during the service life cycle is s=N / K; the command interval is T / s.
[0009] Preferably, the target command is a write command or a flush command with fua. Preferably, the command interval time and the preset time are both 100 ms.
[0010] A second aspect of the present invention provides: a system for reducing write amplification, used to implement any of the above methods for reducing write amplification, comprising: A command interval time calculation module, used to calculate the command interval time of the target command; The down-flush indicator production module is used to produce down-flush indicators according to the command interval; Each execution of the target command consumes a refresh indicator. When the refresh indicator is less than or equal to 0, the target command waits for the preset time; when the existing refresh indicator is greater than the required refresh indicator, no delay is performed; when the existing refresh indicator is less than or equal to the required refresh indicator, delay is performed and aggregation is performed at the same time. When the delay time is up, a unified refresh is performed.
[0011] A third aspect of the present invention provides: a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, any of the above-mentioned methods for reducing write amplification is implemented.
[0012] The beneficial effects of the present invention are: 1) Set the frequency of issuing fua and flush commands according to the service life of the SSD to eliminate the write amplification caused by these two commands; when used as a system disk, ensure that the write amplification caused by fua or flush commands is not too large within the life of the SSD, thereby affecting the life of the SSD; by delaying the response to the host command, the data within this time is aggregated to solve the write amplification problem caused by this situation. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 Flowchart of a method for reducing write amplification. DETAILED DESCRIPTION
[0014] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0015] First, some terminology of the present invention is explained: Page: The smallest refresh unit in flash, usually 16KB.
[0016] Flush: Forces the data in the cache to be flushed to the flash.
[0017] fua: The data carried by the current write command must be written to the disk and cannot be cached.
[0018] cache: data cache, usually sram, stores the data sent by the host.
[0019] See also Figure 1 The first aspect of the present invention provides: a method for reducing write amplification, comprising the following steps: Calculate the command interval time of the target command; Produce refresh indicators according to command intervals; Each execution of the target command consumes a refresh indicator. When the refresh indicator is less than or equal to 0, the target command waits for the preset time; when the existing refresh indicator is greater than the required refresh indicator, no delay is performed; when the existing refresh indicator is less than or equal to the required refresh indicator, delay is performed and aggregation is performed at the same time. When the delay time is up, a unified refresh is performed.
[0020] In this embodiment, if Figure 1As shown, take the write command with fua as an example: when executing the command with fua to the solid-state drive, the data in the cache needs to be forced to be flushed. The execution steps are as follows: 1. According to the write amplification caused by the minimum unit write of the write command with fua, the maximum number of write commands with fua issued during the service life cycle is calculated, and the command interval time A (currently set to 100ms) is converted. 2. Based on the production and consumer model, a flush indicator is produced every A time from the power-on of the disk, and each execution of the write command with fua consumes an indicator. If the system detects that the flush indicator is less than or equal to 0, the host system is delayed to respond. 3. The system starts production from power-on, and produces a flush indicator every 100ms. The flush indicator is preset at the initial power-on. 4. Each execution of a write command with fua consumes a flush indicator. 5. When the flush indicator is equal to or less than 0, the write command with fua waits for 100ms. 6. If the produced indicator is greater than the flush indicator, no delay is performed. If the production index is less than or equal to the refresh index, a delay is performed and aggregation is performed during the delay. After the delay time is up, a unified refresh is performed.
[0021] In some embodiments, the command interval is calculated by the following steps: According to the write amplification caused by the minimum unit write of the target command, the maximum number of target commands issued within the service life cycle is calculated and converted into the command interval time.
[0022] In some embodiments, the step of generating a refresh indicator according to the command interval time comprises the following steps: Based on the production and consumer model, a refresh indicator is generated every command interval from the time the disk is powered on. If it is detected that the refresh indicator is less than or equal to 0, the host system is responded to with a delay.
[0023] In some embodiments, the maximum number of target commands issued within the service life period is calculated by the following steps: Assume that the factory expected life of the SSD disk is T, the expected Flash write volume is N, and the data size flushed by flush or fua is K. The maximum number of target commands issued during the service life cycle is s=N / K; the command interval is T / s.
[0024] In some embodiments, the target command is a write command or a flush command with fua. In some embodiments, the command interval time and the preset time are both 100 ms.
[0025] A second aspect of the present invention provides: a system for reducing write amplification, used to implement any of the above methods for reducing write amplification, comprising: A command interval time calculation module, used to calculate the command interval time of the target command; The down-flush indicator production module is used to produce down-flush indicators according to the command interval; Each execution of the target command consumes a refresh indicator. When the refresh indicator is less than or equal to 0, the target command waits for the preset time; when the existing refresh indicator is greater than the required refresh indicator, no delay is performed; when the existing refresh indicator is less than or equal to the required refresh indicator, delay is performed and aggregation is performed at the same time. When the delay time is up, a unified refresh is performed.
[0026] A third aspect of the present invention provides: a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, any of the above-mentioned methods for reducing write amplification is implemented.
[0027] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.
Claims
1. A method for reducing write amplification, characterized in that: The following steps are involved: Calculate the command interval time of the target command; Produce refresh indicators according to command intervals; Each execution of the target command consumes a refresh indicator. When the refresh indicator is less than or equal to 0, the target command waits for the preset time; when the existing refresh indicator is greater than the required refresh indicator, no delay is performed; when the existing refresh indicator is less than or equal to the required refresh indicator, delay is performed and aggregation is performed at the same time. When the delay time is up, a unified refresh is performed.
2. The method for reducing write amplification according to claim 1, characterized in that: The command interval is calculated by the following steps: According to the write amplification caused by the minimum unit write of the target command, the maximum number of target commands issued within the service life cycle is calculated and converted into the command interval time.
3. The method for reducing write amplification according to claim 1, characterized in that: The method of producing a refresh index according to the command interval time includes the following steps: Based on the production and consumer model, a refresh indicator is generated every command interval from the time the disk is powered on. If it is detected that the refresh indicator is less than or equal to 0, the host system is responded to with a delay.
4. The method for reducing write amplification according to claim 2, characterized in that: The maximum number of target commands issued within the service life period is calculated by the following steps: Assume that the factory expected life of the SSD disk is T, the expected Flash write volume is N, and the data size flushed by flush or fua is K. The maximum number of target commands issued during the service life cycle is s=N / K; the command interval is T / s.
5. The method for reducing write amplification according to any one of claims 1 to 4, characterized in that: The target command is a write command or a flush command with fua.
6. The method for reducing write amplification according to any one of claims 1 to 4, characterized in that: The command interval time and the preset time are both 100ms.
7. A system for reducing write amplification, characterized in that: The method for reducing write amplification according to any one of claims 1 to 6 comprises: A command interval time calculation module, used to calculate the command interval time of the target command; The down-flush indicator production module is used to produce down-flush indicators according to the command interval; Each execution of the target command consumes a refresh indicator. When the refresh indicator is less than or equal to 0, the target command waits for the preset time; when the existing refresh indicator is greater than the required refresh indicator, no delay is performed; when the existing refresh indicator is less than or equal to the required refresh indicator, delay is performed and aggregation is performed at the same time. When the delay time is up, a unified refresh is performed.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by the processor, the method for reducing write amplification according to any one of claims 1 to 6 is implemented.