Storage cleaning method and device, equipment, storage medium and program product

By dynamically sensing the input and output load status and promptly cleaning up invalid data blocks, the problem of data fragmentation in the storage medium is solved, ensuring read and write performance and improving user experience.

CN122308738APending Publication Date: 2026-06-30SPREADTRUM COMM (TIANJIN) INC

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SPREADTRUM COMM (TIANJIN) INC
Filing Date
2026-03-30
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In storage media, existing technologies have failed to effectively clean up invalid data blocks, leading to data fragmentation and affecting the read and write performance of the storage media.

Method used

By dynamically sensing the input and output load status, coordinating the control of resource usage, and promptly cleaning up invalid data blocks, including waking up the cleanup thread under preset conditions and stopping the cleanup operation at the appropriate time, the system avoids frequent interference with other processes.

Benefits of technology

It effectively ensures the read and write performance of the storage medium, reduces the time spent cleaning up invalid data blocks, avoids application unresponsiveness (ANR), and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122308738A_ABST
    Figure CN122308738A_ABST
Patent Text Reader

Abstract

This application provides a storage cleanup method, apparatus, device, storage medium, and program product. The method includes: acquiring the input / output load status of the storage medium; determining the ratio of invalid data blocks to available data blocks in the storage medium when the input / output load status meets preset conditions; and cleaning up invalid data blocks in the storage medium based on the ratio of invalid data blocks to available data blocks. This ensures the read / write performance of the storage medium while promptly cleaning up invalid data blocks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a storage cleanup method, apparatus, device, storage medium, and program product. Background Technology

[0002] During the use of electronic devices containing storage media, when a file system deletes data, it only marks the physical block containing the data as an invalid data block, without actually erasing the data within the block. With prolonged use, invalid data blocks accumulate in the storage medium, causing data fragmentation and directly leading to a decline in the read / write performance of the storage medium.

[0003] Therefore, how to clean up invalid data blocks while ensuring the read and write performance of the storage medium is an urgent technical problem that needs to be solved. Summary of the Invention

[0004] The storage cleanup method, apparatus, device, storage medium, and program product provided in this application can clean up invalid data blocks at appropriate times to ensure the read and write performance of the storage medium.

[0005] In a first aspect, embodiments of this application provide a storage cleanup method applied in an electronic device, the electronic device including a storage medium, the method comprising:

[0006] Obtain the input / output load status of the storage medium;

[0007] When the input / output load state meets preset conditions, determine the ratio of invalid data blocks to available data blocks in the storage medium;

[0008] Based on the ratio of invalid data blocks to available data blocks, invalid data blocks in the storage medium are cleaned up.

[0009] In one possible implementation, the input / output load state satisfies preset conditions, including:

[0010] The sum of the number of first output requests and the number of first input requests is greater than a first preset threshold;

[0011] Wherein, the first output request is an output request whose processing time is within a preset time range, and the first input request is an input request whose processing time is within a preset time range.

[0012] In one possible implementation, determining the ratio of invalid data blocks to available data blocks in the storage medium when the input / output load state meets preset conditions includes:

[0013] If the sum of the number of the first output requests and the number of the first input requests is greater than the first preset threshold, add a cleanup execution task to the work queue;

[0014] During the cleanup task, the ratio of invalid data blocks to available data blocks is determined.

[0015] In one possible implementation, cleaning up invalid data blocks in the storage medium based on the ratio of invalid data blocks to available data blocks includes:

[0016] If the ratio of invalid data blocks to available data blocks is greater than a second preset threshold, a cleanup thread is activated to clean up the invalid data blocks.

[0017] In one possible implementation, during the process of cleaning up the invalid data blocks, the cleaning of the invalid data blocks is stopped after the ratio of invalid data blocks to available data blocks drops below the second preset threshold.

[0018] In one possible implementation, the cleaning of invalid data blocks is stopped after the execution time of the cleanup thread reaches a third preset threshold.

[0019] Secondly, embodiments of this application provide a storage cleanup device applied in an electronic device, the electronic device including a storage medium, the device comprising:

[0020] The acquisition module is used to acquire the input / output load status of the storage medium;

[0021] The determination module is used to determine the ratio of invalid data blocks to available data blocks in the storage medium when the input / output load state meets preset conditions;

[0022] The cleaning module is used to clean up invalid data blocks in the storage medium based on the ratio of invalid data blocks to available data blocks.

[0023] In one possible implementation, the input / output load state satisfies preset conditions, including:

[0024] The sum of the number of first output requests and the number of first input requests is greater than a first preset threshold;

[0025] Wherein, the first output request is an output request whose processing time is within a preset time range, and the first input request is an input request whose processing time is within a preset time range.

[0026] In one possible implementation, the determining module is specifically used for:

[0027] If the sum of the number of the first output requests and the number of the first input requests is greater than the first preset threshold, add a cleanup execution task to the work queue;

[0028] During the cleanup task, the ratio of invalid data blocks to available data blocks is determined.

[0029] In one possible implementation, the cleaning module is specifically used for:

[0030] If the ratio of invalid data blocks to available data blocks is greater than a second preset threshold, a cleanup thread is activated to clean up the invalid data blocks.

[0031] In one possible implementation, the cleaning module is further configured to:

[0032] During the process of cleaning up the invalid data blocks, the cleaning of the invalid data blocks is stopped after the ratio of invalid data blocks to available data blocks drops below the second preset threshold.

[0033] In one possible implementation, the cleaning module is further configured to:

[0034] The cleaning of invalid data blocks stops after the execution time of the cleanup thread reaches a third preset threshold.

[0035] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;

[0036] The memory stores computer-executed instructions;

[0037] The processor executes computer execution instructions stored in the memory, causing the processor to perform the memory cleanup method as described in the first aspect.

[0038] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the storage cleanup method as described in the first aspect.

[0039] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the storage cleanup method described in the first aspect.

[0040] In a sixth aspect, embodiments of this application provide a chip, the chip including at least one processor, the processor being configured to execute program instructions to perform the storage cleanup method described in the first aspect.

[0041] In one possible implementation, the chip is a chip in a chip module.

[0042] The storage cleanup method, apparatus, device, storage medium, and program product provided in this application can promptly clean up invalid data blocks by dynamically sensing the input / output load status and coordinating resource usage control, thus ensuring the read / write performance of the storage medium. Attached Figure Description

[0043] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0044] Figure 1 A schematic flowchart of a storage cleanup method provided in an embodiment of this application;

[0045] Figure 2 Another schematic flowchart of the storage cleanup method provided in the embodiments of this application;

[0046] Figure 3 This is a schematic diagram of the storage cleanup device provided in the embodiments of this application;

[0047] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0048] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0050] The terms "first," "second," etc., used in the embodiments of this application are for illustrative purposes and to distinguish the objects being described. They do not indicate any order or limit on the number of objects in the embodiments of this application, and cannot constitute any limitation on the embodiments of this application. For example, the use of terms such as "first preset threshold" and "second preset threshold" is only to distinguish different preset thresholds, and does not indicate any difference in the size, priority, or importance of these two preset thresholds.

[0051] It should be further understood that the terms "comprising" or "including" indicate the presence of the aforementioned features, steps, operations, elements, components, types, and / or groups, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, types, and / or groups.

[0052] In this application, terms such as "exemplary," "in some embodiments," and "in other embodiments" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Rather, the term "exemplary" is used to present the concept in a specific manner.

[0053] It should be understood that although the steps in the flowcharts of this application's embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include at least one sub-step or at least one stage. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.

[0054] The technical solutions of this application are applicable to electronic devices that include storage media. These electronic devices include mobile phones, tablets, laptops, smart wearable devices, IoT terminals, servers, etc. The storage media can be flash memory devices that support discard functionality, such as devices using the embedded Multi Media Card (eMMC) protocol, devices using the Universal Flash Storage (UFS) protocol, solid state disks (SSDs), etc. This application does not limit the scope of these devices.

[0055] In related technologies, the cleanup operation for invalid data blocks is typically triggered only when the system is in a strictly idle state, such as when there have been no write operations for 5 seconds. In scenarios where the device is continuously used, the cleanup operation may never be triggered, leading to a continuous accumulation of invalid data blocks. When the remaining space on the storage medium is low, read and write performance will significantly decrease. Furthermore, when the cleanup operation is triggered, if the accumulated amount of invalid data blocks is large, the execution time will be long. A prolonged cleanup operation can compete for system resources with input / output requests from other processes, easily causing application not responding (ANR), severely impacting user experience.

[0056] To address the aforementioned technical issues, the storage cleanup method provided in this application, through dynamic sensing of input / output load status and coordinated control of resource usage, can promptly clean up invalid data blocks, ensuring the read / write performance of the storage medium. Furthermore, timely cleanup of invalid data blocks effectively reduces the time required for cleanup, preventing system resources from being contested by input / output requests from other processes, thereby avoiding ANR (Application Not Responding) and improving user experience.

[0057] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0058] Figure 1 This is a schematic flowchart of a storage cleanup method provided in an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:

[0059] S101. Obtain the input / output load status of the storage medium.

[0060] The execution subject of this application embodiment can be an electronic device, a chip, or a chip module, or it can be a storage cleaning device installed in an electronic device, a chip, or a chip module. The storage cleaning device can be implemented by software or by a combination of software and hardware.

[0061] The input / output load status of a storage medium reflects how busy the storage medium is in processing input and output requests and its own performance status over a period of time.

[0062] Electronic devices use their own preset input / output (IO) statistics functions to monitor the input / output operations of their storage media in real time, and to collect statistics on the input / output load status of the storage media.

[0063] Specifically, the input / output statistics function continuously records the processing time of all input and output requests on the storage medium within a preset time period, and counts the number of requests in different processing time intervals.

[0064] For example, the statistical function for input and output can be _io_print_info; the preset time period can be 10 seconds (s); this application does not impose any restrictions on this.

[0065] In this embodiment, an input request refers to a read data request sent by the electronic device to the storage medium, that is, the operation of the storage medium transferring data at a specified address to the electronic device's processor or memory. An output request refers to a write data request sent by the electronic device to the storage medium, that is, the operation of the electronic device's processor or memory storing data at a specified physical address on the storage medium.

[0066] S102. When the input and output load conditions meet the preset conditions, determine the ratio of invalid data blocks to available data blocks in the storage medium.

[0067] An invalid data block refers to a physical block in the storage medium that is marked as erasable and contains no valid data.

[0068] Available data blocks refer to physical blocks in the storage medium that can be used to store data.

[0069] In one possible implementation, the input / output load state satisfying the preset condition may include: the sum of the number of first output requests and the number of first input requests is greater than a first preset threshold; wherein, the first output request is an output request whose processing time is within a preset time period and the first input request is an input request whose processing time is within a preset time period and the processing time is within a preset time period.

[0070] For example, the preset duration range can be 32-64 milliseconds (ms), and this application does not impose any restrictions on this. The electronic device can use the internal structure info->opinfo_bak[0].op_i2c[3] to count the number of first input requests to the storage medium with a processing time of 32-64ms within 10s, and use the structure info->opinfo_bak[1].op_i2c[3] to count the number of first output requests to the storage medium with a processing time of 32-64ms within 10s.

[0071] The first preset threshold can be calibrated through multiple experiments, and its value can be flexibly adjusted according to the type and performance of the storage medium. The core purpose of setting the first preset threshold is to ensure that the cleanup operation is not frequently triggered, so as to avoid interfering with the normal input / output operation of the storage medium and the normal operation of electronic devices.

[0072] The first output request and the first input request can also be called slow requests; the preset conditions can also be called the trigger conditions for the cleanup operation or the load conditions, and this application does not limit them.

[0073] The above content explains that when the number of slow requests to the storage medium accumulates to a certain level, it indicates that the storage medium has experienced a performance decline due to fragmentation of invalid data blocks, and at this point, it is necessary to trigger the subsequent cleanup process.

[0074] If the input / output load status of the storage medium does not meet the preset conditions, it indicates that the performance of the storage medium has not significantly degraded, and there is no need to trigger a cleanup operation. In this case, the input / output load status of the storage medium can be monitored until it meets the preset conditions, at which point a cleanup operation can be triggered.

[0075] In another implementation, the judgment details can be finely adjusted. For example, the input / output load state of the storage medium meeting the preset conditions may mean that the sum of the number of first output requests and the number of first input requests is greater than or equal to a first preset threshold; the input / output load state of the storage medium not meeting the preset conditions may mean that the sum of the number of first output requests and the number of first input requests is less than a first preset threshold.

[0076] S103. Based on the ratio of invalid data blocks to available data blocks, clean up invalid data blocks in the storage medium.

[0077] The system can determine whether a cleanup operation is needed based on the ratio of invalid data blocks to available data blocks. Specifically, if the ratio of invalid data blocks to available data blocks is greater than a second preset threshold, a cleanup thread is activated to clean up the invalid data blocks in the storage medium; if the ratio of invalid data blocks to available data blocks is less than or equal to the second preset threshold, the operation can be terminated.

[0078] For example, the second preset threshold can be 20%. That is, when the proportion of invalid data blocks to available data blocks in the storage medium reaches 20%, it indicates that the accumulated amount of invalid data blocks has significantly impacted storage performance, requiring cleanup. If the proportion of invalid data blocks to available data blocks in the storage medium does not reach 20%, it indicates that the amount of invalid data blocks is small and does not require immediate cleanup, thus avoiding unnecessary consumption of electronic device system resources. It should be noted that the second preset threshold can be set according to actual conditions, and this application does not limit the specific value of the second preset threshold.

[0079] In another implementation, the judgment details can be finely adjusted. For example, if the ratio of invalid data blocks to available data blocks is greater than or equal to a second preset threshold, the cleanup thread is woken up to clean up the invalid data blocks in the storage medium; if the ratio of invalid data blocks to available data blocks is less than the second preset threshold, the operation can be terminated.

[0080] exist Figure 1 In the illustrated embodiment, by dynamically sensing the input / output load status and coordinating resource usage control, invalid data blocks can be cleaned up in a timely manner, ensuring the read / write performance of the storage medium. Furthermore, timely cleanup of invalid data blocks effectively reduces the time required for cleanup, preventing system resources from being contested by input / output requests from other processes, thereby avoiding ANR (Application Not Responding) and improving user experience. Additionally, this application only performs cleanup operations when preset conditions and resource usage ratios are met, avoiding frequent cleanup operations that could affect the operation of other threads.

[0081] Figure 2 This is another schematic flowchart illustrating the storage cleanup method provided in the embodiments of this application, as follows: Figure 2 As shown, the method includes the following steps:

[0082] S201. Obtain the input / output load status of the storage medium.

[0083] It should be noted that the execution process of S201 can be referred to the execution process of S101, and will not be repeated here.

[0084] S202. Determine whether the sum of the number of first output requests and the number of first input requests is greater than a first preset threshold.

[0085] If the sum of the number of first output requests and the number of first input requests is greater than a first preset threshold, execute S203.

[0086] If the sum of the number of first output requests and the number of first input requests is less than or equal to a first preset threshold, the operation ends.

[0087] In another implementation, the judgment details can be finely adjusted, such as determining whether the sum of the number of first output requests and the number of first input requests is greater than or equal to a first preset threshold. If the sum of the number of first output requests and the number of first input requests is greater than or equal to the first preset threshold, S203 is executed; if the sum of the number of first output requests and the number of first input requests is less than the first preset threshold, the operation ends.

[0088] S203. Determine the ratio of invalid data blocks to available data blocks in the storage medium.

[0089] In one possible implementation, if the sum of the number of first output requests and the number of first input requests is greater than a first preset threshold, a cleanup execution task is added to the work queue; during the execution of the cleanup execution task, the ratio of invalid data blocks to available data blocks is determined.

[0090] That is, when the sum of the number of the first output requests and the number of the first input requests is greater than the first preset threshold, the electronic device starts the cleanup preparation process, which is as follows: the electronic device adds a cleanup execution task to its own work queue and wakes up its own worker thread to process the cleanup execution task; during the execution of the cleanup execution task, the worker thread uses the electronic device's preset ratio calculation logic to count the total number of invalid data blocks and the total number of available data blocks in the storage medium, and then calculates the ratio of invalid data blocks to available data blocks.

[0091] For example, the electronic device adds the cleanup task to its own unbound work queue system_unbound_wq, and the kworker thread of this queue performs the subsequent proportion calculation and cleanup triggering operation. The asynchronous task approach avoids the blocking of electronic device system resources caused by synchronous execution.

[0092] S204. Determine whether the ratio of invalid data blocks to available data blocks is greater than the second preset threshold.

[0093] If the ratio of invalid data blocks to available data blocks is greater than the second preset threshold, execute S205.

[0094] If the ratio of invalid data blocks to available data blocks is less than or equal to the second preset threshold, the operation will be stopped.

[0095] In another implementation, the judgment details can be finely adjusted, such as determining whether the ratio of invalid data blocks to available data blocks is greater than or equal to a second preset threshold. If the ratio of invalid data blocks to available data blocks is greater than or equal to the second preset threshold, step S205 is executed; if the ratio of invalid data blocks to available data blocks is less than the second preset threshold, the operation can be terminated.

[0096] S205. Wake up the cleanup thread to clean up invalid data blocks in the storage medium.

[0097] In one possible implementation, during the process of cleaning up invalid data blocks, the cleaning of invalid data blocks in the storage medium is stopped after the ratio of invalid data blocks to available data blocks drops below a second preset threshold. This prevents the cleaning operation from running for an extended period and affecting the read and write operations of other threads.

[0098] In another possible implementation, the cleanup of invalid data blocks is stopped after the execution time of the cleanup thread reaches or exceeds a third preset threshold. This prevents the cleanup operation from running for an extended period and affecting the read and write operations of other threads.

[0099] For example, the third preset threshold can be 2s, but this application does not impose any restrictions on it.

[0100] exist Figure 2 In the illustrated embodiment, by dynamically sensing the input / output load status and coordinating resource usage control, invalid data blocks can be cleaned up in a timely manner, ensuring the read / write performance of the storage medium. Furthermore, timely cleanup of invalid data blocks effectively reduces the time required for cleanup, preventing system resources from being contested by input / output requests from other processes, thereby avoiding ANR (Application Not Responding) and improving user experience. Additionally, this application only performs cleanup operations when preset conditions and resource usage ratios are met, avoiding frequent cleanup operations that could affect the operation of other threads.

[0101] Figure 3 This is a schematic diagram of the storage cleanup device provided in the embodiments of this application, as shown below. Figure 3 As shown, the storage device 10 provided in this embodiment includes:

[0102] The acquisition module 11 is used to acquire the input and output load status of the storage medium;

[0103] The determination module 12 is used to determine the ratio of invalid data blocks to available data blocks in the storage medium when the input and output load states meet preset conditions;

[0104] Cleanup module 13 is used to clean up invalid data blocks in the storage medium based on the ratio of invalid data blocks to available data blocks.

[0105] In one possible implementation, the input / output load state satisfies preset conditions, including:

[0106] The sum of the number of first output requests and the number of first input requests is greater than a first preset threshold;

[0107] The first output request is an output request whose processing time is within a preset time range, and the first input request is an input request whose processing time is within a preset time range.

[0108] In one possible implementation, the determining module 12 is specifically used for:

[0109] If the sum of the number of first output requests and the number of first input requests exceeds a first preset threshold, add a cleanup execution task to the work queue.

[0110] During the cleanup process, the ratio of invalid data blocks to available data blocks is determined.

[0111] In one possible implementation, the cleaning module 13 is specifically used for:

[0112] If the ratio of invalid data blocks to available data blocks exceeds a second preset threshold, a cleanup thread is woken up to clean up the invalid data blocks.

[0113] In one possible implementation, the cleaning module 13 is further configured to:

[0114] During the process of cleaning up invalid data blocks, the cleaning of invalid data blocks will stop once the ratio of invalid data blocks to available data blocks drops below a second preset threshold.

[0115] In one possible implementation, the cleaning module 13 is further configured to:

[0116] After the execution time of the cleanup thread reaches the third preset threshold, the cleanup of invalid data blocks will stop.

[0117] The storage cleanup device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0118] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 20 includes a transceiver 21, a memory 22, and a processor 23. The transceiver 21 may include a transmitter and / or a receiver. The transmitter may also be referred to as a transmitter, transmitter port, or transmitter interface, etc., and the receiver may also be referred to as a receiver, receiver port, or receiver interface, etc. Exemplarily, the transceiver 21, memory 22, and processor 23 are interconnected via a bus 24.

[0119] Memory 22 is used to store program instructions;

[0120] The processor 23 is used to execute the program instructions stored in the memory, so that the electronic device performs any of the memory cleanup methods shown above.

[0121] Transceiver 21 is used to perform the sending and receiving functions of electronic devices.

[0122] In one possible implementation, the memory 22 can be the storage medium described above.

[0123] Electronic devices can include chips, modules, integrated development environments (IDEs), etc.

[0124] Figure 4 The electronic device shown in the embodiments can execute the technical solutions shown in the above method embodiments. Its implementation principle and beneficial effects are similar, and will not be repeated here.

[0125] This application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement any of the above-mentioned storage cleanup methods.

[0126] This application provides a computer program product, including a computer program that, when executed by a processor, can implement any of the above-described storage cleanup methods.

[0127] This application provides a chip on which a computer program is stored. When the computer program is executed by the chip, it implements the above-described storage cleanup method.

[0128] In one possible implementation, the chip is a chip in a chip module.

[0129] The computer-readable storage medium and computer program product of the present application embodiments can execute the technical solutions shown in the above-described storage cleanup method embodiments. Their implementation principles and beneficial effects are similar and will not be described again here.

[0130] All or part of the steps in the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, it performs the steps of the above-described method embodiments; and the aforementioned memory (storage medium) includes: read-only memory (ROM), random access memory (RAM), flash memory, hard disk, solid-state drive, magnetic tape, floppy disk, optical disc, and any combination thereof.

[0131] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.

[0132] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0133] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0134] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims of this application and their equivalents, this application also intends to include these modifications and variations.

Claims

1. A storage cleanup method, characterized in that, Applied in an electronic device, the electronic device including a storage medium, the method includes: Obtain the input / output load status of the storage medium; When the input / output load state meets preset conditions, determine the ratio of invalid data blocks to available data blocks in the storage medium; Based on the ratio of invalid data blocks to available data blocks, invalid data blocks in the storage medium are cleaned up.

2. The method according to claim 1, characterized in that, The input / output load state meets preset conditions, including: The sum of the number of first output requests and the number of first input requests is greater than a first preset threshold; Wherein, the first output request is an output request whose processing time is within a preset time range, and the first input request is an input request whose processing time is within a preset time range.

3. The method according to claim 2, characterized in that, Determining the ratio of invalid data blocks to available data blocks in the storage medium when the input / output load state meets preset conditions includes: If the sum of the number of the first output requests and the number of the first input requests is greater than the first preset threshold, add a cleanup execution task to the work queue; During the cleanup task, the ratio of invalid data blocks to available data blocks is determined.

4. The method according to claim 3, characterized in that, The process of cleaning up invalid data blocks in the storage medium based on the ratio of invalid data blocks to available data blocks includes: If the ratio of invalid data blocks to available data blocks is greater than a second preset threshold, a cleanup thread is activated to clean up the invalid data blocks.

5. The method according to claim 4, characterized in that, During the process of cleaning up the invalid data blocks, the cleaning of the invalid data blocks is stopped after the ratio of invalid data blocks to available data blocks drops below the second preset threshold.

6. The method according to claim 4, characterized in that, The cleaning of invalid data blocks stops after the execution time of the cleanup thread reaches a third preset threshold.

7. A storage cleaning device, characterized in that, Applied in an electronic device, the electronic device including a storage medium, the device includes: The acquisition module is used to acquire the input / output load status of the storage medium; The determination module is used to determine the ratio of invalid data blocks to available data blocks in the storage medium when the input / output load state meets preset conditions; The cleaning module is used to clean up invalid data blocks in the storage medium based on the ratio of invalid data blocks to available data blocks.

8. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.

10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-6.