Abnormal physical erasure block analysis method and device and electronic equipment
By calculating the block head address and partition identification number of the abnormal physical erase block in memory, the problem of not being able to determine which service partition the abnormal physical erase block belongs to is solved, and rapid fault location and data recovery are achieved, reducing the risk of data loss.
Patent Information
- Application Number
- CN202411140908.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-27
AI Technical Summary
In the power-on and shutdown stress test or aging test of NAND Flash memory, it is impossible to determine which service partition the abnormal physical erase block belongs to, resulting in the inability to further analyze and locate the problem points.
By obtaining the number of data pages of the target memory and the data capacity per page, as well as the block number of the abnormal physical erase block, the block address is calculated, and the partition identification number is read based on the first address of the block, thereby determining the physical erase block belonging to Business partition.
Accurate determination of the business partition to which the abnormal physical erase block belongs is achieved, helping to quickly locate fault points and reduce the risk of data loss.
Smart Images

Figure CN119207528A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to an analysis method, device and electronic device for abnormal physical erase blocks. Background Art
[0002] When a new NAND Flash (non-volatile memory) is imported into a project for power-on / off stress testing or aging testing, some Flash blocks (physical blocks, also called erase blocks) may be abnormal, such as ECC (Error Correction Code) over-errors. If an abnormality is detected in the Flash during the UBoot phase, the kernel may stop loading, resulting in the module being unable to boot. When NAND Flash abnormalities occur, Flash manufacturers can use professional tools to easily detect specific abnormal block information (such as abnormal block numbers, etc.), but it is usually impossible to determine which business partitions these abnormal blocks belong to, resulting in an inability to further analyze and locate the problem. Summary of the invention
[0003] The present application provides an analysis method, device and electronic device for abnormal physical erase blocks, so as to solve the technical problem that it is impossible to determine the business partition to which the abnormal physical erase blocks of a memory belong.
[0004] In a first aspect, the present application provides a method for analyzing abnormal physical erase blocks, comprising: obtaining the number of data pages of a physical erase block of a target memory and a first data capacity of a data page of a physical erase block; obtaining the block number of a target physical erase block of the target memory, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory; calculating a block head address of the target physical erase block based on the number of data pages, the first data capacity and the block number; reading a target partition identification number of the target physical erase block based on the block head address, and determining the target partition to which the target physical erase block belongs based on the target partition identification number.
[0005] In a second aspect, the present application provides an analysis device for abnormal physical erase blocks, comprising: a first acquisition module, used to acquire the number of data pages of a physical erase block of a target memory and the first data capacity of a data page of a physical erase block; a second acquisition module, used to acquire the block number of a target physical erase block of the above-mentioned target memory, wherein the above-mentioned target physical erase block is any one of all abnormal physical erase blocks of the above-mentioned target memory; a calculation module, used to calculate the block head address of the above-mentioned target physical erase block according to the above-mentioned number of data pages, the above-mentioned first data capacity and the above-mentioned block number; a determination module, used to read the target partition identification number of the above-mentioned target physical erase block according to the above-mentioned block head address, and determine the target partition to which the above-mentioned target physical erase block belongs according to the above-mentioned target partition identification number.
[0006] As an optional example, the above-mentioned calculation module includes: a first calculation unit, used to calculate the above-mentioned block start address through the following formula: Address1=Number*Page*Byte1; wherein the above-mentioned Address1 is the above-mentioned block start address, the above-mentioned Number is the above-mentioned block number, the above-mentioned Page is the above-mentioned data page number, and the above-mentioned Byte1 is the above-mentioned first data capacity.
[0007] As an optional example, the above-mentioned determination module includes: a second calculation unit, used to calculate the second page header address of the above-mentioned target physical erase block according to the above-mentioned block header address and the above-mentioned first data capacity; a first reading unit, used to read the partition identifier header information of the above-mentioned target physical erase block according to the above-mentioned second page header address; and a second reading unit, used to read the above-mentioned target partition identification number from the above-mentioned partition identifier header information.
[0008] As an optional example, the second calculation unit includes: a first calculation subunit, used to calculate the second page header address through the following formula: Address2=Address1+Byte1; wherein, Address2 is the second page header address, Address1 is the block header address, and Byte1 is the first data capacity.
[0009] As an optional example, the first reading unit includes: an acquisition subunit, used to acquire the second data capacity of the data area of a data page of a physical erase block of the target memory, wherein the data page of a physical erase block includes a data area and an out-of-band data area; a second calculation subunit, used to calculate the head address of the out-of-band data area of the second data page of the target memory according to the second page head address and the second data capacity; a first reading subunit, used to read the out-of-band data area of the second data page of the target physical erase block according to the head address; and a second reading subunit, used to read the partition identifier header information from the out-of-band data area of the second data page of the target physical erase block.
[0010] As an optional example, the second calculation subunit is further used to calculate the zone header address by the following formula: Address3=Address2+Byte2; wherein Address3 is the zone header address, Address2 is the second page header address, and Byte2 is the second data capacity.
[0011] As an optional example, the determination module includes: a search unit for searching the target partition corresponding to the target partition identification number in the partition information table of the target memory, wherein the partition information table stores all partitions of the target memory and their partition identification numbers.
[0012] In a third aspect, the present application provides a storage medium storing a computer program, wherein the computer program executes the above-mentioned abnormal physical erase block analysis method when executed by a processor.
[0013] In a fourth aspect, the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned abnormal physical erase block analysis method through the computer program.
[0014] In the embodiment of the present application, the number of data pages of a physical erase block of the target memory and the first data capacity of a data page of a physical erase block are obtained; the block number of the target physical erase block of the target memory is obtained, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory; the block head address of the target physical erase block is calculated according to the number of data pages, the first data capacity and the block number; the target partition identification number of the target physical erase block is read according to the block head address, and the target partition identification number of the target physical erase block is determined according to the target partition identification number. The method for determining the target partition to which an abnormal physical erase block belongs, because in the above method, by obtaining the number of data pages and the data capacity of each page of the physical erase block, as well as the block number of the abnormal physical erase block, the block head address of the abnormal physical erase block is calculated, and its partition identification number is read according to its block head address, so as to determine the business partition to which the abnormal physical erase block of the memory belongs, it is achieved to determine the business partition to which the abnormal physical erase block of the memory belongs, and the abnormal problem points of the memory can be further analyzed, and rapid positioning and recovery can be performed when a fault occurs, so as to reduce the risk of data loss, thereby solving the technical problem of being unable to determine the business partition to which the abnormal physical erase block of the memory belongs. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0017] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0018] Figure 1 is a flow chart of an optional abnormal physical erase block analysis method according to an embodiment of the present application;
[0019] Figure 2 is a specific implementation flow chart of an optional abnormal physical erase block analysis method according to an embodiment of the present application;
[0020] Figure 3 is a structural schematic diagram of an optional abnormal physical erase block analysis device according to an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0023] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0024] According to a first aspect of an embodiment of the present application, a method for analyzing abnormal physical erase blocks is provided. Optionally, as follows: Figure 1 As shown, the above method includes:
[0025] S102, obtaining the number of data pages of a physical erase block of a target memory and a first data capacity of a data page of a physical erase block;
[0026] S104, obtaining a block number of a target physical erase block of the target memory, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory;
[0027] S106, calculating and obtaining a block head address of a target physical erase block according to the number of data pages, the first data capacity and the block number;
[0028] S108, reading the target partition identification number of the target physical erase block according to the block head address, and determining the target partition to which the target physical erase block belongs according to the target partition identification number.
[0029] Optionally, in this embodiment, NAND Flash is a non-volatile memory used to retain data after power failure. It consists of multiple storage units, which are physically organized in the form of blocks, and each block contains multiple pages. MTD (Memory Technology Device) is an interface layer for flash memory devices such as NAND Flash. It provides an abstraction of flash memory for the file system, enabling the file system to operate through a unified interface. UBI (Unsorted Block Images) is located between MTD and the file system (such as UBIFS). As an intermediate layer, it is responsible for mapping logical erase blocks (LEBs) to physical erase blocks (PEBs). Logical erase blocks are units used by the file system, while physical erase blocks are actual hardware storage units. Through this mapping, UBI can hide the problems caused by physical bad blocks and provide a storage device with no logical bad blocks. UBI can divide a UBI device into multiple UBI volumes (UBI volumes), each of which can be regarded as a logical partition. The file system can create and manage files on these volumes, and each UBI volume consists of a set of continuous LEBs. UBIFS is a file system designed specifically for UBI, and it interacts directly with UBI to manage data.
[0030] Optionally, in this embodiment, PEB is a physical erase block actually existing in NAND Flash, and the size of PEB is usually fixed. For example, if the size of the physical erase block of NAND Flash is 128KB, then the size of each physical erase block is 128KB. Each PEB contains multiple pages (Page), and the number of pages of all physical erase blocks is the same. Each page has a data area and an OOB (Out-of-Band) area. The size of the data area and the OOB data area of each page of all physical erase blocks is the same. Usually, an EC header (Erase Count Header) is stored in the OOB area of the first page of each PEB to record the number of erases of the PEB. Usually, a VID header (Volume Identifier Header) is stored in the OOB area of the second page of each PEB. The VID header stores the volume identifier and other related metadata. This information is used to identify which volume the current PEB belongs to and is used in file system and partition management.
[0031] Optionally, in this embodiment, the number of data pages of a physical erase block of the target memory and the first data capacity of a data page of a physical erase block are first obtained. For example, a physical erase block contains 64 pages, and the data capacity of each page is 4096 bytes (including out-of-band data). Then the number of the abnormal physical erase block in the memory is obtained to uniquely identify a physical erase block. For example, the block number of a target physical erase block is 5. Then the block head address of the target physical erase block is calculated according to the number of data pages, the first data capacity and the block number. Specifically, the block head address = block number × number of data pages × first data capacity of each page. For example, if the block number is 5, each block contains 64 pages, and the first data capacity of each page is 4096 bytes, then the block head address is: block head address = 5 × 64 × 4096 = 1310720 bytes. The block head address determines the starting position of the target physical erase block. Finally, the target partition identification number of the target physical erase block is read according to the block head address, so that the logical partition to which the physical erase block belongs can be determined.
[0032] Optionally, in this embodiment, by accurately calculating and reading the block header address and partition identification number of the target physical erase block, the logical partition to which the physical erase block belongs can be quickly and accurately determined. Determining the block number and partition to which the abnormal physical erase block belongs helps to quickly locate and recover when a failure occurs, reducing the risk of data loss.
[0033] Optionally, in this embodiment, by obtaining the number of data pages and the data capacity of each page of the physical erase block, as well as the block number of the abnormal physical erase block, the block head address of the abnormal physical erase block is calculated, and its partition identification number is read according to its block head address, thereby determining the business partition to which the abnormal physical erase block of the memory belongs. This realizes determining the business partition to which the abnormal physical erase block of the memory belongs, and can further analyze the abnormal problem points of the memory, quickly locate and restore when a failure occurs, thereby reducing the risk of data loss, thereby solving the technical problem of being unable to determine the business partition to which the abnormal physical erase block of the memory belongs.
[0034] As an optional example, according to the number of data pages, the first data capacity, and the block number, calculating the block head address of the target physical erase block includes:
[0035] The block first address is calculated by the following formula:
[0036] Address1=Number*Page*Byte1;
[0037] Among them, Address1 is the block head address, Number is the block number, Page is the number of data pages, and Byte1 is the first data capacity.
[0038] Optionally, in this embodiment, the block header address of each abnormal physical erase block is calculated according to the number of data pages, the first data capacity and the block number. Specifically, the block header address = block number × number of data pages × first data capacity of each page. For example, if the block number is 5, each block contains 64 pages, and the first data capacity of each page is 4096 bytes, then the block header address is: block header address = 5 × 64 × 4096 = 1310720 bytes. The block header address determines the starting position of the physical erase block. Finally, the partition identification number of the physical erase block can be read according to the block header address, so that the logical partition to which the physical erase block belongs can be determined.
[0039] As an optional example, according to the block head address, reading the target partition identification number of the target physical erase block includes:
[0040] Calculate and obtain a second page head address of a target physical erase block according to the block head address and the first data capacity;
[0041] Reading the partition identifier header information of the target physical erase block according to the second page header address;
[0042] Read the target partition identification number from the partition identifier header information.
[0043] Optionally, in this embodiment, since the partition identifier header information is stored in the out-of-band data area of the second page of each physical erase block, the partition identifier header information stores the volume identifier, that is, the partition identification number and other related metadata, which are used to identify which volume the current physical erase block belongs to, and are used in the file system and partition management. Therefore, the second page header address of the physical erase block can be calculated by the block header address and the first data capacity of each page, and then the partition identifier header information of the physical erase block is read according to the second page header address. Finally, the partition identification number of the physical erase block is read from the partition identifier header information, so that the logical partition to which the physical erase block belongs can be determined. Calculate the starting address of the second page: the second page header address = the block header address + the first data capacity of each page. For example, if the block header address is 1310720 bytes and the data capacity of each page is 4096 bytes, the starting address of the second page is: the second page header address = 1310720 + 4096 = 1314816 bytes.
[0044] As an optional example, according to the block head address and the first data capacity, calculating the second page head address of the target physical erase block includes:
[0045] The second page header address is calculated using the following formula:
[0046] Address2 = Address1 + Byte1;
[0047] Among them, Address2 is the second page head address, Address1 is the block head address, and Byte1 is the first data capacity.
[0048] Optionally, in this embodiment, the second page header address of each abnormal physical erase block is calculated based on the block header address and the first data capacity. Specifically, the second page header address = block header address + the first data capacity of each page. For example, if the block header address is 1310720 bytes and the data capacity of each page is 4096 bytes, the starting address of the second page is: second page header address = 1310720 + 4096 = 1314816 bytes.
[0049] As an optional example, according to the second page header address, reading the partition identifier header information of the target physical erase block includes:
[0050] Acquire a second data capacity of a data area of a data page of a physical erase block of a target memory, wherein the data page of a physical erase block includes a data area and an out-of-band data area;
[0051] Calculate the head address of the out-of-band data area of the second data page of the target memory according to the second page head address and the second data capacity;
[0052] Reading the out-of-band data area of the second data page of the target physical erase block according to the area header address;
[0053] The partition identifier header information is read from an out-of-band data area of a second data page of the target physical erase block.
[0054] Optionally, in this embodiment, since the partition identifier header information is stored in the out-of-band data area of the second page of each physical erase block, the partition identifier header information stores the volume identifier, that is, the partition identification number and other related metadata, which are used to identify which volume the current physical erase block belongs to. Therefore, the head address of the out-of-band data area of the second page of the physical erase block can be calculated by the second page head address and the second data capacity of the data area of each page, and then the out-of-band data area of the second page data page of this physical erase block can be read according to the head address, and finally, the partition identifier header information of the physical erase block is read in the out-of-band data area, and finally, the partition identification number of the physical erase block is read from the partition identifier header information, so that the logical partition to which the physical erase block belongs can be determined. The out-of-band data area usually follows the data area. The starting address of the out-of-band data area is: zone header address = second page header address + second data capacity. For example, if the second page header address is 1314816 bytes and the second data capacity of the data area of each page is 64 bytes, then the starting address of the out-of-band data area is: zone header address = 1314816 + 64 = 1314880 bytes.
[0055] As an optional example, according to the second page header address and the second data capacity, calculating the header address of the out-of-band data area of the second page data page of the target memory includes:
[0056] The zone head address is calculated using the following formula:
[0057] Address3 = Address2 + Byte2;
[0058] Among them, Address3 is the zone head address, Address2 is the second page head address, and Byte2 is the second data capacity.
[0059] Optionally, in this embodiment, the header address of the out-of-band data area of the second page data page of the target memory is calculated based on the second page header address and the second data capacity. Specifically, the header address = the second page header address + the second data capacity. For example, if the second page header address is 1314816 bytes and the second data capacity of the data area of each page is 64 bytes, then the starting address of the out-of-band data area is: header address = 1314816 + 64 = 1314880 bytes.
[0060] As an optional example, determining the target partition to which the target physical erase block belongs according to the target partition identification number includes:
[0061] The target partition corresponding to the target partition identification number is searched in the partition information table of the target storage, wherein the partition information table stores all the partitions of the target storage and their partition identification numbers.
[0062] Optionally, in this embodiment, the partition information table is a data structure for recording all partition information, and each partition has a unique partition identification number. By reading the partition identification number, the partition information table can be searched to determine the logical partition to which the abnormal physical erase block belongs.
[0063] In conjunction with an example, the present application relates to an analysis method for abnormal physical erase blocks, which obtains the number of data pages and the data capacity of each page of the abnormal physical erase block, as well as the block number, calculates the block head address, and reads its partition identification number, and then determines the business partition to which it belongs according to the partition identification number. The specific implementation process is as follows: Figure 2 The specific implementation flow chart is shown in:
[0064] 1. Obtain the number of data pages of a physical erase block and the first data capacity of a data page of a physical erase block;
[0065] 2. Get the block number of the abnormal physical erase block;
[0066] 3. Calculate the block head address of the abnormal physical erase block according to the number of data pages, the first data capacity and the block number;
[0067] 4. Calculate the second page header address of the abnormal physical erase block according to the block header address and the first data capacity;
[0068] 5. Calculate the header address of the out-of-band data area of the second data page of the abnormal physical erase block according to the second header address and the second data capacity of the data area of one data page of a physical erase block;
[0069] 6. Read the partition identifier header information in the out-of-band data area of the second data page of the abnormal physical erase block according to the zone header address;
[0070] 7. Read the partition identification number of the abnormal physical erase block from the partition identifier header information;
[0071] 8. Find the business partition corresponding to the partition identification number in the partition information table.
[0072] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0073] According to another aspect of the embodiment of the present application, a device for analyzing abnormal physical erase blocks is also provided. Figure 3 As shown, including:
[0074] A first acquisition module 302 is used to acquire the number of data pages of a physical erase block of a target memory and a first data capacity of a data page of a physical erase block;
[0075] A second acquisition module 304 is used to acquire a block number of a target physical erase block of a target memory, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory;
[0076] A calculation module 306, configured to calculate a block head address of a target physical erase block according to the number of data pages, the first data capacity and the block number;
[0077] The determination module 308 is used to read the target partition identification number of the target physical erase block according to the block head address, and determine the target partition to which the target physical erase block belongs according to the target partition identification number.
[0078] Optionally, in this embodiment, NAND Flash is a non-volatile memory used to retain data after power failure. It consists of multiple storage units, which are physically organized in the form of blocks, and each block contains multiple pages. MTD (Memory Technology Device) is an interface layer for flash memory devices such as NAND Flash. It provides an abstraction of flash memory for the file system, enabling the file system to operate through a unified interface. UBI (Unsorted Block Images) is located between MTD and the file system (such as UBIFS). As an intermediate layer, it is responsible for mapping logical erase blocks (LEBs) to physical erase blocks (PEBs). Logical erase blocks are units used by the file system, while physical erase blocks are actual hardware storage units. Through this mapping, UBI can hide the problems caused by physical bad blocks and provide a storage device with no logical bad blocks. UBI can divide a UBI device into multiple UBI volumes (UBI volumes), each of which can be regarded as a logical partition. The file system can create and manage files on these volumes, and each UBI volume consists of a set of continuous LEBs. UBIFS is a file system designed specifically for UBI, and it interacts directly with UBI to manage data.
[0079] Optionally, in this embodiment, PEB is a physical erase block actually existing in NAND Flash, and the size of PEB is usually fixed. For example, if the size of the physical erase block of NAND Flash is 128KB, then the size of each physical erase block is 128KB. Each PEB contains multiple pages (Page), and the number of pages of all physical erase blocks is the same. Each page has a data area and an OOB (Out-of-Band) area. The size of the data area and the OOB data area of each page of all physical erase blocks is the same. Usually, an EC header (Erase Count Header) is stored in the OOB area of the first page of each PEB to record the number of erases of the PEB. Usually, a VID header (Volume Identifier Header) is stored in the OOB area of the second page of each PEB. The VID header stores the volume identifier and other related metadata. This information is used to identify which volume the current PEB belongs to and is used in file system and partition management.
[0080] Optionally, in this embodiment, the number of data pages of a physical erase block of the target memory and the first data capacity of a data page of a physical erase block are first obtained. For example, a physical erase block contains 64 pages, and the data capacity of each page is 4096 bytes (including out-of-band data). Then the number of the abnormal physical erase block in the memory is obtained to uniquely identify a physical erase block. For example, the block number of a target physical erase block is 5. Then the block head address of the target physical erase block is calculated according to the number of data pages, the first data capacity and the block number. Specifically, the block head address = block number × number of data pages × first data capacity of each page. For example, if the block number is 5, each block contains 64 pages, and the first data capacity of each page is 4096 bytes, then the block head address is: block head address = 5 × 64 × 4096 = 1310720 bytes. The block head address determines the starting position of the target physical erase block. Finally, the target partition identification number of the target physical erase block is read according to the block head address, so that the logical partition to which the physical erase block belongs can be determined.
[0081] Optionally, in this embodiment, by accurately calculating and reading the block header address and partition identification number of the target physical erase block, the logical partition to which the physical erase block belongs can be quickly and accurately determined. Determining the block number and partition to which the abnormal physical erase block belongs helps to quickly locate and recover when a failure occurs, reducing the risk of data loss.
[0082] Optionally, in this embodiment, by obtaining the number of data pages and the data capacity of each page of the physical erase block, as well as the block number of the abnormal physical erase block, the block head address of the abnormal physical erase block is calculated, and its partition identification number is read according to its block head address, thereby determining the business partition to which the abnormal physical erase block of the memory belongs. This realizes determining the business partition to which the abnormal physical erase block of the memory belongs, and can further analyze the abnormal problem points of the memory, quickly locate and restore when a failure occurs, thereby reducing the risk of data loss, thereby solving the technical problem of being unable to determine the business partition to which the abnormal physical erase block of the memory belongs.
[0083] As an optional example, the calculation module includes:
[0084] The first calculation unit is used to calculate the block head address by the following formula:
[0085] Address1=Number*Page*Byte1;
[0086] Among them, Address1 is the block head address, Number is the block number, Page is the number of data pages, and Byte1 is the first data capacity.
[0087] Optionally, in this embodiment, the block header address of each abnormal physical erase block is calculated according to the number of data pages, the first data capacity and the block number. Specifically, the block header address = block number × number of data pages × first data capacity of each page. For example, if the block number is 5, each block contains 64 pages, and the first data capacity of each page is 4096 bytes, then the block header address is: block header address = 5 × 64 × 4096 = 1310720 bytes. The block header address determines the starting position of the physical erase block. Finally, the partition identification number of the physical erase block can be read according to the block header address, so that the logical partition to which the physical erase block belongs can be determined.
[0088] As an optional example, the determination module includes:
[0089] A second calculation unit, used for calculating a second page head address of a target physical erase block according to the block head address and the first data capacity;
[0090] A first reading unit, used for reading the partition identifier header information of the target physical erase block according to the second page header address;
[0091] The second reading unit is used to read the target partition identification number from the partition identifier header information.
[0092] Optionally, in this embodiment, since the partition identifier header information is stored in the out-of-band data area of the second page of each physical erase block, the partition identifier header information stores the volume identifier, that is, the partition identification number and other related metadata, which are used to identify which volume the current physical erase block belongs to, and are used in the file system and partition management. Therefore, the second page header address of the physical erase block can be calculated by the block header address and the first data capacity of each page, and then the partition identifier header information of the physical erase block is read according to the second page header address. Finally, the partition identification number of the physical erase block is read from the partition identifier header information, so that the logical partition to which the physical erase block belongs can be determined. Calculate the starting address of the second page: the second page header address = the block header address + the first data capacity of each page. For example, if the block header address is 1310720 bytes and the data capacity of each page is 4096 bytes, the starting address of the second page is: the second page header address = 1310720 + 4096 = 1314816 bytes.
[0093] As an optional example, the second computing unit includes:
[0094] The first calculation subunit is used to calculate the second page header address by the following formula:
[0095] Address2 = Address1 + Byte1;
[0096] Among them, Address2 is the second page head address, Address1 is the block head address, and Byte1 is the first data capacity.
[0097] Optionally, in this embodiment, the second page header address of each abnormal physical erase block is calculated based on the block header address and the first data capacity. Specifically, the second page header address = block header address + the first data capacity of each page. For example, if the block header address is 1310720 bytes and the data capacity of each page is 4096 bytes, the starting address of the second page is: second page header address = 1310720 + 4096 = 1314816 bytes.
[0098] As an optional example, the first reading unit includes:
[0099] An acquisition subunit is used to acquire a second data capacity of a data area of a data page of a physical erase block of a target memory, wherein the data page of a physical erase block includes a data area and an out-of-band data area;
[0100] A second calculation subunit, configured to calculate a region head address of an out-of-band data region of a second data page of the target memory according to a second page head address and a second data capacity;
[0101] A first reading sub-unit is used to read the out-of-band data area of the second data page of the target physical erase block according to the area header address;
[0102] The second reading subunit is used to read the partition identifier header information from the out-of-band data area of the second page data page of the target physical erase block.
[0103] Optionally, in this embodiment, since the partition identifier header information is stored in the out-of-band data area of the second page of each physical erase block, the partition identifier header information stores the volume identifier, that is, the partition identification number and other related metadata, which are used to identify which volume the current physical erase block belongs to. Therefore, the head address of the out-of-band data area of the second page of the physical erase block can be calculated by the second page head address and the second data capacity of the data area of each page, and then the out-of-band data area of the second page data page of this physical erase block can be read according to the head address, and finally, the partition identifier header information of the physical erase block is read in the out-of-band data area, and finally, the partition identification number of the physical erase block is read from the partition identifier header information, so that the logical partition to which the physical erase block belongs can be determined. The out-of-band data area usually follows the data area. The starting address of the out-of-band data area is: zone header address = second page header address + second data capacity. For example, if the second page header address is 1314816 bytes and the second data capacity of the data area of each page is 64 bytes, then the starting address of the out-of-band data area is: zone header address = 1314816 + 64 = 1314880 bytes.
[0104] As an optional example, the second calculation subunit is further configured to calculate the region head address by the following formula:
[0105] Address3 = Address2 + Byte2;
[0106] Among them, Address3 is the zone head address, Address2 is the second page head address, and Byte2 is the second data capacity.
[0107] Optionally, in this embodiment, the header address of the out-of-band data area of the second page data page of the target memory is calculated based on the second page header address and the second data capacity. Specifically, the header address = the second page header address + the second data capacity. For example, if the second page header address is 1314816 bytes and the second data capacity of the data area of each page is 64 bytes, then the starting address of the out-of-band data area is: header address = 1314816 + 64 = 1314880 bytes.
[0108] As an optional example, the determination module includes:
[0109] The search unit is used to search the target partition corresponding to the target partition identification number in the partition information table of the target storage, wherein the partition information table stores all the partitions of the target storage and their partition identification numbers.
[0110] Optionally, in this embodiment, the partition information table is a data structure for recording all partition information, and each partition has a unique partition identification number. By reading the partition identification number, the partition information table can be searched to determine the logical partition to which the abnormal physical erase block belongs.
[0111] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0112] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present application, such as Figure 4 As shown, it includes a processor 402, a communication interface 404, a memory 406 and a communication bus 408, wherein the processor 402, the communication interface 404 and the memory 406 communicate with each other through the communication bus 408, wherein,
[0113] Memory 406, used to store computer programs;
[0114] The processor 402 is used to implement the following steps when executing the computer program stored in the memory 406:
[0115] Acquire the number of data pages of a physical erase block of the target memory and the first data capacity of a data page of the physical erase block;
[0116] Obtaining a block number of a target physical erase block of a target memory, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory;
[0117] Calculate the block head address of the target physical erase block according to the number of data pages, the first data capacity and the block number;
[0118] According to the block header address, the target partition identification number of the target physical erase block is read, and the target partition to which the target physical erase block belongs is determined according to the target partition identification number.
[0119] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The communication interface is used for communication between the above electronic device and other devices.
[0120] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0121] As an example, the memory 406 may include, but is not limited to, the first acquisition module 302, the second acquisition module 304, the calculation module 306, and the determination module 308 in the abnormal physical erase block analysis device. In addition, other module units in the abnormal physical erase block analysis device may also be included but are not limited to, which will not be repeated in this example.
[0122] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0123] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0124] It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only. The electronic device implementing the synchronization method of the above code library project may be a module capable of realizing the communication function or a terminal device including the module, etc. The terminal device may be a mobile terminal or a smart terminal. The mobile terminal may be at least one of a mobile phone, a tablet computer, a laptop computer, etc.; the smart terminal may be a terminal including a wireless communication module such as a smart car, a smart watch, a shared bicycle, a smart cabinet, etc.; the module may be a wireless communication module, such as any one of a 2G communication module, a 3G communication module, a 4G communication module, a 5G communication module, and a NB-IOT communication module. Figure 4 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 4 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 4 Different configurations shown.
[0125] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.
[0126] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the above-mentioned abnormal physical erase block analysis method when executed by a processor.
[0127] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0128] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0129] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0130] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0131] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0132] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0134] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for analyzing abnormal physical erase blocks, characterized in that: include: Acquire the number of data pages of a physical erase block of the target memory and the first data capacity of a data page of the physical erase block; Acquire a block number of a target physical erase block of the target memory, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory; Calculate the block head address of the target physical erase block according to the number of data pages, the first data capacity and the block number; According to the block header address, the target partition identification number of the target physical erase block is read, and the target partition to which the target physical erase block belongs is determined according to the target partition identification number.
2. The method according to claim 1, characterized in that The step of calculating the block head address of the target physical erase block according to the number of data pages, the first data capacity and the block number comprises: The block head address is calculated by the following formula: Address1=Number*Page*Byte1; Among them, Address1 is the block head address, Number is the block number, Page is the data page number, and Byte1 is the first data capacity.
3. The method according to claim 1, characterized in that The step of reading the target partition identification number of the target physical erase block according to the block header address comprises: Calculating a second page header address of the target physical erase block according to the block header address and the first data capacity; Reading the partition identifier header information of the target physical erase block according to the second page header address; The target partition identification number is read from the partition identifier header information.
4. The method according to claim 3, characterized in that The step of calculating the second page header address of the target physical erase block according to the block header address and the first data capacity comprises: The second page header address is calculated by the following formula: Address2 = Address1 + Byte1; Among them, Address2 is the second page header address, Address1 is the block header address, and Byte1 is the first data capacity.
5. The method according to claim 3, characterized in that: The step of reading the partition identifier header information of the target physical erase block according to the second page header address comprises: Acquire a second data capacity of a data area of a data page of a physical erase block of the target memory, wherein the data page of a physical erase block includes a data area and an out-of-band data area; Calculate the head address of the out-of-band data area of the second data page of the target memory according to the second page head address and the second data capacity; Reading the out-of-band data area of the second data page of the target physical erase block according to the area header address; The partition identifier header information is read from an out-of-band data area of a second page data page of the target physical erase block.
6. The method according to claim 5, characterized in that The step of calculating the header address of the out-of-band data area of the second data page of the target memory according to the second page header address and the second data capacity comprises: The zone head address is calculated by the following formula: Address3 = Address2 + Byte2; Among them, Address3 is the region head address, Address2 is the second page head address, and Byte2 is the second data capacity.
7. The method according to claim 1, characterized in that Determining the target partition to which the target physical erase block belongs according to the target partition identification number comprises: The target partition corresponding to the target partition identification number is searched in a partition information table of the target storage, wherein the partition information table stores all the partitions of the target storage and their partition identification numbers.
8. An analysis device for abnormal physical erase blocks, characterized in that: include: A first acquisition module, used for acquiring the number of data pages of a physical erase block of a target memory and a first data capacity of a data page of a physical erase block; A second acquisition module is used to acquire a block number of a target physical erase block of the target memory, wherein the target physical erase block is any one of all abnormal physical erase blocks of the target memory; A calculation module, configured to calculate a block head address of the target physical erase block according to the number of data pages, the first data capacity and the block number; The determination module is used to read the target partition identification number of the target physical erase block according to the block head address, and determine the target partition to which the target physical erase block belongs according to the target partition identification number.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
