Data block replacement methods, devices, electronic equipment, storage media, and program products
By identifying the utilization rate of target dies and data blocks, and combining data priority to perform dynamic resource scheduling across dies, the problem of uneven resource distribution in solid-state drives is solved, resource utilization and the accuracy of data block replacement are improved, and the reliability and storage life of the system are guaranteed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-16
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, the bad block replacement mechanism of solid-state drives has the problem of uneven resource distribution, which leads to the rapid depletion of resources for dies with high bad block rates while resources for dies with low bad block rates remain idle for a long time. This results in low overall resource utilization efficiency. Furthermore, the bad data block replacement process treats all data indiscriminately, which can easily lead to core data not being replaced in a timely manner because reserved blocks are occupied by low-value data, resulting in unreasonable resource allocation.
By identifying the target die corresponding to the data block to be replaced and the utilization rate of its reserved data blocks, the reserved data blocks are dynamically scheduled. Combining the priority of the data blocks with the overall resource utilization rate of the storage medium, intelligent resource scheduling across dies is achieved to ensure that high-value data is replaced first.
It improves the overall resource utilization, reduces the ineffective consumption of reserved data blocks, improves the accuracy of data block replacement, and ensures the reliability and storage life of the system.
Smart Images

Figure CN121541836B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to data block replacement methods, apparatus, electronic devices, storage media, and program products. Background Technology
[0002] With the widespread adoption of SSDs (Solid-State Drives), the scheduling of reserved block resources and data type matching in bad block replacement mechanisms have become key bottlenecks affecting system reliability. A common flaw in related technologies is uneven resource allocation due to static allocation. Specifically, the static allocation strategy for reserved data blocks leads to resource depletion on dies with high bad block rates and prolonged idleness on dies with low bad block rates, resulting in overall low resource utilization efficiency. Furthermore, the bad block replacement process treats all data indiscriminately, making it easy for core data to fail to be replaced promptly when bad blocks occur because reserved data blocks are occupied by low-value data, leading to unreasonable resource allocation. Summary of the Invention
[0003] This application provides a data block replacement method, apparatus, electronic device, storage medium, and program product to at least solve the problem of uneven resource allocation caused by static allocation in related technologies.
[0004] This application provides a data block replacement method for replacing data blocks in a storage medium. The storage medium includes multiple dies, and each die includes multiple data blocks. The method includes the following steps: identifying a target die corresponding to the data block to be replaced; obtaining a first utilization rate of the reserved data blocks of the target die; if the first utilization rate is greater than a preset first threshold, then determining the target data block from the reserved data blocks of other dies besides the target die; if the first utilization rate is less than or equal to the first threshold, then determining the target data block from the reserved data blocks of the target die; obtaining a second utilization rate of the reserved data blocks of the storage medium; if the second utilization rate is less than or equal to a preset second threshold, then replacing the data block to be replaced with the target data block; if the second utilization rate is greater than the second threshold, then replacing the data block to be replaced according to the priority of the target data block and the target data block.
[0005] This application also provides a data block replacement device, comprising: an identification module for identifying a target die corresponding to a data block to be replaced; a determination module for obtaining a first utilization rate of reserved data blocks of the target die, wherein if the first utilization rate is greater than a preset first threshold, the target data block is determined from reserved data blocks of other dies besides the target die, and if the first utilization rate is less than or equal to the first threshold, the target data block is determined from reserved data blocks of the target die; and a replacement module for obtaining a second utilization rate of reserved data blocks of the storage medium, wherein if the second utilization rate is less than or equal to a preset second threshold, the target data block is used to replace the data block to be replaced, and if the second utilization rate is greater than the second threshold, the target data block is replaced according to its priority.
[0006] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described data block replacement methods when executing the computer program.
[0007] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described data block replacement methods.
[0008] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described data block replacement methods.
[0009] This application achieves dynamic scheduling of reserved data blocks across memory chips by identifying the target die corresponding to the data block to be replaced and the first utilization rate of its reserved data blocks. Based on the first utilization rate of the target die, it determines whether the target data block needs to be selected from the reserved data blocks of other dies besides the target die. It also obtains the second utilization rate of the reserved data blocks of the storage medium and determines whether the data block to be replaced needs to be replaced according to the priority of the target data block. This improves the overall disk resource utilization. At the same time, by replacing data blocks according to data priority, it reduces the ineffective consumption of reserved data blocks. Therefore, it can solve the technical problem of uneven resource allocation caused by static allocation in related technologies and achieve the technical effect of improving resource utilization and the accuracy of data block replacement. Attached Figure Description
[0010] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1A flowchart illustrating a data block replacement method provided in an embodiment of this application;
[0012] Figure 2 A flowchart illustrating a data block replacement method provided in one embodiment of this application;
[0013] Figure 3 A block diagram of a data block replacement device provided in an embodiment of this application;
[0014] Figure 4 A schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0015] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0016] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0017] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0018] The related technologies have the following drawbacks:
[0019] First, the replacement priority of related technologies is disconnected from the importance of the data. The solutions typically focus only on the accuracy of identifying bad data blocks, without differentiating or refining the replacement process. That is, regardless of whether the data block contains high-value core business data or low-value temporary data, a uniform replacement priority and the same resource scheduling threshold are applied. This strategy leads to two serious problems in actual operation:
[0020] ① When core data blocks such as system boot partition, database transaction log, and critical configuration files suddenly become corrupted, if the reserved data block resources have been occupied in advance by a large amount of low-priority temporary data (such as application cache and retransmittable log buffer), the high-priority replacement request will be forced to be delayed or even fail due to insufficient resources, which may lead to system startup failure, service interruption or data consistency failure.
[0021] ② Due to their high-frequency read / write characteristics, temporary data blocks frequently trigger garbage collection and bad block replacement mechanisms, potentially occupying more than 30% of the global reserved data block resources for extended periods, while the business value they carry is often less than 5%. This resource mismatch not only causes ineffective consumption of reserved space but also accelerates the overall wear and tear of NAND flash memory. Actual tests show that under typical loads, it can shorten the overall lifespan of the SSD by approximately 15%.
[0022] Secondly, the reserved data block allocation strategies of related technologies are not adapted to the differences in bad data block generation at the die level. Related technologies typically employ static allocation mechanisms, such as reserving a fixed 7% of the total data blocks for each die as spare blocks, completely ignoring the reliability differences between different dies caused by manufacturing process variations, uneven local temperature distribution, voltage fluctuations, and other factors during actual operation. In fact, within the same SSD chip, the bad data block generation rate of some dies may be 2 to 3 times that of other dies. This static allocation method directly leads to an imbalance in resource allocation:
[0023] ① A die with a high rate of bad data blocks may exhaust its fixed quota of reserved blocks within just 3 months after it is put into use. After that, newly generated bad blocks cannot be effectively replaced and can only be marked as unusable, which in turn leads to local capacity loss or even channel failure.
[0024] ②At the same time, due to the excessively high reservation ratio and lack of dynamic adjustment mechanism, the utilization rate of reserved data blocks of dies with a low bad data block rate has been below 30% for a long time. A large number of valuable spare resources are idle and cannot be borrowed by high-risk dies, resulting in waste of the overall resource pool and uneven decline in system reliability.
[0025] Therefore, in view of the deficiencies of the above-mentioned related technologies, the embodiments of this application provide a data block replacement method, apparatus, electronic device, storage medium and program product to improve resource utilization and the accuracy of data block replacement, which will be described in detail below.
[0026] Figure 1 This is a flowchart illustrating the data block replacement method provided in an embodiment of this application.
[0027] like Figure 1As shown in the figure, this application provides a data block replacement method. The method is used to replace data blocks in a storage medium. The storage medium includes multiple dies, and each die includes multiple data blocks. The method includes the following steps:
[0028] In step S101, the target die corresponding to the data block to be replaced is identified.
[0029] Storage media refers to physical devices or materials used to store digital data, such as solid-state drives (SSDs); a die is the basic unit in semiconductor manufacturing, with each die being an independent memory chip, and multiple dies are integrated within a storage medium; a data block is the basic unit used to organize and transmit data, with each die being divided into multiple data blocks; a data block to be replaced refers to a specific data block in the storage medium that needs to be overwritten by new data or migrated to another location due to reasons such as updates, damage, wear leveling, or garbage collection.
[0030] It is understood that, in the embodiments of this application, when replacing the data block to be replaced, the target die to which the data block to be replaced belongs must first be identified in order to perform the subsequent replacement operation.
[0031] It should be noted that, before identifying the target die corresponding to the data block to be replaced, the storage medium must be powered on and the relevant information tables must be initialized. The relevant information tables include a first correspondence table, a second correspondence table, a die-level status table, and a global reserved data block mapping table.
[0032] Power-on refers to connecting the storage medium to power, enabling it to enter the working state from a power-off or hibernation state. After power-on, the controller starts running and initializes the internal data structures and hardware resources. The first correspondence table is a record table of data blocks to be replaced, recording the data blocks to be replaced and the mapping between the data blocks to be replaced and the corresponding target dies, which can quickly locate the physical location of the data blocks. The second correspondence table records the mapping between data block identifiers and data types, which is used for priority determination. The die-level status table records the operating status of each die in the storage medium, including the reserved data block utilization rate, the number of bad data blocks, the growth rate of bad data blocks, and the die load, which is used for health assessment and resource scheduling. The global reserved data block mapping table is used to maintain the allocation status and ownership of all reserved data blocks in the entire storage medium, recording the physical address of the reserved data block, the current ownership die, and the usage status, such as whether it is idle or has been migrated out.
[0033] It is understood that, before identifying the target die corresponding to the data block to be replaced, the embodiments of this application need to perform a power-on operation on the storage medium and complete the initialization of relevant information tables. The relevant information tables specifically include: a first correspondence table for locating the physical location of the data block, a second correspondence table for identifying the data type, a die-level status table reflecting the health and resource status of each die, and a global reserved data block mapping table for managing the allocation of reserved blocks across the entire device. Through this initialization process, a complete resource view and mapping foundation can be established, providing support for subsequent accurate and efficient data block replacement and die-level scheduling.
[0034] In this embodiment of the application, identifying the target die corresponding to the data block to be replaced includes: identifying the data block identifier of the data block to be replaced; obtaining a pre-set first correspondence table between the data block identifier and the die; querying the first correspondence table to find the target die.
[0035] Among them, the data block identifier is used to uniquely identify the number or address of a data block; the first correspondence table is a mapping table between data block identifiers and dies, which records the correspondence between each data block identifier and its corresponding die, and can be used to quickly locate which die a data block is physically located in.
[0036] It is understood that, in order to determine which physical die the data block to be replaced is located on, this application embodiment can obtain the data block identifier of the data block, query the first correspondence table that records the association between all data block identifiers and their respective dies, and accurately identify the corresponding target die by searching for the data block identifier in the table.
[0037] In this embodiment of the application, before identifying the target die corresponding to the data block to be replaced, the method further includes: obtaining a pre-set second correspondence table between data blocks and data types; querying the second correspondence table to find the data type; determining the priority of the data block to be replaced based on its data type; determining the queue position of the data block to be replaced in the data queue based on its priority; placing the data block to be replaced into the data queue based on its queue position; determining the replacement order of the data block to be replaced based on the data queue; and extracting the data block to be replaced from the data queue based on the replacement order.
[0038] Among them, data type refers to the category or nature of the data stored in the data block. Different types of data have different access frequencies and importance. The second correspondence table is a pre-configured mapping table that records the correspondence between each type of data and its corresponding data type, which is used to quickly query what data type a data block carries. Priority is the importance or urgency of processing a data block according to its data type. For example, critical data needs to be set with higher priority, while temporary cached data has a lower priority. The data queue is a list of pending data blocks sorted by priority, which is used to manage the order in which data blocks to be replaced are replaced.
[0039] It is understood that, before identifying the target die corresponding to the data block to be replaced, the embodiments of this application need to obtain a pre-established second correspondence table, and determine the data type of the data included in the data block to be replaced by querying the table; then, assign a corresponding processing priority to it according to the data type, and arrange it in the appropriate position in the data queue according to the priority; finally, according to the replacement order determined in the data queue, the data blocks to be replaced are extracted from the data queue in sequence for subsequent processing, ensuring that high priority or key data can be managed more timely and reasonably.
[0040] In this embodiment of the application, before determining the priority of the data block to be replaced based on the data type of the data block to be replaced, the method further includes: if no data type is found in the second correspondence table, then identifying the logical block addressing attribute of the data block to be replaced; obtaining a third correspondence table between the logical block addressing attribute and the data type; querying the third correspondence table to find the data type.
[0041] Logical Block Addressing (LBA) is a linear addressing scheme used by the operating system or host to access data from storage devices. Logical Block Addressing Attributes refer to metadata or characteristics related to a specific LBA, such as whether the address is used for file system metadata, whether it is frequently written, or whether it belongs to the log area. The third mapping table is a pre-defined mapping table that associates logical block addressing attributes with data types, used to infer data types when they cannot be directly obtained from the data block identifier.
[0042] It is understood that, before determining the priority of the data block to be replaced based on its data type, if the data type corresponding to the data in the data block to be replaced cannot be found in the second correspondence table, the logical block addressing attribute of the data block will be analyzed instead. At the same time, a pre-configured third correspondence table will be obtained. By querying this table, the corresponding data type will be inferred based on the logical block addressing attribute of the data in the data block to be replaced, thereby providing a basis for subsequent priority determination and enhancing robustness and adaptability when data type information is missing.
[0043] In this embodiment of the application, before determining the queue position of the data block to be replaced in the data queue according to the priority of the data block to be replaced, the process includes obtaining the risk level and erasure / write stage of the data block to be replaced; and correcting the priority of the data block to be replaced according to the risk level and erasure / write stage.
[0044] The risk level refers to the degree to which the data block to be replaced faces the possibility of failure, data loss, or performance degradation in its current storage state. For example, the risk level of a bad data block is greater than that of a weak data block (a data block that is not completely failed but has shown abnormal signs). The erase / write phase describes the current life cycle stage of a data block, which is usually related to the number of erases / writes it has performed. The later the erase / write phase, the lower the reliability of the data block, which may affect the data retention capability. Therefore, the physical wear and tear at the end of the erase / write phase is greater than that in the middle phase, and the physical wear and tear in the middle phase is greater than that in the early phase.
[0045] It is understood that, before determining the position of the data block to be replaced in the data queue based on its priority, this application embodiment will further obtain the risk level and erasure stage of the data block to be replaced to reflect the failure probability and physical wear of the data block to be replaced. Based on these two factors, the original priority will be dynamically corrected. For example, high-risk data blocks or those in the late erasure stage will be given higher priority to ensure that critical or vulnerable data is migrated or replaced first. This ensures that the replacement strategy is more intelligent and reliable, taking into account both data security and storage life.
[0046] In this embodiment of the application, the priority of the data block to be replaced is adjusted according to the risk level and the erasure / write stage, including: determining a first score of the data block to be replaced based on the data type; determining a second score of the data block to be replaced based on the risk level; determining a third score of the data block to be replaced based on the erasure / write stage; obtaining the respective weights of the data type, risk level and erasure / write stage of the data block to be replaced, and calculating a comprehensive score based on the first score, the second score, the third score and their respective weights; and determining the priority of the data block to be replaced based on the comprehensive score.
[0047] The first, second, and third scores are numerical values obtained by quantitatively evaluating the data block based on data type, risk level, and erase / write stage. For example, they can be quantified as integers between 0 and 100. The specific quantitative evaluation method is set according to actual needs and is not specifically limited here. The weight represents the relative importance of different factors (such as data type, risk level, and erase / write stage) in the comprehensive decision-making. For example, if more attention needs to be paid to reliability, the risk level may have a higher weight. The weight is set according to actual needs and is not specifically limited here.
[0048] It is understood that, in correcting the priority of the data block to be replaced, this application embodiment needs to provide three independent scores (i.e., first, second, and third scores) based on the data type, risk level, and erasure / write stage. Then, these three scores are weighted and calculated to obtain a comprehensive score, for example, comprehensive score = first score (50% weight) + second score (30% weight) + third score (20% weight). Finally, the final priority of the data block is determined based on the comprehensive score, i.e., the higher the score, the higher the priority, and thus it will be processed first in subsequent replacement operations. By setting the weights, the importance of each factor in the decision-making can be adjusted according to actual needs, realizing a multi-dimensional and configurable intelligent priority scheduling mechanism.
[0049] In step S102, the first utilization rate of the reserved data block of the target die is obtained. If the first utilization rate is greater than the preset first threshold, the target data block is determined from the reserved data blocks of other dies besides the target die. If the first utilization rate is less than or equal to the first threshold, the target data block is determined from the reserved data blocks of the target die.
[0050] Among them, reserved data blocks are backup data blocks in the storage medium that are reserved in advance and not used for regular user data storage. They are mainly used for maintenance operations such as replacing bad data blocks, wear leveling, or garbage collection to improve equipment reliability and lifespan. The first utilization rate refers to the proportion of reserved data blocks in the target die that have been used. The calculation method is usually: the number of used reserved blocks divided by the total number of reserved blocks. The first utilization rate reflects the sufficiency of the remaining backup resources of the die. The first threshold is a preset upper limit of utilization rate, which is set according to actual needs and is not specifically limited here. For example, it can be set to 70% to determine whether the reserved resources of the target die are sufficient. Exceeding the first threshold indicates that the target die resources are tight and reserved data blocks need to be borrowed from other dies.
[0051] It is understood that, in this embodiment of the application, the current utilization rate of the reserved data block in the target die, i.e., the first utilization rate, is obtained and compared with the first threshold. If the first utilization rate exceeds the preset first threshold, it indicates that the spare resources of the target die are nearly exhausted. At this time, the target data block should be selected from the reserved data blocks of other dies. Conversely, if the utilization rate does not exceed the threshold, it indicates that the target die still has enough spare space. The target data block is then directly selected from the reserved data blocks of the target die. This can effectively avoid the reliability of a single die being affected by the depletion of spare resources and achieve balanced utilization of resources across dies.
[0052] In this embodiment of the application, determining the target data block from the reserved data blocks of other grains besides the target grain includes: obtaining a first utilization rate and a bad data block growth rate of the reserved data blocks of other grains; marking other grains according to the first utilization rate and the bad data block growth rate; and determining the target data block according to the marking results of other grains.
[0053] The first utilization rate refers to the proportion of reserved data blocks used in other dies, that is, the percentage of reserved blocks used by these dies out of their total number of reserved blocks. This indicator reflects the degree of consumption of spare resources of each die. The bad data block growth rate indicates the number of new bad data blocks in a die per unit time. It is used to measure the health deterioration trend or reliability decline rate of the die. The faster the growth, the more serious the die aging or defects.
[0054] It is understood that, in the embodiments of this application, when it is necessary to select a target data block from other dies besides the target die, the first utilization rate of the reserved data block and the growth rate of the bad data block of each candidate die are obtained first. The dies are comprehensively evaluated and marked accordingly based on these two indicators. Finally, based on these marking results, the reserved data block from the die with good health and sufficient reserved resources is selected as the target data block, thereby optimizing the global resource allocation while ensuring data reliability.
[0055] In this embodiment of the application, marking other dies based on a first utilization rate and a bad data block growth rate includes: if the first utilization rate is greater than a preset third threshold and the bad data block growth rate is greater than a preset fourth threshold, then marking other dies as scarce dies; if the second utilization rate is less than or equal to a preset fifth threshold and the bad data block growth rate is less than or equal to a preset sixth threshold, then marking other dies as idle dies.
[0056] The third threshold is the upper limit of the reserved data block utilization rate, exceeding which is considered resource strain; the fourth threshold is the upper limit of the bad data block growth rate, exceeding which is considered high reliability risk; the fifth threshold is the lower limit of the reserved data block utilization rate, below or equal to this value is considered sufficient resources; the sixth threshold is the safe upper limit of the bad data block growth rate, below or equal to this value is considered healthy and stable; the third, fourth, fifth and sixth thresholds are all set according to actual needs, and are not specifically limited here.
[0057] It is understood that, in the embodiments of this application, two judgment criteria are used when marking other dies besides the target die: if the first utilization rate of a die exceeds a preset third threshold and its bad data block growth rate also exceeds a fourth threshold, it is marked as a scarce die, indicating that the die resources are tight and the reliability is rapidly deteriorating; conversely, if its first utilization rate does not exceed a preset fifth threshold and its bad data block growth rate does not exceed a sixth threshold, it is marked as an idle die, indicating that the die resources are sufficient and the state is healthy. This classification mechanism helps to intelligently select the most suitable die to provide the target data block in the future.
[0058] In this embodiment of the application, determining the target data block based on the marking results of other grains includes: identifying scarce grains and idle grains in the marking results of other grains; relocating a reserved data block from an idle grain based on at least one scarce grain and an idle grain; and determining the target data block from the reserved data block relocated from the idle grain.
[0059] Among them, moving out reserved data blocks does not mean physically moving reserved data blocks. Rather, it refers to the reallocation or authorization of reserved data blocks in an idle die for replacement operations in other dies at the logical or resource management level. It belongs to the cross-die spare resource scheduling strategy.
[0060] It is understood that, in determining the target data block based on the marking results of other dies, the embodiments of this application first identify which dies are marked as scarce dies and which are idle dies. Then, based on these marking information, reserved data blocks are allocated from the idle dies, and a portion of them are selected as target data blocks for actual replacement operations. This realizes intelligent resource scheduling across dies, which improves the resource utilization efficiency of the overall storage system while ensuring reliability.
[0061] In this embodiment of the application, relocating a reserved data block from an idle die based on at least one of scarce dies and idle dies includes: calculating an idle quantity based on the number of reserved data blocks in the idle die; calculating a gap quantity based on the number of reserved data blocks in the scarce die; calculating a scheduling amount for the idle die based on the idle quantity and the gap quantity; and relocating a reserved data block from the idle die according to the scheduling amount.
[0062] Specifically, the idle quantity is calculated based on the number of reserved data blocks in the idle dies. This can be achieved by multiplying the total number of reserved data blocks in the idle dies by a preset first percentage, such as 30%. The shortage quantity is calculated based on the number of reserved data blocks in the scarce dies. This can be achieved by multiplying the total number of data blocks in the scarce dies by a preset second percentage, such as 5%, and then subtracting the current total number of reserved data blocks in the scarce dies. The scheduling amount of the idle dies is calculated based on the idle quantity and the shortage quantity, i.e., the smaller value between the idle quantity and the shortage quantity is selected as the scheduling amount. The first percentage and the second percentage are set according to actual needs and are not specifically limited here.
[0063] It is understood that, according to the situation of idle and scarce dies, the number of reserved data blocks to be migrated from idle dies, i.e., the scheduling amount, is dynamically determined. The available idle quantity is calculated by multiplying the total number of reserved data blocks in idle dies by a preset first percentage. Next, the required gap quantity is obtained by multiplying the total number of data blocks in scarce dies by a preset second percentage and then subtracting the number of reserved data blocks that they currently actually have. Then, the smaller value between the idle quantity and the gap quantity is taken as the scheduling amount. Finally, the corresponding number of reserved data blocks are logically migrated from idle dies according to the scheduling amount to support the replacement needs of scarce dies, thereby realizing intelligent resource scheduling and load balancing across dies.
[0064] In this embodiment of the application, before determining the idle reserved data block from the idle die according to the scheduling amount, the method further includes: obtaining the current load rate, data migration status and data block scheduling quantity of the storage medium; if the current load rate is less than or equal to a preset first load rate threshold, the data migration status is a no data migration operation status, and the data block scheduling quantity is less than or equal to a preset quantity threshold, then the idle reserved data block is determined from the idle die according to the scheduling amount.
[0065] The current load rate refers to the current I / O load rate of the storage medium, and the current I / O queue length is the percentage of the maximum queue length. The I / O queue length refers to the number of I / O commands submitted but not yet processed by the storage medium, and the maximum queue length refers to the maximum capacity of the I / O queue supported by the storage medium or protocol. The data migration status indicates whether a data migration operation is currently in progress, such as garbage collection, wear leveling, or bad block replacement. If the status is "no data migration operation," it means that no other concurrent migration tasks are running. The first load rate threshold and the quantity threshold are preset safety boundary values, which are set according to actual needs and are not specifically limited here. For example, the load rate threshold is set to 30%, and the quantity threshold is set to 100 blocks to ensure that operations are only performed under light load, conflict-free, and controllable scheduling conditions.
[0066] It is understood that, before selecting idle reserved data blocks from idle dies according to the scheduling amount in this embodiment of the application, it is necessary to first assess the current overall operating status. Specifically, this is done by obtaining the current load rate of the storage medium, the data migration status, and the number of data blocks to be processed. Only when the three conditions are met simultaneously—the load rate does not exceed the preset first load rate threshold (indicating that the system is relatively idle), there is currently no data migration operation in progress (to avoid resource conflicts), and the scheduling amount does not exceed the preset quantity threshold (to prevent excessive batch size from affecting performance)—is it allowed to determine and allocate idle reserved data blocks from idle dies according to the scheduling amount. This ensures that the resource scheduling operation is executed in a safe and stable system environment, taking into account both efficiency and reliability.
[0067] In this embodiment of the application, if any one of the following conditions is not met: the current load rate is less than or equal to a preset first load rate threshold, the data migration status is a no-data-migration-operation status, and the number of data block scheduling is less than or equal to a preset number threshold, then after waiting for a first preset time period, the target die corresponding to the data block to be replaced is re-identified.
[0068] The first preset duration is a pre-set waiting time, such as 10 seconds, used to pause the operation when the conditions are not met, to avoid frequent attempts, and to give the system state a chance to change. It can be set according to actual needs and is not specifically limited here. Re-identifying the target die corresponding to the data block to be replaced means returning to the upstream of the process and executing step S101 again. Re-identifying the target die corresponding to the data block to be replaced can ensure that subsequent operations are based on the latest information, in order to prevent information errors caused by possible changes in the state within the first preset duration (such as the release of the original target die resources, bad block updates, etc.).
[0069] It is understood that if any of the following situations are detected in the embodiments of this application: the current load rate exceeds a preset first load rate threshold, there is an ongoing data migration operation, or the number of data blocks to be scheduled exceeds a preset quantity threshold, the subsequent operation will not be executed for the time being. Instead, the process of identifying the data blocks to be replaced to the target die will be re-executed after a first preset time. This prevents the impact on other ongoing normal services in the storage medium, while ensuring that the target die can be accurately and safely located and subsequent resource scheduling can be performed. This ensures that the resource scheduling operation is executed in a safe and stable system environment, and enhances the system's adaptability and robustness.
[0070] In this embodiment of the application, after determining the idle reserved data blocks from the idle dies according to the scheduling amount, the method further includes: obtaining the third utilization rate of the reserved data blocks of the idle dies; if the third utilization rate is greater than a preset seventh threshold, calculating the difference between the third utilization rate and the seventh threshold, determining the actual rollback rate of the scheduling amount of the idle dies based on the difference, wherein the actual rollback rate is directly proportional to the difference; and correcting the scheduling amount of the idle dies based on the actual rollback rate.
[0071] The third utilization rate refers to the recalculated utilization ratio of the current reserved data blocks of the idle die after determining the idle reserved data blocks from the idle die according to the scheduling amount (the number of used reserved blocks divided by the total number of reserved blocks). It is used to assess whether the remaining resources are still within a safe range after the scheduling operation. The seventh threshold is a preset safety upper limit, such as 70%, which is set according to actual needs and is not specifically limited here. It represents the maximum reserved block utilization rate allowed for the idle die after scheduling. If this value is exceeded, it indicates that the scheduling may be excessive and a callback is required. The difference between the third utilization rate and the seventh threshold reflects the degree to which the resource usage exceeds the safety boundary after scheduling. The larger the difference, the higher the risk. The actual rollback rate represents the proportion by which the original scheduling amount needs to be reduced. For example, a rollback rate of 20% means that only 80% of the original scheduling amount is executed. The actual rollback rate is directly proportional to the above difference. That is, the more it exceeds the limit, the stronger the rollback is, in order to protect the reliability of the die.
[0072] It is understood that after determining the idle reserved data blocks from the idle dies according to the scheduling amount in the embodiments of this application, it is necessary to further obtain the third utilization rate of the idle die after scheduling. If the utilization rate exceeds the preset seventh threshold, the difference of the excess is calculated, and an actual rollback rate is determined accordingly. The rollback rate is proportional to the difference, that is, the more it exceeds, the greater the rollback magnitude. Subsequently, the original scheduling amount is adjusted downward using the rollback rate, that is, the new scheduling amount = the original scheduling amount × (1 - actual rollback rate), to obtain the adjusted and more conservative new scheduling amount, which is used for subsequent actual execution or recording, thereby avoiding the depletion of idle die resources or the decrease in reliability due to over-scheduling, and realizing dynamic and safe closed-loop control of resource allocation.
[0073] In this embodiment of the application, after relocating the reserved data block from the idle die based on at least one of the scarce die and the idle die, the method further includes: obtaining the idle duration of the reserved data block relocated from the idle die; if the idle duration is greater than a preset duration threshold, then the reserved data block relocated from the idle die is migrated back to the idle die.
[0074] The duration threshold is a preset time limit, such as 24 hours, which is set according to actual needs and is not specifically limited here. It is used to determine whether the reserved data blocks to be migrated have not been used for a long time. If the threshold is exceeded, it is considered that the scheduling is redundant or the demand has disappeared.
[0075] It is understood that after completing the operation of migrating reserved data blocks from idle dies to other dies, the embodiments of this application will continue to monitor these migrated data blocks. If it is detected that the idle time of a certain migrated reserved data block since its migration exceeds a preset time threshold, that is, it has not been actually used for replacement or writing for a long time, then it is determined that the scheduling is unnecessary, and the data block is automatically migrated back to its original idle die and reintegrated into its reserved resource pool. This effectively prevents resource fragmentation and management overhead caused by excessive or ineffective scheduling, and improves the resource utilization efficiency and maintainability of the storage system.
[0076] In step S103, the second utilization rate of the reserved data block of the storage medium is obtained. If the second utilization rate is less than or equal to the preset second threshold, the target data block is used to replace the data block to be replaced. If the second utilization rate is greater than the second threshold, the target data block is used to replace the data block to be replaced according to the priority of the target data block.
[0077] The second utilization rate refers to the overall utilization ratio of all reserved data blocks in the entire storage medium, that is, the number of reserved blocks that have been used divided by the total number of reserved blocks, reflecting the overall tightness of spare resources; the second threshold is a preset upper limit of utilization rate, such as 70%, which is set according to actual needs and is not specifically limited here. It is used to judge whether the overall reserved resources of the storage medium are sufficient. If it is lower than or equal to the second threshold, it means that the resources are abundant, and if it is higher, it means that the resources are tight.
[0078] It is understood that the embodiments of this application identify the second utilization rate of the reserved data blocks in the entire storage medium. If the second utilization rate is less than or equal to the preset second threshold, it indicates that the global spare resources are sufficient and the selected target data block can be directly used to replace the data block to be replaced. However, if the second utilization rate exceeds the second threshold, it indicates that the overall reserved resources are tight. At this time, it is necessary to further refer to the priority of the target data blocks and only perform operations on the high-priority part of the target data blocks, so as to ensure the reliability of critical data and system stability under resource-constrained conditions.
[0079] In this embodiment of the application, replacing the data block to be replaced according to the priority of the data block to be replaced and the target data block includes: if the priority of the data block to be replaced is greater than a preset eighth threshold, then the target data block is used to replace the data block to be replaced; if the priority of the data block to be replaced is less than or equal to the eighth threshold, then the data block to be replaced is temporarily stored in a preset first cache area.
[0080] The eighth threshold is a preset priority threshold, such as a priority score of 80, used to distinguish between high-priority and low-priority replacement tasks. Data blocks to be replaced with a priority higher than the eighth threshold are considered high-priority replacement tasks and must be processed immediately; data blocks to be replaced with a priority lower than or equal to the eighth threshold can be processed with a delay. The first cache area is a buffer specifically used to temporarily store information on data blocks to be replaced that have not yet been processed due to low priority or limited resources. The first cache area does not store actual user data content, but records replacement tasks that need to be processed later.
[0081] It is understood that, in the case of resource scarcity, i.e., when the second utilization rate is greater than the second threshold, the implementation of this application determines whether to immediately perform the replacement based on the priority of the data block to be replaced. If the priority of the data block to be replaced is higher than the preset eighth threshold, the replacement operation of the data block to be replaced is directly completed using the selected target data block. If the priority is lower than or equal to the threshold, the replacement task of the data block to be replaced is considered to be postponed and temporarily stored in the preset first cache area. It will be processed after the load decreases or resources are released, thus ensuring that the reliability of high-value or high-risk data is prioritized under limited resources, while avoiding low-priority operations from occupying critical resources.
[0082] In this embodiment of the application, after temporarily storing the data block to be replaced in a pre-set first cache area, the method further includes: obtaining the current load rate of the storage medium; if the current load rate is less than or equal to a pre-set second load rate threshold, reading the data block to be replaced from the first cache area; and replacing the data block to be replaced with the target data block.
[0083] The current load rate refers to the current I / O load rate of the storage medium, indicating the level of activity of the storage medium in processing input / output operations. The second load rate threshold is a preset upper limit of the I / O load rate, such as 30%, which can be set according to actual needs and is not specifically limited here. It is used to determine whether the system is in a low load state.
[0084] It is understood that, after temporarily storing the data block to be replaced in a pre-set first cache area, the current load rate of the storage medium is obtained in the embodiments of this application. If the current load rate is less than or equal to a preset second load rate threshold, it indicates that the input / output pressure of the storage medium is low and it is in an idle or lightly loaded state. Then, the temporarily stored data block to be replaced is read from the first cache area, and the replacement operation is performed using the allocated target data block. This ensures that the replacement task of the low-priority data block to be replaced is only executed during the low-load window period without affecting the user I / O performance, thus taking into account both system responsiveness and data reliability.
[0085] In this embodiment of the application, replacing the data block to be replaced with the target data block includes: identifying the valid data and logical address of the data block to be replaced; reading the valid data of the data block to be replaced into a pre-set second cache area, and writing the valid data of the second cache area into the target data block; identifying the physical address corresponding to the logical address of the data block to be replaced, and correcting the physical address corresponding to the logical address to the physical address corresponding to the target data block.
[0086] Among them, the valid data is the user data in the data block to be replaced that is still referenced by the logical address and needs to be retained and migrated to the new location; the second cache area is the controller cache, which is embedded inside the main control chip of the storage medium or in a high-speed cache tightly coupled with it. It is directly managed by the storage controller and is used to temporarily store read and write data, mapping tables, metadata, or intermediate data during the migration process. It has the characteristics of low latency and high bandwidth and is a key resource for performing internal management operations, such as garbage collection, wear leveling, and data migration; the logical address refers to the address used by the host (such as the operating system) to access the storage device, such as the LBA address, which is mapped to the physical address through the flash translation layer (FTL); the physical address is the actual storage location of the data in the die, which is maintained and managed by the controller.
[0087] It is understood that, in the process of replacing the data block to be replaced with the target data block in this embodiment of the application, the valid data in the data block to be replaced and its corresponding logical address are first identified; then, the valid data is read and temporarily stored in the second cache area; next, the controller writes the valid data in the second cache area into the target data block; finally, the physical address currently mapped by the logical address (currently the physical address pointing to the data block to be replaced) is found and updated to the physical address of the target data block, thereby completing the data migration and address remapping, and realizing efficient and reliable data transfer.
[0088] It should be noted that in this embodiment of the application, the process of replacing the data block to be replaced with the target data block is carried out in the order of the data queue.
[0089] It is understood that in the process of replacing the data block to be replaced with the target data block in the embodiments of this application, the replacement operation is performed in the order of the data queue. The data queue is pre-ordered and generated according to the comprehensive priority of the data block to be replaced (dynamically calculated in combination with factors such as data type, risk level, and erasure / write stage). The data block with higher priority is placed at the front of the queue. The data block to be replaced is taken out from the front of the queue in turn, the target data block is allocated to it, and the data migration and address remapping are completed. This ensures that high-value or high-risk data is processed first, so that the reliability of core business data and the overall robustness of the system can still be guaranteed in scenarios with limited resources or fluctuating system load.
[0090] According to the data block replacement method provided in the embodiments of this application, the target die corresponding to the data block to be replaced and the first utilization rate of its reserved data blocks can be identified. Based on the first utilization rate of the target die, it is determined whether the target data block needs to be determined from the reserved data blocks of other dies besides the target die. The second utilization rate of the reserved data blocks of the storage medium is obtained, and based on the second utilization rate, it is determined whether the data block to be replaced needs to be replaced according to the priority of the target data block. This realizes cross-die dynamic scheduling of reserved data blocks, improves the overall disk resource utilization, and at the same time, data block replacement according to data priority reduces the invalid consumption of reserved data blocks.
[0091] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0092] The data block replacement method is further described below through a specific embodiment.
[0093] like Figure 2 The diagram shown is a flowchart of the data block replacement method provided in this embodiment. Figure 2 As shown, the method specifically includes the following steps:
[0094] Step S1: Power on and initialize the entire storage medium.
[0095] Initialize the relevant information tables:
[0096] ① Initialize the first correspondence table (the data block to be replaced table, which records the data blocks to be replaced and the target dies corresponding to the data blocks to be replaced);
[0097] ② Initialize the tables related to replacing differential bad data blocks: the second correspondence table, namely the data type mapping table (recording the correspondence between data blocks and data types), and the first cache area (temporary cache area, capacity = total SSD capacity × 2%, temporarily storing low-priority data).
[0098] ③ Initialize the following tables related to grain-level scheduling: the grain-level status table (Die_Status_Table, which records information about each grain, including the grain's ID (Identifier), the SuperLun ID it belongs to, the total number of data blocks, the initial number of reserved data blocks (total number of data blocks × 7%), and the initial number of bad data blocks), and the global reserved data block mapping table (Global_Resv_Map, which records the physical address of the reserved data block, its current belonging grain, and its usage status).
[0099] Step S2: Periodic monitoring and status updates.
[0100] Periodic monitoring and status updates are performed every 5 seconds.
[0101] ① Collect grain-level status: Read the current number of bad data blocks and the number of reserved data blocks used for each grain, calculate the first utilization rate (Resv_Usage) of the reserved data blocks of the grain, the growth rate of bad data blocks, calculate the current load rate (IO load rate) of the entire disk, and update it to the grain-level status table (Die_Status_Table);
[0102] ②Detection of bad data block trigger: Check the first correspondence table. If there is a data block to be replaced, identify the target die of the data block to be replaced and proceed to step S3; otherwise, repeat this step.
[0103] Step S3: Identify the data type of the data block to be replaced.
[0104] For the data blocks to be replaced identified in step S2, the importance of the data is identified and the replacement threshold is adjusted. Specifically, the second correspondence table is queried to obtain its data type. If the data type of the data block to be replaced is not recorded in the second correspondence table, the mapping table is automatically identified and updated through the LBA attribute. For example, if the LBA attribute is a system partition, the data type is set to core data; if the LBA attribute is a temporary directory, the data type is set to temporary data.
[0105] Step S4: Sort and replace according to priority, and generate a data queue.
[0106] For the blocks in the first correspondence table, sort the replacement priority, obtain the data type, risk level (bad block > weak block), and erasure stage (late stage > mid stage > early stage) of the data block to be replaced, and sort them according to "data type (50% weight) + risk level (30% weight) + erasure stage (20% weight)" to form a data queue (blocks with higher priority are placed at the head of the queue).
[0107] Step S5: Query the reserved data block and determine whether scheduling is triggered.
[0108] In this embodiment, the first threshold is set to 70%, and the first utilization rate of the grain to which the block to be replaced belongs is queried:
[0109] ①If the first utilization rate Resv_Usage≤70% (the current die has sufficient reserved data blocks), proceed to step S6;
[0110] ② If the first utilization rate Resv_Usage > 70% (current die reserved blocks are tight), traverse the die-level status table Die_Status_Table, mark dies with "first utilization rate Resv_Usage > 80% and bad block growth rate > 20%" as scarce dies, and mark dies with "first utilization rate Resv_Usage < 30% and bad block growth rate < 5%" as idle dies. Then, perform data block scheduling. The data block scheduling steps are steps S5.1-S5.3:
[0111] Step S5.1, Calculate the scheduling amount: The amount to be transferred out n = min(total number of reserved data blocks for idle dies × 30%, demand gap for scarce dies = total number of data blocks for scarce dies × 5% - current total number of reserved blocks for scarce dies), the amount to be transferred in = the amount to be transferred out = the scheduling amount;
[0112] Step S5.2: Check scheduling protection conditions: If the current load rate (IO load rate) of the entire disk is <30%, there is no data migration operation, and the number of blocks scheduled in a single operation is ≤100, execute the scheduling; otherwise, re-execute steps S2-S5 after 10 seconds (to prevent affecting the normal operation of the entire disk).
[0113] Step S5.3: Perform cross-die data block scheduling: Select n idle reserved blocks from the idle dies, mark them as to be migrated, and update the global reserved data block mapping table Global_Resv_Map (changing the current belonging die to the die with a shortage of reserved data blocks) and the die-level status table Die_Status_Table (subtracting the amount of blocks to be moved out from the number of reserved blocks in the idle die, and adding the amount of blocks to be moved in to the number of reserved blocks in the die with a shortage of blocks); after scheduling, monitor the first utilization rate Resv_Usage of the idle dies every 10 seconds. If the first utilization rate Resv_Usage > 70%, roll back 50% of the scheduling amount.
[0114] Step S6: Allocate reserved data blocks.
[0115] The second utilization rate is the total utilization rate of the reserved data blocks on the entire disk:
[0116] ① If the second utilization rate is ≤80% (sufficient), allocate a free reserved block of the current die (or a die with sufficient reserved data blocks after scheduling) to each data block according to the data queue order (prioritize the block with the smallest logical address).
[0117] ② If the second utilization rate is >80% (tight), reserved blocks are only allocated to data blocks to be replaced with a priority of ≥80 in the data queue (such as core data level + bad data blocks + high priority data blocks to be replaced at the end of the period). Blocks with a priority of <80 are temporarily stored in the first cache area, i.e., the temporary cache area.
[0118] Step S7: Perform data replacement and mapping update.
[0119] The valid data of the data block to be replaced (or the temporary cache) is read into the second cache area, i.e., the controller cache. The second cache area then writes the valid data into the allocated reserved data block. In the L2P (Logical-to-Physical) table, the physical address corresponding to the original logical address is changed to the reserved data block address, and the operation time, data type Data_Type, address before and after replacement, etc. are recorded in the log. If the data comes from the temporary cache area, this step is executed when the current load rate of the entire disk is <30%.
[0120] Step S8: Monitoring of scheduling data blocks.
[0121] After scheduling and optimization, the Global Reserved Data Block Mapping Table (Global_Resv_Map) is checked every 30 seconds. Idle cross-crystal reserved data blocks that have been idle for more than 24 hours are migrated back to their original dies. The Global Reserved Data Block Mapping Table (Global_Resv_Map) and the die-level status table (Die_Status_Table) are updated to release redundant resources in dies with scarce resources. After completion, the process returns to step S2 to enter the next round of periodic monitoring.
[0122] Embodiments of this application also provide a data block replacement device. Figure 3 This is a block diagram of a data block replacement device provided in an embodiment of this application, as shown below. Figure 3 As shown, the device includes: an identification module 201, a determination module 202, and a replacement module 203.
[0123] The identification module 201 is used to identify the target die corresponding to the data block to be replaced; the determination module 202 is used to obtain the first utilization rate of the reserved data blocks of the target die; if the first utilization rate is greater than the preset first threshold, the target data block is determined from the reserved data blocks of other dies besides the target die; if the first utilization rate is less than or equal to the first threshold, the target data block is determined from the reserved data blocks of the target die; the replacement module 203 is used to obtain the second utilization rate of the reserved data blocks of the storage medium; if the second utilization rate is less than or equal to the preset second threshold, the target data block is used to replace the data block to be replaced; if the second utilization rate is greater than the second threshold, the target data block is replaced according to the priority of the target data block.
[0124] In this embodiment of the application, the identification module 201 is further configured to: identify the data block identifier of the data block to be replaced; obtain a pre-set first correspondence table between the data block identifier and the die; query the first correspondence table and query the target die from the first correspondence table.
[0125] In this embodiment, a sorting module is further included, which is used to: obtain a pre-set second correspondence table between data blocks and data types before identifying the target die corresponding to the data block to be replaced; query the second correspondence table to query the data type; determine the priority of the data block to be replaced according to the data type of the data block to be replaced; determine the queue position of the data block to be replaced in the data queue according to the priority of the data block to be replaced, and put the data block to be replaced into the data queue according to the queue position; determine the replacement order of the data block to be replaced according to the data queue, and extract the data block to be replaced from the data queue based on the replacement order.
[0126] In this embodiment of the application, a query module is also included. The query module is further configured to: before determining the priority of the data block to be replaced based on the data type of the data block to be replaced, further include: if no data type is found from the second correspondence table, then identify the logical block addressing attribute of the data block to be replaced; obtain a third correspondence table of logical block addressing attributes and data types; query the third correspondence table, and query the data type from the third correspondence table.
[0127] In this embodiment of the application, the sorting module is further used to: obtain the risk level and erasure / write stage of the data block to be replaced; and correct the priority of the data block to be replaced according to the risk level and erasure / write stage.
[0128] In this embodiment of the application, the sorting module is further configured to: determine a first score for the data block to be replaced based on the data type; determine a second score for the data block to be replaced based on the risk level; determine a third score for the data block to be replaced based on the erasure / write stage; obtain the data type, risk level, and respective weights of the erasure / write stage of the data block to be replaced; calculate a comprehensive score based on the first score, the second score, the third score, and their respective weights; and determine the priority of the data block to be replaced based on the comprehensive score.
[0129] In this embodiment of the application, the determining module 202 is further configured to: obtain the first utilization rate and bad data block growth rate of the reserved data blocks of other dies; mark other dies according to the first utilization rate and bad data block growth rate; and determine the target data block according to the marking results of other dies.
[0130] In this embodiment of the application, the determining module 202 is further configured to: mark other dies as scarce dies if the first utilization rate is greater than a preset third threshold and the bad data block growth rate is greater than a preset fourth threshold; and mark other dies as idle dies if the second utilization rate is less than or equal to a preset fifth threshold and the bad data block growth rate is less than or equal to a preset sixth threshold.
[0131] In this embodiment of the application, the determining module 202 is further configured to: identify scarce and idle grains in the marking results of other grains; migrate a reserved data block from an idle grain based on at least one scarce and idle grain; and determine a target data block from the reserved data block migrated from the idle grain.
[0132] In this embodiment of the application, the determining module 202 is further configured to: calculate the number of idle dies based on the number of reserved data blocks in the idle dies; calculate the number of gaps based on the number of reserved data blocks in the scarce dies; calculate the scheduling amount of the idle dies based on the number of idle dies and the number of gaps; and move reserved data blocks out of the idle dies according to the scheduling amount.
[0133] In this embodiment of the application, the determining module 202 is further configured to: obtain the current load rate, data migration status and data block scheduling quantity of the storage medium; if the current load rate is less than or equal to a preset first load rate threshold, the data migration status is a no data migration operation status, and the data block scheduling quantity is less than or equal to a preset quantity threshold, then determine the idle reserved data blocks from the idle dies according to the scheduling quantity.
[0134] In this embodiment of the application, a monitoring module is also included. The monitoring module is further used to: obtain the third utilization rate of the reserved data blocks of the idle dies; if the third utilization rate is greater than the preset seventh threshold, calculate the difference between the third utilization rate and the seventh threshold, determine the actual rollback rate of the scheduling amount of the idle dies based on the difference, and the actual rollback rate is directly proportional to the difference; and correct the scheduling amount of the idle dies based on the actual rollback rate.
[0135] In this embodiment of the application, the monitoring module is further configured to: obtain the idle time of the reserved data block migrated from the idle die; if the idle time is greater than a preset time threshold, then migrate the reserved data block migrated from the idle die back to the idle die.
[0136] In this embodiment of the application, the replacement module 203 is further configured to: replace the data block to be replaced with the target data block if the priority of the data block to be replaced is greater than the preset eighth threshold; and temporarily store the data block to be replaced in the preset first cache area if the priority of the data block to be replaced is less than or equal to the eighth threshold.
[0137] In this embodiment of the application, the replacement module 203 is further configured to: obtain the current load rate of the storage medium; if the current load rate is less than or equal to a preset second load rate threshold, read the data block to be replaced from the first cache area; and replace the data block to be replaced with the target data block.
[0138] In this embodiment, the replacement module 203 is further configured to: identify the valid data and logical address of the data block to be replaced; read the valid data of the data block to be replaced into a pre-set second cache area, and write the valid data of the second cache area into the target data block; identify the physical address corresponding to the logical address of the data block to be replaced, and correct the physical address corresponding to the logical address to the physical address corresponding to the target data block.
[0139] According to the data block replacement device provided in the embodiments of this application, the target die corresponding to the data block to be replaced and the first utilization rate of its reserved data blocks can be identified. Based on the first utilization rate of the target die, it is determined whether the target data block needs to be determined from the reserved data blocks of other dies besides the target die. The second utilization rate of the reserved data blocks of the storage medium is obtained, and based on the second utilization rate, it is determined whether the data block to be replaced needs to be replaced according to the priority of the target data block. This realizes cross-die dynamic scheduling of reserved data blocks, improves the overall disk resource utilization, and at the same time, data block replacement according to data priority reduces the invalid consumption of reserved data blocks.
[0140] For a description of the features in the embodiment corresponding to the data block replacement device, please refer to the relevant description in the embodiment corresponding to the data block replacement method, which will not be repeated here.
[0141] Embodiments of this application also provide an electronic device, such as... Figure 4 As shown, it includes a memory 301 and a processor 302. The memory 301 stores a computer program, and the processor 302 is configured to run the computer program to perform the steps in any of the above-described data block replacement method embodiments.
[0142] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described data block replacement method embodiments at runtime.
[0143] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0144] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data block replacement method embodiments.
[0145] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data block replacement method embodiments.
[0146] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0147] The foregoing has provided a detailed description of a data block replacement method, apparatus, electronic device, storage medium, and program product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A data block replacement method, characterized in that, The method is used to replace data blocks in a storage medium, the storage medium comprising multiple dies, each die comprising multiple data blocks, and the method comprising the following steps: Identify the target grain corresponding to the data block to be replaced; The first utilization rate of the reserved data block of the target die is obtained. If the first utilization rate is greater than a preset first threshold, the target data block is determined from the reserved data blocks of other dies besides the target die. If the first utilization rate is less than or equal to the first threshold, the target data block is determined from the reserved data blocks of the target die. The second utilization rate of the reserved data block of the storage medium is obtained. If the second utilization rate is less than or equal to a preset second threshold, the target data block is used to replace the data block to be replaced. If the second utilization rate is greater than the second threshold, the target data block is used to replace the data block to be replaced according to the priority of the target data block.
2. The data block replacement method according to claim 1, characterized in that, The identification of the target grain corresponding to the data block to be replaced includes: The data block identifier that identifies the data block to be replaced; Obtain the first correspondence table between pre-set data block identifiers and grains; Query the first correspondence table to find the target grain.
3. The data block replacement method according to claim 1 or 2, characterized in that, Before identifying the target grain corresponding to the data block to be replaced, the process also includes: Obtain the second correspondence table between pre-set data blocks and data types; Query the second correspondence table to find the data type. The priority of the data block to be replaced is determined according to the data type of the data block to be replaced; The queue position of the data block to be replaced in the data queue is determined according to the priority of the data block to be replaced, and the data block to be replaced is placed into the data queue according to the queue position. The replacement order of the data blocks to be replaced is determined according to the data queue, and the data blocks to be replaced are extracted from the data queue based on the replacement order.
4. The data block replacement method according to claim 3, characterized in that, Before determining the priority of the data block to be replaced based on its data type, the method further includes: If the data type is not found in the second correspondence table, the logical block addressing attribute of the data block to be replaced is identified; Obtain the third correspondence table between the logical block addressing attributes and the data types; Query the third correspondence table to find the data type.
5. The data block replacement method according to claim 3, characterized in that, Before determining the queue position of the data block to be replaced in the data queue based on its priority, the process includes: Obtain the risk level and erasure / write stage of the data block to be replaced; The priority of the data block to be replaced is adjusted according to the risk level and the erasure / write phase.
6. The data block replacement method according to claim 5, characterized in that, The step of adjusting the priority of the data block to be replaced based on the risk level and the erasure / write stage includes: Determine the first score of the data block to be replaced based on the data type; A second score is determined for the data block to be replaced based on the risk level. The third score of the data block to be replaced is determined based on the erase / write phase; Obtain the data type, risk level, and respective weights of the erasure and rewrite stages of the data block to be replaced, and calculate a comprehensive score based on the first score, the second score, the third score, and their respective weights; The priority of the data block to be replaced is determined based on the comprehensive score.
7. The data block replacement method according to claim 1, characterized in that, Determining the target data block from the reserved data blocks of other grains besides the target grain includes: Obtain the first utilization rate and bad data block growth rate of the reserved data blocks of the other grains; The other grains are labeled based on the first utilization rate and the growth rate of the bad data blocks; The target data block is determined based on the marking results of the other grains.
8. The data block replacement method according to claim 7, characterized in that, The step of marking the other grains based on the first utilization rate and the bad data block growth rate includes: If the first utilization rate is greater than a preset third threshold and the growth rate of the bad data block is greater than a preset fourth threshold, then the other grains are marked as scarce grains. If the second utilization rate is less than or equal to a pre-set fifth threshold, and the bad data block growth rate is less than or equal to a pre-set sixth threshold, then the other grains are marked as idle grains.
9. The data block replacement method according to claim 8, characterized in that, Determining the target data block based on the marking results of the other grains includes: Identify scarce and idle grains in the marking results of the other grains; A reserved data block is migrated out from the idle die based on at least one of the scarce die and the idle die; The target data block is determined from the reserved data blocks migrated from the idle grains.
10. The data block replacement method according to claim 9, characterized in that, The step of migrating a reserved data block from an idle die based on at least one of the scarce die and the idle die includes: The number of idle units is calculated based on the number of reserved data blocks for the idle units; The number of gaps is calculated based on the number of reserved data blocks for the scarce grains; The scheduling amount of the idle grains is calculated based on the number of idle grains and the number of gaps; Reserved data blocks are migrated from the idle dies according to the specified scheduling amount.
11. The data block replacement method according to claim 10, characterized in that, Before determining the available reserved data blocks from the idle dies according to the scheduling amount, the method further includes: Obtain the current load rate, data migration status, and number of data blocks scheduled for the storage medium; If the current load rate is less than or equal to a preset first load rate threshold, the data migration status is a no-data-migration-operation status, and the number of data blocks scheduled is less than or equal to a preset number threshold, then an idle reserved data block is determined from the idle dies according to the scheduling amount.
12. The data block replacement method according to claim 10, characterized in that, After determining the available reserved data blocks from the idle dies according to the scheduling amount, the process further includes: Obtain the third utilization rate of the reserved data blocks of the idle die; If the third utilization rate is greater than the preset seventh threshold, the difference between the third utilization rate and the seventh threshold is calculated, and the actual rollback rate of the idle die scheduling amount is determined based on the difference. The actual rollback rate is directly proportional to the difference. The scheduling amount of the idle grains is adjusted based on the actual rollback rate.
13. The data block replacement method according to claim 9, characterized in that, After migrating a reserved data block from an idle die based on at least one of the scarce die and the idle die, the process further includes: Obtain the idle time of the reserved data block migrated from the idle die; If the idle time exceeds a preset time threshold, the reserved data block migrated from the idle die will be migrated back to the idle die.
14. The data block replacement method according to claim 1, characterized in that, The step of replacing the data block to be replaced with the target data block according to the priority of the data block to be replaced includes: If the priority of the data block to be replaced is greater than the preset eighth threshold, then the target data block is used to replace the data block to be replaced. If the priority of the data block to be replaced is less than or equal to the eighth threshold, the data block to be replaced is temporarily stored in a pre-set first cache area.
15. The data block replacement method according to claim 14, characterized in that, After temporarily storing the data block to be replaced in a pre-set first cache area, the process further includes: Obtain the current load rate of the storage medium; If the current load rate is less than or equal to a preset second load rate threshold, then the data block to be replaced is read from the first cache area; The target data block is used to replace the data block to be replaced.
16. The data block replacement method according to claim 1, 14, or 15, characterized in that, The step of replacing the data block to be replaced with the target data block includes: Identify the valid data and logical address of the data block to be replaced; The valid data of the data block to be replaced is read into a pre-set second cache area, and the valid data of the second cache area is written into the target data block; Identify the physical address corresponding to the logical address of the data block to be replaced, and correct the physical address corresponding to the logical address to the physical address corresponding to the target data block.
17. A data block replacement device, characterized in that, include: The identification module is used to identify the target die corresponding to the data block to be replaced; The determination module is used to obtain the first utilization rate of the reserved data block of the target die. If the first utilization rate is greater than the first threshold, the target data block is determined from the reserved data blocks of other dies besides the target die. If the first utilization rate is less than or equal to the first threshold, the target data block is determined from the reserved data block of the target die. The replacement module is used to obtain the second utilization rate of the reserved data block of the storage medium. If the second utilization rate is less than or equal to a preset second threshold, the target data block is used to replace the data block to be replaced. If the second utilization rate is greater than the second threshold, the target data block is used to replace the data block to be replaced according to the priority of the target data block.
18. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data block replacement method as described in any one of claims 1 to 16 when executing the computer program.
19. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the data block replacement method as described in any one of claims 1 to 16.
20. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the data block replacement method as described in any one of claims 1 to 16.
Citation Information
Patent Citations
Data replacement method of hierarchical storage system
CN111427969A
Solid state disk management method and device, electronic equipment and storage medium
CN118069068A