Solid state disk data writing method and device
By reserving spare blocks in the solid-state drive to build temporary spare space, and combining multi-dimensional parameters and dynamic threshold adjustments, the bottleneck problem of end-of-drive write performance in solid-state drives is solved, thereby improving write performance and ensuring stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-10
AI Technical Summary
In end-user scenarios of solid-state drives, inefficient garbage collection leads to a significant drop in write performance, and the lack of effective means to temporarily take over write requests creates a write performance bottleneck.
By reserving spare blocks to build temporary spare space, and combining the firmware system resource status and the garbage collection module operation status, it is determined whether to enable the spare space to receive write request data. When there are enough free block resources, the data is migrated to restore the normal write mode. Resource usage is adjusted and optimized by using multi-dimensional parameters and dynamic thresholds.
It effectively improves the end-of-life write performance and operational stability of solid-state drives, ensuring the continuity and efficiency of data writing, while avoiding the excessive use of spare blocks from affecting their original bad block replacement function.
Smart Images

Figure CN121635808A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of solid-state drive (SSD) technology, and more specifically to a method and apparatus for writing data to a solid-state drive. Background Technology
[0002] During long-term use, as the number of write cycles to the flash memory chips increases, the amount of valid data within a large number of data blocks gradually approaches the block's capacity limit. In this "end-stage" usage scenario, when the host initiates a data write request, the SSD's garbage collection (GC) module needs to process data blocks containing a large amount of valid data. Because a large amount of valid data must be migrated before free blocks can be released, garbage collection efficiency is significantly reduced, making it impossible to provide sufficient free block resources for new write requests in a timely manner. This problem directly causes a precipitous drop in SSD write performance, a phenomenon known as the "end-stage performance" bottleneck of SSDs.
[0003] Currently, in edge scenarios, there is a lack of effective means to temporarily handle write requests to avoid garbage collection inefficiencies. Therefore, designing data writing methods based on existing SSD hardware resources to improve edge performance is crucial for enhancing product quality and ensuring user experience. Summary of the Invention
[0004] The main objective of this invention is to provide a solid-state drive data writing method and device, which aims to solve the technical problem of the lack of effective means to temporarily accept write requests in the prior art to avoid the inefficiency of garbage collection.
[0005] To achieve the above objectives, in a first aspect, this application provides a solid-state drive (SSD) data writing method, applied to an SSD, wherein the SSD includes flash memory chips, firmware system, spare blocks, and a garbage collection module, and the spare blocks are redundant blocks reserved in the firmware design for replacing bad blocks, and the method includes:
[0006] Get data write command;
[0007] Based on the data write instruction, and according to the resource status of the firmware system and the running status of the garbage collection module, it is determined whether to activate the backup space to receive write request data.
[0008] If the preset startup conditions are met, the backup space formed by the backup block is activated to temporarily receive write request data sent by the host.
[0009] The system monitors the status of free block resources in the firmware system in real time. When the number of free block resources in the firmware system is found to be higher than the first block quantity threshold, the write request data stored in the spare space is migrated to the free block, and the resources of the spare block are released, so that the solid-state drive is restored to the normal data area writing mode.
[0010] In one possible implementation, determining whether to activate the backup space to receive write request data, based on the resource status of the firmware system and the operating status of the garbage collection module, includes:
[0011] Based on one or more of the following factors: the number of free blocks in the firmware system, the startup frequency of the write-time garbage collection module, and the number of valid data blocks released during garbage collection, it is determined whether the preset startup conditions are met.
[0012] In one possible implementation, the determination of whether the preset startup condition is met is based on one or more of the following: the number of free blocks in the firmware system, the startup frequency of the write-time garbage collection module, and the number of valid data blocks released during garbage collection:
[0013] If the number of free blocks in the firmware system is lower than the second block quantity threshold, the start frequency of the write-time garbage collection module is higher than the preset frequency threshold, and the number of valid data blocks released during the garbage collection process is less than the third block quantity threshold, then the preset start condition is determined to be met; otherwise, the preset start condition is determined not to be met.
[0014] Otherwise, it is determined that the preset startup conditions are not met.
[0015] In one possible implementation, before enabling the spare space formed by the spare block to temporarily receive write request data sent by the host, the method further includes:
[0016] Obtain the PE cycle count of the spare block, and adjust the startup frequency of the spare space according to the PE cycle count; wherein, when the PE cycle count is greater than or equal to a preset PE limit value, the startup frequency of the spare space is reduced.
[0017] In one possible implementation, adjusting the startup frequency of the spare space based on the number of PE cycles includes:
[0018] The number of PE cycles for the spare block is divided into multiple intervals, and each interval corresponds to a preset startup frequency coefficient.
[0019] The interval is determined based on the number of PE cycles obtained, and the base start frequency is multiplied by the corresponding frequency coefficient to obtain the adjusted start frequency.
[0020] The larger the value of the PE cycle count range, the smaller the corresponding startup frequency coefficient. When the PE cycle count reaches the preset scrap threshold, the spare space is locked and startup is prohibited.
[0021] In one possible implementation, before determining whether to activate the backup space to receive write request data based on the resource status of the firmware system and the operating status of the garbage collection module according to the data write instruction, the method further includes:
[0022] The system collects three performance parameters of the solid-state drive in real time: write response latency, write throughput, and flash memory chip erase / write time.
[0023] Calculate the deviation rate of each performance parameter from the corresponding benchmark parameter. If the deviation rate of any performance parameter exceeds a preset deviation threshold, or the average deviation rate of the three performance parameters exceeds a preset average threshold, then the solid-state drive is determined to have a risk of end-point performance degradation.
[0024] In one possible implementation, migrating write request data stored in the spare space to the free block includes:
[0025] The write request data in the spare space is classified to distinguish between random write data and continuous write data;
[0026] Based on the physical address distribution of free blocks, continuously written data is migrated to free blocks with consecutive physical addresses, while randomly written data is migrated to free blocks with discrete physical addresses. Page merging technology is then used to optimize the storage layout of randomly written data.
[0027] In one possible implementation, the method further includes a step of dynamically expanding the spare space:
[0028] After the backup space is enabled, the write request rate of the host is monitored in real time. If the write request rate exceeds the maximum processing rate of the backup space for a preset duration, a temporary redundant block is called from the reserved redundant area of the solid-state drive and merged with the backup block to form an expanded backup space.
[0029] When the number of free block resources is detected to be higher than the first block quantity threshold, the temporary redundant block resources are released first, and then the data in the spare block is migrated and the spare block resources are released.
[0030] In one possible implementation, the first quantity threshold, the second quantity threshold, and the third quantity threshold are all dynamic thresholds, and the method further includes a dynamic threshold adjustment step.
[0031] A threshold adjustment model is established based on the actual usage time of the solid-state drive, the health score of the flash memory chips, and historical garbage collection efficiency data.
[0032] At each preset interval, the threshold for the number of each block is recalculated and updated using the threshold adjustment model. The lower the health score of the flash memory chip, the higher the increase ratio of the second block quantity threshold.
[0033] Secondly, embodiments of this application also provide a solid-state drive device, characterized in that it includes: a memory and a processor, wherein the memory is used to store program code; and the processor is used to call the program code to execute the method as described in the first aspect.
[0034] Unlike existing technologies, the solid-state drive (SSD) data writing method based on spare blocks provided in this application is applied to an SSD containing flash memory chips, firmware, spare blocks, and a garbage collection module. The spare blocks are redundant blocks reserved during firmware design to replace bad blocks. The method first obtains a data write instruction; then, based on the data write instruction and according to the resource status of the firmware system and the operating status of the garbage collection module, it determines whether to activate the spare space to receive write request data. If the preset activation conditions are met, the spare space formed by the spare blocks is activated to temporarily receive write request data sent by the host. The method also monitors the free block resource status of the firmware system in real time. When the number of free block resources in the firmware system is found to be higher than a first block quantity threshold, the write request data stored in the spare space is migrated to the free blocks, and the resources of the spare blocks are released, allowing the SSD to return to normal data area writing mode.
[0035] Thus, this application utilizes reserved spare blocks to construct temporary spare space. By comprehensively judging the firmware system resource status and the garbage collection module's operating status, the spare space is activated. When there are insufficient free blocks in the firmware system or when the garbage collection module's operation causes a shortage of write resources, a temporary writing medium can be quickly provided, avoiding the blocking or delay of host-side write requests. At the same time, by monitoring the status of free block resources in real time, data migration is completed and spare blocks are released in a timely manner when resources are sufficient. This ensures both the continuity and efficiency of data writing, and also ensures that the spare blocks return to their redundant backup role without affecting their original bad block replacement function, effectively improving the end-write performance and operational stability of the solid-state drive. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0037] Figure 1This is a flowchart illustrating the solid-state drive data writing method in some embodiments of this application;
[0038] Figure 2 This is a flowchart illustrating step S400 of the solid-state drive data writing method in some embodiments of this application;
[0039] Figure 3 This is a schematic diagram of the hardware structure of a solid-state drive device in some embodiments of this application.
[0040] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0042] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.
[0043] Furthermore, the use of terms such as "first" and "second" in this invention is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the term "and / or" throughout the text includes three solutions; taking A and / or B as an example, it includes technical solution A, technical solution B, and a technical solution that simultaneously satisfies A and B. Furthermore, the technical solutions of various embodiments can be combined with each other, but this must be based on the ability of a person skilled in the art to implement them. When the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by this invention.
[0044] During long-term use, as the number of write cycles to the flash memory chips increases, the amount of valid data within a large number of data blocks gradually approaches the block's capacity limit. In this "end-stage" usage scenario, when the host initiates a data write request, the SSD's garbage collection (GC) module needs to process data blocks containing a large amount of valid data. Because a large amount of valid data must be migrated before free blocks can be released, garbage collection efficiency is significantly reduced, making it impossible to provide sufficient free block resources for new write requests in a timely manner. This problem directly causes a precipitous drop in SSD write performance, a phenomenon known as the "end-stage performance" bottleneck of SSDs. Currently, in end-stage scenarios, there is a lack of effective means to temporarily take over write requests to avoid the garbage collection inefficiency period.
[0045] To address the aforementioned technical problems, this application provides a solid-state drive (SSD) data writing method, which can be applied to SSD devices, wherein the SSD includes flash memory chips, firmware system, spare blocks, and a garbage collection module.
[0046] Flash memory chips are the core storage medium of solid-state drives (SSDs) used for persistent data storage. Data is written, erased, and read by changing the charge state of the storage cells using electronic signals. They feature no mechanical structure, high read / write speeds, and strong shock resistance, making them the physical carrier for SSD data storage.
[0047] Firmware is the operating system of a solid-state drive (SSD), a software program embedded in the device. It is responsible for coordinating communication between the hardware and the host (such as a computer), managing core operations such as data read / write scheduling, address mapping, and error checking, and is the control core that ensures the normal operation of the SSD.
[0048] The spare block is a redundant storage block reserved during firmware design and is considered a backup resource. Its main function is to automatically replace the bad block when a normal storage block is damaged (i.e., a "bad block") to ensure storage capacity and data security. In this application, it can also be used temporarily as a backup space for data writing to improve write continuity and end-of-pipe performance.
[0049] The garbage collection module is a performance optimization component for solid-state drives (SSDs). Because flash memory chips need to be erased before being written, when invalid data exists in some storage blocks, this module will migrate the valid data in the block to a new block, erase the original block and release it as a free block, thus avoiding the write performance degradation caused by invalid data occupying space.
[0050] like Figure 1 As shown, the following explanation uses a solid-state drive (SSD) device to illustrate the SSD data writing method. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order. The method includes the following steps S100-S400:
[0051] Step S100: Obtain the data write instruction;
[0052] Specifically, solid-state drives (SSDs) can monitor command signals sent by the host (such as a computer host) in real time through interfaces (such as SATA and NVMe). When the host has data storage needs, it sends a data write command containing key information such as the target data, write address, and data length to the SSD firmware system. The firmware system identifies the write request through its command parsing module, completes the acquisition of the data write command, and provides triggering conditions for subsequent write strategy determination. This step is the starting point of the entire data write process, ensuring that the firmware system responds promptly to the host's data storage needs.
[0053] Step S200: Based on the data write instruction, determine whether to activate the backup space to receive write request data according to the resource status of the firmware system and the running status of the garbage collection module;
[0054] After receiving the data write command, the firmware system first collects its own free block resource status (including the total number of free blocks, the distribution of consecutive free blocks, and the health of each free block) through the resource monitoring module. Simultaneously, it obtains the running status of the garbage collection module (such as whether it is running, the progress of garbage collection, the number of blocks currently being collected, and the system bandwidth used) through the garbage collection (GC) status monitoring module. Then, combined with preset startup conditions (e.g., the number of free blocks in the firmware system is below the second block count threshold, the garbage collection module is running under high load and the expected resource occupation time exceeds the preset duration, the frequency of continuously received write requests is higher than the preset frequency threshold), a comprehensive evaluation is performed by the logical judgment unit. If the firmware system currently has scarce free block resources, or the garbage collection module's operation causes excessive load on the normal write channel, directly writing to the normal data area may result in increased write latency, decreased IO performance, or even write request blocking. In this case, it is determined that backup space needs to be activated. If the firmware system has sufficient free blocks and the garbage collection module is not occupying a large amount of resources, and the normal data area can meet the write requirements, it is determined that backup space does not need to be activated, and data is directly written to the free blocks according to the normal write process. The core of this step is to dynamically select the optimal write path through multi-dimensional status monitoring and logical judgment, so as to avoid the degradation of terminal performance caused by insufficient resources or garbage collection interference.
[0055] Step S300: If it is determined that the preset startup conditions are met, the backup space formed by the backup block is activated to temporarily receive write request data sent by the Host.
[0056] The spare space consists of pre-divided independent spare blocks in the solid-state drive (the spare blocks are physically isolated from the storage blocks in the normal data area, do not participate in daily data storage, and are used as emergency write resources or bad block replacements). Its capacity can be pre-configured according to the total storage capacity of the solid-state drive and the application scenario requirements (such as setting a larger spare space in high IO load scenarios).
[0057] When step S200 determines that the preset startup conditions are met, the firmware system sends an enable command to the spare block through the spare space management module, activating the write permission of the spare space. Simultaneously, it redirects the receiving address of subsequent write request data sent by the host to the spare space. During data reception, the firmware system verifies the written data (e.g., CRC check) and detects bad blocks to ensure data integrity, and temporarily caches and manages the data according to the writing order. This step, by enabling the spare space as a temporary write carrier, achieves immediate reception of write request data, avoiding write request loss or blocking due to insufficient resources in the normal data area, and ensuring the continuity of data writing at the host end.
[0058] Step S400: Monitor the status of the free block resources of the firmware system in real time. When the number of free block resources of the firmware system is found to be higher than the first block quantity threshold, migrate the write request data stored in the spare space to the free block and release the resources of the spare block, so that the solid-state drive can be restored to the normal data area writing mode.
[0059] During the data reception process in the spare space, the firmware system's resource monitoring module continuously collects the status of idle block resources in real time (the collection frequency can be dynamically adjusted according to the system load, such as increasing the collection frequency during high load), and compares it in real time with the preset first block quantity threshold (this threshold is higher than the second block quantity threshold in step S200, ensuring that there are sufficient idle blocks for storing migrated data without affecting subsequent new write requests). When the garbage collection module completes the reclamation of some blocks, or when the host-side write request frequency decreases, causing the number of idle block resources in the firmware system to increase to above the first block quantity threshold, it is determined that the current normal data area has sufficient write resources, and the firmware system starts the data migration module. During the data migration process, according to the "first-in, first-out" principle, the write request data temporarily stored in the spare space is migrated in batches to the idle blocks in the normal data area. Data verification and consistency checks are performed simultaneously during the migration process to ensure that there is no data loss or error during the migration. After all data migration is complete, the firmware system releases the resources of the spare block (including clearing temporary data in the spare block, revoking write permissions on the spare space, and restoring the spare block to a standby state), and redirects subsequent write requests from the host directly to the normal data area, enabling the SSD to return to normal data area write mode. This step achieves a seamless transition between the spare space and the normal data area, ensuring write performance in emergency situations while also guaranteeing the standardization and stability of the final data storage.
[0060] Thus, this application utilizes reserved spare blocks to construct temporary spare space. By comprehensively judging the firmware system resource status and the garbage collection module's operating status, the spare space is activated. When there are insufficient free blocks in the firmware system or when the garbage collection module's operation causes a shortage of write resources, a temporary writing medium can be quickly provided, avoiding the blocking or delay of host-side write requests. At the same time, by monitoring the status of free block resources in real time, data migration is completed and spare blocks are released in a timely manner when resources are sufficient. This ensures both the continuity and efficiency of data writing, and also ensures that the spare blocks return to their redundant backup role without affecting their original bad block replacement function, effectively improving the end-write performance and operational stability of the solid-state drive.
[0061] In one embodiment, multi-dimensional preset startup conditions can be constructed by combining the resource status of the firmware system with the key operating parameters of the garbage collection module to accurately determine whether to start the backup space to receive write request data. The judgment criteria include the number of free blocks in the firmware system, the startup frequency of the garbage collection module during writes, and the number of valid data blocks released during garbage collection. In practical applications, one or more of these criteria can be selected as the judgment dimensions based on the performance requirements of the storage system, data read / write pressure, and other scenarios, ensuring the flexibility and adaptability of the judgment logic.
[0062] The specific judgment process is as follows: First, three key thresholds are preset: a second quantity threshold (used to limit the minimum free block reserve that the firmware system can normally support write requests), a preset frequency threshold (used to define the abnormal start threshold of the garbage collection module during writes), and a third quantity threshold (used to measure the effective data release efficiency of the garbage collection process). During actual data read and write processes, the above three core parameters are monitored in real time: if the number of free blocks in the firmware system is lower than the second quantity threshold, it indicates that the current system's available storage resources are insufficient and cannot meet the storage requirements of normal write requests; at the same time, if the start frequency of the garbage collection module during writes is higher than the preset frequency threshold, it indicates that the system has frequently triggered the garbage collection mechanism due to the shortage of free blocks, which will not only lead to increased write request delays but may also cause system performance bottlenecks; in addition, if the number of effective data blocks released during garbage collection is less than the third quantity threshold, it indicates that the garbage collection operation is inefficient and cannot quickly replenish the system's idle resources by reclaiming idle data blocks. The three together constitute a critical state of "insufficient resources + frequent garbage collection + inefficient garbage collection." At this time, it is determined that the preset start conditions are met, and the backup space needs to be activated to receive write request data to avoid write request failures or system lag.
[0063] Conversely, if any of the above three conditions are not met (for example: the number of free blocks is higher than or equal to the second block number threshold, indicating that the system resources are sufficient; or the garbage collection module starts at a frequency lower than or equal to the preset frequency threshold, indicating that the system is running stably; or the number of valid data blocks released by garbage collection is higher than or equal to the third block number threshold, indicating that the collection efficiency meets the standard), it indicates that the current system still has the ability to process write requests normally, and the read and write process can be guaranteed to be smooth without relying on the spare space. At this time, it is determined that the preset start conditions are not met, and the original write request processing mechanism is maintained.
[0064] Thus, this application embodiment, through multi-parameter collaborative judgment and explicit threshold triggering logic, can accurately capture critical scenarios where firmware system storage resources are scarce and the garbage collection mechanism cannot effectively alleviate the situation, and promptly activate the backup space to receive write request data. This not only avoids write request failures due to insufficient free blocks, but also reduces the unnecessary occupation of system resources by activating the backup space, thereby ensuring the read and write stability and performance continuity of the storage system.
[0065] In one embodiment, the first, second, and third quantity thresholds of this application are all dynamic thresholds. The method further includes a threshold dynamic adjustment step: establishing a threshold adjustment model based on the actual usage time of the solid-state drive, the health score of the flash memory chips, and historical garbage collection efficiency data; recalculating and updating the quantity thresholds of each block through the threshold adjustment model at preset intervals, wherein the lower the health score of the flash memory chips, the higher the increase ratio of the second quantity threshold.
[0066] Specifically, in this embodiment, the first, second, and third quantity thresholds are all designed as dynamic thresholds, rather than fixed values. This is to adapt to changes in the performance degradation of the solid-state drive (SSD) at different usage stages, flash memory chip wear, and garbage collection efficiency, avoiding storage resource waste or read / write performance degradation caused by fixed thresholds. To achieve dynamic threshold optimization, the method adds a dynamic threshold adjustment step, specifically including two stages: threshold adjustment model construction and periodic threshold update.
[0067] First, a threshold adjustment model is established based on the actual usage time of the solid-state drive (SSD), the health score of the flash memory chips, and historical garbage collection efficiency data. The actual usage time directly reflects the cumulative wear and tear of the flash memory chips (the longer the usage time, the higher the risk of chip wear). The flash memory chip health score is a comprehensive evaluation derived from key indicators such as read / write speed, remaining erase count, and data retention capability (the higher the score, the more stable the chip performance). Historical garbage collection efficiency data reflects the speed, success rate, and impact on normal read / write operations of the SSD in reclaiming invalid data blocks under different threshold settings (higher efficiency indicates a better fit between the threshold and the current storage state). By using these three key influencing factors as model input variables and training the model with machine learning algorithms (such as gradient boosting regression and neural networks) on historical data, the threshold adjustment model learns the mapping relationship between each factor and the optimal block count threshold, providing accurate model support for subsequent threshold calculations.
[0068] Subsequently, at preset intervals (the preset interval can be set according to the actual application scenario, such as 12 hours, 24 hours, or triggered after each preset amount of writing), the threshold adjustment model is used to recalculate and update the first block quantity threshold, the second block quantity threshold, and the third block quantity threshold. In the threshold adjustment logic, this application embodiment designs a differentiated increase rule for the second block quantity threshold: the lower the flash memory chip health score, the more obvious the degradation of the reliability and read / write performance of the flash memory cell. At this time, it is necessary to increase the second block quantity threshold by a higher proportion to reserve more redundant block resources for data remapping, bad block replacement, or garbage collection preprocessing, thereby offsetting the impact of the decline in chip health on the stability of the storage system; conversely, if the flash memory chip health score is high, the increase ratio of the second block quantity threshold can be appropriately reduced to avoid the reduction of effective storage capacity caused by excessive reservation of redundant blocks. At the same time, the threshold adjustment model will also combine the actual usage time (the longer the usage time, the more the overall block number threshold can be adjusted to improve the system's fault tolerance) and historical garbage collection efficiency data (if the historical collection efficiency is low, the garbage collection triggering time can be optimized by adjusting the threshold to improve collection efficiency) to perform collaborative calculations on the three thresholds, ensuring the logical compatibility between the thresholds (for example, the adjustment of the first block number threshold and the third block number threshold must match the increase trend of the second block number threshold to avoid threshold conflicts).
[0069] Thus, by constructing a threshold adjustment model based on multi-dimensional real-world operational data and updating the block quantity thresholds periodically, dynamic adaptation between the block quantity thresholds and the real-time operational status of the SSD is achieved. Specifically, the differentiated adjustment rules for flash memory chip health scores further enhance targeted optimization for flash memory wear. This ensures the stability of the SSD's read / write performance throughout its entire lifecycle while maximizing the utilization of storage resources, avoiding excessive or insufficient redundant block reservations, and ultimately improving the overall lifespan of the SSD and the quality of storage services.
[0070] In one embodiment, before enabling the spare space formed by the spare block to temporarily receive write request data sent by the host, the method further includes: obtaining the PE cycle count of the spare block, and adjusting the startup frequency of the spare space according to the PE cycle count; wherein, when the PE cycle count is greater than or equal to a preset PE limit value, the startup frequency of the spare space is reduced.
[0071] Specifically, this application embodiment adds a dynamic adjustment mechanism for the startup frequency based on the number of PE (Program / Erase) cycles of the spare block before temporarily receiving write request data from the host in the spare space formed by the spare block. By accurately matching the lifespan status of the spare block, the activation strategy of the spare space is optimized, which ensures the read and write continuity of the storage system and avoids the rapid decay of the spare block's lifespan due to overuse. Among them, the number of PE cycles is a core indicator for measuring the lifespan of flash memory chips. Its value directly reflects the wear degree of the spare block. As the number of PE cycles increases, the stability and durability of the spare block gradually decrease. Therefore, it is necessary to balance the usage requirements of the spare space with the lifespan protection of the spare block by adjusting the startup frequency.
[0072] The specific startup frequency adjustment process is as follows: First, the real-time PE cycle count of the spare block is obtained in advance. This value can be collected by the storage unit wear monitoring module built into the firmware system to ensure the accuracy and real-time nature of the data, providing a reliable basis for subsequent frequency adjustment. Then, the startup frequency is precisely controlled by interval division and coefficient mapping: First, based on parameters such as the design life of the spare block and the PE tolerance limit of the flash memory chip, the PE cycle count is divided into multiple continuous and non-overlapping intervals (e.g., [0, A), [A, B), [B, C), [C, preset scrap threshold], where A < B < C < preset scrap threshold). Each interval corresponds to a preset startup frequency coefficient (this coefficient is a positive number less than or equal to 1). Second, the obtained real-time PE cycle count of the spare block is matched with the above intervals to determine the specific interval to which it belongs, and then the startup frequency coefficient corresponding to that interval is retrieved. Third, the system's preset baseline startup frequency (i.e., the standard startup frequency of the spare block in its brand-new state, set according to the read and write performance requirements of the storage system) is multiplied by this frequency coefficient to calculate the adjusted startup frequency.
[0073] The core logic of frequency adjustment is "the higher the PE cycle count, the smaller the startup frequency coefficient": For example, when the PE cycle count of the spare block is in the low range ([0, A)), the corresponding frequency coefficient is 1.0, and the adjusted startup frequency is consistent with the baseline startup frequency, which can give full play to the temporary storage function of the spare space; when the PE cycle count enters the middle range ([A, B)), the corresponding frequency coefficient drops to 0.7, and the startup frequency is appropriately reduced to reduce the usage frequency of the spare block; when the PE cycle count reaches the high range ([B, C)), the corresponding frequency coefficient further drops to 0.3, strictly controlling the activation scenarios of the spare space; when the PE cycle count reaches the preset scrapping threshold, it indicates that the spare block has approached or reached the end of its service life, and continued use may lead to data loss or system failure. At this time, the spare space is directly locked and startup is prohibited to completely avoid risks.
[0074] Specifically, when the number of PE cycles of the spare block is greater than or equal to the preset PE limit (which is less than the preset scrap threshold and is the warning threshold for life protection), the frequency coefficient of its interval is significantly lower than 1.0. After multiplying the above coefficients, the adjusted start-up frequency will be reduced accordingly, achieving the dynamic control target of "the more severe the wear, the more cautious the start-up".
[0075] Thus, by adjusting the PE cycle count and the startup frequency in conjunction, this embodiment of the application ensures that the spare space can be fully utilized to cope with storage pressure when the spare block is in good condition, and extends its effective service life by reducing the startup frequency or even locking and prohibiting startup when the spare block wears out. This avoids the decline in system reliability caused by excessive wear of the spare block, thereby achieving a balance between storage system performance and hardware lifespan.
[0076] In one embodiment, before determining whether to activate the backup space to receive write request data based on the resource status of the firmware system and the operating status of the garbage collection module according to the data write instruction, the method further includes:
[0077] The system collects three performance parameters of the solid-state drive in real time: write response latency, write throughput, and flash memory chip erase / write time.
[0078] Calculate the deviation rate of each performance parameter from the corresponding benchmark parameter. If the deviation rate of any performance parameter exceeds a preset deviation threshold, or the average deviation rate of the three performance parameters exceeds a preset average threshold, then the solid-state drive is determined to have a risk of end-point performance degradation.
[0079] This application's embodiments add a pre-emptive judgment mechanism for the risk of performance degradation at the end of the solid-state drive (SSD) before determining whether to activate the backup space to receive write request data based on data write commands, firmware system resource status, and the garbage collection module's operating status. By monitoring core performance indicators in real time and quantifying the degree of deviation, performance degradation trends can be identified in advance, providing a more comprehensive basis for subsequent backup space activation decisions. This avoids abnormal write request processing due to sudden drops in end-stage performance, further ensuring the operational stability of the storage system. Specifically, end-stage performance degradation refers to the performance decline that occurs during long-term use of the SSD due to factors such as flash memory chip wear and increased storage fragmentation. Early detection of this risk enables "preventative" performance assurance.
[0080] Specifically, before determining whether to activate the backup space to receive write request data, three performance parameters of the solid-state drive (SSD) can be collected in real time: write response latency, write throughput, and flash memory chip erase / write time. The deviation rate of each performance parameter from the corresponding benchmark parameter is calculated. If the deviation rate of any performance parameter exceeds a preset deviation threshold, or the average deviation rate of the three performance parameters exceeds a preset average threshold, it is determined that the SSD has a risk of end-point performance degradation, and only then is the determination to activate the backup space made.
[0081] Thus, by collecting multi-dimensional core performance parameters in real time and performing deviation rate quantitative analysis, this application embodiment can accurately identify the risk of performance degradation at the end of the solid-state drive in advance, providing a preliminary basis for the decision on whether to activate the backup space. This avoids judging the activation of the backup space according to conventional logic when the performance has already degraded significantly, and further improves the reliability and stability of the storage system's write request processing.
[0082] In one embodiment, such as Figure 2 As shown, step S400, migrating the write request data stored in the spare space to the free block, includes:
[0083] S410. Classify the write request data in the spare space, and distinguish between random write data and continuous write data;
[0084] S420. Based on the physical address distribution of free blocks, migrate consecutively written data to free blocks with consecutive physical addresses, migrate randomly written data to free blocks with discrete physical addresses, and use page merging technology to optimize the storage layout of randomly written data.
[0085] Specifically, the write request data stored in the spare space is first categorized into random write data and sequential write data. Sequential write data refers to write request data with consecutive logical addresses that can be stored in batches sequentially (such as large file chunked transfer data, continuous log records, etc.); random write data refers to write request data with dispersed logical addresses and no fixed storage order (such as random updates of small files, multi-threaded concurrent write data, etc.). By accurately distinguishing between these two types of data, different storage resources can be matched accordingly, laying the foundation for efficient migration later.
[0086] Subsequently, based on the physical address distribution of free blocks, differentiated migration strategies are implemented for the two types of data: For continuously written data, it is migrated to free blocks with contiguous physical addresses, utilizing the storage characteristics of contiguous physical addresses to reduce the number of address seeks during data reads and improve data transfer rates; for randomly written data, it is migrated to free blocks with discrete physical addresses, making full use of scattered storage resources, avoiding fragmentation of contiguous physical address free blocks, and improving the space utilization of the storage medium. Simultaneously, to address the potential storage fragmentation problem after the migration of randomly written data, page merging technology is used to optimize its storage layout. This involves merging multiple small-capacity data pages from discrete storage into large-capacity contiguous data pages, reducing the impact of storage fragmentation on read / write performance and lowering the address jump overhead during data access.
[0087] Thus, by classifying and processing write request data and implementing differentiated migration strategies, combined with the optimization effect of page merging technology, this embodiment of the application not only achieves reasonable allocation of storage resources, but also effectively improves data writing efficiency and storage medium utilization, while reducing the risk of storage fragmentation caused by random writes, and ensuring the long-term stable operation of the storage system.
[0088] In other embodiments, the solid-state drive data writing method of this application further includes a step of dynamically expanding the spare space: after enabling the spare space, the write request rate of the host is monitored in real time. If the write request rate continues to exceed the maximum processing rate of the spare space for a preset duration, a temporary redundant block is called from the reserved redundant area of the solid-state drive and merged with the spare block to form an expanded spare space. When the number of free block resources is detected to be higher than the first block quantity threshold, the temporary redundant block resources are released first, and then the data in the spare block is migrated and the spare block resources are released.
[0089] Specifically, after the solid-state drive (SSD) enables the use of spare space to handle write requests, a real-time monitoring mechanism for the write request rate on the host side (i.e., the host machine) is initiated. This monitoring mechanism can be implemented through the rate statistics module in the SSD controller, which collects the amount of write request data sent by the host side per unit time in real time, converts it into a write request rate indicator, provides real-time data support for subsequent capacity expansion decisions, and ensures that changes in write request load can be detected in a timely manner.
[0090] Subsequently, the system compares the real-time monitored write request rate with the maximum processing rate of the spare space, and sets a "preset duration" as a judgment condition (the preset duration can be set according to the load fluctuation characteristics of the actual application scenario, such as 500 milliseconds, 1 second, etc.) to avoid erroneous expansion operations due to instantaneous peak loads. When the monitored write request rate exceeds the maximum processing rate of the spare space for the preset duration, it indicates that the current spare space can no longer meet the load demand. At this time, the expansion process will be triggered: temporary redundant blocks are called from the reserved redundancy area of the solid-state drive. The reserved redundancy area is a spare storage resource preset by the solid-state drive at the factory to cope with sudden loads or hardware failures. Its temporary redundant blocks have the same storage performance as the spare blocks. The called temporary redundant blocks are logically merged with the original spare blocks to form an expanded spare space. By expanding the storage capacity, the overall write request processing capability is improved, ensuring that it can smoothly handle high-load write requests from the host and avoiding write request blocking or loss.
[0091] Finally, the system continuously monitors the number of free blocks in the SSD. This monitoring is achieved through real-time scanning and statistics of the usage status of each physical block by the storage management module. The first free block count threshold is a system-preset criterion for determining sufficient free block resources (which can be set based on the total SSD capacity, regular write load requirements, etc.). When the number of free blocks detected is higher than this threshold, it indicates that the SSD has sufficient regular storage resources to handle write requests, and there is no need to occupy spare space or temporary redundant block resources. At this point, a resource release process is executed: first, the temporary redundant block resources are released, returning them to the reserved redundant area for subsequent sudden demands; then, the write request data stored in the original spare blocks is migrated to the free blocks. After the data migration is complete, the spare block resources are released, restoring the spare space to its initial unused state, thus achieving efficient cyclical utilization of storage resources.
[0092] Thus, this embodiment of the application, through the step of dynamically expanding the spare space, can flexibly adjust the spare space capacity according to the real-time changes in the write request load on the host side. This not only ensures the write request processing capacity under high load scenarios, but also releases redundant resources in a timely manner when resources are sufficient, avoiding waste of storage resources, thereby improving the overall storage performance and resource utilization of the solid-state drive.
[0093] like Figure 3 As shown, Figure 3 The diagram below illustrates the hardware structure of a solid-state drive (SSD) device in some embodiments of this application. The SSD device provided in this application includes a memory 1000 and a processor 2000. The memory 1000 is used to store computer-readable instructions, and the processor 2000 is used to invoke the computer-readable instructions to execute the SSD data writing method described above.
[0094] The processor 2000 provides computing and control capabilities to control the solid-state drive (SSD) device to perform corresponding tasks, such as controlling the SSD device to perform the SSD data writing method in any of the above method embodiments. The method includes: acquiring a data writing instruction; determining, based on the data writing instruction and according to the resource status of the firmware system and the operating status of the garbage collection module, whether to activate the backup space to receive write request data; if the preset activation conditions are met, activating the backup space formed by the backup block to temporarily receive write request data sent by the host; monitoring the free block resource status of the firmware system in real time, and when the number of free block resources in the firmware system is found to be higher than a first block quantity threshold, migrating the write request data stored in the backup space to the free block and releasing the resources of the backup block, so that the SSD returns to the normal data area writing mode.
[0095] The processor 2000 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0096] The memory 1000, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the solid-state drive data writing method in the embodiments of this application. The processor 2000 can implement the solid-state drive data writing method in any of the above method embodiments by running the non-transitory software programs, instructions, and modules stored in the memory 1000.
[0097] Specifically, memory 1000 may include volatile memory (VM), such as random access memory (RAM); memory 1000 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), solid-state drive (SSD), or other non-transitory solid-state storage devices; memory 1000 may also include combinations of the above types of memory.
[0098] In summary, the solid-state drive device of this application adopts the technical solution of any of the above-described solid-state drive data writing method embodiments, and therefore has at least the beneficial effects brought about by the technical solutions of the above embodiments, which will not be elaborated further here.
[0099] This application also provides a computer-readable storage medium, such as a memory including program code, which can be executed by a processor to complete the solid-state drive data writing method described above. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CDROM), magnetic tape, floppy disk, or optical data storage device, etc.
[0100] This application also provides a computer program product comprising one or more lines of program code stored in a computer-readable storage medium. The processor of the early warning system reads the program code from the computer-readable storage medium and executes the program code to complete the solid-state drive data writing method steps provided in the above embodiments.
[0101] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program or program code related to hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0102] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0103] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0104] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. All equivalent structural transformations made under the inventive concept of the present invention using the contents of the present invention specification and drawings, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.
Claims
1. A method for data writing of a solid state disk, applied to a solid state disk, the solid state disk comprising a flash memory chip, a firmware system, a spare block and a garbage collection module, the spare block being a redundant block reserved for replacing a bad block when the firmware is designed, characterized in that, The method comprises: acquiring a data write instruction; determining whether to start a backup space to receive write request data according to a resource state of the firmware system and a running state of the garbage collection module based on the data write instruction; if it is determined that a preset starting condition is met, enabling a backup space formed by the backup block to temporarily receive write request data sent by a host end; monitoring a free block resource state of the firmware system in real time, and when it is identified that the number of free blocks of the firmware system is higher than a first block quantity threshold, migrating write request data stored in the backup space to the free block and releasing the resource of the backup block to make the solid state disk return to a normal data area write mode. 2.The solid state drive data writing method of claim 1, wherein, The determination whether to start a backup space to receive write request data according to a resource state of the firmware system and a running state of the garbage collection module based on the data write instruction comprises: determining whether the preset starting condition is met based on one or more of the number of free blocks of the firmware system, the starting frequency of the write-time garbage collection module and the number of effective data blocks released in the garbage collection process. 3.The solid state drive data writing method of claim 2, wherein, The determination whether the preset starting condition is met based on one or more of the number of free blocks of the firmware system, the starting frequency of the write-time garbage collection module and the number of effective data blocks released in the garbage collection process comprises: if the number of free blocks of the firmware system is lower than a second block quantity threshold, the starting frequency of the write-time garbage collection module is higher than a preset frequency threshold and the number of effective data blocks released in the garbage collection process is less than a third block quantity threshold, it is determined that the preset starting condition is met; otherwise, it is determined that the preset starting condition is not met. otherwise, it is determined that the preset starting condition is not met. 4.The solid state drive data writing method of claim 1, wherein, Before enabling the backup space formed by the backup block to temporarily receive write request data sent by the host end, the method further comprises: acquiring the PE cycle number of the backup block, and adjusting the starting frequency of the backup space according to the PE cycle number; wherein when the PE cycle number is greater than or equal to a preset PE limit value, the starting frequency of the backup space is reduced. 5.The solid state drive data writing method of claim 4, wherein, The adjustment of the starting frequency of the backup space according to the PE cycle number comprises: dividing the PE cycle number of the backup block into multiple intervals, each interval corresponding to a preset starting frequency coefficient; determining the interval to which the acquired PE cycle number belongs, multiplying the reference starting frequency by the corresponding frequency coefficient to obtain the adjusted starting frequency; wherein the larger the value of the interval to which the PE cycle number belongs, the smaller the corresponding starting frequency coefficient, and when the PE cycle number reaches a preset scrap threshold, the backup space is locked to prohibit starting. 6.The solid state drive data writing method of claim 1, wherein, Before determining whether to start a backup space to receive write request data according to a resource state of the firmware system and a running state of the garbage collection module based on the data write instruction, the method further comprises: collecting three performance parameters of the solid state disk in real time, including write response delay, write throughput and flash particle erase time consumption; The deviation rate of each performance parameter from the corresponding reference parameter is calculated, and if the deviation rate of any performance parameter exceeds a preset deviation threshold or the average deviation rate of the three performance parameters exceeds a preset average threshold, it is determined that the solid state disk has an end performance decline risk. 7.The solid state drive data writing method of claim 1, wherein, The write request data stored in the spare space is migrated to the free blocks, including: Classifying the write request data in the spare space, distinguishing random write data and continuous write data; According to the physical address distribution of the free blocks, the continuous write data is migrated to the free blocks with continuous physical addresses, and the random write data is migrated to the free blocks with discrete physical addresses, and the page merging technique is used to optimize the storage layout of the random write data. 8.The solid state drive data writing method of claim 1, wherein, The method further comprises a spare space dynamic expansion step: After enabling the spare space, the write request rate of the Host is monitored in real time, and if the write request rate exceeds the maximum processing rate of the spare space for a preset time period, temporary redundant blocks are called from the reserved redundancy area of the solid state disk, combined with the spare blocks to form an expanded spare space; When the number of free block resources is higher than the first block quantity threshold, the temporary redundant block resources are released first, and then the data in the spare block is migrated and the spare block resources are released. 9.The solid state drive data writing method of claim 1, wherein, The first block quantity threshold, the second block quantity threshold and the third block quantity threshold are all dynamic thresholds, and the method further comprises a threshold dynamic adjustment step: According to the actual use time length of the solid state disk, the health score of the flash memory particles and the historical garbage collection efficiency data, a threshold adjustment model is established; Every interval of a preset period, the threshold adjustment model is used to recalculate and update each block quantity threshold, wherein the lower the health score of the flash memory particles, the higher the second block quantity threshold adjustment ratio.
10. A solid state hard disk device, characterized by, Including: A memory and a processor, the memory is used to store program code; The processor is used to call the program code to execute the method of any one of claims 1 to 9.
Citation Information
Cited By
Data read-write processing method in storage system and electronic equipment
CN122111350A