Data recovery method, storage control chip and flash memory device

By forcibly flushing valid metadata when the flash memory device crashes and then reading the data from the flash memory medium after power-on, the problem of insufficient flexibility and long time consumption in data recovery in the prior art is solved, and efficient data recovery is achieved.

CN122132223APending Publication Date: 2026-06-02DAPUSTOR CORP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
DAPUSTOR CORP
Filing Date
2024-11-29
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In existing technologies, data recovery from flash memory devices after a system crash can only be completed in a small system state, which is not flexible enough and the whole disk reconstruction process is time-consuming and inefficient.

Method used

When the flash memory device crashes, the valid metadata of the memory space is forced to be written to the flash memory medium by power failure, and the valid metadata is read from the flash memory medium after power is restored. This skips the data flushing process of the front-end module and directly writes the data to the flash memory medium through the flash algorithm module and the back-end module.

Benefits of technology

It improves the efficiency and flexibility of data recovery, allowing data recovery to be completed without entering a small system state, thus reducing the time required for data recovery after a system crash.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132223A_ABST
    Figure CN122132223A_ABST
Patent Text Reader

Abstract

This application relates to the field of storage device applications and discloses a data recovery method, a storage control chip, and a flash memory device. When the flash memory device is in a crash state, in response to a user's power-off operation, valid metadata stored in the memory space is written to the flash memory medium. After the flash memory device is powered on again, the valid metadata is read from the flash memory medium to restore the valid metadata to the memory space. This application can force the flash memory to be flushed when the flash memory device is crashed, thereby enabling the recovery of complete valid metadata without data reconstruction after the flash memory device is powered on, thus improving the efficiency of data recovery. Furthermore, data recovery can be performed without entering a small system state, improving the flexibility of data recovery for flash memory devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage device applications, and in particular to a data recovery method, a storage control chip, and a flash memory device. Background Technology

[0002] Flash memory devices, such as solid-state drives (SSDs), are storage devices that use NAND flash memory as their medium. As the functionality of flash memory devices becomes increasingly complex, the risks they face during operation also increase. For example, if an assertion failure or memory anomaly occurs during device operation, the firmware may malfunction, leading to system crashes. After a flash memory device crashes, data recovery is necessary.

[0003] Currently, data recovery is typically performed by controlling the flash memory device to enter a mini-system. Specifically, data is recovered through a full disk rebuild while in mini-system mode. A mini-system is an operating system running in a simplified or dedicated environment that has direct access to and management of the flash memory device.

[0004] In the process of developing this application, the inventors discovered that the prior art has at least the following problems: data recovery can only be completed in the state of a small system, which is not flexible enough; full reconstruction requires scanning all data blocks of the flash memory device, which is time-consuming and inefficient. Summary of the Invention

[0005] This application provides a data recovery method, a storage control chip, and a flash memory device to improve the flexibility and efficiency of data recovery using flash memory devices.

[0006] The embodiments of this application provide the following technical solutions:

[0007] In a first aspect, embodiments of this application provide a data recovery method applied to a flash memory device, the flash memory device including flash memory medium and memory space, the data recovery method comprising:

[0008] When the flash memory device is in a crash state, in response to the user's power-off operation on the flash memory device, the valid metadata stored in the memory space is written to the flash memory medium.

[0009] After the flash memory device is powered on again, valid metadata is read from the flash memory medium to restore the valid metadata to the memory space.

[0010] In some embodiments, before writing valid metadata to the flash memory medium in response to a user power-down operation on the flash memory device, the method further includes:

[0011] When an assertion failure or memory anomaly occurs in a flash memory device, the state of the flash memory device is identified, including a crash state.

[0012] When a flash memory device is detected to be in a crash state, the value of a global variable is set to the first value. The global variable is used to identify the state of the flash memory device.

[0013] In some embodiments, the flash memory device includes a flash algorithm module and a backend module, and the memory space further includes a cache area;

[0014] In response to a user power-off operation on the flash memory device, valid metadata is written to the flash memory medium, including:

[0015] In response to the user's power-off operation on the flash memory device, the status of the flash memory device is identified;

[0016] When the flash memory device is detected to be in a downtime state, the effective metadata is written from the cache area to the flash memory medium based on the flash memory algorithm module and the back-end module.

[0017] The valid metadata includes a first mapping table from host logical address to flash physical address and a second mapping table from flash physical address to host logical address.

[0018] In some embodiments, in response to a user power-down operation on the flash memory device, the state of the flash memory device is identified, including:

[0019] Query global variables;

[0020] When the value of the global variable is the first value, the flash memory device is determined to be in a crash state.

[0021] In some embodiments, writing valid metadata to the flash memory medium in response to a user power-down operation on the flash memory device further includes:

[0022] If any valid metadata fails to be written to the flash memory, the backend module will re-perform the write operation on the valid metadata until it is successfully written to the flash memory.

[0023] In some embodiments, the flash memory device further includes a front-end module;

[0024] The method also includes:

[0025] In response to the user's power-off operation on the flash memory device, when it is detected that the flash memory device is not in a down state, the front-end module generates a corresponding write command for the data stored in the cache area and adds the write command to the command queue in sequence. The data stored in the cache area includes valid metadata.

[0026] Based on the front-end module, write commands in the command queue are sent sequentially to the flash memory algorithm module, so that the flash memory algorithm module and the back-end module can write the data corresponding to the write command into the flash memory medium.

[0027] In some embodiments, the flash memory device is communicatively connected to the host;

[0028] After restoring the valid metadata to memory space, the method also includes:

[0029] Identify the status of the flash memory device;

[0030] When the flash memory device is detected to be in a crash state, grant the host permission to execute read and erase commands.

[0031] In some embodiments, the flash memory device further includes non-volatile memory for storing the values ​​of global variables used to identify the state of the flash memory device;

[0032] Identify the status of flash memory devices, including:

[0033] Read the value of the global variable from non-volatile memory;

[0034] When the value of the global variable is the first value, the flash memory device is determined to be in a crash state.

[0035] In some embodiments, the flash memory device communicates with the host via an interface;

[0036] Grant the host execute permissions for read and erase commands, including:

[0037] Set the flash memory device to read-only mode;

[0038] Create a whitelist and configure the host in the whitelist to have permissions to read or erase data;

[0039] Based on the interface, obtain the read command or erase command sent by the host.

[0040] Secondly, embodiments of this application provide a storage control chip, comprising:

[0041] At least one processor; and,

[0042] A memory that is communicatively connected to at least one processor; wherein,

[0043] The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to perform the data recovery method as described in the first aspect.

[0044] Thirdly, embodiments of this application provide a flash memory device, including:

[0045] Such as the storage control chip in the second aspect;

[0046] At least one flash memory medium is communicatively connected to the storage controller chip.

[0047] Fourthly, embodiments of this application also provide a non-volatile computer-readable storage medium storing computer-executable instructions for enabling a flash memory device to perform the data recovery method as described in the first aspect.

[0048] The beneficial effects of this application embodiment are as follows: Unlike the prior art, this application embodiment provides a data recovery method applied to a flash memory device, which includes a flash memory medium and a memory space. The data recovery method includes: when the flash memory device is in a crash state, in response to the user's power-off operation on the flash memory device, writing the valid metadata stored in the memory space to the flash memory medium; and after the flash memory device is powered on again, reading the valid metadata from the flash memory medium to restore the valid metadata to the memory space.

[0049] By writing valid metadata stored in the memory space to the flash medium in response to the user's power-down operation when the flash device is in a crash state, and reading valid metadata from the flash medium after the flash device is powered on again to restore the valid metadata to the memory space, this application can force the flash device to flush valid metadata when it crashes. This allows the complete valid metadata to be restored without data reconstruction after the flash device is powered on, thereby improving the efficiency of data recovery. Furthermore, data recovery can be performed without entering a small system state, which improves the flexibility of data recovery for flash devices. Attached Figure Description

[0050] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0051] Figure 1 This is a flowchart illustrating a data recovery method provided in an embodiment of this application;

[0052] Figure 2 This is a schematic diagram of a process for identifying and recording downtime status provided in an embodiment of this application;

[0053] Figure 3 yes Figure 1 A detailed flowchart of step S101;

[0054] Figure 4This is a schematic diagram of the structure of a main control system for a flash memory device provided in an embodiment of this application;

[0055] Figure 5 This is a flowchart illustrating an embodiment of the present application that grants a host the execution permissions for read and erase commands.

[0056] Figure 6 This is a schematic diagram of the structure of a storage control chip provided in an embodiment of this application;

[0057] Figure 7 This is a schematic diagram of the structure of a flash memory device provided in an embodiment of this application. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0059] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. Moreover, the terms "first," "second," and "third" used in this application do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.

[0060] The technical solution of this application will be described in detail below with reference to the accompanying drawings:

[0061] Flash memory devices, such as solid-state drives (SSDs), are storage devices that use NAND flash memory as their medium. With the increasing complexity of flash memory devices, such as the introduction of features like in-disk encryption, multi-streaming, and transparent in-disk compression, the firmware (FW) of flash memory devices has evolved into a highly complex system. It not only needs to perform routine erase, write, and read operations but also handle branching functions under various abnormal conditions. Due to the large system size and high interdependence among multiple functions, the risks faced by flash memory devices during operation are constantly increasing, and the probability of downtime is also rising. Downtime refers to the phenomenon where a device stops working due to a malfunction or abnormality during operation and cannot provide normal service.

[0062] In some extremely unpredictable situations, such as assertion failures or memory anomalies during software code execution, firmware may malfunction, leading to system crashes (bricking). Firmware is a type of embedded software that runs on hardware devices to control and manage their functions.

[0063] When a system crashes, users cannot read the data in the flash memory device, nor can they erase the data that has already been written, which can easily lead to security risks such as data loss or leakage. Therefore, it is necessary to recover the data after the flash memory device crashes.

[0064] Currently, data recovery is typically performed by controlling the flash memory device to enter a small system. Specifically, data is recovered through a full disk rebuild while in a small system state. A small system is an operating system running in a simplified or dedicated environment that can directly access and manage the flash memory device. In a small system state, the flash memory device can recognize character devices and issue commands to the flash media. Character devices are devices that transmit data as character streams, such as serial ports, keyboards, and mice. A full disk rebuild refers to a comprehensive scan, reorganization, and verification of all data blocks or sectors of the flash memory device to reconstruct the data structure or file system, thereby recovering the complete data on the flash memory device.

[0065] However, existing solutions can only complete data recovery in a small system state, which is not flexible enough; moreover, they require a full rebuild, scanning all data blocks of the flash memory device, which is time-consuming, usually more than 1 hour, and is inefficient.

[0066] Based on this, this application proposes a data recovery method that forcibly flushes valid metadata when the flash memory device crashes and then restores the complete valid metadata after the flash memory device is powered on, thereby improving the flexibility and efficiency of data recovery from the flash memory device.

[0067] As is understandable, a flash memory device consists of a storage controller chip and flash memory media, with its firmware running on the storage controller chip. The interaction between the host and the flash memory device is essentially an interaction process between the host and the firmware, and between the firmware and the flash memory media. For example, the host sends a write command or a read command to the flash memory device, the firmware receives and parses the corresponding command, and writes data to or reads data from the flash memory media.

[0068] If the firmware fails to run, the host will be unable to perform any effective operations on the flash memory media. Therefore, this data recovery method is executed when the firmware failure causes the flash memory device to crash, so that the host can subsequently access and operate the flash memory media via commands.

[0069] Please see Figure 1 , Figure 1This is a flowchart illustrating a data recovery method provided in an embodiment of this application;

[0070] This data recovery method is applied to a flash memory device, specifically, to at least one processor within the flash memory device. In this embodiment, the flash memory device includes a solid-state drive or other storage device that uses flash memory as the storage medium.

[0071] The flash memory device includes flash memory media and memory space. The memory space is used to store data received from the host. For example, the data is valid metadata, which includes, but is not limited to, file location information, bad block management information, and other metadata. For example, the valid metadata includes a first mapping table from the host logical address to the flash memory physical address and a second mapping table from the flash memory physical address to the host logical address.

[0072] The first mapping table is a mapping table from host logical addresses to flash physical addresses (Logical Address to Physical Address, L2P), and the second mapping table is a mapping table from flash physical addresses to host logical addresses (Physical Address to Logical Address, P2L). Memory space includes, but is not limited to, dynamic random access memory (DRAM) and other types of memory.

[0073] like Figure 1 As shown, the data recovery method includes:

[0074] Step S101: When the flash memory device is in a crash state, in response to the user's power-down operation on the flash memory device, write the valid metadata stored in the memory space into the flash memory medium.

[0075] In this context, "downtime" refers to a state where the flash memory device cannot function due to an abnormal firmware state. "Power-down" refers to forcibly stopping the device's power supply by disconnecting the device's power source, thereby resetting or clearing the abnormal firmware state and providing conditions for the device to restart or restore normal functionality.

[0076] Specifically, when a flash memory device is in a crash state, the host's write operations to the flash memory device will time out, leading to the loss of block devices or even character devices. Since hardware or network connectivity is prone to problems at this time, a forced power-down operation needs to be performed on the flash memory device to prevent further anomalies. After the user performs the power-down operation, the flash memory device's hardware triggers a power-down interrupt, and the processor immediately recognizes the power-down request, forcibly flushing the valid metadata stored in the memory space to the flash memory medium.

[0077] In this embodiment of the application, before step S101, the method further includes: identifying the state of the flash memory device when an assertion failure or memory abnormality occurs in the flash memory device.

[0078] Assertions are debugging tools used in program development to check whether certain conditions are true during code runtime. If an assertion condition is false, the program actively triggers the assertion failure, causing the firmware to enter an abnormal state. Memory abnormalities include memory overflow or memory access errors. Memory overflow refers to a program allocating or using more memory than the system or process allows, causing the firmware to enter an abnormal state. Memory access errors refer to a program illegally accessing unallocated or out-of-range memory, causing the firmware to enter an abnormal state. The specific conditions for assertions can be set by those skilled in the art based on the functionality of the flash memory device, and are not limited in this embodiment.

[0079] Specifically, when an assertion fails or a memory error occurs in the flash memory device, the firmware enters an abnormal state, and the flash memory device is about to crash. At this time, the state of the flash memory device is identified. The state of the flash memory device includes a normal state, an abnormal error state, or a crash state.

[0080] Normal state refers to the state where the flash memory device exhibits no abnormalities. In normal state, users can perform data read and write operations normally, and all functions of the device operate normally. Abnormal error state refers to the state where the flash memory device experiences data read / write errors or other alarm anomalies during operation, but the device as a whole remains usable. Examples include NAND read failures, data write failures, and high-temperature alarms. In contrast to normal and abnormal error states, in a crash state, the flash memory device completely ceases to function, and the host cannot operate the device.

[0081] Furthermore, when it is detected that the flash memory device is about to enter a crash state, the crash state is recorded through a global variable.

[0082] Please see Figure 2 , Figure 2 This is a schematic diagram of a process for identifying and recording downtime status provided in an embodiment of this application;

[0083] like Figure 2 As shown, the process for identifying and recording downtime includes:

[0084] Step S201: Identify the status of the flash memory device;

[0085] Specifically, the state of the flash memory device is identified during operation.

[0086] Step S202: Determine whether the flash memory device has entered a crash state;

[0087] Specifically, if the flash memory device enters a crash state, proceed to step S203; if the flash memory device is in a normal state or an abnormal error state, return to step S201 and continue to identify the status of the flash memory device.

[0088] Step S203: Set the value of the global variable to the first value.

[0089] The global variable is used to identify the state of the flash memory device. When the value of the global variable is the first value, it indicates that the flash memory device is in a crashed state.

[0090] Specifically, when a flash memory device is detected to be in a crash state, the value of a global variable is set to the first value, for example, the value of the global variable is set to two, thereby recording the crash state.

[0091] In this embodiment of the application, the method further includes:

[0092] Before identifying the state of the flash memory device, initialize the global variable and set its value to the second value; when the flash memory device is identified as being in an abnormal error state, set the value of the global variable to the third value.

[0093] In this embodiment, a value of the global variable indicating the flash memory device is in a normal state signifies a value of the second value; a value of the global variable indicating the flash memory device is in an abnormal error state signifies a value of the third value. The first, second, and third values ​​can be set by those skilled in the art, and are not limited in this embodiment. For example, the first value is 2, the second value is 0, and the third value is 1.

[0094] In some embodiments, the flash memory device further includes non-volatile memory (NVM), which is memory that retains data even when power is off. The method also includes storing the values ​​of global variables into the non-volatile memory. The non-volatile memory includes, but is not limited to, Serial Peripheral Interface (SPI) memory.

[0095] In some embodiments, the method further includes recording the error type, location of occurrence, and device status of the flash memory device. The error type includes, but is not limited to, assertion failure, memory overflow, memory access exception, NAND read failure, data write failure, and high-temperature alarm. The location of occurrence refers to the specific line of code or module where the error occurred. The device status includes, but is not limited to, environmental information such as voltage and temperature.

[0096] In this embodiment, the flash memory device includes a flash algorithm module and a backend module, and the memory space also includes a cache area. The flash algorithm module, also known as the flash translation layer (FTL), is used to map input / output (IO) operations to determine the issued flash memory array. The backend module (BE), connected to the flash algorithm module, receives IO operations from the flash algorithm module to perform read / write / erase operations on the flash memory array. The cache area stores data received from the host, including valid metadata. The cache area includes, but is not limited to, memory such as Dynamic Random Access Memory (DRAM).

[0097] Please see Figure 3 , Figure 3 yes Figure 1 A detailed flowchart of step S101;

[0098] like Figure 3 As shown, step S101 includes:

[0099] Step S111: In response to the user's power-down operation on the flash memory device, identify the status of the flash memory device;

[0100] Specifically, the status of the flash memory device is determined by querying global variables.

[0101] In this embodiment of the application, step S111 specifically includes: querying a global variable; when the value of the global variable is a first value, determining that the flash memory device is in a crash state.

[0102] For example, when the value of the global variable is 2, it is determined that the flash memory device is in a crash state.

[0103] In some embodiments, step S111 further includes: determining that the flash memory device is in a normal state when the value of the global variable is a second value; and determining that the flash memory device is in an abnormal error state when the value of the global variable is a third value.

[0104] For example, when the value of the global variable is 0, the flash memory device is determined to be in a normal state; when the value of the global variable is 1, the flash memory device is determined to be in an abnormal error state.

[0105] Step S112: Determine whether the flash memory device is in a crash state;

[0106] Specifically, if the flash memory device is in a crash state, proceed to step S113; if the flash memory device is in a normal state or an abnormal error state, proceed to step S114.

[0107] Step S113: Based on the flash algorithm module and the backend module, write the valid metadata from the cache area to the flash medium;

[0108] Specifically, when a flash memory device is detected to be in a crash state, the flash memory algorithm module and the backend module force the valid metadata to be written from the cache area to the flash memory medium, thereby flushing the complete valid metadata.

[0109] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of a main control system for a flash memory device provided in an embodiment of this application;

[0110] It is understandable that the storage control chip of the flash memory device includes a main control system 402, which is used to connect the host 401 and the flash memory array to realize data I / O processing.

[0111] like Figure 4 As shown, the main control system 402 includes:

[0112] Front End (FE) module 421 is used to obtain host commands to generate I / O operations.

[0113] The flash algorithm module 422, also known as the flash translation layer (FTL), is connected to the front-end module 421 and is used to map IO operations to determine the flash array to be sent.

[0114] The flash memory algorithm module 422 sends IO operations to the back end (BE) module 423 of the storage control chip, so that the back end module 423 receives the IO operations sent by the flash memory algorithm module 422 and performs read / write / erase operations on the flash memory array.

[0115] The existing method of writing data involves the front-end module of the flash memory device sending the write command to the flash memory algorithm module, which then sequentially writes all the data in the cache area to the flash memory medium through the flash memory algorithm module and the back-end module.

[0116] However, this process requires queuing and scheduling write commands, and it must wait for the front-end module to send all write commands. When the flash memory device is down, the front-end module cannot continue sending write commands, and the data in the cache area and the corresponding write commands cannot be passed from the front-end module to the back-end module. If data flushing fails, it will wait indefinitely, and the data flushing process cannot proceed, resulting in data loss upon the next power-on.

[0117] This application skips the data flushing process of the front-end module and does not need to wait for the front-end module to send a write command. It directly writes the valid metadata from the cache area to the flash memory medium through the flash algorithm module and the back-end module, so that the data can be restored on the next power-on.

[0118] In this embodiment of the application, step S101 further includes: when any valid metadata fails to be written to the flash memory medium, re-performing the write operation on the valid metadata based on the backend module until the valid metadata is successfully written to the flash memory medium.

[0119] Specifically, if any valid metadata fails to be written to the flash memory, there is no need to queue the write command for flushing. Instead, the backend module will re-execute the write operation on the valid metadata until it is successfully written to the flash memory.

[0120] It is understandable that a flash memory device failure may cause the scheduling process to fail, resulting in the failure to successfully write valid metadata to the flash memory medium. Directly having the backend module attempt to write the valid metadata to the flash memory medium multiple times, without going through the software queuing and scheduling, can improve the data writing speed and the success rate of writing valid metadata to the flash memory medium.

[0121] In this embodiment, by skipping the data flushing step of the front-end module and the step of waiting for the data flushing to complete, when any valid metadata is not successfully written to the flash memory medium, the back-end module makes multiple attempts to flush the valid metadata to the flash memory medium again. This application can improve the success rate of writing valid metadata to the flash memory medium, preserve the original data completely, and thus restore the previous data directly in the memory space by reading the data from the flash memory medium after power-on, without the need for data reconstruction.

[0122] Step S114: Enter the abnormal power failure process.

[0123] Specifically, when the flash memory device is detected to be in a normal state or an abnormal error state, the Abnormal Power Loss (APL) process is initiated, and the data in the cache area is written to the flash memory medium through the front-end module, flash memory algorithm module, and back-end module.

[0124] Under the APL process, the methods include:

[0125] In response to the user's power-off operation on the flash memory device, and upon recognizing that the flash memory device is not in a crash state, the front-end module generates a corresponding write command for the data stored in the cache area and adds the write commands to the command queue in sequence. Based on the front-end module, the write commands in the command queue are sent to the flash memory algorithm module in sequence, so that the flash memory algorithm module and the back-end module write the data corresponding to the write command into the flash memory medium.

[0126] Compared to existing solutions where the system loses control of the data path when the firmware crashes (meaning the firmware cannot save valid metadata when the flash memory device loses power), this application addresses the issue of saving valid metadata stored in memory by responding to the user's power-off operation when the flash memory device is in a crashed state, skipping the blocking points encountered during the APL process execution, and forcibly writing the valid metadata stored in memory space to the flash memory medium, thus completing the saving of valid metadata.

[0127] Step S102: After the flash memory device is powered on again, read the valid metadata from the flash memory medium to restore the valid metadata to the memory space.

[0128] Specifically, after the flash memory device is powered on again, valid metadata is read from the flash memory medium, thereby reloading the valid metadata into the memory space. It is understood that since step S101 has already forcibly flushed the valid metadata stored in the memory space to the flash memory medium, data reconstruction is not required in step S102. By reading the valid metadata from the flash memory medium, the previously stored valid metadata in the memory space can be recovered.

[0129] In this embodiment of the application, the flash memory device is connected to the host for communication. After restoring the valid metadata to the memory space, the method further includes granting the host the permission to execute read and erase commands.

[0130] Please see Figure 5 , Figure 5 This is a flowchart illustrating an embodiment of the present application that grants a host the execution permissions for read and erase commands.

[0131] like Figure 5 As shown, the process of granting the host execution permissions for read and erase commands includes:

[0132] Step S501: Identify the status of the flash memory device;

[0133] Specifically, the status of the flash memory device is determined by querying global variables.

[0134] In some embodiments, the flash memory device further includes non-volatile memory for storing the values ​​of global variables. Step S501 specifically includes: reading the values ​​of global variables from the non-volatile memory; and determining that the flash memory device is in a crash state when the value of the global variable is a first value.

[0135] For example: read the value of a global variable from the SPI memory, and determine that the flash memory device is in a crash state when the value of the global variable is 2.

[0136] In some embodiments, step S501 further includes: determining that the flash memory device is in a normal state when the value of the global variable is a second value; and determining that the flash memory device is in an abnormal error state when the value of the global variable is a third value.

[0137] Step S502: Determine whether the flash memory device is in a crash state;

[0138] Specifically, if the flash memory device is in a crash state, proceed to step S503; if the flash memory device is in a normal state or an abnormal error state, proceed to step S504.

[0139] Step S503: Grant the host the permission to execute read and erase commands;

[0140] Specifically, when the flash memory device is detected to be in a crash state, the host is granted permission to execute read and erase commands.

[0141] In this embodiment, the flash memory device and the host are connected via an interface. Granting the host permission to execute read and erase commands includes: setting the flash memory device to read-only mode; creating a whitelist and configuring the host's permission to read or erase data in the whitelist; and obtaining the read or erase commands sent by the host based on the interface.

[0142] In this application embodiment, by setting the flash memory device to read-only state and combining it with a whitelist mechanism and a newly added interface, on the one hand, this application can prevent unauthorized read operations and achieve data protection; on the other hand, compared with the existing solution where users cannot read or erase the data inside the flash memory device when it crashes, this application can allow users to read backups and clear data after data recovery is completed after the flash memory device crashes.

[0143] Step S504: Enter the normal power-on process.

[0144] Specifically, when the flash memory device is detected to be in a normal or abnormal error state, the normal power-on process is initiated, which involves sequentially performing power initialization, hardware self-test, firmware loading, storage media initialization, and metadata restoration before entering normal working mode.

[0145] In this embodiment, by identifying whether the flash memory device is in a crash state, when the flash memory device is in a crash state, in response to the user's power-down operation on the flash memory device, the valid metadata stored in the memory space is written to the flash memory medium, and after the flash memory device is powered on again, the valid metadata is read from the flash memory medium to restore the valid metadata to the memory space, and the execution permissions of read and erase commands are granted to the host. This application can force the flash memory device to be flushed when it is crashed, so that after the flash memory device is powered on, the complete valid metadata can be restored without data reconstruction or entering the small system state. The user can directly read the backup data or perform data clearing without any additional operation.

[0146] In this embodiment of the application, a data recovery method is provided, which is applied to a flash memory device. The flash memory device includes a flash memory medium and a memory space. The data recovery method includes: when the flash memory device is in a crash state, in response to the user's power-off operation on the flash memory device, writing the valid metadata stored in the memory space to the flash memory medium; after the flash memory device is powered on again, reading the valid metadata from the flash memory medium to restore the valid metadata to the memory space.

[0147] By writing valid metadata stored in the memory space to the flash medium in response to the user's power-down operation when the flash device is in a crash state, and reading valid metadata from the flash medium after the flash device is powered on again to restore the valid metadata to the memory space, this application can force the flash device to flush valid metadata when it crashes. This allows the complete valid metadata to be restored without data reconstruction after the flash device is powered on, thereby improving the efficiency of data recovery. Furthermore, data recovery can be performed without entering a small system state, which improves the flexibility of data recovery for flash devices.

[0148] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a storage control chip provided in an embodiment of this application;

[0149] like Figure 6 As shown, the storage control chip 600 includes one or more processors 601 and a memory 602. Wherein, Figure 6 Taking a processor 601 as an example, in this embodiment, the storage control chip includes a controller for a solid-state drive or other storage device that uses flash memory as the storage medium. The flash memory device includes a flash memory medium, and the storage control chip includes memory space.

[0150] Processor 601 and memory 602 can be connected via a bus or other means. Figure 6 Taking the example of a connection between China and Israel via a bus.

[0151] The processor 601 is configured to provide computing and control capabilities to control the flash memory device 700 to perform corresponding tasks, such as controlling the flash memory device 700 to perform a data recovery method in any of the above method embodiments. The data recovery method includes: when the flash memory device is in a crash state, in response to a user's power-off operation on the flash memory device, writing valid metadata stored in the memory space to the flash memory medium; and after the flash memory device is powered on again, reading the valid metadata from the flash memory medium to restore the valid metadata to the memory space.

[0152] By writing valid metadata stored in the memory space to the flash medium in response to the user's power-down operation when the flash device is in a crash state, and reading valid metadata from the flash medium after the flash device is powered on again to restore the valid metadata to the memory space, this application can force the flash device to flush valid metadata when it crashes. This allows the complete valid metadata to be restored without data reconstruction after the flash device is powered on, thereby improving the efficiency of data recovery. Furthermore, data recovery can be performed without entering a small system state, which improves the flexibility of data recovery for flash devices.

[0153] Processor 601 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0154] Memory 602, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the data recovery method in the embodiments of this application. Processor 601 can implement the data recovery method in any of the above method embodiments by running the non-transitory software programs, instructions, and modules stored in memory 602. Specifically, memory 602 may include volatile memory (VM), such as random access memory (RAM); memory 602 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), solid-state drive (SSD), or other non-transitory solid-state storage devices; memory 602 may also include combinations of the above types of memory.

[0155] Memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 602 may optionally include memory remotely located relative to processor 601, which can be connected to processor 601 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0156] One or more modules are stored in memory 602. When executed by one or more processors 601, they perform the data recovery method in any of the above method embodiments, for example, the method described above. Figure 1 The steps shown.

[0157] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a flash memory device provided in an embodiment of this application;

[0158] like Figure 7 As shown, the flash memory device 700 includes a storage control chip 600 and at least one flash memory medium 701. Figure 7 Taking a flash memory medium 701 as an example, the storage controller chip 600 and the flash memory medium 701 are communicatively connected. The flash memory device includes the flash memory medium and memory space.

[0159] The storage control chip 600 is used to execute the data recovery method in any of the above embodiments. The data recovery method includes: when the flash memory device is in a crash state, in response to the user's power-off operation on the flash memory device, writing the valid metadata stored in the memory space into the flash memory medium; and after the flash memory device is powered on again, reading the valid metadata from the flash memory medium to restore the valid metadata to the memory space.

[0160] At least one flash memory medium 701 is communicatively connected to a storage control chip 600 for storing data. The flash memory medium 701 includes a superblock, which comprises data blocks and parity blocks.

[0161] The flash memory device includes a storage control chip and at least one flash memory medium. The storage control chip is used to execute the data recovery method in any of the above embodiments, and the flash memory medium is used to store data. This application can force the flash memory device to refresh valid metadata when it crashes, so that the complete valid metadata can be recovered without data reconstruction after the flash memory device is powered on, thereby improving the efficiency of data recovery. Furthermore, data recovery can be performed without entering the state of a small system, which can improve the flexibility of data recovery of the flash memory device.

[0162] This application also provides a non-volatile computer storage medium storing computer-executable instructions that are executed by one or more processors. For example, the one or more processors can execute the data recovery method in any of the above method embodiments, such as executing the data recovery method in any of the above method embodiments, such as executing the various steps described above.

[0163] The apparatus or device embodiments described above are merely illustrative. The unit modules described as separate components may or may not be physically separate, and the components shown as module units may or may not be physical units; that is, they may be located in one place or distributed across multiple network module units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0164] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions for a computer device (which may be a personal computer, server, or network device, etc.) to execute the various embodiments or some parts of the embodiments.

[0165] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above. For the sake of brevity, they are not provided in detail; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A data recovery method, characterized in that, Applied to a flash memory device, the flash memory device including flash memory medium and memory space, the method includes: When the flash memory device is in a crash state, in response to the user's power-off operation on the flash memory device, the valid metadata stored in the memory space is written to the flash memory medium. After the flash memory device is powered on again, the valid metadata is read from the flash memory medium to restore the valid metadata to the memory space.

2. The method according to claim 1, characterized in that, Before writing valid metadata to the flash memory medium in response to a user power-down operation on the flash memory device, the method further includes: When an assertion failure or memory anomaly occurs in the flash memory device, the state of the flash memory device is identified, wherein the state of the flash memory device includes a crash state; When a flash memory device is detected to have entered a crash state, the value of a global variable is set to a first value, wherein the global variable is used to identify the state of the flash memory device.

3. The method according to claim 2, characterized in that, The flash memory device includes a flash algorithm module and a backend module, and the memory space also includes a cache area; The step of writing valid metadata to the flash memory medium in response to a user's power-off operation on the flash memory device includes: In response to a user powering down the flash memory device, the state of the flash memory device is identified; When the flash memory device is detected to be in a downtime state, the valid metadata is written from the cache area to the flash memory medium based on the flash memory algorithm module and the back-end module. The valid metadata includes a first mapping table from host logical address to flash physical address and a second mapping table from flash physical address to host logical address.

4. The method according to claim 3, characterized in that, The step of identifying the state of the flash memory device in response to a user's power-off operation includes: Query the global variable; When the value of the global variable is the first value, the flash memory device is determined to be in a crash state; The step of writing valid metadata to the flash memory medium in response to a user's power-off operation on the flash memory device further includes: If any of the valid metadata is not successfully written to the flash memory medium, the backend module re-executes the write operation on the valid metadata until the valid metadata is successfully written to the flash memory medium.

5. The method according to claim 3, characterized in that, The flash memory device also includes a front-end module; The method further includes: In response to the user's power-off operation on the flash memory device, when it is detected that the flash memory device is not in a downtime state, the front-end module generates a corresponding write command for the data stored in the cache area, and adds the write command to the command queue in sequence. The data stored in the cache area includes valid metadata. Based on the front-end module, write commands in the command queue are sent sequentially to the flash memory algorithm module, so that the flash memory algorithm module and the back-end module write the data corresponding to the write command into the flash memory medium.

6. The method according to claim 1, characterized in that, The flash memory device is communicatively connected to the host; After restoring the valid metadata to the memory space, the method further includes: Identify the status of the flash memory device; When the flash memory device is detected to be in a crash state, grant the host permission to execute read and erase commands.

7. The method according to claim 6, characterized in that, The flash memory device also includes non-volatile memory, which is used to store the values ​​of global variables, which are used to identify the state of the flash memory device; The process of identifying the state of the flash memory device includes: Read the value of the global variable from the non-volatile memory; When the value of the global variable is the first value, the flash memory device is determined to be in a crash state.

8. The method according to claim 6, characterized in that, The flash memory device is connected to the host via an interface; Granting the host the permission to execute read and erase commands includes: Set the flash memory device to read-only mode; Create a whitelist and configure the host in the whitelist to have the permission to read or erase data; Based on the interface, obtain the read command or erase command sent by the host.

9. A storage control chip, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the data recovery method as described in any one of claims 1-8.

10. A flash memory device, characterized in that, include: The storage control chip as described in claim 9; At least one flash memory medium is communicatively connected to the storage control chip.