Self-adaptive disk allocation and defragmentation system, method and equipment and storage medium
Through the adaptive disk allocation and defragmentation system, the problems of disk defragmentation and metadata errors are solved, adaptive disk space allocation and efficient defragmentation are realized, and the needs of subsequent disk allocation are met.
Patent Information
- Application Number
- CN202411794382.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-05-09
AI Technical Summary
The prior art is difficult to effectively handle the problem of large amounts of fragmentation on disk and errors in storage device metadata, especially the lack of adaptive adjustment of disk processing and defragmentation methods.
Provides an adaptive disk allocation and defragmentation system, including a disk allocation module, a metadata module and a defragmentation module. Through disk allocation and metadata management based on preset thresholds, we can determine whether the current page of disk space has been allocated, and defragment it when necessary to organize large blocks of free space.
It effectively solves the problem of large amounts of fragmentation and storage device metadata errors in disks. Through adaptive disk allocation and defragmentation, disk space is allocated adaptively and large blocks of free space are sorted out under high fragmentation conditions, meeting subsequent disk allocation requirements.
Smart Images

Figure CN119960667A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed storage technology, and in particular to an adaptive disk allocation and fragmentation system, method, device and storage medium. Background Art
[0002] With the rapid development of the big data era, the amount of stored data has exploded. This has put forward higher requirements and challenges for the systems and methods of ceph devices. Currently, when the database utilization rate reaches 90%, a large amount of disk fragmentation occurs and errors occur in the metadata of the storage device.
[0003] In the related technology, the existing methods cannot deal well with the problem of large amounts of disk fragments and errors in storage device metadata. There is little mention of the method of triggering defragmentation by searching for continuous space by page + locking the current page. In particular, there is a lack of adaptive disk processing and defragmentation methods after metadata writing errors. Summary of the invention
[0004] In view of this, the present invention provides an adaptive disk allocation and defragmentation system, method, device and storage medium to solve the problem of large amounts of fragments on the hard-to-handle disk and errors in metadata of the storage device.
[0005] In a first aspect, the present invention provides an adaptive disk allocation and defragmentation system, the system comprising: a disk allocation module, a metadata module and a defragmentation module:
[0006] The disk allocation module is used to determine whether the log to be allocated is allocated to the disk space that meets the preset conditions based on the preset threshold when receiving the log to be allocated; when the log to be allocated is allocated to the disk space that meets the preset conditions, allocate the log to the disk space that meets the preset conditions;
[0007] The metadata module is used to store the length and offset of the disk space when the log to be allocated is allocated to the disk space that meets the preset conditions;
[0008] The defragmentation module is used to determine whether the current page of the disk space has been fully allocated based on the length and offset of the disk space; when the current page of the disk space has been fully allocated, the disk space is defragmented to obtain the defragmented disk space;
[0009] The disk allocation module is also used to allocate the logs to be allocated to the organized disk space.
[0010] In the present invention, when the metadata space is fixed and the disk blocks within the space allocation threshold key number range are determined, an adaptive disk allocation and defragmentation system, including a disk allocation module, a metadata module and a defragmentation module, is used to allocate qualified disk space in combination with disk defragmentation, and it is adapted to allocate disk space and defragment when there are too many disk fragments to meet the subsequent disk allocation requirements. Large blocks of free space are sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to avoid the inability to continue the operation, and the problem of a large number of fragments on the disk and errors in the metadata of the storage device is solved.
[0011] In an optional embodiment, the disk allocation module is also used to move the starting address of the current disk space allocation to the end address of the last allocated disk space when the log to be allocated is not allocated to the disk space that meets the preset conditions, until the log to be allocated is allocated to the disk space that meets the preset conditions.
[0012] In this method, the starting address of the current disk space allocation is moved to the end address of the last allocated disk space through the disk allocation module. When the metadata size is fixed, the qualified disk space is allocated in combination with disk defragmentation to meet certain specific needs.
[0013] In an optional embodiment, the defragmentation module is used to query the allocated disk blocks from the front end of the current page of the disk space, query the unallocated disk blocks from the back end of the current page of the disk space, exchange the allocated disk blocks with the unallocated disk blocks, and obtain the defragmented disk space.
[0014] In this method, the defragmentation module queries the allocated disk blocks from the front end of the current page of the disk space, queries the unallocated disk blocks from the back end of the current page of the disk space, and exchanges the allocated disk blocks with the unallocated disk blocks. When the disk space is almost full, large blocks of free space can be sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to avoid the operation being unable to continue.
[0015] In an optional implementation, the system further includes a disk management module for managing the disk space using a bitmap, setting allocated disk blocks to 1 and unallocated disk blocks to 0.
[0016] In this method, the disk space is managed by the disk management module using a bitmap, the allocated disk blocks are set to 1, and the unallocated disk blocks are set to 0, thereby identifying whether the disk blocks are occupied and facilitating the management of the disk space.
[0017] In a second aspect, the present invention provides an adaptive disk allocation and defragmentation method, which is applied to an adaptive disk allocation and defragmentation system as described in any one of the first aspects, wherein the system comprises: a disk allocation module, a metadata module and a defragmentation module, and the method comprises:
[0018] Get the logs to be allocated;
[0019] Based on the preset threshold, determine whether the log to be allocated is allocated to the disk space that meets the preset conditions;
[0020] When the log to be allocated is allocated to the disk space that meets the preset conditions, the length and offset of the disk space are stored;
[0021] Based on the length and offset of the disk space, determine whether the current page of the disk space has been fully allocated;
[0022] When the current page of the disk space has been fully allocated, the disk space is defragmented to obtain a defragmented disk space;
[0023] Allocate the logs to be allocated to the organized disk space.
[0024] In the present invention, when the metadata space is fixed and the disk blocks within the space allocation threshold key number range are determined, the adaptive disk allocation and defragmentation system is combined with disk defragmentation to allocate qualified disk space, adapt to allocating disk space and defragmenting when there are too many disk fragments to meet the subsequent disk allocation requirements. Large blocks of free space are sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to avoid the inability to continue the operation, which solves the problem of a large number of fragments on the disk and errors in the metadata of the storage device.
[0025] In an optional implementation, when the log to be allocated is not allocated to a disk space that meets the preset conditions, the starting address of the current disk space allocation is moved to the end address of the last allocated disk space until the log to be allocated is allocated to a disk space that meets the preset conditions.
[0026] In this method, the starting address of the current disk space allocation is moved to the end address of the last allocated disk space. When the metadata size is fixed, qualified disk space is allocated in combination with disk defragmentation to meet certain specific needs.
[0027] In an optional implementation, defragmenting the disk space to obtain the defragmented disk space includes:
[0028] The allocated disk blocks are queried from the front end of the current page of the disk space, and the unallocated disk blocks are queried from the back end of the current page of the disk space. The allocated disk blocks are exchanged with the unallocated disk blocks to obtain the organized disk space.
[0029] In this method, the allocated disk blocks are queried from the front end of the current page of the disk space, and the unallocated disk blocks are queried from the back end of the current page of the disk space. The allocated disk blocks are exchanged with the unallocated disk blocks. When the disk space is almost full, large blocks of free space can be sorted out by exchanging free blocks and data blocks. There is no need to copy the data to continuous large blocks of space first to prevent the operation from being unable to continue.
[0030] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the adaptive disk allocation and defragmentation method of the above-mentioned second aspect or any corresponding embodiment thereof by executing the computer instructions.
[0031] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the adaptive disk allocation and defragmentation method of the second aspect or any corresponding embodiment thereof.
[0032] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the adaptive disk allocation and defragmentation method of the second aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 is a schematic diagram of the structure of an adaptive disk allocation and defragmentation system according to an embodiment of the present invention.
[0035] Figure 2 is a processing flow chart of a ceph-based adaptive disk allocation and defragmentation system according to an embodiment of the present invention
[0036] Figure 3 Schematic diagram of disk space allocation and defragmentation according to an embodiment of the present invention.
[0037] Figure 4 The figure is a flow chart of an adaptive disk allocation and defragmentation method according to an embodiment of the present invention.
[0038] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0040] In the related technology, the existing methods cannot deal well with the problem of large amounts of disk fragments and errors in storage device metadata. There is little mention of the method of triggering defragmentation by searching for continuous space by page + locking the current page. In particular, there is a lack of adaptive disk processing and defragmentation methods after metadata writing errors.
[0041] To solve the above problems, an adaptive disk allocation and defragmentation system is provided in an embodiment of the present invention. The adaptive disk allocation and defragmentation system in this embodiment is suitable for adaptively allocating disk space when the metadata space is fixed and the number of disk blocks within the space allocation threshold key range is determined, and defragmenting when there are too many disk fragments to meet the use scenario of subsequent disk allocation requirements. The adaptive disk allocation and defragmentation system provided by the present invention, when the metadata space is fixed and the number of disk blocks within the space allocation threshold key range is determined, the adaptive disk allocation and defragmentation system includes a disk allocation module, a metadata module and a defragmentation module, and combines disk defragmentation to allocate qualified disk space, and is adapted to allocating disk space and defragmenting when there are too many disk fragments to meet the subsequent disk allocation requirements. Large blocks of free space are sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to prevent the operation from being unable to continue, and the problem of a large number of fragments on the disk and errors in the metadata of the storage device is solved.
[0042] According to an embodiment of the present invention, an adaptive disk allocation and defragmentation system embodiment is provided. Figure 1 is a schematic diagram of the structure of an adaptive disk allocation and defragmentation system according to an embodiment of the present invention. Figure 1As shown, the system includes: a disk allocation module 1, a metadata module 2 and a defragmentation module 3: the disk allocation module 1 is used to determine whether the log to be allocated is allocated to the disk space that meets the preset conditions based on a preset threshold when receiving the log to be allocated; when the log to be allocated is allocated to the disk space that meets the preset conditions, the log to be allocated is allocated to the disk space that meets the preset conditions; the metadata module 2 is used to store the length and offset of the disk space when the log to be allocated is allocated to the disk space that meets the preset conditions; the defragmentation module 3 is used to determine whether the current page of the disk space has been fully allocated based on the length and offset of the disk space; when the current page of the disk space has been fully allocated, the disk space is defragmented to obtain the defragmented disk space; the disk allocation module 1 is also used to allocate the log to be allocated to the defragmented disk space.
[0043] In an optional embodiment, the disk allocation module 1 is also used to move the starting address of the current disk space allocation to the end address of the last allocated disk space when the log to be allocated is not allocated to the disk space that meets the preset conditions, until the log to be allocated is allocated to the disk space that meets the preset conditions.
[0044] In this method, the starting address of the current disk space allocation is moved to the end address of the last allocated disk space through the disk allocation module. When the metadata size is fixed, the qualified disk space is allocated in combination with disk defragmentation to meet certain specific needs.
[0045] In an optional embodiment, the defragmentation module 3 is used to query the allocated disk blocks from the front end of the current page of the disk space, query the unallocated disk blocks from the back end of the current page of the disk space, exchange the allocated disk blocks with the unallocated disk blocks, and obtain the defragmented disk space.
[0046] In this method, the defragmentation module queries the allocated disk blocks from the front end of the current page of the disk space, queries the unallocated disk blocks from the back end of the current page of the disk space, and exchanges the allocated disk blocks with the unallocated disk blocks. When the disk space is almost full, large blocks of free space can be sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to avoid the operation being unable to continue.
[0047] In an optional implementation, the system further includes a disk management module 4 for managing the disk space using a bitmap, setting allocated disk blocks to 1 and unallocated disk blocks to 0.
[0048] In this method, the disk space is managed by the disk management module using a bitmap, the allocated disk blocks are set to 1, and the unallocated disk blocks are set to 0, thereby identifying whether the disk blocks are occupied and facilitating the management of the disk space.
[0049] In one example, Figure 2 is a processing flow chart of a ceph-based adaptive disk allocation and defragmentation system according to an embodiment of the present invention, such as Figure 2 As shown in the figure, the processing flow of the adaptive disk allocation and defragmentation system caused by log compression is as follows: when the log starts to be compressed, a large space needs to be allocated to load the compressed new log, and the disk space not exceeding the threshold number of keys is allocated; if the space that meets the conditions is allocated, the offset and length of the space block are stored in the metadata; if the space that meets the conditions cannot be allocated, the starting address of the disk block allocation is moved to the end of the last allocation; repeat the second and third steps, if the space that meets the conditions is still not allocated after crossing to the second page, the previous page is locked to trigger defragmentation; use a bitmap to manage the disk, set the allocated space to 1, and the unallocated space to 0.
[0050] Figure 3 Schematic diagram of disk space allocation and defragmentation according to an embodiment of the present invention. Figure 3 As shown, disk space allocation and defragmentation can include: starting from the front of the page to find the used disk blocks, starting from the back of the page to find the free disk blocks, swapping them after finding them, and finally obtaining the disk page defragmented as shown in the figure below. Disk allocation starts from hint0. If the space that does not exceed the key value cannot be allocated, it will continue to allocate from the last allocation end position hint1 until the disk space that meets the conditions is allocated.
[0051] The adaptive disk allocation and defragmentation system provided in this embodiment allocates qualified disk space through the adaptive disk allocation and defragmentation system, including a disk allocation module, a metadata module and a defragmentation module, in combination with disk defragmentation, when the metadata space is fixed and the disk blocks within the range of the number of space allocation keys are determined, and is adapted to allocating disk space and defragmenting when there are too many disk fragments to meet subsequent disk allocation requirements. Large blocks of free space are sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to prevent the operation from continuing, which solves the problem of a large number of disk fragments and errors in the metadata of the storage device.
[0052] According to an embodiment of the present invention, an embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0053] In this embodiment, an adaptive disk allocation and defragmentation method is provided, which can be used in the above-mentioned mobile terminals, such as mobile phones, tablet computers, etc. Figure 4 FIG. 1 is a flow chart of an adaptive disk allocation and defragmentation method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0054] Step S401, obtaining the log to be allocated.
[0055] Step S402: Based on a preset threshold, determine whether the log to be allocated is allocated to a disk space that meets preset conditions.
[0056] Step S403, when the log to be allocated is allocated to the disk space that meets the preset conditions, the length and offset of the disk space are stored.
[0057] Step S404, when the log to be allocated is not allocated to the disk space that meets the preset conditions, the starting address of the current disk space allocation is moved to the end address of the last allocated disk space until the log to be allocated is allocated to the disk space that meets the preset conditions.
[0058] Step S405: Based on the length and offset of the disk space, determine whether the current page of the disk space has been fully allocated.
[0059] Step S406, when the current page of the disk space has been fully allocated, the disk space is defragmented to obtain a defragmented disk space.
[0060] In an optional implementation, defragmenting the disk space to obtain the defragmented disk space includes:
[0061] Step a1, query the allocated disk blocks from the front end of the current page of the disk space, query the unallocated disk blocks from the back end of the current page of the disk space, exchange the allocated disk blocks with the unallocated disk blocks to obtain the organized disk space.
[0062] Step S407, allocating the logs to be allocated to the organized disk space.
[0063] In one example, the processing flow of the adaptive disk allocation and defragmentation system caused by log compression is as follows: when the log starts to be compressed, a large space needs to be allocated to load the compressed new log, and the disk space not exceeding the threshold number of keys is allocated; if the space that meets the conditions is allocated, the offset and length of the space block are stored in the metadata; if the space that meets the conditions cannot be allocated, the starting address of the disk block allocation is moved to the end of the last allocation; repeat the second and third steps, if the space that meets the conditions is still not allocated after crossing to the second page, the previous page is locked to trigger defragmentation; use a bitmap to manage the disk, set the allocated space to 1, and the unallocated space to 0.
[0064] Disk space allocation and defragmentation can include: starting from the front of the page to find the used disk blocks, starting from the back of the page to find the free disk blocks, swapping them after finding them, and finally getting the disk page organized as shown in the figure below. Disk allocation starts from hint0. If the space that does not exceed the key value cannot be allocated, it will continue to allocate from the last allocation position hint1 until the disk space that meets the conditions is allocated.
[0065] The adaptive disk allocation and defragmentation method provided in this embodiment allocates qualified disk space through an adaptive disk allocation and defragmentation system in combination with disk defragmentation when the metadata space is fixed and the disk blocks within the range of the number of space allocation keys are determined, and is adapted to allocating disk space and defragmenting when there are too many disk fragments to meet subsequent disk allocation requirements. Large blocks of free space are sorted out by exchanging and sorting free blocks and data blocks, without involving the process of first copying data to continuous large blocks of space to prevent the operation from continuing, and solves the problem of a large number of disk fragments and errors in the metadata of the storage device.
[0066] The embodiment of the present invention also provides a computer device for executing the above Figure 5 The adaptive disk allocation and defragmentation method shown.
[0067] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0068] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0069] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0070] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0071] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0072] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0073] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0074] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0075] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0076] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. An adaptive disk allocation and defragmentation system, characterized in that: The system includes: a disk allocation module, a metadata module and a fragmentation module: The disk allocation module is used to determine whether the log to be allocated is allocated to the disk space that meets the preset conditions based on the preset threshold when receiving the log to be allocated; when the log to be allocated is allocated to the disk space that meets the preset conditions, allocate the log to the disk space that meets the preset conditions; The metadata module is used to store the length and offset of the disk space when the log to be allocated is allocated to the disk space that meets the preset conditions; The defragmentation module is used to determine whether the current page of the disk space has been fully allocated based on the length and offset of the disk space; when the current page of the disk space has been fully allocated, the disk space is defragmented to obtain a defragmented disk space; The disk allocation module is further used to allocate the logs to be allocated to the organized disk space.
2. The system according to claim 1, characterized in that The disk allocation module is also used to move the starting address of the current disk space allocation to the ending address of the last allocated disk space when the log to be allocated is not allocated to the disk space that meets the preset conditions, until the log to be allocated is allocated to the disk space that meets the preset conditions.
3. The system according to claim 1, characterized in that The defragmentation module is used to query the allocated disk blocks from the front end of the current page of the disk space, query the unallocated disk blocks from the back end of the current page of the disk space, and exchange the allocated disk blocks with the unallocated disk blocks to obtain a defragmented disk space.
4. The system according to claim 1, characterized in that The system also includes a disk management module, which is used to manage the disk space using a bitmap, set the allocated disk blocks to 1, and set the unallocated disk blocks to 0.
5. An adaptive disk allocation and defragmentation method, characterized in that: Applied to the adaptive disk allocation and defragmentation system according to any one of claims 1 to 4, the system comprises: a disk allocation module, a metadata module and a defragmentation module, the method comprises: Get the logs to be allocated; Based on a preset threshold, determining whether the log to be allocated is allocated to a disk space that meets preset conditions; When the log to be allocated is allocated to the disk space that meets the preset conditions, storing the length and offset of the disk space; Based on the length and offset of the disk space, determining whether the current page of the disk space has been fully allocated; When all current pages of the disk space have been allocated, defragmenting the disk space to obtain a defragmented disk space; Allocate the log to be allocated to the organized disk space.
6. The method according to claim 5, characterized in that When the log to be allocated is not allocated to the disk space that meets the preset conditions, the starting address of the current disk space allocation is moved to the end address of the last allocated disk space until the log to be allocated is allocated to the disk space that meets the preset conditions.
7. The method according to claim 5, characterized in that The defragmenting the disk space to obtain the defragmented disk space includes: The allocated disk blocks are queried from the front end of the current page of the disk space, and the unallocated disk blocks are queried from the back end of the current page of the disk space, and the allocated disk blocks are exchanged with the unallocated disk blocks to obtain the organized disk space.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the adaptive disk allocation and defragmentation method according to any one of claims 5 to 7 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the adaptive disk allocation and defragmentation method according to any one of claims 5 to 7.
10. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the adaptive disk allocation and defragmentation method according to any one of claims 5 to 7.
Citation Information
Patent Citations
Disk storage method and disk storage system
CN103425435A
Log storage method and device
CN104021088A
Disk space distribution method and device, storage device and storage medium
CN109977035A