A file deletion method and related device

By creating index files in the storage medium and automatically deleting files when the threshold is reached, the storage abnormality caused by the continuous increase in the storage pool water level is solved, and storage space management is achieved without cost-effectively increased.

CN115114245BActive Publication Date: 2025-09-02JINAN INSPUR DATA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210867237.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-22
Publication Date
2025-09-02
Estimated Expiration
2042-07-22

AI Technical Summary

Technical Problem

In the prior art, the water level of the storage pool continues to increase, resulting in full storage space, which may cause abnormalities in the storage system and business interruptions, and the expansion of the storage pool increases procurement costs, while manual data deletion is inefficient.

Method used

By pre-creating the index file, storing the index information of the deleted file, monitoring the storage medium footprint, and automatically deleting the files corresponding to the index information when the threshold is reached, realizing automated file deletion based on preset policies.

Benefits of technology

It effectively avoids the storage data failure problem caused by the full storage pool, while avoiding the increase in additional costs and improving the efficiency of storage space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115114245B_ABST
    Figure CN115114245B_ABST
Patent Text Reader

Abstract

This application discloses a file deletion method, comprising: obtaining the occupied space of a target storage medium; when the occupied space reaches a preset threshold, reading index information from a preset index file, wherein the index information is the index information of deletable files in the target storage medium; and deleting the deletable files corresponding to the index information from the target storage medium. By applying the technical solution provided by this application, the problem of storage data failure caused by a full storage pool can be effectively avoided without incurring additional costs. This application also discloses a file deletion device, an electronic device, and a computer-readable storage medium, which also have the above-mentioned beneficial effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of storage systems, and in particular to a file deletion method, and also to a file deletion device, an electronic device, and a computer-readable storage medium. Background Art

[0002] Ceph is a system that provides distributed storage services to external cloud platforms. Based on Ceph, it can provide the platform with distributed storage services such as object storage services, block storage services, and file system storage services.

[0003] The most basic unit of a distributed storage system is the disk, where all business data is stored. Redundancy algorithms can be used to combine the disks on multiple storage nodes into a storage pool, providing secure and reliable storage services. Based on the redundancy strategy, each piece of data is redundant. For example, if the redundancy strategy is 3 copies, each piece of data will be replicated three times and stored in the storage pool. Obviously, when business operations run for a long time, the storage pool's water level will continue to rise. Once the storage pool water level exceeds a certain value, storage system anomalies may occur due to storage space limitations, leading to business interruptions.

[0004] To reduce the number of underlying data objects and address the issue of ever-increasing storage pool capacity, existing approaches to distributed storage are to expand the storage pool to increase capacity or to manually delete unnecessary data to reduce capacity. However, expanding the storage pool requires adding nodes, which inevitably increases procurement costs, while manually deleting data also requires increased time and effort to traverse the data, resulting in low efficiency.

[0005] Therefore, how to effectively avoid the problem of storage data failure caused by the storage pool being full without increasing additional costs is an urgent problem to be solved by those skilled in the art. Summary of the Invention

[0006] The purpose of this application is to provide a file deletion method, which can effectively avoid the problem of storage data failure caused by the storage pool being full without incurring additional costs; another purpose of this application is to provide a file deletion device, electronic device and computer-readable storage medium, all of which have the above-mentioned beneficial effects.

[0007] In a first aspect, the present application provides a file deletion method, comprising:

[0008] Get the occupied space of the target storage medium;

[0009] When the occupied space reaches a preset threshold, index information is read from a preset index file, where the index information is index information of the deletable files in the target storage medium;

[0010] The deletable file corresponding to the index information is deleted from the target storage medium.

[0011] Optionally, deleting the deletable file corresponding to the index information from the target storage medium includes:

[0012] Determining whether the deletable file corresponding to the index information is in an accessed state;

[0013] If not, the step of deleting the deletable file corresponding to the index information from the target storage medium is performed.

[0014] Optionally, after deleting the deletable file corresponding to the index information from the target storage medium, the method further includes:

[0015] The index information is deleted from the preset index file.

[0016] Optionally, after deleting the deletable file corresponding to the index information from the target storage medium, the method further includes:

[0017] Performing resource statistics on the target storage medium to obtain resource statistics results;

[0018] Determine the file deletion result according to the resource statistics result;

[0019] When the file deletion result is deletion failure, determining to delete the failed file;

[0020] Perform a deduplication operation on the file that failed to be deleted.

[0021] Optionally, the resource statistical result includes a file creation time of the deleted file, and determining the file deletion result according to the resource statistical result includes:

[0022] Reading the corresponding file creation time in the preset index file according to the index information of the deleted file;

[0023] When the file creation time in the resource statistical result is inconsistent with the read file creation time, it is determined that the file deletion result is deletion failure.

[0024] Optionally, the process of creating the preset index file includes:

[0025] Create a blank index file;

[0026] When a file write operation is detected, the file parameters of the written file are obtained;

[0027] When the file parameters meet the preset parameters, creating index information for the written file;

[0028] The index information is written into the blank index file to generate the preset index file.

[0029] Optionally, the file parameters include one or more of a file name, a wildcard, a file size, and a file creation time.

[0030] In a second aspect, the present application further discloses a file deletion device, comprising:

[0031] An acquisition module, used to obtain the occupied space of the target storage medium;

[0032] a reading module, configured to read index information from a preset index file when the occupied space reaches a preset threshold, the index information being index information of deletable files in the target storage medium;

[0033] The deleting module is used to delete the deletable file corresponding to the index information from the target storage medium.

[0034] In a third aspect, the present application further discloses an electronic device, comprising:

[0035] memory for storing computer programs;

[0036] A processor is configured to implement the steps of any one of the file deletion methods described above when executing the computer program.

[0037] In a fourth aspect, the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the file deletion methods described above are implemented.

[0038] A file deletion method provided in the present application includes obtaining the occupied space of a target storage medium; when the occupied space reaches a preset threshold, reading index information from a preset index file, wherein the index information is the index information of the deletable files in the target storage medium; and deleting the deletable files corresponding to the index information from the target storage medium.

[0039] By applying the technical solution provided in the present application, an index file is created in advance to store the index information of the deletable files in the target storage medium. During the use of the target storage medium, its occupied space is monitored. When the occupied space reaches the upper limit, the deletable files corresponding to the index information in the index file can be directly deleted from the target storage medium, thereby realizing automatic deletion based on the preset file deletion policy, so that the occupied space of the target storage medium is kept below the preset threshold, thereby effectively avoiding the problem of storage data failure caused by the storage pool being full; in addition, compared with the method of expanding the capacity of the target storage medium or manually deleting it in the related art, this implementation method does not increase any other additional costs.

[0040] The file deletion device, electronic device, and computer-readable storage medium provided in this application all have the above-mentioned beneficial effects, which will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the prior art and the embodiments of the present application, the following is a brief introduction to the drawings required for describing the prior art and the embodiments of the present application. Of course, the drawings described below in connection with the embodiments of the present application are only part of the embodiments of the present application. For those skilled in the art, other drawings can be obtained based on the provided drawings without inventive effort, and the obtained other drawings also fall within the scope of protection of the present application.

[0042] Figure 1 A flowchart of a file deletion method provided by this application;

[0043] Figure 2 A schematic diagram of the structure of a file deletion device provided by this application;

[0044] Figure 3 This is a schematic structural diagram of an electronic device provided in this application. DETAILED DESCRIPTION

[0045] The core of this application is to provide a file deletion method, which can effectively avoid the problem of storage data failure caused by the storage pool being full without incurring additional costs; another core of this application is to provide a file deletion device, electronic device and computer-readable storage medium, which also have the above-mentioned beneficial effects.

[0046] In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0047] For storage systems, when services run for extended periods, the water level in the storage pool continues to rise. Once the water level exceeds a certain value, storage system anomalies are likely to occur due to storage space limitations, leading to service interruptions. Traditionally, storage pool capacity has been increased by expanding the capacity of the storage pool, or by users manually deleting no longer needed data to reduce the capacity. However, expanding the capacity of the storage pool requires adding nodes, which inevitably increases procurement costs. Manually deleting data also requires increased time and effort to traverse the data, resulting in low efficiency.

[0048] It is understandable that in actual production, although front-end business data is continuously updated for a long time, some user data may be temporary files or one-time files. Subsequent users will no longer use these files, but they have not been deleted. These residual files will occupy storage pool space, reducing the valid data that users can write to the storage pool. Therefore, in order to ensure that business data is not interrupted and at the same time ensure that the storage pool is not full and causes blockage or failure, it is possible to delete data that users no longer need, thereby controlling the storage pool water level. Based on this, the present application provides a file deletion method for a storage system, which aims to effectively avoid the problem of storage data failure caused by a full storage pool without adding additional costs.

[0049] An embodiment of the present application provides a method for deleting a file.

[0050] Please refer to Figure 1 , Figure 1 This is a flowchart of a file deletion method provided by the present application. The file deletion method includes the following S101 to S103.

[0051] S101: Obtaining the occupied space of the target storage medium;

[0052] This step is intended to achieve the acquisition of occupied space in the target storage medium. The target storage medium is the storage medium on which files need to be deleted. Its specific type does not affect the implementation of this technical solution. For example, it can be a created cache space, a physical storage device, etc., and the file deletion method provided by the embodiment of this application can be used to avoid the problem of storage data timeliness caused by the storage space being full. The occupied space is the size of the space that has been occupied in the target storage medium, and its role is to determine whether it is necessary to perform a file deletion operation on the target storage medium based on the occupied space. During the implementation process, the target storage medium can be monitored in real time to obtain the occupied space statistics.

[0053] S102: When the occupied space reaches a preset threshold, index information is read from a preset index file, where the index information is index information of deletable files in the target storage medium;

[0054] This step is intended to read the index information. In the embodiment of the present application, an index file may be pre-created to store the index information of the deletable files in the target storage medium. The pre-set index file may be implemented in a table format.

[0055] Specifically, for all files stored in the target storage medium, deletable files can be pre-determined. These deletable files are considered useless files that occupy additional storage space, such as temporary files or one-time files generated during business processing. Furthermore, a file index is set for these deletable files in the target storage medium, and index information corresponding to each deletable file is generated and stored in a pre-set index file. Of course, the index information is a unique identifier, and each deletable file corresponds to a unique index information.

[0056] Therefore, when it is detected that the occupied space of the target storage medium reaches the preset threshold, it means that the space occupied by the target storage medium has reached the upper limit. If file storage continues, an abnormality may occur. Therefore, it is necessary to perform a file deletion operation on it. At this time, each index information can be read from the preset index file to facilitate deleting the deletable files corresponding to each index information from the target storage medium. Of course, if the occupied space of the target storage medium does not reach the preset threshold, it means that the space occupied by the target storage medium has not reached the upper limit, and file storage can continue without performing a file deletion operation.

[0057] It is understandable that the specific value of the preset threshold does not affect the implementation of this technical solution and can be set by technical personnel based on the actual performance of the target storage medium. This application does not limit this.

[0058] S103: Deleting the deletable file corresponding to the index information from the target storage medium.

[0059] This step is designed to delete deletable files. After reading the index information from the preset index file, the corresponding deletable files are found on the target storage medium and then deleted from the target storage medium. By deleting some unused deletable files, the target storage medium's occupied space can be reduced to below a preset threshold, thus avoiding data corruption and forced business interruptions.

[0060] It can be seen that the file deletion method provided in the embodiment of the present application pre-creates an index file for storing index information of deletable files in the target storage medium, and monitors the occupied space of the target storage medium during use. When the occupied space reaches the upper limit, the deletable files corresponding to the index information in the index file can be directly deleted from the target storage medium, thereby realizing automatic deletion based on the preset file deletion policy, so that the occupied space of the target storage medium is kept below the preset threshold, thereby effectively avoiding the problem of storage data failure caused by the storage pool being full; in addition, compared with the method of expanding the capacity of the target storage medium or manually deleting it in the related art, this implementation method does not increase any other additional costs.

[0061] In one embodiment of the present application, the above-mentioned deleting of the deletable file corresponding to the index information from the target storage medium may include: determining whether the deletable file corresponding to the index information is in an accessed state; if not, executing the step of deleting the deletable file corresponding to the index information from the target storage medium.

[0062] In an embodiment of the present application, before performing a deletion operation on a deletable file corresponding to the index information, it is possible to first determine whether the deletable file meets some preset deletion conditions. For example, if the deletable file is in an accessed state, at this time, if a deletion operation is performed on it, it will inevitably cause problems with the front-end access service. Therefore, for such deletable files, it can be directly skipped and the deletion operation is not performed on them.

[0063] Therefore, when deleting a deletable file corresponding to the index information from the target storage medium, you can first determine whether the deletable file is in an accessed state. If it is not in an accessed state, you can directly delete the deletable file from the target storage medium; if it is in an accessed state, skip the deletable file and identify the status of the next deleted file corresponding to the index information.

[0064] In one embodiment of the present application, after deleting the deletable file corresponding to the index information from the target storage medium, the method may further include: deleting the index information from a preset index file.

[0065] In an embodiment of the present application, in order to avoid unnecessary space occupation, after deleting the deletable file corresponding to the index information from the target storage medium, the index information can also be deleted from the preset index file to provide sufficient storage space for the index information of the newly entered deletable file.

[0066] In one embodiment of the present application, after deleting the deletable file corresponding to the index information from the target storage medium, the method may also include: performing resource statistics on the target storage medium to obtain resource statistical results; determining the file deletion result based on the resource statistical results; when the file deletion result is a deletion failure, determining the failed file to be deleted; and performing a deduplication operation on the failed file to be deleted.

[0067] In an embodiment of the present application, in order to avoid the problem that the file deletion operation may fail in the future and cause the occupied space of the target storage medium to exceed the preset threshold, after deleting the deletable files corresponding to the index information from the target storage medium, the file deletion results can also be counted to facilitate the deleting operation on the deletable files that failed to be deleted.

[0068] During the implementation process, after the deletable file corresponding to the index information is deleted from the target storage medium, resource statistics can be performed on the target storage medium to obtain resource statistics results. The resource statistics results may include various types of information such as relevant information of the deleted file, the occupied space before the file is deleted, and the occupied space after the file is deleted. Further, after obtaining the resource statistics results, the file deletion result can be determined based on the resource statistics results, that is, whether the file deletion operation is successfully executed. When the file deletion operation is successfully executed, the current file deletion process can be exited. When the file deletion operation fails, the deletion failed file in the target storage medium can be further determined, and a duplicate deletion operation can be performed on it.

[0069] In one embodiment of the present application, the resource statistical result may include the file creation time of the deleted file. The above-mentioned determination of the file deletion result based on the resource statistical result may include: reading the corresponding file creation time in the preset index file according to the index information of the deleted file; when the file creation time in the resource statistical result is inconsistent with the read file creation time, determining that the file deletion result is a deletion failure.

[0070] An embodiment of the present application provides an implementation method for determining a file deletion result based on resource statistics. First, the resource statistics include the file creation information of the deleted file; and the preset index file also stores the file creation time of each deletable file, corresponding to the index information of the deletable file. On this basis, for the same file, the success or failure of the file deletion operation can be determined by judging whether the file creation time in the resource statistics is consistent with the file creation time stored in the preset index file.

[0071] Therefore, after obtaining the resource statistics results, the interface parses the file creation time of the deleted file; further, it reads the file creation time of the deleted file from the preset index file, and determines whether the file creation time in the resource statistics results is consistent with the read file creation time. If they are consistent, it means that the file deletion operation is executed successfully; if they are inconsistent, it means that the file deletion operation fails.

[0072] In one embodiment of the present application, the creation process of the above-mentioned preset index file may include: creating a blank index file; when a file write operation is monitored, obtaining file parameters of the write file; when the file parameters meet the preset parameters, creating index information for the write file; writing the index information into the blank index file to generate a preset index file.

[0073] The embodiment of the present application provides a method for creating a preset index file. During the implementation process, first, a blank index file is created to facilitate storing the index information of a deletable file therein, thereby generating a preset index file; further, the target storage medium is monitored in real time, and once a new file is detected to be written, the file parameters of the written file can be obtained at the same time; then, it is determined whether the file parameters meet the pre-set parameter information. If so, it indicates that the written file is a deletable file. At this time, index information can be set for it and the index information can be written to the blank index file, thereby generating a preset index file; conversely, if the file parameters of the written file do not meet the pre-set parameters, it indicates that the written file is an undeletable file. At this time, there is no need to perform the index information creation operation on it, and the monitoring of the next written file can be continued.

[0074] Among them, the specific type of file parameters does not affect the implementation of this technical solution and can be set by technical personnel according to actual needs. For example, in one possible implementation method, the above-mentioned file parameters may include one or more of file name, wildcard, file size, and file creation time.

[0075] The embodiments of this application provide several specific types of file parameters, including but not limited to file name, wildcard, file size, and file creation time. Technicians can customize and select these parameters based on actual needs. Of course, the corresponding preset parameters for different types of file parameters may also be different, but they can all be customized by technicians. For example, you can set written files with a file size less than a preset size as deletable files, or you can set written files with a file creation time exceeding a preset time as deletable files, etc. This application does not limit this.

[0076] On the basis of the above embodiments, the embodiment of the present application takes the target storage medium as OSD (Object Storage Device) as an example to provide another file deletion method.

[0077] In the file deletion method provided in the embodiment of the present application, the configuration of the file deletion and water level maintenance policies can be implemented through management software. The MDS (Metadata Server) scans the files to be deleted according to the deletion and water level policy configurations, sends them in batches to the backend, and reads the file data through the backend and deletes them from the OSD. The three parts are specifically implemented as follows:

[0078] 1. Configuration file deletion and water level maintenance strategy:

[0079] (1) Storage pool: Select the storage pool where files need to be deleted;

[0080] (2) Directory: Select the directory where you want to delete files;

[0081] (3) Match file name: supports deleting data based on specific file names and wildcards;

[0082] (4) Match file size: support deleting data based on file size;

[0083] (5) Match file creation time: support deleting data based on file creation time;

[0084] (6) Water level: When the set water level (preset threshold) is exceeded, the system starts deleting files that meet the policy requirements.

[0085] 2. MDS file deletion scan management:

[0086] (1) Create a blank index table;

[0087] (2) Manage the index table: When the front-end business writes data, the file index that meets the file deletion policy is added to the index table. When the storage pool water level reaches the set value, the file deletion operation is triggered, and the corresponding file index is deleted from the index table;

[0088] (3) Scan the index table: According to the above strategy, the index table is scanned periodically to determine whether the corresponding files meet the deletion conditions. The files that meet the deletion conditions are added to the deletion task. Each deletion task includes the index information of 32 files by default, and then the task is sent to the backend.

[0089] 3. Backend delete file implementation:

[0090] (1) The backend parses the task data sent by the MDS, obtains the index information of the file to be deleted, reads all the file indexes in the task in a loop, releases resources and performs statistics on the corresponding files, and deletes the actual data from the OSD;

[0091] (2) When the data in the task is processed, the backend updates the file deletion result to MDS, such as deletion success or deletion failure, and then the backend process exits.

[0092] 4. Lib adaptation processing:

[0093] (1) For files that meet the deletion policy and are being accessed by the front-end business, they are marked and not sent to the MDS or added to the index table;

[0094] (2) For front-end stock data that does not perform metadata IO operations, even if the deletion policy is met, it will not be added to the index table and the deletion operation will not be performed.

[0095] Based on the above settings, the implementation process of the file deletion method may include:

[0096] 1. Manage software settings for file deletion and water level maintenance strategies:

[0097] (1) Input specific policy models into the management interface;

[0098] (2) Connect the model to the underlying Ceph interface.

[0099] 2. MDS processing flow:

[0100] (1) Receive the setting parameters input by the management software and save the parameters;

[0101] (2) Call the create function to create the index table and follow the Map<key,vec> How to store data;

[0102] (3) User access to data triggers a response interrupt, files are processed cyclically according to the file deletion policy, and a task (including 32 file indexes) is created and packaged and sent to the backend for processing;

[0103] (4) Receive the return from backend and clean up the failed tasks.

[0104] 3. Backend processing flow:

[0105] (1) Backend obtains the deletion task sent by MDS

[0106] (2) Call the get_obj function to obtain the object obj. The get_obj function obtains all file indexes in the task, and then calls delete_obj to clear the data corresponding to the file index in the OSD to release resources;

[0107] (3) After all tasks are processed, call reply_delete_success_files_num to perform resource statistics, such as deleted file information, undeleted file information, storage capacity changes, etc.

[0108] (4) MDS determines whether the btime (file creation time) in the message statistics information is consistent with the btime in the index table. If they are consistent, the index table is updated. If they are inconsistent, a deletion failure prompt is returned and the failed index information is recycled and cleared.

[0109] It can be seen that the file deletion method provided in the embodiment of the present application pre-creates an index file for storing index information of deletable files in the target storage medium, and monitors the occupied space of the target storage medium during use. When the occupied space reaches the upper limit, the deletable files corresponding to the index information in the index file can be directly deleted from the target storage medium, thereby realizing automatic deletion based on the preset file deletion policy, so that the occupied space of the target storage medium is kept below the preset threshold, thereby effectively avoiding the problem of storage data failure caused by the storage pool being full; in addition, compared with the method of expanding the capacity of the target storage medium or manually deleting it in the related art, this implementation method does not increase any other additional costs.

[0110] An embodiment of the present application provides a file deletion device.

[0111] Please refer to Figure 2 , Figure 2 This is a schematic diagram of the structure of a file deletion device provided by this application. The file deletion device may include:

[0112] Acquisition module 1, used to obtain the occupied space of the target storage medium;

[0113] Reading module 2, used for reading index information from a preset index file when the occupied space reaches a preset threshold, the index information being index information of the deletable files in the target storage medium;

[0114] The deletion module 3 is configured to delete the deletable file corresponding to the index information from the target storage medium.

[0115] It can be seen that the file deletion device provided in the embodiment of the present application pre-creates an index file for storing index information of deletable files in the target storage medium, and monitors the occupied space of the target storage medium during use. When the occupied space reaches the upper limit, the deletable files corresponding to the index information in the index file can be directly deleted from the target storage medium, thereby realizing automatic deletion based on the preset file deletion policy, so that the occupied space of the target storage medium is kept below the preset threshold, thereby effectively avoiding the problem of storage data failure caused by the storage pool being full; in addition, compared with the method of expanding the capacity of the target storage medium or manually deleting it in the related art, this implementation method does not increase any other additional costs.

[0116] In one embodiment of the present application, the reading module 2 may be specifically configured to determine whether the deletable file corresponding to the index information is in an accessed state; if not, the step of deleting the deletable file corresponding to the index information from the target storage medium is executed.

[0117] In one embodiment of the present application, the file deletion device may further include an index deletion module, configured to delete the index information from a preset index file after deleting the deletable file corresponding to the index information from the target storage medium.

[0118] In one embodiment of the present application, the file deletion device may further include a file deduplication module, which is used to perform resource statistics on the target storage medium to obtain resource statistics results after deleting the deletable file corresponding to the index information from the target storage medium; determine the file deletion result based on the resource statistics results; when the file deletion result is a deletion failure, determine the deletion failure file; and perform a deduplication operation on the deletion failure file.

[0119] In one embodiment of the present application, the resource statistics result may include the file creation time of the deleted file, and the above-mentioned file deduplication module can be specifically used to read the corresponding file creation time in the preset index file according to the index information of the deleted file; when the file creation time in the resource statistics result is inconsistent with the read file creation time, the file deletion result is determined to be deletion failure.

[0120] In one embodiment of the present application, the file deletion device may also include an index file creation module for creating a blank index file; when a file write operation is monitored, obtaining file parameters of the write file; when the file parameters meet preset parameters, creating index information for the write file; writing the index information into the blank index file to generate a preset index file.

[0121] In one embodiment of the present application, the above-mentioned file parameters may include one or more of the following: file name, wildcard, file size, and file creation time.

[0122] For an introduction to the apparatus provided in the embodiments of this application, please refer to the above method embodiments, which will not be elaborated in this application.

[0123] An embodiment of the present application provides an electronic device.

[0124] Please refer to Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in this application, which may include:

[0125] memory for storing computer programs;

[0126] A processor, configured to implement the steps of any of the above-mentioned file deletion methods when executing a computer program.

[0127] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device, which may include a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, the memory 11, and the communication interface 12 communicate with each other via the communication bus 13.

[0128] In the embodiment of the present application, the processor 10 may be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field programmable gate array, or other programmable logic devices.

[0129] The processor 10 may call a program stored in the memory 11 . Specifically, the processor 10 may execute the operations in the embodiment of the file deletion method.

[0130] The memory 11 is used to store one or more programs. The program may include program code, and the program code includes computer operating instructions. In the embodiment of the present application, the memory 11 stores at least a program for implementing the following functions:

[0131] Get the occupied space of the target storage medium;

[0132] When the occupied space reaches a preset threshold, index information is read from a preset index file, where the index information is the index information of the deletable files in the target storage medium;

[0133] Delete the deletable file corresponding to the index information from the target storage medium.

[0134] In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.

[0135] In addition, the memory 11 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.

[0136] The communication interface 12 may be an interface of a communication module, and is used to connect to other devices or systems.

[0137] Of course, it needs to be explained that Figure 3 The structure shown does not constitute a limitation on the electronic device in the embodiment of the present application. In actual applications, the electronic device may include Figure 3 More or fewer components than shown, or combinations of certain components.

[0138] An embodiment of the present application provides a computer-readable storage medium.

[0139] The computer-readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned file deletion methods can be implemented.

[0140] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes.

[0141] For an introduction to the computer-readable storage medium provided in the embodiments of the present application, please refer to the above method embodiments, and this application will not elaborate on them here.

[0142] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0143] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0144] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0145] The technical solution provided by the present application is described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core ideas of the present application. It should be noted that, for those skilled in the art, without departing from the principles of the present application, several improvements and modifications may be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.

Claims

1. A file deletion method, characterized in that: include: Get the occupied space of the target storage medium; When the occupied space reaches a preset threshold, index information is read from a preset index file, where the index information is index information of the deletable files in the target storage medium; Deleting the deletable file corresponding to the index information from the target storage medium; After deleting the deletable file corresponding to the index information from the target storage medium, the method further includes: Performing resource statistics on the target storage medium to obtain resource statistics results; Determine the file deletion result according to the resource statistics result; When the file deletion result is deletion failure, determining to delete the failed file; Performing a deduplication operation on the file that failed to be deleted; The resource statistics result includes the file creation time of the deleted file, and determining the file deletion result according to the resource statistics result includes: Reading the corresponding file creation time in the preset index file according to the index information of the deleted file; When the file creation time in the resource statistical result is inconsistent with the read file creation time, it is determined that the file deletion result is deletion failure.

2. The file deletion method according to claim 1, wherein: Deleting the deletable file corresponding to the index information from the target storage medium includes: Determining whether the deletable file corresponding to the index information is in an accessed state; If not, the step of deleting the deletable file corresponding to the index information from the target storage medium is performed.

3. The file deletion method according to claim 1, wherein: After deleting the deletable file corresponding to the index information from the target storage medium, the method further includes: The index information is deleted from the preset index file.

4. The file deletion method according to any one of claims 1 to 3, characterized in that: The process of creating the preset index file includes: Create a blank index file; When a file write operation is detected, the file parameters of the written file are obtained; When the file parameters meet the preset parameters, creating index information for the written file; The index information is written into the blank index file to generate the preset index file.

5. The file deletion method according to claim 4, characterized in that: The file parameters include one or more of file name, wildcard, file size, and file creation time.

6. A file deletion device, characterized in that: include: An acquisition module, used to obtain the occupied space of the target storage medium; a reading module, configured to read index information from a preset index file when the occupied space reaches a preset threshold, the index information being index information of deletable files in the target storage medium; A deletion module, configured to delete the deletable file corresponding to the index information from the target storage medium; Wherein, the file deletion device further includes: A file deduplication module is configured to perform resource statistics on the target storage medium to obtain resource statistics results; determine a file deletion result based on the resource statistics results; when the file deletion result is a deletion failure, determine to delete the failed file; and perform a deduplication operation on the failed file; Among them, the resource statistical result includes the file creation time of the deleted file, and the process of determining the failed file deletion through the file deduplication module includes: reading the corresponding file creation time in the preset index file according to the index information of the deleted file; when the file creation time in the resource statistical result is inconsistent with the read file creation time, determining that the file deletion result is a deletion failure.

7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the file deletion method according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the file deletion method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Distributed file deletion method, device and system, and computer-readable storage medium

    CN109388624A