A data read-write method and device

By inspecting and rewriting flipped data blocks in flash memory, the problem of adjacent block bit flipping caused by flash memory writing is solved, improving data read/write efficiency and storage space utilization.

CN115437566BActive Publication Date: 2026-02-06HANGZHOU HUACHENG SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211017965.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-24
Publication Date
2026-02-06
Estimated Expiration
2042-08-24

AI Technical Summary

Technical Problem

Due to the physical characteristics of flash memory, writing data blocks may cause bit flipping in adjacent physical blocks, especially in compressed file systems, leading to abnormal file system mounting and affecting data read and write efficiency.

Method used

When writing data, check whether the previous physical block of the current physical block has undergone bit flipping, and rewrite the data block that has been flipped into the next physical block. At the same time, record the index mapping relationship between the data block and the physical block, and mark the flipped block as an isolated block to avoid further interference.

Benefits of technology

This avoids data anomalies in adjacent physical blocks, shortens data read/write time, improves data read/write efficiency, and optimizes the utilization of flash memory storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115437566B_ABST
    Figure CN115437566B_ABST
Patent Text Reader

Abstract

The application discloses a data read-write method and device, which is used for shortening the time required for data read-write by using non-type flash memory, improving data read-write efficiency and non-type flash memory space utilization. The application provides a method for writing data into non-type flash memory, which comprises the following steps: writing a current data block into a current physical block of the non-type flash memory; when the current physical block is not the first physical block of the non-type flash memory, checking whether bit flipping occurs in a data block in a previous physical block of the current physical block; and when bit flipping occurs in the data block in the previous physical block, re-writing an original data block previously written into the previous physical block into a next physical block of the current physical block.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, and in particular to a data read-write method and device. BACKGROUND

[0002] Due to the physical characteristics of hardware implementation, flash performs read-write operation on a physical block. When data blocks are written into a certain physical block, a bit flip of a data block stored in a physical block adjacent to the physical block may occur. If a compressed file system, such as squashfs (compressed read-only file system), is stored on the flash, the bit flip of the data block may cause failure of decompression and reading of data, thereby causing abnormal mounting and starting of the file system. SUMMARY

[0003] Embodiments of the present application provide a data read-write method and device, which rewrites a data block with a bit flip into a next physical block when writing data into a non-type flash, thereby avoiding data abnormality in adjacent physical blocks during the process of writing data into the non-type flash, shortening the time required for data read-write, and improving the data read-write efficiency.

[0004] A method for writing data into a non-type flash provided by an embodiment of the present application includes:

[0005] writing a current data block into a current physical block of the non-type flash;

[0006] when the current physical block is not the first physical block of the non-type flash, checking whether a data block in a previous physical block of the current physical block has a bit flip;

[0007] when the data block in the previous physical block has the bit flip, rewriting an original data block previously written into the previous physical block into a next physical block of the current physical block.

[0008] By the method, the current data block is written into the current physical block of the non-type flash; when the current physical block is not the first physical block of the non-type flash, whether the data block in the previous physical block of the current physical block has the bit flip is checked; and when the data block in the previous physical block has the bit flip, the original data block previously written into the previous physical block is rewritten into the next physical block of the current physical block, thereby avoiding data abnormality in adjacent physical blocks during the process of writing data into the current physical block.

[0009] In some embodiments, the method further includes:

[0010] For each data block written into the non-type flash memory, a mapping relationship between the data block and a physical block where the data block is last written is recorded.

[0011] By the method, a mapping relationship between each data block and a physical block where the data block is last written is established, so that the actual corresponding physical block of the data block can be found according to the mapping relationship when the data is read subsequently.

[0012] In some embodiments, when the data block in the previous physical block has a bit flip, the method further comprises:

[0013] The previous physical block is marked as an isolated block.

[0014] By the method, the physical block corresponding to the data block having a bit flip is marked as an isolated block, and no data is written into the physical block, so as to avoid interference with the data blocks written previously.

[0015] In some embodiments, when the current physical block is not the first physical block of the non-type flash memory, whether the data block in the previous physical block of the current physical block has a bit flip is checked, comprising:

[0016] When the current physical block is not the first physical block of the non-type flash memory, and the previous physical block of the current physical block is not an isolated block, whether the data block in the previous physical block of the current physical block has a bit flip is checked.

[0017] By the method, the checking of whether the data block in the first physical block and the isolated block has a bit flip is excluded, so that the number of checks is reduced, and the data writing efficiency is improved.

[0018] In some embodiments, when the data block in the previous physical block has a bit flip, the method further comprises:

[0019] The data in the current physical block is erased, and the current data block is written into the current physical block again.

[0020] By the method, interference caused when the original data block in the previous physical block is written into the next physical block of the current physical block again can be avoided.

[0021] In some embodiments, if the current data block is the last data block to be written into the non-type flash memory, after the current data block is written into the current physical block again, the method further comprises:

[0022] Whether the data block in the next physical block has a bit flip is checked.

[0023] When bit flipping occurs in the data block in the next physical block, the original data block previously written in the previous physical block is re-written in the next physical block of the next physical block.

[0024] By this method, the cyclic write disturb check can be avoided.

[0025] Another embodiment of the present application provides a method for reading data from a non-type flash memory, comprising:

[0026] Obtaining an index mapping relationship between data blocks and physical blocks; wherein, the index mapping relationship is an index mapping relationship between each data block written in the non-type flash memory and the physical block where the data block is last written, recorded in the process of writing data into the non-type flash memory;

[0027] According to the index mapping relationship, reading a data block from the non-type flash memory.

[0028] By this method, the actual physical block corresponding to the data block is determined according to the index mapping relationship, so that the data reading efficiency and accuracy are improved.

[0029] Another embodiment of the present application provides a data reading and writing device, comprising a memory and a processor, wherein the memory is used to store program instructions, and the processor is used to call the program instructions stored in the memory to perform any of the above methods according to the obtained program.

[0030] Another embodiment of the present application provides an electronic device comprising the data reading and writing device.

[0031] In addition, according to the embodiments, for example, a computer program product for a computer is provided, which comprises software code portions for performing the steps of the above-defined method when the product is running on a computer. The computer program product can comprise a computer-readable medium on which the software code portions are stored. Furthermore, the computer program product can be directly loadable into the internal memory of the computer and / or transmittable via a network by means of at least one of a upload process, a download process and a push process.

[0032] Another embodiment of the present application provides a computer-readable storage medium, which stores computer executable instructions, and the computer executable instructions are used to make the computer execute any of the above methods. BRIEF DESCRIPTION OF DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative effort based on these drawings.

[0034] Figure 1 A schematic diagram of writing a data block into a physical block to cause bit flips of the data block before and after the data block is provided for the embodiments of the present application;

[0035] Figure 2 A schematic diagram of a method for writing a data block into a physical block is provided for the embodiments of the present application;

[0036] Figure 3 A schematic diagram of a flow of a method for writing data into a non-type flash memory is provided for the embodiments of the present application;

[0037] Figure 4 A schematic diagram of a flow of a method for reading data from a non-type flash memory is provided for the embodiments of the present application;

[0038] Figure 5 A specific flow of a method for writing data into a non-type flash memory is provided for the embodiments of the present application;

[0039] Figure 6 A specific flow of a method for writing data into a non-type flash memory is provided for the embodiments of the present application;

[0040] Figure 7a A schematic diagram of writing a data block 1 into a physical block 1 is provided for the embodiments of the present application;

[0041] Figure 7b A schematic diagram of re-writing a data block 2 that has bit flips into a physical block 4 is provided for the embodiments of the present application;

[0042] Figure 8 A specific flow of another method for writing data into a non-type flash memory is provided for the embodiments of the present application;

[0043] Figure 9a A schematic diagram of writing a data block 3 into a physical block 3 is provided for the embodiments of the present application;

[0044] Figure 9b A schematic diagram of a data block 3 having bit flips is provided for the embodiments of the present application;

[0045] Figure 9c A schematic diagram of re-writing a data block 3 that has bit flips into a physical block 5 is provided for the embodiments of the present application;

[0046] Figure 9dA schematic diagram of writing a data block 5 to a physical block 6 is provided for an embodiment of the present application;

[0047] Figure 10 A schematic diagram of another specific process of writing data to a non-type flash memory is provided for an embodiment of the present application;

[0048] Figure 11 A schematic diagram of a specific process of reading data from a non-type flash memory is provided for an embodiment of the present application;

[0049] Figure 12 A schematic diagram of a structure of a data reading and writing device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0050] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.

[0051] The embodiments of the present application provide a data reading and writing method and device, which rewrites a data block with bit flips into a next physical block when writing data to a non-type flash memory, so as to avoid data abnormality in adjacent physical blocks during the process of writing data to the non-type flash memory, shorten the time length required for data reading and writing, and improve the data reading and writing efficiency.

[0052] The method and the device are based on the same application concept, and the implementation of the device and the method can be referred to each other because the principles of solving problems are similar, and the repeated parts will not be described again.

[0053] The terms "first", "second", and the like (if any) in the specification and claims of the embodiments of the present application and the above drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product, or device.

[0054] The following examples and embodiments will be understood only as illustrative examples. Although the present description can refer to "an", "one", or "some" example or embodiment at several locations, this does not mean that each such reference is referring to the same example or embodiment, nor is this feature only applicable to a single example or embodiment. Individual features of different embodiments can also be combined to provide other embodiments. Furthermore, terms such as "comprising" and "including" should be understood as not limiting the described embodiments to only those consisting of the features mentioned; such examples and embodiments can also include features, structures, units, modules, etc. that are not specifically mentioned.

[0055] The various embodiments of the present application are described in detail below with reference to the accompanying drawings. It should be noted that the order of display of the embodiments of the present application only represents the order of the embodiments, and does not represent the advantages and disadvantages of the technical solutions provided by the embodiments.

[0056] It should be noted that in the technical solutions provided by the embodiments of the present application, the storage unit in the Nor flash to which the data block is written is referred to as a physical block, and the data block in the previous physical block of the current physical block is checked for bit flipping, and the data block with bit flipping is re-written to the next physical block of the current physical block, but it is not limited thereto.

[0057] Nor flash (non-type flash memory) performs read and write operations in units of physical blocks. For example, in the data upgrade process, the process of writing data blocks to a certain physical block may cause bit flipping of data blocks in the previous and next physical blocks of the current physical block where the data is written, as shown in Figure 1 When data block 3 is written to physical block 3, it may cause bit flipping of previous and next data blocks 2 and 4. Nand flash (Nand type flash memory) usually uses ECC (Error Correction Code) algorithm for error detection and data correction, which can identify the interference block, so that the bit flipping caused by write interference can be eliminated by not using the interference block for data storage, i.e. marking physical block 3 as an interference block and no longer writing data blocks. However, Nor flash itself has limited space and no ECC error correction function, and if multiple data upgrades are performed, more interference blocks will be generated and cannot be used, resulting in less and less available storage space of Nor flash.

[0058] To solve the above problems, the embodiment of the present application provides a data read-write method and device. In the data upgrading process, after writing the data block into the current physical block, it is checked whether the data block in the previous physical block is damaged. If the data block is damaged, the previous physical block is marked as an isolated block, and no new data block is written into the isolated block, so as to avoid the interference of the isolated block to the data block in the previous physical block when the isolated block is written into the data block again, to avoid the bit flip of the data block in the previous physical block, to reduce the number of data block reading and checking, to shorten the time length of data upgrading, and to avoid the reduction of the utilization rate of Nor flash space. Referring to Figure 2 For example, the data block 3 which is subjected to bit flip is written into the physical block 5, the data block 4 in the physical block 4 is erased, and the data block 4 is written into the physical block 4 which has been erased, to avoid the interference caused by writing the data block 3 into the physical block 5, and to avoid the problem of the reduction of the utilization rate of Nor flash space, and to improve the utilization rate of the storage space of Nor flash.

[0059] Referring to Figure 3 The embodiment of the present application provides a method for writing data into a non-type flash memory, which comprises the following steps.

[0060] Step S11, writing a current data block into a current physical block of the non-type flash memory.

[0061] In the above, the current data block is, for example, the data block N, the current physical block is, for example, the physical block M, and N and M represent numbers.

[0062] Step S12, when the current physical block is not the first physical block of the non-type flash memory, checking whether the data block in the previous physical block of the current physical block is subjected to bit flip.

[0063] In the above, the previous physical block is, for example, the physical block (M-1), and the bit flip refers to the damage of data.

[0064] Step S13, when the data block in the previous physical block is subjected to bit flip, re-writing the original data block which has been written into the previous physical block into the next physical block of the current physical block.

[0065] In the above, the original data block refers to the correct data block which is not damaged, and the next physical block is, for example, the physical block (M+1).

[0066] Through step S13, the data block subjected to bit flip is written into the next physical block of the current physical block, so that the flip abnormality caused by writing data can be avoided.

[0067] In order to facilitate subsequent reading of data from the non-type flash memory, in some embodiments, the above method further comprises the following steps.

[0068] For each data block written in the non-type flash memory, record the index mapping relationship between the data block and the physical block where the data block is last written.

[0069] It should be noted that the index mapping relationship can be stored in any physical block, for example, the first physical block can also be the last physical block, which is not limited here, as long as the storage location is agreed with the upper layer application in advance when reading and writing data.

[0070] In order to avoid interfering with the data block written in the front, in some embodiments, when the data block in the previous physical block is flipped, the above method further comprises:

[0071] Mark the previous physical block as an isolation block.

[0072] In order to reduce the number of checks and shorten the time required for data upgrade, in some embodiments, when the current physical block is not the first physical block of the non-type flash memory, checking whether the data block in the previous physical block of the current physical block is flipped, comprising:

[0073] When the current physical block is not the first physical block of the non-type flash memory, and the previous physical block of the current physical block is not an isolation block, check whether the data block in the previous physical block of the current physical block is flipped.

[0074] In order to avoid interference when the original data block in the previous physical block is re-written into the next physical block of the current physical block, in some embodiments, when the data block in the previous physical block is flipped, the above method further comprises:

[0075] Erase the data in the current physical block, and re-write the current data block into the current physical block.

[0076] It should be noted that the data in the current physical block can be erased and the current data block can be re-written into the current physical block after the original data block in the previous physical block is re-written into the next physical block of the current physical block; or the data in the current physical block can be erased and the current data block can be re-written into the current physical block at the same time as the original data block in the previous physical block is re-written into the next physical block of the current physical block.

[0077] In order to avoid performing a loop write interference check, in some embodiments, if the current data block is the last data block to be written in the non-type flash memory, after re-writing the current data block into the current physical block, the method further comprises:

[0078] Check whether the data block in the next physical block is flipped;

[0079] When a bit flip occurs in the data block in the next physical block, the original data block written in the previous physical block is re-written in the next physical block in the next physical block.

[0080] Referring to Figure 4 The embodiment of the present application provides a method for reading data from a non-type flash memory, comprising:

[0081] Step S21, obtaining an index mapping relationship between a data block and a physical block; wherein the index mapping relationship is an index mapping relationship between the data block and a physical block to which the data block is last written, recorded in the process of writing data into the non-type flash memory for each data block written into the non-type flash memory;

[0082] Wherein, obtaining the index mapping relationship between the data block and the physical block means reading the index mapping relationship from a previously agreed storage location (for example, the last physical block);

[0083] Step S22, reading the data block from the non-type flash memory according to the index mapping relationship.

[0084] Through step S22, the physical block actually corresponding to the data block is determined according to the index mapping relationship.

[0085] It should be noted that when reading data from the non-type flash memory, data can also be read from a physical block that is not marked as an isolated block, not only according to the index mapping relationship.

[0086] The following gives several embodiments of specific method processes.

[0087] Embodiment one:

[0088] Referring to Figure 5 The embodiment of the present application provides a specific process of a method for writing data into a non-type flash memory, comprising:

[0089] Step S101, in the data partition upgrade (i.e. when the software program is upgraded, the software program data is written into the corresponding partition according to the order) scenario, write the current data block N (the data block is also called a logical block) into the physical block M, record the index mapping relationship between the data block N and the physical block M, see Table 1 below:

[0090] Data block number Physical block number N M

[0091] Table 1

[0092] Wherein, the logical block refers to the data block stored on the disk; the physical block is the access unit of data on the disk; N and M can take the same value or different values; the index mapping relationship, when the upper application needs to read the data block, the actual storage physical block of the data block can be quickly found according to the index mapping relationship;

[0093] Step S102, judge whether the current written data block N is data block 1, if yes (i.e. the corresponding physical block of the written data is physical block 1), proceed to step S103; if not, proceed to step S104;

[0094] Step S103, continue to write data block 2 in the next physical block (i.e. physical block (M+1)), record the index mapping relationship between data block 2 and physical block (M+1), see Table 2 below;

[0095] Data block number Physical block number 2 M+1

[0096] Table 2

[0097] Step S104, read data block (N-1) in the previous physical block (M-1), judge whether data block (N-1) has bit flip, if data block (N-1) has bit flip, proceed to step S105; if normal (i.e. data block (N-1) has no bit flip), proceed to step S107;

[0098] Wherein, the judgment of whether data block (N-1) has bit flip is by comparing data block (N-1) with the original data block (N-1) before writing into the physical block, to check whether data block (N-1) has data damage;

[0099] Step S105, mark physical block (M-1) as isolated block, and re-write data block (N-1) into the next physical block (i.e. physical block (M+1)), and record the corresponding index mapping relationship between data block (N-1) and physical block (M+1) (i.e. update the index mapping relationship between data block (N-1) and physical block (M-1) to the index mapping relationship between data block (N-1) and physical block (M+1)), see Table 3 below:

[0100] Data block number Physical block number N-1 M+1

[0101] Table 3

[0102] Therefore, when the upper application needs to read data block (N-1), the index mapping relationship can be used to quickly find that data block (N-1) is actually stored in physical block (M+1) instead of physical block (M-1), thereby ensuring the accuracy of reading data.

[0103] For example, N=2, M=2, the above-mentioned writing 2nd data block, checking 1st data block, 1st data block has bit flip, re-writing 1st data block into 3rd physical block, the index mapping relationship between 1st data block and 3rd physical block, see Table 4 below:

[0104] Data block number Physical block number 1 3

[0105] Table 4

[0106] It should be noted that before the completion of the current data partition upgrade, the physical block (M-1) will be used as an isolation block, and no new data block will be written into it, so as to avoid interference with the data block in the physical block (M-2) when the new data block is written into it. At the same time, in order to avoid the interference with the data block N after the data block (N-1) is written into the physical block (M+1), the data block N in the physical block M can be erased and then re-written, because the data block in the isolation block has been re-written into the physical block (M+1), and the re-writing of the data block N will not affect the upper-layer data acquisition even if it interferes with the isolation block.

[0107] When the next data partition upgrade is performed, the data blocks in the Nor flash will be erased, so that the isolation block can be used to write data blocks again, and thus the situation that the space of the Nor flash is used less and less after multiple data partition upgrades can be avoided.

[0108] The reason why the physical block M is not used as an isolation block is that if the physical block M is used as an isolation block, in order to improve the utilization rate of the physical block, the interfered physical block (M-1) needs to be re-written with data blocks, and when the new data block is written, it may interfere with the data block in the physical block (M-2) and cause bit flipping, thereby causing more bit flipping of the previously written data blocks. Therefore, the physical block (M-1) is selected as an isolation block, which reduces the number of times of reading and checking the data blocks during the data upgrade, and thus shortens the time length of the data upgrade.

[0109] In step S106, the data block N in the physical block M is erased, and the data block N is re-written into the physical block M in which the data has been erased, so as to avoid the interference with the data block N in the physical block M caused by the writing of the data block (N-1) into the physical block (M+1) in step S105;

[0110] It should be noted that instead of reading the data block N first, checking whether the bit flipping of the data block N occurs, and then determining whether the data block N needs to be re-written, the data block N is directly erased and then re-written, so as to omit the checking step and simplify the process;

[0111] In step S107, a new data block is continuously written into the next physical block, and the index mapping relationship between the data block and the physical block is recorded.

[0112] It should be noted that if the bit flipping of the data block (N-1) occurs in the above step S104, the data block (N+1) is written into the physical block (M+2) in this step; if the bit flipping of the data block (N-1) does not occur in the above step S104, the data block (N+1) is written into the physical block (M+1) in this step.

[0113] It should be noted that all subsequent steps are based on the premise that the data block (N-1) in step S104 has undergone bit flipping, that is, the data block (N+1) is written into the physical block (M+2);

[0114] Step S108: Determine whether data block (N+1) is the last data block written. If yes, proceed to step S109; otherwise, continue with the corresponding checks and subsequent steps in step S104.

[0115] Step S109: Determine whether the physical block (M+1) preceding the data block (N+1) is an isolation block. If yes, proceed to step S113; otherwise, proceed to step S110.

[0116] It should be noted that if physical block (M+1) is an isolated block, after writing data block (N+1) into physical block (M+2), there is no need to check whether it has interfered with the data blocks in the isolated block;

[0117] Step S110: Check whether bit flipping has occurred in data block (N-1) in physical block (M+1). If bit flipping has occurred, proceed to step S111; if normal, proceed to step S113.

[0118] Step S111: Mark physical block (M+1) as an isolated block, and rewrite data block (N-1) into the next physical block, i.e., physical block (M+3). Record the index mapping relationship between data block (N-1) and physical block (M+3), as shown in Table 5 below:

[0119] Data block number Physical block number N-1 M+3

[0120] Table 5

[0121] Step S112: Erase the data block (N+1) in physical block (M+2) and rewrite the data block (N+1) into the physical block (M+2) whose data has been erased;

[0122] Step S113: Write the corresponding index mapping relationship between each data block and its final physical block into the data file partition record, i.e., the last physical block.

[0123] It should be noted that during the next data partition upgrade, the data blocks in each physical block will be erased, and the data blocks from 1 to N will be written into the physical blocks one by one. Therefore, the index mapping relationship established by the previous data partition upgrade will be cleared, and the skipped isolation blocks can be reused. This can avoid the situation where the Nor flash space becomes less and less due to multiple data partition upgrades.

[0124] Example 2:

[0125] SeeFigure 6 The embodiment of the application provides a specific process for writing data into a non-type flash memory. It is known that in a certain data upgrade, four data blocks (corresponding to numbers 1, 2, 3 and 4) need to be sequentially written into physical blocks (corresponding to numbers 1, 2, 3, 4 and 5). After writing the data block 2, the data block 1 in the physical block 1 is checked. The data block 1 does not occur bit flipping. The specific steps include the following steps.

[0126] Step S201, write the data block 1 into the physical block 1. Referring to FIG. 1, Figure 7a Record the index mapping relationship between the data block 1 and the physical block 1. Referring to Table 6 below:

[0127] Data block number Physical block number 1 1

[0128] Table 6

[0129] Step S202, write the data block 2 into the physical block 2. Record the index mapping relationship between the data block 2 and the physical block 2. Referring to Table 7 below:

[0130] Data block number Physical block number 2 2

[0131] Table 7

[0132] Step S203, read the data block 1 and check whether the data block 1 occurs bit flipping. It is found that the data block 1 does not occur bit flipping. The data block 1 is completed to be written.

[0133] Wherein, the completion of writing means that when other data blocks are subsequently written, the data block, that is, the data block 1, does not need to be checked again whether bit flipping occurs;

[0134] Step S204, write the data block 3 into the physical block 3. Record the index mapping relationship between the data block 3 and the physical block 3. Referring to Table 8 below:

[0135] Data block number Physical block number 3 3

[0136] Table 8

[0137] Step S205, read the data block 2 and check whether the data block 2 occurs bit flipping. It is found that the data block 2 occurs bit flipping. The physical block 2 is marked as an isolated block, that is, the data in the physical block 2 is not read.

[0138] Step S206, write the data block 2 into the physical block 4. Referring to FIG. 4, Figure 7b Record the index mapping relationship between the data block 2 and the physical block 4. Referring to Table 9 below:

[0139] Data block number Physical block number 2 4

[0140] Table 9

[0141] Step S207, erasing the data block 3 in the physical block 3, and re-writing the data block 3 into the physical block 3 where the data is erased, and the data block 3 is completed to be written;

[0142] Step S208, writing the data block 4 into the physical block 5, and recording the index mapping relationship between the data block 4 and the physical block 5, see Table 10 below:

[0143] Data block number Physical block number 4 5

[0144] Table 10

[0145] Step S209, determining that the data block 4 is the last data block, and determining that the physical block 4 is not an isolated block;

[0146] Step S210, reading the data block 2, checking whether the data block 2 in the physical block 5 is bit-flipped, that is, checking whether the process of writing the data block 4 into the physical block 5 causes the data block 2 in the physical block 4 to be bit-flipped, if the data block 2 is not bit-flipped, the data blocks 2 and 4 are completed to be written;

[0147] Step S211, writing the index mapping relationship between each data block and the physical block where it is finally written, that is, Table 6, 8, 9, 10, into the last physical block, that is, the physical block 5.

[0148] Embodiment three:

[0149] Referring to Figure 8 , another specific process of writing data into a non-type flash memory provided by the embodiment of the application is provided, in a certain data upgrade (data block numbers 1, 2, 3, 4, 5, physical block numbers 1, 2, 3, 4, 5, 6, 7), after writing the data block 3, the data block 2 in the physical block 2 is checked, and the data block 2 is not bit-flipped, and the specific steps include:

[0150] Step S301, writing the data block 3 into the physical block 3, see Figure 9a , recording the index mapping relationship between the data block 3 and the physical block 3;

[0151] Step S302, reading the data block 2, checking whether the data block 2 is bit-flipped, and finding that the data block 2 is normal, and the data block 2 is completed to be written;

[0152] Step S303, writing the data block 4 into the physical block 4, and recording the index mapping relationship between the data block 4 and the physical block 4;

[0153] Step S304, reading the data block 3, checking whether the data block 3 is bit-flipped, and finding that the data block 3 is bit-flipped, see Figure 9b , marking the physical block 3 as an isolated block;

[0154] Step S305, write data block 3 into physical block 5, refer to Figure 9c record the index mapping relationship between data block 3 and physical block 5;

[0155] Step S306, erase data block 4 in physical block 4, and write data block 4 into the physical block 4 after erasing data, and data block 4 is completed;

[0156] Step S307, write data block 5 into physical block 6, refer to Figure 9d record the index mapping relationship between data block 5 and physical block 6;

[0157] Step S308, determine that data block 5 is the last data block, and determine that physical block 5 is not an isolated block;

[0158] Step S309, check whether data block 3 in physical block 5 has bit flip, that is, check whether the process of writing data block 5 into physical block 6 causes data block 3 in physical block 5 to have bit flip, if data block 3 does not have bit flip, data block 3, 5 is completed;

[0159] Step S310, write the index mapping relationship between each data block and the physical block where it is finally written into physical block 7.

[0160] Embodiment four:

[0161] Refer to Figure 10 Another specific process for writing data into non-type flash memory provided by the embodiment of the application is provided, it is known that in a certain data upgrade, four data blocks (corresponding to numbers 1, 2, 3, 4) need to be sequentially written into physical blocks (corresponding to numbers 1, 2, 3, 4, 5, 6, 7), after writing data block 2, check data block 1 in physical block 1, data block 1 has bit flip, the specific steps include:

[0162] Step S401, write data block 1 into physical block 1, record the index mapping relationship between data block 1 and physical block 1;

[0163] Step S402, write data block 2 into physical block 2, record the index mapping relationship between data block 2 and physical block 2;

[0164] Step S403, check whether data block 1 has bit flip, find that data block 1 has bit flip, mark physical block 1 as an isolated block;

[0165] Step S404, write data block 1 into physical block 3 again, record the index mapping relationship between data block 1 and physical block 3;

[0166] Step S405, erasing the data block 2 in the physical block 2, and re-writing the data block 2 into the physical block 2 in which the data is erased, and the data block 2 is completed to be written;

[0167] Step S406, writing the data block 3 into the physical block 4, and recording the index mapping relationship between the data block 3 and the physical block 4;

[0168] Step S407, checking whether the data block 1 has bit flip, and finding that the data block 1 has bit flip, marking the physical block 3 as an isolated block;

[0169] Step S408, re-writing the data block 1 into the physical block 5, and recording the index mapping relationship between the data block 1 and the physical block 5;

[0170] Step S409, erasing the data block 3 in the physical block 4, and re-writing the data block 3 into the physical block 4 in which the data is erased, and the data block 3 is completed to be written;

[0171] Step S410, writing the data block 4 into the physical block 6, and recording the index mapping relationship between the data block 4 and the physical block 6;

[0172] Step S411, determining that the data block 4 is the last data block, and determining that the physical block 5 is not an isolated block;

[0173] Step S412, checking whether the data block 1 in the physical block 5 has bit flip, and finding that the data block 1 has bit flip, and marking the physical block 5 as an isolated block;

[0174] Step S413, re-writing the data block 1 into the physical block 7, and recording the index mapping relationship between the data block 1 and the physical block 7, and then the data block 1 is completed to be written;

[0175] Step S414, erasing the data block 4 in the physical block 6, and re-writing the data block 4 into the physical block 6 in which the data is erased, and then the data block 4 is completed to be written; and checking whether the data block 1 in the physical block 7 is caused to have bit flip in the process of executing the step, if not, the writing of all data blocks is completed; if flip occurs, writing the data block 1 into the physical block 8, that is, writing the data block 1 to be spaced one physical block from the data block 4 in the physical block 6, so as to avoid the data block 1 re-written into the physical block 8 from interfering the data block 4 again;

[0176] Step S415, writing the index mapping relationship between each data block and the physical block in which the data block is finally written into the physical block 8.

[0177] Embodiment five:

[0178] Referring to Figure 11The specific flow of reading data from the non-type flash memory provided by the embodiment of the application is as follows: it is known that in a certain data upgrade, four data blocks are written into a physical block, and the index mapping relationship between each physical block and the physical block where it is finally written is saved in the physical block 8, as shown in Table 11 below. The specific steps include:

[0179] Data block number Physical block number 1 7 2 2 3 4 4 6

[0180] Table 11

[0181] Step S501, receiving a data reading request, reading the index mapping relationship in the physical block 8;

[0182] Step S502, determining that the data blocks 1, 2, 3 and 4 are respectively stored in the physical blocks 7, 2, 4 and 6 according to the index mapping relationship;

[0183] Step S503, reading the data blocks 1, 2, 3 and 4 from the physical blocks 7, 2, 4 and 6 respectively.

[0184] The following describes the device or apparatus provided by the embodiment of the application, and the explanation or illustration of the same or corresponding technical features in the above method will not be repeated.

[0185] Referring to Figure 12 The data reading and writing apparatus provided by the embodiment of the application includes a processor 600 and a memory 620.

[0186] When writing data:

[0187] The processor 600 is configured to read the program in the memory 620 and perform the following process:

[0188] write the current data block into the current physical block of the non-type flash memory;

[0189] When the current physical block is not the first physical block of the non-type flash memory, check whether the data block in the previous physical block of the current physical block has bit flip;

[0190] When the data block in the previous physical block has bit flip, re-write the original data block written into the previous physical block into the next physical block of the current physical block.

[0191] In some embodiments, the processor 600 is further configured to read the program in the memory 620 and perform the following process:

[0192] For each data block written into the non-type flash memory, record the index mapping relationship between the data block and the physical block where the data block is written last time.

[0193] In some embodiments, when a bit flip occurs in the data block in the previous physical block, the processor 600 is further configured to read a program in the memory 620 to perform the following process:

[0194] marking the previous physical block as an isolated block.

[0195] In some embodiments, when the current physical block is not the first physical block of the non-type flash memory, the processor 600 is configured to check whether a bit flip occurs in the data block in the previous physical block of the current physical block, including:

[0196] when the current physical block is not the first physical block of the non-type flash memory, and the previous physical block of the current physical block is not an isolated block, checking whether a bit flip occurs in the data block in the previous physical block of the current physical block.

[0197] In some embodiments, when a bit flip occurs in the data block in the previous physical block, the processor 600 is further configured to read a program in the memory 620 to perform the following process:

[0198] erasing the data in the current physical block and re-writing the current data block into the current physical block.

[0199] In some embodiments, if the current data block is the last data block to be written into the non-type flash memory, after re-writing the current data block into the current physical block, the processor 600 is further configured to read a program in the memory 620 to perform the following process:

[0200] checking whether a bit flip occurs in the data block in the next physical block;

[0201] when a bit flip occurs in the data block in the next physical block, re-writing the original data block written into the previous physical block into the next physical block of the next physical block again.

[0202] When reading data:

[0203] In some embodiments, the processor 600 is configured to read a program in the memory 620 to perform the following process:

[0204] obtaining an index mapping relationship between the data block and the physical block; wherein the index mapping relationship is an index mapping relationship between the data block and the physical block recorded for each data block written into the non-type flash memory in the process of writing data into the non-type flash memory;

[0205] reading the data block from the non-type flash memory according to the index mapping relationship.

[0206] In some embodiments, the data reading and writing apparatus provided by the embodiments of the present application further comprises a transceiver 610 configured to receive and send data under the control of the processor 600.

[0207] wherein, in Figure 12 The bus architecture can include any number of interconnected buses and bridges, specifically the various circuitry of the processor 600 and the memory 620 represented by one or more processors and memory, respectively. The bus architecture can also link various other circuitry, such as peripheral devices, voltage regulators, and power management circuitry, which are well known in the art and thus, not further described herein. The bus interface provides an interface to the transceiver 610, which can be a plurality of elements, i.e., including a transmitter and a receiver, providing a means for communicating with various other apparatus over a transmission medium.

[0208] In some embodiments, the data reading and writing apparatus provided by the embodiments of the present application further includes a user interface 630, which can be an interface capable of externally connecting the required device, and the connected device includes but is not limited to a keypad, a display, a speaker, a microphone, a joystick, etc.

[0209] The processor 600 is responsible for managing the bus architecture and general processing, and the memory 620 can store data used by the processor 600 in performing operations.

[0210] In some embodiments, the processor 600 can be a CPU (Central Processor Unit), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or a CPLD (Complex Programmable Logic Device).

[0211] The embodiments of the present application provide an electronic device, which can be a desktop computer, a portable computer, a smart phone, a tablet computer, a personal digital assistant (PDA) and the like. The electronic device can include a central processing unit (CPU), a memory, an input / output device and the like, the input device can include a keyboard, a mouse, a touch screen and the like, and the output device can include a display device, such as a liquid crystal display (LCD), a cathode ray tube (CRT) and the like.

[0212] The memory can include a read-only memory (ROM) and a random access memory (RAM), and provide the processor with program instructions and data stored in the memory. In the embodiments of the present application, the memory can be used to store the programs of any method provided by the embodiments of the present application.

[0213] The processor executes the program instructions stored in the memory to perform any of the methods provided by the embodiments of the present application.

[0214] The embodiments of the present application further provide a computer program product or computer program, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform any of the methods in the above embodiments. The program product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0215] The embodiments of the present application provide a computer readable storage medium for storing computer program instructions for the apparatus provided by the above embodiments of the present application, which contains programs for executing any of the methods provided by the above embodiments of the present application. The above computer readable storage medium can be a non-transitory computer readable medium.

[0216] The computer readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to a magnetic storage (such as a floppy disk, a hard disk, a magnetic tape, a magneto-optical disk (MO), etc.), an optical storage (such as a CD, a DVD, a BD, a HVD, etc.), and a semiconductor storage (such as a ROM, an EPROM, an EEPROM, a NAND FLASH, a solid state disk (SSD), etc.).

[0217] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to a magnetic disk memory, a CD-ROM, an optical memory, etc.) containing computer usable program code.

[0218] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks. Figure 1 one or more flow or blocks.

[0219] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart block or blocks. Figure 1 one or more flow or blocks. Figure 1 one or more flow or blocks.

[0220] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks. Figure 1 one or more flow or blocks.

[0221] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A method of writing data to a non-volatile memory, the method comprising: The method comprises: writing a current data block into a current physical block of the non-type flash memory; when the current physical block is not the first physical block of the non-type flash memory, checking whether a bit flip occurs to a data block in a previous physical block of the current physical block; when the bit flip occurs to the data block in the previous physical block, re-writing an original data block previously written into the previous physical block into a next physical block of the current physical block, erasing data in the current physical block, and re-writing the current data block into the erased current physical block.

2. The method of claim 1, wherein, The method further comprises: for each data block written into the non-type flash memory, recording an index mapping relationship between the data block and a physical block where the data block is last written.

3. The method of claim 1, wherein, When the bit flip occurs to the data block in the previous physical block, the method further comprises: marking the previous physical block as an isolated block.

4. The method according to claim 1 or 3, characterized in that, When the current physical block is not the first physical block of the non-type flash memory, checking whether a bit flip occurs to a data block in a previous physical block of the current physical block comprises: when the current physical block is not the first physical block of the non-type flash memory, and the previous physical block of the current physical block is not an isolated block, checking whether a bit flip occurs to a data block in the previous physical block of the current physical block.

5. The method of claim 1, wherein, If the current data block is the last data block to be written into the non-type flash memory, after re-writing the current data block into the current physical block, the method further comprises: checking whether a bit flip occurs to a data block in the next physical block; when the bit flip occurs to the data block in the next physical block, re-writing an original data block previously written into the previous physical block into a next physical block of the next physical block.

6. A method of reading data from a non-NAND flash memory, the method comprising: The method comprises: obtaining an index mapping relationship between data blocks and physical blocks; wherein the index mapping relationship is recorded for each data block written into the non-type flash memory in a process of writing data into the non-type flash memory by the method of any one of claims 1 to 5; reading data blocks from the non-type flash memory according to the index mapping relationship.

7. A data read / write device, characterized by comprise: a memory for storing program instructions; a processor for invoking the program instructions stored in the memory, and performing the method of any one of claims 1 to 6 according to the obtained program execution right.

8. An electronic device, comprising: The data reading and writing apparatus of claim 7.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions for causing the computer to perform the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for reading data and method for writing data

    CN103514104A

  • Memory system and method for reducing read disturb errors

    CN105843550A