Method, device, storage medium and electronic device for dynamically allocating bad block replacement resources
By dynamically allocating bad block replacement resources, the problem of waste of free space and early end of life caused by bad block management in solid state drives is solved, and efficient bad block replacement and stable performance solid state drives are achieved.
Patent Information
- Application Number
- CN202411946724.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-27
AI Technical Summary
When the prior art manages bad blocks in solid-state drives, it is easy to lead to waste of available space and the premature end of the life of the solid-state drive.
By dynamically allocating bad block replacement resources, we determine the maximum number of bad blocks in average per plane, establish a bad block replacement table, and sort and initialize the replacement table in the super block to dynamically perform bad block replacement processing.
Improves the efficiency of bad block replacement, reduces the waste of available space, extends the life of the solid-state drive, and maintains stable performance.
Smart Images

Figure CN119376646B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of bad block replacement, and in particular to a method, device, storage medium and electronic device for dynamically allocating bad block replacement resources. Background Art
[0002] Due to the characteristics of flash memory, there will be bad blocks in solid state drives (Solid State Disk). The wafer will be packaged into flash memory particles (flash memory chips) after many processes such as testing, cutting, and packaging. During this process, bad blocks may be generated in the flash memory particles. In addition, as the solid state drive is used for a long time, some originally good flash memory blocks in the solid state drive will become bad blocks due to wear and tear during use or some unexpected conditions. This kind of bad block is called a "growing bad block".
[0003] At present, the relevant bad block management technology mainly uses a fixed number of bad block replacement tables as bad block replacements, which will not only cause a premature waste of available space, but also when a storage unit has poor quality and a large number of bad blocks, the good blocks in the bad block replacement table will be quickly consumed, and the available space will be rapidly reduced, resulting in the premature end of the life of the solid-state drive. Summary of the invention
[0004] The embodiments of the present application provide a method, device, storage medium and electronic device for dynamically allocating bad block replacement resources to solve the technical problems existing in the prior art.
[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0006] According to a first aspect of an embodiment of the present application, a method for dynamically allocating bad block replacement resources is provided, comprising:
[0007] Determine the maximum number of bad blocks per plane on average;
[0008] Perform a factory bad block check on all super blocks in the storage unit to determine the number of bad blocks in each super block;
[0009] Establishing a bad block replacement table for each plane of each storage unit, wherein the bad block replacement table includes bad blocks and good blocks to be replaced;
[0010] Sort all superblocks in descending order of the number of bad blocks in the superblock;
[0011] After the sorting is completed, the bad block replacement table of each plane is initialized based on the good blocks in the super block;
[0012] Perform cyclic checks according to the arrangement order of super blocks. When a bad block is detected in the super block, replace it based on the initialized bad block replacement table.
[0013] When a new bad block is added to the super block, a replacement process is performed based on the initialized bad block replacement table.
[0014] In some embodiments of the present application, based on the above solution, determining the average maximum number of bad blocks per plane includes:
[0015] Determine the maximum number of bad blocks that can be controlled during the life cycle of a storage unit based on the flash memory particle type;
[0016] The maximum number of bad blocks per plane is determined according to the number of planes in the storage unit and the maximum number of bad blocks that can be controlled during the life cycle.
[0017] In some embodiments of the present application, based on the above solution, the step of initializing the bad block replacement table of each plane based on the good blocks in the super block includes:
[0018] Add the good blocks in the X super blocks with the largest number of bad blocks as the good blocks to be replaced into the bad block replacement table of the plane corresponding to the good blocks, where X is an integer greater than or equal to 1;
[0019] The good blocks in a super block with the least number of bad blocks are added as replaced good blocks to the bad block replacement table of the plane corresponding to the good blocks.
[0020] In some embodiments of the present application, based on the above solution, when a bad block is detected in the super block, replacement processing is performed based on the initialized bad block replacement table, including:
[0021] Check whether there is a good block to be replaced in the bad block replacement table of the plane corresponding to the super block where the bad block exists. If yes, replace the bad block with the good block to be replaced, and add the replaced super block to the free super block;
[0022] If not, check whether the number of entries in the bad block replacement table of the current plane has reached the maximum number of bad blocks per plane on average; if not, add all good blocks in the super block with bad blocks as replaced good blocks to the bad block replacement table of the plane corresponding to each good block; and at the same time check whether the bad blocks before the super block with bad blocks have been replaced; if they have been replaced, cancel the replacement relationship;
[0023] If it has been reached, the good blocks in other planes in the storage unit are added as replaced good blocks to the bad block replacement table of the plane corresponding to each good block, and the storage unit is isolated in the super block where the bad blocks exist.
[0024] In some embodiments of the present application, based on the above solution, it also includes:
[0025] When the number of entries in the bad block replacement table of the current plane reaches the average maximum number of bad blocks per plane, recording the current plane through a bitmap;
[0026] During the super block reading and writing process of the storage unit, if a super block with the bitmap is encountered, all planes of the storage unit are directly skipped.
[0027] In some embodiments of the present application, based on the above solution, when a new bad block is added to the super block, replacement processing is performed based on the initialized bad block replacement table, including:
[0028] Check whether there is a good block to be replaced in the bad block replacement table of the plane corresponding to the newly added bad block. If yes, replace the bad block with the good block to be replaced, and add the replaced super block to the free super block;
[0029] If not, check whether the number of entries in the bad block replacement table of the plane corresponding to the newly added bad block has reached the average maximum number of bad blocks per plane; if not, perform garbage collection on the super block corresponding to the newly added bad block, and add all good blocks in the super block corresponding to the newly added bad block to the bad block replacement table of the plane corresponding to each good block;
[0030] If it has been reached, the corresponding plane of the newly added bad block is recorded through a bitmap, and the good blocks of other planes in the storage unit are added to the bad block replacement table of the corresponding planes of the good blocks as replaced good blocks, and the storage unit is isolated in the super block of the newly added bad block.
[0031] According to a second aspect of an embodiment of the present application, a device for dynamically allocating bad block replacement resources is provided, comprising:
[0032] A determination unit, used for determining a maximum number of bad blocks per plane on average;
[0033] A detection unit, used to perform a factory bad block check on all super blocks in the storage unit to determine the number of bad blocks in each super block;
[0034] An establishing unit, used for establishing a bad block replacement table for each plane of each storage unit, wherein the bad block replacement table includes bad blocks and good blocks to be replaced;
[0035] A sorting unit is used to sort all super blocks in the order of the number of bad blocks in the super block from the largest to the smallest;
[0036] An initialization unit, used to initialize a bad block replacement table of each plane based on good blocks in the super block after the sorting is completed;
[0037] A loop check unit, used for performing loop checks according to the arrangement order of super blocks;
[0038] A first replacement unit is used to perform replacement processing based on the initialized bad block replacement table when a bad block is detected in the super block;
[0039] The second replacement unit is used to perform replacement processing based on the initialized bad block replacement table when a new bad block is added to the super block.
[0040] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer executes the method according to the first aspect.
[0041] According to a fourth aspect of the embodiments of the present application, there is provided an electronic device, including: a memory and a processor;
[0042] The memory is used to store computer instructions;
[0043] The processor is used to call the computer instructions stored in the memory so that the electronic device executes the method as described in the first aspect.
[0044] The technical solution of this application has the following advantages:
[0045] 1. Efficiently replace bad blocks, improve cross-plane parallelism, and improve SSD performance;
[0046] 2. Reduce the waste of available space throughout the entire life cycle, maintain the size of reserved space, and maintain stable performance.
[0047] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0049] Figure 1 A schematic diagram of the structure of a storage unit according to an embodiment of the present application is shown;
[0050] Figure 2 A schematic diagram of the structure of a super block according to an embodiment of the present application is shown;
[0051] Figure 3 A schematic diagram of a process of dynamically allocating bad block replacement resources according to an embodiment of the present application is shown;
[0052] Figure 4 A block diagram of a device for dynamically allocating bad block replacement resources according to an embodiment of the present application is shown;
[0053] Figure 5 A block diagram of an electronic device according to an embodiment of the present application is shown;
[0054] Figure 6 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0055] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0056] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0057] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0058] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0059] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all the embodiments. Based on the embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Some embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments may be combined with each other.
[0061] In order to facilitate understanding of the technical solution provided by this embodiment, the following description is first made:
[0062] The internal storage particles of a solid state drive (SSD) are composed of storage units (Die), and a storage unit includes multiple blocks (blocks). In order to improve NAND concurrency, a storage unit has multiple planes (planes), and different planes can be read and written in parallel. Figure 1 As shown in the figure, there are two blocks, one belonging to plane0 and the other to plane1, which can be written at the same time; but if the two blocks both belong to plane0, they cannot be written at the same time. Therefore, when replacing a bad block, you can only find other good blocks on the same plane, but not on other planes.
[0063] Inside the SSD, each plane block (the corresponding block under the plane) of multiple storage units (Die) is organized into a logical super block, such as Figure 2 As shown, a super block includes multiple physical blocks from different storage units, and these physical blocks are logically regarded as a whole.
[0064] See also Figure 3 , shows a flow chart of a method for dynamically allocating bad block replacement resources according to an embodiment of the present application.
[0065] like Figure 1 As shown, a method for dynamically allocating bad block replacement resources is shown, which specifically includes steps S100 to S700.
[0066] refer to Figure 1 , step S100, determining the average maximum number of bad blocks per plane.
[0067] In some feasible embodiments, based on the above solution, determining the average maximum number of bad blocks per plane includes:
[0068] Determine the maximum number of bad blocks that can be controlled during the life cycle of a storage unit based on the flash memory particle type;
[0069] The maximum number of bad blocks per plane is determined according to the number of planes in the storage unit and the maximum number of bad blocks that can be controlled during the life cycle.
[0070] Exemplarily, the calculation formula for the average maximum number of bad blocks per plane is as follows:
[0071] .
[0072] Continue to refer Figure 1 , step S200, performing a factory bad block check on all super blocks in the storage unit to determine the number of bad blocks in each super block.
[0073] Continue to refer Figure 1 , step S300, establishing a bad block replacement table for each plane of each storage unit, wherein the bad block replacement table includes bad blocks and good blocks to be replaced.
[0074] Continue to refer Figure 1 , step S400, sort all super blocks in order from most to least number of bad blocks in the super block.
[0075] Continue to refer Figure 1 , Step S500, after the sorting is completed, initialize the bad block replacement table of each plane based on the good blocks in the super block.
[0076] In some feasible embodiments, based on the above solution, the step of initializing the bad block replacement table of each plane based on the good blocks in the super block includes:
[0077] Add the good blocks in the X super blocks with the largest number of bad blocks as the good blocks to be replaced into the bad block replacement table of the plane corresponding to the good blocks, where X is an integer greater than or equal to 1;
[0078] The good blocks in a super block with the least number of bad blocks are added as replaced good blocks to the bad block replacement table of the plane corresponding to the good blocks.
[0079] It is understandable that X depends on the flash memory particle type and the number of bad blocks. The more bad blocks a single super block has, the larger X is, but it is generally within 10.
[0080] Continue to refer Figure 1 , step S600, a cyclic check is performed according to the arrangement order of the super block. When a bad block is detected in the super block, a replacement process is performed based on the initialized bad block replacement table.
[0081] In some feasible embodiments, based on the above solution, when a bad block is detected in the super block, replacement processing is performed based on the initialized bad block replacement table, including:
[0082] Check whether there is a good block to be replaced in the bad block replacement table of the plane corresponding to the super block where the bad block exists. If yes, replace the bad block with the good block to be replaced, and add the replaced super block to the free super block;
[0083] If not, check whether the number of entries in the bad block replacement table of the current plane has reached the maximum number of bad blocks per plane on average; if not, add all good blocks in the super block with bad blocks as replaced good blocks to the bad block replacement table of the plane corresponding to each good block; and at the same time check whether the bad blocks before the super block with bad blocks have been replaced; if they have been replaced, cancel the replacement relationship;
[0084] If it has been reached, the good blocks in other planes in the storage unit are added as replaced good blocks to the bad block replacement table of the plane corresponding to each good block, and the storage unit is isolated in the super block where the bad blocks exist.
[0085] It should be noted that the super blocks added to the free super blocks can be used for normal business use.
[0086] In some feasible embodiments, based on the above solution, it also includes:
[0087] When the number of entries in the bad block replacement table of the current plane reaches the average maximum number of bad blocks per plane, recording the current plane through a bitmap;
[0088] During the super block reading and writing process of the storage unit, if a super block with the bitmap is encountered, all planes of the storage unit are directly skipped.
[0089] Continue to refer Figure 1 , step S700, when a new bad block is added to the super block, replacement processing is performed based on the initialized bad block replacement table.
[0090] In some feasible embodiments, based on the above solution, when a new bad block is added to the super block, replacement processing is performed based on the initialized bad block replacement table, including:
[0091] Check whether there is a good block to be replaced in the bad block replacement table of the plane corresponding to the newly added bad block. If yes, replace the bad block with the good block to be replaced, and add the replaced super block to the free super block;
[0092] If not, check whether the number of entries in the bad block replacement table of the plane corresponding to the newly added bad block has reached the average maximum number of bad blocks per plane; if not, perform garbage collection on the super block corresponding to the newly added bad block, and add all good blocks in the super block corresponding to the newly added bad block to the bad block replacement table of the plane corresponding to each good block;
[0093] If it has been reached, the corresponding plane of the newly added bad block is recorded through a bitmap, and the good blocks of other planes in the storage unit are added to the bad block replacement table of the corresponding planes of the good blocks as replaced good blocks, and the storage unit is isolated in the super block of the newly added bad block.
[0094] To summarize, the technical solution of the present application provides a small number of bad block replacement tables for replacement during the bad block replacement stage before leaving the factory; if the good blocks to be replaced are not enough, the good blocks in the current super block are added to the bad block replacement table, and the number of overall bad block replacement tables is dynamically increased; at the same time, when new bad blocks just appear, they are replaced in the same way or dynamically added to the bad block replacement table, so as to minimize the waste of available space; in the later stage of the life of the storage unit, when there are too many new bad blocks, the super block chooses to isolate the storage unit to avoid the continuous growth of the number of bad block replacement tables, which leads to an excessive reduction in the super blocks that can be used for normal business, affecting the performance of the SSD.
[0095] The following describes an apparatus embodiment of the present application, which can be used to execute a method for dynamically allocating bad block replacement resources in the above embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above method embodiment of the present application.
[0096] Reference Figure 4 As shown, according to an embodiment of the present application, a device 400 for dynamically allocating bad block replacement resources includes:
[0097] A determination unit 401 is used to determine the maximum number of bad blocks per plane on average;
[0098] A detection unit 402, configured to perform a factory bad block check on all super blocks in the storage unit to determine the number of bad blocks in each super block;
[0099] An establishing unit 403 is used to establish a bad block replacement table for each plane of each storage unit, wherein the bad block replacement table includes bad blocks and good blocks to be replaced;
[0100] The sorting unit 404 is used to sort all the super blocks in the order of the number of bad blocks in the super blocks from large to small;
[0101] Initialization unit 405, used to initialize the bad block replacement table of each plane based on the good blocks in the super block after the sorting is completed;
[0102] A loop checking unit 406, configured to perform a loop checking according to the arrangement order of the super blocks;
[0103] A first replacement unit 407, configured to perform replacement processing based on an initialized bad block replacement table when a bad block is detected in the super block;
[0104] The second replacement unit 408 is used to perform replacement processing based on the initialized bad block replacement table when a new bad block is added to the super block.
[0105] like Figure 5 As shown, an embodiment of the present application also provides an electronic device 500, including a memory 510, a processor 520, and a computer program 511 stored in the memory 510 and executable on the processor, and when the processor 520 executes the computer program 511, the steps of the above-mentioned method for dynamically allocating bad block replacement resources are implemented.
[0106] Since the electronic device introduced in this embodiment is a device used to implement a dynamic allocation of bad block replacement resources in the embodiment of the present application, based on the method introduced in the embodiment of the present application, the technical personnel in this field can understand the specific implementation mode of the electronic device of this embodiment and its various variations. Therefore, how the electronic device implements the method in the embodiment of the present application is not introduced in detail here. As long as the equipment used by the technical personnel in this field to implement the method in the embodiment of the present application is within the scope of protection of this application.
[0107] During the specific implementation process, when the computer program 511 is executed by a processor, any implementation method in the embodiments corresponding to the first aspect can be implemented.
[0108] Figure 6 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0109] It should be noted that Figure 6 The computer system 600 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0110] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603, such as executing the method described in the above embodiment. In the RAM 603, various programs and data required for system operation are also stored. The CPU 601, the ROM 602 and the RAM 603 are connected to each other through the bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0111] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 608 as needed.
[0112] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 609, and / or installed from a removable medium 611. When the computer program is executed by a central processing unit (CPU) 601, various functions defined in the system of the present application are executed.
[0113] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0114] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0115] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0116] As another aspect, the present application further provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes a method for dynamically allocating bad block replacement resources described in the above embodiment.
[0117] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements a method for dynamically allocating bad block replacement resources described in the above embodiment.
[0118] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0119] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation method of the present application.
[0120] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary techniques in the art that are not disclosed in the present application. It should be understood that the present application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for dynamically allocating bad block replacement resources, characterized in that: include: Determine the maximum number of bad blocks per plane on average; Perform a factory bad block check on all super blocks in the storage unit to determine the number of bad blocks in each super block; Establishing a bad block replacement table for each plane of each storage unit, wherein the bad block replacement table includes bad blocks and good blocks to be replaced; Sort all superblocks in descending order of the number of bad blocks in the superblock; After the sorting is completed, the bad block replacement table of each plane is initialized based on the good blocks in the super block; Perform cyclic checks according to the arrangement order of super blocks. When a bad block is detected in the super block, replace it based on the initialized bad block replacement table. When a new bad block is added to the super block, it is replaced based on the initialized bad block replacement table; When a bad block is detected in the super block, replacement processing is performed based on the initialized bad block replacement table, including: Check whether there is a good block to be replaced in the bad block replacement table of the plane corresponding to the super block where the bad block exists. If yes, replace the bad block with the good block to be replaced, and add the replaced super block to the free super block; If not, check whether the number of entries in the bad block replacement table of the current plane has reached the maximum number of bad blocks per plane on average; if not, add all good blocks in the super block with bad blocks as replaced good blocks to the bad block replacement table of the plane corresponding to each good block; and at the same time check whether the bad blocks before the super block with bad blocks have been replaced; if they have been replaced, cancel the replacement relationship; If it has been reached, the good blocks of other planes in the storage unit are added as replaced good blocks to the bad block replacement table of the plane corresponding to each good block, and the storage unit is isolated in the super block where the bad blocks exist; When a new bad block is added to the super block, a replacement process is performed based on the initialized bad block replacement table, including: Check whether there is a good block to be replaced in the bad block replacement table of the plane corresponding to the newly added bad block. If yes, replace the bad block with the good block to be replaced, and add the replaced super block to the free super block; If not, check whether the number of entries in the bad block replacement table of the plane corresponding to the newly added bad block has reached the average maximum number of bad blocks per plane; if not, perform garbage collection on the super block corresponding to the newly added bad block, and add all good blocks in the super block corresponding to the newly added bad block to the bad block replacement table of the plane corresponding to each good block; If it has been reached, the corresponding plane of the newly added bad block is recorded through a bitmap, and the good blocks of other planes in the storage unit are added to the bad block replacement table of the corresponding planes of the good blocks as replaced good blocks, and the storage unit is isolated in the super block of the newly added bad block.
2. The method according to claim 1, characterized in that The determining of the average maximum number of bad blocks per plane comprises: Determine the maximum number of bad blocks that can be controlled during the life cycle of a storage unit based on the flash memory particle type; The maximum number of bad blocks per plane is determined according to the number of planes in the storage unit and the maximum number of bad blocks that can be controlled during the life cycle.
3. The method according to claim 1, characterized in that The step of initializing the bad block replacement table of each plane based on the good blocks in the super block includes: Add the good blocks in the X super blocks with the largest number of bad blocks as the good blocks to be replaced into the bad block replacement table of the plane corresponding to the good blocks, where X is an integer greater than or equal to 1; The good blocks in a super block with the least number of bad blocks are added as replaced good blocks to the bad block replacement table of the plane corresponding to the good blocks.
4. The method according to claim 1, characterized in that: Also includes: When the number of entries in the bad block replacement table of the current plane reaches the average maximum number of bad blocks per plane, recording the current plane through a bitmap; During the super block reading and writing process of the storage unit, if a super block with the bitmap is encountered, all planes of the storage unit are directly skipped.
5. A device for dynamically allocating bad block replacement resources, applied to the method according to any one of claims 1 to 4, characterized in that: include: A determination unit, used for determining a maximum number of bad blocks per plane on average; A detection unit, used to perform a factory bad block check on all super blocks in the storage unit to determine the number of bad blocks in each super block; An establishing unit, used for establishing a bad block replacement table for each plane of each storage unit, wherein the bad block replacement table includes bad blocks and good blocks to be replaced; A sorting unit is used to sort all super blocks in the order of the number of bad blocks in the super block from the largest to the smallest; An initialization unit, used to initialize a bad block replacement table of each plane based on good blocks in the super block after the sorting is completed; A loop check unit, used for performing loop checks according to the arrangement order of super blocks; A first replacement unit is used to perform replacement processing based on the initialized bad block replacement table when a bad block is detected in the super block; The second replacement unit is used to perform replacement processing based on the initialized bad block replacement table when a new bad block is added to the super block.
6. A computer-readable storage medium, characterized in that: The storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 4.
7. An electronic device, characterized in that: include: Memory and processor; The memory is used to store computer instructions; The processor is used to call the computer instructions stored in the memory so that the electronic device executes the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Bad block replacement method and device, equipment and storage medium
CN117234426A