A storage space recycling method, device and medium

By traversing disk storage blocks, deleting tagged files, and consolidating available space locations, the problem of insufficient storage space reclamation is solved, improving disk utilization efficiency and reuse rate.

CN115269448BActive Publication Date: 2026-04-07SHANDONG SENTER ELECTRONICS
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-19
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies cannot create temporary files when the system's reserved storage space is insufficient, and cannot reclaim storage space when the tail space of the storage block is insufficient, resulting in reduced disk usage efficiency.

Method used

By traversing the storage blocks in the disk, small files with deletion tags are identified, their starting positions are obtained and deleted, freeing up available space. Small files without deletion tags are then moved forward to available space, shifted backward, and integrated into available space.

Benefits of technology

This avoids the decrease in disk utilization caused by deleting tag files, improves the reuse rate of storage space, reduces the frequency of metadata updates, and improves disk write efficiency without increasing storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115269448B_ABST
    Figure CN115269448B_ABST
Patent Text Reader

Abstract

This application discloses a storage space reclamation method, device, and medium to solve the technical problems of insufficient storage space preventing the creation of temporary files and insufficient space at the end of storage blocks leading to space reclamation failure. The method includes: determining the disk availability rate based on the total number of storage blocks in the disk, the size of each storage block, and the size of small files to be deleted within each storage block; when the disk availability rate is less than a preset availability threshold, traversing the metadata of each small file in the storage block to determine the first small file with a deletion tag, and obtaining the starting position of the first block corresponding to the first small file from the storage block mapping table; deleting the first small file accordingly to obtain the corresponding first available space position; determining small files without deletion tags after the first available space position, and shifting these small files forward to the first available space position corresponding to the first small file to shift the first available space position backward, thereby reclamation of the storage space.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, and particularly relates to a storage space recycling method, device and medium. BACKGROUND

[0002] With the development of network technology and various applications, a large amount of small file data such as pictures, audio and video is generated in the network. Small files refer to files much smaller than the size of a storage block. On a storage block, any file has its corresponding metadata information. Too many small files will result in too much metadata, which is inconvenient to maintain and will increase the overhead. When deleting small files in a disk storage block, a large number of file holes will be generated, reducing the efficiency of the disk.

[0003] The prior art generally creates a temporary file, copies the non-deleted files to the temporary file, and then overwrites the original large file through the temporary file, so that the small file storage space is effectively recycled and reused, or the small files that do not need to be recycled are copied to the tail of the storage block to improve the efficiency of the disk. However, the above method cannot create a temporary file when the system reserved storage space is insufficient, and cannot recycle the storage space when the tail space of the storage block is insufficient, which has limitations. SUMMARY

[0004] The embodiments of the present application provide a storage space recycling method, device and medium to solve the technical problem that the prior art cannot create a temporary file when the system reserved storage space is insufficient, and cannot recycle the storage space when the tail space of the storage block is insufficient.

[0005] In one aspect, the embodiments of the present application provide a storage space recycling method, comprising:

[0006] According to the total number of storage blocks in the disk, the size of each storage block and the size of the small file to be deleted in the storage block, the available rate of the disk is determined, and it is determined whether the available rate of the disk is less than a preset available rate threshold;

[0007] When the available rate of the disk is less than the preset available rate threshold, the metadata of each small file in the storage block is traversed to determine a first small file having a deletion tag in the metadata of the storage block, and the first block start position corresponding to the first small file is obtained from a mapping table of the storage block. The deletion tag is a tag set based on the same small file being learned;

[0008] Based on the first block start position corresponding to the first small file, the first small file is deleted, and a first available space position corresponding to the first small file is obtained;

[0009] After determining the first available space position without the delete tag, the small file without the delete tag is forwardly shifted to the first available space position corresponding to the first small file, so as to make the first available space position backwardly shift, and the integration of the available space positions is realized.

[0010] In an implementation manner of the present application, after the forward shifting of the small file without the delete tag to the first available space position corresponding to the first small file, so as to make the first available space position backwardly shift, and the integration of the available space positions is realized, the method further comprises:

[0011] Traversing the small file after the first available space position, and determining a second small file with the delete tag after the first available space position;

[0012] Obtaining a second block start position in the metadata of the second small file from the mapping table of the storage block, and performing hole processing on the second small file according to the second block start position, so as to obtain a second available space position corresponding to the second small file;

[0013] Determining a small file without the delete tag after the second available space position, so as to forwardly shift the small file without the delete tag to the second available space position corresponding to the second small file, and make the second available space position backwardly shift;

[0014] Continuing to traverse the small file after the second available space position until the small file after the second available space position has no delete tag, and the integration of the available space positions is realized.

[0015] In an implementation manner of the present application, after the forward shifting of the small file without the delete tag to the first available space position corresponding to the first small file, so as to make the first available space position backwardly shift, and the integration of the available space positions is realized, the method further comprises:

[0016] Respectively determining a current block start position corresponding to each small file without the delete tag after the forward shifting, and a current block start position corresponding to each available space position;

[0017] According to the current block start position corresponding to each small file without the delete tag, updating the metadata of each small file, and according to the current block start position corresponding to each available space position, updating each available space position in the disk.

[0018] In an implementation manner of the present application, the determination of the available rate of the disk according to the total number of storage blocks in the disk, the size of each storage block and the size of the small file to be deleted in the storage block specifically comprises:

[0019] Obtaining configuration information of the disk, and determining a total number of storage blocks in the disk and a storage block size corresponding to each storage block according to the configuration information of the disk;

[0020] respectively determining a total size of all small files to be deleted in each of the storage blocks, and calculating an available rate of the disk according to the following formula:

[0021]

[0022] wherein R represents the available rate of the disk, N represents the total number of storage blocks in the disk, S represents the storage block size, D represents the total size of all small files to be deleted in the storage blocks, S i represents the storage block size of the i-th storage block in the disk, and D i represents the total size of all small files to be deleted in the i-th storage block.

[0023] In an implementation manner of the present application, the determining whether the available rate of the disk is less than a preset available rate threshold specifically comprises:

[0024] calculating the available rate of the disk at a preset time interval;

[0025] comparing the available rate of the disk with the preset available rate threshold at the preset time interval, to determine whether the available rate of the disk is less than the preset available rate threshold.

[0026] In an implementation manner of the present application, before the first small file with the deletion tag in the metadata of the storage block is determined by traversing the metadata of each small file in the storage block when the available rate of the disk is less than the preset available rate threshold, the method further comprises:

[0027] determining whether the content corresponding to the small file is duplicated with the content of the existing small file in the storage block by reading the small file, and if yes, adding a deletion tag to the small file;

[0028] adding the deletion tag to the metadata corresponding to the small file, and adding the metadata of the small file to a space recycling processing module; wherein the space recycling processing module is arranged in the disk, and is used for counting the small files to be deleted in the disk.

[0029] In an implementation manner of the present application, before the first block start position corresponding to the first small file is obtained from the mapping table of the storage block, the method further comprises:

[0030] saving a plurality of small files into the storage block, and taking the file name, the block serial number, the block start position and the file size corresponding to the small file as the metadata corresponding to the small file;

[0031] The metadata corresponding to each of the small files is added to the mapping table of the storage block corresponding to the small file.

[0032] In an implementation manner of the present application, the deleting processing is performed on the first small file based on the first block start position corresponding to the first small file, and the first available space position corresponding to the first small file is obtained, and specifically includes:

[0033] The position of the small file to be deleted is determined according to the first block start position corresponding to the first small file.

[0034] The deleting processing is performed on the small file at the first block start position based on the position of the small file to be deleted, so that the first block start position forms a hole, and the first available space position corresponding to the first small file is obtained.

[0035] On the other hand, the present application also provides a storage space recycling device, and the device includes:

[0036] At least one processor;

[0037] and a memory in communication connection with the at least one processor;

[0038] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above-mentioned storage space recycling method.

[0039] On the other hand, the present application also provides a non-volatile computer storage medium, which stores computer executable instructions, and the computer executable instructions are configured to:

[0040] The above-mentioned storage space recycling method.

[0041] The present application provides a storage space recycling method, device and medium, which at least includes the following beneficial effects:

[0042] According to the total number of storage blocks in the disk, the total size of all small files to be deleted in each storage block is estimated according to the size of the storage block, the available rate of the disk is determined, and the available rate of the disk is compared with the preset available rate threshold, when the available rate of the disk is less than the preset available rate threshold, the disk is processed for space recycling, the small files in the storage block are traversed, and the first small file with a deletion tag is determined, and then the first block starting position corresponding to the first small file is obtained from the mapping table of the storage block, and the first small file is pretreated according to the first block starting position, so as to obtain the first available space position corresponding to the first small file, and then the small file without a deletion tag after the first available space position is forward shifted to the first available space position, and the first available space position is shifted backward, so as to avoid the decrease of the disk usage rate caused by deleting the small file with a deletion tag, the forward shift of the small file without a deletion tag can avoid the problem of insufficient space at the tail of the storage block and cannot recycle the space, the update frequency of the metadata is reduced, and the reusability of the small file storage space is improved without increasing the storage space of the storage block. BRIEF DESCRIPTION OF DRAWINGS

[0043] The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application and illustrate the illustrative embodiments of the present application and their description serve to explain the present application, and do not constitute improper limitations on the present application. In the drawings:

[0044] Figure 1 A flowchart of a storage space recycling method provided for the embodiment of the present application;

[0045] Figure 2 A forward shift diagram of a small file without a deletion tag provided for the embodiment of the present application;

[0046] Figure 3 An internal structure diagram of a storage space recycling device provided for the embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme of the present application will be described clearly and completely in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0048] This application provides a storage space reclamation method, device, and medium. It estimates the total size of all small files to be deleted in each storage block by calculating the total number of storage blocks and the size of each block, thus determining the disk's availability. The disk availability is then compared to a preset availability threshold. If the disk availability is less than the threshold, space reclamation is performed. By traversing the small files in the storage blocks, a first small file with a deletion tag is identified. The starting position of the first block corresponding to the first small file is obtained from the storage block mapping table. The first small file is preprocessed based on this starting position to obtain the first available space position. Small files without deletion tags after the first available space position are then shifted forward to that position, and the first available space position is shifted backward. This solves the technical problems of existing technologies, such as the inability to create temporary files when the system's reserved storage space is insufficient, and the inability to reclaim storage space when there is insufficient space at the end of the storage block.

[0049] The technical solutions proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0050] Figure 1 This is a schematic flowchart illustrating a storage space reclamation method provided in an embodiment of this application. Figure 1 As shown in the figure, a storage space reclamation method provided in this application mainly includes the following steps:

[0051] Step 101: Determine the disk availability rate based on the total number of storage blocks in the disk, the size of each storage block, and the size of the small files to be deleted within the storage blocks, and determine whether the disk availability rate is less than the preset availability rate threshold.

[0052] A hard disk is a storage device that uses magnetic recording technology to store data. It is the main storage medium of a computer, capable of storing large amounts of binary data and retaining the data even after power is off. Early computers used floppy disks, while today hard disks are more commonly used.

[0053] With the development of network technology and various applications, a large amount of small file data such as images, audio, and video has been generated on the network. Currently, the common practice is to pre-create storage blocks of 64MB each on the system storage and store several small files within a single block. It should be noted that, in this embodiment, a small file refers to a file smaller than the minimum storage and processing unit. The size of a small file is generally less than 64MB; for example, a file of 10MB is defined as a small file. Small files can be in formats such as JPG, TXT, DOC, HTML, and JS.

[0054] The server can determine the disk availability based on the total number of storage blocks on the disk, the size of each storage block, and the total size of all small files to be deleted within the storage blocks. Then, it can determine the size relationship between the current disk availability and the preset availability threshold, and then determine whether to recycle the small files based on the size relationship.

[0055] Specifically, the server obtains the configuration information corresponding to the disk, and based on this information, determines the total number of storage blocks on the disk and the size of each storage block. Then, it determines the size of each small file to be deleted within a storage block, and calculates the total size of files to be deleted within that block. Based on the total number of storage blocks, the storage block size, and the total size of files to be deleted, the server calculates the current disk availability using the following formula:

[0056]

[0057] It should be noted that in the embodiments of this application, R represents the disk availability, N represents the total number of storage blocks on the disk, S represents the storage block size, and D represents the total size of all small files to be deleted in the storage block. i D represents the size of the i-th storage block on the disk. i This represents the total size of all small files to be deleted in the i-th storage block.

[0058] The server periodically retrieves the total size of all small files to be deleted in the storage block at preset time intervals and calculates the disk availability. At the same time, the server also periodically compares the calculated disk availability with a preset availability threshold at preset time intervals to obtain the corresponding size relationship.

[0059] Step 102: When the disk availability is less than the preset availability threshold, the first small file with the delete tag in the storage block's metadata is determined by traversing the metadata of each small file in the storage block, and the starting position of the first block corresponding to the first small file is obtained from the storage block's mapping table.

[0060] When the server determines that the current disk availability is less than a preset availability threshold, it iterates through the metadata of several small files in the storage block, identifies the first small file with a deletion tag in the storage block's metadata, retrieves the metadata of the first small file from the storage block's mapping table, and obtains the starting position of the first block corresponding to the first small file from its metadata. This facilitates subsequent processing of the first small file based on the starting position of the first block. It should be noted that the deletion tag in this embodiment is a tag set after it is known that there is a small file in the storage block that is identical to the current small file.

[0061] In one embodiment of this application, when the disk availability is less than a preset availability threshold, the server reads the small files in the storage block to determine the content corresponding to the small file before identifying the first small file with a deletion tag in the storage block. Then, the content corresponding to the small file is compared with the existing content in the storage block to determine whether they are duplicates. If the content corresponding to the small file is duplicated with the existing content in the storage block, a deletion tag is added to the current small file, the deletion tag of the current small file is added to the metadata of the small file, and the metadata of the current small file is added to the space reclamation processing module.

[0062] It should be noted that, in this embodiment of the application, the space reclamation processing module is located on the disk. The space reclamation processing module is used to count the small files to be deleted on the disk and process the small files to be deleted according to the actual situation of the disk.

[0063] In one embodiment of this application, before the server obtains the starting position of the first block corresponding to the first small file from the mapping table of the storage block, it saves several small files to the storage block, and then uses the file name, block number, block starting position and file size and other attribute information corresponding to each small file as the metadata corresponding to the small file. Then, the metadata corresponding to each small file is added to the mapping table of the corresponding storage block so that the relevant information of the small file can be obtained from the mapping table later.

[0064] Step 103: Based on the starting position of the first block corresponding to the first small file, delete the first small file and obtain the first available space position corresponding to the first small file.

[0065] Based on the starting position of the first block corresponding to the first small file, the server deletes the first small file at the starting position of the first block, thereby realizing the emptying of the first small file and thus releasing and obtaining the first available space position corresponding to the first small file.

[0066] Specifically, the server can determine the location of the small file to be deleted based on the starting position of the first block corresponding to the first small file. Then, based on the determined location of the small file to be deleted, the small file at the starting position of the first block is deleted, thereby creating a hole at the starting position of the first block, and thus obtaining the first available space location corresponding to the first small file.

[0067] Step 104: Determine the small files without deletion tags after the first available space location, and move the small files without deletion tags forward to the first available space location corresponding to the first small file, so that the first available space location is shifted backward to achieve the integration of available space locations.

[0068] The server, based on the first available space location corresponding to the first small file, traverses all small files without deletion tags after the first available space location in the storage block. It then shifts these small files forward to the first available space location corresponding to the first small file, and shifts the first available space location corresponding to the first small file backward, thus consolidating the available space locations and completing the reclamation of storage space. This avoids the problem in existing technologies where small files that don't need reclamation are moved to the end of the storage block, but reclamation fails due to insufficient space at the end. Furthermore, this application shifts the available space locations after small file hole processing backward until all available space locations in the current storage block are gathered at the end of the storage block, forming a complete block of available space. This accelerates disk write efficiency, improves disk availability, and avoids the low disk availability caused by insufficient system-reserved storage space to create temporary files or insufficient space at the end of the storage block to reclaim storage space, as seen in existing technologies.

[0069] In one embodiment of this application, the server forward-shifts small files without deletion tags to the first available space position corresponding to the first small file, so that the first available space position is shifted backward. Then, it traverses the small files after the first available space position in the storage block and determines the second small file with deletion tags after the first available space position. Then, it finds the metadata of the second small file from the mapping table of the storage block and obtains the second block start position corresponding to the second small file from the metadata of the second small file. Then, based on the obtained second block start position, it performs hole processing on the second small file, that is, it deletes the second small file to be deleted corresponding to the second block start position to form the corresponding hole, thereby obtaining the second available space position corresponding to the second small file.

[0070] By traversing the small files after the second available space position in the storage block, the server can identify the small files without deletion tags after the second available space position. Then, the small files without deletion tags are shifted forward to the second available space position corresponding to the second small file, and the second available space position corresponding to the second small file is shifted backward. The server continues to traverse the small files after the second available space position in the storage block until all small files after the second available space position have no deletion tags. This forward shift of small files without deletion tags is equivalent to backward shift of available space positions, thereby avoiding the problem of space reclamation failure caused by insufficient space at the end of the storage block in existing technologies.

[0071] In one embodiment of this application, the server continues to traverse the small files after the second available space location until the small files after the second available space location have no deletion tags. Then, it determines the current block start position corresponding to the forward displacement of each small file without deletion tags, and the current block start position corresponding to each available space location. This allows the server to update the metadata of the small files without deletion tags based on the current block start position corresponding to the small files without deletion tags, and to update the available space location in the storage block of the disk based on the current block start position corresponding to the available space location.

[0072] Figure 2 This is a schematic diagram illustrating the forward displacement of a small file without a deletion tag, as provided in an embodiment of this application. Figure 2 As shown, the metadata of small files to be deleted includes deletion tags. By traversing the small files in the storage block, the server can identify small files with deletion tags. It can then obtain the block start position corresponding to the small file from its metadata, thereby performing hole-filling processing on the small files with deletion tags, making the block start position corresponding to the small file with deletion tags a available space position. Then, this application moves small files without deletion tags after the first available space position forward to the first available space position, while simultaneously moving the first available space position backward. This avoids the problem of insufficient space at the end of the storage block leading to space reclamation failure in the prior art. This application continuously performs several rounds of traversal in the storage block until no small files without deletion tags are stored after the available space position, achieving the merging and integration of available space positions, reducing the metadata update frequency, and improving the small file storage space reuse rate without increasing storage space.

[0073] The above are embodiments of the method proposed in this application. Based on the same inventive concept, embodiments of this application also provide a storage space reclamation device, the structure of which is as follows: Figure 3 As shown.

[0074] Figure 3 This is a schematic diagram of the internal structure of a storage space recycling device provided in an embodiment of this application. Figure 3 As shown, the device includes:

[0075] At least one processor;

[0076] And, a memory that is communicatively connected to at least one processor;

[0077] The memory stores instructions that can be executed by at least one processor, and the instructions, when executed by at least one processor, enable at least one processor to:

[0078] The disk availability rate is determined based on the total number of storage blocks in the disk, the size of each storage block, and the size of small files to be deleted within each storage block, and it is also determined whether the disk availability rate is less than the preset availability rate threshold.

[0079] When the disk availability is less than the preset availability threshold, the metadata of each small file in the storage block is traversed to determine the first small file with the deletion tag in the metadata of the storage block, and the starting position of the first block corresponding to the first small file is obtained from the mapping table of the storage block; the deletion tag is a tag set after it is known that there are identical small files.

[0080] Based on the starting position of the first block corresponding to the first small file, the first small file is deleted, and the first available space position corresponding to the first small file is obtained;

[0081] After determining the first available space location, small files without deletion tags are moved forward to the first available space location corresponding to the first small file, so that the first available space location is shifted backward, thereby integrating the available space locations.

[0082] This application embodiment also provides a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:

[0083] The disk availability rate is determined based on the total number of storage blocks in the disk, the size of each storage block, and the size of small files to be deleted within each storage block, and it is also determined whether the disk availability rate is less than the preset availability rate threshold.

[0084] When the disk availability is less than the preset availability threshold, the metadata of each small file in the storage block is traversed to determine the first small file with the deletion tag in the metadata of the storage block, and the starting position of the first block corresponding to the first small file is obtained from the mapping table of the storage block; the deletion tag is a tag set after it is known that there are identical small files.

[0085] Based on the starting position of the first block corresponding to the first small file, the first small file is deleted, and the first available space position corresponding to the first small file is obtained;

[0086] After determining the first available space location, small files without deletion tags are moved forward to the first available space location corresponding to the first small file, so that the first available space location is shifted backward, thereby integrating the available space locations.

[0087] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and medium embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the description of the method embodiments.

[0088] The devices and media provided in this application are one-to-one with the methods. Therefore, the devices and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.

[0089] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0090] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will 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 processor 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 processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0091] 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.

[0092] 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.

[0093] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0094] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0095] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0096] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0097] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for reclaiming storage space, characterized in that, The method includes: The availability of the disk is determined based on the total number of storage blocks in the disk, the size of each storage block, and the size of small files to be deleted within each storage block, and it is also determined whether the availability of the disk is less than a preset availability threshold. By reading the small file, it is determined whether the content of the small file is the same as the content of the existing small file in the storage block. If so, a deletion tag is added to the small file. The deletion tag is added to the metadata corresponding to the small file, and the metadata of the small file is added to the space reclamation module; wherein, the space reclamation module is set in the disk and is used to count the small files to be deleted in the disk; When the availability of the disk is less than a preset availability threshold, the metadata of each small file in the storage block is traversed to determine the first small file with a deletion tag in the metadata of the storage block, and the starting position of the first block corresponding to the first small file is obtained from the mapping table of the storage block; the deletion tag is a tag set after it is known that there are identical small files. Based on the starting position of the first block corresponding to the first small file, the first small file is deleted, and the first available space position corresponding to the first small file is obtained; After identifying the small file without deletion tags in the first available space location, the small file without deletion tags is shifted forward to the first available space location corresponding to the first small file, so that the first available space location is shifted backward to achieve the integration of available space locations; After shifting the small file without the deletion tag forward to the first available space position corresponding to the first small file, thereby shifting the first available space position backward and consolidating the available space positions, the method further includes: Traverse the small files after the first available space location, and determine the second small file with a deletion tag after the first available space location; From the mapping table of the storage blocks, obtain the starting position of the second block in the metadata of the second small file, and perform hole processing on the second small file according to the starting position of the second block to obtain the second available space position corresponding to the second small file; After determining the second available space location, small files without deletion tags are shifted forward to the second available space location corresponding to the second small file, and the second available space location is shifted backward. Continue traversing the small files after the second available space location until there are no deletion tags for the small files after the second available space location, thus consolidating the available space locations.

2. The storage space reclamation method according to claim 1, characterized in that, After continuing to traverse the small files after the second available space location until no deletion tags are found in the small files after the second available space location, thus consolidating the available space locations, the method further includes: Determine the starting position of the current block after the forward displacement of each small file without deletion tags, and the starting position of the current block corresponding to each available space location; Based on the current block start position corresponding to each of the small files without deletion tags, the metadata of each of the small files is updated, and based on the current block start position corresponding to each of the available space positions, the available space positions in the disk are updated.

3. The storage space reclamation method according to claim 1, characterized in that, The process of determining the disk availability based on the total number of storage blocks, the size of each storage block, and the size of small files to be deleted within each storage block specifically includes: Obtain the disk configuration information, and determine the total number of storage blocks in the disk and the size of each storage block based on the disk configuration information; The total size of all small files to be deleted in each of the aforementioned storage blocks is determined, and the availability of the disk is calculated according to the following formula: ; Where R represents the disk availability, N represents the total number of storage blocks on the disk, S represents the storage block size, and D represents the total size of all small files to be deleted in the storage block. i D represents the size of the i-th storage block in the disk. i This represents the total size of all small files to be deleted in the i-th storage block.

4. The storage space reclamation method according to claim 1, characterized in that, Determining whether the availability of the disk is less than a preset availability threshold specifically includes: The availability of the disk is calculated periodically at preset time intervals; The disk availability rate is compared with a preset availability rate threshold at the preset time interval to determine whether the disk availability rate is less than the preset availability rate threshold.

5. A storage space reclamation method according to claim 1, characterized in that, Before obtaining the starting position of the first block corresponding to the first small file from the mapping table of the storage blocks, the method further includes: Several small files are saved to a storage block, and the file name, block number, block start position, and file size of the small files are used as the metadata of the small files. The metadata corresponding to each of the small files is added to the mapping table of the storage block corresponding to the small file.

6. A storage space reclamation method according to claim 1, characterized in that, The step of deleting the first small file based on the starting position of the first block corresponding to the first small file and obtaining the first available space position corresponding to the first small file specifically includes: The location of the small file to be deleted is determined based on the starting position of the first block corresponding to the first small file; Based on the location of the small file to be deleted, the small file at the starting position of the first block is deleted to create a hole at the starting position of the first block, thereby obtaining the first available space location corresponding to the first small file.

7. A storage space recycling device, characterized in that, The device includes: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a memory reclamation method as described in any one of claims 1-6.

8. A non-volatile computer storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions are set as follows: A storage space reclamation method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Merged storage space recovery method and device and electronic equipment

    CN108090128A

  • A method and apparatus for reclaiming storage space

    CN109086220A