Data processing method and device, equipment and storage medium
The method addresses data loss in NAND Flash by backing up data to a reserved area when bit flips exceed ECC limits, enhancing data stability and security in NAND Flash memory.
Patent Information
- Application Number
- CN202411336501.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-12-20
AI Technical Summary
NAND Flash memory experiences bit flips during data reading and writing, leading to potential data loss when the number of bit flips exceeds the error correction capability of ECC, causing system crashes and data instability.
A data processing method that backs up data from a target data block to a reserved area when bit flips exceed a preset threshold and corrects the data based on the size relationship between the bit flip number and the number of correctable bits, using a nonlinear macro cell mode flash memory with user and reserved areas.
Reduces the risk of data loss and improves data stability in NAND Flash memory by proactively backing up data to a reserved area when bit flips exceed correctable limits, ensuring data integrity.
Smart Images

Figure CN119166072A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a data processing method, device, equipment and storage medium. Background Art
[0002] Due to the inherent characteristics of NAND Flash and its manufacturing process, one or more data errors may occasionally occur during the process of reading and writing data in NAND Flash. For example, some bits in the binary representation change from "1" to "0", or from "0" to "1". When bit flipping occurs in critical codes or critical data, it may cause system crashes, data loss, etc., resulting in serious consequences.
[0003] Normally, the solution to the bit flip problem is to use ECC (Error Correcting Code), which is to calculate an error correction code for the user data read from a data page, and analyze the error correction code to determine the number of bits where bit flips occur. If the number of bits where bit flips occur is less than or equal to the number of bits that can be corrected by ECC, the user data can be corrected based on the error correction code. However, if the number of bits where bit flips occur is greater than the number of bits that can be corrected by ECC, the error may result in data loss on the data page because the error correction capability of ECC is exceeded. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a data processing method, device, equipment and storage medium, which can first back up the data in the target data block where the target data page is located to the reserved area when the bit flip number is not less than the bit flip threshold, and then correct the target data based on the size relationship between the bit flip number and the preset number of correctable bits, so as to reduce the risk of data loss in the target data page when the bit flip number is greater than the preset number of correctable bits, and improve the stability of the data in the target flash memory. The specific scheme is as follows:
[0005] In a first aspect, the present invention provides a data processing method, applied to a preset processor, comprising:
[0006] Determine a data processing operation for a target data page in a user area of a target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro cell mode; and the user area is used to store user data;
[0007] When the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation, a data read operation is performed on the target data page to read the target data from the target data page, and a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory is obtained;
[0008] If the number of bit flips is not less than a preset bit flip threshold, a reserved data block that meets the preset conditions is determined from the reserved area of the target flash memory, and the data in the target data block is backed up to the reserved data block, and the mapping relationship between the target data block and the reserved data block is stored using the first block mapping table, and then the target data is corrected based on the size relationship between the number of bit flips and a preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
[0009] Optionally, after determining the data processing operation for the target data page in the user area of the target flash memory, the method further includes:
[0010] When the first block mapping table exists in the preset memory and there exists a mapping relationship corresponding to the target data block in the first block mapping table, a corresponding data block to be operated is determined from the reserved area based on the mapping relationship corresponding to the target data block, and the data processing operation is performed on the data block to be operated; wherein the data processing operation includes a data reading operation, a data writing operation and a data erasing operation.
[0011] Optionally, the data processing method further includes:
[0012] When the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and the first block mapping table does not have a mapping relationship corresponding to the target data block, if the data processing operation is not a data read operation, the data processing operation is performed on the target data page; wherein the data processing operation includes a data write operation and a data erase operation;
[0013] Among them, if the data processing operation is a data writing operation, after performing the data writing operation on the target data page, the original error correction code is calculated based on the data written in the target data page, and the original error correction code is stored in the target free area corresponding to the target data page.
[0014] Optionally, performing a data read operation on the target data page to read target data from the target data page, and obtaining a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory, includes:
[0015] Performing a data read operation on the target data page to read target data from the target data page, so that the controller of the target flash memory calculates an error correction code on the target data to obtain a target error correction code, and determines a corresponding bit flip number based on a comparison result between the target error correction code and the original error correction code stored in the target free area;
[0016] The bit flip number sent by the controller of the target flash memory is obtained.
[0017] Optionally, determining a reserved data block that meets a preset condition from a reserved area of the target flash memory includes:
[0018] Based on the status identifier and the bad block identifier, a reserved data block that is in an idle state and is not a bad block is determined from each data block in the reserved area; wherein the bad block identifier for identifying whether the data block is a bad block and the status identifier for identifying the current state of the data block are stored in the idle area corresponding to any data page in the data block.
[0019] Optionally, before determining the data processing operation for the target data page in the user area of the target flash memory, the method further includes:
[0020] Traversing the management area of the target flash memory to determine the first data block in the management area as the current data block, and to determine the first data page in the current data block as the current data page, and to read the current data page, and to determine whether the read block mapping table identifier is a preset identifier; wherein the management area is used to store a block mapping table;
[0021] If the block mapping table identifier read is the preset identifier, it indicates that the second block mapping table corresponding to the block mapping table identifier is a valid block mapping table, and creates the corresponding first block mapping table in the preset memory based on the second block mapping table, and then ends the traversal of the management area;
[0022] If the block mapping table identifier is not read or the read block mapping table identifier is not the preset identifier, determining whether the current data page is the last data page in the current data block;
[0023] If the current data page is not the last data page in the current data block, determining the next data page in the current data block as a new current data page, and jumping back to the step of reading the current data page;
[0024] If the current data page is the last data page in the current data block, determining whether the current data block is the last data block in the management area;
[0025] If the current data block is not the last data block in the management area, the next data block in the management area is determined as a new current data block, and the process jumps again to the step of determining the first data page in the current data block as the current data page;
[0026] If the current data block is the last data block in the management area, the traversal of the management area is terminated.
[0027] Optionally, the storing the mapping relationship between the target data block and the reserved data block by using the first block mapping table includes:
[0028] When the first block mapping table does not exist in the preset memory, creating the first block mapping table in the preset memory, storing the mapping relationship between the target data block and the reserved data block in the first block mapping table, and creating the corresponding second block mapping table in the management area based on the first block mapping table;
[0029] Or, when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block in the first block mapping table, the mapping relationship between the target data block and the reserved data block is stored in the first block mapping table, and the second block mapping table in the management area is updated based on the first block mapping table.
[0030] In a second aspect, the present invention provides a data processing device, applied to a preset processor, comprising:
[0031] A processing operation determination module, used to determine a data processing operation for a target data page in a user area of a target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro cell mode; and the user area is used to store user data;
[0032] A bit flip number acquisition module, for performing a data read operation on the target data page to read the target data from the target data page, and acquiring a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory, when the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation;
[0033] A data backup module, for determining a reserved data block that meets a preset condition from a reserved area of the target flash memory if the bit flip number is not less than a preset bit flip threshold, backing up the data in the target data block to the reserved data block, and storing a mapping relationship between the target data block and the reserved data block using the first block mapping table, and then correcting the target data based on a size relationship between the bit flip number and a preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
[0034] In a third aspect, the present invention provides an electronic device, comprising:
[0035] Memory for storing computer programs;
[0036] A processor is used to execute the computer program to implement the steps of the aforementioned data processing method.
[0037] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the aforementioned data processing method when executed by a processor.
[0038] In the present invention, a preset processor determines a data processing operation for a target data page in a user area of a target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro unit mode; the user area is used to store user data; when there is no first block mapping table in the preset memory, or when there is the first block mapping table in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation, a data read operation is performed on the target data page to read the target data from the target data page, and a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory is obtained; if the bit flip number is not less than a preset bit flip threshold, a reserved data block that meets a preset condition is determined from a reserved area of the target flash memory, and data in the target data block is backed up to the reserved data block, and a mapping relationship between the target data block and the reserved data block is stored using the first block mapping table, and then the target data is corrected based on the relationship between the bit flip number and a preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
[0039] Beneficial effect: The present invention partitions a target flash memory using a nonlinear macro unit mode to divide the target flash memory into a user area for storing user data and a reserved area for storing backup data, and sets a preset bit flip threshold value that is less than a preset number of correctable bits, so that when a data read operation is performed on a target data page in the user area to read the target data, if the number of bit flips determined based on the error correction code corresponding to the target data is greater than or equal to the preset bit flip threshold value, the data in the target data block where the target data page is located can be first backed up to a reserved data block in the reserved area that meets the preset conditions, and then the target data is corrected based on the size relationship between the bit flip number and the preset number of correctable bits, so as to reduce the risk of data loss in the target data page when the bit flip number is greater than the preset number of correctable bits, thereby improving the stability of the data in the target flash memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 A flow chart of a data processing method provided by an embodiment of the present invention;
[0042] Figure 2 A management area traversal flow chart provided by an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of the data structure of a block mapping table provided in an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of a target flash memory partition provided by an embodiment of the present invention;
[0045] Figure 5 A specific data processing flow chart provided for an embodiment of the present invention;
[0046] Figure 6 Another specific data processing flow chart provided for an embodiment of the present invention;
[0047] Figure 7 A schematic diagram of the structure of a data processing device provided by an embodiment of the present invention;
[0048] Figure 8 A structural diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] The solution to the bit flip problem is to use an ECC error correction code, that is, it is necessary to calculate an error correction code for the user data read from a data page, and analyze the error correction code to determine the number of bits where bit flipping occurs. If the number of bits where bit flipping occurs is greater than the number of bits that can be corrected by ECC, it is beyond the error correction capability of ECC, so it may cause data loss in the data page. To this end, the present invention provides a data processing method, by first backing up the data in the target data block where the target data page is located to a reserved area when the number of bit flips is not less than the bit flip threshold, and then correcting the target data based on the size relationship between the number of bit flips and the preset number of bits that can be corrected, so as to reduce the risk of data loss in the target data page when the number of bit flips is greater than the preset number of bits that can be corrected, and improve the stability of data in the target flash memory.
[0051] See also Figure 1 As shown, an embodiment of the present invention provides a data processing method, which is applied to a preset processor, comprising:
[0052] Step S11, determining a data processing operation for a target data page in a user area of a target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro cell mode; and the user area is used to store user data.
[0053] In the embodiment of the present invention, the preset processor can be a CPU (Central Processing Unit) or other processors with processing capabilities. In addition, the target flash memory is a flash memory using a nonlinear macro unit mode, that is, NAND Flash. In addition, NAND Flash is a non-volatile memory with advantages such as large capacity and fast rewrite speed. It is suitable for storing large amounts of data and is widely used in storage devices (such as SSD (Solid State Disk), U disk, memory card, etc.), smart phones and tablet computers, digital cameras and camcorders, embedded systems and vehicle-mounted systems.
[0054] Furthermore, when the preset processor obtains the data processing instruction for the target data page in the user area of the target flash memory, it determines the data processing operation for the target data page in the user area of the target flash memory based on the data processing instruction, and then determines whether there is a first block mapping table in the preset memory. It should be noted that the user area is a space area in the target flash memory for storing user data; and the data processing operation includes but is not limited to data writing operation, data erasing operation and data reading operation. It should also be noted that the preset memory is a memory that directly exchanges data with the preset processor, such as RAM (Random Access Memory), and the data exchange speed between the preset processor and the preset memory is better than the data exchange speed between the preset processor and the target flash memory.
[0055] For the first block mapping table in the preset memory, before determining the data processing operation for the target data page in the user area of the target flash memory, it is necessary to first traverse the management area of the target flash memory to determine whether there is a valid block mapping table in the management area, and if there is a valid block mapping table in the management area, it is necessary to create a corresponding first block mapping table in the preset memory based on the valid block mapping table. The management area is a space area in the target flash memory used to store block mapping tables.
[0056] Specifically, Figure 2As shown, the management area of the target flash memory is traversed to determine the first data block in the management area as the current data block, and the first data page in the current data block is determined as the current data page, and the current data page is read, and it is determined whether the read block mapping table identifier is a preset identifier; wherein the block mapping table identifier can be set to 0 and 1, if the block mapping table identifier is 0, then the second block mapping table corresponding to the block mapping table identifier is an invalid block mapping table, and if the block mapping table identifier is 1, then the second block mapping table corresponding to the block mapping table identifier is a valid block mapping table. Further, if the read block mapping table identifier is a preset identifier, such as 1, then the second block mapping table corresponding to the block mapping table identifier is a valid block mapping table, and a corresponding first block mapping table is created in a preset memory based on the second block mapping table, and then the traversal of the management area of the target flash memory is ended. If the block mapping table identifier is not read or the read block mapping table identifier is not a preset identifier, it is determined whether the current data page is the last data page in the current data block. If the current data page is not the last data page in the current data block, the next data page in the current data block is determined as the new current data page, and the step of reading the current data page is jumped again. If the current data page is the last data page in the current data block, it is determined whether the current data block is the last data block in the management area. If the current data block is not the last data block in the management area, the next data block in the management area is determined as the new current data block, and the step of determining the first data page in the current data block as the current data page is jumped again. If the current data block is the last data block in the management area, the traversal of the management area of the target flash memory is terminated. In this way, the embodiment of the present invention determines whether the valid block mapping table is traversed by traversing each data block in the management area and each data page in the data block, and when the valid block mapping table is traversed, the corresponding first block mapping table can be created in the preset memory based on the valid block mapping table.
[0057] Step S12: When the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation, a data read operation is performed on the target data page to read the target data from the target data page, and the number of bit flips determined by the target error correction code corresponding to the target data and sent by the controller of the target flash memory is obtained.
[0058] According to one of the embodiments, when the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data write operation or a data erase operation, the data write operation or the data erase operation is directly performed on the target data page, and the corresponding execution result is obtained.
[0059] It should be noted that if the data processing operation is a data write operation, then after performing the data write operation on the target data page, an original error correction code can be calculated based on the data written in the target data page, and the original error correction code is stored in the target free area corresponding to the target data page. It should be noted that each data page in the data block corresponds to a spare area (spare area), also known as the oob (out of band) area, which is used to store error correction codes, bad block identifiers, status identifiers, and organizational information of the file system, etc.; wherein the bad block identifier is used to identify whether the data block is a bad block, and the status identifier is used to identify the current state of the data block, and the current state includes but is not limited to the idle state, occupied state, alarm state, etc.
[0060] According to another embodiment, when there is no first block mapping table in the preset memory, or when there is a first block mapping table in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation, the preset processor directly performs a data read operation on the target data page to read the target data from the target data page, and at this time, the controller of the target flash memory will calculate the error correction code for the read target data to obtain the target error correction code, and compare the target error correction code with the original error correction code stored in the target free area corresponding to the target data page, thereby determining the number of bit flips corresponding to the target data based on the comparison result, and then the controller of the target flash memory will send the number of bit flips to the preset processor so that the preset processor obtains the number of bit flips sent by the controller of the target flash memory. It should be noted that based on the comparison result between the target error correction code and the original error correction code, it can also be determined which specific bits have flipped, that is, the specific location where the bit flip has occurred.
[0061] Step S13: If the number of bit flips is not less than a preset bit flip threshold, a reserved data block that meets the preset conditions is determined from the reserved area of the target flash memory, and the data in the target data block is backed up to the reserved data block, and the mapping relationship between the target data block and the reserved data block is stored using the first block mapping table, and then the target data is corrected based on the relationship between the number of bit flips and a preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
[0062] In the embodiment of the present invention, after obtaining the bit flip number, the preset processor needs to determine whether the bit flip number is less than the preset bit flip threshold; wherein the preset bit flip threshold is less than the preset number of correctable bits, the preset number of correctable bits is the maximum number of correctable bits, and the preset bit flip threshold T is equal to the preset ratio m of the preset number of correctable bits n, that is, T=n×m; the preset ratio is a ratio less than 1, and the ratio can be set according to the actual error correction requirements. If the bit flip number is less than the preset bit flip threshold, it means that the bit flip number is also less than the preset number of correctable bits. At this time, the target data can be directly corrected based on the comparison result between the target error correction code and the original error correction code, so as to obtain the correct data after error correction.
[0063] If the number of bit flips is not less than the preset bit flip threshold, it indicates that the data in the target data page may be lost in the subsequent error correction process of the target data. At this time, the reserved data block that meets the preset conditions can be determined from the reserved area of the target flash memory, and the data in the target data block where the target data page is located can be backed up to the reserved data block, and a mapping relationship between the target data block and the reserved data block can be established. The mapping relationship between the target data block and the reserved data block is stored using the first mapping table in the preset memory, and then the target data is corrected based on the relationship between the number of bit flips and the preset number of correctable bits. It should be noted that if the number of bit flips is less than or equal to the preset number of correctable bits, it is highly likely that the target data can be corrected based on the comparison result between the target error correction code and the original error correction code to obtain the correct data after correction. However, in order to prevent accidental situations, the data in the target data block where the target data page is located is still backed up; if the number of bit flips is greater than the preset number of correctable bits, it indicates that the number of bit flips has exceeded the maximum number of correctable bits, and it is very easy to cause the data in the target data page to be lost when the erroneous data is returned and used. However, because the embodiment of the present invention has backed up the data in the target data block where the target data page is located to the reserved data block in advance, the stability and security of the data in the target flash memory can be improved.
[0064] Among them, for determining the reserved data blocks that meet the preset conditions from the reserved area of the target flash memory, specifically: based on the state identifier and the bad block identifier, determine the reserved data blocks that are in an idle state and are not bad blocks from each data block in the reserved area. It should be noted that the bad block identifier for identifying whether the data block is a bad block and the state identifier for identifying the current state of the data block are stored in the idle area corresponding to any data page in the data block. In this way, the embodiment of the present invention can determine the reserved data blocks that meet the conditions from the reserved area through the two identifiers of the state identifier and the bad block identifier, thereby realizing data backup of the target data blocks based on the reserved data blocks, and improving the efficiency of determining the reserved data blocks and the efficiency of data backup.
[0065] Regarding storing the mapping relationship between the target data block and the reserved data block using the first block mapping table, according to one embodiment, when the first block mapping table does not exist in the preset memory, the first block mapping table is first created in the preset memory, and the mapping relationship between the target data block and the reserved data block is established, and the mapping relationship between the target data block and the reserved data block is stored in the first block mapping table. Furthermore, since the first block mapping table does not exist in the preset memory, that is, no valid second block mapping table is found when traversing the management area of the target flash memory, it is also necessary to create a corresponding second block mapping table in the management area of the target flash memory based on the first block mapping table.
[0066] Regarding storing the mapping relationship between the target data block and the reserved data block by using the first block mapping table, according to another embodiment, when the first block mapping table exists in the preset memory and the mapping relationship corresponding to the target data block does not exist in the first block mapping table, a mapping relationship between the target data block and the reserved data block is established, and the mapping relationship between the target data block and the reserved data block is stored in the first block mapping table, and then the second block mapping table in the management area of the target flash memory needs to be updated based on the first block mapping table, so as to achieve synchronization of the mapping relationship between the first block mapping table in the preset memory and the second block mapping table in the management area of the target flash memory.
[0067] It should be noted that Figure 3 It is the data structure of the block mapping table, in which the mapping relationship stored in the block mapping table is actually determined based on the block number of the target data block (source_block_id) and the block number of the reserved data block (target_block_id); and the block number of the target data block and the block number of the reserved data block are both integer types (unit) and 16-bit binary numbers. Secondly, the parameters of the block mapping table include the block mapping table identifier (magic_num), the number of mapping relationships actually stored (len), and the maximum number of mapping relationships supported (MAX_MAPPING_LEN); in which the block mapping table identifier and the number of mapping relationships actually stored are both integer types (unit) and 32-bit binary numbers.
[0068] In the embodiment of the present invention, after determining the data processing operation for the target data page in the user area of the target flash memory, if there is a first block mapping table in the preset memory and there is a mapping relationship corresponding to the target data block in the first block mapping table, it indicates that the data of the target data block has been backed up to the reserved area of the target flash memory, so based on the mapping relationship corresponding to the target data block, the corresponding data block to be operated can be determined from the reserved area of the target flash memory, and then the data processing operation is performed on the data block to be operated. The data processing operation includes but is not limited to a data reading operation, a data writing operation, and a data erasing operation.
[0069] It should be noted that if Figure 4 As shown, the embodiment of the present invention divides the target flash memory NAND Flash into a user area, a reserved area and a management area; wherein the user area includes a plurality of data blocks for storing user data; the reserved area also includes a plurality of data blocks for backing up user data, that is, backing up the data of a certain data block in the user area to the corresponding data block in the reserved area based on a mapping relationship (mapping); and the management area also includes a plurality of data blocks for storing a block mapping table. In particular, the management area can also perform redundant backup storage on the block mapping table to avoid the problem of bad blocks that may occur when the block mapping table is erased and written in large quantities, thereby causing the block mapping table to be lost.
[0070] It should also be noted that, after the present invention backs up the data in the target data block where the target data page is located to the reserved data block that meets the preset conditions in the reserved area, the error correction code can be calculated for the data backed up in the reserved data block to obtain the original error correction code. If the data in the reserved data block needs to be read later, the error correction code can also be calculated for the read data to obtain the target error correction code, and the original error correction code and the target error correction code are compared to determine the number of bit flips based on the comparison result. If the number of bit flips is less than or equal to the preset number of error-correctable bits, the read data can be directly corrected to obtain the correct data after error correction. If the number of bit flips is greater than the preset number of error-correctable bits, a risk warning message can be sent to the user terminal first to inform the user whether there may be a risk of data loss and whether the data needs to be backed up, and the risk warning message will also inform the user how much free capacity is left in the current target flash memory. If a data backup instruction is received from the user end, the data in the reserved data block can be backed up to another data block in the reserved area that meets the preset conditions based on the data backup instruction, and the mapping relationship corresponding to the target data block in the first mapping table is updated based on the established mapping relationship between the target data block and the other data block, and then the second mapping table in the management area of the target flash memory is updated based on the updated first mapping table, thereby achieving synchronization of the mapping relationship between the first mapping table and the second mapping table, and further improving the stability and security of the data in the target flash memory.
[0071] Beneficial effect: The present invention partitions a target flash memory using a nonlinear macro unit mode to divide the target flash memory into a user area for storing user data, a reserved area for storing backup data, and a management area for storing a block mapping table, and sets a preset bit flip threshold value that is less than a preset number of correctable bits, so that when a data read operation is performed on a target data page in the user area to read the target data, if the number of bit flips determined based on the error correction code corresponding to the target data is greater than or equal to the preset bit flip threshold value, the data in the target data block where the target data page is located can be first backed up to a reserved data block in the reserved area that meets the preset conditions, and then the target data is corrected based on the size relationship between the bit flip number and the preset number of correctable bits, so as to reduce the risk of data loss in the target data page when the bit flip number is greater than the preset number of correctable bits, thereby improving the stability of the data in the target flash memory.
[0072] Take the data processing operation as an example, see Figure 5 As shown, an embodiment of the present invention provides a data processing method, which is applied to a preset processor, comprising:
[0073] After determining the data read operation for the target data page in the user area of the target flash memory, it is necessary to determine whether there is a first block mapping table in the preset memory. If there is a first block mapping table in the preset memory, it is necessary to further determine whether there is a mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table.
[0074] If the first block mapping table does not exist in the preset memory, or if the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, a data read operation can be directly performed on the target data page to read the target data from the target data page, and the number of bit flips determined based on the target error correction code corresponding to the target data and sent by the controller of the target flash memory is obtained, and then it is determined whether the number of bit flips is greater than or equal to the preset bit flip threshold. If the number of bit flips is less than the preset bit flip threshold, it indicates that the number of bit flips is also less than the preset number of correctable bits, and at this time, the target data can be directly corrected based on the target error correction code to obtain the correct data after error correction.
[0075] If the number of bit flips is greater than or equal to the preset bit flip threshold, it indicates that the data in the target data page may be lost in the subsequent error correction process of the target data. At this time, the reserved data blocks that are idle and not bad blocks can be determined from the reserved area of the target flash memory, that is, the reserved data blocks are good blocks in the reserved area, and the data in the target data blocks where the target data page is located is backed up to the reserved data blocks, and then it is determined again whether the first block mapping table exists in the preset memory.
[0076] If the first block mapping table does not exist in the preset memory, it is necessary to first create the first block mapping table in the preset memory, establish a mapping relationship between the target data block and the reserved data block according to the data structure of the block mapping table, and store the mapping relationship between the target data block and the reserved data block in the first block mapping table, and then create a corresponding second block mapping table in the management area of the target flash memory based on the first block mapping table.
[0077] If there is a first block mapping table in the preset memory and there is no mapping relationship corresponding to the target data block in the first block mapping table, it is necessary to first establish a mapping relationship between the target data block and the reserved data block according to the data structure of the block mapping table, and store the mapping relationship between the target data block and the reserved data block in the first block mapping table, and update the second block mapping table in the management area of the target flash memory based on the first block mapping table.
[0078] Furthermore, after determining the data reading operation for the target data page in the user area of the target flash memory, if there is a first block mapping table in the preset memory and there is a mapping relationship corresponding to the target data block in the first block mapping table, then based on the mapping relationship corresponding to the target data block, the corresponding data block to be operated can be determined from the reserved area of the target flash memory, and then the data reading operation is performed on the corresponding data page in the data block to be operated.
[0079] Beneficial effect: The present invention partitions the target flash memory into a user area for storing user data, a reserved area for storing backup data, and a management area for storing block mapping tables, and sets a preset bit flip threshold that is less than a preset number of correctable bits, so that when a data read operation is performed on a target data page in the user area to read the target data, if the number of bit flips determined based on the error correction code corresponding to the target data is greater than or equal to the preset bit flip threshold, the data in the target data block where the target data page is located can be first backed up to a reserved data block in the reserved area that meets the preset conditions, and then the target data is corrected, so as to reduce the risk of data loss in the target data page when the number of bit flips is greater than the preset number of correctable bits, thereby improving the stability and security of the data in the target flash memory.
[0080] Take the data processing operation as a data writing operation or a data erasing operation as an example, see Figure 6 As shown, an embodiment of the present invention provides a data processing method, which is applied to a preset processor, comprising:
[0081] After determining the data write operation or data erase operation for the target data page in the user area of the target flash memory, it is necessary to determine whether there is a first block mapping table in the preset memory. If there is a first block mapping table in the preset memory, it is necessary to further determine whether there is a mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table.
[0082] If the first block mapping table does not exist in the preset memory, or if the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, a data write operation or a data erase operation can be directly performed on the target data page.
[0083] If there is a first block mapping table in the preset memory and there is a mapping relationship corresponding to the target data block in the first block mapping table, then based on the mapping relationship corresponding to the target data block, the corresponding data block to be operated can be determined from the reserved area of the target flash memory, and then a data write operation or a data erase operation can be performed on the corresponding data page in the data block to be operated.
[0084] Beneficial effects: The present invention partitions the target flash memory to divide the target flash memory into a user area for storing user data, a reserved area for storing backup data, and a management area for storing a block mapping table, and the block mapping table in the management area is synchronized with the block mapping table in the preset memory, so that when there is a first block mapping table in the preset memory and there is a mapping relationship corresponding to the target data block in the first block mapping table, the corresponding data block to be operated is determined from the reserved area of the target flash memory based on the mapping relationship, and a data write operation or a data erase operation is performed on the data block to be operated. In this way, the present invention can improve the stability of data in the target flash memory by setting a reserved area for storing backup data.
[0085] See also Figure 7 As shown, an embodiment of the present invention provides a data processing device, which is applied to a preset processor, including:
[0086] The processing operation determination module 11 is used to determine the data processing operation for the target data page in the user area of the target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro unit mode; the user area is used to store user data;
[0087] A bit flip number acquisition module 12 is used for, when there is no first block mapping table in the preset memory, or when there is the first block mapping table in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation, performing a data read operation on the target data page to read the target data from the target data page, and acquiring a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory;
[0088] The data backup module 13 is used to determine a reserved data block that meets the preset conditions from the reserved area of the target flash memory if the bit flip number is not less than a preset bit flip threshold, and back up the data in the target data block to the reserved data block, and use the first block mapping table to store the mapping relationship between the target data block and the reserved data block, and then correct the target data based on the size relationship between the bit flip number and the preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
[0089] Since the embodiments of the device part correspond to the above embodiments, please refer to the description of the embodiments of the method part for the embodiments of the device part, and will not be repeated here.
[0090] Beneficial effect: The present invention partitions a target flash memory using a nonlinear macro unit mode to divide the target flash memory into a user area for storing user data and a reserved area for storing backup data, and sets a preset bit flip threshold value that is less than a preset number of correctable bits, so that when a data read operation is performed on a target data page in the user area to read the target data, if the number of bit flips determined based on the error correction code corresponding to the target data is greater than or equal to the preset bit flip threshold value, the data in the target data block where the target data page is located can be first backed up to a reserved data block in the reserved area that meets the preset conditions, and then the target data is corrected based on the size relationship between the bit flip number and the preset number of correctable bits, so as to reduce the risk of data loss in the target data page when the bit flip number is greater than the preset number of correctable bits, thereby improving the stability of the data in the target flash memory.
[0091] Furthermore, the present application also discloses an electronic device. Figure 8 It is a structural diagram of an electronic device according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the data processing method disclosed in any of the aforementioned embodiments. In addition, the electronic device in this embodiment may specifically be an electronic computer.
[0092] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0093] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0094] The operating system 221 is used to manage and control various hardware devices on the electronic device and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the data processing method performed by the electronic device disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0095] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed data processing method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.
[0096] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0097] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0098] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0099] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0100] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data processing method, characterized in that: Applies to preset processors, including: Determine a data processing operation for a target data page in a user area of a target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro cell mode; and the user area is used to store user data; When the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation, a data read operation is performed on the target data page to read the target data from the target data page, and a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory is obtained; If the number of bit flips is not less than a preset bit flip threshold, a reserved data block that meets the preset conditions is determined from the reserved area of the target flash memory, and the data in the target data block is backed up to the reserved data block, and the mapping relationship between the target data block and the reserved data block is stored using the first block mapping table, and then the target data is corrected based on the size relationship between the number of bit flips and a preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
2. The data processing method according to claim 1, characterized in that: After determining the data processing operation for the target data page in the user area of the target flash memory, the method further includes: When the first block mapping table exists in the preset memory and there exists a mapping relationship corresponding to the target data block in the first block mapping table, a corresponding data block to be operated is determined from the reserved area based on the mapping relationship corresponding to the target data block, and the data processing operation is performed on the data block to be operated; wherein the data processing operation includes a data reading operation, a data writing operation and a data erasing operation.
3. The data processing method according to claim 1, characterized in that: Also includes: When the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and the first block mapping table does not have a mapping relationship corresponding to the target data block, if the data processing operation is not a data read operation, the data processing operation is performed on the target data page; wherein the data processing operation includes a data write operation and a data erase operation; Among them, if the data processing operation is a data writing operation, after performing the data writing operation on the target data page, the original error correction code is calculated based on the data written in the target data page, and the original error correction code is stored in the target free area corresponding to the target data page.
4. The data processing method according to claim 3, characterized in that: The performing of a data read operation on the target data page to read the target data from the target data page, and obtaining a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory, comprises: Performing a data read operation on the target data page to read target data from the target data page, so that the controller of the target flash memory calculates an error correction code on the target data to obtain a target error correction code, and determines a corresponding bit flip number based on a comparison result between the target error correction code and the original error correction code stored in the target free area; The bit flip number sent by the controller of the target flash memory is obtained.
5. The data processing method according to claim 1, characterized in that: The step of determining a reserved data block that meets a preset condition from the reserved area of the target flash memory includes: Based on the status identifier and the bad block identifier, a reserved data block that is in an idle state and is not a bad block is determined from each data block in the reserved area; wherein the bad block identifier for identifying whether the data block is a bad block and the status identifier for identifying the current state of the data block are stored in the idle area corresponding to any data page in the data block.
6. The data processing method according to claim 1, characterized in that: Before determining the data processing operation for the target data page in the user area of the target flash memory, the method further includes: Traversing the management area of the target flash memory to determine the first data block in the management area as the current data block, and to determine the first data page in the current data block as the current data page, and to read the current data page, and to determine whether the read block mapping table identifier is a preset identifier; wherein the management area is used to store a block mapping table; If the block mapping table identifier read is the preset identifier, it indicates that the second block mapping table corresponding to the block mapping table identifier is a valid block mapping table, and creates the corresponding first block mapping table in the preset memory based on the second block mapping table, and then ends the traversal of the management area; If the block mapping table identifier is not read or the read block mapping table identifier is not the preset identifier, determining whether the current data page is the last data page in the current data block; If the current data page is not the last data page in the current data block, determining the next data page in the current data block as a new current data page, and jumping back to the step of reading the current data page; If the current data page is the last data page in the current data block, determining whether the current data block is the last data block in the management area; If the current data block is not the last data block in the management area, the next data block in the management area is determined as a new current data block, and the process jumps again to the step of determining the first data page in the current data block as the current data page; If the current data block is the last data block in the management area, the traversal of the management area is terminated.
7. The data processing method according to claim 6, characterized in that: The storing the mapping relationship between the target data block and the reserved data block by using the first block mapping table includes: When the first block mapping table does not exist in the preset memory, creating the first block mapping table in the preset memory, storing the mapping relationship between the target data block and the reserved data block in the first block mapping table, and creating the corresponding second block mapping table in the management area based on the first block mapping table; Or, when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block in the first block mapping table, the mapping relationship between the target data block and the reserved data block is stored in the first block mapping table, and the second block mapping table in the management area is updated based on the first block mapping table.
8. A data processing device, characterized in that: Applies to preset processors, including: A processing operation determination module, used to determine a data processing operation for a target data page in a user area of a target flash memory; wherein the target flash memory is a flash memory using a nonlinear macro cell mode; and the user area is used to store user data; A bit flip number acquisition module, for performing a data read operation on the target data page to read the target data from the target data page, and acquiring a bit flip number determined based on a target error correction code corresponding to the target data and sent by a controller of the target flash memory, when the first block mapping table does not exist in the preset memory, or when the first block mapping table exists in the preset memory and there is no mapping relationship corresponding to the target data block where the target data page is located in the first block mapping table, if the data processing operation is a data read operation; A data backup module, for determining a reserved data block that meets a preset condition from a reserved area of the target flash memory if the bit flip number is not less than a preset bit flip threshold, backing up the data in the target data block to the reserved data block, and storing a mapping relationship between the target data block and the reserved data block using the first block mapping table, and then correcting the target data based on a size relationship between the bit flip number and a preset number of correctable bits; wherein the preset bit flip threshold is less than the preset number of correctable bits.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the data processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Data storage method and device, storage medium and electronic device
CN119806435A
Data storage method, device, storage medium and electronic device
CN119806435B
