Method, device and medium for processing bad blocks in storage medium
Patent Information
- Application Number
- CN202310987841.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-07
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2043-08-07
AI Technical Summary
[0005]本申请提供一种存储介质中坏块的处理方法、装置、设备和介质,至少用于解决现有存储介质中超级块存在坏块,容易降低系统性能的问题
[0016] The bad block processing method, apparatus, device, and medium provided in this application embodiment can minimize the difference in the number of bad blocks between superblocks by mapping and replacing good blocks and bad blocks between superblocks, thereby reducing the fluctuation of system read and write performance. At the same time, it does not require the configuration of a separate bad block mapping area, does not occupy redundant space, and can effectively improve system read and write performance and service life.
Smart Images

Figure CN117149504B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage technology, and in particular to a method, apparatus, device, and medium for processing bad blocks in a storage medium. Background Technology
[0002] Solid State Disk (SSD) storage media may develop bad blocks during the manufacturing and use process. Bad blocks can affect the performance and lifespan of the storage system, and also reduce the available physical storage space. However, the generation of bad blocks is usually difficult to avoid. Therefore, it is necessary to handle these bad blocks properly to minimize their impact.
[0003] In existing technologies, the common approach is to directly divide a specific area into storage spaces and replace bad blocks with good blocks in that specific area through mapping.
[0004] However, the existing method requires dividing specific areas, which occupies redundant storage space and reduces the lifespan of the storage space. Summary of the Invention
[0005] This application provides a method, apparatus, device, and medium for processing bad blocks in a storage medium, which at least addresses the problem that bad blocks in superblocks of existing storage media can easily reduce system performance.
[0006] In a first aspect, embodiments of this application provide a method for processing bad blocks in a storage medium, comprising:
[0007] Obtain all superblocks in the storage medium, and determine the number and type of bad blocks in each superblock. The superblock is a stripe block composed of physical blocks at the same physical location in all logical units of the storage medium. The bad blocks include two types: original bad blocks when the storage medium leaves the factory and newly added bad blocks after the storage medium leaves the factory.
[0008] Based on the type of bad blocks contained in the superblock, at least a first processing strategy is selected from preset processing strategies. The preset processing strategies include a first processing strategy and a second processing strategy. The first processing strategy is to select good blocks from each superblock and replace bad blocks in other superblocks except for that superblock, until the number of bad blocks in each superblock meets the target condition. The second processing strategy is to ignore the bad blocks in the superblock and jump to the next good block in the superblock. The replacement refers to establishing a mapping relationship between the selected good blocks and bad blocks. The mapping relationship is used to transfer the data operation performed on the bad block to the good block when performing data operations on the bad block.
[0009] Bad blocks in each superblock are processed according to at least the first processing strategy.
[0010] Secondly, embodiments of this application provide an apparatus for processing bad blocks in a storage medium, comprising:
[0011] The superblock acquisition module is used to acquire all superblocks in the storage medium and determine the number and type of bad blocks in each superblock. The superblock is a stripe block composed of physical blocks at the same physical location in all logical units of the storage medium. The bad blocks include two types: original bad blocks when the storage medium leaves the factory and newly added bad blocks after the storage medium leaves the factory.
[0012] The strategy selection module is used to select at least a first processing strategy from preset processing strategies based on the type of bad blocks contained in the superblock. The preset processing strategies include a first processing strategy and a second processing strategy. The first processing strategy is to select good blocks from each superblock and replace bad blocks in other superblocks until the number of bad blocks in each superblock meets the target condition. The second processing strategy is to ignore bad blocks in the superblock and jump to the next good block in the superblock. The replacement refers to establishing a mapping relationship between the selected good blocks and bad blocks. The mapping relationship is used to transfer the data operation performed on the bad block to the good block when performing data operations on the bad block.
[0013] The bad block handling module is used to process bad blocks in each superblock according to at least a first processing strategy.
[0014] Thirdly, embodiments of this application provide an electronic device, including: a processor, and a memory communicatively connected to the processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method described above.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described above.
[0016] The bad block processing method, apparatus, device, and medium provided in this application embodiment can minimize the difference in the number of bad blocks between superblocks by mapping and replacing good blocks and bad blocks between superblocks, thereby reducing the fluctuation of system read and write performance. At the same time, it does not require the configuration of a separate bad block mapping area, does not occupy redundant space, and can effectively improve system read and write performance and service life. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application;
[0018] Figure 1 A schematic diagram of bad blocks and good blocks in a storage medium provided in an embodiment of this application;
[0019] Figure 2 This is a schematic diagram of the current bad block replacement process;
[0020] Figure 3 A flowchart illustrating a method for handling bad blocks in a storage medium provided in an embodiment of this application;
[0021] Figure 4 This is a schematic diagram of bad block processing provided in an embodiment of this application;
[0022] Figure 5 This is a schematic diagram of bad block processing provided in another embodiment of this application;
[0023] Figure 6 This is a schematic diagram of bad block mapping in a superblock provided in an embodiment of this application;
[0024] Figure 7 This is a schematic diagram of superblock mapping replacement provided in an embodiment of this application;
[0025] Figure 8 This is a schematic diagram of superblock mapping replacement provided in another embodiment of this application;
[0026] Figure 9 A schematic diagram of the structure of a device for processing bad blocks in a storage medium provided in an embodiment of this application;
[0027] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0028] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0030] First, let me explain the terms used in this application:
[0031] Solid State Drive (SSD): refers to a hard drive made using an array of solid-state electronic storage processing units.
[0032] NAND flash memory refers to the storage medium of solid-state drives (SSDs).
[0033] Original bad blocks: Bad blocks generated during the production process of NAND Flash due to process and other reasons.
[0034] New bad blocks: Bad blocks generated during the use of NAND Flash.
[0035] Superblock: A strip block composed of physical blocks at the same physical location of all logical unit numbers (LUNs), which can be used as a unit for concurrent operations.
[0036] The performance and lifespan of NAND Flash-based storage systems are affected by bad blocks. Bad blocks are divided into original bad blocks and newly added bad blocks. The generation of bad blocks reduces the available physical storage space of the system, resulting in reduced over-provisioning space (OP) and increased write amplification (WA), thus shortening the system's lifespan. Simultaneously, the distribution of bad blocks may be uneven; the number of bad blocks may vary significantly across different superblocks, leading to fluctuations in system read and write performance. Currently, the main approach to addressing the adverse effects of bad blocks is to maintain the integrity of the superblock and reduce the numerical differences between superblocks through bad block replacement. However, bad block replacement requires the separate allocation of a bad block mapping region, which consumes OP, and the mapping strategy suffers from the "weakest link" effect, meaning the available blocks in the entire SSD are related to the LUN with the worst quality.
[0037] To address the aforementioned issues, this application provides a method, apparatus, device, and medium for processing bad blocks in a storage medium. By mapping and replacing good and bad blocks between superblocks, the difference in the number of bad blocks between each superblock is minimized, thereby reducing fluctuations in system read and write performance. Furthermore, it eliminates the need for a separate bad block mapping area, thus avoiding redundant space usage and effectively improving system read and write performance and lifespan.
[0038] The technical solution of this application will now be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0039] Figure 1 This is a schematic diagram of bad and good blocks in the storage medium provided in the embodiments of this application, as shown below. Figure 1As shown, the entire storage space can include M LUNs, each LUN can include several planes, and each plane contains multiple physical blocks, including good blocks and bad blocks. Since the number and location distribution of bad blocks on each LUN can vary significantly, performance may fluctuate considerably when performing superblock erase / write reads on user block areas. For example, Figure 2 This is a schematic diagram of the current bad block replacement process, as shown below. Figure 2 As shown, the entire storage space is divided into a user block area and a bad block mapping area. When a physical block in the user block area is a bad block, a good block in the bad block mapping area is used to replace the bad block through mapping.
[0040] Figure 3 This is a flowchart illustrating a method for handling bad blocks in a storage medium according to an embodiment of this application. This method can be specifically applied to processing storage media (e.g., solid-state drives). Figure 3 As shown, the method may specifically include the following steps:
[0041] Step S301: Obtain all superblocks in the storage medium and determine the number and type of bad blocks in each superblock. A superblock is a stripe block composed of physical blocks at the same physical location in all logical units of the storage medium. Bad blocks include two types: original bad blocks when the storage medium leaves the factory and newly added bad blocks after the storage medium leaves the factory.
[0042] In this embodiment, refer to Figure 1 Each LUN contains two Planes, for example, LUN0 contains Plane0 and Plane1. The storage medium may contain multiple superblocks. For example, SuperBlock0 is composed of the physical blocks in the first row of each LUN, including physical blocks BLK0 and BLK1 in LUN0, physical blocks BLK0 and BLK1 in LUN1, ..., physical blocks BLK0 and BLK1 in LUN(M-1).
[0043] Since superblocks are also composed of physical blocks, which can be good blocks, newly added bad blocks, or original bad blocks, and because the distribution of bad blocks is uncertain and random, different superblocks contain different numbers of bad blocks. For example, superblock SuperBlock0 may not contain any bad blocks, while superblock SuperBlock1 may contain two bad blocks. When erasing, writing, and reading these superblocks, the difference in the number of bad blocks between superblocks can cause significant performance fluctuations if the difference in the number of bad blocks is large. Therefore, it is necessary to process these bad blocks.
[0044] In this embodiment, original bad blocks can be understood as bad blocks that appear in the storage medium during the manufacturing process, and newly added bad blocks can be understood as bad blocks that appear in the storage medium during use. As the usage time increases, the number of newly added bad blocks may continue to rise, that is, the number of bad blocks may increase, which may cause the number of bad blocks in the superblock to also change. Therefore, the bad block processing method of the storage medium provided in this application embodiment can be a real-time dynamic processing method. For example, when the increase in the number of bad blocks is detected, the method can be executed cyclically based on the change in the number of bad blocks.
[0045] Bad blocks cannot be used for data operations such as reading and writing. This makes it easy to distinguish which blocks in the storage medium are bad and which are good. Original bad blocks can usually be identified at the factory, while newly added bad blocks can be identified based on the original bad blocks. For example, other bad blocks besides the original bad blocks can be regarded as newly added bad blocks.
[0046] Step S302: Based on the type of bad blocks contained in the superblock, at least the first processing strategy is selected from the preset processing strategies. The preset processing strategies include the first processing strategy and the second processing strategy. The first processing strategy is to select good blocks from each superblock and replace bad blocks in other superblocks except for that superblock, until the number of bad blocks in each superblock meets the target condition. The second processing strategy is to ignore the bad blocks in the superblock and jump to the next good block in the superblock.
[0047] In this embodiment, the replacement in the first processing strategy refers to selecting a good block from the superblock, then selecting a bad block from other superblocks besides the superblock, and then establishing a mapping relationship between the good block and the bad block. This mapping relationship is used to transfer the data operation performed on the bad block to the good block when performing data operations on the bad block.
[0048] For example, taking SuperBlock0 and SuperBlock1 as examples, a good block H1 is selected from SuperBlock0, and a bad block H2 is selected from SuperBlock1. Then, a mapping relationship H1-H2 is established. When performing data operations (such as read, write, erase) on the bad block H2 in SuperBlock1, the data operation is switched to the good block H1 in SuperBlock0.
[0049] Step S303: Process the bad blocks in each superblock according to at least the first processing strategy.
[0050] In this embodiment, the number of bad blocks contained in each superblock of the storage medium is not uniform. For example, some superblocks may not contain bad blocks, while others may contain a large number of bad blocks. Superblocks that do not contain bad blocks can be prioritized for selecting good blocks, while superblocks with a large number of bad blocks can be prioritized for bad block replacement. For example, SuperBlock0 represents a superblock that does not contain bad blocks, and SuperBlockM represents the superblock containing the most bad blocks. In this case, good blocks in SuperBlock0 can be selected first, and bad blocks in SuperBlockM can be replaced first. This reduces the difference in the number of bad blocks between SuperBlock0 and SuperBlockM, thereby reducing the performance fluctuation of the system during read, write, and erase operations.
[0051] When a superblock contains bad blocks, it may include both newly added bad blocks and original bad blocks, or it may only include newly added bad blocks or only original bad blocks. Depending on the type of bad blocks it contains, a corresponding processing strategy can be selected to handle that type of bad block.
[0052] For example, Figure 4 This is a schematic diagram of bad block processing provided in an embodiment of this application, such as... Figure 4 As shown, taking superblocks SuperBlock0 and SuperBlock1 as examples, when there are bad blocks in SuperBlock1, good blocks in SuperBlock0 can replace the bad blocks in SuperBlock1 through mapping (i.e., the first processing strategy). Furthermore, Figure 5 This is a schematic diagram of bad block processing provided in another embodiment of this application, as shown below. Figure 5 As shown, continuing with the example of SuperBlock1, when there is a bad block in SuperBlock1, if data operations such as reading, writing, and erasing are performed, the bad block can be directly ignored through the skip strategy (i.e., the second processing strategy), and the process can jump to the next good block.
[0053] This application embodiment obtains the type of each bad block in the superblock and selects at least a first processing strategy to process these bad blocks according to the type of each bad block. This reduces the difference in the number of bad blocks between the various superblocks. As a result, when performing data operations such as reading, writing, and erasing on these superblocks, the fluctuation in the number of bad blocks between the various superblocks is small, which can reduce system performance fluctuations. At the same time, there is no need to additionally divide the bad block mapping area, which will not occupy redundant space and ensure the service life of the storage medium.
[0054] In some embodiments, step S302 can be implemented by the following steps: if the bad blocks in the super block include original bad blocks or newly added bad blocks, then a first processing strategy is selected from the preset processing strategies; if the bad blocks in the super block include original bad blocks and newly added bad blocks, then a first processing strategy and a second processing strategy are selected from the preset processing strategies, or a first processing strategy is selected from the preset processing strategies.
[0055] In this embodiment, under certain special scenarios, some superblocks may contain only original bad blocks or newly added bad blocks. Regardless of the type of bad blocks they contain, the first processing strategy is used first to process these bad blocks. When a superblock contains both original bad blocks and newly added bad blocks, the second processing strategy is selected as needed to process one type of bad block.
[0056] For example, Table 1 is a strategy selection illustration table provided in the embodiments of this application, as shown in Table 1 below:
[0057] Original bad blocks Second processing strategy First processing strategy First processing strategy New bad blocks First processing strategy Second processing strategy First processing strategy
[0058] Table 1
[0059] When the superblock includes both original bad blocks and newly added bad blocks, a corresponding strategy can be adopted to specifically process a certain type of bad block. In some embodiments, step S303 can be implemented through the following steps: determining whether the superblock includes both original bad blocks and newly added bad blocks; if the superblock includes both original bad blocks and newly added bad blocks, then processing the newly added bad blocks according to the first processing strategy; and processing the original bad blocks according to the second processing strategy.
[0060] In this embodiment, referring to Table 1 above, when the superblock contains both original bad blocks and newly added bad blocks, scheme A can be adopted, that is, the original bad blocks in the superblock are processed by the second processing strategy, while the newly added bad blocks in the superblock are processed by the first processing strategy.
[0061] The second processing strategy is to directly ignore the original bad block when there is one in the superblock, and then jump to the next physical block in the superblock. If the original bad block is frequently ignored and skipped when performing read, write and erase operations on the superblock, it may cause system performance fluctuations. Therefore, solution A is mainly used when there are few original bad blocks or the distribution is relatively uniform. This can reduce the system performance fluctuations caused by frequently ignoring and skipping original bad blocks.
[0062] Furthermore, when it is determined that the superblock includes both original bad blocks and newly added bad blocks, the above step S303 can also be implemented through the following steps: determining whether the superblock includes both original bad blocks and newly added bad blocks; if the superblock includes both original bad blocks and newly added bad blocks, then processing the original bad blocks according to the first processing strategy; and processing the newly added bad blocks according to the second processing strategy.
[0063] In this embodiment, referring to Table 1 above, when the superblock contains both original bad blocks and newly added bad blocks, scheme B can also be adopted, that is, the original bad blocks are processed by the first processing strategy, and the newly added bad blocks are processed by the second processing strategy.
[0064] In this context, the number of original bad blocks is usually fixed after the storage medium leaves the factory. However, in the initial period after manufacturing, the number of newly added bad blocks is typically small (it usually increases with the duration of use). Therefore, for storage media that have just been used, handling these original bad blocks using the first processing strategy can prevent system performance fluctuations and provide greater stability. The second processing strategy, used to handle newly added bad blocks, saves processing time (as it doesn't require building a mapping relationship like the first strategy). This means that while ensuring system performance is not affected, it also improves the efficiency of bad block handling. Furthermore, if the number of original bad blocks is large or unevenly distributed within the superblock, even if the number of original bad blocks is small, using the first processing strategy can still prevent system performance fluctuations.
[0065] Furthermore, in some other embodiments, when it is determined that the super block includes both original bad blocks and newly added bad blocks, the above step S303 can also be implemented by the following steps: determining whether the super block includes both original bad blocks and newly added bad blocks; if the super block includes both original bad blocks and newly added bad blocks, then processing the original bad blocks and newly added bad blocks according to the first processing strategy.
[0066] In this embodiment, referring to Table 1 above, scheme C is adopted, that is, the original bad blocks and newly added bad blocks are processed using the first processing strategy. Scheme C can avoid system performance fluctuations regardless of the number of original bad blocks and newly added bad blocks in the superblock, and has stronger adaptability. Generally, scheme C can be applied in scenarios where there are a large number of both original bad blocks and newly added bad blocks, such as when there are a large number of original bad blocks before the storage medium leaves the factory, and the storage medium has been used for a considerable period of time, and the number of newly added bad blocks is also large.
[0067] This application embodiment allows for the configuration of various different schemes (e.g., scheme A, scheme B, and scheme C), enabling the selection of different schemes to process bad blocks based on actual conditions, thereby improving the flexibility and effectiveness of bad block processing.
[0068] In some embodiments, when processing bad blocks in a superblock using the first processing strategy, the process can be implemented through the following steps: sorting all superblocks according to the number of bad blocks in each superblock to obtain sorted superblocks; selecting M superblocks from the sorted superblocks; obtaining all good blocks in the M superblocks and replacing the bad blocks in all superblocks except the M superblocks to obtain the remaining superblocks after replacement; and processing the bad blocks in the remaining superblocks after replacement according to the first processing strategy.
[0069] In this embodiment, for example, superblocks can be sorted in descending order of the number of bad blocks, with superblocks having more bad blocks being sorted earlier and superblocks having fewer bad blocks being sorted later.
[0070] One approach is to replace all physical blocks in some superblocks with bad blocks. These superblocks (i.e., the M selected superblocks) will no longer require data operations (such as read, write, erase, etc.). This reduces the total number of superblocks and provides more good blocks to other superblocks, allowing them to make full use of the good blocks in the storage space. It also reduces the processing time of the first processing strategy for bad blocks and improves processing efficiency.
[0071] For example, based on sorting, the superblocks with a large number of bad blocks can be selected as the M superblocks. Then, all the good blocks in these M superblocks can be used to replace the bad blocks in other superblocks, so that all physical blocks in these M superblocks become bad blocks.
[0072] In other embodiments, the value of M can be determined by: obtaining the number of bad blocks contained in each face of each logic unit, determining the target face with the fewest number of bad blocks among all faces, wherein each logic unit includes at least one face, and each face includes at least one physical block; and taking the number of bad blocks contained in the target face as the value of M.
[0073] In this embodiment, the above can continue to be referred to. Figure 1 Each logic unit (LUN) can include several planes. For example, logic unit LUN0 includes plane0 and plane1. For instance, if plane0 has 10 bad blocks and plane1 has 15 bad blocks, then the bad block value of plane0 (i.e., the value 10) with the smallest bad block is taken as the value of M.
[0074] In the embodiments of the present application, by finding the plane with the least bad blocks, the number M of superblocks in which all physical blocks can be bad blocks through mapping replacement is determined, and then the good blocks in these M superblocks are replaced to other superblocks, which can fully utilize all good blocks in the storage medium, reduce the number of superblocks to be processed, and improve processing efficiency.
[0075] Further, based on the above embodiments, in some embodiments, the above method may further comprise the following steps: acquiring a volatility, wherein the volatility is used to characterize the average number of bad blocks contained in all superblocks; dividing each superblock into a first list or a second list according to the volatility and the number of bad blocks in each superblock; determining a first superblock with the most bad blocks from the first list; determining a second superblock with the least bad blocks from the second list; selecting good blocks from the second superblock and replacing bad blocks in the first superblock until a target condition is satisfied.
[0076] In this embodiment, the value of volatility can be an integer, which can be calculated by the following formula (if it is not an integer, round down):
[0077]
[0078] In the above formula, ave is the volatility, N is the total number of superblocks, M is the number of the superblocks selected above, y i represents the number of bad blocks on the i-th superblock, and i is the sequence number of other superblocks after M superblocks are taken out from all superblocks.
[0079] In this embodiment, the remaining superblocks mentioned in the above embodiments can be divided into two different lists (List0 represents the first list, and List1 represents the second list). Among the remaining superblocks, superblocks with yi≥ave are placed in List0, and superblocks with yi<ave are placed in List1. If either List0 or List1 is empty, it can be determined that the target condition is satisfied, and processing through the first processing strategy is stopped. Otherwise, the bad blocks of the superblock i (i.e., the first superblock) with the largest number of bad blocks in List0 are mapped and replaced to the superblock j (i.e., the second superblock) with the smallest number of bad blocks in List1. Wherein, if the corresponding planes of superblock i and superblock j are both bad blocks, switch to the next plane, and stop mapping replacement when max(yi)-min(yi)≤1.
[0080] For example, Figure 6 is a schematic diagram of bad block mapping in a superblock provided by an embodiment of the present application, as Figure 6As shown, the first original bad block in superblock i can be mapped and replaced with a good block in superblock j. When both superblock i and superblock j have bad blocks in plane1, the process is skipped and the process is switched to the next plane to continue mapping and replacement until max(yi)-min(yi)<=1, at which point the mapping and replacement stops.
[0081] In some other embodiments, after selecting good blocks from the second superblock and replacing bad blocks in the first superblock, the superblocks in the first list and the second list are updated; it is determined whether there are superblocks in the updated first list or the second list; if there are no superblocks in the updated first list or the second list, it is determined that the target condition is met.
[0082] In this embodiment, List0 and List1 need to be updated each time a successful mapping replacement is performed. This is because the number of bad blocks in each superblock in List0 and List1 will change, and the number of superblocks in List0 and List1 will also change. Each update can also determine whether the target condition is met after the current mapping replacement.
[0083] Furthermore, in some other embodiments, if a superblock exists in the updated first list or second list, a minimum value is obtained, which is the number of superblocks in the list containing the fewest superblocks; a superblock interval value is calculated based on the minimum value and the total number of all superblocks contained in the first and second lists; based on the superblock interval value, a first superblock is determined from the list containing the fewest superblocks and a second superblock is determined from the list containing the most superblocks, wherein the sum of the identifier value of the first superblock and the superblock interval value is less than the identifier value of the second superblock; good blocks are selected from the second superblock and bad blocks in the first superblock are replaced.
[0084] In this embodiment, NVB0 represents the number of superblocks in the first list, and NVB1 represents the number of superblocks in the second list. The minimum value of these two superblocks can be obtained using a minimum function, i.e., NVBmin = min(NVB0, NVB1). If NVBmin is 0, it means that there are no superblocks in the updated first or second list, thus satisfying the target condition. In this case, the system performance will tend to stabilize when these superblocks are subjected to read, write, and erase operations. If NVBmin is not 0, a mapping rule is needed to make the interval between superblocks with performance fluctuations Interval = NT / NVBmin, where NT is the number of remaining superblocks. The mapping rule can be specifically as follows:
[0085] When NVB0 is less than NVB1, if the difference between the maximum interval Interval0_max and the minimum interval Interval0_min of the superblock ID in the first list List0 is less than a preset threshold α, or the absolute value of the difference between the superblock interval Interval and the maximum interval Interval0_max of the superblock ID is less than or equal to the preset threshold α, then no processing is performed, and it is determined that the above target condition is met. Otherwise, the bad blocks of the superblocks in the first list List0 are mapped and replaced to the superblocks in the second list List1 whose superblock ID is a multiple of [Interval B (B is a positive integer greater than or equal to 1) - 1] (if the ID of the superblock in the first list List0 is itself [Interval B - 1], then no mapping and replacement is performed).
[0086] To facilitate differentiation of superblocks, each superblock is identified by an ID, and each superblock's ID is unique. A preset threshold α is used to control the interval of system performance fluctuations. For example, the preset threshold α can be set to 20. Under other conditions, the larger the preset threshold α is, the smaller the system performance fluctuations.
[0087] For example, Figure 7 This is a schematic diagram of superblock mapping replacement provided in an embodiment of this application, such as... Figure 7 As shown, taking a list of superblocks in List0 (NVB0) as 3, a list of superblocks in List1 (NVB1) as 573, and a superblock interval (Interval = NT / NVBmin = 576 / 3 = 192) as an example, bad blocks in superblock 10 of List0 can be mapped and replaced to good blocks in superblock 383 of List1, and bad blocks in superblock 11 of List0 can be mapped and replaced to good blocks in superblock 575 of List1. During the mapping and replacement process, List0 and List1 cannot be updated.
[0088] When NVB0 is greater than or equal to NVB1, if the difference between the maximum interval Interval0_max and the minimum interval Interval0_min of the superblock ID in the first list List0 is less than a preset threshold α, or the absolute value of the difference between the superblock interval Interval and the maximum interval Interval0_max of the superblock ID is less than or equal to the preset threshold α, then no processing is performed, and the above target condition is satisfied. Otherwise, the bad blocks of the SuperBlock with SuperBlock_id of [B times Interval - 1] in the first list List1 are mapped to the SuperBlocks in the second list List1 (if the ID of the SuperBlock in the second list List1 is itself [B times Interval - 1], then the blocks in the first list List0 are not mapped to that SuperBlock).
[0089] For example, Figure 8 This is a schematic diagram of superblock mapping replacement provided in another embodiment of this application, as shown below. Figure 8 As shown, taking a list of superblocks in List0 (NVB0) as 573, a list of superblocks in List1 (NVB1) as 3, and a superblock interval (Interval = NT / NVBmin = 576 / 3 = 192) as an example, bad blocks in superblock 383 of List0 can be mapped and replaced to good blocks in superblock 10 of List1, and bad blocks in superblock 575 of List0 can be mapped and replaced to good blocks in superblock 11 of List1. During the mapping and replacement process, List0 and List1 cannot be updated.
[0090] This application embodiment sets a superblock interval, and based on the superblock interval, replaces good blocks in the list containing the most superblocks with bad blocks in the list containing the fewest superblocks. This can reduce the fluctuation in the number of bad blocks between adjacent superblocks, and further reduce system performance fluctuations and improve system performance stability when performing data operations such as read, write and erase.
[0091] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0092] Figure 9 This is a schematic diagram of the structure of the device for processing bad blocks in a storage medium provided in the embodiments of this application, as shown below. Figure 9As shown, the processing device 900 includes a superblock acquisition module 910, a strategy selection module 920, and a bad block processing module 930. The superblock acquisition module 910 acquires all superblocks in the storage medium and determines the number and type of bad blocks in each superblock. A superblock is a stripe block composed of physical blocks at the same physical location in all logical units of the storage medium. Bad blocks include two types: original factory bad blocks at the time of manufacture and newly added bad blocks after the storage medium leaves the factory. The strategy selection module 920 is used to select at least a first processing strategy from preset processing strategies based on the type of bad blocks contained in the superblock. The preset processing strategies include a first processing strategy and a second processing strategy. The first processing strategy is to select good blocks from each superblock and replace bad blocks in other superblocks until the number of bad blocks in each superblock meets the target condition. The second processing strategy is to ignore bad blocks in the superblock and jump to the next good block in the superblock. Here, replacement refers to establishing a mapping relationship between the selected good blocks and bad blocks. The mapping relationship is used to transfer the data operation performed on the bad blocks to the good blocks when performing data operations on the bad blocks. The bad block processing module 930 is used to process the bad blocks in each superblock according to at least the first processing strategy.
[0093] Optionally, the strategy selection module can be used to: if the bad blocks in the superblock include original bad blocks and / or newly added bad blocks, then select the first processing strategy from the preset processing strategies; if the bad blocks in the superblock include original bad blocks and newly added bad blocks, then select the first processing strategy and the second processing strategy from the preset processing strategies.
[0094] Optionally, the bad block processing module can be used to: process original bad blocks and / or newly added bad blocks according to a first processing strategy; or, process newly added bad blocks according to the first processing strategy and process original bad blocks according to a second processing strategy; or, process newly added bad blocks according to the second processing strategy and process original bad blocks according to the first processing strategy.
[0095] Optionally, it also includes a bad block processing module, which is used to sort all superblocks according to the number of bad blocks in each superblock to obtain sorted superblocks; select M superblocks from the sorted superblocks; obtain all good blocks in the M superblocks, and replace the bad blocks in all superblocks except the M superblocks to obtain the remaining superblocks after replacement; and process the bad blocks in the remaining superblocks after replacement according to the first processing strategy.
[0096] Optionally, the bad block processing module can be used to: obtain the number of bad blocks contained in each face of each logical unit, determine the target face with the fewest bad blocks among all faces, each logical unit includes at least one face, and each face includes at least one physical block; and use the number of bad blocks contained in the target face as the value of M.
[0097] Optionally, the bad block processing module can be used to: obtain volatility, which is used to characterize the average number of bad blocks contained in all superblocks; divide each superblock into a first list or a second list according to the volatility and the number of bad blocks in each superblock; determine the first superblock with the most bad blocks from the first list; determine the second superblock with the fewest bad blocks from the second list; select good blocks from the second superblock and replace the bad blocks in the first superblock, until the target condition is met.
[0098] Optionally, the bad block handling module can be specifically used to: after selecting good blocks from the second superblock and replacing bad blocks in the first superblock, update the superblocks in the first list and the second list; determine whether there are superblocks in the updated first list or the second list; if there are no superblocks in the updated first list or the second list, then determine that the target condition is met.
[0099] Optionally, a replacement module is also included, which is used to obtain the minimum value if a superblock exists in the updated first list or second list, the minimum value being the number of superblocks in the list containing the fewest superblocks; calculate the superblock interval value based on the minimum value and the total number of all superblocks contained in the first and second lists; determine the first superblock from the list containing the fewest superblocks and the second superblock from the list containing the most superblocks based on the superblock interval value, wherein the sum of the identifier value of the first superblock and the superblock interval value is less than the identifier value of the second superblock; select good blocks from the second superblock and replace bad blocks in the first superblock.
[0100] The apparatus provided in this application embodiment can be used to execute the methods in the above embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0101] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, the superblock acquisition module can be a separate processing element, or it can be integrated into a processing unit of the above device. Alternatively, it can be stored as program code in the memory of the above device, and its functions can be called and executed by a processing element of the device. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.
[0102] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 10 As shown, the electronic device 1000 includes at least one processor 1001, a memory 1002, a bus 1003, and a communication interface 1004. The processor 1001, communication interface 1004, and memory 1002 communicate with each other via the bus 1003. The communication interface is used to communicate with other devices. The processor executes computer instructions stored in the memory, specifically performing the relevant steps in the methods described in the above embodiments.
[0103] The processor may be a central processing unit, an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The electronic device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs. The memory is used to store instructions for computer execution. The memory may include high-speed RAM and may also include non-volatile memory, such as at least one disk storage device.
[0104] This embodiment also provides a computer-readable storage medium storing computer instructions. When at least one processor of an electronic device executes the computer instructions, the electronic device performs the bad block processing method in the storage medium provided in the various embodiments described above.
[0105] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates an "or" relationship between the preceding and following related objects; in formulas, the character " / " indicates a "division" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0106] It is understood that the various numerical designations used in the embodiments of this application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application. In the embodiments of this application, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for processing bad blocks in a storage medium, characterized in that, include: Obtain all superblocks in the storage medium, and determine the number and type of bad blocks in each superblock. The superblock is a stripe block composed of physical blocks at the same physical location in all logical units of the storage medium. The bad blocks include two types: original bad blocks when the storage medium leaves the factory and newly added bad blocks after the storage medium leaves the factory. Based on the type of bad blocks contained in the superblock, at least a first processing strategy is selected from preset processing strategies. The preset processing strategies include a first processing strategy and a second processing strategy. The first processing strategy is to select good blocks from each superblock and replace bad blocks in other superblocks except for that superblock, until the number of bad blocks in each superblock meets the target condition. The second processing strategy is to ignore the bad blocks in the superblock and jump to the next good block in the superblock. The replacement refers to establishing a mapping relationship between the selected good blocks and bad blocks. The mapping relationship is used to transfer the data operation performed on the bad block to the good block when performing data operations on the bad block. According to at least the first processing strategy, bad blocks in each superblock are processed; The step of selecting at least a first processing strategy from preset processing strategies based on the type of bad blocks contained in the superblock includes: if the bad blocks in the superblock include original bad blocks and / or newly added bad blocks, then selecting the first processing strategy from preset processing strategies; the step of processing the bad blocks in each superblock according to at least the first processing strategy includes: processing the original bad blocks and / or newly added bad blocks according to the first processing strategy; or The step of selecting at least a first processing strategy from preset processing strategies based on the type of bad blocks contained in the superblock includes: if the bad blocks in the superblock include original bad blocks and newly added bad blocks, then selecting a first processing strategy and a second processing strategy from preset processing strategies; the step of processing bad blocks in each superblock according to at least the first processing strategy includes: processing the newly added bad blocks according to the first processing strategy and processing the original bad blocks according to the second processing strategy; or, processing the newly added bad blocks according to the second processing strategy and processing the original bad blocks according to the first processing strategy.
2. The method according to claim 1, characterized in that, According to at least the first processing strategy, bad blocks in each superblock are processed, including: Sort all superblocks according to the number of bad blocks in each superblock to obtain the sorted superblocks; Select M superblocks from the sorted superblocks; Get all the good blocks in the M superblocks, and replace the bad blocks in all superblocks except the M superblocks to get the remaining superblocks after replacement; The bad blocks in the remaining superblock after replacement are processed according to at least the first processing strategy.
3. The method according to claim 2, characterized in that, The step of selecting M superblocks from the sorted superblocks includes: Obtain the number of bad blocks contained in each face of each logical unit, determine the target face with the fewest bad blocks among all faces, each logical unit includes at least one face, and each face includes at least one physical block; The number of bad blocks contained in the target surface is taken as the value of M.
4. The method according to claim 1, characterized in that, According to at least the first processing strategy, bad blocks in each superblock are processed, including: Obtain volatility, which is used to characterize the average number of bad blocks contained in all superblocks; Based on the volatility and the number of bad blocks in each superblock, each superblock is assigned to either a first list or a second list; The first superblock with the most bad blocks is determined from the first list; The second superblock with the smallest number of bad blocks is determined from the second list; Select good blocks from the second superblock and replace bad blocks in the first superblock until the target condition is met.
5. The method according to claim 4, characterized in that, The step of selecting good blocks from the second superblock and replacing bad blocks in the first superblock until the target condition is met includes: After selecting good blocks from the second superblock and replacing bad blocks in the first superblock, the superblocks in the first and second lists are updated. Determine if a superblock exists in the updated first or second list; If no superblock exists in the updated first or second list, then the target condition is satisfied.
6. The method according to claim 5, characterized in that, The method further includes: If a superblock exists in the updated first or second list, then the minimum value is obtained, which is the number of superblocks in the list containing the fewest superblocks; Calculate the superblock interval value based on the minimum value, the total number of all superblocks contained in the first list and the second list; Based on the superblock interval value, a first superblock is determined from the list containing the fewest superblocks and a second superblock is determined from the list containing the most superblocks, wherein the sum of the identifier value of the first superblock and the superblock interval value is less than the identifier value of the second superblock; Select good blocks from the second superblock and replace the bad blocks in the first superblock.
7. An apparatus for processing bad blocks in a storage medium, characterized in that, include: The superblock acquisition module is used to acquire all superblocks in the storage medium and determine the number and type of bad blocks in each superblock. The superblock is a stripe block composed of physical blocks at the same physical location in all logical units of the storage medium. The bad blocks include two types: original bad blocks when the storage medium leaves the factory and newly added bad blocks after the storage medium leaves the factory. The strategy selection module is used to select at least a first processing strategy from preset processing strategies based on the type of bad blocks contained in the superblock. The preset processing strategies include a first processing strategy and a second processing strategy. The first processing strategy involves selecting good blocks from each superblock and replacing bad blocks in other superblocks until the number of bad blocks in each superblock meets a target condition. The second processing strategy involves ignoring bad blocks in a given superblock and jumping to the next good block in that superblock. The replacement refers to establishing a mapping relationship between the selected good blocks and bad blocks. This mapping relationship is used to redirect data operations performed on bad blocks to good blocks when data operations are performed on bad blocks. The bad block handling module is used to process bad blocks in each superblock according to at least a first processing strategy; The strategy selection module is used to select a first processing strategy from preset processing strategies if the bad blocks in the superblock include original bad blocks and / or newly added bad blocks; the bad block processing module is used to process the original bad blocks and / or newly added bad blocks according to the first processing strategy. or The strategy selection module is used to select a first processing strategy and a second processing strategy from preset processing strategies if the bad blocks in the superblock include original bad blocks and newly added bad blocks. The bad block processing module is configured to process the newly added bad blocks according to the first processing strategy and process the original bad blocks according to the second processing strategy; or, process the newly added bad blocks according to the second processing strategy and process the original bad blocks according to the first processing strategy.
8. An electronic device, comprising: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Memory block management
CN102341792A
Management method of memory block, write operation method of memory, and memory
CN113220508A