CN107704338B - Data recovery method and device for data storage type flash memory - Google Patents

Data recovery method and device for data storage type flash memory Download PDF

Info

Publication number
CN107704338B
CN107704338B CN201710732155.8A CN201710732155A CN107704338B CN 107704338 B CN107704338 B CN 107704338B CN 201710732155 A CN201710732155 A CN 201710732155A CN 107704338 B CN107704338 B CN 107704338B
Authority
CN
China
Prior art keywords
abstract
page
data
physical
pages
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710732155.8A
Other languages
Chinese (zh)
Other versions
CN107704338A (en
Inventor
余云锋
吴大畏
李晓强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Deyi Microelectronics Co ltd
SHENZHEN SILICONGO MICROELECTRONICS CO Ltd
Original Assignee
SHENZHEN SILICONGO MICROELECTRONICS CO Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHENZHEN SILICONGO MICROELECTRONICS CO Ltd filed Critical SHENZHEN SILICONGO MICROELECTRONICS CO Ltd
Priority to CN201710732155.8A priority Critical patent/CN107704338B/en
Publication of CN107704338A publication Critical patent/CN107704338A/en
Application granted granted Critical
Publication of CN107704338B publication Critical patent/CN107704338B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention discloses a data recovery method and a data recovery device for a data storage type flash memory. The invention sets a target physical block in a data storage type flash memory into an abstract model with n abstract pages; selecting a check information page from the n abstract pages, and setting a physical check code for the check information page; and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page. The invention aims at restoring the data which is invalid due to the damaged data when the data storage type flash memory is matched with the buffer with lower resource expenditure, and ensuring that the working stability and safety of the data storage type flash memory are not influenced when the data is restored.

Description

Data recovery method and device for data storage type flash memory
Technical Field
The present invention relates to the field of storage technologies, and in particular, to a data recovery method and apparatus for a data storage type flash memory.
Background
At present, storage media of solid-state storage devices (such as solid-state disks) are mainly data storage type memory chips Nand flash, and due to negative factors such as data retention strategies (data retention), read disturb (read disturb) and wear of the data storage type memory chips, data of the solid-state storage devices may be damaged, that is, data of a certain physical page may be lost.
During the whole life cycle of the solid-state memory device, when data writing operation (Program, commonly called as programming) is performed on the data storage type memory chip, a data writing error may occur when data is written into a certain physical Page of the data storage type memory chip.
For example, some platform differences of eMMC (Embedded Multi Media Card) result in a large difference in power supply conditions, and such write errors are more common. When such problems occur, user data loss is often caused, which is undoubtedly fatal to users who need high-stability solid-state storage devices. However, when data write-in errors occur in the Nand flash of the data storage type memory chip at present, the adopted method is not too many, the cost is high, or the performance of the solid-state storage device is reduced. Two methods are common at present:
the first scheme is as follows: the Buffer (Buffer) with a large Buffer is adopted to ensure that after the data writing instruction is executed, if the data writing error occurs, the error data is still kept in the Buffer, and the method for recovering the data is simpler and more direct, but needs the Buffer with higher resource expenditure for support, so the cost is higher, and the method is not beneficial to popularization and application.
Scheme II: the data in the Buffer is flushed after waiting and confirming the programming success every time, so that the data protection method is also an insurance method. However, the programming time of Nand flash is generally longer, so adopting such a method can cause performance reduction and is not favorable for user experience.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The present invention provides a data recovery method, device and computer readable storage medium for a data storage flash memory, and aims to solve the problems of poor stability and low security of the data storage flash memory caused by recovering invalid data when the data of the data storage flash memory is destroyed and invalid.
In order to achieve the above object, the present invention provides a data recovery method for a data storage type flash memory, the method comprising the steps of:
setting a target physical block in a data storage type flash memory into an abstract model with n abstract pages, wherein n is the product of the number of channels of the data storage type flash memory, the number of enabling terminals in each channel, the number of logic storage units of each channel, the number of storage matrixes in each storage unit and the number of physical pages of the target physical block;
selecting a check information page from the n abstract pages, and setting a physical check code for the check information page;
and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
Preferably, after the check information page is selected from the n abstract pages and a physical check code is set for the check information page, the method further includes:
establishing a corresponding cache model according to the abstract model, wherein the cache model comprises a plurality of cache pages and cache check pages corresponding to the check information pages, each cache page is generated according to the number of the channels and the number of the enabling ends, and the cache check pages are provided with cache check codes corresponding to the physical check codes;
receiving an external data writing instruction, and splitting target data corresponding to the data writing instruction into a plurality of partial target data;
when the current part of target data is written into an abstract page corresponding to the current cache page, performing XOR operation on the current part of target data and the written part of target data, and taking an operation result as a cache check code of the cache check page;
before the target data are completely written into the abstract model, if an abstract page to be restored with part of target data lost appears in the abstract model, performing data restoration on the abstract page to be restored according to the cache check code.
Preferably, after the xor operation is performed on the current partial target data and the written partial target data, and the operation result is used as the cache check code of the cache check page, the method further includes
After the target data are completely written into the abstract model, updating the physical check code of the check information page according to the cache check code;
and if the abstract page to be recovered with part of target data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
Preferably, the selecting a check information page from the n abstract pages, and setting a physical check code for the check information page specifically includes:
selecting an nth abstract page from the n abstract pages as the check information page, and setting a physical check code for the check information page, wherein the physical check code is represented by an exclusive or value of effective data of each abstract page in the abstract model;
correspondingly, when an abstract page to be restored with effective data loss occurs in the abstract model, performing data restoration on the abstract page to be restored according to the physical check code of the check information page, which specifically includes:
and when the abstract page to be restored with the lost effective data appears in the abstract model, determining the effective data of the rest abstract pages in the abstract model, and performing data restoration on the abstract page to be restored according to the effective data of the rest abstract pages and the physical check code.
Preferably, the selecting a check information page from the n abstract pages, and setting a physical check code for the check information page specifically includes:
respectively setting check information pages for the n abstract pages, and respectively setting physical check codes for the check information pages, wherein each physical check code is represented as backup data of each abstract page;
correspondingly, when an abstract page to be restored with effective data loss occurs in the abstract model, performing data restoration on the abstract page to be restored according to the physical check code of the check information page, which specifically includes:
and when an abstract page to be restored with effective data loss appears in the abstract model, determining a physical check code corresponding to the abstract page to be restored, and performing data restoration on the abstract page to be restored according to the corresponding physical check code.
Preferably, the setting of the target physical block in the data storage type flash memory into an abstract model with n abstract pages specifically includes:
determining the number of physical pages in a target physical block in the data storage type flash memory;
acquiring the number of channels of the data storage type flash memory, the number of logic memory units of each channel, the number of memory matrixes in each memory unit and the number of energy section sections in each channel;
and setting the target physical block into an abstract model with n abstract pages according to the number of the physical pages, the number of the channels, the number of the logic storage units of each channel, the number of the storage matrixes in each storage unit and the number of the energy segments in each channel.
Preferably, the determining the number of physical pages in the target physical block in the data storage type flash memory specifically includes:
receiving a paging instruction input from outside;
and determining the number of each physical page of the target physical block in the data storage type flash memory according to the paging instruction.
Preferably, the physical check code is obtained by calculating according to the following formula:
Figure BDA0001385554880000041
d1 represents valid data of a 1 st abstract page in the abstract model, D2 represents valid data of a 2 nd abstract page in the abstract model, D3 represents valid data of a 3 rd abstract page in the abstract model, Dn represents valid data of an nth abstract page in the abstract model, and P represents a physical check code generated after the valid data of each abstract page is subjected to XOR operation;
correspondingly, the cache check code is obtained by calculating the following formula:
Figure BDA0001385554880000042
wherein C1 represents the partial target data written into the 1 st abstract page in the abstract model, C2 represents the partial target data written into the 2 nd abstract page in the abstract model, C3 represents the partial target data written into the 3 rd abstract page in the abstract model, Cn represents the partial target data written into the nth abstract page in the abstract model, and P' represents the cached parity.
In addition, to achieve the above object, the present invention further provides a data recovery apparatus for a data storage type flash memory, the apparatus comprising: a processor, a memory and a data recovery program of a data storage type flash memory stored on the memory and operable on the processor; the data recovery apparatus of the data storage type flash memory is configured to implement the steps of the method for data recovery of the data storage type flash memory as described above.
In addition, to achieve the above object, the present invention further provides a computer-readable storage medium, on which a data recovery program of the data storage type flash memory is stored, wherein the data recovery program of the data storage type flash memory, when executed by a processor, implements the steps of the data recovery method of the data storage type flash memory as described above.
According to the method, a target physical block in a data storage type flash memory is set to be an abstract model with n abstract pages, a check information page is selected from the n abstract pages, a physical check code is set for the check information page, and when an abstract page to be restored with effective data loss occurs in the abstract model, data restoration is carried out on the abstract page to be restored according to the physical check code of the check information page. The data recovery method can further recover the data which is invalid due to the fact that the data are damaged in the data storage type flash memory, can ensure that the stability and the safety of the data flash memory are not affected while the data recovery is carried out, and can still recover the data in the data storage type flash memory under the condition that errors occur in the written data even if the resource overhead of a buffer is low.
Drawings
FIG. 1 is a schematic diagram of a data recovery apparatus of a data storage type flash memory in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a data recovery method of a data storage flash memory according to a first embodiment of the present invention;
FIG. 3 is a diagram illustrating a paging model of a target physical block of a data storage flash memory according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating an abstract model generated based on the paging model diagram of FIG. 3 according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a model after a check information page is set for the abstract model schematic diagram in the embodiment of the present invention;
FIG. 6 is a schematic diagram of a cache model generated based on the abstract model schematic diagram of FIG. 5 according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating a data recovery method for a data storage flash memory according to a second embodiment of the present invention;
FIG. 8 is a schematic diagram illustrating a data flow relationship between the first two cache pages of the cache model and the abstract pages of the corresponding abstract model according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a data flow relationship between two cache pages after caching a model and an abstract page corresponding to an abstract model according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data recovery apparatus of a data storage type flash memory in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the data recovery apparatus of the data storage type flash memory may include: a processor 1001, such as a CPU, a user interface 1002, a solid state storage device 1003, a memory 1004, a communication bus 1005. The user interface 1002 may include a Display screen (Display) and an input unit such as a Keyboard (Keyboard), and optionally, the user interface 1002 may also include a standard wired interface and a wireless interface. The Memory 1004 may be a non-volatile Memory (non-volatile Memory) and may include an Electrically Erasable Programmable Read-Only Memory (EEPROM). A communication bus 1005 is used to enable connective communication between these components. The solid-state storage device 1003 may be a solid-state storage device such as a solid-state hard disk.
Those skilled in the art will appreciate that the configuration of the data recovery device of the data storage type flash memory shown in fig. 1 does not constitute a limitation of the data recovery device of the data storage type flash memory, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
As shown in fig. 1, the memory 1004, which is a kind of computer storage medium, may include an operating system, a hard disk control module, a user interface module, and a data recovery program of a data storage type flash memory.
In the data recovery apparatus of the data storage type flash memory shown in fig. 1, the user interface 1002 is mainly used for interacting with a user; the processor 1001 and the memory 1004 in the application server of the present invention may be disposed in a data recovery apparatus of a data storage type flash memory, which calls a data recovery program of the data storage type flash memory stored in the memory 1004 through the processor 1001 and performs the following operations:
setting a target physical block in a data storage type flash memory into an abstract model with n abstract pages, wherein n is the product of the number of channels of the data storage type flash memory, the number of enabling terminals in each channel, the number of logic storage units of each channel, the number of storage matrixes in each storage unit and the number of physical pages of the target physical block;
selecting a check information page from the n abstract pages, and setting a physical check code for the check information page;
and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
Further, the processor 1001 may call a data recovery procedure of the data storage type flash memory stored in the memory 1004, and further perform the following operations:
establishing a corresponding cache model according to the abstract model, wherein the cache model comprises a plurality of cache pages and cache check pages corresponding to the check information pages, each cache page is generated according to the number of the channels and the number of the enabling ends, and the cache check pages are provided with cache check codes corresponding to the physical check codes;
receiving an external data writing instruction, and splitting target data corresponding to the data writing instruction into a plurality of partial target data;
when the current part of target data is written into an abstract page corresponding to the current cache page, performing XOR operation on the current part of target data and the written part of target data, and taking an operation result as a cache check code of the cache check page;
before the target data are completely written into the abstract model, if an abstract page to be restored with part of target data lost appears in the abstract model, performing data restoration on the abstract page to be restored according to the cache check code.
Further, the processor 1001 may call a data recovery procedure of the data storage type flash memory stored in the memory 1004, and further perform the following operations:
after the target data are completely written into the abstract model, updating the physical check code of the check information page according to the cache check code;
and if the abstract page to be recovered with part of target data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
Further, the processor 1001 may call a data recovery procedure of the data storage type flash memory stored in the memory 1004, and further perform the following operations:
selecting an nth abstract page from the n abstract pages as the check information page, and setting a physical check code for the check information page, wherein the physical check code is represented by an exclusive or value of effective data of each abstract page in the abstract model;
and when the abstract page to be restored with the lost effective data appears in the abstract model, determining the effective data of the rest abstract pages in the abstract model, and performing data restoration on the abstract page to be restored according to the effective data of the rest abstract pages and the physical check code.
Further, the processor 1001 may call a data recovery procedure of the data storage type flash memory stored in the memory 1004, and further perform the following operations:
respectively setting check information pages for the n abstract pages, and respectively setting physical check codes for the check information pages, wherein each physical check code is represented as backup data of each abstract page;
and when an abstract page to be restored with effective data loss appears in the abstract model, determining a physical check code corresponding to the abstract page to be restored, and performing data restoration on the abstract page to be restored according to the corresponding physical check code.
Further, the processor 1001 may call a data recovery procedure of the data storage type flash memory stored in the memory 1004, and further perform the following operations:
determining the number of physical pages in a target physical block in the data storage type flash memory;
acquiring the number of channels of the data storage type flash memory, the number of logic memory units of each channel, the number of memory matrixes in each memory unit and the number of energy section sections in each channel;
and setting the target physical block into an abstract model with n abstract pages according to the number of the physical pages, the number of the channels, the number of the logic storage units of each channel, the number of the storage matrixes in each storage unit and the number of the energy segments in each channel.
Further, the processor 1001 may call a data recovery procedure of the data storage type flash memory stored in the memory 1004, and further perform the following operations:
receiving a paging instruction input from outside;
and determining the number of each physical page of the target physical block in the data storage type flash memory according to the paging instruction.
In this embodiment, a target physical block in a data storage type flash memory is set as an abstract model with n abstract pages, where n is a product of the number of channels of the data storage type flash memory, the number of enable terminals in each channel, the number of logical memory units in each channel, the number of memory matrices in each memory unit, and the number of physical pages of the target physical block; selecting a check information page from the n abstract pages, and setting a physical check code for the check information page; and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page. The invention aims at restoring the data which is invalid due to the damaged data when the data storage type flash memory is matched with the buffer with lower resource expenditure, and ensuring that the working stability and safety of the data storage type flash memory are not influenced when the data is restored.
Based on the above hardware structure, an embodiment of the data recovery method for the data storage flash memory of the present invention is provided.
Referring to fig. 2, fig. 2 is a flow chart illustrating a data recovery method of a data storage type flash memory according to a first embodiment of the present invention.
In a first embodiment, the data recovery method of the data storage type flash memory includes the following steps:
s10: setting a target physical block in a data storage type flash memory into an abstract model with n abstract pages, wherein n is the product of the number of channels of the data storage type flash memory, the number of enabling terminals in each channel, the number of logic storage units of each channel, the number of storage matrixes in each storage unit and the number of physical pages of the target physical block;
it should be noted that the present embodiment is described by taking a solid state disk as an example of a solid state storage device, and the description is given.
It is understood that the internal storage organization structure in the data storage type Flash memory NAND Flash is that each "chip" has several LUNs (logical storage units), each Lun includes several planes (storage matrices), each Plane includes several blocks (physical blocks), each Block includes several pages (physical pages), in a NAND Flash chip, several LUNs can be packaged, LUNs are basic units for receiving and executing Flash commands, for example, a "chip" includes Lun0 and Lun1, Lun0 and Lun1 can receive and execute different commands at the same time. However, in one LUN, only one command can be executed at a time, and you cannot write to one Page and simultaneously read and access other pages. Plane is the minimum unit that NAND Flash can operate according to commands such as read, write, erase, etc., and a Plane contains a plurality of blocks in a matrix form, which is the minimum erase unit of NAND Flash, and contains a plurality of pages, which is the minimum read-write unit of NAND Flash.
In this embodiment, it is assumed that the number of physical pages of each physical block of each plane in each Lun in the Nand flash chip is set to 4 pages (Page0 is the first physical Page of each physical block, Page2 is the second physical Page of each physical block, Page3 is the third physical Page of each physical block, and Page4 is the fourth physical Page of each physical block), and the Nand flash chip has 2 channels and 2 enable terminals as an example for explanation; as shown in fig. 3, fig. 3 is a schematic diagram of a paging model of a target physical block of each plane in each Lun under a solid state disk controller (SSD controller), where CH is a channel, CH0 is a first channel, and CH1 is a second channel; CE is the enable, CE0 is the first enable of each channel, and CE1 is the second enable of each channel.
In order to ensure the highest performance of reading and writing of the solid state disk, this embodiment generates the abstract model of the target physical block shown in fig. 4 according to the paging model of the target physical block of each plane in each Lun shown in fig. 3, where physical pages at different enabling ends of different channels in fig. 3 form abstract pages shown in fig. 4 after being bound (CH0CE0Page0 is an abstract Page of a first enabling end of a first physical Page of the target physical block in a first channel, CH1CE0Page0 is an abstract Page of a first enabling end of the first physical Page in a second channel, CH0CE1Page0 is an abstract Page of a second enabling end of the first physical Page in the first channel, CH1CE1Page0 is an abstract Page of a second enabling end of the first physical Page in the second channel, CH0CE0Page1 is an abstract Page … … of the first enabling end of the second physical Page of the target physical block in the first channel, and so on the same order, 4 physical pages, 2 channels, and 16 abstract pages in total for 2 enabled terminals); in fig. 4, the sequence of the abstract page pages of the abstract model of the target physical block of each plane in each Lun from top to bottom is the sequence of data written when a data write instruction (program) is executed.
In a specific implementation, when the host sends data to the device, the binding operation is performed on each physical Page of the target physical block of each plane in each Lun according to the above sequence. For a block, i.e., the target physical block, it is bound into an abstract model with n abstract pages,
where n is the number of channels CH, the number of enable terminals CE, the number of planes, and the number of pages in the block. For convenience of description, in this embodiment, it is described by taking as an example when the number of CH is 1, the number of LUN is 1, the number of CE is 1, and the number of plane is 1, and each block has 4 abstract pages, but in practice, a "chip" may have different combinations of the number of CH, the number of LUN, the number of CE, the number of plane, and the number of pages in one block;
s20: selecting a check information page from the n abstract pages, and setting a physical check code for the check information page;
s30: and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
It should be noted that, the check information page may be selected and the physical check code may be set in two ways.
The first mode is as follows: the last abstract page is a check information page, the data of the last abstract page is check codes (simple exclusive or operation can be performed) of the rest 15 abstract pages, as long as any one of the 16 abstract pages (including the check information page) has data loss and other unrecoverable conditions, the data can be restored through the rest 15 abstract pages, and 16 times of capacity is sacrificed as safety data protection through the first mode. As for the Nand flash chip used in the current solid state disk, generally, a physical block has at least 256 physical pages by default, and accordingly, an abstract physical block (the abstract model) has at least 1024 abstract pages by default, and according to the above-mentioned expression, in every 1024 abstract pages, the last abstract page is a page (i.e. raid page) for storing a check code. Therefore, the solid state disk has capacity loss of about one thousandth, and the use and popularization of users are basically not affected too much.
The second way is: certainly, each abstract page may also be provided with a check information page, each check information page is provided with a physical check code, each physical check code represents backup data of each abstract page, and the second way is to sacrifice half of the capacity to further improve the data security, which is actually the case of completely backing up data.
In a concrete implementation, the first manner is taken as an example in this embodiment, a 16 th abstract Page (i.e., a last abstract Page (corresponding to CH1CE1Page3Raid Page in fig. 5) is selected from the 16 abstract pages in the abstract model as the check information Page, that is, refer to fig. 5, and a physical check code is set for the check information Page (CH1CE1Page3Raid Page), where the physical check code is represented by an exclusive or value of valid data of each abstract Page in the abstract model; the physical check code is obtained by calculating the following formula:
Figure BDA0001385554880000111
wherein D1 represents valid data of the 1 st abstract page in the abstract model, D2 represents valid data of the 2 nd abstract page in the abstract model, D3 represents valid data of the 3 rd abstract page in the abstract model, Dn represents valid data of the nth abstract page in the abstract model, and P represents a physical check code generated by performing exclusive or operation on the valid data of each abstract page.
For convenience of description, in this embodiment, it is described by taking as an example when the number of CH is 1, the number of LUNs is 1, the number of CE is 1, the number of planes is 1, and each block has 4 abstract pages, and then the check information Page is CH1CE1Page3Raid Page in fig. 5 (that is, the abstract Page of the first plane of the corresponding first LUN at the second enable end of the third physical Page of the target physical block is the check information Page);
of course, it may also be assumed that the number of CH is 2, the number of LUN is 2, the number of CE is 1, the number of planes is 1, and each block has 4 abstract pages, where the check information Page should be CH1LUN1plane1CE1Page3Raid Page (that is, the abstract Page of the second plane of the second LUN corresponding to the second enable end of the third physical Page of the target physical block in the second channel is the check information Page).
When the host detects that one and only one of D1 to Dn in the above formula is damaged and lost (i.e. an abstract page to be restored occurs) through hard disk control, the processor of the host determines the correct valid data of the remaining abstract pages in the abstract model through the firmware version, and performs data restoration on the abstract page to be restored according to the valid data of the remaining abstract pages and the physical check code P.
In the embodiment, a target physical block in a data storage type flash memory is set as an abstract model with n abstract pages, a check information page is selected from the n abstract pages, and a physical check code is set for the check information page; and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page. The invention aims at restoring the data which is invalid due to the damaged data when the data storage type flash memory is matched with the buffer with lower resource expenditure, and ensuring that the working stability and safety of the data storage type flash memory are not influenced when the data is restored.
Referring to fig. 7, a second embodiment of a data recovery method for a data storage type flash memory according to the present invention is based on the first embodiment of the method, and fig. 6 is based on the embodiment shown in fig. 2 as an example.
In this embodiment, after step S20, the method further includes the following steps:
s301: establishing a corresponding cache model according to the abstract model, wherein the cache model comprises a plurality of cache pages and cache check pages corresponding to the check information pages, each cache page is generated according to the number of the channels and the number of the enabling ends, and the cache check pages are provided with cache check codes corresponding to the physical check codes;
it is to be understood that, referring to fig. 6, a corresponding cache model is established according to the abstract model in fig. 5, and the cache model operates in the Buffer, and the cache model has four cache pages and one cache check Page Raid Buff, where the four cache pages are Page Buff0, Page Buff1, Page Buff2 and Page Buff3 respectively;
and when a host executes a data writing instruction, each cache page in the cache model of the cache and each abstract page of the abstract model have a corresponding data flow relationship: that is, each cache Page in the cache model corresponds to a different enable end of a different channel, and four cache pages in the cache model, Page Buff0, Page Buff1, Page Buff2 and Page Buff3, will cache each part of target data of the target data to be written in sequence, and transmit each part of target data to a different enable end of each channel where the corresponding abstract Page is located in sequence according to the graph: CH0CE0, CH1CE0, CH0CE1, CH1CE 1. Referring to fig. 8, (a) shows that the first batch of partial target data is transmitted to different enabled terminals of each channel where Page0 is located, (B) shows that the second batch of partial target data is transmitted to different enabled terminals of each channel where Page1 is located, (C) shows that the third batch of partial target data is transmitted to different enabled terminals of each channel where Page2 is located, and (D) shows that the fourth batch of partial target data is transmitted to different enabled terminals of each channel where Page3 is located.
In a specific implementation, each channel is at least allocated with one cache page (page buff), the more cache pages allocated to each channel, the better the performance, but when allocated to a certain level, the performance will not be improved, which is related to the specific running time of Nandflash. For example, when a data write operation is performed, the time for writing a data into a physical page needs 200 microseconds, and the time for transmitting a data to the corresponding physical page needs 40 microseconds, when a channel has 4 enable ports ce, the performance is optimal when 4 cache pages (page buffs) are allocated to each channel, but the performance is not greatly improved when more cache pages (page buffs) are allocated.
S302: receiving an external data writing instruction, and splitting target data corresponding to the data writing instruction into a plurality of partial target data;
it can be understood that, when the host receives a data write command, the host will split the data to be written (i.e. target data) corresponding to the data write command into multiple cache pages (page buffs) of the cache model, and then sequentially write each part of the target data into each abstract page of the corresponding abstract model through the buffer.
S303: when the current part of target data is written into an abstract page corresponding to the current cache page, performing XOR operation on the current part of target data and the written part of target data, and taking an operation result as a cache check code of the cache check page;
s304: before the target data are completely written into the abstract model, if an abstract page to be restored with part of target data lost appears in the abstract model, performing data restoration on the abstract page to be restored according to the cache check code.
It should be noted that the cache check code is obtained by calculating according to the following formula:
Figure BDA0001385554880000141
wherein C1 represents the partial target data written to the 1 st abstract page in the abstract model, C2 represents the partial target data written to the 2 nd abstract page in the abstract model, C3 represents the partial target data written to the 3 rd abstract page in the abstract model, Cn represents the partial target data written to the nth abstract page in the abstract model, and P' represents the cached parity; in the present embodiment, n is 16 in the above formula;
in a specific implementation, for example, when writing C2 into the second abstract page, and before C1 has written the first abstract page, the cache check code of the cache check page Raid Buff is set to
Figure BDA0001385554880000142
Next, when writing C3 into the third abstract page, the cache check code of the cache check page Raid Buff is set to
Figure BDA0001385554880000143
And the original cache check code of the cache check page is used
Figure BDA0001385554880000144
By using
Figure BDA0001385554880000145
If the host processor detects the situation of the failed programming by the hard disk control if the programmed data loss occurs in C3 (i.e. corresponding to step S303), the host processor will recover D3 according to the cache check code P' and D1, D2 by the firmware version (i.e. corresponding to step S304) because the target data is not written into the abstract model completely (i.e. this time the programming is not completed, and 16 abstract pages are not fully written).
S304': after the target data are completely written into the abstract model, updating the physical check code of the check information page according to the cache check code; and if the abstract page to be recovered with part of target data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
It is understood that the steps S304' and S304 are two different cases where the programming error causes a part of the target data to be destroyed and fail.
Step S304' is to use the physical check code P before the check information Page (CH1CE1Page3Raid Page) in the abstract model after all the target data are written in the abstract model (i.e. 16 abstract pages are full), so as to check the information Page (CH1CE1Page3Raid Page) in the abstract model
Figure BDA0001385554880000146
Covering, at this time, the physical check code
Figure BDA0001385554880000147
When valid data is damaged and lost in one of the C1 to C16 in the above formula (i.e. the abstract page to be restored), the processor of the host determines the correct valid data of the remaining abstract page in the abstract model through the firmware version, and performs data restoration on the abstract page to be restored according to the valid data of the remaining abstract page and the physical check code P.
In this embodiment, a corresponding cache model is established according to the abstract model, a cache check page is set for the cache model, when a current part of target data is written into the abstract page corresponding to the current cache page, an exclusive or operation is performed on the current part of target data and the written part of target data, and an operation result is used as a cache check code of the cache check page, so that a part of target data which fails due to a programming error in the data storage type flash memory can be recovered, the stability and the safety of the data flash memory can be ensured to be unaffected while data recovery is performed, and even if the resource overhead of the cache is small, the data in the data storage type flash memory can still be recovered under the condition that an error occurs in the written data.
In addition, an embodiment of the present invention further provides a computer-readable storage medium, where a data recovery program of the data storage type flash memory is stored on the storage medium, and when executed by a processor, the data recovery program of the data storage type flash memory implements the following operations:
setting a target physical block in a data storage type flash memory into an abstract model with n abstract pages, wherein n is the product of the number of channels of the data storage type flash memory, the number of enabling terminals in each channel, the number of logic storage units of each channel, the number of storage matrixes in each storage unit and the number of physical pages of the target physical block;
selecting a check information page from the n abstract pages, and setting a physical check code for the check information page;
and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
Further, when executed by a processor, the data recovery program of the data storage flash memory further implements the following operations:
establishing a corresponding cache model according to the abstract model, wherein the cache model comprises a plurality of cache pages and cache check pages corresponding to the check information pages, each cache page is generated according to the number of the channels and the number of the enabling ends, and the cache check pages are provided with cache check codes corresponding to the physical check codes;
receiving an external data writing instruction, and splitting target data corresponding to the data writing instruction into a plurality of partial target data;
when the current part of target data is written into an abstract page corresponding to the current cache page, performing XOR operation on the current part of target data and the written part of target data, and taking an operation result as a cache check code of the cache check page;
before the target data are completely written into the abstract model, if an abstract page to be restored with part of target data lost appears in the abstract model, performing data restoration on the abstract page to be restored according to the cache check code.
Further, when executed by a processor, the data recovery program of the data storage flash memory further implements the following operations:
after the target data are completely written into the abstract model, updating the physical check code of the check information page according to the cache check code;
and if the abstract page to be recovered with part of target data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
Further, when executed by a processor, the data recovery program of the data storage flash memory further implements the following operations:
selecting an nth abstract page from the n abstract pages as the check information page, and setting a physical check code for the check information page, wherein the physical check code is represented by an exclusive or value of effective data of each abstract page in the abstract model;
and when the abstract page to be restored with the lost effective data appears in the abstract model, determining the effective data of the rest abstract pages in the abstract model, and performing data restoration on the abstract page to be restored according to the effective data of the rest abstract pages and the physical check code.
Further, when executed by a processor, the data recovery program of the data storage flash memory further implements the following operations:
respectively setting check information pages for the n abstract pages, and respectively setting physical check codes for the check information pages, wherein each physical check code is represented as backup data of each abstract page;
and when an abstract page to be restored with effective data loss appears in the abstract model, determining a physical check code corresponding to the abstract page to be restored, and performing data restoration on the abstract page to be restored according to the corresponding physical check code.
Further, when executed by a processor, the data recovery program of the data storage flash memory further implements the following operations:
determining the number of physical pages in a target physical block in the data storage type flash memory;
acquiring the number of channels of the data storage type flash memory, the number of logic memory units of each channel, the number of memory matrixes in each memory unit and the number of energy section sections in each channel;
and setting the target physical block into an abstract model with n abstract pages according to the number of the physical pages, the number of the channels, the number of the logic storage units of each channel, the number of the storage matrixes in each storage unit and the number of the energy segments in each channel.
Further, when executed by a processor, the data recovery program of the data storage flash memory further implements the following operations:
receiving a paging instruction input from outside;
and determining the number of each physical page of the target physical block in the data storage type flash memory according to the paging instruction.
In this embodiment, a target physical block in a data storage type flash memory is set as an abstract model with n abstract pages, where n is a product of the number of channels of the data storage type flash memory, the number of enable terminals in each channel, the number of logical memory units in each channel, the number of memory matrices in each memory unit, and the number of physical pages of the target physical block; selecting a check information page from the n abstract pages, and setting a physical check code for the check information page; and when the abstract page to be recovered with the effective data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page. The invention aims at restoring the data which is invalid due to the damaged data when the data storage type flash memory is matched with the buffer with lower resource expenditure, and ensuring that the working stability and safety of the data storage type flash memory are not influenced when the data is restored.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (9)

1. A method for recovering data in a data storage flash memory, the method comprising:
setting a target physical block in a data storage type flash memory into an abstract model with n abstract pages;
selecting a check information page from the n abstract pages, and setting a physical check code for the check information page;
when an abstract page to be restored with effective data loss appears in the abstract model, performing data restoration on the abstract page to be restored according to a physical verification code of the verification information page;
the setting of the target physical block in the data storage type flash memory into an abstract model with n abstract pages specifically includes:
determining the number of physical pages in a target physical block in the data storage type flash memory;
acquiring the number of channels of the data storage type flash memory, the number of logic memory cells of each channel, the number of memory matrixes in each memory cell and the number of enable terminals in each channel;
and setting the target physical block into an abstract model with n abstract pages according to the number of the physical pages, the number of the channels, the number of the logic storage units of each channel, the number of the storage matrixes in each storage unit and the number of the enabling ends in each channel.
2. The method of claim 1, wherein after selecting a check information page from the n abstract pages and setting a physical check code for the check information page, the method further comprises:
establishing a corresponding cache model according to the abstract model, wherein the cache model comprises a plurality of cache pages and cache check pages corresponding to the check information pages, each cache page is generated according to the number of the channels and the number of the enabling ends, and the cache check pages are provided with cache check codes corresponding to the physical check codes;
receiving an external data writing instruction, and splitting target data corresponding to the data writing instruction into a plurality of partial target data;
when the current part of target data is written into an abstract page corresponding to the current cache page, performing XOR operation on the current part of target data and the written part of target data, and taking an operation result as a cache check code of the cache check page;
before the target data are completely written into the abstract model, if an abstract page to be restored with part of target data lost appears in the abstract model, performing data restoration on the abstract page to be restored according to the cache check code.
3. The method of claim 2, wherein after xoring the current partial target data with the written partial target data and taking the result of the xoring as the cache check code of the cache check page, the method further comprises:
after the target data are completely written into the abstract model, updating the physical check code of the check information page according to the cache check code;
and if the abstract page to be recovered with part of target data lost appears in the abstract model, performing data recovery on the abstract page to be recovered according to the physical verification code of the verification information page.
4. The method as claimed in claim 1, wherein said selecting a check information page from said n abstract pages, and setting a physical check code for said check information page, specifically comprises:
selecting an nth abstract page from the n abstract pages as the check information page, and setting a physical check code for the check information page, wherein the physical check code is represented by an exclusive or value of effective data of each abstract page in the abstract model;
correspondingly, when an abstract page to be restored with effective data loss occurs in the abstract model, performing data restoration on the abstract page to be restored according to the physical check code of the check information page, which specifically includes:
and when the abstract page to be restored with the lost effective data appears in the abstract model, determining the effective data of the rest abstract pages in the abstract model, and performing data restoration on the abstract page to be restored according to the effective data of the rest abstract pages and the physical check code.
5. The method as claimed in claim 1, wherein said selecting a check information page from said n abstract pages, and setting a physical check code for said check information page, specifically comprises:
selecting a check information page from the n abstract pages, and respectively setting a physical check code for each check information page, wherein each physical check code is represented as backup data of each abstract page;
correspondingly, when an abstract page to be restored with effective data loss occurs in the abstract model, performing data restoration on the abstract page to be restored according to the physical check code of the check information page, which specifically includes:
and when an abstract page to be restored with effective data loss appears in the abstract model, determining a physical check code corresponding to the abstract page to be restored, and performing data restoration on the abstract page to be restored according to the corresponding physical check code.
6. The method of any of claims 1 to 5, wherein the determining the number of physical pages in the target physical block in the data storage flash memory comprises:
receiving a paging instruction input from outside;
and determining the number of each physical page of the target physical block in the data storage type flash memory according to the paging instruction.
7. A method according to any one of claims 2 to 3, wherein the physical check code is calculated by the following formula:
Figure 1381DEST_PATH_IMAGE001
wherein D1 represents valid data of the 1 st abstract page in the abstract model, and D2 represents the 2 nd abstract page in the abstract model
The effective data of the abstract pages, D3 represents the effective data of the 3 rd abstract page in the abstract model, Dn represents the effective data of the nth abstract page in the abstract model, and P represents the physical check code;
correspondingly, the cache check code is obtained by calculating the following formula:
Figure 781118DEST_PATH_IMAGE002
wherein C1 represents the partial target data written into the 1 st abstract page in the abstract model, C2 represents the partial target data written into the 2 nd abstract page in the abstract model, C3 represents the partial target data written into the 3 rd abstract page in the abstract model, Cn represents the partial target data written into the nth abstract page in the abstract model, and P' represents the cached parity.
8. A data recovery apparatus for a data storage type flash memory, the apparatus comprising: a processor, a memory and a data recovery program of a data storage type flash memory stored on the memory and operable on the processor; the data recovery program of the data storage type flash memory is configured to implement the steps of the method for data recovery of the data storage type flash memory according to any one of claims 1 to 7.
9. A computer-readable storage medium, wherein the storage medium stores thereon a data recovery program of the data storage type flash memory, and the data recovery program of the data storage type flash memory implements the steps of the data recovery method of the data storage type flash memory according to any one of claims 1 to 7 when executed by a processor.
CN201710732155.8A 2017-08-22 2017-08-22 Data recovery method and device for data storage type flash memory Active CN107704338B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710732155.8A CN107704338B (en) 2017-08-22 2017-08-22 Data recovery method and device for data storage type flash memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710732155.8A CN107704338B (en) 2017-08-22 2017-08-22 Data recovery method and device for data storage type flash memory

Publications (2)

Publication Number Publication Date
CN107704338A CN107704338A (en) 2018-02-16
CN107704338B true CN107704338B (en) 2020-10-30

Family

ID=61171002

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710732155.8A Active CN107704338B (en) 2017-08-22 2017-08-22 Data recovery method and device for data storage type flash memory

Country Status (1)

Country Link
CN (1) CN107704338B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108647152A (en) * 2018-04-27 2018-10-12 江苏华存电子科技有限公司 The management method of data is protected in a kind of promotion flash memory device with array of data
CN109542671B (en) * 2018-11-30 2022-06-07 湖南国科微电子股份有限公司 Verification data generation method and solid state disk
CN111414345B (en) * 2020-03-30 2022-03-25 杭州华望系统科技有限公司 Model data recovery method based on operation log

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100468367C (en) * 2003-10-29 2009-03-11 鸿富锦精密工业(深圳)有限公司 Solid state storage unit safety storage system and method
KR100575657B1 (en) * 2004-10-28 2006-05-03 엘지전자 주식회사 Method for reading nand flash
US8365041B2 (en) * 2010-03-17 2013-01-29 Sandisk Enterprise Ip Llc MLC self-raid flash data protection scheme
CN102929736B (en) * 2012-10-23 2016-05-11 忆正科技(武汉)有限公司 A kind of flash memory interweave verification error correction method and flash controller

Also Published As

Publication number Publication date
CN107704338A (en) 2018-02-16

Similar Documents

Publication Publication Date Title
CN109582217B (en) Data storage device and method for writing data into memory device
US8175012B2 (en) Decoding/encoding method for booting from a NAND flash and system thereof
US9645894B2 (en) Data storage device and flash memory control method
US10347349B2 (en) Method and device for fail-safe erase of flash memory
US7610465B2 (en) Method and related apparatus for data migration utilizing disk arrays
EP3336706B1 (en) Method and storage device for processing stripes in storage device
US20070055969A1 (en) System and method for updating firmware
JP5364807B2 (en) MEMORY CONTROLLER AND NONVOLATILE MEMORY DEVICE
CN108268337B (en) Method for managing data in memory device, memory device and controller thereof
CN104808951A (en) Storage control method and device
CN109582216B (en) Data storage device and data processing method of memory device
WO2012140695A1 (en) Storage control apparatus and error correction method
CN107665097B (en) Method and device for partitioning solid state disk and computer readable storage medium
JPWO2007000862A1 (en) MEMORY CONTROLLER, NONVOLATILE MEMORY DEVICE, NONVOLATILE MEMORY SYSTEM, AND DATA WRITE METHOD
CN103995784A (en) Flash memory controller, storage device and flash memory control method
CN114528226A (en) High-efficiency garbage collection method, data storage device and controller thereof
CN107704338B (en) Data recovery method and device for data storage type flash memory
CN109697170B (en) Method for accessing flash memory module, related flash memory controller and electronic device
US20130159605A1 (en) Data merging method for non-volatile memory module, and memory controller and memory storage device using the same
TWI779707B (en) Method and apparatus for bad block management in flash memory
JPWO2009004674A1 (en) Storage device, disk device, write determination method, control device
TW202028981A (en) Data storage devices and methods for firmware failure prevention
CN114416147B (en) Firmware loading method, memory and computer readable storage medium
CN113885808A (en) Mapping information recording method, memory control circuit unit and memory device
CN107329850B (en) Memory satisfying mass read-write frequency operation and data storage method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Units 05-2 and 06-08, 6th floor, Changhong Science and Technology Building, 18 Science and Technology South 12 Road, Nanshan District, Shenzhen City, Guangdong Province

Applicant after: SHENZHEN SILICONGO MICROELECTRONICS Co.,Ltd.

Address before: Units 05-2 and 06-08, 6th floor, Changhong Science and Technology Building, 18 Science and Technology South 12 Road, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SLICONGO MICROELECTRONICS, Inc.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220907

Address after: 518000 area a, 7th floor, building A1, Shenzhen digital technology park, 17 Gaoxin South 7th Road, high tech Zone community, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Patentee after: Deyi Microelectronics Co.,Ltd.

Patentee after: SHENZHEN SILICONGO MICROELECTRONICS Co.,Ltd.

Address before: 518057 05-2, 06-08 unit, 6 floor, Changhong science and technology building, 18 Nanshan District science and technology south twelve Road, Shenzhen, Guangdong.

Patentee before: SHENZHEN SILICONGO MICROELECTRONICS Co.,Ltd.

TR01 Transfer of patent right