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:
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:
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.
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:
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:
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
Next, when writing C3 into the third abstract page, the cache check code of the cache check page Raid Buff is set to
And the original cache check code of the cache check page is used
By using
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
Covering, at this time, the physical check code
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.