Method, apparatus, device and medium for disk space management
By pre-allocating contiguous space blocks and implementing a data reclamation mechanism after deletion, the disk fragmentation problem is solved, improving disk read/write performance and space utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2024-09-26
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, disk fragmentation leads to a decrease in disk read and write performance, especially when writing large files, which requires spreading the data across multiple discrete sectors, thus affecting performance.
Disk space management uses pre-allocated contiguous blocks of preset capacity. After the target data is written, the space block is reclaimed when the data is deleted, ensuring the continuity and rational use of the space blocks.
Reduce disk fragmentation, improve disk read and write performance, ensure continuous data writing and efficient use of space, and avoid resource waste.
Smart Images

Figure CN119376619B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, specifically to cloud storage, cloud computing, big data and other technical fields, and particularly to a disk space management method, apparatus, device and medium. Background Technology
[0002] Disk space management mainly includes operations such as allocating space and reclaiming space.
[0003] To manage disk space efficiently, it is necessary to address the issue of reducing disk fragmentation. Summary of the Invention
[0004] This disclosure provides a disk space management method, apparatus, device, and medium.
[0005] According to one aspect of this disclosure, a disk space management method is provided, comprising: in response to a write instruction for target data, writing the target data into a target space block corresponding to a target level of the target data; the target space block being a contiguous space of a preset capacity within the disk, wherein the preset capacity is greater than the size corresponding to the target level; in response to a delete instruction for the target data, deleting the target data in the target space block; and reclaiming the target space block after all the target data has been deleted.
[0006] According to another aspect of this disclosure, a disk space management device is provided, comprising: a writing module, configured to write the target data into a target space block corresponding to a target level of the target data in response to a write instruction for the target data; the target space block is a contiguous space of a preset capacity within the disk, and the preset capacity is greater than the size corresponding to the target level; a deletion module, configured to delete the target data in the target space block in response to a deletion instruction for the target data; and a recycling module, configured to reclaim the target space block after all the target data has been deleted.
[0007] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to said at least one processor; wherein the memory stores instructions executable by said at least one processor, said instructions being executed by said at least one processor to enable said at least one processor to perform the method as described in any of the foregoing aspects.
[0008] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method according to any of the preceding aspects.
[0009] According to another aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method according to any of the preceding aspects.
[0010] According to embodiments of this disclosure, disk fragmentation can be reduced, thereby improving disk read / write performance.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0012] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0013] Figure 1 This is a schematic diagram based on the first embodiment of the present disclosure;
[0014] Figure 2 This is a schematic diagram illustrating the application scenarios used to implement the embodiments of this disclosure;
[0015] Figure 3 This is a schematic diagram of a space block provided according to an embodiment of the present disclosure;
[0016] Figure 4 This is a schematic diagram of data writing after the existence of an idle position, provided according to an embodiment of this disclosure;
[0017] Figure 5 This is a schematic diagram illustrating the allocation of new space blocks according to embodiments of this disclosure;
[0018] Figure 6 This is a schematic diagram of a data movement operation provided according to an embodiment of the present disclosure;
[0019] Figure 7 This is a schematic diagram according to the second embodiment of the present disclosure;
[0020] Figure 8 This is a schematic diagram according to the third embodiment of the present disclosure;
[0021] Figure 9 This is a schematic diagram of an electronic device used to implement the disk space management method of the embodiments of this disclosure. Detailed Implementation
[0022] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0023] In related technologies, the buddy algorithm can be used for disk space management.
[0024] The buddy algorithm is a dynamic memory management algorithm that continuously divides or merges free blocks to meet the needs of memory allocation or reclamation.
[0025] The size of each free block is a power of 2, with a minimum of 4k bytes (4kB), i.e., 4kB, 8kB, 16kB...
[0026] During space allocation, the smallest free block that meets the requirements is found. If no such block is found, half of a larger free block is split off, and this process continues until a suitable free block is found. Two smaller free blocks split from the same larger free block are called buddies, and their physical addresses are contiguous. During merging, if two adjacent buddies are both free (i.e., neither stores data), they are merged into a larger free block. This process continues until no adjacent free blocks remain.
[0027] The buddy algorithm continuously splits and merges free blocks, which can lead to significant disk fragmentation over time. For example, if there is a 4kB free block between two 8kB free blocks, and the two 8kB blocks are released first, then although these 20kB blocks are all free, they cannot be merged because the adjacent 8kB and 4kB blocks are different in size. Therefore, these three free blocks cannot be merged, resulting in disk fragmentation.
[0028] Over time, a large amount of disk fragmentation can affect disk read and write performance. For example, when a user writes a large file, because there is no large contiguous space, the large file will be scattered across multiple discrete sectors on the disk, turning what could have been sequential read and write operations into multiple random read and write operations, which greatly impacts performance.
[0029] To reduce disk fragmentation and improve disk read / write performance, this disclosure provides the following embodiments.
[0030] Figure 1 This is a schematic diagram based on the first embodiment of the present disclosure. This embodiment provides a disk space management method, such as... Figure 1 As shown, the method includes:
[0031] 101. In response to a write command for target data, the target data is written to a target space block corresponding to the target level of the target data; the target space block is a contiguous space of a preset capacity on the disk, and the preset capacity is greater than the size corresponding to the target level.
[0032] 102. In response to a deletion instruction for the target data, delete the target data in the target space block.
[0033] 103. After all the target data has been deleted, the target space block is reclaimed.
[0034] In this embodiment of the disclosure, disk space management is performed based on the size level of the data, similar to the buddy algorithm.
[0035] For example, the size levels are divided into 10 levels, corresponding to sizes of 4kB, 8kB, 16kB, ..., 2MB, which are powers of two.
[0036] Unlike the buddy algorithm, in this embodiment of the disclosure, a space block is pre-allocated for each size level. This space block is a segment of physically contiguous space on the disk, and its capacity is a preset value, such as 32MB.
[0037] For example, the levels corresponding to 4kB and 8kB are called the first level and the second level, respectively. Then, the first level can be pre-allocated to the first space block and the second level to the second space block. Both the first space block and the second space block are physically contiguous spaces, and both are 32MB in size.
[0038] The target data is the data to be written to the disk.
[0039] Target level refers to the size level corresponding to the target data.
[0040] Generally speaking, the target level is the level that is greater than or equal to the target data size and is closest to the target data size. Based on the level example above, if the target data size is 8kB, then the target level is the second level; if the target data size is 10kB, then the target level is 16kB.
[0041] A target spatial block refers to the spatial block corresponding to a target level. Based on the level example above, assuming the target level is the second level, then the target spatial block is the second spatial block.
[0042] For each size level, a corresponding space block is allocated initially, and then the data is written into the existing space block of the corresponding level.
[0043] For example, if the target data is 8kB of data to be written for the first time, then first allocate a 32MB contiguous disk space as the disk space corresponding to the 8kB level, and write the 8kB of data to the first location interval of the 32MB disk space (each location interval can write 8kB of data); then, after writing the second 8kB of data, write the second 8kB of data to the second location interval of the existing 32MB disk space, and so on.
[0044] Taking the second level and the second space block mentioned above as an example, if the target data of the second level is received for the first time, the second space block is allocated and the target data is written into the allocated second space block; if the target data of the second level is not received for the first time, the target data is written into the existing second space block corresponding to the second level.
[0045] Data within the target space block can be deleted. Once the target space block is completely free, meaning all target data has been deleted, the target space block will be reclaimed.
[0046] The reclaimed space blocks can be redistributed and used for data of any size. For example, the second space block mentioned above, after being reclaimed, can be used for data of 4kB size.
[0047] In this embodiment, the target data is written into the target space block, which can be reclaimed when it is completely idle. Since the target space block is contiguous and its preset capacity is greater than the size corresponding to the data size level, a larger contiguous space can be allocated to the data. In this way, a larger contiguous space can also be reclaimed during reclamation, thereby reducing disk fragmentation and improving disk read and write performance.
[0048] To better understand this disclosure, the application scenarios involved in this disclosure are explained as follows:
[0049] Figure 2 This is a schematic diagram illustrating the application scenarios used to implement the embodiments of this disclosure.
[0050] like Figure 2 As shown, this application scenario includes: a client and a disk management system.
[0051] The client is deployed on user terminal 201, which may include: personal computer (PC), mobile device (such as mobile phone), tablet computer, laptop computer, smart wearable device, etc.
[0052] The disk management system is deployed on the disk manager 202. The disk manager is used to manage the disk 203. The disk manager 202 and the disk 203 are located on the same electronic device, which can be a host, server, etc. The disk manager 202 can be located inside or outside the disk 203. In this embodiment, the disk manager 202 is located outside the disk 203 as an example.
[0053] Users generate read / write commands for target data through the client. After receiving the read / write commands, the disk management system performs read / write operations on the target data on the disk.
[0054] Figure 3 This is a schematic diagram of a space block provided according to an embodiment of the present disclosure.
[0055] like Figure 3 As shown, the disk manager pre-allocates contiguous blocks of space with a preset capacity for each size level. When data at a certain level is actually written, the corresponding blocks of space are actually allocated and occupied.
[0056] For example, if the data to be written is at the 4kB level, then a first space block is allocated for the 4kB level, and the 4kB data is written into the first space block; then, upon receiving an 8kB level data write instruction, a second space block is allocated, and the 8kB data is written into the second space block; subsequently, upon receiving a 32kB level data write instruction, a third space block is allocated, and the 32kB data is written into the third space block. The different space blocks can be allocated sequentially, meaning that the first, second, and third space blocks are physically contiguous.
[0057] Taking 4kB level as an example, after writing the first received 4kB data in the first position interval of the first space block, if a write instruction for 4kB data is received a second time, the second received 4kB data will be written to the second position interval of the first space block.
[0058] For hard disk drives (HDDs), data within the same block (e.g., the first block) is written sequentially. For example, see... Figure 3 The first and second location intervals mentioned above are physically contiguous. For solid-state drives (SSDs), data within the same block (such as the first block) can be written sequentially or randomly.
[0059] After data is written to a space block, it can be deleted, leaving some location intervals in an idle state. When new data is received, these idle intervals can be filled or sequential writing can continue.
[0060] Figure 4This is a schematic diagram of data writing after an empty space exists, provided according to an embodiment of this disclosure.
[0061] like Figure 4 As shown, taking the 4kB level as an example, for the first space block, assume that the current write is to the third position interval, and the data in the second position interval has been deleted. Here, 4kB represents the presence of data, and blank parts represent the corresponding position intervals that are free. If new 4kB data is received, then the new 4kB data can be written to the second position interval, or the new 4kB data can continue to be written sequentially.
[0062] For example, such as Figure 4 As shown, for an SSD, the new 4kB of data (represented by a filled box) can be written to the second location range; for an HDD, the new 4kB of data (represented by a filled box) can be written to the fourth location range.
[0063] If the allocated space block (such as the first space block) for a certain level of data (e.g., 4kB) is full, then a new space block can be allocated for that level.
[0064] Figure 5 This is a schematic diagram of the allocation of new space blocks according to an embodiment of this disclosure.
[0065] like Figure 5 As shown, taking the 4kB level as an example, if the first space block is full, then after receiving the write instruction for 4kB data again, a 32M contiguous space block will be allocated for the 4kB level, which can be called the fourth space block. The received 4kB data will be written in the fourth space block.
[0066] As data is written and deleted, there may be multiple space blocks at the same level, and each space block may have a lot of free space intervals. At this time, the remaining data in multiple space blocks can be moved to the same space block. This same space block can be one of the multiple space blocks, or a space block can be reallocated.
[0067] Figure 6 This is a schematic diagram of a data movement operation provided according to an embodiment of the present disclosure.
[0068] like Figure 6 As shown, taking the 4kB level as an example, assuming the allocated space blocks include the first space block and the fourth space block, if the proportion of free space intervals within these two space blocks is greater than a preset threshold, then the remaining data in these two space blocks will be moved to the same space block. Here, 4kB represents the remaining data, and blank spaces represent the corresponding free space intervals.
[0069] Assuming we move to the first spatial block, such as Figure 6 As shown, after the data is moved, the fourth space block is completely free. Since the fourth space block is completely free, it can be reclaimed and subsequently reassigned to new data.
[0070] In conjunction with the above application scenarios, this disclosure also provides the following embodiments.
[0071] Figure 7 Based on a schematic diagram of the second embodiment of this disclosure, this embodiment provides a disk space management method, the method comprising:
[0072] 701. In response to a write command for target data, the target data is written to a target space block corresponding to the target level of the target data; the target space block is a contiguous space of a preset capacity on the disk, and the preset capacity is greater than the size corresponding to the target level.
[0073] For example, refer to Figure 3 When the disk manager receives a write command for target data at the 4kB level, it writes the target data to the first space block. When the disk manager receives a write command for target data at the 8kB level, it writes the target data to the second space block.
[0074] In addition, the disk manager can also record the location of the space blocks corresponding to each level, as well as the free status. The free status includes, for example, whether the space block is full, and what free space intervals exist within the space block, so that when data is received again, the data can be written to the space block of the corresponding level.
[0075] 702. In response to a deletion instruction for the target data, delete the target data in the target space block.
[0076] 703. After the target data is deleted, the write position of the target data is recorded as an idle position.
[0077] 704. If a write instruction for new data is received, and the size level of the new data is the same as the target level, the new data is written to the free position within the target space block.
[0078] For example, refer to Figure 4 As shown on the upper right, after the data in the second position interval of the first spatial block is deleted, the second position interval is used as the spatial position. If 4kB of data is received again, the 4kB of data can be written into the second position interval.
[0079] In this embodiment, writing new data to an idle location can improve space utilization and avoid resource waste.
[0080] The above example uses writing to a free position. Alternatively, the free position can be ignored, and sequential writing can continue. For example, see [link to example]. Figure 4 Below and to the right of the position, you can continue writing to the fourth position interval instead of writing to the free second position interval.
[0081] Writing in this sequential manner can improve write speed.
[0082] 705. If the target space block is full and a write instruction for new data at the target level is received, allocate a new space block corresponding to the target level and write the new data into the new space block; the new space block is a contiguous space of a preset capacity within the disk.
[0083] For example, refer to Figure 5 For the 4kB level, if the first space block is full, a new space block (the fourth space block) can be allocated, and then the new 4kB of data is written to the fourth space block.
[0084] In this embodiment, by allocating new space blocks, the successful writing of new data can be guaranteed, thereby improving disk performance.
[0085] 706. If the target level corresponds to other spatial blocks, and the remaining data in the target spatial block and the other spatial blocks meet the preset conditions, move the remaining data to the same spatial block.
[0086] The same spatial block can be one of the target spatial block and other spatial blocks, or it can be a reallocated spatial block outside of the target spatial block and other spatial blocks.
[0087] For example, refer to Figure 6 Assuming the target space block is the first space block and the other space blocks are the fourth space blocks, and taking the first space block as an example, if the remaining data meets the preset condition, specifically, the proportion of remaining data is less than a threshold, then the remaining data in the first space block and the fourth space block are all moved to the first space block.
[0088] After the movement, the fourth space block is empty, meaning it is completely free. At this point, the fourth space block can be reclaimed and reassigned to any level of data in subsequent processes.
[0089] In this embodiment, by moving the remaining data in multiple space blocks to the same space block, the data concentration can be improved. After the move, the completely idle space blocks are reclaimed, reducing disk fragmentation and improving disk read / write performance.
[0090] 707. After all the target data has been deleted, the target space block is reclaimed.
[0091] The deletion of target data can be performed either based on the user's deletion command or after the data has been moved.
[0092] For example, for the first space block, at least 4kB of data within it can be deleted according to the user's deletion command. Alternatively, the remaining data in the first space block can also be deleted after it has been moved to other space blocks.
[0093] For each size level, space blocks of the same capacity can be pre-allocated. For example, 32M space blocks can be pre-allocated for 4kB level, 8kB level, etc.
[0094] These pre-allocated space blocks are only used when there is actual data writing; in some cases, there may be pre-allocated space blocks that are not actually used.
[0095] For example, if the write commands are all for 4kB of data and no data at other levels is written, then the pre-allocated space blocks at other levels are not actually used. Taking nine other levels as an example, there is approximately 270M (9*32M) of space that is not actually used. In order to improve resource utilization, the size of the pre-allocated space blocks at unused levels can be adjusted, such as from 32M to 8M, which can avoid resource waste.
[0096] Based on this, some embodiments may further include:
[0097] If a pre-allocated space block corresponding to another level already exists, and no data write instruction for that other level has been received, the pre-allocated space block is adjusted from the preset capacity to the target capacity, and the target capacity is less than the preset capacity.
[0098] For example, if the target level is 4kB and the other levels are 8kB, and no write command for 8kB data is received, the space block corresponding to 8kB will be adjusted from 32M to 8M.
[0099] In this embodiment, resource utilization can be improved by reducing the capacity of the pre-allocated space that is not actually used.
[0100] After capacity adjustment, once the corresponding level of data is received, the data in multiple small space blocks (space blocks of target capacity) can be moved to a large space block (space block of preset capacity) through a rewrite operation.
[0101] For example, after adjusting the space block corresponding to 8kB from 32M to 8M, after receiving 8kB data, the 8kB data is written into the 8M space block. After multiple 8M space blocks are full, for example, after four 8M space blocks are full, a space block with a preset capacity (32M) can be reallocated for 8kB, and the data in the four 8M space blocks is rewritten into the 32M space block.
[0102] This improves data continuity and allows for the reclamation of larger contiguous spaces (32MB), reducing disk fragmentation and improving disk performance.
[0103] Figure 8 This is a schematic diagram based on the third embodiment of the present disclosure. This embodiment provides a disk space management device 800, which includes: a writing module 801, a deletion module 802, and a recycling module 803.
[0104] The write module 801 is used to write the target data into the target space block corresponding to the target level of the target data in response to a write command for the target data; the target space block is a contiguous space of a preset capacity in the disk, and the preset capacity is greater than the size corresponding to the target level; the delete module 802 is used to delete the target data in the target space block in response to a delete command for the target data; the reclaim module 803 is used to reclaim the target space block after all the target data has been deleted.
[0105] In this embodiment, the target data is written into the target space block, which can be reclaimed when it is completely idle. Since the target space block is contiguous and its preset capacity is greater than the size corresponding to the data size level, a larger contiguous space can be allocated to the data. In this way, a larger contiguous space can also be reclaimed during reclamation, thereby reducing disk fragmentation and improving disk read and write performance.
[0106] In some embodiments, the device 800 further includes:
[0107] The recording module is used to record the write position of the target data as an idle position after the target data is deleted.
[0108] The reuse module is used to write the new data into the free space within the target space block if it receives a write instruction for new data and the size level of the new data is the same as the target level.
[0109] In this embodiment, writing new data to an idle location can improve space utilization and avoid resource waste.
[0110] In some embodiments, the device 800 further includes:
[0111] The allocation module is used to allocate a new space block corresponding to the target level and write the new data into the new space block if the target space block is full and a write instruction for new data at the target level is received; the new space block is a contiguous space of a preset capacity within the disk.
[0112] In this embodiment, by allocating new space blocks, the successful writing of new data can be guaranteed, thereby improving disk performance.
[0113] In some embodiments, the device 800 further includes:
[0114] The moving module is used to move the remaining data to the same spatial block if the target level corresponds to other spatial blocks and the remaining data in the target spatial block and the other spatial blocks meet preset conditions.
[0115] In this embodiment, by moving the remaining data in multiple space blocks to the same space block, the data concentration can be improved. After the move, the completely idle space blocks are reclaimed, reducing disk fragmentation and improving disk read / write performance.
[0116] In some embodiments, the device 800 further includes:
[0117] An adjustment module is used to adjust the pre-allocated space block from the preset capacity to the target capacity if there is already a pre-allocated space block corresponding to another level and no data write instruction for the other level has been received, and the target capacity is less than the preset capacity.
[0118] In this embodiment, resource utilization can be improved by reducing the capacity of the pre-allocated space that is not actually used.
[0119] It is understood that the same or similar content in different embodiments of this disclosure can be referred to each other.
[0120] It is understood that the terms "first" and "second" in the embodiments of this disclosure are only used for distinction and do not indicate the degree of importance or the order of events.
[0121] It is understandable that, unless otherwise specified, the order of steps in the process indicates that the temporal relationship between these steps is not limited.
[0122] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0123] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0124] Figure 9 A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device 900 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0125] like Figure 9 As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded into a random access memory (RAM) 903 from a storage unit 908. The RAM 903 may also store various programs and data required for the operation of the electronic device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0126] Multiple components in electronic device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of displays, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows electronic device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0127] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as disk space management methods. For example, in some embodiments, the disk space management method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of the disk space management method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform disk space management methods by any other suitable means (e.g., by means of firmware).
[0128] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0129] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable task processing device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0130] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0132] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0133] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0134] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0135] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A disk space management method, comprising: In response to a write command for target data, the target data is written into the location range of the target space block corresponding to the target level of the target data. The size of the location range is the same as the target level, and target data of different levels of the same target level is written into different location ranges. The target space block is a contiguous space of a preset capacity within the disk, and the preset capacity is greater than the size corresponding to the target level; wherein, each level is a power of 2; the target level is the level that is greater than or equal to the target data size and is closest to the target data size; the pre-allocated preset capacity corresponding to different target levels is the same; In response to a deletion instruction for the target data, the target data is deleted from the target space block; After all the target data has been deleted, the target space block is reclaimed; If a pre-allocated space block corresponding to another level already exists, and no data write instruction for that other level has been received, the pre-allocated space block is adjusted from the preset capacity to the target capacity, and the target capacity is less than the preset capacity; If, after capacity adjustment, data of the corresponding level is received, the data in multiple target capacity space blocks is moved to the preset capacity space block through a rewrite operation.
2. The method according to claim 1, further comprising: After the target data is deleted, the location where the target data was written is recorded as an empty location. If a write instruction for new data is received, and the size level of the new data is the same as the target level, the new data is written to the free location within the target space block.
3. The method according to claim 1, further comprising: If the target space block is full and a write instruction for new data at the target level is received, a new space block corresponding to the target level is allocated, and the new data is written to the new space block; the new space block is a contiguous space of a preset capacity within the disk.
4. The method according to claim 1, further comprising: If the target level corresponds to other spatial blocks, and the remaining data in the target spatial block and the other spatial blocks meet the preset conditions, the remaining data is moved to the same spatial block.
5. A disk space management device, comprising: The writing module is used to respond to a writing instruction for target data and write the target data into the location interval of the target space block corresponding to the target level of the target data. The size of the location interval is the same as the target level, and different levels of target data of the same target level are written into different location intervals. The target space block is a contiguous space of a preset capacity within the disk, and the preset capacity is greater than the size corresponding to the target level; wherein, each level is a power of 2; the target level is the level that is greater than or equal to the target data size and is closest to the target data size; the pre-allocated preset capacity corresponding to different target levels is the same; A deletion module is configured to delete the target data in the target space block in response to a deletion command for the target data; The recycling module is used to reclaim the target space block after all the target data has been deleted; An adjustment module is configured to, if a pre-allocated space block corresponding to another level already exists and no data write instruction for that other level has been received, adjust the pre-allocated space block from the preset capacity to a target capacity, wherein the target capacity is less than the preset capacity; and, if, after the capacity adjustment, data of the corresponding level is received, move the data in multiple space blocks of the target capacity to the space block of the preset capacity through a rewrite operation.
6. The apparatus according to claim 5, further comprising: The recording module is used to record the write position of the target data as an idle position after the target data is deleted. The reuse module is used to write the new data into the free space within the target space block if it receives a write instruction for new data and the size level of the new data is the same as the target level.
7. The apparatus according to claim 5, further comprising: The allocation module is used to allocate a new space block corresponding to the target level and write the new data into the new space block if the target space block is full and a write instruction for new data at the target level is received; the new space block is a contiguous space of a preset capacity within the disk.
8. The apparatus according to claim 5, further comprising: The moving module is used to move the remaining data to the same spatial block if the target level corresponds to other spatial blocks and the remaining data in the target spatial block and the other spatial blocks meet preset conditions.
9. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-4.
11. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-4.