Data block processing method and device, terminal equipment and readable storage medium

By identifying and erasing invalid data blocks in the simulation platform, the problem of invalid data occupying storage space is solved, and the performance and efficiency of the storage system are improved.

CN119883126APending Publication Date: 2025-04-25YEESTOR MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411986586.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-25

Smart Images

  • Figure CN119883126A_ABST
    Figure CN119883126A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of storage, and provides a data block processing method and device, terminal equipment and a readable storage medium. The data block processing method comprises the following steps: determining invalid data blocks in simulation platform data blocks; erasing data in the invalid data blocks before executing the garbage collection process; and when the garbage collection process is executed, returning a corresponding execution result according to the invalid data block after data erasing. According to the embodiment of the invention, the invalid data blocks are erased in advance, so that the storage space is released, the fragmentation degree of the storage system is reduced, the storage system can manage the storage space more efficiently, the utilization rate of storage resources is improved, and the read-write speed and the response capability of the storage system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of storage technology, and in particular relates to a data block processing method, apparatus, terminal device and readable storage medium. Background Art

[0002] With the continuous development of storage technology, simulation platforms are playing an increasingly important role in the design and testing of storage systems. Simulation platforms can simulate real storage environments to comprehensively test and optimize the performance, reliability, and stability of storage systems.

[0003] However, as data is continuously written and updated, a large amount of invalid data will be generated in the simulation platform, which will occupy storage space and reduce the overall performance of the storage system. Summary of the Invention

[0004] The embodiments of the present application provide a data block processing method, apparatus, terminal device and readable storage medium, which can solve the problem in the related art that invalid data in the simulation platform occupies storage space, resulting in reduced storage system performance.

[0005] In a first aspect, an embodiment of the present application provides a method for processing a data block, including:

[0006] Determine invalid data blocks in the simulation platform data block;

[0007] Erasing data in invalid data blocks before performing garbage collection process;

[0008] When executing the garbage collection process, the corresponding execution result is returned according to the invalid data blocks after erasing the data.

[0009] In some implementations of the first aspect, determining an invalid data block in a simulation platform data block includes:

[0010] Get the number of write times of data blocks in the simulation platform;

[0011] Determine invalid data blocks based on the number of writes.

[0012] In some implementations of the first aspect, determining an invalid data block according to the number of write times includes:

[0013] Determine whether the number of write times of the data block is greater than a preset threshold;

[0014] A data block with a write count greater than a preset threshold is determined as an invalid data block.

[0015] In some implementations of the first aspect, determining an invalid data block in a simulation platform data block includes:

[0016] Obtain the physical to logical mapping table corresponding to the data block;

[0017] Invalid data blocks are determined based on the physical to logical mapping table.

[0018] In some implementations of the first aspect, determining the invalid data block according to the physical-to-logical mapping table includes:

[0019] Get the physical address and the corresponding logical address in the physical to logical mapping table;

[0020] Determine whether the corresponding logical address is a failed logical address according to the physical address;

[0021] Traverse the physical to logical mapping table to find the physical addresses corresponding to all failed logical addresses;

[0022] The invalid data block is determined according to the physical address corresponding to the failed logical address.

[0023] In some implementations of the first aspect, erasing data in an invalid data block before performing a garbage collection process includes:

[0024] Get the physical address of the invalid data block;

[0025] Based on the physical address of the invalid data block, the data in the invalid data block is erased before the garbage collection process is performed.

[0026] In some implementations of the first aspect, before determining the invalid data block in the simulation platform data block, the method further includes:

[0027] After writing new data, obtain the logical address of the new data;

[0028] Determine the physical address of the old data according to the logical address of the new data;

[0029] An invalid data block in the simulation platform data block is determined according to the physical address of the old data.

[0030] In a second aspect, an embodiment of the present application provides a data block processing device, including:

[0031] A determination module, used for determining invalid data blocks in the simulation platform data blocks;

[0032] An erase module, used to erase data in invalid data blocks before executing the garbage collection process;

[0033] The return module is used to return the corresponding execution result according to the invalid data block after erasing the data when executing the garbage collection process.

[0034] In a third aspect, an embodiment of the present application provides a terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data block processing method when executing the computer program.

[0035] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the above-mentioned data block processing method.

[0036] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a terminal device, enables the terminal device to execute the above-mentioned data block processing method.

[0037] Compared with the prior art, the embodiments of the present application have the following advantages: the embodiments of the present application determine invalid data blocks in the simulation platform data blocks and erase the data in the invalid data blocks before executing the garbage collection process. When the garbage collection process is executed, the corresponding execution results are returned based on the invalid data blocks after the data is erased. By erasing the invalid data blocks in advance, the embodiments of the present application free up storage space, help reduce the degree of fragmentation of the storage system, enable the storage system to manage storage space more efficiently, improve the utilization of storage resources, and thus improve the read and write speed and responsiveness of the storage system. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0039] Figure 1 This is a schematic diagram of an implementation flow of a data block processing method provided in an embodiment of the present application;

[0040] Figure 2 This is a schematic diagram of data compression provided by an embodiment of the present application;

[0041] Figure 3 This is a schematic diagram of the structure of a data block processing device provided in an embodiment of the present application;

[0042] Figure 4 It is a structural diagram of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solutions and advantages of this application more clear, the application 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 only used to explain this application and are not intended to limit this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without making any creative work are protected by this application.

[0044] It should be noted that the terms "include", "comprising" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, terminal, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In the claims, specification and drawings of this application, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such real-time relationship or order between these entities / operations / objects.

[0045] References to "embodiments" herein mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0046] With the continuous development of storage technology, simulation platforms are playing an increasingly important role in the design and testing of storage systems. Simulation platforms can simulate real storage environments to comprehensively test and optimize the performance, reliability, and stability of storage systems.

[0047] However, as data is continuously written and updated, a large amount of invalid data will be generated in the simulation platform, which will occupy storage space and reduce the overall performance of the storage system.

[0048] In view of this, the embodiments of the present application free up storage space by erasing invalid data blocks in advance, which helps to reduce the fragmentation of the storage system, enables the storage system to manage storage space more efficiently, improves the utilization of storage resources, and thus improves the read and write speed and responsiveness of the storage system.

[0049] In order to illustrate the technical solution of the present application, specific embodiments are provided below.

[0050] Figure 1 The present invention provides a schematic diagram of a data block processing method according to an embodiment of the present invention, which can be applied to a terminal device, such as a mobile phone, tablet computer, laptop computer, ultra-mobile personal computer (UMPC), or netbook.

[0051] Specifically, the method for processing the data block may include the following steps S101 to S103.

[0052] Step S101: determining invalid data blocks in the simulation platform data blocks.

[0053] The simulation platform is a system or software used to simulate a real-world storage environment, allowing developers to test and optimize the performance, reliability, and stability of storage systems without actually deploying hardware. A data block is the basic unit of data in a storage system, typically used to store a file or a portion of data. It is the fundamental unit of storage management.

[0054] In the simulation platform, an invalid data block refers to a data block that stores invalid data. It's understandable that due to operations like data updates, deletions, and duplicate writes, the data within some data blocks may become useless. In such cases, these data blocks are considered invalid data blocks. For example, in some simulation tests, the same data may be written to different data blocks at different times. In this case, the data block that first stored the same data becomes an invalid data block.

[0055] In an embodiment of the present application, the terminal device can determine whether each data block is an invalid data block based on the number of writes in the simulation platform, or by determining whether the logical address of the data block is invalid.

[0056] Step S102 , erasing data in invalid data blocks before executing the garbage collection process.

[0057] Among them, the garbage collection process is a storage management technology that can be used to identify objects that are no longer in use (including data in invalid data blocks) and reclaim the memory resources occupied by these objects to free up storage space and optimize the performance of the storage system.

[0058] It should be understood that in the relevant technology, when the firmware executes the garbage collection process, it can traverse all data blocks and identify objects that are no longer used, including data in invalid data blocks, and reclaim memory resources for these objects. That is, the garbage collection process will not only erase the data in invalid data blocks, but also perform various other memory resource recovery operations. However, the garbage collection process is usually performed when the storage system is idle or when memory resources are insufficient, and it is necessary to traverse the entire storage space, which will cause large delays and performance degradation. That is, before the firmware executes the garbage collection process, there will be some invalid data blocks in the simulation platform. These invalid data blocks will occupy a certain amount of storage space, which will affect the reading and writing speed of the data.

[0059] In the embodiments of the present application, after determining an invalid data block in the simulation platform data block, the terminal device can immediately erase the data in the invalid data block, without having to wait until the garbage collection process is executed to erase the data in the invalid data block. By erasing the data in the invalid data block in advance before the garbage collection process is executed, the invalid data block can be cleared in a timely manner, effectively managing storage space, thereby improving the speed and efficiency of data processing.

[0060] In a typical application scenario, at the first moment, the terminal device writes data x into data block A of the simulation platform. At the second moment (the second moment is later than the first moment), the terminal device performs a repeated write test on the simulation platform, and at this time, the terminal device also writes data x into data block B of the simulation platform. Since the data in data block B is the same as the data in data block A, and the time when data x is written into data block B is later than the time when data x is written into data block A, data block A can be considered an invalid data block at this time. In the related art, the firmware will execute a garbage collection process when the storage system is idle or at other preset times, traverse all data blocks, identify invalid data blocks A therein, and erase data from invalid data blocks A. During the period from the moment after data x is written into data block B to the time when the firmware executes the garbage collection process, the invalid data of invalid data block A will still occupy storage space, that is, during this period, invalid data block A cannot store other data, resulting in the data that needs to be written can only be written into other free data blocks, or even resulting in no free data blocks in the storage device to write data, and can only be written to other storage media (such as files), resulting in a significant reduction in data reading and writing speeds. In this case, the present application can determine invalid data block A in the simulation platform data block when writing data x into data block B, and immediately erase the data in invalid data block A after determining the invalid data block A (before executing the garbage collection process), so that data block A can be stored again. The embodiment of the present application effectively manages storage space by promptly clearing data in invalid data blocks, thereby improving the speed and efficiency of data processing.

[0061] In some specific implementations, after erasing the data in the invalid data block before executing the garbage collection process, the following steps are further included:

[0062] Mark invalid data blocks of erased data.

[0063] In an embodiment of the present application, after the terminal device erases the data in the invalid data blocks before executing the garbage collection process, the terminal device can mark the invalid data blocks from which the data has been erased to indicate that the invalid data has been erased from these data blocks, so that the subsequent terminal device can directly identify the invalid data blocks from which the data has been erased.

[0064] Step S103: When executing the garbage collection process, the corresponding execution result is returned according to the invalid data block after the data is erased.

[0065] In an embodiment of the present application, after the terminal device erases the data in the invalid data block before the garbage collection process, it starts to execute the garbage collection process according to the preset execution time of the garbage collection process.

[0066] Specifically, the terminal device can start with root objects (such as global variables and the stacks of active threads) and mark all reachable objects along the reference chain of the root objects to determine which objects are currently referenced or reachable. After the marking phase is complete, the terminal device can determine which objects are garbage objects (including invalid data blocks), that is, unreachable objects. Since these objects are no longer referenced by any root or reachable objects, they are considered eligible for collection. The terminal device can then perform garbage collection to reclaim the memory space occupied by the marked garbage objects. The specific collection method can vary depending on the GC algorithm, such as mark-and-sweep, copy, or mark-and-compact. Specifically, the mark-and-sweep algorithm marks unused objects and removes them. The copy algorithm copies surviving objects to another area and clears the original area. The mark-and-compact algorithm compacts memory after marking, moving all surviving objects together. After garbage collection is complete, heap memory may become fragmented. To improve memory utilization, the terminal device can compact the memory space, arranging surviving objects in a compact manner to reduce memory fragmentation and improve memory allocation efficiency. After garbage collection and memory compaction are completed, the terminal device can allocate memory space for new objects.

[0067] During the execution of the garbage collection process, when the terminal device scans invalid data blocks that have been erased, it can read the marks of the invalid data blocks that have been erased, thereby quickly identifying these invalid data blocks that have been erased. At this time, the terminal device does not need to perform garbage collection operations on these invalid data blocks that have been erased, but can directly return an execution result of successful erasure. That is, in an embodiment of the present application, the terminal device erases the data in the invalid data blocks before executing the garbage collection process, so that when executing the garbage collection process, the terminal device does not need to re-identify the invalid data blocks and erase the data, which can reduce the computational complexity of the garbage collection process and save the time of the garbage collection process, thereby improving the user experience.

[0068] Compared with the prior art, the embodiments of the present application have the following advantages: the embodiments of the present application determine invalid data blocks in the simulation platform data blocks and erase the data in the invalid data blocks before executing the garbage collection process. When the garbage collection process is executed, the corresponding execution results are returned based on the invalid data blocks after the data is erased. By erasing the invalid data blocks in advance, the embodiments of the present application free up storage space, help reduce the degree of fragmentation of the storage system, enable the storage system to manage storage space more efficiently, improve the utilization of storage resources, and thus improve the read and write speed and responsiveness of the storage system.

[0069] In some implementations of the present application, the above-mentioned determination of invalid data blocks in the simulation platform data blocks may specifically include step S301 and step S302.

[0070] Step S301, obtaining the number of write times of a data block in the simulation platform.

[0071] The number of writes refers to the number of times a data block is written. In the simulation platform, each time data is updated or written, the number of writes for the corresponding data block is recorded.

[0072] In the embodiment of the present application, the terminal device can define the data format of the input host in the simulation platform. Specifically, the compression format is as follows: Figure 2 As shown, 512:8 compression can be used. The host data transmitted from the emulation platform to the firmware algorithm consists of a 6-byte LBA address, a 1-byte data status, and a 1-byte write count. After receiving this host data, the firmware forms a page of data and sends it to the emulation platform's flash. The emulation platform can then parse the write count of the corresponding data block and determine whether the data block has been updated or overwritten multiple times.

[0073] In addition, the terminal device can also maintain a counter or log of the number of data block writes. Each time a data block is written, the counter or log is updated. Therefore, the terminal device can query this counter or log to obtain the number of data block writes. Obtaining the write count can help identify which data blocks may be outdated or invalid.

[0074] Step S302: Determine invalid data blocks according to the number of write times.

[0075] In the embodiments of the present application, after obtaining the number of writes to a data block, the terminal device can determine whether the data block is invalid based on a preset threshold or rule. For example, a threshold for the number of writes can be set. When the number of writes to a data block exceeds this threshold, the data block is considered invalid. Determining invalid data blocks based on the number of writes can accurately identify data blocks that no longer contain valid data, providing targets for subsequent erase operations.

[0076] The present embodiment determines the validity of a data block by the number of writes, providing a more sophisticated control method for data management. Furthermore, by identifying and deleting invalid data blocks, storage space can be freed up, thereby improving the utilization of storage devices.

[0077] In some specific implementations of the present application, the above-mentioned determination of invalid data blocks based on the number of write times may specifically include step S401 and step S402.

[0078] Step S401: determine whether the number of write times of a data block is greater than a preset threshold.

[0079] In an embodiment of the present application, the terminal device may compare the number of write times of each data block with a preset threshold to determine whether the number of write times of the data block is greater than the preset threshold. Specifically, the preset threshold may be set to 1.

[0080] Step S402: Determine a data block whose write times are greater than a preset threshold as an invalid data block.

[0081] In the embodiment of the present application, when the number of writes to a data block is greater than a preset threshold, that is, when the number of writes to a data block is greater than 1, the terminal device can determine that the data block is an invalid data block and can perform data erasure. It should be understood that in the simulation platform, if the number of writes is greater than 1, it means that the LBA is an overwrite write, so the data written previously is old data, that is, the data block is an invalid data block.

[0082] For example, assume that there are two data blocks A and B in the simulation platform, and their write counts are both 0 initially. When the firmware writes data to data block A, the simulation platform updates the write count of A to 1. Subsequently, if the firmware writes new data to the same logical address (assuming it is LBA0) again, but this time writes the data to data block B, the simulation platform updates the write count of B to 1 and increases the write count of A to 2 (indicating that LBA0 has been overwritten). At this point, the terminal device can mark A as an invalid data block and can immediately erase A. When the firmware executes the garbage collection process, it can be found that A has been erased by the simulation platform, so A can be skipped directly, thereby improving the efficiency of garbage collection.

[0083] In other specific embodiments of the present application, in addition to the above-mentioned method of determining invalid data blocks by the number of write times of the data blocks, the above-mentioned determination of invalid data blocks in the simulation platform data blocks may further specifically include step S501 and step S502.

[0084] Step S501: Obtain a physical-to-logical mapping table corresponding to a data block.

[0085] The Page-to-Logical Block Mapping Table (PBM) is a table that records the mapping relationship between logical block addresses (LBA) and physical page addresses (PPA). In storage devices such as NAND flash memory, the actual physical location of data blocks may change due to factors such as bad blocks and wear leveling. The PBM can be used to track changes in the actual physical location of data blocks.

[0086] In the embodiments of the present application, a terminal device can utilize a firmware algorithm to call an interface provided by the simulation platform to obtain a physical-to-logical mapping table corresponding to all data blocks in the current storage system, thereby understanding the current status of each data block. The table is typically stored in the internal memory of the simulation platform or can be obtained from an external device via a communication protocol.

[0087] It is important to understand that the simulation platform can maintain a physical-to-logical mapping table that records the correspondence between each physical data block and the logical data block. When data is written or updated, the simulation platform can update this mapping table to ensure that it always reflects the latest data layout.

[0088] Step S502: Determine invalid data blocks according to the physical-to-logical mapping table.

[0089] In an embodiment of the present application, the terminal device may utilize a firmware algorithm to traverse the physical-to-logical mapping table, check the mapping relationship of each data block, and determine whether the data block is an invalid data block based on the logical address of the data block.

[0090] Specifically, the terminal device can traverse the physical-to-logical mapping table to locate physical data blocks that are no longer referenced by any logical blocks. This is accomplished by examining each entry in the mapping table, specifically those where the logical block field is empty or points to a deleted or overwritten logical block. By comparing the information in the physical-to-logical mapping table, the terminal device can accurately identify which physical data blocks contain invalid data. Once these invalid data blocks are identified, the terminal device can erase them, freeing up storage space.

[0091] For example, assume that the simulation platform maintains a storage device containing three physical data blocks (physical block 1, physical block 2, and physical block 3) and a physical-to-logical mapping table. Initially, all three physical blocks store valid data, and the mapping table records their correspondence with the logical blocks.

[0092] The user then deletes logical block A (originally stored on physical block 1) and creates a new logical block B (stored on physical block 2). When deleting logical block A, the emulation platform updates the mapping table, setting the logical block references for physical block 1 to either null or a special "invalid" state. When the end device wants to determine which physical data blocks are invalid, it can check the mapping table. At this point, the end device can see that physical block 1 is no longer referenced by any logical block and can therefore mark it as an invalid data block. It can then schedule an erase of the data on physical block 1 to free up storage space for other logical blocks.

[0093] In some specific implementations of the present application, the above-mentioned determination of invalid data blocks according to the physical-to-logical mapping table may specifically include steps S601 to S604.

[0094] Step S601: Obtain a physical address and a corresponding logical address in a physical-to-logical mapping table.

[0095] The physical address is the actual location of a data block or page on a storage device within a storage system. It is a unique identifier used within the storage device to locate and access data. The logical address is the address space provided by the storage system to users or upper-layer applications, used to identify the logical location of a data block or page. Logical addresses are mapped to physical addresses using a physical-to-logical mapping table.

[0096] In an embodiment of the present application, the terminal device may obtain each physical address and its corresponding logical address by reading the physical-to-logical mapping table within the storage system, which may be achieved by accessing a specific area of ​​the storage device or calling an interface provided by the storage system.

[0097] Step S602: Determine whether the corresponding logical address is a failed logical address according to the physical address.

[0098] Invalid logical addresses refer to logical addresses that are no longer valid or have been marked as deleted.

[0099] In an embodiment of the present application, the terminal device can check whether the logical address corresponding to each physical address in the physical-to-logical mapping table exists in a predefined invalid logical address list, or determine whether the logical address is invalid based on a specific flag bit or status code.

[0100] Step S603: traverse the physical-to-logical mapping table to search for physical addresses corresponding to all failed logical addresses.

[0101] In an embodiment of the present application, the terminal device may search the physical-to-logical mapping table to find all physical addresses that match the failed logical address, specifically by checking the physical-to-logical mapping table row by row until all matching physical addresses are found.

[0102] Step S604: determining an invalid data block according to the physical address corresponding to the failed logical address.

[0103] In an embodiment of the present application, the terminal device may collect the physical addresses corresponding to the failed logical addresses and determine the data blocks corresponding to these physical addresses as invalid data blocks.

[0104] The embodiments of the present application can accurately identify which data blocks are invalid through the determination of the physical-to-logical mapping table and the failed logical address, so as to more effectively manage the storage space and thus improve the efficiency of data access.

[0105] In some embodiments of the present application, the erasing of data in the invalid data block before executing the garbage collection process may specifically include step S701 and step S702.

[0106] Step S701: Obtain the physical address of the invalid data block.

[0107] In an embodiment of the present application, a terminal device may maintain an invalid data block list or a marking bitmap that records the physical addresses of all data blocks identified as invalid. Before executing the garbage collection process, the terminal device may first access this list or marking bitmap to obtain the physical addresses of all invalid data blocks that need to be erased.

[0108] Step S702 : Erasing data in the invalid data block according to the physical address of the invalid data block before executing the garbage collection process.

[0109] In an embodiment of the present application, the terminal device may send an erase instruction to the simulation platform according to the physical address of the invalid data block. After receiving the instruction, the simulation platform will perform a corresponding erase operation to completely clear the data in the invalid data block.

[0110] The embodiments of the present application obtain the physical addresses of invalid data blocks and, based on the physical addresses of the invalid data blocks, clear all invalid data blocks before the garbage collection process, thereby freeing up storage space for new data to be written. In addition, erasing invalid data blocks in advance can also reduce the amount of data migration during the garbage collection process, thereby improving the efficiency of garbage collection.

[0111] In some specific implementations of the present application, before determining the invalid data blocks in the simulation platform data blocks, the method may further include steps S801 to S803.

[0112] Step S801: After writing new data, obtain the logical address of the new data.

[0113] In an embodiment of the present application, when new data is written on the simulation platform, the terminal device may record the logical address of the new data for locating the new data in the logical storage structure.

[0114] Step S802: determining the physical address of the old data according to the logical address of the new data.

[0115] In the embodiments of the present application, when new data is written, the terminal device can find the physical address of the corresponding old data in the mapping relationship based on the logical address of the new data. This physical address is the actual location of the old data on the physical storage medium, so as to find the physical address of the old data that may be overwritten or deleted after the new data is written.

[0116] Step S803: determining the invalid data block in the simulation platform data block according to the physical address of the old data.

[0117] In the embodiment of the present application, after finding the physical addresses of the old data, the terminal device can mark the data blocks corresponding to these physical addresses as invalid data blocks. Specifically, this can be achieved by setting a mark bit in the internal data structure or updating the status.

[0118] The implementation method of the present application can start to determine invalid data blocks when writing new data, so as to immediately erase the data in the invalid data blocks without waiting for the garbage collection process to be executed to erase the data in the invalid data blocks. The invalid data blocks can be cleaned up in time, and the storage space can be effectively managed, thereby improving the speed and efficiency of data processing.

[0119] Figure 3 The following is a schematic diagram showing the structure of a data block processing device provided in an embodiment of the present application. The data block processing device 3 can be configured on a terminal device. Specifically, the data block processing device 3 can include:

[0120] A determination module 301 is configured to determine an invalid data block in a simulation platform data block;

[0121] An erasing module 302, configured to erase data in the invalid data block before executing a garbage collection process;

[0122] The return module 303 is used to return the corresponding execution result according to the invalid data blocks after the data is erased when executing the garbage collection process.

[0123] Compared with the prior art, the embodiments of the present application have the following advantages: the embodiments of the present application determine invalid data blocks in the simulation platform data blocks and erase the data in the invalid data blocks before executing the garbage collection process. When the garbage collection process is executed, the corresponding execution results are returned based on the invalid data blocks after the data is erased. By erasing the invalid data blocks in advance, the embodiments of the present application free up storage space, help reduce the degree of fragmentation of the storage system, enable the storage system to manage storage space more efficiently, improve the utilization of storage resources, and thus improve the read and write speed and responsiveness of the storage system.

[0124] In some implementations of the present application, the determination module 301 may also be used to:

[0125] Get the number of write times of data blocks in the simulation platform;

[0126] An invalid data block is determined according to the number of write times.

[0127] In some implementations of the present application, the determination module 301 may also be used to:

[0128] Determining whether the number of write times of the data block is greater than a preset threshold;

[0129] The data block whose write times is greater than the preset threshold is determined as an invalid data block.

[0130] In some implementations of the present application, the determination module 301 may also be used to:

[0131] Obtaining a physical-to-logical mapping table corresponding to the data block;

[0132] The invalid data block is determined according to the physical-to-logical mapping table.

[0133] In some implementations of the present application, the determination module 301 may also be used to:

[0134] Obtaining a physical address and a corresponding logical address in the physical-to-logical mapping table;

[0135] Determining whether a corresponding logical address is a failed logical address according to the physical address;

[0136] Traversing the physical-to-logical mapping table to find the physical addresses corresponding to all the failed logical addresses;

[0137] The invalid data block is determined according to the physical address corresponding to the failed logical address.

[0138] In some embodiments of the present application, the erasure module 302 may also be used to:

[0139] Obtaining the physical address of the invalid data block;

[0140] According to the physical address of the invalid data block, data in the invalid data block is erased before executing the garbage collection process.

[0141] In some embodiments of the present application, the data block processing device 3 may further include an acquisition module for:

[0142] After writing new data, obtain the logical address of the new data;

[0143] determining the physical address of the old data according to the logical address of the new data;

[0144] The invalid data block in the simulation platform data block is determined according to the physical address of the old data.

[0145] like Figure 4FIG. 4 is a schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 4 may include: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401, such as a data block processing program. When the processor 401 executes the computer program 403, the steps in the above-mentioned data block processing method embodiment are implemented, such as Figure 1 Steps S101 to S103 are shown.

[0146] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned terminal device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.

[0147] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A method for processing a data block, characterized in that: include: Determine invalid data blocks in the simulation platform data block; Erasing the data in the invalid data block before executing the garbage collection process; When the garbage collection process is executed, the corresponding execution result is returned according to the invalid data blocks after the data is erased.

2. The method for processing a data block according to claim 1, characterized in that: The step of determining an invalid data block in a simulation platform data block comprises: Get the number of write times of data blocks in the simulation platform; An invalid data block is determined according to the number of write times.

3. The data block processing method according to claim 2, characterized in that: The determining of the invalid data block according to the number of write times includes: Determining whether the number of write times of the data block is greater than a preset threshold; The data block whose write times is greater than the preset threshold is determined as an invalid data block.

4. The method for processing a data block according to claim 1, characterized in that: The step of determining an invalid data block in a simulation platform data block comprises: Obtaining a physical-to-logical mapping table corresponding to the data block; The invalid data block is determined according to the physical-to-logical mapping table.

5. The method for processing a data block according to claim 4, characterized in that: The determining of the invalid data block according to the physical to logical mapping table comprises: Obtaining a physical address and a corresponding logical address in the physical-to-logical mapping table; Determining whether the corresponding logical address is a failed logical address according to the physical address; Traversing the physical-to-logical mapping table to find the physical addresses corresponding to all the failed logical addresses; The invalid data block is determined according to the physical address corresponding to the failed logical address.

6. The method for processing a data block according to claim 1, characterized in that: Erasing the data in the invalid data block before executing the garbage collection process includes: Obtaining the physical address of the invalid data block; According to the physical address of the invalid data block, data in the invalid data block is erased before executing the garbage collection process.

7. The method for processing a data block according to claim 1, characterized in that: Before determining the invalid data block in the simulation platform data block, the method further includes: After writing new data, obtain the logical address of the new data; Determine the physical address of the old data according to the logical address of the new data; The invalid data block in the simulation platform data block is determined according to the physical address of the old data.

8. A data block processing device, characterized in that: include: A determination module, used for determining invalid data blocks in the simulation platform data blocks; An erasing module, used for erasing the data in the invalid data block before executing the garbage collection process; The return module is used to return the corresponding execution result according to the invalid data blocks after erasing the data when executing the garbage collection process.

9. A terminal device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for processing a data block according to any one of claims 1 to 7 when executing the computer program.

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