A physical block management method and related device
By dividing the 3D NAND Flash storage device into data cache and interaction areas, and prioritizing the use of good blocks in reliable mode as management blocks, the problem of low storage space utilization is solved, achieving efficient use of storage space and improved system robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN CHIPSBANK TECH
- Filing Date
- 2025-11-12
- Publication Date
- 2026-08-04
AI Technical Summary
Because 3D NAND Flash storage devices have large individual physical block capacity and a small number of effective blocks, the existing technology of handling all bad blocks leads to a significant reduction in the actual usable space of the storage device, affecting the space utilization of USB flash drives, eMMC, and SSDs.
By controlling the flash memory storage space to enter reliable mode, writing random numbers and comparing the number of error bits, recording the address of good blocks, dividing it into data cache and interaction areas, prioritizing the use of good blocks in reliable mode as management blocks, and dynamically supplementing good blocks in normal mode.
It improves the space utilization of storage devices, reduces resource waste, enhances system robustness and data processing efficiency, and ensures the available storage capacity for users.
Smart Images

Figure CN121478199B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a method and related equipment for managing physical blocks. Background Technology
[0002] With the widespread application of big data and the rapid development of storage technology, the manufacturing process of NAND Flash is becoming more and more advanced. Among the new process products, the use of 3D NAND Flash is the most mature. High-capacity USB flash drives, embedded multimedia controllers (eMMC, Embedded Multi Media Card), and solid-state drives (SSD) all use 3D NAND Flash as storage media. This type of Flash has a large capacity of a single physical block and a small number of effective physical blocks, which puts higher demands on the actual usable space of storage devices using this type of NAND Flash.
[0003] Due to the complexity of the manufacturing process and the differences in the number of P / E cycles between different modes, 3D NAND Flash may contain physical blocks that are all good in SLC (Single-Level Cell, i.e., one memory cell stores 1 bit of information) mode (i.e., Reliable Mode) but all bad after exiting SLC mode (i.e., Normal Mode). Currently, these types of physical blocks are treated as bad blocks. Since the Flash Translation Layer (FTL) algorithm of storage devices requires a certain number of management blocks to implement, and the capacity of a single physical block in 3D NAND Flash is large with a small number of effective blocks, using this treatment method will significantly reduce the actual usable space of the storage device, greatly impacting the space utilization of USB flash drives, eMMC, and SSDs. Summary of the Invention
[0004] This application provides a method and related equipment for managing physical blocks, which can increase the space utilization of storage devices.
[0005] The first aspect of this application provides a method for managing physical blocks, including:
[0006] The flash memory of the control storage device is put into a reliable mode, and a first random number is written to all physical blocks within the flash memory.
[0007] Read the first stored data in all the physical blocks, compare it with the first random number written, obtain the first error bit count of each physical block, and record the physical block address of the physical block with the first error bit count less than the first preset threshold in the first tag space;
[0008] Control the flash memory storage space to exit the reliable mode and enter the normal mode, so as to write the second random number into the physical block recorded in the first tag space;
[0009] Read the second stored data of all physical blocks in the first tag space, compare it with the second random number to obtain the second error bit number of each physical block, and record the physical block address of the physical block with the second error bit number less than the second preset threshold in the second tag space, and record the physical block address of the remaining physical blocks in the first tag space that have not been recorded in the second tag space in the third tag space.
[0010] The flash memory storage space is divided into a data cache area and a data interaction area. The physical blocks recorded in the third tag space are used as the management blocks of the data cache area, and the physical blocks recorded in the second tag space are used as the management blocks of the data interaction area.
[0011] A second aspect of this application provides a physical block management system, comprising:
[0012] A control unit is used to control the flash memory space of the storage device to enter a reliable mode and write a first random number on all physical blocks within the flash memory space;
[0013] The reading unit is used to read the first stored data in all the physical blocks, compare it with the first random number written, obtain the first error bit count of each physical block, and record the physical block address of the physical block with the first error bit count less than the first preset threshold into the first tag space;
[0014] The control unit is also used to control the flash memory storage space to exit the reliable mode and enter the normal mode, so as to write the second random number into the physical block recorded in the first tag space;
[0015] The reading unit is further configured to read the second storage data of all physical blocks in the first tag space, compare it with the second random number to obtain the second error bit number of each physical block, and record the physical block address of the physical block with the second error bit number less than the second preset threshold in the second tag space, and record the physical block address of the remaining physical blocks in the first tag space that have not been recorded in the second tag space in the third tag space.
[0016] The partitioning unit is used to divide the flash memory storage space into a data cache area and a data interaction area, and to use the physical blocks recorded in the third tag space as the management blocks of the data cache area and the physical blocks recorded in the second tag space as the management blocks of the data interaction area.
[0017] The physical block management system provided in the second aspect of this application is used to execute the physical block management method described in the first aspect.
[0018] A third aspect of this application provides a physical block management device, comprising:
[0019] Central processing unit, memory, input / output interfaces, wired or wireless network interfaces, and power supply;
[0020] The memory is either a short-term storage memory or a persistent storage memory;
[0021] The central processing unit is configured to communicate with the memory and execute instruction operations in the memory to perform the physical block management method described in the first aspect.
[0022] A fourth aspect of this application provides a computer-readable storage medium including instructions that, when executed on a computer, cause the computer to perform the physical block management method described in the first aspect.
[0023] A fifth aspect of this application provides a computer program product including instructions that, when executed on a computer, cause the computer to perform the physical block management method described in the first aspect.
[0024] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: The physical block management method disclosed in the embodiments of this application enables the physical blocks within the flash memory storage space to be fully utilized by the storage device, increasing the actual usable space of the storage device and improving economic efficiency. Simultaneously, it can also fully allocate physical blocks to the data cache area and data interaction area as management blocks, further improving space utilization. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0026] Figure 1 This is a flowchart illustrating a physical block management method disclosed in an embodiment of this application;
[0027] Figure 2 This is a flowchart illustrating another method for managing physical blocks disclosed in an embodiment of this application;
[0028] Figure 3 This is a flowchart illustrating another method for managing physical blocks disclosed in an embodiment of this application;
[0029] Figure 4 This is a flowchart illustrating another method for managing physical blocks disclosed in an embodiment of this application;
[0030] Figure 5 This is a flowchart illustrating another method for managing physical blocks disclosed in an embodiment of this application;
[0031] Figure 6 This is a schematic diagram of the structure of a physical block management system disclosed in an embodiment of this application;
[0032] Figure 7 This is a schematic diagram of the structure of a physical block management device disclosed in an embodiment of this application. Detailed Implementation
[0033] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] It should be noted that the use of terms such as "first" and "second" in this application is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed in this application.
[0035] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0036] To address the issue of low space utilization in storage devices to some extent, this application discloses a method for managing physical blocks, which can be found in [reference needed]. Figure 1 , Figure 1 This is a flowchart illustrating a physical block management method disclosed in an embodiment of this application. It includes steps 101-105.
[0037] 101. Control the flash memory of the storage device to enter reliable mode and write the first random number on all physical blocks in the flash memory.
[0038] Flash memory is the NAND Flash storage medium in storage devices. Each storage block cell of a NAND Flash chip is described as a physical block. To allocate physical blocks as quickly as possible, the flash memory is first controlled to enter Reliable Mode (i.e., SLC mode), all physical blocks in all flash memory are scanned, and all physical blocks are filled with random numbers (i.e., the first random number mentioned above).
[0039] 102. Read the first stored data in all physical blocks, compare it with the first random number written, obtain the first error bit count of each physical block, and record the physical block address of the physical block with the first error bit count less than the first preset threshold in the first tag space.
[0040] Then, the first storage data stored in all physical blocks at this time is read, and the first storage data is compared with the first random number to count the first error bit count of each physical block. Then, the physical block address of the physical block with the first error bit count less than the first preset threshold is recorded in the first tag space.
[0041] In one specific embodiment, the stored data of all physical blocks is read out (since the stored data of the physical blocks will change after the first random number is written), compared with the written random number, and the number of error bits for each physical block is counted. The addresses of physical blocks with an error bit count less than threshold A (i.e., the first preset threshold, which can be set according to the situation, such as the reliability requirements and error tolerance of the NAND Flash) are recorded in Table A (i.e., the first tag space mentioned above). At this time, it can be understood that the physical block addresses recorded in Table A are the good block addresses of the physical blocks in reliable mode.
[0042] In some embodiments, when counting the number of erroneous bits, a bit-by-bit comparison can be performed on each physical block, the details of which will not be elaborated here.
[0043] 103. Control the flash memory storage space to exit reliable mode and enter normal mode, so as to write the second random number into the physical block recorded in the first tag space.
[0044] Then, the flash memory is controlled to exit reliable mode and enter normal mode, thereby writing the second random number into the physical block recorded in the first tag space.
[0045] In one specific embodiment, exiting SLC mode leads to entering normal mode, and then a random number (i.e., the second random number) is written to all physical blocks recorded in the first tag space. It is understood that the method of writing the random number in steps 101 and 103 can be found in [reference needed]. Figure 4 Steps 401-403 are detailed here but will not be elaborated upon.
[0046] 104. Read the second storage data of all physical blocks in the first tag space, compare it with the second random number to obtain the second error bit number of each physical block, and record the physical block address of the physical block with the second error bit number less than the second preset threshold in the second tag space, and record the physical block address of the remaining physical blocks in the first tag space that have not been recorded in the second tag space in the third tag space.
[0047] Then, the stored data of all physical blocks in the first tag space (i.e., the second stored data mentioned above) is read, and this second stored data is compared with the second random number to count the second error bits of each physical block in the first tag space. Then, the physical block addresses of physical blocks whose second error bits are less than the second preset threshold are recorded in the second tag space. At the same time, the physical block addresses of the remaining physical blocks in the first tag space that have not been recorded in the second tag space can also be recorded in the third tag space.
[0048] In one specific embodiment, the stored data of all physical blocks in the first tag space is read out (since the stored data of the physical blocks will change after the second random number is written), compared with the written random number, and the number of error bits for each physical block is counted. Physical block addresses with an error bit count less than threshold B (i.e., the second preset threshold, which can be set as needed, for example, based on the error rate characteristics under Normal Mode) are recorded in Table B (i.e., the second tag space mentioned above). Physical block addresses with an error bit count greater than threshold B are recorded in Table C (i.e., the third tag space mentioned above). At this point, it can be understood that the physical block addresses recorded in Table B are the good block addresses of physical blocks in normal mode (including reliable mode). The physical block addresses recorded in Table C are the bad block addresses of physical blocks in normal mode and the good block addresses of physical blocks in reliable mode.
[0049] In some embodiments, when counting the number of erroneous bits, a bit-by-bit comparison can also be performed on each physical block, the details of which will not be elaborated here.
[0050] 105. Divide the flash storage space into a data cache area and a data interaction area, and use the physical blocks recorded in the third tag space as the management blocks of the data cache area, and use the physical blocks recorded in the second tag space as the management blocks of the data interaction area.
[0051] Furthermore, the flash memory storage space can be divided into a data cache area and a data interaction area. The physical blocks recorded in the third tag space serve as the management blocks for the data cache area, and the physical blocks recorded in the second tag space serve as the management blocks for the data interaction area. The data cache area is used for temporary storage of written data, while the data interaction area is used for performing data exchange and read / write operations.
[0052] In one specific embodiment, the Flash Translation Layer (FTL) algorithm is used to divide the flash memory storage space into a data cache area and a data interaction area, thereby managing the physical location of data storage. Furthermore, relevant physical blocks can be set as management blocks for the corresponding areas. The management blocks for the data cache area only use good blocks in the Reliable Mode of the NAND Flash, while the management blocks for the data interaction area use physical blocks that are good blocks in both the Reliable Mode and Normal Mode of the NAND Flash.
[0053] In some embodiments, the management blocks for the data cache region only need to be good blocks detected in reliable mode. The management blocks for the data interaction region need to be good blocks detected in both reliable mode and normal mode.
[0054] Other feasible technical solutions may suffer from insufficient allocation of management blocks in the data cache area; please refer to [reference needed]. Figure 2 or Figure 3 The illustrated embodiment.
[0055] The physical block management method disclosed in this embodiment enables the storage device to fully utilize the physical blocks within the flash memory storage space, increasing the actual usable space of the storage device and improving economic efficiency. Simultaneously, it can also allocate physical blocks to the data cache area and data interaction area as management blocks, further improving space utilization.
[0056] After completing the partitioning of the flash memory storage space, management blocks for different regions need to be allocated. (See [link to relevant documentation]). Figure 2 and Figure 3 ,in, Figure 2 This is a flowchart illustrating another physical block management method disclosed in an embodiment of this application. It includes steps 201-203.
[0057] 105. Divide the flash storage space into a data cache area and a data interaction area.
[0058] In this embodiment, step 105 is the same as described above. Figure 1 Step 105 is similar, and will not be elaborated here.
[0059] 201. If a physical block address is recorded in the third tag space, the physical block corresponding to the recorded physical block address in the third tag space shall be allocated to the data cache area as the management block of the data cache area.
[0060] Based on step 105, check whether a physical block address is recorded in the third label space. If a physical block address is recorded in the third label space, allocate the physical block corresponding to the recorded physical block address in the third label space to the data cache area and use it as the management block of the data cache area.
[0061] In some embodiments, the number of management blocks in the data cache area is generally set. Therefore, if the number of physical blocks recorded in the third label space is greater than the number of management blocks in the data cache area, after allocating the physical blocks recorded in the third label space, the remaining unallocated physical blocks can continue to be allocated as management blocks in the data cache area. No specific restrictions are imposed here.
[0062] Furthermore, if the number of physical blocks recorded in the third tag space is less than the number of managed blocks in the data cache area, then step 202 can be executed.
[0063] 202. If the number of physical blocks recorded in the third tag space does not meet the preset number of cache management blocks in the data cache area, select some physical blocks from the physical block addresses in the second tag space and allocate them to the data cache area as management blocks of the data cache area.
[0064] During the allocation of management blocks in the data cache area, if the number of physical blocks recorded in the third tag space does not reach the preset number of cache management blocks in the data cache area (which can be set according to actual needs, i.e., the allocation number is determined according to the actual capacity requirements of the data interaction area or the data cache area, and no specific restrictions are imposed here), then a corresponding number of physical blocks can be selected from some physical block addresses in the second tag space and allocated to the data cache area as management blocks of the data cache area.
[0065] In one specific embodiment, if the number of physical blocks in TableC does not meet the requirements of the data cache area—that is, after all physical blocks in TableC are allocated, there is still a management block gap in the data cache area—then a portion of physical blocks are extracted from TableB to fill the data cache area, thereby using some physical blocks in TableB as management blocks for the data cache area. It can be understood that the number of physical blocks extracted from TableB at this time can be the difference between the preset number of cache management blocks and the number of physical blocks in TableC.
[0066] 203. If no physical block address is recorded in the third tag space, select a portion of physical blocks from the physical block addresses in the second tag space and allocate them to the data cache area as management blocks for the data cache area.
[0067] Unlike step 203, if no physical block address is recorded in the third tag space at this time, it indicates that there are no physical blocks that are bad in normal mode. In this case, a portion of physical blocks are directly selected from the physical block addresses in the second tag space and allocated to the data cache area as management blocks for the data cache area.
[0068] In one specific embodiment, if TableC does not record any physical block addresses, then some physical blocks in TableB are allocated to the data cache area as management blocks. It is understood that the number of physical blocks allocated from TableB in this case should be related to the preset number of cache management blocks.
[0069] In some embodiments, the physical blocks allocated to the data interaction area come from the remaining portion of TableB that has not been allocated to the data cache area, and the number of blocks allocated is determined based on the actual capacity requirements of the data interaction area.
[0070] Based on the above description, when allocating management blocks according to the FTL algorithm corresponding to the storage device, non-data interaction management blocks are preferentially allocated to the physical blocks of the aforementioned records (good blocks in Reliable Mode and bad blocks in Normal Mode). That is, if TableC is not empty, physical blocks in TableC are preferentially allocated to the data cache area to ensure that the data cache area uses physical blocks that perform better in Reliable Mode.
[0071] This embodiment discloses a physical block management method that, through multi-level tag space management and a differentiated allocation strategy, improves storage space utilization while achieving efficient use of storage resources and enhanced system reliability. Specifically: 1. By establishing a third tag space (Table C) to specifically record physical blocks that are bad blocks in normal mode but good blocks in reliable mode, these "conditionally good blocks" usable in specific modes are included in the resource pool, effectively revitalizing storage space that might otherwise be abandoned and reducing resource waste. 2. Physical blocks in the third tag space are prioritized for allocation as management blocks in the data cache area. Since these physical blocks have been verified to be stable in modes with higher reliability requirements, using them for critical data cache management tasks significantly reduces the risk of system anomalies due to management block failures and enhances the overall system robustness. 3. An intelligent allocation process of "Table C priority → Table B supplementation" is constructed. First, the special physical blocks in Table C are fully utilized; when the number is insufficient, standard "good blocks" are selected from the second tag space (Table B) to supplement. This hierarchical strategy ensures the efficiency and rationality of management block allocation. 4. A dynamic replenishment mechanism ensures that the number of management blocks in the data cache area always meets the preset requirements, thereby guaranteeing the performance and data processing efficiency of the caching system. Simultaneously, the allocation of the data interaction area is handled independently, ensuring that the available storage capacity for users remains unaffected.
[0072] and Figure 2 Similarly, after allocating management blocks for the data cache area, it is necessary to allocate management blocks for the data interaction area. (See also...) Figure 3 , Figure 3 This is a flowchart illustrating another physical block management method disclosed in an embodiment of this application. It includes step 301.
[0073] 301. If there is a physical block in the second tag space that is allocated to the data cache area and serves as the management block of the data cache area, select the unallocated physical block recorded in the second tag space as the management block of the data interaction area.
[0074] After allocating management blocks for the data cache area, the allocation of management blocks for the data interaction area needs to be performed. If there are already allocated management blocks for the data cache area in the second label space, then the unallocated physical blocks recorded in the second label space can be used as management blocks for the data interaction area. It is understandable that the number of physical blocks selected within the second label space is related to the preset number of cache management blocks for the data cache area.
[0075] In one specific embodiment, after allocating a portion of the physical blocks in TableB to the data cache area as management blocks, it is necessary to extract a portion of the remaining physical blocks in TableB to the data interaction area as management blocks. This completes the allocation operation of management blocks between the data interaction area and the data cache area.
[0076] In some embodiments, if no physical blocks in the second tag space are allocated to the data cache area, the physical blocks in the second tag space can be allocated as management blocks for the data interaction area according to the normal management block allocation process. The number of management blocks in the data interaction area can be determined based on actual capacity requirements.
[0077] This embodiment discloses a physical block management method that: 1. Prioritizes the allocation of management blocks to the data cache area, ensuring resource supply for critical cache components and guaranteeing core read / write performance and efficiency. Subsequently, management blocks are allocated to the data interaction area from the remaining physical blocks in the second tag space, achieving clear division and isolation of system resources across different functional modules, avoiding resource contention, and ensuring the stability of the user's operating space. 2. Fully utilizes the physical blocks in the second tag space, allocating them granularly according to their purpose. A portion is used for high-priority cache management, while the remainder is allocated to the data interaction area, ensuring that all "good block" resources are effectively utilized, reducing idle and wasted storage space. 3. The number of management blocks in the data interaction area can be dynamically determined based on actual capacity requirements, enabling the storage system to flexibly adapt to different application scenarios and user needs, possessing good configurability and scalability. 4. When no physical blocks are allocated to the cache area from the second tag space, the system automatically reverts to the standard allocation process. This design reflects the system's backward compatibility and fault tolerance, ensuring that the allocation of operations proceeds normally under various initial conditions, and maintaining the simplicity and robustness of the overall architecture.
[0078] Distinguishing between good and bad physical blocks can be achieved using a random number generation function; see reference [link to relevant documentation]. Figure 4 , Figure 4 This is a flowchart illustrating another physical block management method disclosed in an embodiment of this application. It includes steps 401-403.
[0079] 401. Obtain the physical block address of any physical block.
[0080] It should be noted that the operation of writing the first random number to any physical block in this embodiment is similar to the operation of writing the second random number in the embodiment of this application, and will not be repeated here.
[0081] First, for any given physical block, obtain the physical block address of that physical block as a seed reference.
[0082] 402. Place the physical block address of any physical block into the random number generation function for calculation to obtain the first random number.
[0083] Then, based on the seed reference of the physical block address, random numbers are generated by an algorithm (such as a random number generation function).
[0084] In one specific embodiment, the physical block address is input into a random number generation function, and then an OR operation and a AND operation are performed to generate a random number (i.e., the first random number mentioned above). It can be understood that in normal mode, this would be described as the second random number.
[0085] In some embodiments, taking the generation of 1DW random numbers as an example, the physical block address of physical block 1 is 0x00000001. The random number 0x5AC3E769 of 1DW can be obtained by performing an OR operation between the physical block address and 0xFFFFFFFF, and then performing an AND operation between the physical block address and 0x5AC3E769.
[0086] 403. Write the first random number into the corresponding physical block.
[0087] Then, the generated first random number is written into the corresponding physical block.
[0088] In some embodiments, this random number is written into physical block 1. Then, the step of comparing the first stored data with the first random number in step 102 can be performed. When the data (first stored data) is read out again, it becomes 0x4AC3E769. Comparing the generated random number with the read data, it is found that there is a 1-bit error.
[0089] In other embodiments, the algorithm for generating random numbers may be quite complex in actual operation, and the number of random numbers is consistent with the actual capacity of a single physical block. By comparison, the number of error bits for each physical block can be obtained. When the number of error bits exceeds a set threshold, the physical block is considered to be a bad block.
[0090] This embodiment discloses a physical block management method that, by comparing generated random numbers bit-by-bit with the actual read data, can quickly and accurately count the number of error bits in each physical block. Once the number of errors exceeds a preset threshold, the physical block can be accurately identified as a bad block, improving the automation and reliability of storage medium quality testing. Furthermore, this method does not rely on specific hardware characteristics, but is based solely on the physical block address and a general random number generation algorithm, making it applicable to various storage devices. Moreover, using the physical block address as the random number seed saves storage space and testing time.
[0091] In combination with the above Figures 1 to 4 For the management method of the physical blocks shown, please refer to [link / reference]. Figure 5 , Figure 5 This is a flowchart illustrating another physical block management method disclosed in an embodiment of this application.
[0092] Depend on Figure 5 The flowchart shown illustrates the overall process of an embodiment of this application. Specifically,
[0093] Step 1: Enter Reliable Mode, scan all physical blocks, and record the addresses of good blocks obtained from the scan into Table A.
[0094] Step 2: Enter Normal Mode, scan the physical blocks in Table A, and record the addresses of the good blocks obtained from the scan to Table B.
[0095] Step 3: Record the remaining physical block addresses in TableA into TableC.
[0096] Step 4: Check if TableC is empty. If TableC is not empty, proceed to Step 5. If TableC is empty, proceed to Step 7.
[0097] Step 5: Allocate the physical blocks in TableC to the data cache area.
[0098] Step 6: Determine if the data buffer has been allocated. If the allocation is complete, proceed to Step 8; if not, proceed to Step 7.
[0099] Step 7: Allocate physical blocks in TableB to the data cache area, then proceed to Step 8.
[0100] Step 8: Assign physical blocks in TableB to the data interaction area.
[0101] The physical block management method disclosed in this embodiment utilizes an intelligent and adaptive physical block classification and partitioning management mechanism to significantly improve the performance, data reliability, and lifespan of the storage system while taking into account the overall capacity of the Nand Flash.
[0102] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0103] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a physical block management system disclosed in an embodiment of this application.
[0104] Control unit 601 is used to control the flash memory space of the storage device to enter reliable mode and write a first random number on all physical blocks in the flash memory space;
[0105] The reading unit 602 is used to read the first stored data in all physical blocks, compare it with the first random number written, obtain the first error bit count of each physical block, and record the physical block address of the physical block with the first error bit count less than the first preset threshold into the first tag space;
[0106] The control unit 601 is also used to control the flash memory storage space to exit the reliable mode and enter the normal mode so as to write the second random number into the physical block recorded in the first tag space;
[0107] The reading unit 602 is also used to read the second storage data of all physical blocks in the first tag space, compare it with the second random number, obtain the second error bit number of each physical block, and record the physical block address of the physical block with the second error bit number less than the second preset threshold in the second tag space, and record the physical block address of the remaining physical blocks in the first tag space that have not been recorded in the second tag space in the third tag space.
[0108] The partitioning unit 603 is used to divide the flash memory storage space into a data cache area and a data interaction area, and to use the physical blocks recorded in the third tag space as the management blocks of the data cache area and the physical blocks recorded in the second tag space as the management blocks of the data interaction area.
[0109] Optionally, the system further includes: an allocation unit 604;
[0110] The allocation unit 604 is used to allocate the physical block corresponding to the recorded physical block address in the third tag space to the data cache area when the physical block address is recorded in the third tag space, so as to serve as the management block of the data cache area.
[0111] Optionally, the system further includes: a selection unit 605;
[0112] The selection unit 605 is used to select a portion of physical blocks from the physical block addresses in the second tag space and allocate them to the data cache area as management blocks of the data cache area when the number of physical blocks recorded in the third tag space does not meet the preset number of cache management blocks in the data cache area; wherein, the number of physical blocks selected in the second tag space is related to the preset number of cache management blocks and the number of physical blocks recorded in the third tag space.
[0113] Optionally,
[0114] The selection unit 605 is further configured to select a portion of physical blocks from the physical block addresses in the second label space when no physical block address is recorded in the third label space, and allocate them to the data cache area as management blocks of the data cache area; wherein the number of physical blocks selected in the second label space is related to the number of preset cache management blocks in the data cache area.
[0115] Optionally, the system includes:
[0116] The selection unit 605 is further configured to select an unallocated physical block recorded in the second label space as a management block of the data interaction area when there is a physical block in the second label space that is allocated to the data cache area and serves as a management block of the data cache area; wherein the number of unallocated physical blocks recorded in the second label space is related to the number of preset interaction management blocks of the data interaction area.
[0117] Optionally, the system further includes: an acquisition unit 606 and a writing unit 607;
[0118] The acquisition unit 606 is used to acquire the physical block address of any physical block;
[0119] The acquisition unit 606 is also used to place the physical block address of any physical block into a random number generation function for calculation to obtain a first random number;
[0120] The write unit 607 is used to write the first random number to the corresponding physical block.
[0121] Optionally, the first preset threshold is set by the reliability requirements and error tolerance of the flash memory storage space; the second preset threshold is set by the error rate characteristics of the normal mode.
[0122] Please refer to the following: Figure 7 A schematic diagram of a physical block management device disclosed in this application includes:
[0123] Central processing unit 701, memory 705, input / output interface 704, wired or wireless network interface 703, and power supply 702;
[0124] Memory 705 is either a short-term storage memory or a persistent storage memory;
[0125] The central processing unit 701 is configured to communicate with the memory 705 and execute instructions stored in the memory 705 to perform the aforementioned operations. Figures 1 to 5 A method for managing physical blocks in any of the illustrated embodiments.
[0126] This application also provides a chip system, which includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the aforementioned... Figures 1 to 5 A method for managing physical blocks in any of the illustrated embodiments.
[0127] This application also provides a computer-readable storage medium, which includes instructions that, when executed on a computer, cause the computer to perform the aforementioned actions. Figures 1 to 5 A method for managing physical blocks in any of the illustrated embodiments.
[0128] This application also provides a computer program product containing instructions, which, when run on a computer, causes the computer to perform the aforementioned... Figures 1 to 5 A method for managing physical blocks in any of the illustrated embodiments.
[0129] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0130] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0131] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0132] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0133] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for managing physical blocks, characterized in that, The method includes: The flash memory of the control storage device is put into a reliable mode, and a first random number is written to all physical blocks within the flash memory. Read the first stored data in all the physical blocks, compare it with the first random number written, obtain the first error bit count of each physical block, and record the physical block address of the physical block with the first error bit count less than the first preset threshold in the first tag space; Control the flash memory storage space to exit the reliable mode and enter the normal mode, so as to write the second random number into the physical block recorded in the first tag space; Read the second stored data of all physical blocks in the first tag space, compare it with the second random number to obtain the second error bit number of each physical block, and record the physical block address of the physical block with the second error bit number less than the second preset threshold in the second tag space, and record the physical block address of the remaining physical blocks in the first tag space that have not been recorded in the second tag space in the third tag space. The flash memory storage space is divided into a data cache area and a data interaction area. The physical blocks recorded in the third tag space are used as the management blocks of the data cache area, and the physical blocks recorded in the second tag space are used as the management blocks of the data interaction area. The method further includes: If the number of physical blocks recorded in the third tag space does not meet the preset number of cache management blocks in the data cache area, a portion of physical blocks are selected from the physical block addresses in the second tag space and allocated to the data cache area as management blocks of the data cache area; wherein, the number of physical blocks selected in the second tag space is related to the preset number of cache management blocks and the number of physical blocks recorded in the third tag space; The first preset threshold is set by the reliability requirements and error tolerance of the flash memory storage space; The second preset threshold is set by the error rate characteristics of the normal mode.
2. The method for managing physical blocks according to claim 1, characterized in that, After dividing the flash memory storage space into a data cache area and a data interaction area, the method further includes: If a physical block address is recorded in the third tag space, the physical block corresponding to the recorded physical block address in the third tag space is allocated to the data cache area as the management block of the data cache area.
3. The method for managing physical blocks according to claim 1, characterized in that, If no physical block address is recorded in the third tag space, a portion of physical blocks are selected from the physical block addresses in the second tag space and allocated to the data cache area as management blocks of the data cache area; wherein, the number of physical blocks selected in the second tag space is related to the number of preset cache management blocks in the data cache area.
4. The method for managing physical blocks according to claim 1, characterized in that, The step of using the physical block recorded in the second tag space as the management block of the data interaction area includes: If there are physical blocks in the second tag space that are allocated to the data cache area and serve as management blocks of the data cache area, the unallocated physical blocks recorded in the second tag space are selected as management blocks of the data interaction area; wherein, the number of unallocated physical blocks recorded in the second tag space is related to the number of preset interaction management blocks of the data interaction area.
5. The method for managing physical blocks according to claim 1, characterized in that, Writing the first random number to all physical blocks within the flash memory storage space includes: Get the physical block address of any physical block; The physical block address of any physical block is placed in the random number generation function for calculation to obtain the first random number; Write the first random number into the corresponding physical block.
6. A physical block management system, characterized in that, The system includes: A control unit is used to control the flash memory space of the storage device to enter a reliable mode and write a first random number on all physical blocks within the flash memory space; The reading unit is used to read the first stored data in all the physical blocks, compare it with the first random number written, obtain the first error bit count of each physical block, and record the physical block address of the physical block with the first error bit count less than the first preset threshold into the first tag space; The control unit is also used to control the flash memory storage space to exit the reliable mode and enter the normal mode, so as to write the second random number into the physical block recorded in the first tag space; The reading unit is further configured to read the second storage data of all physical blocks in the first tag space, compare it with the second random number to obtain the second error bit number of each physical block, and record the physical block address of the physical block with the second error bit number less than the second preset threshold in the second tag space, and record the physical block address of the remaining physical blocks in the first tag space that have not been recorded in the second tag space in the third tag space. A partitioning unit is used to divide the flash memory storage space into a data cache area and a data interaction area, and to use the physical blocks recorded in the third tag space as the management blocks of the data cache area, and the physical blocks recorded in the second tag space as the management blocks of the data interaction area. The system also includes: a selection unit; The selection unit is configured to select a portion of physical blocks from the physical block addresses in the second tag space and allocate them to the data cache area as management blocks when the number of physical blocks recorded in the third tag space does not meet the preset number of cache management blocks in the data cache area; wherein, the number of physical blocks selected in the second tag space is related to the preset number of cache management blocks and the number of physical blocks recorded in the third tag space; The first preset threshold is set by the reliability requirements and error tolerance of the flash memory storage space; The second preset threshold is set by the error rate characteristics of the normal mode.
7. A physical block management device, characterized in that, The device includes: Central processing unit, memory, input / output interfaces, wired or wireless network interfaces, and power supply; The memory is either a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the physical block management method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on a computer, cause the computer to perform the method for managing physical blocks as described in any one of claims 1 to 5.