Abnormal power failure recovery method and system based on block management

文档序号:1963607 发布日期:2021-12-14 浏览:11次 中文

阅读说明:本技术 一种基于block管理的异常掉电恢复方法及系统 (Abnormal power failure recovery method and system based on block management ) 是由 金岳平 于 2021-08-04 设计创作,主要内容包括:本申请提供一种基于block管理的异常掉电恢复方法及系统,方法包括:在空闲block列表中选择预设数量的block作为预写block;将预写block的信息及FTL的增量变化表写入SSD;新数据写入预写block中,同时将FTL的更新项同步记录到增量变化表,直到预写block被用完;重复上述步骤,当增量变化表的记录数据总量达到预设值,将完整的FTL备份替换增量备份过程;发生异常掉电后再次上电时,读取有效的增量变化表,将记录更新到FTL中;遍历最后一份有效增量变化表中每一个预写block,查找其有效数据,更新FTL后将最新的FTL更新至SSD。本申请解决了大容量SSD的异常掉电恢复时间过长问题。(The application provides an abnormal power failure recovery method and system based on block management, wherein the method comprises the following steps: selecting a preset number of blocks in an idle block list as pre-written blocks; writing the information of the pre-written block and the increment change table of the FTL into the SSD; writing new data into the pre-written block, and synchronously recording an updating item of the FTL into an incremental change table until the pre-written block is used up; repeating the steps, and replacing the complete FTL backup for the incremental backup process when the total amount of the recorded data of the incremental change table reaches a preset value; when the power is powered on again after abnormal power failure occurs, reading the effective incremental change table and updating the record into the FTL; and traversing each pre-written block in the last effective increment change table, searching effective data of the block, and updating the latest FTL to the SSD after updating the FTL. The method and the device solve the problem that the abnormal power failure recovery time of the high-capacity SSD is too long.)

1. An abnormal power failure recovery method based on block management is characterized by comprising the following steps:

and (3) writing data:

a, selecting a preset number of blocks in an idle block list of an SSD as pre-written blocks;

b, writing the information of the pre-written block and the increment change table of the FTL into the SSD, and emptying the increment change table after the completion, wherein the step is an increment backup process;

writing the new data into the pre-written block, and synchronously recording an updating item of the FTL into an incremental change table until the pre-written block is used up, wherein the incremental change table also comprises a sequence number for identifying a time sequence;

d, repeating the steps a to c, when the total amount of the recorded data of the incremental change table reaches the data amount of the whole FTL, carrying out a complete FTL backup replacing incremental backup process in the step b, and recording the latest serial number of the incremental change table in a new FTL record;

e, when the equipment is normally shut down or the drive is unloaded, updating the FTL into the SSD, and marking the written data as a shutdown backup;

and (3) an abnormal power failure recovery stage:

f, if abnormal power failure occurs at any time in the steps a, b, c and d, after power is turned on again, reading the latest FTL;

judging whether a power-off backup mark exists in the read FTL, if the FTL does not have the power-off backup mark, reading an incremental change table, and searching for an effective part according to the serial number;

h, reading the effective increment change table, and updating the record into the FTL;

i, reading information of the prewritten blocks in the last effective incremental change table, traversing each prewritten block, and searching effective data in the prewritten blocks;

and j, after traversing the information of the pre-written block, updating the FTL, updating the latest FTL into the SSD, and completing the abnormal power failure recovery process.

2. The abnormal power failure recovery method based on block management as claimed in claim 1, wherein in step b, block is pre-written as addressing information of block, including a channel number of block, a serial number of NAND chip in the channel, and a serial number of block in the NAND chip.

3. The method for recovering abnormal power failure based on block management according to claim 1, wherein in the step c, each item of content of the update item of the FTL is a mapping relationship between a pair of physical addresses and LBAs.

4. The method for recovering abnormal power failure based on block management as claimed in claim 1, wherein in step g, it is determined whether there is a shutdown backup mark in the FTL that is read, and if there is a relevant machine backup mark in the FTL, the FTL loading process is completed.

5. The method for recovering abnormal power failure based on block management according to claim 1, wherein the method further comprises: after the FTL is updated, the newly added data of the FTL is incremental data, and the incremental data is written into an incremental storage space preset on a memory, namely an incremental change table; the FTL stores a correspondence between logical block addresses and physical block addresses of the SSD.

6. The abnormal power failure recovery method based on block management according to claim 1, wherein in step a, if the free block reserved by the SSD is lower than the set threshold, the method further comprises a garbage recovery stage, comprising the steps of:

selecting a block with the lowest effective data ratio from all block lists of the SSD, and if more blocks are needed, continuing to select a block with the next lower effective data ratio until the requirement on the number of blocks is met;

transferring effective data in the selected block to other idle blocks, and erasing the selected block;

and adding the erased block into an idle block list.

7. An abnormal power failure recovery system based on block management is characterized by comprising: a data writing unit and an abnormal power failure recovery unit; wherein the content of the first and second substances,

the write data unit includes:

the block allocation module is used for selecting a preset number of blocks from a block list which is free in the SSD as pre-written blocks;

the incremental backup module is used for writing the information of the pre-written block and the incremental change table of the FTL into the SSD together, and emptying the incremental change table after the completion;

the new data writing module is used for writing the new data into the pre-written block and synchronously recording an updating item of the FTL into an incremental change table until the pre-written block is used up, wherein the incremental change table also comprises a sequence number used for identifying a time sequence;

the first judgment module is used for judging whether the total recorded data amount of the incremental change table reaches the data amount of the whole FTL or not;

the replacement module is used for carrying out a complete FTL backup and incremental backup replacement process when the total recorded data amount of the incremental change table reaches the data amount of the whole FTL, and the latest serial number of the incremental change table is recorded in a new FTL record;

the shutdown backup marking module is used for updating the FTL into the SSD when the equipment is normally shut down or the drive is unloaded, and marking the written data as shutdown backup;

the abnormal power failure recovery unit includes:

the latest FTL reading module is used for reading the latest FTL after the SSD is powered on again when abnormal power failure occurs;

the second judging module is used for judging whether the read FTL has a shutdown backup mark;

the incremental change table reading module is used for reading the incremental change table when the FTL has no shutdown backup mark, and searching for an effective part according to the serial number;

the effective increment change table reading module is used for reading the effective increment change table and updating the record into the FTL;

the effective data acquisition module is used for reading the information of the pre-written blocks in the last effective incremental change table, traversing each pre-written block and searching effective data in the pre-written blocks;

and the FTL updating module is used for updating the FTL after the information of the pre-written block is traversed, and updating the latest FTL into the SSD.

8. The block management-based abnormal power failure recovery system according to claim 7, wherein the system further comprises a garbage collection unit, and the garbage collection unit comprises:

the failure target block selection module is used for selecting blocks to be recovered, wherein the blocks to be recovered are blocks with the lowest effective data ratio selected from all block lists of the SSD, and if more blocks are needed, the blocks with the second lowest effective data ratio are continuously selected until the quantity requirement of the blocks is met;

the migration module is used for migrating the effective data in the selected block to be recovered to other idle blocks, wherein the other idle blocks refer to idle blocks except the block to be recovered in the SSD;

and the erasing module is used for erasing the block to be recovered and adding the erased block into the idle block list.

9. An abnormal power failure recovery device based on block management is characterized by comprising:

a memory for storing a computer program;

a processor for executing the computer program to implement the steps of the block management based abnormal power failure recovery method according to any one of claims 1 to 6.

10. A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when being executed by a processor, the computer program implements the steps of the block management-based abnormal power failure recovery method according to any one of claims 1 to 6.

Technical Field

The invention relates to the technical field of solid state disk storage, in particular to a block management-based abnormal power failure recovery method and system.

Background

The solid state disk uses an operating system to read and write data inside the solid state disk through a group of Logical Block Addresses (LBAs), on a common hard disk, because the data can be directly covered, the relationship between the LBAs and Physical Block Addresses (PBAs) is in one-to-one correspondence and cannot be changed, but because a storage medium NAND Flash memory used by the solid state disk has the characteristic that the storage medium can be written in by being erased first, the relationship between the LBAs and the PBAs is not fixed any more, the solid state disk is specially provided with a Layer for conversion from an upper Layer to a bottom Layer, namely an FTL (Flash Translation Layer), and the main task of the Layer is to convert the LBAs on the FTL Layer into the PBAs required by the bottom Layer. For the conversion task, the FTL layer needs a mapping table from LBA to PBA, called FTL table, which is stored in the memory, and needs to search and update the table in real time during the whole read-write process of the solid state disk, so as to correctly read or write data.

The design of the FTL has great influence on the performance and the service life of the SSD, in the SSD with small capacity, the FTL generally takes large pagesize as mapping, the latest FTL can be automatically stored when the power is normally off, and the stored FTL is directly read to restore data when the power is on and reloaded. When abnormal power failure occurs, the latest FTL has not been written into the SSD, and the previously stored FTL is not the latest, and all the NAND gates need to be scanned to reconstruct the latest FTL. Due to the large pagesize used, the time to scan the full disk is limited and no additional mechanism needs to be used.

In large-capacity enterprise-level SSDs, the operating frequency is more than 10TB, and such SSDs generally improve the access efficiency of flash memories by concurrent access through a plurality of channels, each channel reading and writing a part of NAND chips. Even so, the time for scanning the entire disk of the SSD is long, limited by the read/write speed of the NAND itself and the speed of the external interface, for example, a certain enterprise SSD provides 24T physical capacity, and even with a large pagesize, the time for scanning the entire disk needs 1-2 hours, which cannot meet the requirement. Meanwhile, in order to improve the service life and performance of the SSD, the enterprise-level SSD design generally adopts 4K pagesize, and the scanning granularity is smaller and the required time is longer.

To increase the speed of power loss recovery, a block fixed packet is typically used, as shown in fig. 1. Several NAND chips are divided into a group, and divided into a plurality of groups according to the serial number of the block, for example, 2X NAND in fig. 1, each X NAND is divided into a group, each NAND has n blocks, each group of NAND has n groups, and the entire SSD includes 2n groups.

And during data writing, writing data according to the groups, and not writing the next group until one group is not full. When garbage collection is carried out, sorting is carried out according to the effective data proportion of the groups, the group with the least effective data proportion is selected for garbage collection, and all the effective data need to be migrated and then erased when the garbage collection is carried out.

Detailed step of writing data

a. Searching the next idle group A write-in management information, wherein the management information comprises a write-in sequence number and is used for marking the write-in sequence of each group;

b. the newly written data are all written into group A until the group A is full;

c. when continuous writing is carried out, the a and b processes are repeatedly executed, and the written serial numbers are sequentially increased when the idle group is acquired each time;

d. updating the FTL into the SSD after a certain number of groups are written, writing the latest group serial number when the FTL is updated, and marking the written FTL as a temporary backup;

e. and when the equipment is normally shut down or the drive is unloaded, updating the FTL into the SSD and marking that the current writing is shut down backup.

When an abnormal power outage occurs, it may be at any time in a, b, c, d.

Detailed steps of garbage recovery

a. When the reserved groups are not enough, finding out the group F with the lowest average effective data ratio in all the groups;

b. migrating valid data to an idle group K;

after the group F migration is completed, erasing all blocks in the original group F;

d. and adding the erased group F into the free group list.

Device re-power-on procedure

a. Reading the latest FTL, if the FTL identification is a shutdown backup, loading the FTL, and reading the serial number as the starting serial number started by the equipment;

b. if the FTL represents temporary backup, the FTL indicates that the last power-off is abnormal power-off, abnormal power-off recovery is needed, the last FTL backup is read firstly during recovery, the recorded serial number y is obtained, and scanning of group is started;

c. scanning each group on a disc, reading the serial number of the group, recording the groups of all the serial numbers after y, sequencing according to the serial numbers, sequentially reading the information of all effective data in the groups, and updating the information into an FTL (fiber to the L);

d. and after the scanning is finished, completing the power failure recovery process.

By using the method to recover the abnormal power failure, the scanning of the whole disk can be avoided, the recovery process of the abnormal power failure is greatly accelerated, but the following defects exist:

(1) the design of the group can improve the write amplification of the whole SSD. Multiple blocks are included in a group, and the proportion of valid data in each block is not consistent with the use of an application. For example, the average valid data percentage of a group is 20%, it may be that each block is relatively average, and is 20%, and more may be that the block valid data percentage inside the group is not balanced, some is 5% or less, even there is no valid data, and some is more than 50%. As a whole, the group can only erase the whole group during recovery, so that the write amplification of part of blocks is increased, and the overall write amplification of the SSD is improved. If the granularity is smaller, such as management to a block level, only the block with the least effective data can be recycled, and the write amplification is effectively reduced.

(2) The write amplification factor and recovery time cannot be taken into account. The group size influences the write amplification and recovery time in design, if the group size is large, the probability that the effective data proportion is uneven is higher, the write amplification is relatively large, but the total number of the groups is small, and the recovery time of abnormal power failure is shorter; the group is small, the closer to the management of block level, the write amplification is relatively small, but the total number of the group is large, and the time for recovering the abnormal power failure is long.

(3) The abnormal power down recovery time increases with capacity. When the group size is fixed, the larger the capacity is, the more the groups are, which causes the abnormal power failure recovery time to be longer with the capacity.

Disclosure of Invention

The invention aims to provide a block management-based abnormal power failure recovery method and system, which are used for solving the problem that the abnormal power failure recovery time of a high-capacity SSD is too long and also considering the write amplification of the SSD.

In order to achieve the purpose, the invention adopts the following technical scheme:

the application provides an abnormal power failure recovery method based on block management in a first aspect, which comprises the following steps: and (3) writing data:

a, selecting a preset number of blocks in an idle block list of an SSD as pre-written blocks;

b, writing the information of the pre-written block and the increment change table of the FTL into the SSD, and emptying the increment change table after the completion, wherein the step is an increment backup process;

writing the new data into the pre-written block, and synchronously recording an updating item of the FTL into an incremental change table until the pre-written block is used up, wherein the incremental change table also comprises a sequence number for identifying a time sequence;

d, repeating the steps a to c, when the total amount of the recorded data of the incremental change table reaches the data amount of the whole FTL, carrying out a complete FTL backup replacing incremental backup process in the step b, and recording the latest serial number of the incremental change table in a new FTL record;

e, when the equipment is normally shut down or the drive is unloaded, updating the FTL into the SSD, and marking the written data as a shutdown backup;

and (3) an abnormal power failure recovery stage:

f, if abnormal power failure occurs at any time in the steps a, b, c and d, after power is turned on again, reading the latest FTL;

judging whether a power-off backup mark exists in the read FTL, if the FTL does not have the power-off backup mark, reading an incremental change table, and searching for an effective part according to the serial number;

h, reading the effective increment change table, and updating the record into the FTL;

i, reading information of the prewritten blocks in the last effective incremental change table, traversing each prewritten block, and searching effective data in the prewritten blocks;

and j, after traversing the information of the pre-written block, updating the FTL, updating the latest FTL into the SSD, and completing the abnormal power failure recovery process.

Preferably, in step a, the preset number of blocks included in the pre-written block can meet the requirement of the data volume of the full-speed writing in several seconds in the future.

Preferably, in step b, the block is pre-written as addressing information of the block, including a channel number of the block, a serial number of the NAND chip in the channel, and a serial number of the block in the NAND chip.

Preferably, in step c, each item of the update entry of the FTL is a mapping relationship between a pair of physical addresses and LBAs.

Preferably, in step g, it is determined whether the read FTL has a power-off backup mark, and if the FTL has a relevant machine backup mark, the FTL loading process is completed.

Preferably, the method further comprises: after the FTL is updated, the newly added data of the FTL is incremental data, and the incremental data is written into an incremental storage space preset on a memory, namely an incremental change table; the FTL stores a correspondence between logical block addresses and physical block addresses of the SSD.

Preferably, in the step a, if the free block reserved by the SSD is lower than the set threshold, the method further includes a garbage collection stage, including the steps of:

selecting a block with the lowest effective data ratio from all block lists of the SSD, and if more blocks are needed, continuing to select a block with the next lower effective data ratio until the requirement on the number of blocks is met;

transferring effective data in the selected block to other idle blocks, and erasing the selected block;

and adding the erased block into an idle block list.

A second aspect of the present application provides an abnormal power failure recovery system based on block management, including: a data writing unit and an abnormal power failure recovery unit; wherein the content of the first and second substances,

the write data unit includes:

the block allocation module is used for selecting a preset number of blocks from a block list which is free in the SSD as pre-written blocks;

the incremental backup module is used for writing the information of the pre-written block and the incremental change table of the FTL into the SSD together, and emptying the incremental change table after the completion;

the new data writing module is used for writing the new data into the pre-written block and synchronously recording an updating item of the FTL into an incremental change table until the pre-written block is used up, wherein the incremental change table also comprises a sequence number used for identifying a time sequence;

the first judgment module is used for judging whether the total recorded data amount of the incremental change table reaches the data amount of the whole FTL or not;

the replacement module is used for carrying out a complete FTL backup and incremental backup replacement process when the total recorded data amount of the incremental change table reaches the data amount of the whole FTL, and the latest serial number of the incremental change table is recorded in a new FTL record;

the shutdown backup marking module is used for updating the FTL into the SSD when the equipment is normally shut down or the drive is unloaded, and marking the written data as shutdown backup;

the abnormal power failure recovery unit includes:

the latest FTL reading module is used for reading the latest FTL after the SSD is powered on again when abnormal power failure occurs;

the second judging module is used for judging whether the read FTL has a shutdown backup mark;

the incremental change table reading module is used for reading the incremental change table when the FTL has no shutdown backup mark, and searching for an effective part according to the serial number;

the effective increment change table reading module is used for reading the effective increment change table and updating the record into the FTL;

the effective data acquisition module is used for reading the information of the pre-written blocks in the last effective incremental change table, traversing each pre-written block and searching effective data in the pre-written blocks;

and the FTL updating module is used for updating the FTL after the information of the pre-written block is traversed, and updating the latest FTL into the SSD.

Preferably, the information of the pre-written block is addressing information of the block, and includes a channel number of the block, a serial number of the NAND chip in the channel, and a serial number of the block in the NAND chip.

Preferably, each item of the update item of the FTL is a mapping relationship between a pair of physical addresses and LBAs.

Preferably, the system further comprises a waste recovery unit comprising:

the failure target block selection module is used for selecting blocks to be recovered, wherein the blocks to be recovered are blocks with the lowest effective data ratio selected from all block lists of the SSD, and if more blocks are needed, the blocks with the second lowest effective data ratio are continuously selected until the quantity requirement of the blocks is met;

the migration module is used for migrating the effective data in the selected block to be recovered to other idle blocks, wherein the other idle blocks refer to idle blocks except the block to be recovered in the SSD;

and the erasing module is used for erasing the block to be recovered and adding the erased block into the idle block list.

The third aspect of the present application provides an abnormal power failure recovery device based on block management, including:

a memory for storing a computer program;

a processor configured to execute the computer program to implement any of the above steps of the block management based abnormal power failure recovery method.

A fourth aspect of the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method for recovering abnormal power failure based on block management according to any of the foregoing steps is implemented.

Compared with the prior art, the technical scheme of the invention has the following beneficial effects:

1) the invention provides an abnormal power failure recovery method based on block management, which effectively limits the search range of data by recording the position to which future data will be written before writing data; write amplification of the SSD is minimized by FTL management using block granularity; the actual FTL change condition is recorded through the incremental change table, the recovery is carried out without rereading the original data, and the updating speed of the unrecorded FTL table entry is improved. The method and the device solve the problem that the abnormal power failure recovery time of the high-capacity SSD is too long, and simultaneously consider the write amplification of the SSD.

2) The invention provides an abnormal power failure recovery system based on block management, which can support the abnormal power failure recovery method based on block management.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the application and, together with the description, serve to explain the application and are not intended to limit the application. In the drawings:

FIG. 1 is a block fixed packet format packet diagram in the prior art;

FIG. 2 is a flow chart of a data writing process of the preferred embodiment of the present application;

FIG. 3 is a flow chart of an abnormal power loss recovery process in accordance with a preferred embodiment of the present application;

FIG. 4 is a flow chart of a garbage collection process of the preferred embodiment of the present application;

FIG. 5 is a diagram of a block list of blocks in a SSD in accordance with the preferred embodiment of the present application (there are thousands of blocks in an actual NAND chip);

fig. 6 is a block management-based abnormal power failure recovery system in accordance with the preferred embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order, it being understood that the data so used may be interchanged under appropriate circumstances. Furthermore, the terms "comprises," "comprising," and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.

The first embodiment is as follows:

FIG. 2 is a flow chart of a data writing process in the abnormal power failure recovery method based on block management according to the present application; FIG. 3 is a flow chart of an abnormal power loss recovery process; FIG. 4 is a flow chart of a garbage collection process; FIG. 5 is a block list diagram of blocks as granularity in an SSD.

Referring to fig. 2 to 5, the abnormal power failure recovery method based on block management disclosed in the present application includes the following stages:

write data process

And step A1, selecting a batch of blocks from the free block list as pre-written blocks, wherein the number of the blocks can generally meet the requirement of the data volume of the full-speed writing in several seconds in the future.

And step A2, writing the information of the pre-written blocks and the increment change table of the FTL into the SSD, and emptying the increment change table after the completion. This step is an incremental backup process. The incremental backup process records changes before this point in time and possible changes in the future. The information of the pre-written block is addressing information of the block, and comprises a channel number of the block, a serial number of the NAND chip in the channel, and a serial number of the block in the NAND chip.

Step a3, start writing data, new data will be written into these pre-written blocks, and simultaneously record the updated entries of FTL to the incremental change table synchronously until these blocks are used up. The delta change table contains sequence numbers identifying its timing. Wherein, each item content of the update item of the FTL is a mapping relationship between a pair of physical addresses and LBAs.

And step A4, repeating the processes of the steps A1-A3, and if the total recorded data amount of the several incremental change tables reaches the data amount of the whole FTL, performing a complete FTL backup replacement incremental backup process at the step A2. The latest sequence number of the delta change table is recorded in the new FTL record.

Step a5, when the device is normally powered off or the drive is unloaded, the FTL is updated to the SSD to indicate that the current writing is a power-off backup.

When an abnormal power outage occurs, it may be at any time in a1, a2, A3, a 4.

(II) abnormal Power loss recovery procedure

And step B1, after power-on, reading the latest FTL, and if the relevant machine in the FTL stores the backup mark, finishing the loading process of the FTL.

Step B2, if the FTL has no power-off backup mark, the incremental change table is read and the valid part is searched according to the sequence number.

And step B3, reading the effective incremental change table, and updating the record into the FTL.

And step B4, reading the information of the pre-written blocks in the last effective incremental change table, traversing each pre-written block, and searching effective data in the pre-written blocks.

And step B5, after traversing the block information, updating the FTL, updating the latest FTL into the SSD, and completing the abnormal power failure recovery process.

(III) garbage recovery Process

In step C1, when the reserved empty Block is insufficient, a Block with the lowest valid data percentage is selected from all Block lists of the SSD, for example, in fig. 5, blocks (0,4), (1,3), (2,2) … … and the like are blocks without valid data, blocks (0,1), (1,2) … … and the like, and blocks (0,3), (1,0) … … and the like are all blocks with valid data. Blocks such as Block (0,4), (1,3), (2,2) … … are selected, and if more blocks are needed, blocks such as Block (0,1), (1,2) … … are selected. Wherein, the coding rule of Block (x, y) is: x corresponds to the NAND number and y corresponds to the block number in the NAND.

And step C2, migrating the effective data in the selected block, and erasing the block.

And step C3, adding the erased block into an idle block list.

Example two:

corresponding to the above method embodiment, the embodiment of the present application further provides an abnormal power failure recovery system based on block management, referring to fig. 6, where the system includes a data writing unit 100, an abnormal power failure recovery unit 200, and a garbage collection unit 300.

Wherein, the data writing unit 100 includes:

the block pre-writing distribution module 101 is configured to select a preset number of blocks from a block list that is free in the SSD as pre-writing blocks;

the incremental backup module 102 is configured to write the information of the pre-written block and the incremental change table of the FTL into the SSD, and clear the incremental change table after completion;

a new data writing module 103, configured to write new data into the pre-written block, and simultaneously record an update item of the FTL into an incremental change table synchronously until the pre-written block is used up, where the incremental change table further includes a sequence number used for identifying a timing sequence;

a first judging module 104, configured to judge whether a total amount of recorded data of the incremental change table reaches a data amount of the entire FTL;

a replacement module 105, configured to perform a complete FTL backup replacement incremental backup process once when the total amount of recorded data of the incremental change table reaches the data amount of the entire FTL, where a new FTL record may record a latest serial number of the incremental change table;

and a shutdown backup marking module 106, configured to update the FTL to the SSD when the device is normally shutdown or the drive is unloaded, and mark the data written this time as a shutdown backup.

Wherein, the abnormal power failure recovery unit 200 includes:

the latest FTL reading module 201 is configured to, when the SSD is abnormally powered down, read the latest FTL after being powered up again;

a second determining module 202, configured to determine whether a shutdown backup flag exists in the read FTL;

an incremental change table reading module 203, configured to read an incremental change table when there is no shutdown backup flag in the FTL, and search for an effective part therein according to the sequence number;

an effective incremental change table reading module 204, configured to read an effective incremental change table, and update a record to the FTL;

the valid data obtaining module 205 is configured to read information of the pre-written blocks in the last valid incremental change table, traverse each pre-written block, and search for valid data therein;

and the FTL updating module 206 is configured to update the FTL after traversing the information of the pre-written block, and update the latest FTL into the SSD.

Wherein the garbage collection unit 300 includes:

the failure target block selection module 301 is configured to select a block to be recovered, where the block to be recovered selects a block with the lowest effective data ratio from all block lists of the SSD, and if more blocks are needed, continues to select a block with the second lowest effective data ratio until the number requirement on the blocks is met;

a migration module 302, configured to migrate effective data in the selected block to be recovered to other idle blocks, where the other idle blocks are idle blocks in the SSD except for the block to be recovered;

the erasing module 303 is configured to erase the block to be recovered, and add the erased block to the free block list.

Example three:

corresponding to the above method embodiment, an embodiment of the present application further provides an abnormal power failure recovery device based on block management, including:

a memory for storing a computer program;

and the processor is used for executing a computer program to realize the steps of the abnormal power failure recovery method based on block management in the embodiment 1.

Example four:

on the other hand, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method for recovering abnormal power failure based on block management in embodiment 1 is implemented. A computer-readable storage medium as referred to herein may include Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

To sum up, the technical scheme of the application has the following characteristics:

(1) it is necessary to record the position to which future data will be written before writing, which effectively limits the search range of the data. The distribution frequency and the number of the pre-written blocks are related to the writing speed of the SSD, the speed of the SSD cannot be greatly changed along with the capacity, the number of the pre-written blocks of the SSD with different capacities is basically consistent, the read data volume cannot be greatly changed, and the recovery time of the SSD cannot be increased along with the capacity.

(2) FTL management using block granularity minimizes write amplification of SSDs. In garbage collection, the block with the lowest effective data in all blocks is selected each time, so that the moved data volume can be reduced to the maximum extent, and the write amplification factor is reduced.

(3) The incremental change table records the actual FTL change condition, and the recovery is performed without rereading the original data, so that the updating speed of the unrecorded FTL table entry is increased. Each entry of the incremental change table corresponds to a 4k page mapping, generally 8 bytes represent an entry, and if the table is not available, management information in original data needs to be read for recovery. For example, an incremental change table with a size of 16k may record 2k mapping entries, and only one read operation is needed to complete the incremental change table, and if the management information in the original data is to be read, 2k times of reading are needed, and the time cost of the two is very different.

The embodiments of the present invention have been described in detail, but the embodiments are merely examples, and the present invention is not limited to the embodiments described above. Any equivalent modifications and substitutions to those skilled in the art are also within the scope of the present invention. Accordingly, equivalent changes and modifications made without departing from the spirit and scope of the present invention should be covered by the present invention.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:数据的恢复方法、计算设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!