Data processing method, device, electronic device and storage medium

By dynamically allocating the data area and backup area in the user area of ​​the solid-state drive, processing the data transfer and recovery of files to be moved, the problem of poor data recovery after file deletion is solved, and more efficient space use and resource management is achieved.

CN119440421BActive Publication Date: 2025-04-08ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510025276.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-04-08
Estimated Expiration
2045-01-07

AI Technical Summary

Technical Problem

When existing solid-state drives cannot effectively recover data after file deletion and do not support TRIM operations, it will cause multiple data transfers and garbage collection, seriously affecting the life of the solid-state drive.

Method used

By dynamically allocating the data area and backup area in the user area of ​​the solid state hard disk, obtaining free data blocks and moving the data of the files to be moved to the block, recording its attribute information and physical addresses to the data recovery index information table, and restoring or clearing is performed as needed.

Benefits of technology

Improves data recovery, optimizes the space use of solid-state drives, reduces resource consumption, and extends the life of solid-state drives.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440421B_ABST
    Figure CN119440421B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of solid-state hard disks, and in particular to a data processing method, device, electronic device and storage medium, which are used to improve the recoverability of data without affecting the performance of solid-state hard disks. The method includes: when it is detected that there are files to be moved in the file system, according to the space status of the user area of ​​the solid-state hard disk, a corresponding acquisition method is adopted to obtain free data blocks, wherein the files to be moved are files marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the files marked as deleted after the move; the data of the files to be moved are moved to the free data blocks, and the attribute information of the files to be moved and the physical address after the move are recorded in the data recovery index information table in the system area of ​​the solid-state hard disk; based on the data recovery index information table, the data of the files in the backup area are processed, and the processing is: recovery processing or clearing processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of solid-state hard disks, and in particular to a data processing method, device, electronic device and storage medium. Background Art

[0002] In Solid State Drives (SSDs), since data must be erased before being written and the basic unit of erasing is larger than the basic unit of writing, SSDs are not directly compatible with the original file system and require the Flash Translation Layer (FTL) algorithm to achieve the mapping of logical addresses to physical addresses.

[0003] When a file is deleted, the host will mark the information in the file system as deleted. For file systems that support TRIM operations, the host will subsequently send a TRIM command (a command used to erase deleted data in the SSD) during idle time to erase the corresponding block. At this time, the data will be lost and cannot be recovered. For file systems that do not support TRIM operations, since the SSD does not know that the data is invalid, it will be moved multiple times. At the same time, when the corresponding area is overwritten later, garbage collection (GC) operations must be performed to process these spaces, which seriously affects the life of the SSD.

[0004] Therefore, how to improve data recoverability without affecting the performance of the solid-state drive is a technical problem that needs to be solved at present. Summary of the invention

[0005] The embodiments of the present application provide a data processing method, device, electronic device and storage medium to improve the recoverability of data without affecting the performance of a solid-state drive.

[0006] The specific technical solutions provided by the embodiments of this application are as follows:

[0007] In a first aspect, a data processing method is provided, the method comprising:

[0008] When it is detected that there are files to be moved in the file system, a corresponding acquisition method is adopted to acquire free data blocks according to the space status of the user area of ​​the solid state drive, wherein the files to be moved are files marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the files marked as deleted after the migration;

[0009] Move the data of the file to be moved to the free data block, and record the attribute information of the file to be moved and the physical address after the move into the data recovery index information table in the system area of ​​the solid state drive;

[0010] Based on the data recovery index information table, the data of the files in the backup area are processed, and the processing is: recovery processing or clearing processing.

[0011] In a possible embodiment, according to the space status of the user area of ​​the solid state hard disk, a corresponding acquisition method is adopted to acquire the free data block, including:

[0012] When the number of empty data blocks in the user area is greater than a first number threshold, applying for a free data block;

[0013] When the number of empty data blocks in the user area is less than or equal to a first number threshold, and the number of data blocks with valid data less than a second number threshold exists in the data area, garbage collection is performed on the data blocks to obtain free data blocks;

[0014] When there is not enough space in the user area and there are no data blocks in the data area whose number of valid data is less than the second number threshold, data blocks whose generation time meets the time condition are selected from the backup area as free data blocks.

[0015] Through the above method, the space status of the user area is taken into consideration, and different space statuses use different acquisition methods to obtain free data blocks, which can ensure the performance of the solid-state hard disk and the reliability of migration under each space status.

[0016] In a possible embodiment, moving the data of the file to be moved to the free data block includes:

[0017] Write the directory entry and cluster chain corresponding to the file to be moved to the free data block;

[0018] According to the logical address of the file to be moved, the flash translation layer FTL mapping table is searched to obtain the physical address of the file to be moved, and based on the physical address of the file to be moved, the data of the file to be moved is moved to the free data block, where the FTL mapping table records the mapping of the logical address of each file to the physical address.

[0019] Through the above method, the data of the file to be moved can be accurately moved to the free data block, and the scattered data of the file to be moved can be moved together.

[0020] In a possible embodiment, after moving the data of the file to be moved to the free data block, the method further includes:

[0021] If the free data block is full and there is unmoved data in the file to be moved, a new free data block is obtained by adopting a corresponding acquisition method according to the space status of the user area;

[0022] Move the unmoved data to new free data blocks.

[0023] Through the above method, it can be ensured that all the data of the files to be moved are moved.

[0024] In a possible embodiment, the method further includes:

[0025] Based on the physical address of the file to be moved after the move, modify the FTL mapping table.

[0026] Through the above method, the accuracy of the FTL mapping table can be guaranteed.

[0027] In a possible embodiment, if the processing is recovery processing, the data of the files in the backup area are processed based on the data recovery index information table, including:

[0028] In response to a recovery operation for a file to be recovered, querying a data recovery index information table to obtain a physical address of the file to be recovered, wherein the file to be recovered is a file stored in a backup area;

[0029] The FTL mapping table is modified based on the new logical address of the file to be restored and the physical address of the file to be restored.

[0030] Through the above method, data recovery can be performed quickly and accurately without the need for actual writing operations, and data recovery consumes low resources. In addition, the normal operation of the original file system is guaranteed.

[0031] In a possible embodiment, if the processing is a clearing processing, the data of the files in the backup area are processed based on the data recovery index information table, including:

[0032] In response to a clearing operation on a file to be cleared, querying a data recovery index information table to obtain a physical address of the file to be cleared, wherein the file to be cleared is a file stored in a backup area;

[0033] Based on the physical address of the file to be cleared, the logical address of the file to be cleared is obtained, 0 is written to the logical address, and the data block corresponding to the physical address of the file to be cleared is erased.

[0034] Through the above method, data can be deleted quickly and accurately, performance can be optimized, and the normal operation of the original file system is guaranteed.

[0035] In a second aspect, the present application provides a data processing device, the device comprising:

[0036] The acquisition module is used to acquire free data blocks by adopting a corresponding acquisition method according to the space status of the user area of ​​the solid state disk when detecting that there are files to be moved in the file system, wherein the files to be moved are files marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the files marked as deleted after the migration;

[0037] A migration module, used to migrate the data of the file to be migrated to a free data block, and record the attribute information of the file to be migrated and the physical address after migration into the data recovery index information table in the system area of ​​the solid state drive;

[0038] The processing module is used to process the data of the files in the backup area based on the data recovery index information table, and the processing is: recovery processing or clearing processing.

[0039] In a possible embodiment, according to the space status of the user area of ​​the solid state hard disk, a corresponding acquisition method is adopted to acquire the free data block, and the acquisition module is further used to:

[0040] When the number of empty data blocks in the user area is greater than a first number threshold, applying for a free data block;

[0041] When the number of empty data blocks in the user area is less than or equal to a first number threshold, and the number of data blocks with valid data less than a second number threshold exists in the data area, garbage collection is performed on the data blocks to obtain free data blocks;

[0042] When there is not enough space in the user area and there are no data blocks in the data area whose number of valid data is less than the second number threshold, data blocks whose generation time meets the time condition are selected from the backup area as free data blocks.

[0043] In a possible embodiment, when moving the data of the file to be moved to the free data block, the moving module is further used to:

[0044] Write the directory entry and cluster chain corresponding to the file to be moved to the free data block;

[0045] According to the logical address of the file to be moved, the flash translation layer FTL mapping table is searched to obtain the physical address of the file to be moved, and based on the physical address of the file to be moved, the data of the file to be moved is moved to the free data block, where the FTL mapping table records the mapping of the logical address of each file to the physical address.

[0046] In a possible embodiment, after moving the data of the file to be moved to the free data block, the moving module is further used to:

[0047] If the free data block is full and there is unmoved data in the file to be moved, a new free data block is obtained by adopting a corresponding acquisition method according to the space status of the user area;

[0048] Move the unmoved data to new free data blocks.

[0049] In a possible embodiment, the moving module is further used for:

[0050] Based on the physical address of the file to be moved after the move, modify the FTL mapping table.

[0051] In a possible embodiment, if the processing is recovery processing, when processing the data of the file in the backup area based on the data recovery index information table, the processing module is further used to:

[0052] In response to a recovery operation for a file to be recovered, querying a data recovery index information table to obtain a physical address of the file to be recovered, wherein the file to be recovered is a file stored in a backup area;

[0053] The FTL mapping table is modified based on the new logical address of the file to be restored and the physical address of the file to be restored.

[0054] In a possible embodiment, if the processing is a clearing processing, when processing the data of the files in the backup area based on the data recovery index information table, the processing module is further used to:

[0055] In response to a clearing operation on a file to be cleared, querying a data recovery index information table to obtain a physical address of the file to be cleared, wherein the file to be cleared is a file stored in a backup area;

[0056] Based on the physical address of the file to be cleared, the logical address of the file to be cleared is obtained, 0 is written to the logical address, and the data block corresponding to the physical address of the file to be cleared is erased.

[0057] According to a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any one of the methods described in the first aspect are implemented.

[0058] According to a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in any one of the first aspects are implemented.

[0059] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods described in the first aspect.

[0060] In the embodiment of the present application, when it is detected that there are files to be moved in the file system, a corresponding acquisition method is adopted according to the space status of the user area of ​​the solid-state hard disk to obtain free data blocks, wherein the files to be moved are files marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the files marked as deleted after the move, and then the data of the files to be moved are moved to the free data blocks, and the attribute information of the files to be moved and the physical address after the move are recorded in the data recovery index information table in the system area of ​​the solid-state hard disk, and based on the data recovery index information table, the data of the files in the backup area are processed, and the processing is: recovery processing or clearing processing. In this way, the user area of ​​the solid-state hard disk is dynamically divided into two parts (data area and backup area), and the free space of the solid-state hard disk is used to realize the integration management of the files marked as deleted, and the integrated files moved to the backup area can be quickly restored or deleted, which improves the data recovery capability and optimizes the space, and saves resources, and improves the data recovery capability of the solid-state hard disk while improving the performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;

[0062] Figure 2 Another flowchart of the data processing method in the embodiment of the present application is shown;

[0063] Figure 3 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;

[0064] Figure 4 Schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0065] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0066] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0067] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0068] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.

[0069] To facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:

[0070] Logical Block Address (LBA): It is an abstract way for operating systems and applications to access data blocks on storage devices. User applications read and write data through LBA.

[0071] Physical Block Address (PBA): It is the address of the location where data is actually stored inside the storage device, indicating the specific location inside the storage device (such as a hard disk or SSD) (for example, a specific track, cylinder, or page in a flash memory chip).

[0072] The following is a brief introduction to the design concept of the embodiment of the present application:

[0073] In a solid-state drive, since data must be erased before being written and the basic unit of erasing is larger than the basic unit of writing, the solid-state drive cannot be directly compatible with the original file system and needs to use the FTL algorithm to achieve the mapping of logical addresses to physical addresses.

[0074] Due to the existence of FTL, an independent space needs to be opened up to store the FTL mapping table. Usually, a hard disk needs to declare 1 / 1000 of its capacity to store the FTL mapping table. At the same time, a certain amount of space is required to store table items, firmware and other information for solid-state operation. A certain amount of space is also required in user data for GC. In summary, in a solid-state drive, all space will be divided into the system area (SYS area) and the data area (data area), and the FTL mapping table is stored in the SYS area.

[0075] When a file is deleted, the host will mark the information in the file system as deleted. For file systems that support TRIM operations, the host will subsequently send a TRIM command (a command used to erase deleted data in the SSD) during idle time to erase the corresponding blocks. At this time, the data will be lost and cannot be recovered. For file systems that do not support TRIM operations, since the SSD does not know that the data is invalid, it will be moved multiple times. At the same time, when overwriting the corresponding area later, GC operations must be performed to process these spaces, which seriously affects the life of the SSD.

[0076] When restoring a file, it is necessary to re-apply for the data block and re-execute the actual writing process, which is slow and consumes more resources.

[0077] Therefore, how to improve data recoverability without affecting the performance of the solid-state drive is a technical problem that needs to be solved at present.

[0078] In view of this, in an embodiment of the present application, a data processing method, device, electronic device and storage medium are provided. When it is detected that there is a file to be moved in the file system, a corresponding acquisition method is adopted according to the space status of the user area of ​​the solid-state hard disk to obtain a free data block, wherein the file to be moved is a file marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the file marked as deleted after the move, and then the data of the file to be moved is moved to the free data block, and the attribute information of the file to be moved and the physical address after the move are recorded in the data recovery index information table in the system area of ​​the solid-state hard disk, and based on the data recovery index information table, the data of the file in the backup area is processed, and the processing is: recovery processing or clearing processing. In this way, the user area of ​​the solid-state hard disk is dynamically divided into two parts (data area and backup area), and the free space of the solid-state hard disk is used to realize the integration management of the files marked as deleted, and the integrated files moved to the backup area can be quickly restored or deleted, which improves the data recovery capability and optimizes the space, and saves resources, improves the data recovery capability of the solid-state hard disk while improving the performance, and realizes the recovery of accidentally deleted files.

[0079] See also Figure 1 As shown, it is an implementation flow chart of a data processing method provided in an embodiment of the present application. The specific implementation process of the method is as follows:

[0080] Step 10: When it is detected that there are files to be moved in the file system, a corresponding acquisition method is used to acquire free data blocks according to the space status of the user area of ​​the solid state drive.

[0081] The files to be moved are files marked for deletion, which are divided into a data area and a backup area by the user. The backup area is used to store the data of the files marked for deletion after the migration. The obtained free data blocks come from the data area or the backup area.

[0082] In the embodiment of the present application, the solid-state hard disk parses the boot information and the file system information, and when it detects that a file in the file system is marked as deleted, that is, when it detects that there are files to be moved in the file system.

[0083] In the embodiment of the present application, different acquisition methods are used for different space states to obtain free data blocks. The space state of the user area is divided into the following three situations:

[0084] Case 1: the number of empty data blocks in the user area is less than or equal to the first number threshold, and the number of data blocks with valid data less than the second number threshold exists in the data area.

[0085] Among them, if the number of empty data blocks in the user area is less than or equal to the first quantity threshold, it means that the user area does not have enough space. At this time, it is necessary to erase the data blocks that meet the erasure conditions to generate free data blocks. In the embodiment of the present application, the first quantity threshold and the second quantity threshold are not restricted.

[0086] In an embodiment of the present application, when the number of empty data blocks in the user area is less than or equal to a first number threshold, and there are data blocks in the data area where the number of valid data is less than a second number threshold, garbage collection is performed on the data blocks to obtain free data blocks.

[0087] Case 2: the number of empty data blocks in the user area is less than or equal to the first number threshold, and the data area does not have data blocks with the number of valid data less than the second number threshold.

[0088] In the embodiment of the present application, data blocks whose generation time meets the time condition are selected from the backup area as free data blocks.

[0089] Among them, the data block whose generation time meets the time condition is the data block whose generation time is farthest from the current time. Since the data blocks in the backup area store the data of the files marked as deleted after being moved, the generation time of a data block in the backup area is the time when the data of the files marked as deleted are moved to the data block. The farther the time is, the less likely the data needs to be restored. Therefore, the data stored in the data blocks whose generation time meets the time condition in the backup area can be cleared to obtain free data blocks.

[0090] In addition, it is worth noting that after selecting a data block whose generation time meets the time condition as a free data block, the information of the file corresponding to the data block in the data recovery index information table is deleted to ensure the accuracy of the data recovery index information table.

[0091] Case 3: The number of empty data blocks in the user area is greater than the first number threshold.

[0092] The fact that the number of empty data blocks in the user area is greater than the first number threshold indicates that there is enough space in the user area.

[0093] In an embodiment of the present application, when the number of empty data blocks in the user area is greater than a first quantity threshold, it is detected whether there are unfilled data blocks in the backup area (i.e., it is detected whether the previous free data block is full). If so, the unfilled data block is used as a free data block. If not, a free data block is requested from the data area.

[0094] For example, if it is a triple-level cell (TLC) solid state drive, apply for TLC.

[0095] In this way, considering the space status of the user area, different space status adopts different acquisition methods to obtain free data blocks, which can ensure the performance of the solid-state hard disk and the reliability of migration under each space status.

[0096] Step 11: Move the data of the file to be moved to the free data block, and record the attribute information of the file to be moved and the physical address after the move into the data recovery index information table in the system area of ​​the solid state drive.

[0097] Among them, the data recovery index information table records the attribute information of each file to be moved and the physical address after the move. The attribute information of the file to be moved includes but is not limited to the file name, deletion time and storage number, etc. The information of the physical address includes but is not limited to: the number of address items, PB number, offset within PB, length within PB, among which PB number, offset within PB and length within PB may be composed of multiple groups, and the number is obtained through the number of address items.

[0098] In an embodiment of the present application, the data of the file to be moved is moved to a free data block, and the attribute information of the file to be moved and the physical address after the move are recorded in the data recovery index information table in the system area of ​​the solid state drive, and the free data block is used as a data block in the backup area.

[0099] Optionally, in an embodiment of the present application, a possible embodiment is provided for moving the data of the file to be moved to the free data block, and the specific process is as follows:

[0100] Step 110: Write the directory entry and cluster chain corresponding to the file to be moved into the free data block.

[0101] Step 111: according to the logical address of the file to be moved, search the flash translation layer FTL mapping table to obtain the physical address of the file to be moved, and based on the physical address of the file to be moved, move the data of the file to be moved to the free data block.

[0102] Among them, the FTL mapping table records the mapping from the logical address to the physical address of each file.

[0103] In an embodiment of the present application, the logical address of the file to be moved is obtained based on the directory entry and cluster chain information corresponding to the file to be moved, and then the FTL mapping table is searched based on the logical address of the file to be moved to obtain the physical address of the file to be moved, and based on the physical address of the file to be moved, the data of the file to be moved is moved to the free data block until the data is moved or the free data block is full.

[0104] In this way, the data of the file to be moved can be accurately moved to the free data block, and the scattered data of the file to be moved can be moved together.

[0105] Furthermore, in the embodiment of the present application, the FTL mapping table is modified based on the physical address of the file to be moved after the move.

[0106] Specifically, the ftl convert process is called to modify the FTL mapping table, and the original table entry information of the file to be moved is modified.

[0107] In this way, the accuracy of the FTL mapping table can be guaranteed.

[0108] In addition, it is worth explaining that in the embodiment of the present application, after the data of the file to be moved is moved to the free data block, it also includes: if the free data block is full and there is unmoved data in the file to be moved, then according to the space status of the user area, a corresponding acquisition method is adopted to acquire a new free data block, and then the unmoved data is moved to the new free data block until there is no unmoved data in the file to be moved.

[0109] In this way, it can be ensured that all the data of the files to be moved are moved.

[0110] Step 12: Based on the data recovery index information table, the data of the files in the backup area are processed.

[0111] The processing is: recovery processing or clearing processing.

[0112] Specifically, when the processing is recovery processing, the following operations are performed:

[0113] Step 120: In response to the recovery operation for the file to be recovered, query the data recovery index information table to obtain the physical address of the file to be recovered.

[0114] The files to be restored are files stored in the backup area.

[0115] Step 121: based on the new logical address of the file to be restored and the physical address of the file to be restored, modify the FTL mapping table.

[0116] In an embodiment of the present application, dedicated software is used. The dedicated software obtains information from a data recovery index table through a customized interactive protocol (developed based on an original protocol), parses a list of files that can be recovered, and the user selects the files to be recovered. The dedicated software notifies the solid-state drive and writes the files to be recovered to the file system. The solid-state drive queries the data recovery index information table, obtains the physical address of the file to be recovered, determines the location of the written data, and compares the written data of the file to be recovered with the original data. When the new written data of the file to be recovered is consistent with the original data, no actual write operation is required, and only the FTL mapping table is modified. The FTL mapping table is modified based on the new logical address of the file to be recovered and the physical address of the file to be recovered.

[0117] In this way, when performing data recovery, since the files recorded in the data recovery index information table have been summarized and managed, the data of the files recorded in the data recovery index information table have been stored in the backup area. Therefore, data recovery can be performed quickly and accurately, and no actual write operation is required. Data recovery consumes low resources. In addition, the normal operation of the original file system is guaranteed.

[0118] Specifically, when the processing is clearing processing, the following operations are performed:

[0119] Step 122: In response to the clearing operation on the file to be cleared, query the data recovery index information table to obtain the physical address of the file to be cleared.

[0120] The files to be cleared are files stored in the backup area.

[0121] Step 123: Based on the physical address of the file to be cleared, obtain the logical address of the file to be cleared, write 0 to the logical address, and erase the data block corresponding to the physical address of the file to be cleared.

[0122] In an embodiment of the present application, dedicated software is used. The dedicated software obtains information from a data recovery index table through a customized interactive protocol, parses a list of files that can be recovered, and the user selects the files to be cleared. The dedicated software notifies the solid-state drive, queries the data recovery index information table, obtains the physical address of the file to be cleared, queries the mapping table based on the physical address of the file to be cleared, obtains the logical address of the file to be cleared, writes 0 to the logical address, and notifies the solid-state drive to erase the data block corresponding to the physical address of the file to be cleared.

[0123] Among them, the mapping table records the mapping from physical addresses to logical addresses. The mapping table can be a P2L mapping table, which is not limited in the embodiments of the present application.

[0124] In this way, in order to optimize performance, the data in the backup area can be deleted. Since the files recorded in the data recovery index information table have been summarized and managed, the data of the files recorded in the data recovery index information table have been stored in the backup area. Therefore, data deletion can be performed quickly and accurately. In addition, the normal operation of the original file system is guaranteed.

[0125] Based on the above embodiments, see Figure 2 FIG. 1 is another flow chart of a data processing method in an embodiment of the present application, which specifically includes:

[0126] Step 20: Get the files to be moved from the file system.

[0127] The files to be moved are files marked as deleted.

[0128] Step 21: Determine whether the number of empty data blocks in the user area is greater than a first quantity threshold, if so, execute step 22, otherwise, execute step 25.

[0129] The user area is dynamically divided into a data area and a backup area. The backup area is used to store the data of files marked as deleted after being moved.

[0130] Step 22: Determine whether there are unfilled data blocks in the backup area. If so, execute step 23; otherwise, execute step 24.

[0131] Step 23: Use the unfilled data blocks in the backup area as free data blocks.

[0132] Step 24: Apply for a free data block.

[0133] Step 25: Determine whether there are data blocks in the data area whose amount of valid data is less than the second amount threshold; if so, execute step 26; otherwise, execute step 27.

[0134] Step 26: performing garbage collection on data blocks whose amount of valid data is less than a second amount threshold to obtain free data blocks.

[0135] Step 27: From the backup area, select data blocks whose generation time meets the time condition as free data blocks.

[0136] Step 28: Move the data of the file to be moved to the free data block.

[0137] Step 29: After the free data block is filled, determine whether there is any unmoved data in the file to be moved. If so, execute step 210; otherwise, execute step 211.

[0138] Step 210: Obtain a new free data block and move the unmoved data to the new free data block.

[0139] In the embodiment of the present application, continue to apply for a free data block. If the application fails, execute steps 25-27 to obtain a free data block.

[0140] Step 211: based on the physical address of the file to be moved after the move, modify the FTL mapping table.

[0141] Step 212: Record the attribute information of the file to be moved and the physical address after the move into the data recovery index information table in the system area of ​​the solid state drive.

[0142] Step 213: Based on the data recovery index information table, the data of the files in the backup area are processed.

[0143] The processing is: recovery processing or clearing processing.

[0144] Based on the same inventive concept, the present application embodiment provides a data processing device, please refer to Figure 3 , the device comprises:

[0145] The acquisition module 301 is used to acquire free data blocks by adopting a corresponding acquisition method according to the space status of the user area of ​​the solid state disk when it is detected that there is a file to be moved in the file system, wherein the file to be moved is a file marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the file marked as deleted after the migration;

[0146] A moving module 302 is used to move the data of the file to be moved to a free data block, and record the attribute information of the file to be moved and the physical address after the move to the data recovery index information table in the system area of ​​the solid state drive;

[0147] The processing module 303 is used to process the data of the files in the backup area based on the data recovery index information table, and the processing is: recovery processing or clearing processing.

[0148] In a possible embodiment, according to the space status of the user area of ​​the solid state hard disk, a corresponding acquisition method is adopted to acquire the free data block, and the acquisition module 301 is further used to:

[0149] When the number of empty data blocks in the user area is greater than a first number threshold, applying for a free data block;

[0150] When the number of empty data blocks in the user area is less than or equal to a first number threshold, and the number of data blocks with valid data less than a second number threshold exists in the data area, garbage collection is performed on the data blocks to obtain free data blocks;

[0151] When there is not enough space in the user area and there are no data blocks in the data area whose number of valid data is less than the second number threshold, data blocks whose generation time meets the time condition are selected from the backup area as free data blocks.

[0152] In a possible embodiment, when moving the data of the file to be moved to the free data block, the moving module 302 is further used to:

[0153] Write the directory entry and cluster chain corresponding to the file to be moved to the free data block;

[0154] According to the logical address of the file to be moved, the flash translation layer FTL mapping table is searched to obtain the physical address of the file to be moved, and based on the physical address of the file to be moved, the data of the file to be moved is moved to the free data block, where the FTL mapping table records the mapping of the logical address of each file to the physical address.

[0155] In a possible embodiment, after moving the data of the file to be moved to the free data block, the moving module 302 is further used to:

[0156] If the free data block is full and there is unmoved data in the file to be moved, a new free data block is obtained by adopting a corresponding acquisition method according to the space status of the user area;

[0157] Move the unmoved data to new free data blocks.

[0158] In a possible embodiment, the moving module is further used for:

[0159] Based on the physical address of the file to be moved after the move, modify the FTL mapping table.

[0160] In a possible embodiment, if the processing is recovery processing, when processing the data of the file in the backup area based on the data recovery index information table, the processing module 303 is further used to:

[0161] In response to a recovery operation for a file to be recovered, querying a data recovery index information table to obtain a physical address of the file to be recovered, wherein the file to be recovered is a file stored in a backup area;

[0162] The FTL mapping table is modified based on the new logical address of the file to be restored and the physical address of the file to be restored.

[0163] In a possible embodiment, if the processing is a clearing processing, when processing the data of the files in the backup area based on the data recovery index information table, the processing module 303 is further used to:

[0164] In response to a clearing operation on a file to be cleared, querying a data recovery index information table to obtain a physical address of the file to be cleared, wherein the file to be cleared is a file stored in a backup area;

[0165] Based on the physical address of the file to be cleared, the logical address of the file to be cleared is obtained, 0 is written to the logical address, and the data block corresponding to the physical address of the file to be cleared is erased.

[0166] Based on the above embodiments, see Figure 4 Shown is a schematic diagram of the structure of an electronic device in an embodiment of the present application.

[0167] An embodiment of the present application provides an electronic device, which may include a processor 410 (Center Processing Unit, CPU), a memory 420, an input device 430 and an output device 440, etc. The input device 430 may include a keyboard, a mouse, a touch screen, etc., and the output device 440 may include a display device, such as a liquid crystal display (Liquid Crystal Display, LCD), a cathode ray tube (Cathode Ray Tube, CRT), etc.

[0168] The memory 420 may include a read-only memory (ROM) and a random access memory (RAM), and provides the processor 410 with program instructions and data stored in the memory 420. In the embodiment of the present application, the memory 420 may be used to store the program of any data processing method in the embodiment of the present application.

[0169] The processor 410 calls the program instructions stored in the memory 420, and the processor 410 is used to execute any data processing method in the embodiments of the present application according to the obtained program instructions.

[0170] Based on the above embodiments, in an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data processing method in any of the above method embodiments is implemented.

[0171] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0172] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0173] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0174] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0175] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data processing method, characterized in that: include: When it is detected that there is a file to be moved in the file system, a corresponding acquisition method is adopted to acquire a free data block from the user area according to the space status of the user area of ​​the solid state drive, wherein the file to be moved is a file marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the file marked as deleted after the move; Moving the data of the file to be moved to the free data block, and recording the attribute information of the file to be moved and the physical address after the move into the data recovery index information table in the system area of ​​the solid state drive; Based on the data recovery index information table, the data of the files in the backup area are processed, and the processing is: recovery processing or clearing processing.

2. The method according to claim 1, characterized in that The method of acquiring free data blocks from the user area of ​​the solid state disk by adopting a corresponding acquisition method according to the space status of the user area of ​​the solid state disk includes: When the number of empty data blocks in the user area is greater than a first number threshold, applying for a free data block; When the number of empty data blocks in the user area is less than or equal to the first number threshold, and the number of data blocks with valid data less than the second number threshold exists in the data area, garbage collection is performed on the data blocks to obtain free data blocks; When the user area does not have enough space and the data area does not have data blocks with the number of valid data less than the second number threshold, data blocks whose generation time meets the time condition are selected from the backup area as free data blocks.

3. The method according to claim 1, characterized in that The step of moving the data of the file to be moved to the free data block includes: Writing the directory entry and cluster chain corresponding to the file to be moved into the free data block; According to the logical address of the file to be moved, the flash translation layer FTL mapping table is searched to obtain the physical address of the file to be moved, and based on the physical address of the file to be moved, the data of the file to be moved is moved to the free data block, wherein the FTL mapping table records the mapping of the logical address of each file to the physical address.

4. The method according to claim 1, characterized in that After the data of the file to be moved is moved to the free data block, the method further includes: If there is unmoved data in the file to be moved after the free data block is full, a new free data block is obtained by adopting a corresponding acquisition method according to the space status of the user area; The unmoved data is moved to the new free data block.

5. The method according to claim 1, characterized in that The method further comprises: Based on the physical address of the file to be moved after the move, the FTL mapping table is modified.

6. The method according to claim 1, characterized in that If the processing is recovery processing, the processing of the data of the file in the backup area based on the data recovery index information table includes: In response to a recovery operation for a file to be recovered, querying the data recovery index information table to obtain a physical address of the file to be recovered, wherein the file to be recovered is a file stored in the backup area; The FTL mapping table is modified based on the new logical address of the file to be restored and the physical address of the file to be restored.

7. The method according to claim 1, characterized in that If the processing is a clearing processing, then the processing of the data of the files in the backup area based on the data recovery index information table includes: In response to a clearing operation on a file to be cleared, querying the data recovery index information table to obtain a physical address of the file to be cleared, wherein the file to be cleared is a file stored in the backup area; Based on the physical address of the file to be cleared, the logical address of the file to be cleared is obtained, 0 is written to the logical address, and the data block corresponding to the physical address of the file to be cleared is erased.

8. A data processing device, characterized in that: include: an acquisition module, for acquiring free data blocks from the user area of ​​the solid state disk by adopting a corresponding acquisition method when detecting that there is a file to be moved in the file system, according to the space status of the user area of ​​the solid state disk, wherein the file to be moved is a file marked as deleted, and the user area is divided into: a data area and a backup area, and the backup area is used to store the data of the file marked as deleted after the move; A moving module, used for moving the data of the file to be moved to the free data block, and recording the attribute information of the file to be moved and the physical address after the move into the data recovery index information table in the system area of ​​the solid state drive; A processing module is used to process the data of the files in the backup area based on the data recovery index information table, and the processing is: recovery processing or clearing processing.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Flash memory storage method and device with file system

    CN108804344A

  • Method and system for quickly writing data into storage equipment

    CN110515552A