Distributed storage system and garbage collection method in distributed storage system

By selecting storage nodes with a large amount of valid data as target nodes in the distributed storage system and performing internal data migration, the problem of network bandwidth waste caused by cross-node migration during garbage collection is solved, and the effect of saving bandwidth and computing resources is achieved.

CN113302597BActive Publication Date: 2025-09-12HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201980089025.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-23
Publication Date
2025-09-12
Estimated Expiration
2039-04-23

AI Technical Summary

Technical Problem

In a distributed storage system, migrating data across nodes during garbage collection consumes a lot of bandwidth resources, resulting in a waste of network bandwidth.

Method used

Select a storage node that stores a large amount of valid data as the target node, create a target logical unit, and migrate data within the target node to reduce cross-node data migration.

Benefits of technology

By migrating data within the target node, cross-node data migration is reduced, network bandwidth resources are saved, and the computing burden of the master node is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113302597B_ABST
    Figure CN113302597B_ABST
Patent Text Reader

Abstract

A distributed storage system, and a garbage collection method in a distributed storage system. A master node selects a target node from the multiple storage nodes based on the amount of valid data distributed in each storage node by a source logical unit, and the amount of first valid data stored in the target node exceeds a set quantity threshold. The master node creates a target logical unit, and the storage nodes to which the target logical unit is distributed include the target node. In other words, at least a portion of the storage space occupied by the target logical unit comes from the target node. Then, the master node instructs the target node to migrate the first valid data from a first source address to a first target address. The storage space indicated by the first source address is then released. The network bandwidth between storage nodes is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage, and more specifically, to a distributed storage system and a garbage collection method in the distributed storage system. Background Art

[0002] In a distributed storage system, data is usually written into the multiple storage nodes contained in the system by appending. Append writing is different from overwriting. When data is modified, the original data is not deleted immediately. Therefore, a large amount of garbage data will inevitably appear in the system (the modified data is valid data). In order to release the storage space occupied by garbage data, the system will perform garbage collection regularly. Garbage collection takes logical units as the object. Its specific process is to select a certain number of storage nodes in the distributed storage system, create new logical units in these storage nodes, and then write the valid data in the logical unit to be recycled into the new logical unit, and then release the storage space occupied by the logical unit to be recycled. Since the certain number of storage nodes where the new logical unit is located are usually randomly selected, these storage nodes are often different from the nodes where the storage node to be recycled is located. Then, in the process of rewriting valid data into the new logical unit, data forwarding between storage nodes is often involved, which will consume a lot of bandwidth resources. Summary of the Invention

[0003] The present application provides a distributed storage system and a garbage collection method in a distributed storage system, which can ensure that at least a portion of valid data is migrated in the same storage node, reducing cross-node data migration to a certain extent, thereby achieving the purpose of saving bandwidth.

[0004] A first aspect provides a garbage collection method in a distributed storage system, the distributed storage system comprising multiple storage nodes, one of which is a master node. In this method, the master node selects a target node from the multiple storage nodes based on the amount of valid data distributed by a source logical unit in each storage node, wherein the amount of first valid data stored in the target node exceeds a set threshold value. The master node creates a target logical unit, wherein the storage nodes to which the target logical unit is distributed include the target node. In other words, at least a portion of the storage space occupied by the target logical unit is from the target node. The master node then instructs the target node to migrate the first valid data from a first source address to a first target address. The first source address and the first target address are both actual addresses, and both are located within the target node. However, the storage space indicated by the first source address belongs to the source logical unit, and the storage space indicated by the first target address belongs to the target logical unit. After the master node confirms that all valid data in the source logical unit has been migrated to the target logical unit, the storage space occupied by the source logical unit is released. The storage space occupied by the source logic unit includes the storage space indicated by the first source address.

[0005] According to the garbage collection method provided in the first aspect, the storage node that stores more valid data among the source logical units is used as the target node, and the storage nodes distributed among the target logical units created by the master node include the target node. Therefore, the target node not only provides storage space for the source logical unit, but also provides storage space for the target logical unit. Then, in the process of migrating the valid data of the source logical unit, the master node can instruct the target node to migrate the first valid data from the first source address within the target node to the first target address within the target node. Since the first valid data is migrated within the target node, the forwarding of data between storage nodes is avoided to a certain extent, saving network bandwidth.

[0006] In a first implementation of the first aspect, before the master node instructs the target node to migrate the first valid data from a first source address within the target node to a first target address within the target node, the master node creates a migration list, the migration list including the first source address of the first valid data and the first target address of the first valid data. The master node then sends the migration list to the target node. The migration list may be created based on a minimum migration principle.

[0007] In combination with the first implementation of the first aspect, in the second implementation of the first aspect, the multiple storage nodes also include other storage nodes, and the other storage nodes are independent of the storage nodes where the target logical unit is distributed. The migration list also includes the second source address of the second valid data stored in the other storage nodes and the second target address of the second valid data, the second source address is located in the other storage node, and the second target address is located in the target node. The master node also sends the migration list to the other storage nodes. The other storage nodes are storage nodes that store less valid data among the source logical units distributed, and are not selected as target nodes, so no storage space is provided for the target logical unit. In this case, the other storage nodes need to migrate the second valid data stored in them to the target node. If there are multiple target nodes, they can be migrated to any target node. Alternatively, the other storage nodes can also migrate the second valid data to other nodes other than the target node where the target logical unit is located.

[0008] In conjunction with the first implementation of the first aspect, in a third implementation of the first aspect, the first source address and the first target address are both located on a first hard disk of the target node. In this case, the target node can send the first source address and the first target address to the first hard disk, and the first hard disk performs the migration operation, thereby reducing the burden on the processor of the target node.

[0009] In conjunction with the first implementation of the first aspect, in a fourth implementation of the first aspect, the first source address is located on a first hard disk of the target node, and the first target address is located on a second hard disk of the target node. In this case, the specific migration operation is that the processor of the target node reads the first valid data from the first source address into a cache, and then writes the first valid data from the cache to the first target address.

[0010] In combination with the first implementation of the first aspect, in the fourth implementation of the first aspect, the master node instructing the target node to migrate the first valid data from the first source address within the target node to the first target address within the target node includes the master node instructing the target node to migrate the first valid data from the first source address to the first target address based on the offset of the first valid data within the source logical unit, so that the offset of the first valid data within the target logical unit after the migration is the same as the offset of the first valid data within the source logical unit before the migration. According to this migration method, the position of the first valid data in the source logical unit is the same as the position of the first valid data in the target logical unit. If all the valid data contained in the first stripe where the first valid data is located is migrated in this way, the data slices contained in the first stripe will not change before and after the migration, so there is no need to recalculate the check slices, and the original check slices of the first stripe can be retained. This reduces the computational workload of the master node and saves computing resources.

[0011] In combination with the fourth implementation of the first aspect, in the fifth implementation of the first aspect, after all valid data in the source logical unit are migrated to the target logical unit and the storage space occupied by the source logical unit is released, the master node can modify the identifier of the target logical unit to the identifier of the source logical unit. Since the logical address of the data is composed of the identifier of the logical unit where the data is located and the offset within the logical unit. Because the target logical unit inherits the identifier of the source logical unit, and it can be seen from the fourth implementation that the position of the first valid data in the source logical unit is the same as the position in the target logical unit, the logical address of the first valid data does not change before and after the migration, thereby avoiding the modification of the metadata of the first valid data and the forwarding of the modified metadata between storage nodes, further saving network bandwidth.

[0012] The second aspect of the present application provides a master node, which is located in a distributed storage system, and the distributed storage system includes multiple storage nodes. The master node includes an interface and a processor, wherein the interface is used to communicate with the multiple storage nodes; the processor is used to execute any one of the implementations provided by the first aspect.

[0013] The third aspect of the present application provides a garbage collection device, which is located in a master node of a distributed storage system. The distributed storage system includes multiple storage nodes, the master node is one of the multiple storage nodes, and the garbage collection device is used to execute any one of the implementations provided in the first aspect.

[0014] A fourth aspect of the present application provides a computer program product for garbage collection, comprising a computer-readable storage medium storing program code, wherein the program code includes instructions for executing the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 This is an application scenario diagram provided by an embodiment of the present invention;

[0016] Figure 2 is a schematic diagram of a logic unit provided by an embodiment of the present invention;

[0017] Figure 3 This is a schematic diagram of the effect of a garbage collection method provided by an embodiment of the present invention;

[0018] Figure 4 This is a flow chart of a garbage collection method provided by an embodiment of the present invention;

[0019] Figure 5 is a schematic diagram of a migration list provided by an embodiment of the present invention;

[0020] Figure 6 is a flow chart of another garbage collection method provided by an embodiment of the present invention;

[0021] Figure 7 This is a schematic diagram of another garbage collection method provided by an embodiment of the present invention;

[0022] Figure 8 is a schematic diagram of the structure of a master node provided by an embodiment of the present invention;

[0023] Figure 9 It is a structural diagram of a garbage collection device of a master node provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The embodiment of the present application can ensure that at least a portion of valid data is migrated within the same storage node during garbage collection, thereby reducing cross-node data migration to a certain extent, thereby achieving the purpose of saving bandwidth. The technical solution of the embodiment of the present invention will be described below with reference to the accompanying drawings.

[0025] The technical solutions of the embodiments of the present application can be applied to various storage systems. The technical solutions of the embodiments of the present application are described below using a distributed storage system as an example, but the embodiments of the present invention are not limited to this. In a distributed storage system, data is stored in a dispersed manner on multiple storage nodes (hereinafter referred to as "nodes"), and the storage load is shared by multiple storage nodes. This storage method not only improves the reliability, availability and access efficiency of the system, but is also easy to expand. A storage node is, for example, a server, or a combination of a storage controller and a storage medium.

[0026] Figure 1 This is a schematic diagram of a scenario in which the technical solution of this embodiment can be applied. Figure 1 As shown, multiple client servers 101 communicate with a storage system 100, which includes a switch 103 and multiple storage nodes (or simply "nodes") 104. Switch 103 is optional. Each storage node 104 may include multiple mechanical hard disks or other types of storage media (such as solid-state drives or shingled magnetic recording media) for storing data.

[0027] Figure 2 is an example of a logical unit provided in this embodiment. A logical unit is a logical space, and the actual physical space of each logical unit comes from multiple nodes. The number of nodes occupied by a logical unit depends on the type of Redundant Array of Independent Disks (RAID) corresponding to the logical unit. Figure 2As shown, nodes 2, 3, 4, 5, 6, and 7 each provide a portion of storage space, thereby constructing a logical unit 1 with a RAID type of "4+2," wherein nodes 2, 3, 4, and 5 are used to store data slices, and nodes 6 and 7 are used to store parity slices. Among these six nodes, one node (for example, node 2) is elected as the master node. The master node divides the received data into four data slices, calculates two parity slices for the four data slices, and then sends each data slice and its parity slice to the corresponding node for storage. The master node can be the node where one of the slices is located, or it can be a node independent of the logical unit 1. When a data slice is written to a node, it is usually written at a set granularity, such as 8KB or 16KB. A data slice or parity slice can be divided into multiple data blocks according to the set granularity. For example, a data slice stored in node 2 includes data block D1 and data block D2, a data slice stored in node 3 includes data D3 and D4, ..., a check slice stored in node 6 includes Q1 and Q2, and so on. The check slice includes Q1, Q2, and P1, P2. D1, D2, D3, D4, D5, D6, D7, D8 and Q1, Q2, P1, P2 together form a stripe. When any two data slices / check slices are damaged, other slices can be used for recovery, thereby ensuring data reliability. Exemplarily, logical unit 1 can also include another stripe, which is composed of D9, D10, D11, D12, D13, D14, D15, D16 and Q3, Q4, P3, P4. For each shard (data shard or check shard), the identifier of the logical unit in which it is located and the position inside the logical unit constitute the logical address of the shard, and the actual address of the shard in the node is the physical address of the shard.

[0028] Each logical unit may include one or more stripes. In this embodiment, the number of stripes included in the logical unit is not limited. Figure 2 This is just an example. The situations of logical unit 2 and logical unit 3 are similar to those of logical unit 1 and will not be described in detail here. This embodiment does not limit the number of nodes, the number of logical units, or the corresponding RAID types.

[0029] In practical applications, systems often use an append-write mode to write data to logical units. When a logical unit is full, the system allocates a new logical unit for data writing. As data is modified, the data written before the modification becomes invalid. This invalid data is not read, but still occupies storage space. Therefore, when the system runs out of space, it is necessary to reclaim the logical unit to free up storage space. Append-write is also called redirect-on-write (ROW).

[0030] In this embodiment, the logical unit is the basic unit of garbage collection. In other words, when certain conditions are triggered, the system selects one or more logical units to be recycled (also called source logical units) from multiple logical units, migrates the valid data in these logical units to other locations, and then releases these logical units to achieve the purpose of reclaiming storage space.

[0031] The following combination Figure 3 and Figure 4 This paper introduces the garbage collection method provided by this embodiment. This method can be applied to Figure 1 In the distributed storage system shown in the figure, the objects of garbage collection are as follows Figure 2 The logic unit shown. Figure 3 This is a schematic diagram of the effect of the garbage collection method. Figure 4 This is a flowchart of the garbage collection method. Figure 4 As shown, the method includes the following steps.

[0032] In S401, the master node determines the source logical unit. This step is usually performed under certain triggering conditions, such as the amount of garbage data in the system reaches a specific threshold, or the size of the available storage space in the system is lower than a specific space threshold, or the number of logical units that meet the recycling conditions reaches a certain number, etc. The source logical unit also needs to meet certain conditions, such as the amount of garbage data contained in the logical unit reaches a first garbage threshold, or the amount of valid data contained in the logical unit is lower than a second garbage threshold, etc. Under normal circumstances, the determined source logical unit can be one or more. Figure 3 For example, it is assumed that the determined source logical units are logical unit 1, logical unit 2, and logical unit 3.

[0033] In S402, the master node determines the node where the source logical unit is located. Assume that logical unit 1, logical unit 2 and logical unit 3 are all source logical units. Figure 3 As can be seen, the RAID type corresponding to logical unit 1 is "4+2" and is distributed across nodes 2, 3, 4, 5, 6, and 7. Logical unit 2 has the same RAID type as logical unit 1 and is distributed across nodes 1, 2, 3, 5, 6, and 7. Logical unit 3 has the same RAID type as logical unit 1 and is distributed across nodes 1, 2, 3, 4, 5, and 7. Therefore, the nodes where the source logical unit is located include nodes 1, 2, 3, 4, 5, 6, and 7.

[0034] In S403, the master node counts the amount of valid data contained in the node where the source logical unit is located, and selects the node whose amount of valid data exceeds the set amount threshold as the target node. In actual applications, the amount of valid data is often counted according to the granularity of the data block described above. If a data block contains only valid data, such a data block is called a valid data block (e.g., Figure 3 If a data block contains invalid data, then this data block is called an invalid data block (as shown in the white Dn in the middle). Figure 3 (shown as Dn in medium grey). In addition, Figure 3 The P and Q data blocks in the data store checksum. Since the data shards within the original stripe typically change after garbage collection, the checksum is recalculated and stored to ensure reliability. Therefore, valid and invalid data apply only to data blocks within a data shard. P and Q data blocks do not distinguish between valid and invalid data; only valid data blocks within a data shard are counted.

[0035] For example, Figure 3 As shown, nodes 2, 3, 4, and 5 all contain 3 or 4 valid data blocks. If the quantity threshold is 2, then nodes 2, 3, 4, and 5 can all be used as target nodes. However, Figure 3 This is just an example. In this embodiment, any node whose amount of valid data exceeds a set threshold can be used as a target node. The number of target nodes can be one or more, which is not limited in this embodiment.

[0036] In S404, the master node creates a target logical unit (such as Figure 3 The target logical unit 4 is shown in FIG403 ), and the storage space occupied by the target logical unit is at least partially derived from the target node. The RAID type of the newly created target logical unit is consistent with the RAID type of the source logical unit (logical unit 1, logical unit 2, and logical unit 3). Therefore, logical unit 4 needs to span 6 nodes, and the 6 nodes include the target node selected in S403. If the selected target nodes are not enough, some nodes are selected from the distributed storage system to make up 6 nodes. For example: assuming that the number of target nodes in S403 is 4, then 2 more nodes need to be selected. Figure 3As shown, the storage space of logical unit 4 comes from nodes 2, 3, 4, 5, 6, and 7. Nodes 2, 3, 4, and 5 are the target nodes selected in S403, and nodes 6 and 7 are two other nodes selected. The selection strategy for nodes other than the target nodes can be load balancing or random, which is not limited in this embodiment. The RAID type of logical unit 4 is "4+2." Nodes 2, 3, 4, and 5 can be used for data sharding, while nodes 6 and 7 are used to store parity shards.

[0037] In S405, the valid data blocks in the source logical unit are migrated to the target logical unit (logical unit 4). Since the valid data blocks in the source logical unit are distributed across multiple nodes, the master node specifically needs to send instructions to the nodes where each valid data block is located, instructing the node to migrate its stored valid data blocks to the target logical unit. This can be divided into two cases. Case 1: For the target node, the valid data blocks only need to be migrated within the node. In this case, the master node can instruct the target node to migrate the valid data blocks from a first source address within the target node to a first target address within the target node. The first source address and the first target address are both real addresses. The storage space indicated by the first source address belongs to the source logical unit, and the storage space indicated by the first target address belongs to the target logical unit. For example, the source address and target address of data block D1 are both located within node 2, so data block D1 only needs to be migrated within node 2. Case 2: For nodes other than the target node, the valid data blocks stored in the node need to be sent to one of the target nodes. In this case, the master node instructs the node to migrate its stored valid data blocks from a second source address to a second target address. For example, the source address of data block D19 is located in node 1, and the destination address is located in node 2. Since node 1 does not provide storage space for logical unit 4, D26 needs to be sent to one of the destination nodes (such as Figure 3 Node 2 shown), node 2 stores D26 in logic unit 4.

[0038] An optional implementation is that before S405, the master node assigns a target address to each valid data block according to the minimum migration strategy and creates a migration list 50 (eg Figure 5As shown). The migration list 50 includes the source address and target address of each valid data block. The source address of a valid data block refers to the actual address of the valid data block before migration, and the target address of a valid data block refers to the actual address of the valid data block after migration. The minimum migration strategy is a migration strategy that minimizes the amount of data migrated across nodes and avoids data migration across nodes as much as possible. For example, for a target node (such as node 2), it provides storage space for both the source logical unit and the target logical unit, so the valid data blocks in the target node do not need to be migrated to other nodes. For a non-target node (such as node 6), since it does not provide storage space for the target logical unit, the valid data blocks in the node have to be migrated to the node where the target logical unit is located. After the master node creates the migration list 50, it sends the list 50 to the nodes where the valid data blocks are located and instructs these nodes to migrate according to the target addresses in the list. It should be noted that the minimum migration strategy is only one type of migration strategy, and other migration strategies can also be used in embodiments of the present invention. Because the destination node for migration is randomly selected in the prior art, as long as at least one data block is designated to remain on the local node after migration, in other words, for this data block, the source and destination nodes are the same node. Compared to the prior art, this method can achieve the beneficial effect of reducing cross-node migrations, and therefore falls within the scope of protection of the embodiments of the present invention.

[0039] Another optional implementation is that the master node does not need to generate the migration list 50, but directly instructs the node where the valid data block is located to perform data migration according to the target address after allocating the target address to each valid data block according to the minimum migration strategy.

[0040] Furthermore, for the target node, the valid data block is migrated within its node, but the processing method varies in different scenarios. If the source address and target address of a valid data block point to different hard disks, then during migration, the valid data block needs to be read from the source address to the cache within the node, and then the data block needs to be retrieved from the cache and rewritten to the target address. For example, data block D5, its source address is located at hard disk 0 of node 4, and the target address is located at hard disk 1 of node 4. At this time, node 4 needs to read D5 from hard disk 0 to the cache, and then retrieve D5 from the cache and write it to hard disk 1. If the source address and target address of a valid data block point to the same hard disk, then during migration, there is no need to read the valid data block from the hard disk to the cache, and the migration can be directly implemented within the hard disk. At this time, the processor of the node can send a migration instruction to the hard disk where the valid data block is located, and the migration instruction includes the source address and target address of the valid data block. The hard disk can directly read data from the source address and then write it to the target address. For example, if data block D3 has both a source address and a destination address located on disk 0 of node 3, the processor of node 3 sends a migration instruction to the read / write chip of disk 0. The read / write chip writes D3 from disk offset 2 to disk offset 10. In this embodiment, the disk offset address indicates the specific location where data is stored on the hard disk.

[0041] For the target logical unit (such as Figure 3 As shown in the logical unit 4), after each data slice is written to the corresponding node, the master node also needs to calculate the check slices of these data slices. The check slices include the check data blocks, such as Figure 3 The P and Q shown are the check data blocks. After the check data block is calculated, the master node sends the check shard (check shard includes the check data block) to the storage of the corresponding node.

[0042] After all valid data in the source logical unit are migrated to the target logical unit, the master node updates the metadata of the data. The metadata includes the logical address and physical address of the data. The logical address refers to the identifier of the logical unit where the data is located and the offset within the logical unit. It can be understood that after the valid data block is migrated from the source logical unit to the target logical unit, its logical address will change. In order for the client server 101 to read the correct data subsequently, the master node needs to modify the logical address of the data. The physical address refers to the physical location where the data is actually stored. It indicates the identifier of the node where the data is located, the identifier of the hard disk within the node, and the offset address within the disk (see Figure 5 When data is actually migrated from one node to another, or from one hard drive to another, or within the same hard drive, its physical address will change. The changed physical address must be recorded in the data metadata.

[0043] In S406, the master node releases the source logical unit ( Figure 3 The storage space occupied by the source logical unit (logical unit 1, logical unit 2, and logical unit 3) is released. Before the release, all data stored in the source logical unit, including valid data and invalid data, is deleted. The storage space obtained after the release can be used by other logical units. It should be noted that S406 occurs after all valid data in the source logical unit has been migrated to the target logical unit. It specifically includes: the master node releases the corresponding storage space of the source logical unit distributed in each storage node.

[0044] according to Figure 4 The garbage collection method shown here selects nodes with a high concentration of valid data to continue providing storage space for the target logical unit. This allows the valid data stored in these nodes to remain in those nodes, avoiding inter-node forwarding and saving network bandwidth. Even if a small amount of valid data on other nodes still needs to be sent to these nodes, this approach can still save network bandwidth to a certain extent compared to existing technologies.

[0045] Furthermore, S405 can be implemented in at least two ways. One implementation involves migrating each valid data block in logical unit 1, logical unit 2, and logical unit 3 to the storage space corresponding to logical unit 4, regardless of the logical address of the valid data block. In other words, the location of the valid data block within the logical unit will change before and after the migration. Consequently, the data shards contained in a stripe will also change, requiring recalculation of the check shards. Another implementation involves migrating the valid data blocks from the source logical unit to the target logical unit according to their original logical addresses, ensuring that the offsets of the migrated valid data blocks within logical unit 4 remain consistent with their original offsets. With this migration approach, if a large number of logical units need to be reclaimed, there is a high probability that the data shards contained in some stripes will remain unchanged after the migration compared to before the migration. Therefore, recalculating the check shards for these stripes is unnecessary. Therefore, compared to the previous approach, this approach can save system computing resources. This will be illustrated below with a specific example.

[0046] Please refer to Figure 6 and Figure 7 , Figure 6 This is another garbage collection method provided by this embodiment. This method can be applied to Figure 1 In the distributed storage system shown in the figure, the objects of garbage collection are as follows Figure 2 The logic unit shown. Figure 6 is a flow chart of the method, Figure 7It is a schematic diagram of the effect of the method. Figure 6 As shown, the method includes the following steps.

[0047] S601, the master node determines at least two source logical units. This step is usually performed under certain trigger conditions. The trigger conditions here are similar to Figure 4 The trigger conditions in S401 are consistent, and reference may be made to the description of S401. The at least two source logical units also need to meet certain conditions. Optionally, the master node may set the source logical units to meet certain conditions, and reference may be made to the description of S401 for specific condition settings.

[0048] For example, take two source logical units as an example, and these two logical units are logical unit 22 and logical unit 33. In this embodiment, each source logical unit can be set to meet the trigger condition, or only any one of the source logical units can be set to meet the trigger condition. It can also be set that when the amount of garbage data of logical unit 22 reaches the first garbage threshold, the amount of garbage data of logical unit 33 is lower than the second garbage threshold. Such a setting makes the amount of garbage data contained in the two source logical units have a certain difference. Furthermore, in some scenarios, logical unit 22 can be the logical unit with the highest amount of garbage data, and logical unit 33 is the logical unit with the lowest amount of garbage data. Similarly, this embodiment can also set other equivalent conditions to filter the two source logical units.

[0049] S602, the master node determines the node where the source logical unit is located. The nodes where the logical unit 22 and the logical unit 33 are located can be referenced. Figure 7 .

[0050] In step S603, the master node counts the amount of valid data contained in the node where the source logical unit is located, and selects a node whose amount of valid data exceeds a set threshold as a target node. The specific implementation of step S603 is consistent with step S403, so please refer to the description of step S403.

[0051] S604: The master node creates a target logical unit (e.g. Figure 7 The storage space occupied by the target logical unit is at least partially derived from the target node. The specific implementation of S604 is consistent with S404, please refer to the description of S404. Figure 7 In the example, the node where the logic unit 44 is located completely overlaps with the nodes where the logic units 22 and 33 are located. This is just an example. It should be understood that in actual application scenarios, the node where the logic unit 44 is located may only partially overlap with the nodes where the logic units 22 and 33 are located (e.g. Figure 3 shown).

[0052] S605: Migrate the valid data blocks in the logical unit 33 to the logical unit 44. During the migration process, the offsets of the valid data blocks in the logical unit are not changed. In other words, the offsets of the valid data blocks in the logical unit 33 before migration are the same as the offsets of the valid data blocks in the logical unit 44 after migration.

[0053] S606, write the valid data block in the logic unit 22 into the blank data block in the logic unit 44. Figure 7 As shown in the figure, after the stripe where D50 is located is migrated to the logical unit 44, blank data blocks will appear in some data slices because the original data blocks become invalid data blocks in the logical unit 33. Therefore, when migrating the valid data blocks in the logical unit 22, the blank data blocks can be filled first, and if there is overflow, they can be written to the new stripe. Figure 7 The D1, D3, etc. shown are written to the stripe where D51 is located. In order to distinguish it from the valid data in the logic unit 33, Figure 7 In the example, the valid data in the logic unit 22 is named as padding data and is represented by a dotted line.

[0054] According to the migration method of S605-S606, some data slices contained in the stripes in the logical unit 33 have not changed after the migration, such as Figure 7 The stripe where D33 is located and the stripe where D41 is located. Therefore, the stripe where D33 is located and the stripe where D41 is located do not need to be recalculated for the check slice. As for the stripe where D50 is located and the stripe where D58 is located, since new data blocks are filled in, the stripe has changed, so the check slice needs to be recalculated. It is understandable that even if there are still some stripes that need to recalculate the check slice, at least the calculation amount of a part of the check slice is reduced, saving computing resources. On the other hand, since the check slice is calculated by the master node and then sent to the corresponding node (such as Figure 7 As shown in the nodes 5 and 6), since there is no need to calculate the check fragments, the calculated check fragments will not be sent, saving bandwidth resources.

[0055] Furthermore, in this embodiment, logical unit 44 can also inherit the identifier of logical unit 33. In this way, for data blocks D33, D34, not only do their offsets within the logical unit remain unchanged, but the identifiers of the logical units in which they are located also remain unchanged. This means that the logical addresses of these data blocks remain unchanged (a logical address includes the identifier of the logical unit and the offset within the logical unit). Therefore, the modification of the metadata of valid data blocks such as D33 and D34 and the forwarding of the modified metadata between storage nodes are avoided, further saving network bandwidth.

[0056] S607, the master node releases the storage space occupied by the logical unit 22 and the logical unit 33. This step can be referred to Figure 4 Description of S406 is shown.

[0057] This embodiment also provides a storage node, which can be a storage array or a server. When the storage node is a storage array, the storage node includes a storage controller and a storage medium. The structure of the storage controller can refer to Figure 8 When the storage node is a server, you can also refer to Figure 8 Schematic diagram of the structure. Therefore, no matter what type of device the storage node is, it at least includes a processor 801 and a memory 802. The memory 802 stores a program 803. The processor 801, the memory 802, and the interface 804 are connected via a system bus 805 and communicate with each other.

[0058] The processor 801 is a single-core or multi-core central processing unit, or a specific integrated circuit, or one or more integrated circuits configured to implement the embodiments of the present invention. The memory 802 can be a random access memory (RAM) or a non-volatile memory (non-volatile memory), such as at least one hard disk memory. The memory 802 is used to store computer-executable instructions. Specifically, the computer-executable instructions may include a program 803. When the storage node is running, the processor 801 runs the program 803 to execute Figure 4 The method flow of S401-S406 shown, or executing Figure 6 The method flow of S601-S607 is shown.

[0059] Please refer to Figure 9 This embodiment also provides a garbage collection device, which is located in a master node of a distributed storage system. The distributed storage system includes multiple storage nodes, the master node is one of the multiple storage nodes, and the garbage collection device includes the following modules.

[0060] The selection module 901 is used to select a target node from the plurality of storage nodes according to the amount of valid data distributed in each storage node by the source logical unit, and the amount of first valid data stored in the target node exceeds a set threshold. Figure 4 S401, S402, S403 shown, and Figure 6 In addition, the functions of this module can be Figure 8 The processor 801 shown executes the program 803 in the memory 802 .

[0061] The creation module 902 is used to create a target logical unit, and the storage nodes to which the target logical unit is distributed include the target node. The specific functions of this module can be found in Figure 4 S404 shown and Figure 6 In addition, the function of this module can be Figure 8 The processor 801 shown executes the program 803 in the memory 802 .

[0062] Instruction module 903 is used to instruct the target node to migrate the first valid data from the first source address in the target node to the first target address in the target node, the storage space indicated by the first source address belongs to the source logical unit, and the storage space indicated by the first target address belongs to the target logical unit. Figure 4 The S405 shown and Figure 6 In addition, the functions of this module can be Figure 8 The processor 801 shown executes the program 803 in the memory 802 .

[0063] Release module 904 is used to release the storage space indicated by the first source address. Figure 4 The S406 shown and Figure 6 In addition, the function of this module can be Figure 8 The processor 801 shown executes the program 803 in the memory 802 .

[0064] Optionally, the creation module 902 is further configured to create a migration list before the master node instructs the target node to migrate the first valid data from the first source address within the target node to the first target address within the target node, the migration list including the first source address of the first valid data and the first target address of the first valid data. The garbage collection device may further include a sending module 905 configured to send the migration list to the target node.

[0065] Optionally, the migration list also includes a second source address of the second valid data stored in the other storage node and a second target address of the second valid data, the second source address is located in the other storage node, and the second target address is located in the target node. The sending module 905 is also used to send the migration list to the other storage node. The indication module 903 is also used to instruct the other storage node to migrate the stored second valid data from the second source address to the second target address, the storage space indicated by the second source address belongs to the source logical unit, and the storage space indicated by the second target address belongs to the target logical unit. The release module 904 is also used to release the storage space indicated by the second source address.

[0066] Optionally, the first source address and the first target address are both located in a first hard disk of the target node.

[0067] Optionally, the first source address is located in a first hard disk of the target node, and the first target address is located in a second hard disk of the target node.

[0068] Optionally, the indication module 903 is specifically used to instruct the target node to migrate the first valid data from the first source address to the first target address according to the offset of the first valid data in the source logical unit, so that the offset of the first valid data in the target logical unit after the migration is the same as the offset of the first valid data in the source logical unit before the migration.

[0069] Optionally, the first valid data is distributed in the first stripe of the source logical unit before migration, and is distributed in the second stripe of the target logical unit after migration. The indication module 903 is also used to determine whether the data shards contained in the first stripe are the same as the data shards contained in the second stripe; when the data shards contained in the first stripe are the same as the data shards contained in the second stripe, the check shards contained in the first stripe are retained.

[0070] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a storage node, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0071] It should be understood that in the embodiments of the present application, the terms "first" and the like are merely used to refer to objects and do not indicate the order of the corresponding objects.

[0072] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0073] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0074] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0075] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0076] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0077] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a storage node, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0078] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A garbage collection method in a distributed storage system, wherein the distributed storage system includes a plurality of storage nodes, characterized in that: The method comprises: The master node among the multiple storage nodes selects a target node from the multiple storage nodes according to the amount of valid data distributed in each storage node by the source logical unit, and the amount of first valid data stored in the target node exceeds a set quantity threshold; The master node creates a target logical unit, and the storage nodes to which the target logical unit is distributed include the target node; The master node instructs the target node to migrate the first valid data from a first source address in the target node to a first target address in the target node, where the storage space indicated by the first source address belongs to the source logical unit, and the storage space indicated by the first target address belongs to the target logical unit; The master node releases the storage space indicated by the first source address.

2. The method according to claim 1, characterized in that Before the master node instructs the target node to migrate the first valid data from the first source address in the target node to the first target address in the target node, the method further includes: The master node creates a migration list, where the migration list includes a first source address of the first valid data and a first target address of the first valid data; The master node sends the migration list to the target node.

3. The method according to claim 2, characterized in that The multiple storage nodes further include other storage nodes, the other storage nodes being independent of the storage nodes to which the target logical unit is distributed, the migration list further including a second source address of second valid data stored in the other storage nodes and a second target address of the second valid data, the second source address being located in the other storage nodes, and the second target address being located in the target node, the method further including: The master node sends the migration list to the other storage nodes; The master node instructs the other storage nodes to migrate the second valid data stored therein from the second source address to the second target address, where the storage space indicated by the second source address belongs to the source logical unit, and the storage space indicated by the second target address belongs to the target logical unit; The master node releases the storage space indicated by the second source address.

4. The method according to claim 1, wherein The first source address and the first target address are both located in a first hard disk of the target node.

5. The method according to claim 1, characterized in that The first source address is located in a first hard disk of the target node, and the first target address is located in a second hard disk of the target node.

6. The method according to claim 1, characterized in that The master node instructing the target node to migrate the first valid data from a first source address in the target node to a first target address in the target node includes: The master node instructs the target node to migrate the first valid data from the first source address to the first target address according to the offset of the first valid data in the source logical unit, so that the offset of the first valid data in the target logical unit after the migration is the same as the offset of the first valid data in the source logical unit before the migration.

7. The method according to claim 6, characterized in that The first valid data is distributed in the first stripe of the source logical unit before migration, and the first valid data is distributed in the second stripe of the target logical unit after migration. The method further includes: Determining whether the data fragments included in the first stripe are the same as the data fragments included in the second stripe; When the data fragments included in the first stripe are the same as the data fragments included in the second stripe, the check fragments included in the first stripe are retained.

8. A master node, characterized in that: The master node is located in a distributed storage system, which includes multiple storage nodes. The master node includes an interface and a processor. The interface is used to communicate with the multiple storage nodes; The processor is used to: Selecting a target node from the plurality of storage nodes according to the amount of valid data distributed in each storage node by the source logical unit, wherein the amount of first valid data stored in the target node exceeds a set quantity threshold; Creating a target logical unit, where the storage nodes distributed by the target logical unit include the target node; instructing the target node through the interface to migrate the first valid data from a first source address in the target node to a first target address in the target node, where the storage space indicated by the first source address belongs to the source logical unit, and the storage space indicated by the first target address belongs to the target logical unit; Release the storage space indicated by the first source address.

9. The master node according to claim 8, characterized in that: The processor is further configured to: Before instructing the target node to migrate the first valid data from the first source address within the target node to the first target address within the target node, a migration list is created, the migration list including the first source address of the first valid data and the first target address of the first valid data; and the migration list is sent to the target node.

10. The master node according to claim 9, characterized in that: The multiple storage nodes include other storage nodes, the other storage nodes are independent of the storage nodes where the target logical unit is distributed, the migration list further includes a second source address of second valid data stored in the other storage nodes and a second target address of the second valid data, the second source address is located in the other storage nodes, and the second target address is located in the target node, and the processor is further configured to: Sending the migration list to the other storage nodes through the interface; instructing the other storage nodes to migrate the second valid data stored therein from the second source address to the second target address, where the storage space indicated by the second source address belongs to the source logical unit, and the storage space indicated by the second target address belongs to the target logical unit; Release the storage space indicated by the second source address.

11. The master node according to claim 8, characterized in that: The first source address and the first target address are both located in a first hard disk of the target node.

12. The master node according to claim 8, wherein: The first source address is located in a first hard disk of the target node, and the first target address is located in a second hard disk of the target node.

13. The master node according to claim 8, wherein: The processor is specifically configured to: Instruct the target node to migrate the first valid data from the first source address to the first target address according to the offset of the first valid data in the source logical unit, so that the offset of the first valid data in the target logical unit after the migration is the same as the offset of the first valid data in the source logical unit before the migration.

14. The master node according to claim 13, wherein: The first valid data is distributed in a first stripe of the source logical unit before migration, and is distributed in a second stripe of the target logical unit after migration. The processor is further configured to: Determining whether the data fragments included in the first stripe are the same as the data fragments included in the second stripe; When the data fragments included in the first stripe are the same as the data fragments included in the second stripe, the check fragments included in the first stripe are retained.

15. A garbage collection device, characterized in that: The device is located in a master node of a distributed storage system, the distributed storage system includes multiple storage nodes, the master node is one of the multiple storage nodes, and the garbage collection device includes: a selection module, configured to select a target node from the plurality of storage nodes according to the amount of valid data distributed in each storage node by the source logical unit, wherein the amount of first valid data stored in the target node exceeds a set quantity threshold; A creation module, configured to create a target logical unit, wherein the storage nodes to which the target logical unit is distributed include the target node; an instruction module, configured to instruct the target node to migrate the first valid data from a first source address in the target node to a first target address in the target node, where the storage space indicated by the first source address belongs to the source logical unit, and the storage space indicated by the first target address belongs to the target logical unit; A release module is used to release the storage space indicated by the first source address.

16. The device according to claim 15, characterized in that The creation module is further configured to: before the master node instructs the target node to migrate the first valid data from the first source address in the target node to the first target address in the target node, create a migration list, the migration list including the first source address of the first valid data and the first target address of the first valid data; The device further includes a sending module configured to send the migration list to the target node.

17. The device according to claim 16, characterized in that The multiple storage nodes further include other storage nodes, the other storage nodes being independent of the storage nodes to which the target logical unit is distributed, the migration list further including a second source address of second valid data stored in the other storage nodes and a second target address of the second valid data, the second source address being located in the other storage nodes, and the second target address being located in the target node. The sending module is further configured to send the migration list to the other storage nodes; The instruction module is further configured to instruct the other storage nodes to migrate the second valid data stored therein from the second source address to the second target address, where the storage space indicated by the second source address belongs to the source logical unit, and the storage space indicated by the second target address belongs to the target logical unit; The releasing module is further configured to release the storage space indicated by the second source address.

18. The device according to claim 15, characterized in that The first source address and the first target address are both located in the first hard disk of the target node.

19. The device according to claim 15, characterized in that The first source address is located in a first hard disk of the target node, and the first target address is located in a second hard disk of the target node.

20. The device according to claim 15, characterized in that The indication module is specifically used for: Instruct the target node to migrate the first valid data from the first source address to the first target address according to the offset of the first valid data in the source logical unit, so that the offset of the first valid data in the target logical unit after the migration is the same as the offset of the first valid data in the source logical unit before the migration.

21. The device according to claim 20, characterized in that The first valid data is distributed in the first stripe of the source logical unit before migration, and is distributed in the second stripe of the target logical unit after migration. The indication module is further configured to: Determining whether the data fragments included in the first stripe are the same as the data fragments included in the second stripe; When the data fragments included in the first stripe are the same as the data fragments included in the second stripe, the check fragments included in the first stripe are retained.

Citation Information

Patent Citations

  • Storage space recovery method and storage space recovery device

    CN102591789A

  • Method and system for accessing small files, control node and storage node

    CN103605726A