A cache power failure recovery method, system and storage medium thereof

By quickly narrowing the reading range of the block to be restored after the Flash memory is powered off, and just scanning the last physical page for data recovery is solved, the problem of low data recovery efficiency after power outage in the prior art is solved, and efficient data recovery and normal block writing is achieved.

CN119512825BActive Publication Date: 2025-05-16GUANGDONG JIANGXINCHUANG TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510102665.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-16
Estimated Expiration
2045-01-22

AI Technical Summary

Technical Problem

In the prior art, data recovery efficiency is low after the Flash memory is powered off, and the problem of blocks not being written normally after recovery may occur.

Method used

By obtaining the target flash partition after the power outage of the Flash flash memory, scan the starting physical page of each block in turn to obtain the first out-of-band data, determine the block to be restored based on the block type data, and quickly narrow the reading range in the first block scan. The second time you only need to scan the last physical page of the block to be restored for data recovery.

Benefits of technology

Improve the efficiency of cache power outage recovery and ensure that blocks can be written normally after power outage recovery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512825B_ABST
    Figure CN119512825B_ABST
Patent Text Reader

Abstract

The present application provides a cache power failure recovery method, system and storage medium thereof, which obtain a target flash memory partition after a Flash memory is powered off, sequentially scan the starting physical page of each block in the target flash memory partition, and respectively obtain the first out-of-band data of each starting physical page, and then, according to each block type data, determine the block belonging to the used type as the first block to be recovered, and store the first block to be recovered in a first blockchain table, then, sequentially scan the last physical page of each first block to be recovered in the first blockchain table, and according to the data storage situation of the last physical page in the first block to be recovered, perform data recovery processing on the first block to be recovered, and determine and rebuild the target working block in the space to be rebuilt, and then through the first block scan and the second block scan, the block can be quickly recovered from power failure, thereby improving the efficiency of power failure recovery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer cache, and in particular to a cache power failure recovery method, system and storage medium thereof. Background Art

[0002] With the development of the Internet of Things, smart homes and mobile Internet, the popularity of embedded systems and mobile devices continues to increase. These devices usually need to use Flash storage to store data and programs. Flash storage has the advantages of high speed, low power consumption and reliability, so it has been widely used in embedded and mobile devices. However, the management of Flash storage is challenging for different hardware platforms and operating system environments, such as how to recover data after the Flash memory is powered off.

[0003] In the prior art, most power failure recovery mechanisms often require a comprehensive scan of all physical pages of each block after a power failure, and then determine which blocks require data recovery and which blocks do not require data recovery based on all physical page data of all blocks. The step of comprehensively scanning all physical pages of each block often takes too long, which greatly reduces the efficiency of power failure recovery. At the same time, after power failure data recovery, the problem of blocks not being able to be written normally may occur. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to propose a cache power failure recovery method, system and storage medium thereof, which quickly narrows and determines the reading range of the block to be recovered in the first block scan through the first out-of-band data, and then comprehensively scans the last physical page of the block to be recovered, thereby being able to accurately and quickly perform power failure recovery on the block to be recovered, thereby improving the efficiency of cache power failure recovery. At the same time, by rebuilding the target working block, it also ensures that the block after power failure recovery can be written normally.

[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a cache power failure recovery method, comprising:

[0006] Get the target flash memory partition after the Flash memory is powered off;

[0007] Scanning the starting physical page of each block in the target flash memory partition in sequence, and respectively acquiring the first out-of-band data of each starting physical page, wherein the first out-of-band data includes block type data for characterizing the block type, wherein the block type includes a used type;

[0008] According to each block type data, a block belonging to a used type is determined as a first block to be recovered, and the first block to be recovered is stored in a first blockchain table, where the first blockchain table is used to store blocks that need data recovery;

[0009] Scan the last physical page of each first block to be recovered in the first blockchain table in sequence, and perform data recovery processing on the first block to be recovered according to the data storage status of the last physical page in the first block to be recovered, and determine and rebuild the target working block in the space to be rebuilt;

[0010] Among them, data recovery processing is to recover the data of the logical page to physical page mapping relationship of all used blocks, that is, to recover the logical mapping table data for use in the next read and write operation processing; the space to be rebuilt is used to store all physical pages that are not fully written with user data, and the target working block is used as the data storage block when the next write operation is performed.

[0011] Furthermore, in some embodiments, the space to be rebuilt is provided with a first storage node and a second storage node, and determining and reconstructing a target working block in the space to be rebuilt includes:

[0012] Determine whether the first storage node and the second storage node are empty;

[0013] When both the first storage node and the second storage node are empty, an idle block is obtained from the head of the third blockchain table, and the idle block is determined as the target working block and rebuilt, wherein the third blockchain table is used to store blocks in an idle state;

[0014] Alternatively, when the second storage node is empty, the block stored in the first storage node is determined as the target working block and rebuilt;

[0015] Alternatively, when both the first storage node and the second storage node are not empty, the first usage count of the block stored in the first storage node and the second usage count of the block stored in the second storage node are obtained respectively, and the target working block is determined and rebuilt according to the first usage count and the second usage count.

[0016] Furthermore, in some embodiments, determining and reconstructing the target working block according to the first number of times used and the second number of times used includes:

[0017] If the first used count is less than the second used count, the block stored in the first storage node is determined as the target working block and rebuilt;

[0018] If the first used count is greater than or equal to the second used count, the block stored in the second storage node is determined as the target working block and rebuilt.

[0019] Furthermore, in some embodiments, data recovery processing is performed on the first block to be recovered according to the data storage status of the last physical page in the first block to be recovered, including:

[0020] Determine the first block to be restored in which all physical pages are not empty as the second block to be restored;

[0021] According to the data storage status of the last physical page in the second block to be recovered, data recovery processing is performed on the second block to be recovered.

[0022] Furthermore, in some embodiments, data recovery of the second block to be recovered according to the data storage status of the last physical page in the second block to be recovered includes:

[0023] Reading the flash memory working state of the Flash flash memory, as well as the second out-of-band data and the first mapping data of the last physical page in the second block to be recovered, wherein the second out-of-band data includes page type data for characterizing the type of the physical page, and the first mapping array includes physical mapping data for mapping each physical page except the last physical page in the second block to be recovered, and the first mapping array is stored in the last physical page of the second block to be recovered;

[0024] Determine whether the second block to be restored has triggered an ECC error according to the working status of the Flash memory;

[0025] If the second block to be recovered has triggered an ECC error, it is determined that obtaining the first mapping array is invalid, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is rebuilt according to each third out-of-band data, and the second block to be recovered is placed at the end of the second blockchain table, wherein the second blockchain table is used to store blocks that need to be garbage collected;

[0026] Alternatively, if the second block to be recovered has not triggered an ECC error, data recovery processing is performed on the first block to be recovered according to the second out-of-band data and the first mapping array.

[0027] Furthermore, in some embodiments, determining whether all physical pages in the second block to be recovered are fully written with user data according to the second out-of-band data and the first mapping array includes:

[0028] Determine, according to the page type data of the second out-of-band data, whether all physical pages except the last physical page in the second block to be restored are fully written with user data;

[0029] If all physical pages except the last physical page in the second block to be restored are fully written with user data, then the mapping data of the second block to be restored in the logical mapping table is rebuilt according to the first mapping array;

[0030] Alternatively, if all physical pages except the last physical page in the second block to be recovered are not fully written with user data, the space to be rebuilt is updated according to the second block to be recovered, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is reconstructed according to each third out-of-band data.

[0031] Furthermore, in some embodiments, determining whether all physical pages in the second to-be-recovered block are fully written with user data according to the page type data of the second out-of-band data includes:

[0032] When the physical page type of the page type data is a physical mapping page type, it is determined that all physical pages except the last physical page in the second block to be restored are fully written with user data;

[0033] Alternatively, when the physical page type of the page type data is a non-physical mapping page type or the page type data is empty data, it is determined that all physical pages except the last physical page in the second block to be restored are not fully written with user data.

[0034] Furthermore, in some embodiments, updating the to-be-reconstructed space according to the second to-be-recovered block includes:

[0035] Determine whether the first storage node is empty;

[0036] When the first storage node is empty, the second block to be restored is placed in the first storage node;

[0037] When the first storage node is not empty, determining whether the second storage node is empty;

[0038] When the second storage node is empty, the second block to be restored is placed in the second storage node;

[0039] When the second storage node is not empty, the block stored in the first storage node is placed at the end of the second blockchain table, the block stored in the second storage node is placed in the first storage node, and the second block to be recovered is placed in the second storage node.

[0040] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a cache power failure recovery system, comprising:

[0041] A partition reading module, the partition reading module is used to obtain a target flash memory partition after a power failure occurs in the cache;

[0042] A first power failure recovery module, the first power failure recovery module is used to sequentially scan the starting physical page of each block in the target flash memory partition, and respectively obtain the first out-of-band data of each starting physical page;

[0043] The first power failure recovery module is further used to determine the block type of each block according to each first out-of-band data, wherein the block type includes a used type;

[0044] The first power failure recovery module is further used to determine the block of the used type as the first block to be recovered, and store the first block to be recovered in the first blockchain table, where the first blockchain table is used to store blocks that need to be recovered;

[0045] The second power failure recovery module is used to scan the last physical page of each first block to be recovered in the first blockchain table in sequence, and according to the data storage situation of the last physical page in the first block to be recovered, perform data recovery processing on the first block to be recovered, and determine and rebuild the target working block in the space to be rebuilt; wherein the space to be rebuilt is used to store blocks whose physical pages are not fully written with user data, and the target working block is used as a data storage block when a write operation is performed next time.

[0046] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the cache power-off recovery method of the above-mentioned first aspect embodiment when executing the computer program.

[0047] To achieve the above-mentioned purpose, the fourth aspect of the embodiment of the present application proposes a storage medium, which is a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by the processor, the cache power-off recovery method of the above-mentioned first aspect embodiment is implemented.

[0048] The embodiments of the present application have the following beneficial effects: the present application obtains the target flash memory partition after the Flash flash memory is powered off, sequentially scans the starting physical page of each block in the target flash memory partition, and respectively obtains the first out-of-band data of each starting physical page, the first out-of-band data includes block type data for characterizing the block type, the block type includes a used type, and then, according to each block type data, determines the block belonging to the used type as the first block to be recovered, and stores the first block to be recovered in the first blockchain table, the first blockchain table is used to store blocks that need to be recovered, and then based on the first out-of-band data, quickly narrows and determines the reading range of the block to be recovered in the first block scan, and then, sequentially scans the first block The last physical page of each first block to be recovered in the linked list, and according to the data storage situation of the last physical page in the first block to be recovered, the first block to be recovered is processed for data recovery, and the target working block is determined and reconstructed in the space to be reconstructed; wherein, the space to be reconstructed is used to store blocks whose physical pages are not fully written with user data, and the target working block is used as the data storage block when the write operation is performed next time, and then in the second block scan, only the last physical page of each first block to be recovered needs to be scanned, which can further accurately and quickly perform power-off recovery on the block to be recovered, thereby improving the efficiency of cache power-off recovery, and at the same time, by reconstructing the target working block, it can be ensured that the block after power-off recovery can be written normally. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 is a flow chart of a cache power failure recovery method provided by some embodiments of the present application;

[0050] Figure 2 is a flowchart of determining and reconstructing a target working block in a space to be reconstructed provided by some embodiments of the present application;

[0051] Figure 3 is a flowchart of performing data recovery processing on a first block to be recovered provided by some embodiments of the present application;

[0052] Figure 4 Some embodiments of the present application provide Figure 3 Flowchart of step S302;

[0053] Figure 5 Some embodiments of the present application provide Figure 4 The flowchart before step S404;

[0054] Figure 6 Some embodiments of the present application provide Figure 5 Flowchart of step S501;

[0055] Figure 7is a flowchart of updating the space to be rebuilt according to the second block to be recovered provided by some embodiments of the present application;

[0056] Figure 8 A schematic diagram of the structure of a cache power failure recovery system provided in some embodiments of the present application;

[0057] Fig. 9 It is a schematic diagram of the hardware structure of an electronic device provided in some embodiments of the present application. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0059] In the description of the present application, it should be understood that descriptions involving orientation, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0060] It should also be noted that in the description of this application, "several" means more than one, "more" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used to distinguish the technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0062] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0063] First, some nouns involved in this application are analyzed:

[0064] NAND Flash memory is a non-volatile memory widely used to store data, which will not be lost even after power failure. With its high density, low cost and high write / erase performance, it has become the core technology of devices such as solid-state drives (SSDs), USB flash drives, and SD cards. Among them, NAND Flash uses block-level operations when writing and erasing data.

[0065] A linked list is a data structure used to store a series of linear data elements. Unlike an array, the elements in a linked list are not stored continuously, but each element is linked together through pointers or references. The basic component of a linked list is a node, and each node consists of two parts: a cache space (used to store specific data) and a pointer space (used to store a pointer to the next node or a pointer to the previous node).

[0066] Block is one of the basic units of NAND Flash memory. Each block consists of multiple pages. Usually, a page is the smallest read and write unit, and a block is the smallest erase unit.

[0067] In the prior art, most power failure recovery mechanisms often require a comprehensive scan of all physical pages of each block after a power failure, and then determine which blocks require data recovery and which blocks do not require data recovery based on all physical page data of all blocks. The step of comprehensively scanning all physical pages of each block often takes too long, which greatly reduces the efficiency of power failure recovery. At the same time, after power failure data recovery, the problem of blocks not being able to be written normally may occur.

[0068] Based on this, the present application obtains the target flash memory partition after the Flash flash memory is powered off, scans the starting physical page of each block in the target flash memory partition in sequence, and obtains the first out-of-band data of each starting physical page respectively, the first out-of-band data includes block type data for characterizing the block type, the block type includes a used type, and then, according to each block type data, the block belonging to the used type is determined as the first block to be recovered, and the first block to be recovered is stored in the first blockchain table, the first blockchain table is used to store blocks that need to be recovered, and then based on the first out-of-band data, the reading range of the block to be recovered is quickly narrowed and determined in the first block scan, and then, each first block in the first blockchain table is scanned in sequence. The last physical page of the block to be recovered is scanned in the second block scan, and according to the data storage status of the last physical page in the first block to be recovered, data recovery processing is performed on the first block to be recovered, and a target working block is determined and reconstructed in the space to be reconstructed; wherein the space to be reconstructed is used to store blocks whose physical pages are not fully written with user data, and the target working block is used as a data storage block when a write operation is performed next time, and then in the second block scan, only the last physical page of each first block to be recovered needs to be scanned, which can further accurately and quickly perform power-off recovery on the block to be recovered, thereby improving the efficiency of cache power-off recovery, and at the same time, by reconstructing the target working block, it can be ensured that the block can be written normally after power-off recovery.

[0069] A cache power failure recovery method, system and storage medium provided by the embodiments of the present application are specifically described through the following embodiments.

[0070] In the first aspect, a cache power failure recovery method in an embodiment of the present application is first described.

[0071] Reference Figure 1 As shown, Figure 1 It is a flowchart of a cache power failure recovery method provided in some embodiments of the present application. The cache power failure recovery method may include but is not limited to steps S101 to S104.

[0072] Step S101: obtaining a target flash memory partition after a power failure occurs in the Flash memory.

[0073] Specifically, when the Flash memory is restarted after being powered off, the target flash memory partition after the Flash memory is powered off is obtained.

[0074] Step S102: sequentially scan the starting physical page of each block in the target flash memory partition, and respectively obtain the first out-of-band data of each starting physical page.

[0075] The first out-of-band data is the oob data of the starting physical page of each block, and the first out-of-band data includes block type data for characterizing the block type, and the block type includes a used type.

[0076] In a possible implementation, the starting physical pages of each block in the target flash memory partition (i.e., the first physical page of each block) are traversed in a loop structure, and for each starting physical page, a read command is used to read the oob data of the starting physical page from the Flash.

[0077] It should be noted that the block type also includes a bad block type, a used type, an unused type, a filled type and other types. When the block type of the block is determined to be an unused type, the block of the unused block type is stored in the third blockchain table, and the third blockchain table stores blocks in an idle state; when the block type of the block is determined to be other types, the data of the block is cleared and the block after the data is cleared is stored in the third blockchain table.

[0078] It should be noted that the data characteristics stored in the oob data of the starting physical page are as follows: the first byte stores the page type, which is characterized as a normal fill page type; the second to fifth bytes store the logical page number; the sixth to ninth bytes store the number of times the block is used; and the tenth to twelfth bytes store the number of times the block is erased. When it is determined that the first to twelfth bytes of the starting physical page are all 0xFF, it means that the block is not used (that is, the block type of the block is an unused type); otherwise, it means that the block has been used (that is, the block type of the block is a used type).

[0079] Step S103: According to each block type data, a block belonging to a used type is determined as a first block to be recovered, and the first block to be recovered is stored in the first blockchain table.

[0080] Among them, the first blockchain table block_used_list is used to store blocks that need data recovery.

[0081] In a possible implementation, based on each block type data, a block belonging to a used type is determined in each block, and then the block belonging to the used type is determined as the first block to be recovered, and the first block to be recovered is stored in the first blockchain table.

[0082] It should be noted that the first block to be restored is divided into two situations according to the usage type: completely used (all physical pages are written with user data) and not completely used (only some physical pages are written with user data).

[0083] Furthermore, after executing step S103, the working area of ​​the flash memory needs to be initialized, so as to provide prerequisites for the flash memory to perform read and write operations, garbage collection operations, etc.

[0084] Step S104: sequentially scan the last physical page of each first block to be recovered in the first blockchain table, and perform data recovery processing on the first block to be recovered according to the data storage status of the last physical page in the first block to be recovered, and determine and rebuild the target working block in the space to be rebuilt.

[0085] Specifically, the last physical page of each first block to be recovered in the first blockchain table is scanned in sequence to obtain the second out-of-band data and the first mapping array of the last physical page of each first block to be recovered, and then the validity of the first mapping array is established according to the physical mapping page type of the second out-of-band data, data recovery processing is performed on the first block to be recovered according to the validity of the first mapping array, and the target working block is determined and reconstructed in the space to be reconstructed.

[0086] Among them, the first mapping array stores the logical mapping data of each physical page in the first block to be recovered except the last physical page, and the data recovery processing of the first block to be recovered according to the validity of the first mapping array is to restore and rebuild the logical mapping table; the space to be reconstructed is used to store blocks whose physical pages are not fully written with user data, and the target working block is used as the data storage block when the next write operation is performed.

[0087] Furthermore, the space to be rebuilt is provided with a first storage node and a second storage node. Figure 2 As shown, Figure 2 It is a flowchart of determining and reconstructing a target working block in a space to be reconstructed provided by some embodiments of the present application. The method of determining and reconstructing the target working block in the space to be reconstructed may include but is not limited to steps S201 to S204.

[0088] Step S201: Determine whether the first storage node and the second storage node are empty.

[0089] In a possible implementation, it is determined whether the first storage node and the second storage node are empty, that is, it is determined whether the first storage node block1 is null, and it is determined whether the second storage node block2 is null.

[0090] Step S202: When both the first storage node and the second storage node are empty, a free block is obtained from the head of the third blockchain table, and the free block is determined as the target working block and rebuilt.

[0091] Step S203: When the second storage node is not empty, the block stored in the first storage node is determined as the target working block and rebuilt.

[0092] In a possible implementation, when the second storage node block2 is null, the first storage node block1 is not null, and the block stored in the first storage node is determined as the target working block and rebuilt.

[0093] Step S204: when both the first storage node and the second storage node are not empty, the target working block is determined and rebuilt according to the number of times the first storage node and the second storage node have been used.

[0094] In a possible implementation, when the first storage node block1 and the second storage node block2 are not null at the same time, the first usage count of the block stored in the first storage node and the second usage count of the block stored in the second storage node are obtained respectively, and the target working block is determined and reconstructed based on the first usage count and the second usage count.

[0095] Among them, determining the target working block and rebuilding it according to the first number of times used and the second number of times used includes the following steps: if the first number of times used is less than the second number of times used, determining the block stored in the first storage node as the target working block and rebuilding it; if the first number of times used is greater than or equal to the second number of times used, determining the block stored in the second storage node as the target working block and rebuilding it.

[0096] In general, in the process from step S201 to step S204, the first storage node and the second storage node can provide block sources for rebuilding the target working block, and when the first storage node and the second storage node are both empty, an idle block can be obtained from the head of the third blockchain table as the target working block, thereby ensuring that the target working blocks are blocks that are not fully written with user data, ensuring that the read and write operations can be performed normally when the write operation is performed next time.

[0097] Reference Figure 3 As shown, Figure 3 It is a flowchart of performing data recovery processing on the first block to be recovered provided by some embodiments of the present application. The method of performing data recovery processing on the first block to be recovered may include but is not limited to steps S301 to S302.

[0098] Step S301: Determine a first block to be restored in which all physical pages are not empty as a second block to be restored.

[0099] In a possible implementation manner, a first block to be restored in which all physical pages are not empty is determined as the second block to be restored.

[0100] Specifically, the process of determining that all physical pages of the first block to be recovered are not empty is as follows: when it is determined that the page type stored in the first byte of the out-of-band data of the last physical page in the first block to be recovered is all the physical mapping page type, it is determined that the last physical page of the first block to be recovered is written with the logical mapping data (that is, the logical mapping physical page is not empty), and it is further determined whether all physical pages except the last physical page of the first block to be recovered are all written with user data. When all physical pages except the last physical page are all written with user data, it is determined that all physical pages of the first block to be recovered are not empty; and when it is determined that the page type stored in the first byte of the out-of-band data of the last physical page in the first block to be recovered is not the physical mapping page or is empty, it is determined that the data of the last physical page of the first block to be recovered is invalid (that is, the logical mapping physical page is empty), and it is further determined whether all physical pages except the last physical page of the first block to be recovered have data. When all physical pages except the last physical page of the first block to be recovered have no data, it is determined that all physical pages of the first block to be recovered are empty.

[0101] Step S302: performing data recovery processing on the second block to be recovered according to the data storage status of the last physical page in the second block to be recovered.

[0102] In a possible implementation, data recovery processing is performed on the second block to be recovered according to the data storage status of the last physical page in the second block to be recovered.

[0103] Reference Figure 4 As shown, Figure 4 Some embodiments of the present application provide Figure 3 In the flowchart of step S302, the cache power failure recovery method may include but is not limited to steps S401 to S404.

[0104] Step S401: reading the working status of the Flash memory, as well as the second out-of-band data of the last physical page in the second block to be restored and the first mapping array.

[0105] The second out-of-band data is the oob data of the last physical page of each block, and the second out-of-band data includes page type data for characterizing the type of the physical page. The first mapping array includes physical mapping data for mapping each physical page except the last physical page in the second block to be recovered, and the first mapping array is stored in the last physical page of the second block to be recovered;

[0106] It should be noted that the data characteristics stored in the oob data of the last physical page are: the first byte stores the page type, which is characterized as the page type; bytes 2 to 5 store invalid data; bytes 6 to 9 store the number of times the block has been used; and bytes 10 to 12 store the number of times the block has been erased.

[0107] In a possible implementation manner, the cache working state of the Flash memory, as well as the second out-of-band data of the last physical page in the second block to be restored and the first mapping array are read.

[0108] Step S402: Determine whether the second block to be restored has triggered an ECC error according to the Flash memory working status.

[0109] In a possible implementation, according to reading the working state of the last physical page in the second block to be restored of the Flash memory, an ECC check is performed on the second block to be restored to determine whether the second block to be restored has triggered an ECC error.

[0110] Step S403: If the second block to be recovered has triggered an ECC error, the first mapping array is invalidated, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is rebuilt according to each third out-of-band data, and the second block to be recovered is placed at the end of the second blockchain table.

[0111] Among them, the second blockchain table priority_gc_list is used to store blocks that need to be garbage collected.

[0112] In a possible implementation, if the second block to be recovered has triggered an ECC error, the first mapping array is determined to be invalid, the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and then each third out-of-band data is parsed, wherein the 2nd to 5th bytes of each third out-of-band data store the logical page number logic_page_num corresponding to each physical page, and then the physical block number block_num and each physical page number page_num mapped in the Flash memory of the second block to be recovered in the logical mapping table according to the logical page number logic_page_num, and finally, since the second block to be recovered has triggered an ECC error, the second block to be recovered also needs to be placed at the end of the second blockchain table.

[0113] It should be noted that after the mapping data of the second block to be recovered is restored in the logical mapping table, in the subsequent processing flow, if the user needs to read the file data in the file system, the corresponding physical block number and physical page number can be found in the logical mapping table by passing the logical page number, and then the stored user data can be read from the Flash memory according to the physical block number and physical page number and returned to the user.

[0114] It should also be noted that after the mapping data of the second block to be recovered is restored in the logical mapping table, in the subsequent processing flow, if the user needs to write file data, the logical page number can be passed to search the logical mapping table for the corresponding physical block number and physical page number and write to the target working block. Based on whether the physical block number and physical page number exist, it is determined whether to add the new physical block number and physical page number to the logical mapping table or to update the new physical block number and physical page number to the logical mapping table.

[0115] In general, in the above step S403, if an ECC error occurs in the second block to be recovered, it means that an error occurs in the process of reading the data of the last physical page, but the out-of-band data can still be read in the non-last physical page of the current second block to be recovered, and the logical page number corresponding to each physical page can be obtained according to these out-of-band data to recover the mapping data of the second block to be recovered, and further rebuild the logical mapping table. At the same time, in this case, since the data of the last physical page has a read exception (it may also be a write failure), the second block to be recovered with the ECC error needs to be put into the second blockchain table to recycle the second block to be recovered.

[0116] Step S404: Alternatively, if the second block to be recovered has not triggered an ECC error, data recovery processing is performed on the first block to be recovered according to the first mapping array.

[0117] In a possible implementation, or if the second block to be recovered has not triggered an ECC error, data recovery processing is performed on the first block to be recovered according to the physical mapping data, and a target working block is determined and reconstructed in the space to be reconstructed.

[0118] Reference Figure 5 As shown, Figure 5 Some embodiments of the present application provide Figure 4 In the flowchart before step S404, the cache power failure recovery method may include but is not limited to steps S501 to S503.

[0119] Step S501: Determine, based on the second out-of-band data of the last physical page, whether all physical pages except the last physical page in the second to-be-recovered block are fully written with user data.

[0120] In a possible implementation, the second out-of-band data of the last physical page determines whether all physical pages except the last physical page in the second block to be recovered have stored valid user data.

[0121] Step S502: If all physical pages except the last physical page in the second block to be restored are fully written with user data, the mapping data of the second block to be restored in the logical mapping table is rebuilt according to the first mapping array.

[0122] In a possible implementation, if all physical pages except the last physical page in the second block to be recovered are filled with user data (i.e., the page type stored in the first byte of the second out-of-band data of the last physical page in the second block to be recovered is a physical mapping page type), then, the logical page number logic_page_num of each physical page of the second block to be recovered is obtained according to the first mapping array, and finally, the physical block number block_num of the second block to be recovered and each physical page number page_num are written into the data space corresponding to each logical page number logic_page_num in the logical mapping table, thereby completing the work of reconstructing the mapping data of the second block to be recovered in the logical mapping table.

[0123] In general, in step S502, by reading the data of all the second blocks to be restored in the first blockchain table block_used_list, the mapping relationship between the physical page and the logical page in the second block to be restored, that is, the logical mapping table, can be quickly restored. When the user needs to read a file, the logical data sector can be passed, and then converted into a logical page number logic_page_num, and finally, the corresponding physical block number block_num and each physical page number page_num can be read in the logical mapping table according to the logical page number logic_page_num, so as to quickly realize the mapping process from the logical space to the physical space, and read the data from the physical space (that is, the second block to be restored in the first blockchain table block_used_list).

[0124] Step S503: Alternatively, if all physical pages except the last physical page in the second block to be recovered are not fully written with user data, the space to be rebuilt is updated according to the second block to be recovered, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is reconstructed according to each third out-of-band data.

[0125] In one possible implementation, if all physical pages in the second block to be recovered are not fully written with user data, the space to be rebuilt is updated based on the second block to be recovered, and the third out-of-band data of each physical page in the second block to be recovered except the last physical page is read, and the mapping data of the second block to be recovered in the logical mapping table is reconstructed based on each third out-of-band data.

[0126] Specifically, the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the process of reconstructing the mapping data of the second block to be recovered in the logical mapping table according to each third out-of-band data is as follows: read the logical page number logic_page_num corresponding to each physical page stored in the 2nd to 5th bytes of each third out-band data, and then write the physical block number block_num of the second block to be recovered and each physical page number page_num into the data space corresponding to each logical page number logic_page_num in the logical mapping table, thereby completing the reconstruction of the data of the second block to be recovered in the logical mapping table.

[0127] Among them, when the first byte of the third out-of-band data is a normal fill page type, it means that the logic_page_num corresponding to the physical page is valid, and the physical page number page_num will be written into the logical mapping table; when the first byte of the third out-of-band data is a non-normal fill page type, it indicates that the physical page has no data and will not be rebuilt.

[0128] Reference Figure 6 As shown, Figure 6 Some embodiments of the present application provide Figure 5 Flowchart of step S501, the cache power failure recovery method may include but is not limited to steps S601 to S602.

[0129] Step S601: when the physical page type of the page type data is a physical mapping page type, it is determined that all physical pages except the last physical page in the second block to be restored are fully written with user data.

[0130] Specifically, when it is determined that the data stored in the first byte of the second out-of-band data of the last physical page (i.e., the page type data) is a physical mapping page type, the first mapping array is determined to be valid data. When the first mapping array is valid data, it is determined that all physical pages other than the last physical page in the second block to be recovered are filled with user data.

[0131] Step S602: Alternatively, when the physical page type of the page type data is not a physical mapping page type or the page type data is empty data, it is determined that all physical pages except the last physical page in the second block to be restored are not fully written with user data.

[0132] Specifically, when it is determined that the data stored in the first byte of the second out-of-band data of the last physical page (i.e., the page type data) is not the physical mapping page type or the page type data is empty data, it is determined that the first mapping array is invalid data. When the first mapping array is invalid data, it is determined that all physical pages other than the last physical page in the second block to be recovered are not all filled with user data.

[0133] Reference Figure 7 As shown, Figure 7 It is a flowchart of updating the space to be reconstructed according to the second block to be recovered provided by some embodiments of the present application. The method of updating the space to be reconstructed according to the second block to be recovered may include but is not limited to steps S701 to S704.

[0134] Step S701: Determine whether the first storage node is empty.

[0135] In a possible implementation, it is determined whether the first storage node is empty, that is, whether the first storage node block1 is null.

[0136] Step S702: When the first storage node is empty, the second block to be restored is placed in the first storage node.

[0137] Specifically, when the first storage node block1 is null, the second block to be recovered is placed in the first storage node.

[0138] Step S703: When the first storage node is not empty, determine whether the second storage node is empty.

[0139] In a possible implementation, when the first storage node block1 is not null, it is determined whether the second storage node is empty, that is, it is determined whether the second storage node block2 is null at the same time.

[0140] Step S704: When the second storage node is empty, the second block to be restored is placed in the second storage node.

[0141] In a possible implementation, when the first storage node block1 is not null and the second storage node block2 is null, the second block to be restored is placed in the second storage node block2.

[0142] Step S705: When the second storage node is not empty, the block stored in the first storage node is placed at the end of the second blockchain table, the block stored in the second storage node is placed in the first storage node, and the second block to be recovered is placed in the second storage node.

[0143] In a possible implementation, when the first storage node block1 is not null and the second storage node block2 is not null, the block stored in the first storage node block1 is first placed at the end of the second blockchain table, and then the block stored in the second storage node block2 is placed in the first storage node block1, and finally, the second block to be recovered is placed in the second storage node block2.

[0144] It should be noted that in the power failure recovery process, the second block to be recovered is placed in the second storage node, and the block stored in the first storage node is placed at the end of the second blockchain table, so that garbage collection can be performed on the second block to be recovered whose physical pages are not fully written, thereby freeing up more storage space to meet subsequent read and write needs.

[0145] In a second aspect, the present application also provides a cache power failure recovery system, referring to Figure 8 , Figure 8 A schematic diagram of a cache power failure recovery system provided in some embodiments of the present application, wherein the cache power failure recovery system 800 includes:

[0146] The partition reading module 801 is used to obtain the target flash memory partition after the cache is powered off;

[0147] A first power failure recovery module 802, the first power failure recovery module 802 is used to sequentially scan the starting physical page of each block in the target flash memory partition, and respectively obtain the first out-of-band data of each starting physical page;

[0148] The first power failure recovery module 802 is further used to determine the block type of each block according to each first out-of-band data, wherein the block type includes a used type;

[0149] The first power failure recovery module 802 is further used to determine the used type of block as the first block to be recovered, and store the first block to be recovered in the first blockchain table, where the first blockchain table is used to store blocks that need to be recovered;

[0150] The second power failure recovery module 803 is used to sequentially scan the last physical page of each first block to be recovered in the first blockchain table, and perform data recovery processing on the first block to be recovered according to the data storage status of all physical pages in the first block to be recovered, and determine and rebuild the target working block in the space to be rebuilt; wherein the space to be rebuilt is used to store blocks whose physical pages are not fully written with user data, and the target working block is used as a data storage block when a write operation is performed next time.

[0151] The cache power failure recovery system 800 and the cache power failure recovery method are based on the same inventive concept. The above process describes the cache power failure recovery system 800 of the embodiment of the present application, which obtains the target flash memory partition after the Flash flash memory is powered off, scans the starting physical page of each block in the target flash memory partition in sequence, and obtains the first out-of-band data of each starting physical page respectively, the first out-of-band data includes block type data for characterizing the block type, the block type includes a used type, and then, according to each block type data, the block belonging to the used type is determined as the first block to be recovered, and the first block to be recovered is stored in the first blockchain table, the first blockchain table is used to store the blocks that need to be recovered, and then based on the first out-of-band data The reading range of the block to be recovered is quickly narrowed down and determined in the first block scan, and then all physical pages of each first block to be recovered in the first blockchain table are scanned in turn, and data recovery processing is performed on the first block to be recovered according to the data storage status of all physical pages in the first block to be recovered, and a target working block is determined and reconstructed in the space to be reconstructed; wherein the space to be reconstructed is used to store blocks whose physical pages are not all fully written with user data, and the target working block is used as a data storage block when a write operation is performed next time, so that the block to be recovered can be accurately and quickly restored from power failure, thereby improving the efficiency of cache power failure recovery, and at the same time, by reconstructing the target working block, it is ensured that the block after power failure recovery can be written normally.

[0152] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the cache power failure recovery method when executing the computer program. The electronic device can be any smart terminal including a mobile phone, a tablet computer, a car computer, etc.

[0153] See also Fig. 9 , Fig. 9 : is a schematic diagram of the hardware structure of an electronic device provided in some embodiments of the present application, and the electronic device includes:

[0154] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the cache power failure recovery method provided in the embodiment of the present application;

[0155] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the cache power-off recovery method provided in the embodiment of this application;

[0156] Input / output interface 903, used to implement information input and output;

[0157] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0158] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);

[0159] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .

[0160] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the cache power failure recovery method provided in the embodiment of the present application is implemented.

[0161] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0162] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0163] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0164] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0165] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0166] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0167] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0168] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0169] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0170] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0171] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0172] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A cache power failure recovery method, characterized in that: include: Get the target flash memory partition after the Flash memory is powered off; Scanning the starting physical page of each block in the target flash memory partition in sequence, and respectively acquiring first out-of-band data of each starting physical page, wherein the first out-of-band data includes block type data for characterizing a block type, wherein the block type includes a used type; According to each of the block type data, a block belonging to the used type is determined as a first block to be recovered, and the first block to be recovered is stored in a first blockchain table, where the first blockchain table is used to store blocks that need to be recovered; sequentially scan the last physical page of each of the first blocks to be recovered in the first blockchain table, and perform data recovery processing on the first blocks to be recovered according to the data storage status of the last physical page in the first blocks to be recovered, and determine and rebuild the target working block in the space to be rebuilt; The to-be-reconstructed space is used to store blocks of all physical pages that are not fully written with user data, and the target working block is used as a data storage block when a write operation is performed next time; Further, performing data recovery processing on the first block to be recovered according to the data storage status of the last physical page in the first block to be recovered includes the following steps: Determine the first block to be restored in which all physical pages are not empty as the second block to be restored; Reading the working state of the Flash memory, as well as the second out-of-band data of the last physical page in the second block to be recovered and the first mapping array, wherein the second out-of-band data includes page type data for characterizing the type of the physical page, and the first mapping array includes physical mapping data for mapping each physical page except the last physical page in the second block to be recovered, and the first mapping array is stored in the last physical page of the second block to be recovered; Determine whether the second block to be restored has triggered an ECC error according to the working status of the Flash memory; If the second block to be recovered has triggered an ECC error, it is determined that obtaining the first mapping array is invalid, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is rebuilt according to each of the third out-of-band data, and the second block to be recovered is placed at the end of the second blockchain table, wherein the second blockchain table is used to store blocks that need to be garbage collected; Alternatively, if the second block to be recovered has not triggered an ECC error, data recovery processing is performed on the first block to be recovered based on the second out-of-band data and the first mapping array.

2. The cache power failure recovery method according to claim 1, characterized in that: The space to be reconstructed is provided with a first storage node and a second storage node, and the step of determining and reconstructing the target working block in the space to be reconstructed includes: Determine whether the first storage node and the second storage node are empty; When both the first storage node and the second storage node are empty, an idle block is obtained from the head of a third blockchain table, and the idle block is determined as the target working block and rebuilt, wherein the third blockchain table is used to store blocks in an idle state; Alternatively, when the second storage node is empty, the block stored in the first storage node is determined as the target working block and rebuilt; Alternatively, when both the first storage node and the second storage node are not empty, the first usage count of the block stored in the first storage node and the second usage count of the block stored in the second storage node are obtained respectively, and the target working block is determined and reconstructed based on the first usage count and the second usage count.

3. The cache power failure recovery method according to claim 2, characterized in that: The step of determining and reconstructing the target working block according to the first used count and the second used count includes: If the first used count is less than the second used count, determining the block stored in the first storage node as the target working block and rebuilding it; If the first number of times used is greater than or equal to the second number of times used, the block stored in the second storage node is determined as the target working block and rebuilt.

4. The cache power failure recovery method according to claim 2, characterized in that: The performing data recovery processing on the first block to be recovered according to the second out-of-band data and the first mapping array includes: Determine, according to the page type data of the second out-of-band data, whether all physical pages except the last physical page in the second block to be recovered are fully written with user data; If all physical pages except the last physical page in the second block to be restored are fully written with user data, rebuilding the mapping data of the second block to be restored in the logical mapping table according to the first mapping array; Alternatively, if all physical pages except the last physical page in the second block to be recovered are not fully written with user data, the space to be rebuilt is updated according to the second block to be recovered, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is reconstructed according to each of the third out-of-band data.

5. The cache power failure recovery method according to claim 4, characterized in that: The determining, according to the page type data of the second out-of-band data, whether all physical pages except the last physical page in the second block to be recovered are fully written with user data includes: When the physical page type of the page type data is a physical mapping page type, determining that each physical page except the last physical page in the second block to be restored is fully written with user data; Alternatively, when the physical page type of the page type data is a non-physical mapping page type or the page type data is empty data, it is determined that all physical pages except the last physical page in the second block to be recovered are not fully written with user data.

6. The cache power failure recovery method according to claim 4, characterized in that: The updating of the to-be-reconstructed space according to the second to-be-recovered block includes: Determine whether the first storage node is empty; When the first storage node is empty, placing the second block to be recovered into the first storage node; When the first storage node is not empty, determining whether the second storage node is empty; When the second storage node is empty, placing the second block to be restored into the second storage node; When the second storage node is not empty, the blocks stored by the first storage node are placed at the end of the second blockchain table, the blocks stored by the second storage node are placed at the first storage node, and the second block to be recovered is placed at the second storage node.

7. A cache power failure recovery system, characterized in that: include: A partition reading module, wherein the partition reading module is used to obtain a target flash memory partition after the flash memory is restored after power failure; A first power failure recovery module, the first power failure recovery module is used to sequentially scan the starting physical page of each block in the target flash memory partition, and respectively obtain the first out-of-band data of each starting physical page; The first power failure recovery module is further used to determine the block type of each of the blocks according to each of the first out-of-band data, wherein the block type includes a used type; The first power failure recovery module is further used to determine the used type of block as a first block to be recovered, and store the first block to be recovered in a first blockchain table, where the first blockchain table is used to store blocks that need data recovery; a second power failure recovery module, the second power failure recovery module is used to sequentially scan the last physical page of each of the first blocks to be recovered in the first blockchain table, and perform data recovery processing on the first blocks to be recovered according to the data storage status of the last physical page in the first blocks to be recovered, and determine and rebuild the target working block in the space to be rebuilt; wherein the space to be rebuilt is used to store blocks whose physical pages are not fully written with user data, and the target working block is used as a data storage block when a write operation is performed next time; Further, performing data recovery processing on the first block to be recovered according to the data storage status of the last physical page in the first block to be recovered includes the following steps: Determine the first block to be restored in which all physical pages are not empty as the second block to be restored; Reading the working state of the Flash memory, as well as the second out-of-band data of the last physical page in the second block to be recovered and the first mapping array, wherein the second out-of-band data includes page type data for characterizing the type of the physical page, and the first mapping array includes physical mapping data for mapping each physical page except the last physical page in the second block to be recovered, and the first mapping array is stored in the last physical page of the second block to be recovered; Determine whether the second block to be restored has triggered an ECC error according to the working status of the Flash memory; If the second block to be recovered has triggered an ECC error, it is determined that obtaining the first mapping array is invalid, and the third out-of-band data of each physical page except the last physical page in the second block to be recovered is read, and the mapping data of the second block to be recovered in the logical mapping table is rebuilt according to each of the third out-of-band data, and the second block to be recovered is placed at the end of the second blockchain table, wherein the second blockchain table is used to store blocks that need to be garbage collected; Alternatively, if the second block to be recovered has not triggered an ECC error, data recovery processing is performed on the first block to be recovered based on the second out-of-band data and the first mapping array.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the cache power failure recovery method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method for rapidly booting solid state disc and solid state disc thereof

    CN103744795A

  • Quick reestablishment method for RAID (redundan array of inexpensive disk)

    CN104142872A

  • Data recovery method for solid state disk, and solid state disk

    CN108874318A