[go: up one dir, main page]

CN119473731B - Exception handling method, device, equipment and medium - Google Patents

Exception handling method, device, equipment and medium Download PDF

Info

Publication number
CN119473731B
CN119473731B CN202510059217.8A CN202510059217A CN119473731B CN 119473731 B CN119473731 B CN 119473731B CN 202510059217 A CN202510059217 A CN 202510059217A CN 119473731 B CN119473731 B CN 119473731B
Authority
CN
China
Prior art keywords
user data
metadata
data
target
target user
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202510059217.8A
Other languages
Chinese (zh)
Other versions
CN119473731A (en
Inventor
喻乾红
黄泽诚
刘海川
张力夫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Yunhai Core Microelectronics Technology Co ltd
Original Assignee
Sichuan Yunhai Core Microelectronics Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Yunhai Core Microelectronics Technology Co ltd filed Critical Sichuan Yunhai Core Microelectronics Technology Co ltd
Priority to CN202510059217.8A priority Critical patent/CN119473731B/en
Publication of CN119473731A publication Critical patent/CN119473731A/en
Application granted granted Critical
Publication of CN119473731B publication Critical patent/CN119473731B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种异常处理方法、装置、设备及介质,涉及硬盘技术领域,包括:确定硬盘中待执行垃圾回收流程的目标条带;目标条带包括用于存储用户数据和第一元数据的物理页、用于存储P2L表和第二元数据的物理页和用于存储校验数据和第三元数据的物理页;第一元数据为用户数据的逻辑地址,第二元数据的每一位均为1,第三元数据为第一元数据和第二元数据的异或结果,校验数据为用户数据与P2L表的异或结果;在垃圾回收时,若P2L表读取失败且存在一个目标用户数据读取失败,则基于其余元数据恢复目标用户数据的第一元数据,并判断目标用户数据是否有效,若是则重新构建P2L表,以利用P2L表、其余用户数据和校验数据恢复目标用户数据。

The present application discloses an exception handling method, device, equipment and medium, which relates to the technical field of hard disks, including: determining a target stripe in a hard disk to be subjected to a garbage collection process; the target stripe includes a physical page for storing user data and a first metadata, a physical page for storing a P2L table and a second metadata, and a physical page for storing verification data and a third metadata; the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an XOR result of the first metadata and the second metadata, and the verification data is an XOR result of the user data and the P2L table; during garbage collection, if the P2L table fails to be read and there is a target user data that fails to be read, the first metadata of the target user data is restored based on the remaining metadata, and it is determined whether the target user data is valid, and if so, the P2L table is rebuilt to restore the target user data using the P2L table, the remaining user data and the verification data.

Description

Exception handling method, device, equipment and medium
Technical Field
The present invention relates to the field of hard disk technologies, and in particular, to an exception handling method, apparatus, device, and medium.
Background
Because NAND (Not AND, a flash memory technology) in an SSD (Solid STATE DISK) does Not support overwriting, only the overwriting operation on a host computer can write on a new physical page of the NAND, AND the original old data becomes garbage data on a physical block of the NAND, so that the user space of the SSD is insufficient, AND therefore, a garbage collection flow is required to move effective data in the physical block, AND then erase the physical block to obtain a new physical block capable of writing data.
Before the garbage collection moves the effective data of the physical block, it needs to determine which are the effective data, so it needs to read the mapping relation table (Physical to Logical Mapping Table, i.e. the P2L table) from the physical address to the logical address, and due to the continuous use of the disk, there may be partial data failure, if the P2L reading fails and cannot be recovered by the XOR technology, which indicates that the user data also fails to read at this time. In this case, the existing scheme can only reconstruct the physical address and the Logical address of all the user data, and then only traverse the mapping relation Table (Logical to PHYSICAL MAPPING Table, i.e. L2P Table) from the Logical address to the physical address by the physical address for the user data that fails the current stripe read. However, the L2P table is very large, and if it is an 8T disk, the L2P table is theoretically 8G in size, so that it takes a very long time, which greatly reduces the performance of the hard disk.
In summary, when a stripe has two abnormal conditions, i.e. a P2L table read failure and a user data read failure, how to quickly solve the two abnormal conditions and recover data, so as to ensure the consistency of the data and the stability of the hard disk is a problem to be solved at present.
Disclosure of Invention
Accordingly, the present invention is directed to an exception handling method, apparatus, device, and medium, which can quickly solve the double exception condition and recover data when a stripe has a double exception condition, i.e. a P2L table read failure and a user data read failure, so as to ensure the consistency of data and the stability of a hard disk. The specific scheme is as follows:
in a first aspect, the present application discloses an exception handling method, including:
Determining a target stripe of a garbage collection flow to be executed in a hard disk, wherein the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive-or result of the first metadata and the second metadata, and the check data is an exclusive-or result of the user data and the P2L table;
When garbage collection is carried out on each first physical page, if the P2L table fails to read and one target user data fails to read, recovering the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata and the rest user data;
Judging whether the target user data is valid or not based on the first metadata corresponding to the target user data and an L2P table, and if the target user data is valid, reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of user data so as to recover the target user data by using the reconstructed P2L table, the rest of user data and the verification data.
Optionally, the exception handling method further includes:
Reading the P2L table to determine the validity of user data stored in each of the first physical pages when garbage collection is performed on each of the first physical pages;
If the P2L table fails to be read, reading the check data and all the user data to restore the P2L table by using the check data and all the user data, and then jumping to the step of reading the P2L table to determine the validity of the user data stored in each first physical page;
if there is a failure in reading the target user data, the method jumps to the step of recovering the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata and the rest of the user data.
Optionally, the P2L table is configured to store a mapping relationship from an initial physical address to a logical address of each user data, and the L2P table is configured to store a mapping relationship from a logical address to a latest physical address of each user data;
accordingly, the reading the P2L table to determine the validity of the user data stored in each of the first physical pages includes:
obtaining a logical address and a first physical address corresponding to user data stored in each first physical page from the P2L table;
Searching a corresponding second physical address from the L2P table according to the logical address corresponding to each piece of user data;
and if the first physical address is the same as the second physical address, judging that the user data stored in the first physical page is valid, otherwise, judging that the user data stored in the first physical page is invalid.
Optionally, after the reading the P2L table to determine the validity of the user data stored in each of the first physical pages, the method further includes:
If the user data stored in any physical page is valid, carrying out data moving processing on the corresponding user data;
And if the user data stored in any physical page is invalid, performing data discarding processing on the corresponding user data.
Optionally, the determining whether the target user data is valid based on the first metadata and the L2P table corresponding to the target user data includes:
Determining a target logical address of the target user data based on first metadata corresponding to the target user data, and searching a target physical address corresponding to the target logical address from the L2P table;
judging whether the target physical address is the same as the current physical address of the target user data;
If the target physical address is the same as the current physical address, judging that the target user data is valid;
And if the target physical address is different from the current physical address, judging that the target user data is invalid, and carrying out data discarding processing on the target user data.
Optionally, after reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the remaining user data, the method further includes:
reading the reconstructed P2L table to determine the validity of the rest of the user data;
And if the rest of the user data is judged to be valid, carrying out data migration processing on the rest of the user data, and if the rest of the user data is judged to be invalid, carrying out data discarding processing on the rest of the user data.
Optionally, the exception handling method further includes:
performing exclusive-or operation on each first metadata and each second metadata according to bits to obtain third metadata, and performing exclusive-or operation on each user data and each P2L table according to bits to obtain check data;
correspondingly, the restoring the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest user data includes:
Performing exclusive OR operation on the first metadata corresponding to the second metadata, the third metadata and the rest user data according to bits to restore the first metadata corresponding to the target user data;
correspondingly, the recovering the target user data by using the reconstructed P2L table, the rest user data and the verification data includes:
And carrying out exclusive OR operation on the reconstructed P2L table, the rest user data and the verification data according to bits to restore the target user data.
In a second aspect, the present application discloses an exception handling apparatus, comprising:
The system comprises a stripe determining module, a stripe determining module and a data processing module, wherein the stripe determining module is used for determining a target stripe of a garbage collection flow to be executed in a hard disk, the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive-OR result of the first metadata and the second metadata, and the check data is an exclusive-OR result of the user data and the P2L table;
The metadata recovery module is configured to, when garbage collection is performed on each of the first physical pages, if the P2L table fails to read and there is a failure in reading the target user data, recover first metadata corresponding to the target user data based on the second metadata, the third metadata, and first metadata corresponding to the rest user data;
And the user data recovery module is used for judging whether the target user data is valid or not based on the first metadata corresponding to the target user data and the L2P table, and reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of user data if the target user data is valid, so as to recover the target user data by using the reconstructed P2L table, the rest of user data and the verification data.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
And a processor for executing the computer program to implement the steps of the foregoing disclosed exception handling method.
In a fourth aspect, the present application discloses a computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the steps of the previously disclosed exception handling method.
The method comprises the steps of determining a target stripe of a garbage collection flow to be executed in a hard disk, determining whether the target stripe comprises a first physical page for storing user data and first metadata, a second physical page for storing P2L table and second metadata and a third physical page for storing check data and third metadata, wherein the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive OR result of the first metadata and the second metadata, the check data is an exclusive OR result of the user data and the P2L table, and if garbage collection is carried out on each first physical page, the P2L table is failed to read and one target user data is failed to read, the first metadata corresponding to the target user data is restored based on the second metadata, the third metadata and the first metadata corresponding to other user data, judging whether the target user data is valid or not based on the first metadata and the L2P table corresponding to the target user data, and reconstructing the rest of the check data by using the first metadata and the rest of the first metadata and the rest user data if the target user data is valid.
The method has the advantages that when data are stored in the hard disk, each stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing P2L table and second metadata and a third physical page used for storing check data and third metadata, wherein the first metadata is used for storing logical addresses of the user data, the P2L table records the mapping relation from the physical addresses of the user data to the logical addresses, each bit of the corresponding second metadata is written as 1, finally, the exclusive OR result of all the user data and the P2L table is used as the check data, and the exclusive OR result of the first metadata and the second metadata is used as the third metadata corresponding to the check data. Further, when garbage collection is performed on each first physical page, if the P2L table fails to read and there is a failure to read the target user data, this indicates that a double exception condition occurs at this time, and because the value of the second metadata is all 1, the present application can quickly recover the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest of the user data, that is, recover to obtain the logical address of the target user data, and then determine whether the target user data is valid data by reading the L2P table, and under the valid condition, because all metadata in the target stripe are known at this time, the present application can reconstruct to obtain the P2L table again based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of the user data, and finally recover the target user data by using the reconstructed P2L table, the rest of the user data and the verification data. In this way, the metadata of the P2L data is fixed to be 1, so that under the condition of double anomalies, the L2P table is not required to be traversed globally by using the physical address of the target user data, the metadata of the target user data can be quickly recovered, and the P2L table is quickly reconstructed, thereby recovering the double anomalies of the read failure to be single anomalies, finally recovering the target user data of the read failure, and ensuring the consistency of the data and the stability of the hard disk.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an exception handling method disclosed in the present application;
FIG. 2 is a schematic diagram of an IO data sector format disclosed herein;
FIG. 3 is a schematic diagram of a stripe storage architecture according to the present disclosure;
FIG. 4 is a schematic diagram of a dual anomaly of a stripe in accordance with the present disclosure;
FIG. 5 is a flowchart of a specific exception handling method disclosed in the present application;
FIG. 6 is a schematic diagram of an exception handling apparatus according to the present disclosure;
Fig. 7 is a block diagram of an electronic device according to the present disclosure.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
When a stripe fails to read the P2L table and a user data fails to read the user data, the existing scheme is that only the physical addresses and the logical addresses of all user data can be reconstructed, and then for the user data which fails to read the current stripe, the mapping relation table (i.e. the L2P table) from the logical address to the physical address can be traversed only through the physical address. However, the L2P table is very large, and if it is an 8T disk, the L2P table is theoretically 8G in size, so that it takes a very long time, which greatly reduces the performance of the hard disk.
Therefore, the embodiment of the application discloses an exception handling method, an exception handling device, exception handling equipment and an exception handling medium, which can quickly solve double exception conditions and recover data when double exception conditions such as P2L table reading failure and user data reading failure occur in one strip so as to ensure the consistency of the data and the stability of a hard disk.
Referring to fig. 1, an embodiment of the present application discloses an exception handling method, which includes:
The method comprises the step S11 of determining a target stripe of a garbage collection flow to be executed in a hard disk, wherein the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive OR result of the first metadata and the second metadata, and the check data is an exclusive OR result of the user data and the P2L table.
In this embodiment, first, a target stripe of a garbage collection process to be executed in a solid state disk is determined. It should be noted that, when storing data in a hard disk, each stripe includes a first physical page for storing user data and first metadata, a second physical page for storing P2L table and second metadata, and a third physical page for storing check data and third metadata, where the first metadata is used to store a logical address of the user data, the P2L table records a mapping relationship from the physical address to the logical address of each user data, each bit of the corresponding second metadata is written as 1, finally, an exclusive or result of all the user data and the P2L table is used as check data, and an exclusive or result of the first metadata and the second metadata is used as third metadata corresponding to the check data.
It will be appreciated that different hard disks have different sector formats, and taking the sector format in fig. 2 as an example, in this embodiment of the present application, each IO (Input/Output) data issued by the host has 4K of user data and a total of 80 bytes of reserved bytes and metadata bytes, where FMD (Flash Meta Data) represents metadata, and each IO data records the logical address (LBA, logical Block Address) of the data in the first 4 bytes of its FMD. It should be noted that, the sizes of possible LBAs of different disks are different, and the present embodiment only takes 4 bytes as an example, and the size of the LBAs is not limited.
In this embodiment, each IO data is stored using one physical page, and the physical page is denoted as a first physical page, i.e. is mainly used for storing user data and corresponding first metadata, where the first metadata is used for storing a logical address of the user data. Further, each IO data generates a mapping table (i.e. a P2L table) from a physical address to a logical address, and the mapping table is stored in a P2L Buffer, when the write stripe is written to a P2L position, the P2L Buffer is written to a corresponding P2L position, as shown by IO P2L in FIG. 3, and before writing, metadata in the P2L data is written to a fixed value of 1. It will be appreciated that the used sector format of the P2L data also corresponds to the sector format shown in fig. 2, i.e. the data area for storing the P2L table and the corresponding metadata are also included, here the P2L table and the second metadata are denoted as a whole as IO P2L, whereas the present application writes each bit of the second metadata corresponding to the P2L table as a fixed value of 1 and then also writes such physical pages as second physical pages in the physical pages of the stripe. It should be noted that the number of second physical pages may be one or more, which mainly depends on the size of the hard disk and the number of first physical pages.
After the P2L data is written to the disk, the user data in all the first physical pages and the P2L table in all the second physical pages are xored finally to generate check data, all the first metadata and all the second metadata are xored equally to generate third metadata, and then the check data and the third metadata are written to the last location IO XOR of the stripe, i.e. one physical page is used to store it as well, and this type of physical page is denoted as a third physical page, and a complete stripe storage structure is shown in fig. 3, where a plurality of stripes form a complete physical Block (i.e. Block).
In the specific embodiment, the method specifically comprises the steps of carrying out exclusive-or operation on each first metadata and each second metadata according to bits to obtain third metadata, and carrying out exclusive-or operation on each user data and each P2L table according to bits to obtain the verification data. That is, in the exclusive-or operation, each data is operated according to a bit, for example, the first bit of each first metadata and the first bit of each second metadata are operated by exclusive-or according to a bit to obtain the first bit of the third metadata, and similarly, the first bit of each user data and the first bit of each P2L table are operated by exclusive-or according to a bit to obtain the first bit of the check data, and so on to obtain the complete third metadata and the check data.
And step S12, when garbage collection is carried out on each first physical page, if the P2L table fails to read and one target user data fails to read, recovering the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest user data.
In this embodiment, when garbage collection is performed on each first physical page, if the P2L table fails to read and there is a failure to read the target user data, this indicates that a double exception condition occurs at this time, and since the values of the second metadata are all 1, the present application can quickly recover the first metadata corresponding to the target user data based on the second metadata, the third metadata, and the first metadata corresponding to the rest of the user data, that is, recover the logical address of the target user data.
The method for recovering the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata and the rest user data comprises the step of performing exclusive-or operation on the first metadata corresponding to the second metadata, the third metadata and the rest user data according to bits to recover the first metadata corresponding to the target user data. It can be understood that, in this embodiment, when the first metadata corresponding to the target user data is restored, the second metadata, the third metadata, and the first metadata corresponding to the rest of the user data need to be xored according to bits.
That is, in this embodiment, metadata corresponding to all user data and check data that are successfully read needs to be stripped, and metadata corresponding to the P2L table is known to be all 1, so that metadata of target data that are failed to read can be recovered by performing XOR on all metadata, and thus a logical address of the target user data can be obtained. Taking fig. 4 as an example, the first metadata corresponding to the target user data is denoted as FMD 2, the first metadata corresponding to the user data with the rest of successfully read are denoted as FMD 1、FMD3、…、FMDn, and the third metadata corresponding to the verification data are denoted as FMD xor. Then, according to the characteristics of exclusive or operation, each bit is calculated, and since the second metadata corresponding to the P2L table is all 1, b 2i=1 XOR b1i XOR b3i XOR…XOR bni exists for each bit b 2i in the FMD 2, wherein b 1i、b3i…bni is the corresponding bit in the FMD 1、FMD3、…、FMDn, i represents the ith bit in the metadata, and the complete metadata of the target user data can be obtained by sequentially performing the above calculation on each bit in the metadata.
The process specifically includes the steps of reading the P2L table to determine validity of user data stored in each first physical page when garbage is recovered from each first physical page, reading the check data and all the user data if the P2L table fails to be read to recover the P2L table by using the check data and all the user data, then jumping to the step of reading the P2L table to determine validity of the user data stored in each first physical page, and jumping to the step of recovering the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata and the rest of the user data if there is a failure to read the target user data.
After the validity of the user data stored in each first physical page is determined by reading the P2L table, the method further comprises the steps of carrying out data moving processing on the corresponding user data if the user data stored in any physical page is valid, and carrying out data discarding processing on the corresponding user data if the user data stored in any physical page is invalid.
That is, in the normal flow, the P2L table needs to be read to determine the validity of the user data stored in each first physical page, and if the user data stored in any physical page is determined to be valid according to the P2L table, the data migration process is performed on the corresponding user data, that is, the data determined to be valid is transferred from the old storage location to the new storage location, so as to perform the erase operation on the original physical block, thereby obtaining the physical block of the new writable data. If the user data stored in any physical page is invalid according to the P2L table, the corresponding user data is subjected to data discarding processing without moving.
In a specific embodiment, if the P2L table fails to be read, the validity of the user data stored in the first physical page cannot be determined, so that the check data and all the user data need to be read first, an exclusive or operation is performed by using the check data and all the user data to restore the P2L table, and if the P2L table is restored successfully, the subsequent steps are performed according to the garbage collection procedure, that is, the P2L table is read again to determine the validity of the user data stored in each first physical page.
Further, as shown in fig. 4, if it is found that there is a failure in reading the target user data during the process of recovering the P2L table, the P2L table cannot be recovered, and the target user data cannot be recovered, thereby forming a double abnormal situation. At this time, the process jumps to the step of restoring the first metadata corresponding to the target user data based on the second metadata, the third metadata, and the first metadata corresponding to the remaining user data.
In addition, in a specific embodiment, the P2L table is configured to store a mapping relationship from an initial physical address to a logical address of each user data, the L2P table is configured to store a mapping relationship from a logical address to a latest physical address of each user data, and correspondingly, the reading the P2L table to determine validity of the user data stored in each first physical page includes obtaining, from the P2L table, a logical address and a first physical address corresponding to the user data stored in each first physical page, searching, from the L2P table, a corresponding second physical address according to the logical address corresponding to each user data, and if the first physical address is the same as the second physical address, determining that the user data stored in the first physical page is valid, otherwise, determining that the user data stored in the first physical page is invalid.
It can be understood that the application sets two different mapping tables, namely a P2L table for storing the mapping relation from the initial physical address to the logical address of each user data, wherein the P2L table only records the related data in a single strip, and a L2P table for storing the mapping relation from the logical address to the latest physical address of each user data, wherein the L2P table records the related data of the whole hard disk. That is, considering that the physical address of the data may change during the use process, the P2L table records the initial physical address corresponding to the user data when the user data is initially written, and uses the current latest physical address of the user data recorded by the L2P table. Therefore, when determining the validity of the user data stored in each first physical page, the application firstly needs to acquire the logical address and the first physical address corresponding to the user data from the P2L table, then searches the corresponding second physical address from the L2P table by utilizing the acquired logical address of the user data, namely searches the latest physical address, if the first physical address is the same as the second physical address, the physical address for storing the user data is unchanged, so that the user data stored in the first physical page is still valid, and if the first physical address is different from the second physical address, the user data stored in the first physical page is invalid.
And S13, judging whether the target user data is valid or not based on the first metadata corresponding to the target user data and an L2P table, and reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of user data if the target user data is valid, so as to restore the target user data by using the reconstructed P2L table, the rest of user data and the verification data.
In this embodiment, after the first metadata corresponding to the target user data is recovered, whether the target user data is valid data is then determined by reading the L2P table. Under the effective condition, because all metadata in the target stripe are known at this time, namely the logical address of each user data is known, the application can reconstruct the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest user data, and finally, the reconstructed P2L table and the verification data are used for recovering the target user data. In this way, the metadata of the P2L data is fixed to be 1, so that under the condition of double anomalies, the physical data of the target user data is not required to be utilized to globally traverse the L2P table, the metadata of the target user data can be quickly recovered, the P2L table is quickly reconstructed, the double anomalies with failed reading are recovered to be single anomalies, the target user data with failed reading is finally recovered, and the consistency of the data and the stability of the hard disk are ensured.
In a specific embodiment, the recovering the target user data by using the reconstructed P2L table, the rest of the user data and the check data includes performing an exclusive-or operation on the reconstructed P2L table, the rest of the user data and the check data according to bits to recover the target user data. It will be appreciated that, in this embodiment, when recovering the target user data, the reconstructed P2L table, the remaining user data and the check data also need to be xored according to bits.
It can be seen that when data is stored in a hard disk, each stripe includes a first physical page for storing user data and first metadata, a second physical page for storing P2L table and second metadata, and a third physical page for storing check data and third metadata, where the first metadata is used to store a logical address of the user data, the P2L table records a mapping relationship from the physical address to the logical address of each user data, each bit of the corresponding second metadata is written as 1, finally, an exclusive-or result of all the user data and the P2L table is used as check data, and an exclusive-or result of the first metadata and the second metadata is used as third metadata corresponding to the check data. Further, when garbage collection is performed on each first physical page, if the P2L table fails to read and there is a failure to read the target user data, this indicates that a double exception condition occurs at this time, and because the value of the second metadata is all 1, the present application can quickly recover the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest of the user data, that is, recover to obtain the logical address of the target user data, and then determine whether the target user data is valid data by reading the L2P table, and under the valid condition, because all metadata in the target stripe are known at this time, the present application can reconstruct to obtain the P2L table again based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of the user data, and finally recover the target user data by using the reconstructed P2L table and the verification data. In this way, the metadata of the P2L data is fixed to be 1, so that under the condition of double anomalies, the L2P table is not required to be traversed globally by using the physical address of the target user data, the metadata of the target user data can be quickly recovered, and the P2L table is quickly reconstructed, thereby recovering the double anomalies of the read failure to be single anomalies, finally recovering the target user data of the read failure, and ensuring the consistency of the data and the stability of the hard disk.
Referring to fig. 5, an embodiment of the present application discloses a specific exception handling method, and compared with the previous embodiment, the present embodiment further describes and optimizes a technical solution. The method specifically comprises the following steps:
The method comprises the step S21 of determining a target stripe of a garbage collection flow to be executed in a hard disk, wherein the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive OR result of the first metadata and the second metadata, and the check data is an exclusive OR result of the user data and the P2L table.
And S22, when garbage collection is carried out on each first physical page, if the P2L table fails to read and one target user data fails to read, recovering the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest user data.
Step S23, determining a target logical address of the target user data based on the first metadata corresponding to the target user data, and searching a target physical address corresponding to the target logical address from the L2P table.
In this embodiment, after the first metadata corresponding to the target user data is recovered, the target logical address of the target user data may be determined based on the first metadata corresponding to the target user data, and then the target physical address corresponding to the target logical address may be searched for from the L2P table.
And S24, judging whether the target physical address is the same as the current physical address of the target user data, if the target physical address is the same as the current physical address, judging that the target user data is valid, and if the target physical address is different from the current physical address, judging that the target user data is invalid, and performing data discarding processing on the target user data.
In this embodiment, it is determined whether the target physical address found from the L2P table is the same as the current physical address of the target user data, if so, it is determined that the target user data is valid because the physical address storing the target user data is unchanged, and if not, it is determined that the target user data is invalid because the target user data is stored at a new physical address, and data discarding processing is performed on the target user data. And because the first metadata corresponding to all user data of the current stripe are known at the moment, the logical address is also known, and the validity of each user data of the current stripe can be directly judged without recovering the P2L table.
And S25, if the target user data is valid, reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of user data, so as to recover the target user data by using the reconstructed P2L table, the rest of user data and the verification data.
In this embodiment, if the target user data is valid, the data needs to be restored, and the P2L table needs to be restored first to construct the double anomaly into the single anomaly. Because the first metadata corresponding to the target user data or the first metadata corresponding to the rest user data in the current stripe are known, the P2L table can be rebuilt, namely, the P2L table is rebuilt by using the mapping relation from the physical address to the logical address of each user data, and at the moment, the double anomalies are restored to a single anomaly scene. And finally, recovering the target user data by using the reconstructed P2L table, the rest user data and the verification data, and then carrying out data moving processing.
Further, after reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the remaining user data, the method further includes reading the reconstructed P2L table to determine validity of the remaining user data, if the remaining user data is determined to be valid, performing data moving processing on the remaining user data, and if the remaining user data is determined to be invalid, performing data discarding processing on the remaining user data.
That is, after reconstructing the P2L table, the reconstructed P2L table may be read to determine the validity of the remaining user data, thereby deciding whether to move or discard the data according to the validity of the remaining user data.
For more specific processing procedures in the steps S21 and S22, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no detailed description is given here.
Therefore, the application writes the metadata of the P2L table into the fixed value of 1, saves the metadata of the user data in the logical address of the user data, and when the same band fails to read the P2L table and one user data is also failed to read, strips the metadata of the P2L table, the check data and the metadata of other user data which are read normally out to carry out metadata exclusive OR, because the metadata of the P2L table is known to be the fixed value, the double anomaly phenomenon is constructed as single anomaly, and the metadata of the user data which fails to read are recovered, thereby being used for judging the validity of the user data which fails to read later and recovering the P2L table and recovering the user data. According to the scheme, the whole disk L2P table does not need to be traversed globally, so that the speed of screening effective data under the condition of double abnormal reading is greatly improved, the abnormal solving time is prolonged, and meanwhile, the stability of a hard disk and the consistency of data are ensured.
Referring to fig. 6, an embodiment of the present application discloses an exception handling apparatus, which includes:
The system comprises a stripe determining module 11, a stripe determining module and a data processing module, wherein the stripe determining module is used for determining a target stripe of a garbage collection flow to be executed in a hard disk, the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive-OR result of the first metadata and the second metadata, and the check data is an exclusive-OR result of the user data and the P2L table;
the metadata recovery module 12 is configured to, when garbage collection is performed on each of the first physical pages, if the P2L table fails to read and there is a failure to read the target user data, recover the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata, and the rest of the user data;
And a user data recovery module 13, configured to determine whether the target user data is valid based on the first metadata corresponding to the target user data and the L2P table, and if the target user data is valid, reconstruct the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of the user data, so as to recover the target user data by using the reconstructed P2L table, the rest of the user data, and the verification data.
It can be seen that when data is stored in a hard disk, each stripe includes a first physical page for storing user data and first metadata, a second physical page for storing P2L table and second metadata, and a third physical page for storing check data and third metadata, where the first metadata is used to store a logical address of the user data, the P2L table records a mapping relationship from the physical address to the logical address of each user data, each bit of the corresponding second metadata is written as 1, finally, an exclusive-or result of all the user data and the P2L table is used as check data, and an exclusive-or result of the first metadata and the second metadata is used as third metadata corresponding to the check data. Further, when garbage collection is performed on each first physical page, if the P2L table fails to read and there is a failure to read the target user data, this indicates that a double exception condition occurs at this time, and because the value of the second metadata is all 1, the present application can quickly recover the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest of the user data, that is, recover to obtain the logical address of the target user data, and then determine whether the target user data is valid data by reading the L2P table, and under the valid condition, because all metadata in the target stripe are known at this time, the present application can reconstruct to obtain the P2L table again based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of the user data, and finally recover the target user data by using the reconstructed P2L table and the verification data. In this way, the metadata of the P2L data is fixed to be 1, so that under the condition of double anomalies, the L2P table is not required to be traversed globally by using the physical address of the target user data, the metadata of the target user data can be quickly recovered, and the P2L table is quickly reconstructed, thereby recovering the double anomalies of the read failure to be single anomalies, finally recovering the target user data of the read failure, and ensuring the consistency of the data and the stability of the hard disk.
Since the embodiments of the apparatus portion and the embodiments of the method portion correspond to each other, the embodiments of the apparatus portion are described with reference to the embodiments of the method portion, which are not repeated herein. And, has the same advantageous effects as the above-mentioned exception handling method.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Specifically, the system comprises at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input/output interface 25 and a communication bus 26. Wherein the memory 22 is configured to store a computer program that is loaded and executed by the processor 21 to implement relevant steps in the exception handling method performed by the electronic device as disclosed in any of the foregoing embodiments.
In this embodiment, the power supply 23 is configured to provide working voltages for each hardware device on the electronic device 20, the communication interface 24 is capable of creating a data transmission channel with an external device for the electronic device 20, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein, and the input/output interface 25 is configured to obtain external input data or output data to the external device, and the specific interface type of the input/output interface may be selected according to the specific application needs and is not specifically limited herein.
Processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (DIGITAL SIGNAL Processing), FPGA (Field-Programmable gate array), PLA (Programmable Logic Array ). The processor 21 may also include a main processor, which is a processor for processing data in a wake-up state, also called a CPU (Central Processing Unit ), and a coprocessor, which is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit, image processor) for rendering and drawing of content required to be displayed by the display screen. In some embodiments, the processor 21 may also include an AI (ARTIFICIAL INTELLIGENCE ) processor for processing computing operations related to machine learning.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon include an operating system 221, a computer program 222, and data 223, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and the computer program 222, so as to implement the operation and processing of the processor 21 on the mass data 223 in the memory 22, which may be Windows, unix, linux. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the exception handling method performed by the electronic device 20 as disclosed in any of the foregoing embodiments. The data 223 may include, in addition to data received by the electronic device and transmitted by the external device, data collected by the input/output interface 25 itself, and so on.
Further, the embodiment of the application also discloses a computer readable storage medium, wherein the storage medium stores a computer program, and when the computer program is loaded and executed by a processor, the steps of the exception handling method disclosed in any embodiment are realized.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application, but such implementation is not intended to be limiting.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in random access Memory (Random Access Memory, i.e., RAM), memory, read-Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a compact disc Read-Only Memory (Compact Disc Read-Only Memory, i.e., CD-ROM), or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
While the foregoing describes the method, apparatus, device and storage medium for exception handling provided by the present invention, specific examples are set forth herein to illustrate the principles and embodiments of the present invention, the above examples are provided to assist in understanding the method and core ideas of the present invention, and meanwhile, to those skilled in the art, according to the ideas of the present invention, there are variations in the specific embodiments and application scope, and in summary, the disclosure should not be construed as limiting the present invention.

Claims (10)

1. An exception handling method, comprising:
Determining a target stripe of a garbage collection flow to be executed in a hard disk, wherein the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive-or result of the first metadata and the second metadata, and the check data is an exclusive-or result of the user data and the P2L table;
When garbage collection is carried out on each first physical page, if the P2L table fails to read and one target user data fails to read, recovering the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata and the rest user data;
Judging whether the target user data is valid or not based on the first metadata corresponding to the target user data and an L2P table, and if the target user data is valid, reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of user data so as to recover the target user data by using the reconstructed P2L table, the rest of user data and the verification data.
2. The exception handling method according to claim 1, further comprising:
Reading the P2L table to determine the validity of user data stored in each of the first physical pages when garbage collection is performed on each of the first physical pages;
If the P2L table fails to be read, reading the check data and all the user data to restore the P2L table by using the check data and all the user data, and then jumping to the step of reading the P2L table to determine the validity of the user data stored in each first physical page;
if there is a failure in reading the target user data, the method jumps to the step of recovering the first metadata corresponding to the target user data based on the first metadata corresponding to the second metadata, the third metadata and the rest of the user data.
3. The exception handling method according to claim 2, wherein the P2L table is configured to store a mapping relationship from an initial physical address to a logical address of each of the user data, and the L2P table is configured to store a mapping relationship from a logical address to a latest physical address of each of the user data;
accordingly, the reading the P2L table to determine the validity of the user data stored in each of the first physical pages includes:
obtaining a logical address and a first physical address corresponding to user data stored in each first physical page from the P2L table;
Searching a corresponding second physical address from the L2P table according to the logical address corresponding to each piece of user data;
and if the first physical address is the same as the second physical address, judging that the user data stored in the first physical page is valid, otherwise, judging that the user data stored in the first physical page is invalid.
4. The exception handling method according to claim 2, wherein after said reading the P2L table to determine validity of the user data stored in each of the first physical pages, further comprising:
If the user data stored in any physical page is valid, carrying out data moving processing on the corresponding user data;
And if the user data stored in any physical page is invalid, performing data discarding processing on the corresponding user data.
5. The exception handling method according to claim 1, wherein the determining whether the target user data is valid based on the first metadata corresponding to the target user data and the L2P table comprises:
Determining a target logical address of the target user data based on first metadata corresponding to the target user data, and searching a target physical address corresponding to the target logical address from the L2P table;
judging whether the target physical address is the same as the current physical address of the target user data;
If the target physical address is the same as the current physical address, judging that the target user data is valid;
And if the target physical address is different from the current physical address, judging that the target user data is invalid, and carrying out data discarding processing on the target user data.
6. The exception handling method according to claim 1, wherein after reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the remaining user data, further comprising:
reading the reconstructed P2L table to determine the validity of the rest of the user data;
And if the rest of the user data is judged to be valid, carrying out data migration processing on the rest of the user data, and if the rest of the user data is judged to be invalid, carrying out data discarding processing on the rest of the user data.
7. The exception handling method according to any one of claims 1 to 6, further comprising:
performing exclusive-or operation on each first metadata and each second metadata according to bits to obtain third metadata, and performing exclusive-or operation on each user data and each P2L table according to bits to obtain check data;
correspondingly, the restoring the first metadata corresponding to the target user data based on the second metadata, the third metadata and the first metadata corresponding to the rest user data includes:
Performing exclusive OR operation on the first metadata corresponding to the second metadata, the third metadata and the rest user data according to bits to restore the first metadata corresponding to the target user data;
correspondingly, the recovering the target user data by using the reconstructed P2L table, the rest user data and the verification data includes:
And carrying out exclusive OR operation on the reconstructed P2L table, the rest user data and the verification data according to bits to restore the target user data.
8. An abnormality processing apparatus, comprising:
The system comprises a stripe determining module, a stripe determining module and a data processing module, wherein the stripe determining module is used for determining a target stripe of a garbage collection flow to be executed in a hard disk, the target stripe comprises a first physical page used for storing user data and first metadata, a second physical page used for storing a P2L table and second metadata and a third physical page used for storing check data and third metadata, the first metadata is a logical address of the user data, each bit of the second metadata is 1, the third metadata is an exclusive-OR result of the first metadata and the second metadata, and the check data is an exclusive-OR result of the user data and the P2L table;
The metadata recovery module is configured to, when garbage collection is performed on each of the first physical pages, if the P2L table fails to read and there is a failure in reading the target user data, recover first metadata corresponding to the target user data based on the second metadata, the third metadata, and first metadata corresponding to the rest user data;
And the user data recovery module is used for judging whether the target user data is valid or not based on the first metadata corresponding to the target user data and the L2P table, and reconstructing the P2L table based on the first metadata corresponding to the target user data and the first metadata corresponding to the rest of user data if the target user data is valid, so as to recover the target user data by using the reconstructed P2L table, the rest of user data and the verification data.
9. An electronic device, comprising:
a memory for storing a computer program;
A processor for executing the computer program to implement the steps of the exception handling method according to any one of claims 1 to 7.
10. A computer readable storage medium for storing a computer program, wherein the computer program when executed by a processor implements the steps of the exception handling method according to any one of claims 1 to 7.
CN202510059217.8A 2025-01-15 2025-01-15 Exception handling method, device, equipment and medium Active CN119473731B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510059217.8A CN119473731B (en) 2025-01-15 2025-01-15 Exception handling method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510059217.8A CN119473731B (en) 2025-01-15 2025-01-15 Exception handling method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN119473731A CN119473731A (en) 2025-02-18
CN119473731B true CN119473731B (en) 2025-03-14

Family

ID=94588762

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202510059217.8A Active CN119473731B (en) 2025-01-15 2025-01-15 Exception handling method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN119473731B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542800A (en) * 2018-11-23 2019-03-29 深圳大普微电子科技有限公司 Method, solid state hard disk and the storage device of garbage disposal based on flash memory
CN111045956A (en) * 2019-12-22 2020-04-21 北京浪潮数据技术有限公司 Solid state disk garbage recycling method and device based on multi-core CPU

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11556467B1 (en) * 2021-07-13 2023-01-17 Micron Technology, Inc. Optimizing garbage collection that uses a logical-to-physical table search

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542800A (en) * 2018-11-23 2019-03-29 深圳大普微电子科技有限公司 Method, solid state hard disk and the storage device of garbage disposal based on flash memory
CN111045956A (en) * 2019-12-22 2020-04-21 北京浪潮数据技术有限公司 Solid state disk garbage recycling method and device based on multi-core CPU

Also Published As

Publication number Publication date
CN119473731A (en) 2025-02-18

Similar Documents

Publication Publication Date Title
US11301379B2 (en) Access request processing method and apparatus, and computer device
US10509730B2 (en) Aggregation of write traffic to a data store
JP6026538B2 (en) Non-volatile media journaling of validated datasets
KR101870521B1 (en) Methods and systems for improving storage journaling
US20140281307A1 (en) Handling snapshot information for a storage device
CN110196818B (en) Method, cache device and storage system for caching data
US20140351526A1 (en) Data storage controller with multiple pipelines
JP2019502987A (en) Multipage failure recovery in non-volatile memory systems
JP2011197945A (en) Controller, data storage device, and program
KR20110010580A (en) Index page recovery
CN103019888A (en) Backup method and device
CN108255414B (en) Solid state disk access method and device
CN119248197B (en) Data processing method, device, equipment and medium
US11487428B2 (en) Storage control apparatus and storage control method
CN119473731B (en) Exception handling method, device, equipment and medium
CN116795295B (en) Data processing methods and devices, storage media, and electronic equipment in disk arrays
CN105573862B (en) Method and equipment for recovering file system
CN105068760A (en) Data storage method, data storage apparatus and storage device
US20210034516A1 (en) System and method for improving write performance for log structured storage systems
CN114721584B (en) Method, apparatus and computer program product for writing data
CN111124746B (en) Method, apparatus and computer readable medium for managing redundant array of independent disks
US20190196900A1 (en) Networked storage redundancy scheme
CN119645733B (en) KVM data storage processing method and system and continuous data point recovery method thereof
US11392543B2 (en) System and method for optimizing capacity and performance for sparse snapshots
CN109542359B (en) Data reconstruction method, device, equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant