Disk arrangement method and device, electronic equipment and storage medium

By dividing the disk into two types of storage spaces, counting and dividing data, and prioritizing the storage space that is easy to modify data, the problem of low disk consolidation efficiency under the writeappend mechanism is solved, improving the sorting efficiency and reducing the impact on business performance.

CN120215818APending Publication Date: 2025-06-27CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510151316.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-11
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In the storage system, the writeappend mechanism causes the data to be modified and deleted not to be recycled, causing the disk consolidation process to consume a large amount of resources and affect the foreground business access performance.

Method used

The target disk is divided into at least two types of storage spaces, and the number of times the data in the target volume is written within the preset time is counted. According to the statistical results, it is divided into two types of data, and stored separately according to the volume and capacity. In response to the satisfaction of the preset conditions, disk consolidation of the storage space of a type of data is preferred.

Benefits of technology

Improve disk consolidation efficiency, reduce the impact on business performance, and significantly narrow the scope of disk consolidation through partition storage and priority sorting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120215818A_ABST
    Figure CN120215818A_ABST
Patent Text Reader

Abstract

The invention relates to a disk arrangement method and device, electronic equipment and a storage medium, and relates to the field of data storage. The method comprises the following steps: dividing a target disk into at least two types of storage spaces; counting the writing times of the data in the target volume within a preset duration, and dividing the data into two types according to a counting result and a preset times threshold value; according to the volumes of the two types of data and the capacity of each storage space, storing the two types of data into at least two types of storage spaces respectively; and in response to the condition that a preset disk arrangement condition is met, preferentially carrying out disk arrangement on the storage space of one type of data. By applying the method, the disk sorting efficiency can be improved, and the influence on service performance is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data storage, and in particular, to a disk defragmentation method, apparatus, electronic device, and storage medium. Background Art

[0002] In a storage system, the write-append mechanism has been a commonly used data storage method. Write-append usually appends data to the end of the existing data on the storage medium instead of overwriting or replacing the original data. Especially for mechanical hard disks, it can significantly improve the read and write efficiency of the hard disk. However, for the write-append mechanism, when data is modified, overwritten, or deleted, the space is not really reclaimed. Often, a background garbage collection process needs to be started to collect the garbage in the previous data and free up a relatively complete space for subsequent data writing. The data defragmentation process consumes a large amount of disk resources and affects the performance of foreground service access. Summary of the Invention

[0003] Embodiments of the present disclosure provide a disk defragmentation method, apparatus, electronic device, and storage medium.

[0004] In a first aspect, embodiments of the present disclosure provide a disk defragmentation method, including: dividing a target disk into at least two types of storage spaces; counting the number of write times of data in a target volume within a preset time period, and dividing the data into two types according to the statistical result and a preset number threshold; storing the two types of data into at least two types of storage spaces respectively according to the volume of the two types of data and the capacity of each storage space; and in response to a preset disk defragmentation condition being satisfied, preferentially performing disk defragmentation on the storage space of one of the two types of data.

[0005] In a second aspect, embodiments of the present disclosure provide a disk defragmentation apparatus, including: a disk division unit configured to divide a target disk into at least two types of storage spaces; a data division unit configured to count the number of write times of data in a target volume within a preset time period, and divide the data into two types according to the statistical result and a preset number threshold; a data storage unit configured to store the two types of data into at least two types of storage spaces respectively according to the volume of the two types of data and the capacity of each storage space; and a disk defragmentation unit configured to, in response to a preset disk defragmentation condition being satisfied, preferentially perform disk defragmentation on the storage space of one of the two types of data.

[0006] In a third aspect, embodiments of the present disclosure provide an electronic device, including a memory, a processor, a bus, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the disk defragmentation method described in the first aspect is implemented.

[0007] Fourthly, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the disk defragmentation method described in the first aspect is implemented.

[0008] By applying the technical solution of the present disclosure, the target disk can be divided into at least two types of storage spaces, and at the same time, the write times of the data in the target volume are counted to determine the easily modified data and the not easily modified data. The easily modified data and the not easily modified data are stored in different storage spaces respectively, and when the disk defragmentation condition is met, the storage space storing one type of data is preferentially defragmented, thereby improving the disk defragmentation efficiency and reducing the impact on the service performance.

[0009] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The drawings are used to better understand the solution and do not constitute a limitation to the present disclosure. Among them:

[0011] Figure 1 FIG. is an exemplary system architecture diagram to which an embodiment of the disk defragmentation method of the present disclosure can be applied;

[0012] Figure 2 FIG. is a flowchart of an embodiment of the disk defragmentation method of the present disclosure;

[0013] Figure 3 FIG. is a flowchart of another embodiment of the disk defragmentation method of the present disclosure;

[0014] Figure 4 FIG. is a schematic diagram of storing data in the existing method and the disk defragmentation method of the present disclosure;

[0015] Figure 5 FIG. is a schematic diagram of disk defragmentation in the existing method and the disk defragmentation method of the present disclosure;

[0016] Figure 6 FIG. is a schematic structural diagram of an embodiment of the disk defragmentation apparatus of the present disclosure;

[0017] Figure 7 FIG. is a schematic structural diagram of an embodiment of the electronic device of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0018] It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present disclosure belongs.

[0019] It should be noted that the terms used herein are for the purpose of describing particular embodiments only and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular forms are also intended to include the plural forms. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they specify the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0020] In the case of no conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.

[0021] In order to make the technical solutions and advantages of the present disclosure more clearly understood, the following further describes the present disclosure in detail with reference to the accompanying drawings and specific embodiments.

[0022] Figure 1 An exemplary system architecture 100 is shown that can apply the embodiments of the disk defragmentation method or disk defragmentation device of the present disclosure.

[0023] As Figure 1 shown, the system architecture 100 may include a data source 101, a server 102, a network 103, and a data storage device 104. The network 103 is used to provide a medium for communication links between the data source 101, the server 102, and the data storage device 104. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0024] Various types of data may be stored in the data source 101. For example, it may be data generated by users on certain applications, or data stored by users in cloud storage, etc.

[0025] The server 102 may operate on the data in the data source 101, such as reading, writing, deleting, modifying, etc. The server 102 may also store the data in the data source 101 into the data storage device 104.

[0026] The data storage device 104 may be a hardware device for storing the data in the data source 101, and it may include, but is not limited to: external hard drives, mechanical hard drives, solid state drives, MP3s, MP4s, USB flash drives, flash memory cards, etc.

[0027] It should be noted that the disk defragmentation method provided by the embodiments of the present disclosure is generally executed by the server 102. Correspondingly, the disk defragmentation device is generally disposed in the server 102.

[0028] It should be understood that Figure 1 the numbers of the terminal devices, networks, and servers in are merely illustrative. According to the implementation requirements, there may be any number of terminal devices, networks, and servers.

[0029] Figure 2 The flowchart 200 of an embodiment of the disk defragmentation method according to the present disclosure is shown. As Figure 2 shown, the disk defragmentation method of this embodiment may include the following steps:

[0030] Step 201, divide the target disk into at least two types of storage spaces.

[0031] In this embodiment, the execution entity of the disk defragmentation method (such as Figure 1 the server 102 shown) may divide the target disk into at least two types of storage spaces. Here, the target disk may be hardware for storing data. The capacities of the storage spaces may be the same or different.

[0032] Step 202, count the number of write times of the data in the target volume within a preset time period, and divide the above data into two categories according to the statistical result and a preset number threshold.

[0033] The execution entity may also count the number of write times of the data in the target volume within a preset time period. The above preset time period may be one week, one month, etc. It can be understood that the more the number of write times, the easier it is for this part of the data to be modified. The statistical result may be compared with the preset number threshold, and the data greater than or equal to the preset number threshold may be divided into one category, and the data less than the preset number threshold may be divided into one category. In some specific practices, the target volume may be divided, and the number of write times of the data in each divided block within a preset time period may be counted. For example, if the capacity of a volume is 100 GB, it may be divided into several blocks with a capacity of 10 M. Count the number of write times of each block in the past week.

[0034] Step 203, according to the volume of the two types of data and the capacities of the storage spaces, store the two types of data into at least two types of storage spaces respectively.

[0035] After the data is divided into two categories, the volume of each category of data may be determined. Combining the capacities of the storage spaces, the above two types of data are stored into at least two types of storage spaces respectively. Specifically. If the volume of one type of data is 3 GB and the capacity of the storage space is 5 GB, then this type of data can be stored in this storage space. If the volume of one type of data is 9 GB and the capacity of the storage space is 5 GB, then this type of data needs to be stored in two storage spaces.

[0036] Step 204, in response to the satisfaction of a preset disk defragmentation condition, preferentially defragment the storage space of one type of data.

[0037] After the data storage is completed, it is possible to monitor whether the preset disk defragmentation conditions are met. Here, the preset disk defragmentation conditions may include, but are not limited to: a preset time period has passed since the last disk defragmentation, the disk capacity is less than a preset threshold, a disk defragmentation instruction is received, and so on. If the preset disk defragmentation conditions are met, then it is possible to preferentially defragment the storage space of one type of data. Specifically, it is possible to preferentially defragment the storage space of the type of data with a higher write count.

[0038] The disk defragmentation method provided by the above embodiments of the present disclosure can divide the target disk into at least two types of storage spaces, simultaneously count the write counts of the data in the target volume, determine the easily modified data and the not easily modified data, store the easily modified data and the not easily modified data in different storage spaces respectively, and when the disk defragmentation conditions are met, preferentially defragment the storage space storing one type of data, thereby improving the disk defragmentation efficiency and reducing the impact on the service performance.

[0039] Continue to refer to Figure 3 which shows the flow 300 of another embodiment of the disk defragmentation method according to the present disclosure. As Figure 3 shown, the method in this embodiment may include the following steps:

[0040] Step 301, divide the target disk into at least two types of storage spaces according to a preset capacity.

[0041] In this embodiment, the target disk can be divided into at least two types of storage spaces according to a preset capacity. Specifically, the preset capacity can be set according to the actual application scenario, for example, it can be 10 GB.

[0042] Step 302, count the write counts of the data in the target volume within a preset time period, and determine the data with a write count greater than or equal to a preset count threshold as easily modified data; determine the data with a write count less than the preset count threshold as not easily modified data.

[0043] In this embodiment, the write counts of the data in the target volume within a preset time period are counted and compared with the preset count threshold. If the write count is greater than or equal to the preset count threshold, then the data is determined as easily modified data. If the write count is less than the preset count threshold, then the data is determined as not easily modified data.

[0044] Step 303, for the easily modified data or the not easily modified data, if its volume is less than or equal to the capacity of each storage space, arbitrarily select one storage space from at least two types of storage spaces to store the data; if its volume is greater than the capacity of each storage space, select at least two types of storage spaces from at least two types of storage spaces to store this type of data, so that the capacity of the selected storage space is greater than the volume of this type of data.

[0045] When storing data, for data that is easy to modify or not easy to modify, if its volume is less than or equal to the capacity of each storage space, it means that the storage space can completely store this type of data. Then, any one of the storage spaces obtained by partitioning can be selected to store this type of data. It can be understood that if the capacities of the storage spaces are different, one with a capacity greater than the volume of this type of data can be selected to store this type of data. If the volume of this type of data is greater than the capacity of each storage space, at least two types of storage spaces need to be selected from the storage spaces to store this type of data. It should be noted that the capacities of the at least two types of storage spaces selected need to be greater than the volume of this type of data.

[0046] Step 304, during the process of storing data that is easy to modify or not easy to modify, if the capacity of the storage space for storing this type of data is insufficient, select a storage space from the idle storage spaces to continue storing this type of data.

[0047] Among the storage spaces obtained by partitioning, one of the storage spaces can be used to store data that is easy to modify first, and another storage space can be used to store data that is not easy to modify. The remaining storage spaces are not allocated temporarily. During the process of storing data that is easy to modify or not easy to modify, if the capacity of the storage space for storing this type of data is insufficient, a storage space can be selected from the idle storage spaces to continue storing this type of data.

[0048] Step 305, in response to the satisfaction of a preset disk defragmentation condition, preferentially perform disk defragmentation on the storage space for storing data that is easy to modify.

[0049] If the preset disk defragmentation condition is satisfied, perform disk defragmentation on the storage space for storing data that is easy to modify. Since most modifications occur in the storage space for data that is easy to modify, only these storage spaces need to be defragmented. The storage space for data that is not easy to modify has a small number of write operations, and the amount of garbage generated is small, or even no garbage, so it does not need to participate in disk defragmentation. During the process of performing disk defragmentation on the storage space, the data can be moved to continuous positions within the storage space, so as to free up a relatively large amount of idle space within the storage space.

[0050] In some alternative implementation manners of this embodiment, when performing disk defragmentation on the storage space for storing data that is easy to modify, the data that is easy to modify in each storage space can be moved to the idle storage space, so that the storage space storing the data that is easy to modify can be sorted out and redistributed during the data storage process.

[0051] See Figure 4, which shows a comparison schematic diagram of the existing disk defragmentation method and the disk defragmentation method adopting the present disclosure. It can be seen from the comparison that in the existing disk defragmentation method, the easily modified data and the not easily modified data are stored crosswise. While in the disk defragmentation method of the present disclosure, the easily modified data and the not easily modified data can be stored separately. When performing disk defragmentation, the existing method needs to defragment the entire disk. While the disk defragmentation method of the present disclosure only needs to defragment the storage space for storing the easily modified data (see Figure 5 ).

[0052] The disk defragmentation method provided by the above embodiments of the present disclosure, by performing write count statistics on the data in the target volume and dividing the hard disk area, concentrates the data that is easily modified in a limited area. In the subsequent space defragmentation process, the scope of space defragmentation is greatly reduced, the defragmentation efficiency is improved, and the impact on the foreground service is reduced.

[0053] Further referring to Figure 6 , as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a disk defragmentation device. This device embodiment corresponds to the Figure 2 shown method embodiment, and this device can be specifically applied to various electronic devices.

[0054] As shown in Figure 6 , the disk defragmentation device 600 of this embodiment includes: a disk partitioning unit 601, a data partitioning unit 602, a data storage unit 603, and a disk defragmentation unit 604.

[0055] The disk partitioning unit 601 is configured to partition the target disk into at least two types of storage spaces.

[0056] The data partitioning unit 602 is configured to count the write times of the data in the target volume within a preset time period, and divide the data into two types according to the statistical result and a preset number threshold.

[0057] The data storage unit 603 is configured to store the two types of data into at least two types of storage spaces respectively according to the volume of the two types of data and the capacity of each storage space.

[0058] The disk defragmentation unit 604 is configured to, in response to the satisfaction of a preset disk defragmentation condition, preferentially defragment the storage space of one of the types of data.

[0059] In addition, in the technical solution of the present application, an electronic device is also proposed.

[0060] Figure 7 shows a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.

[0061] As shown in Figure 7As shown, the electronic device may include a processor 701, a memory 702, a bus 703, and a computer program stored on the memory 702 and executable on the processor 701. Among them, the processor 701 and the memory 702 communicate with each other through the bus 703. When the processor 701 executes the computer program, the steps of the above method are implemented, for example, including: dividing the target disk into at least two types of storage spaces; counting the number of write operations of the data in the target volume within a preset time period, and dividing the data into two types according to the statistical result and a preset number threshold; storing the two types of data into at least two types of storage spaces respectively according to the volume of the two types of data and the capacity of each storage space; in response to the satisfaction of a preset disk defragmentation condition, preferentially performing disk defragmentation on the storage space of one of the types of data.

[0062] In addition, in an embodiment of the present disclosure, a non-transitory computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented, for example, including: dividing the target disk into at least two types of storage spaces; counting the number of write operations of the data in the target volume within a preset time period, and dividing the data into two types according to the statistical result and a preset number threshold; storing the two types of data into at least two types of storage spaces respectively according to the volume of the two types of data and the capacity of each storage space; in response to the satisfaction of a preset disk defragmentation condition, preferentially performing disk defragmentation on the storage space of one of the types of data.

[0063] In summary, in the technical solution of the present disclosure, the target disk can be divided into at least two types of storage spaces, and at the same time, the number of write operations of the data in the target volume is counted to determine the hot data and non-hot data, and the hot data and non-hot data are stored in different storage spaces respectively. When the disk defragmentation condition is satisfied, the storage space of one of the types of data is preferentially defragmented, thereby improving the disk defragmentation efficiency and reducing the impact on the service performance.

[0064] The above are only the preferred embodiments of the present disclosure and are not intended to limit the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present disclosure shall be included within the scope of protection of the present disclosure.

Claims

1. A disk defragmentation method, comprising: Divide the target disk into at least two types of storage space; Counting the number of writes of the data in the target volume within a preset time period, and dividing the data into two categories according to the statistical result and a preset number threshold; According to the volume of the two types of data and the capacity of each storage space, the two types of data are stored in the at least two types of storage spaces respectively; In response to a preset disk defragmentation condition being met, the storage space of one type of data is preferentially defragmented.

2. The method according to claim 1, wherein: The step of dividing the target disk into at least two types of storage space includes: According to the preset capacity, the target disk is divided into at least two types of storage space.

3. The method according to claim 2, wherein: According to the statistical results and the preset number threshold, the data is divided into two categories, including: Determine data having a write count greater than or equal to the preset write count threshold as easily modifiable data; The data having a write count less than the preset count threshold is determined as data that is not easy to modify.

4. The method according to claim 3, wherein: According to the volume of the two types of data and the capacity of the at least two types of storage space, the two types of data are stored in the at least two types of storage space respectively, including: For the easily modifiable data or the non-modifiable data, if the volume thereof is less than or equal to the capacity of each storage space, any one storage space is selected from the at least two types of storage spaces to store the data; If the volume is larger than the capacity of each storage space, at least two types of storage space are selected from the at least two types of storage space to store this type of data, so that the capacity of the selected storage space is larger than the volume of this type of data.

5. The method according to claim 4, wherein: The method further comprises: In the process of storing the easily modifiable data or the non-modifiable data, if the capacity of the storage space for storing such data is insufficient, a storage space is selected from the free storage spaces to continue storing such data.

6. The method according to claim 4, wherein: In response to the preset disk defragmentation condition being met, defragmenting the storage space of one type of data includes: In response to the preset disk defragmentation condition being met, the storage space storing the easily modifiable data is defragmented.

7. The method according to claim 6, wherein: The disk defragmentation of the storage space storing easily modifiable data includes: The easily modifiable data is moved to a free storage space.

8. A disk defragmentation device, comprising: A disk partitioning unit configured to partition the target disk into at least two types of storage spaces; The data division unit is configured to count the number of write times of the data in the target volume within a preset time length, and divide the data into two categories according to the statistical result and a preset number threshold; A data storage unit is configured to store the two types of data in the at least two types of storage spaces respectively according to the volume of the two types of data and the capacity of each storage space; The disk defragmentation unit is configured to preferentially defragment the storage space of one type of data in response to the preset disk defragmentation condition being met.

9. An electronic device comprising a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the disk defragmentation method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the disk defragmentation method according to any one of claims 1 to 7 is implemented.