Method and device for determining space occupation amount and computer equipment

By determining the target snapshot chain and data sharing status of the data block, accurately calculating the snapshot space occupancy, the problem of low accuracy of writable snapshot space occupancy in traditional methods is solved, and the utilization rate of storage resources and system performance is improved.

CN120215807APending Publication Date: 2025-06-27天津中科曙光存储科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311820557.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-26
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

Traditional methods are less accurate when determining the disk space occupancy of a writable snapshot because changes in the write operations and mapping relationship of data will affect the space occupancy.

Method used

By determining the target snapshot chain of each data block, the data sharing status of the data block is determined based on the number of read-only snapshots and the mapping relationship between the logical block address of the data block and the writable snapshot, and the home snapshot of the data block is determined based on the sharing state and preset home rules, thereby accurately calculating the snapshot space occupancy.

Benefits of technology

Improve the accuracy of disk space usage and ensure resource utilization and system performance of storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120215807A_ABST
    Figure CN120215807A_ABST
Patent Text Reader

Abstract

The invention relates to a space occupation amount determination method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: determining a target snapshot chain corresponding to each data block; determining a data sharing state of the data block based on the number of read-only snapshots contained in the target snapshot chain and a mapping relationship between the logic block address of the data block and writable snapshots; and based on the data sharing state and a preset affiliation rule, determining a target snapshot to which the data block belongs, and based on an affiliation result of each data block in a storage space, determining a snapshot space occupation amount. By adopting the method, the accuracy of determining the occupation amount of the disk space is improved.
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 particularly to a method, apparatus, computer device, storage medium, and computer program product for determining the occupied space volume. Background Art

[0002] The snapshot function is an important function of the storage system, which is used to maintain the data state at the user-specified time point. Snapshots are divided into read-only snapshots and writable snapshots. As important stored data in the storage space, snapshots play an important role in the process of determining the resource occupancy of the disk storage space.

[0003] In the traditional method, usually when the original snapshot version is created and at the beginning of creating the latest snapshot version, for the newly added or modified data blocks, they are copied when creating the new snapshot to form the snapshot data of the latest snapshot version. Furthermore, based on the snapshot data of the latest snapshot version, the space resources occupied by the current snapshot are determined.

[0004] However, for the writable snapshot type, the disk space occupancy of the writable snapshot data will change due to operations such as write operations and mapping relationship deletions performed on the data. Therefore, the accuracy of the disk space occupancy determined by the traditional method based on the snapshot data determined at the time of snapshot creation is relatively low. Summary of the Invention

[0005] Based on this, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for determining the occupied space volume to solve the above technical problems.

[0006] In a first aspect, this application provides a method for determining the occupied space volume, including:

[0007] Determine the target snapshot chain corresponding to each data block;

[0008] Based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot, determine the data sharing state of the data block;

[0009] Based on the data sharing state and the preset attribution rule, determine the target snapshot to which the data block belongs, and based on the attribution results of each data block in the storage space, determine the snapshot space occupancy.

[0010] In this embodiment, based on the number of read-only snapshots in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot, the data sharing state of the data block is determined. Furthermore, on the basis of clarifying the sharing state of the data block, based on the data sharing state of the data block and the preset attribution rule, the space attribution of the current data block is clarified, that is, the space storage change of each data block in the current storage space is clarified. Furthermore, the snapshot space occupancy is determined based on the space attribution of the current data block, improving the accuracy of the disk space occupancy.

[0011] In one embodiment, the determining the target snapshot chain corresponding to each data block includes:

[0012] Obtain the data copy identifier corresponding to each data block;

[0013] In the snapshot version lookup table, query the snapshot copy identifier that matches the data copy identifier, and determine the snapshot chain where the snapshot corresponding to the snapshot copy identifier is located as the target snapshot chain.

[0014] In this embodiment, the corresponding data snapshots are searched and managed according to the data copy identifier. Furthermore, based on the information contained in the target snapshot chain, the data sharing state of each data block can be clarified, thereby clarifying the change of the storage space.

[0015] In one embodiment, the method further includes:

[0016] In the snapshot version lookup table, if there is no snapshot copy identifier that matches the data copy identifier, determine the snapshot chain where the snapshot containing the data block is located as the target snapshot chain.

[0017] In this embodiment, in the case where no matching snapshot copy identifier is found, the snapshot chain is searched through the data block, thereby ensuring data consistency and reliability.

[0018] In one embodiment, the determining the data sharing state of the data block based on the number of read-only snapshots contained in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot includes:

[0019] Scan the target snapshot chain according to the rule of ascending order scanning of the snapshot copy identifier to determine the initial scan result;

[0020] If the number of read-only snapshots included in the initial scan result meets the first preset condition, determine that the data block is in a shared state;

[0021] If the number of read-only snapshots included in the initial scan result does not meet the first preset condition, determine the data sharing status of the data block based on the mapping relationship between the logical block address of the data block and the writable snapshot.

[0022] In this embodiment, a method for determining the data sharing status is proposed. By setting a snapshot chain scanning rule, scanning the target snapshot chain, and based on the number of read-only snapshots included in the scan result and the mapping relationship between the writable snapshot and the logical block address of the data block, judging the data sharing status of the data block. Furthermore, the belonging snapshot of the data block can be determined based on the data sharing status of the data block, the space occupancy division of the storage space can be clarified, and the accuracy of determining the space occupancy of the storage space is improved.

[0023] In one embodiment, the determining the data sharing status of the data block based on the mapping relationship between the logical block address of the data block and the writable snapshot includes:

[0024] For the writable snapshot in the target snapshot chain, query in the snapshot mapping relationship table whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified;

[0025] If it is not modified, determine that the data block is shared by the current writable snapshot and determine that the data block is in a shared state;

[0026] If it is modified, query the next writable snapshot of the current writable snapshot in the target snapshot chain, and execute the step of querying whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified.

[0027] In this embodiment, the data sharing status of the data block is judged through the mapping relationship between the writable snapshot and the logical block address of the data block. Furthermore, the belonging snapshot of the data block can be determined based on the data sharing status of the data block, the space occupancy division of the storage space can be clarified, and the accuracy of determining the space occupancy of the storage space is improved.

[0028] In one embodiment, the method further includes:

[0029] Receive a snapshot write request, where the snapshot write request includes the logical block address information of the snapshot to be written;

[0030] Obtain the metadata node of the snapshot, and determine the number of data blocks of the snapshot based on the logical block address information;

[0031] Query the indirect index including the starting address of the logical block address in the metadata node;

[0032] If the indirect index is a valid value and the data block pointed to by the indirect index is in a shared state, split the indirect index to obtain lower-level indirect indexes and direct indexes, and allocate persistent addresses to each of the indirect indexes and the direct indexes;

[0033] Update the metadata node of the snapshot, and store the updated metadata node, each layer of indirect indexes, and direct indexes in the persistent address.

[0034] In this embodiment, during the snapshot write process, the indirect index and direct index of the snapshot are determined by the data sharing degree of the data block. Furthermore, the processing efficiency of the snapshot write request is improved, the waste of storage space is reduced, thereby enhancing the overall performance of the system and the utilization rate of storage resources.

[0035] In one embodiment, the method further includes:

[0036] If the indirect index is an invalid value, query the lower-level indirect index of the indirect index in the metadata node until the direct index;

[0037] If there is a lower-level indirect index or the direct index is a valid value and the data block pointed to by the lower-level indirect index or the direct index is in a shared state, perform the step of allocating persistent addresses to each of the indirect indexes and the direct indexes.

[0038] In this embodiment, through the processing of the case where the indirect index is an invalid value, the storage utilization rate and query and write efficiency are improved on the premise of ensuring data reliability, which is of great significance for optimizing system performance and resource utilization.

[0039] In one embodiment, the method further includes:

[0040] Receive a snapshot deletion request, where the snapshot deletion request includes the logical block address information of the valid snapshot and the metadata node of the snapshot to be deleted;

[0041] Based on the logical block address information of the valid snapshot, determine the number of data blocks of the snapshot;

[0042] Query the number of indirect indexes of the data blocks in the metadata node; the indirect index includes the starting address of the logical block address;

[0043] If the data block pointed to by the indirect index is in a shared state, query the corresponding lower-level indirect index and direct index of the indirect index, and delete the target mapping relationship between the indirect index and the direct index based on the data sharing state of the data block pointed to by the lower-level indirect index and the direct index.

[0044] In this embodiment, information of the snapshot to be deleted is obtained through the metadata node of the snapshot, and then the index is queried layer by layer using the information of the snapshot to be deleted. Based on the judgment method of the given data sharing state, the data sharing state is judged, the corresponding target mapping relationship is clarified and deleted, so as to realize the deletion of the snapshot.

[0045] In a second aspect, the present application also provides a device for determining the space occupancy, and the device includes:

[0046] A first determination module, configured to determine a target snapshot chain corresponding to each data block;

[0047] A second determination module, configured to determine the data sharing state of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot;

[0048] A third determination module, configured to determine the target snapshot to which the data block belongs based on the data sharing state and a preset attribution rule, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space.

[0049] In this embodiment, based on the number of read-only snapshots in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot, the data sharing state of the data block is determined. Furthermore, on the basis of clarifying the sharing state of the data block, based on the data sharing state of the data block and the preset attribution rule, the space attribution of the current data block is clarified, that is, the space storage change of each data block in the current storage space is clarified. Furthermore, the snapshot space occupancy is determined based on the space attribution of the current data block, improving the accuracy of the disk space occupancy.

[0050] In a third aspect, the present application relates to a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0051] Determine a target snapshot chain corresponding to each data block;

[0052] Determine the data sharing state of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot;

[0053] Determine the target snapshot to which the data block belongs based on the data sharing state and a preset attribution rule, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space.

[0054] In a fourth aspect, the present application relates to a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0055] Determine the target snapshot chain corresponding to each data block;

[0056] Determine the data sharing status of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot;

[0057] Determine the target snapshot to which the data block belongs based on the data sharing status and a preset attribution rule, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space.

[0058] In a fifth aspect, the present application relates to a computer program product, including a computer program, which when executed by a processor implements the following steps:

[0059] Determine the target snapshot chain corresponding to each data block;

[0060] Determine the data sharing status of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot;

[0061] Determine the target snapshot to which the data block belongs based on the data sharing status and a preset attribution rule, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space.

[0062] The above method, device, computer device, storage medium, and computer program product for determining the space occupancy determine the target snapshot chain corresponding to each data block; determine the data sharing status of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot; determine the target snapshot to which the data block belongs based on the data sharing status, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space. By using this method, based on the number of read-only snapshots in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot, the data sharing status of the data block is determined. Furthermore, on the basis of clarifying the sharing status of the data block, based on the data sharing status of the data block and a preset attribution rule, the space attribution of the current data block is clarified, that is, the space storage changes of each data block in the current storage space are clarified. Furthermore, the snapshot space occupancy is determined based on the space attribution of the current data block, improving the accuracy of determining the disk space occupancy. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] To more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings required for use in the description of the embodiments or the related art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0064] Figure 1 It is a schematic structural diagram of a snapshot creation method in an embodiment;

[0065] Figure 2 It is a schematic structural diagram of the index relationship of a snapshot in an embodiment;

[0066] Figure 3 It is a schematic flowchart of a method for determining the space occupancy in an embodiment;

[0067] Figure 4 It is a schematic flowchart of a method for determining a target snapshot chain in an embodiment;

[0068] Figure 5 It is a schematic flowchart of the steps for determining the data sharing status of a data block in an embodiment;

[0069] Figure 6 It is a schematic flowchart of the steps for determining the data sharing status of a data block based on the mapping relationship between a writable snapshot and the data block in another embodiment;

[0070] Figure 7 It is a schematic flowchart of a snapshot writing method in an embodiment;

[0071] Figure 8 It is a schematic flowchart of the steps for determining the mapping relationship in the lower-layer snapshot query when the indirect index is an invalid value in an embodiment;

[0072] Figure 9 It is a schematic flowchart of a snapshot deletion method in an embodiment;

[0073] Figure 10 It is a schematic block diagram of a device for determining the space occupancy in an embodiment;

[0074] Figure 11 It is an internal structural diagram of a computer device in an embodiment. Detailed implementation manners

[0075] In order to make the objectives, technical solutions, and advantages of the present application clearer, the following further details the present application in conjunction with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0076] In one embodiment, a sample method for creating a snapshot and a snapshot chain is provided. As Figure 1 shown, the process of creating a snapshot and a snapshot chain is introduced. Specifically, the method mainly includes: pre-specifying a snapshot source, which is used to create subsequent snapshots, or creating a source-less snapshot when no snapshot source is specified, and using the source-less snapshot as the snapshot source for subsequent snapshots. The snapshot version identifier corresponding to the snapshot source (i.e., the snapshot version ID) is set to a default value. For example, the snapshot version ID is 0. When creating a snapshot, it should be noted that no operations on direct indexing and indirect indexing with changes on the snapshot source occur. Then, obtain a version number from the snapshot version generator, create the in-memory structure of the metadata root node corresponding to the snapshot of the snapshot source, and save the newly obtained version number as the snapshot version ID of the newly created snapshot to the in-memory structure of the metadata root node; secondly, use the snapshot version ID of the snapshot source as the snapshot source version ID of the newly created snapshot; initialize all indirect indexes in the in-memory structure of the metadata root node; allocate a persistent address through the persistent address allocator, and save the in-memory structure of the metadata root node to the location where the persistent address is executed, that is, the saved in-memory structure of the metadata root node is the disk structure. At the same time, set the number of exclusive resources of the snapshot source to 0 (i.e., indicating that the data sharing state of the data corresponding to the current snapshot source is a non-shared state), and update it to the disk structure of the metadata root node of the snapshot source.

[0077] After clarifying the process of creating a snapshot and a snapshot chain, for each snapshot and snapshot chain stored in the disk space, when determining the disk space occupancy, in order to improve the accuracy of the disk space occupancy, since during the snapshot creation process, no operations on direct indexing and indirect indexing with changes on the snapshot source occur, therefore, the disk space change can be clarified at this stage, that is, determine the ownership of each data block in the disk space. Thus, after clarifying the snapshot to which each data block belongs, the disk space occupancy can be accurately determined.

[0078] In addition, as Figure 2As shown, the data sharing status of each data block can be used to reflect the data sharing relationship between data blocks. Specifically, the indirect index block contains the user-visible LBA (Logical Block Address), data block address / indirect index block address, weight, and sharing identifier; different snapshots can point to the same data block through the indirect index block, achieving sharing the same data block between snapshots; snapshots can point to the same indirect index block through their respective indirect index blocks; each data block has a preset weight, and the belonging weight is mainly used to represent the sharing relationship. The value of the preset weight of a data block itself only represents the upper limit of writable snapshots that can share the data block. For read-only snapshots, there are no relevant restrictions; all snapshots sharing the same data block respectively hold a part of the weight of the shared data block, and the sum of the parts of the weight of the shared data block held by all snapshots sharing the same data block is equal to the preset weight of the shared data block; subsequent snapshots will take away a part of the weight from its snapshot source or snapshots of other shared data blocks.

[0079] In one embodiment, as Figure 3 shown, a method for determining the space occupancy is provided. In this embodiment, this method can be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. The embodiments of the present application do not limit this. Thus, in this embodiment, the execution subject of this method is collectively referred to as a computer device for description. In this embodiment, the method includes the following steps:

[0080] Step 302, determine the target snapshot chain corresponding to each data block.

[0081] In implementation, the computer device determines the target snapshot chain corresponding to each data block. Specifically, the target snapshot chain can be found in the snapshot version lookup table through the data copy identifier (data copy ID) of the data block, or the target snapshot chain can be found based on the data of the current data block. Different situations for determining the target snapshot chain will be introduced in detail below in the embodiments of the present application, and will not be elaborated here.

[0082] Step 304, based on the number of read-only snapshots included in the target snapshot chain, and the mapping relationship between the logical block address of the data block and the writable snapshot, determine the data sharing status of the data block.

[0083] In implementation, since the efficiency of querying a read-only snapshot is higher than that of querying a writable snapshot, when the computer device scans the target snapshot chain, it first determines the number of read-only snapshots included in the target snapshot chain in the scan result, and then, based on the read-only snapshots, determines the data sharing status of the data block. When the number of read-only snapshots does not meet the preset judgment condition, that is, when the data sharing status of the data block cannot be determined, the data sharing status of the data block is further determined based on the mapping relationship between the logical block address of the data block and the writable snapshot.

[0084] Step 306: Based on the data sharing status and the preset attribution rule, determine the target snapshot to which the data block belongs, and based on the attribution results of each data block in the storage space, determine the snapshot space occupancy.

[0085] In implementation, the data sharing status includes two cases: exclusive status and non-exclusive status. Non-exclusive also means shared. When the data block is in the exclusive status, the data block corresponds to one snapshot, and the attribution snapshot of the data block can be directly determined. When the data block is in the non-exclusive status, the data block corresponds to multiple snapshots. Therefore, the computer device determines the attribution snapshot of the data block based on the preset attribution rule. Thus, after clarifying the attribution results of each data block, the computer device can select eligible target snapshots based on business requirements, etc., and count the snapshot space occupancy of the target snapshots.

[0086] In the above method for determining the space occupancy, based on the number of read-only snapshots in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot, the data sharing status of the data block is determined. Then, on the basis of clarifying the sharing status of the data block, based on the data sharing status of the data block and the preset attribution rule, the space attribution of the current data block is clarified, that is, the space storage change of each data block in the current storage space is clarified. Furthermore, the snapshot space occupancy is determined based on the space attribution of the current data block, improving the accuracy of the disk space occupancy.

[0087] In an exemplary embodiment, as Figure 4 shown, step 302 includes steps 402 to 404. Among them:

[0088] Step 402: Obtain the data copy identifier corresponding to each data block.

[0089] In implementation, the computer device obtains the data copy identifier corresponding to each data block.

[0090] Step 404: In the snapshot version lookup table, query the snapshot copy identifier that matches the data copy identifier, and determine the snapshot chain where the snapshot corresponding to the snapshot copy identifier is located as the target snapshot chain.

[0091] In implementation, in the snapshot version lookup table, query the snapshot copy identifier that matches the data copy identifier, that is, query the snapshot copy identifier that is consistent with the data copy identifier. If the snapshot copy identifier exists in the snapshot version lookup table, based on the snapshot copy identifier, determine the snapshot chain where the snapshot of the snapshot copy identifier is located as the target snapshot chain.

[0092] Specifically, the snapshot version lookup table is shown in Table 1 below:

[0093] Table 1

[0094]

[0095] In this embodiment, corresponding data snapshots are found and managed according to the data copy identifier. Furthermore, based on the information contained in the target snapshot chain, the data sharing status of each data block can be clarified, and thus, the change of the storage space is clarified.

[0096] In an exemplary embodiment, the method further includes:

[0097] In the snapshot version lookup table, if there is no snapshot copy identifier that matches the data copy identifier, determine the snapshot chain where the snapshot containing the data block is located as the target snapshot chain.

[0098] In implementation, if there is no snapshot copy identifier that is consistent with the data copy identifier in the snapshot version lookup table, it may be that the original snapshot source has been deleted. For example, a snapshot B is created with snapshot A as the snapshot source, then a snapshot C is created with snapshot B as the source, and then snapshot A and snapshot B are deleted. The data of the original snapshot A still exists, but no snapshot copy identifier that matches the data copy identifier can be found. Therefore, the computer device searches based on the data block and determines the snapshot chain where the snapshot containing the data block is located as the target snapshot chain.

[0099] In this embodiment, in the case of not finding a matching snapshot copy identifier, the snapshot chain is searched through the data block, thereby ensuring data consistency and reliability.

[0100] In an exemplary embodiment, as Figure 5 shown, step 304 includes steps 502 to 506. Among them:

[0101] Step 502, scan the target snapshot chain according to the rule of ascending order scanning of the snapshot copy identifier, and determine the initial scan result.

[0102] In implementation, after determining the target snapshot chain, the computer device scans the target snapshot chain, and during the scanning process, based on the preset ascending order scanning rule, scans in the ascending order of the snapshot copy identifier to determine the initial scan result.

[0103] Optionally, if the target snapshot chain is determined based on data chunks, the snapshot with the smallest snapshot copy identifier (the smallest snapshot copy ID) of the data copy identifier (i.e., the data copy ID) of the current data chunk is used as the search starting point for scanning the target snapshot chain.

[0104] Step 504: If the number of read-only snapshots included in the initial scan result meets the first preset condition, determine that the data chunk is in a shared state.

[0105] In implementation, if the number of read-only snapshots included in the initial scan result meets the first preset condition, determine that the data chunk is in a shared state. Among them, the first preset condition is that the number (count) of read-only snapshots is equal to the preset number threshold. Therefore, when the number of read-only snapshots is equal to the preset number threshold, the data sharing degree of the data chunk is at least the number count of read-only snapshots. The data sharing degree is used to reflect the number of snapshots of the data chunk that are shared. Therefore, when the count is greater than 1, it can be determined that the data chunk is in a shared state.

[0106] Step 506: If the number of read-only snapshots included in the initial scan result does not meet the first preset condition, determine the data sharing state of the data chunk based on the mapping relationship between the logical block address of the data chunk and writable snapshots.

[0107] In implementation, when the number of read-only snapshots included in the initial scan result does not meet the first preset condition, further combine the mapping relationship between the logical block address of the data chunk and writable snapshots to determine the data sharing state of the data chunk.

[0108] Optionally, if the number of read-only snapshots included in the initial scan result of the target snapshot chain does not meet the first preset condition, further search for the snapshot chain with the snapshots in the target snapshot chain as the snapshot sources, that is, the relevant snapshot chain of the target snapshot chain, and scan the relevant snapshot chain in the ascending order of the snapshot copy identifier until the relevant snapshot chain is scanned completely. If the number of read-only snapshots included in the scan result can meet the first preset condition, the data sharing state of the data chunk can still be determined to be in a shared state. If the number of read-only snapshots in the scan result of the relevant snapshot chain still does not meet the first preset condition, combine the mapping relationship between the logical block address of the data chunk and writable snapshots to determine the data sharing state of the data chunk.

[0109] In this embodiment, a method for determining the data sharing state is proposed. By setting a snapshot chain scanning rule, the target snapshot chain is scanned, and based on the number of read-only snapshots included in the scanning result and the mapping relationship between the writable snapshot and the logical block address of the data block, the data sharing state of the data block is judged. Furthermore, based on the data sharing state of the data block, the belonging snapshot of the data block can be determined, the space occupancy division of the storage space can be clarified, and the accuracy of determining the space occupancy of the storage space is improved.

[0110] In an exemplary embodiment, as Figure 6 shown, the specific processing of determining the data sharing state of the data block based on the mapping relationship between the logical block address of the data block and the writable snapshot in step 304 or step 506 includes steps 602 to 606. Among them:

[0111] Step 602, for the writable snapshot in the target snapshot chain, query in the snapshot mapping relationship table whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified.

[0112] In implementation, when the number of read-only snapshots does not meet the first preset condition, the computer device searches the snapshot mapping relationship table based on the logical block address LBA of the data block, and in this snapshot mapping relationship table, queries whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified.

[0113] Step 604, if it is not modified, determine that the data block is shared by the current writable snapshot and determine that the data block is in a shared state.

[0114] In implementation, if it is not modified, then based on the mapping relationship between the writable snapshot and the data block given in the snapshot mapping relationship table, the computer device determines that the data block is shared by the current writable snapshot. In combination with the foregoing embodiment, for the number count of read-only snapshots included in the initial scanning result of the target snapshot chain, the data sharing degree result of the data block is determined to be count + 1. Furthermore, the computer device determines that the data block is in a shared state.

[0115] Step 606, if it is modified, query the next writable snapshot of the current writable snapshot in the target snapshot chain, and execute the step of querying whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified.

[0116] In implementation, in the case of modification, it is indicated that the sharing relationship between the data block and the writable snapshot has been modified. Therefore, the computer device cannot determine the sharing relationship between the data block and each writable snapshot based on the mapping relationship in the snapshot mapping table, and it is necessary to continue scanning the writable snapshots in the target snapshot chain to analyze whether the current data block is shared by a certain writable snapshot. Specifically, the scanning process of the writable snapshots in the target snapshot chain is as follows: If the data copy ID of the data block is equal to or less than the snapshot copy ID of the currently queried writable snapshot, it indicates that the modification operation of the queried data block was performed before the currently writable snapshot, that is, a certain snapshot or the original data before the currently writable snapshot modified the data block. Therefore, there is no need to continue the subsequent scanning of this data block. The data sharing degree of this data block is determined as the number count of the determined read-only snapshots, and no subsequent scanning is required. On the contrary, if the data copy ID of the data block is greater than the snapshot copy ID of the currently queried writable snapshot, it is necessary to query the next writable snapshot of the current snapshot on the snapshot chain to determine whether there is a sharing relationship between the next writable snapshot and the data block.

[0117] In this embodiment, the sharing state of the data block is judged through the mapping relationship between the writable snapshot and the logical block address of the data block. Furthermore, the belonging snapshot of the data block can be determined based on the sharing state of the data block, the space occupancy division of the storage space can be clarified, and the accuracy of determining the space occupancy of the storage space is improved.

[0118] In an exemplary embodiment, after determining the sharing state of the data block, based on the data sharing degree obtained during the process of determining the sharing state, the mapping relationship between the data block and the snapshot can be further clarified. Thus, when performing a snapshot write operation or a snapshot deletion operation, the indirect indexes and direct indexes of the data block can be quickly determined based on the mapping relationship between the data block and the snapshot, as Figure 7 shown, the method further includes:

[0119] Step 702, receiving a snapshot write request.

[0120] Among them, the snapshot write request includes the logical block address information of the snapshot to be written. The logical block address information includes the start address and length information of the logical address.

[0121] In implementation, when the user needs to perform a snapshot write operation, a snapshot write request will be triggered, and the computer device receives the snapshot write request to perform the snapshot write operation.

[0122] Step 704, obtaining the metadata node of the snapshot and determining the number of data blocks of the snapshot based on the logical block address information.

[0123] In implementation, the computer device obtains the metadata root node of the snapshot specified by the snapshot write request and converts the logical block address range included in the snapshot write request into the number of data blocks. Specifically, when processing the snapshot write request, first the computer device needs to find the metadata root node of the corresponding snapshot. This metadata root node contains information about all data blocks and related records bound to the snapshot. Then, it is necessary to convert the logical block address range included in the snapshot write request into the corresponding number of data blocks to determine the data block range to be processed.

[0124] Step 706, query in the metadata node for the indirect index containing the start address of the logical block address.

[0125] In implementation, the computer device also finds the indirect index containing the start address of the logical block address. Specifically, the computer device needs to find the indirect index containing this address according to the start address of the logical block address. This is to find the corresponding data block and perform subsequent operations.

[0126] Step 708, if the indirect index is a valid value and the data block pointed to by the indirect index is in a shared state, split the indirect index to obtain the lower-level indirect index and the direct index, and allocate persistent addresses for each indirect index and direct index.

[0127] In implementation, if the indirect index is a valid value and the data block pointed to by the indirect index is in a shared state (i.e., the data sharing degree is greater than 1), indicating that the indirect index can be further split downwards, then the computer device can find the corresponding indirect index in the metadata root node, traverse the child nodes of the indirect index layer by layer until the corresponding direct index is found, and allocate the required persistent addresses through a preset persistent address allocator, initialize the split indirect index and direct index, and save the allocated persistent addresses to the metadata root node of the snapshot / or the memory structure of the previous-level indirect index.

[0128] Step 710, update the metadata node of the snapshot, and store the updated metadata node, each layer of indirect index and direct index to the persistent address.

[0129] In implementation, for the snapshot that has been modified, the computer device updates the metadata node of the snapshot, and stores the updated metadata node, each layer of indirect index and direct index to the persistent address.

[0130] Optionally, when updating the metadata node of a snapshot, the snapshot chain where the current snapshot is located may overlap with other snapshot chains. Therefore, it is necessary to determine the value of the data replica ID. To ensure data consistency and correctness, the data replica ID uses the maximum value of all snapshot replica IDs in the snapshot chain where the current snapshot is located (including related sub-snapshot chains). That is, among all replicas of this data block in the current snapshot chain and its sub-chains, the one with the largest replica ID is selected as the data replica ID, and the metadata node of the snapshot is searched for and updated.

[0131] In this embodiment, during the snapshot write process, the indirect index and direct index of the snapshot are determined based on the data sharing degree of the data block, thereby improving the processing efficiency of the snapshot write request, reducing waste of storage space, and thus enhancing the overall performance of the system and the utilization rate of storage resources.

[0132] In an exemplary embodiment, as Figure 8 shown, the method further includes:

[0133] Step 802, if the indirect index is an invalid value, query the lower-level indirect index of the indirect index in the metadata node until the direct index is obtained.

[0134] In implementation, during the snapshot write process, if the indirect index queried based on the starting position of the logical block address is an invalid value, then it is necessary to continue searching until it is refined to the direct index, that is, it is necessary to query the lower-level indirect index of the indirect index in the metadata node until the direct index is obtained.

[0135] Step 804, if there is a lower-level indirect index or the direct index is a valid value and the data block pointed to by the lower-level indirect index or direct index is in a shared state, then execute the step of allocating a persistent address for each indirect index and direct index.

[0136] In implementation, if it is refined to a certain indirect index, or the direct index already exists as a valid value, and the data block is shared among multiple snapshots, then a persistent address is allocated by the persistent address allocator and written into the corresponding data block metadata, that is, the creation and storage of new data blocks are allowed during use, that is, the computer device executes the above step 708. The process of step 708 will not be elaborated here.

[0137] In this embodiment, by handling the case where the indirect index is an invalid value, the storage utilization rate and query and write efficiency are improved on the premise of ensuring data reliability, which is of great significance for optimizing the system performance and resource utilization rate.

[0138] In an exemplary embodiment, a snapshot deletion method is provided. Similar to the snapshot write operation, this snapshot deletion method also utilizes the data sharing degree of data blocks to clarify mapping relationships such as indirect indexes and direct indexes between snapshots. During the specific execution process of this snapshot deletion method, the deletion of the data blocks of the snapshot is first performed. After repeatedly performing the deletion of the data blocks of the snapshot, the deletion of the snapshot is achieved. As Figure 9 shown, the method further includes:

[0139] Step 902, receive a snapshot deletion request.

[0140] Among them, the snapshot deletion request includes the logical block address information of the valid snapshot and the metadata node of the snapshot to be deleted. The logical block address information includes the start address and length information of the logical block address specified by the snapshot deletion request.

[0141] In implementation, when the user needs to perform a snapshot deletion operation, a snapshot deletion request is triggered. The computer device receives this snapshot deletion request to execute the snapshot deletion operation.

[0142] Step 904, based on the logical block address information of the valid snapshot, determine the number of data blocks of the snapshot.

[0143] In implementation, the computer device determines the number of data blocks of the snapshot based on the logical block address information of the valid snapshot. Specifically, the computer device needs to convert the logical block address information included in the snapshot deletion request into the corresponding number of data blocks of the snapshot in order to determine the range of data blocks that need to be deleted and processed.

[0144] Step 906, query the number of data blocks of indirect indexes in the metadata node.

[0145] Among them, the indirect index includes the start address of the logical block address.

[0146] In implementation, after determining the range of data blocks, the computer device queries the indirect indexes corresponding to the data block range in the metadata node, that is, queries the number of data blocks of indirect indexes.

[0147] Step 908, if the data block pointed to by the indirect index is in a shared state, query the lower-level indirect index and direct index corresponding to the indirect index, and based on the data sharing states of the data blocks pointed to by the lower-level indirect index and direct index, delete the target mapping relationship between the indirect index and the direct index.

[0148] In implementation, if the data block pointed to by the indirect index is in a shared state, that is, the queried indirect index is an index shared among multiple snapshots, it is necessary to further search for the lower-level index. If the lower-level index is an indirect index, the computer device continues to query the lower-level index corresponding to this indirect index until the data block pointed to by the direct index is reached. After reaching the direct index, the computer device needs to determine whether this direct index is exclusive or shared, that is, to determine the data sharing state of the data block of this direct index. If it is in an exclusive state, the relevant mapping relationship is deleted. If it is in a shared state, it is necessary to analyze this direct index and delete the records of the relevant data blocks in the split direct index. Finally, modify the metadata node of this snapshot in the persistent address to ensure data consistency.

[0149] In this embodiment, the information of the snapshot to be deleted is obtained through the metadata node of the snapshot, and then the index is queried layer by layer using the information of the snapshot to be deleted, and the data sharing state is judged based on the given method for judging the data sharing state, and the corresponding target mapping relationship is clarified and deleted, so as to realize the deletion of the snapshot.

[0150] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps in other steps.

[0151] Based on the same inventive concept, the embodiments of the present application also provide a device for determining the space occupancy for implementing the method for determining the space occupancy involved above. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the device for determining the space occupancy provided below can refer to the limitations on the method for determining the space occupancy in the above text, and will not be repeated here.

[0152] In an exemplary embodiment, as Figure 10 shown, a device for determining the space occupancy is provided, including: a first determination module 1001, a second determination module 1002, and a third determination module 1003, where:

[0153] The first determination module 1001 is used to determine the target snapshot chain corresponding to each data block.

[0154] A second determination module 1002, configured to determine the data sharing status of a data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshots.

[0155] A third determination module 1003, configured to determine the target snapshot to which the data block belongs based on the data sharing status and a preset attribution rule, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space.

[0156] In one embodiment, the first determination module 1001 is specifically configured to obtain a data copy identifier corresponding to each data block;

[0157] In the snapshot version lookup table, query for a snapshot copy identifier that matches the data copy identifier, and determine the snapshot chain where the snapshot corresponding to the snapshot copy identifier is located as the target snapshot chain.

[0158] In one embodiment, the apparatus 1000 further includes:

[0159] A fourth determination module, further configured to, in the snapshot version lookup table, if there is no snapshot copy identifier that matches the data copy identifier, determine the snapshot chain where the snapshot containing the data block is located as the target snapshot chain.

[0160] In one embodiment, the second determination module 1002 is specifically configured to scan the target snapshot chain according to the rule of ascending order scanning of the snapshot copy identifiers to determine an initial scanning result;

[0161] If the number of read-only snapshots included in the initial scanning result meets a first preset condition, determine that the data block is in a shared state;

[0162] If the number of read-only snapshots included in the initial scanning result does not meet the first preset condition, determine the data sharing status of the data block based on the mapping relationship between the logical block address of the data block and the writable snapshots.

[0163] In one embodiment, the second determination module 1002 is specifically configured to, for the writable snapshots in the target snapshot chain, query in the snapshot mapping relationship table whether the mapping relationship between the logical block address of the data block and the current writable snapshot has been modified;

[0164] In the case where it has not been modified, determine that the data block is shared by the current writable snapshot and determine that the data block is in a shared state;

[0165] In the case where it has been modified, query the next writable snapshot of the current writable snapshot in the target snapshot chain, and execute the step of querying whether the mapping relationship between the logical block address of the data block and the current writable snapshot has been modified.

[0166] In one embodiment, the apparatus 1000 further includes:

[0167] a receiving module, configured to receive a snapshot write request, where the snapshot write request includes logical block address information of a snapshot to be written;

[0168] an obtaining module, configured to obtain a metadata node of the snapshot, and determine the number of data blocks of the snapshot based on the logical block address information;

[0169] a first query module, configured to query an indirect index including a starting address of the logical block address in the metadata node;

[0170] a write allocation module, configured to, if the indirect index is a valid value and the data block pointed to by the indirect index is in a shared state, split the indirect index to obtain a lower-level indirect index and a direct index, and allocate a persistent address for each indirect index and direct index;

[0171] an update module, configured to update the metadata node of the snapshot, and store the updated metadata node, each layer of indirect index, and direct index to the persistent address.

[0172] In one embodiment, the apparatus 1000 further includes:

[0173] a second query module, configured to, if the indirect index is an invalid value, query a lower-level indirect index of the indirect index in the metadata node until a direct index;

[0174] a third query module, configured to, if there is a lower-level indirect index or the direct index is a valid value and the data block pointed to by the lower-level indirect index or the direct index is in a shared state, perform the step of allocating a persistent address for each indirect index and direct index.

[0175] In one embodiment, the apparatus 1000 further includes:

[0176] a receiving module, configured to receive a snapshot deletion request, where the snapshot deletion request includes logical block address information of a valid snapshot and a metadata node of the snapshot to be deleted;

[0177] a fifth determination module, configured to determine the number of data blocks of the snapshot based on the logical block address information of the valid snapshot;

[0178] a fourth query module, configured to query a number of indirect indexes equal to the number of data blocks in the metadata node; the indirect index includes a starting address of the logical block address;

[0179] A deletion module, configured to query a lower - level indirect index and a direct index corresponding to an indirect index if a data block pointed to by the indirect index is in a shared state, and delete a target mapping relationship between the indirect index and the direct index based on the data sharing states of the data blocks pointed to by the lower - level indirect index and the direct index.

[0180] Each module in the above - mentioned apparatus for determining the space occupancy can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above - mentioned modules can be embedded in the processor of the computer device in hardware form or independent of the processor, or stored in the memory of the computer device in software form, so as to facilitate the processor to call and execute the operations corresponding to each of the above - mentioned modules.

[0181] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 11 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non - volatile storage medium and an internal memory. The non - volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non - volatile storage medium. The database of the computer device is used to store snapshot - related data. The input / output interface of the computer device is used for the processor to exchange information with external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a method for determining the space occupancy.

[0182] Those skilled in the art can understand that Figure 11 the structure shown in

[0183] is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.

[0184] In an embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the steps in the above - mentioned method embodiments.

[0185] In one embodiment, a computer program product is provided, including a computer program which, when executed by a processor, implements the steps in the above method embodiments.

[0186] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0187] Those of ordinary skill in the art can understand that all or part of the processes of implementing the above method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0188] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0189] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A method for determining the space occupancy, characterized in that The method includes: Determining a target snapshot chain corresponding to each data block; Determining the data sharing status of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot; Determining the target snapshot to which the data block belongs based on the data sharing status and a preset attribution rule, and determining the snapshot space occupancy based on the attribution results of each data block in the storage space.

2. The method according to claim 1, characterized in that, The determining a target snapshot chain corresponding to each data block includes: Obtaining a data copy identifier corresponding to each data block; In the snapshot version lookup table, querying for a snapshot copy identifier that matches the data copy identifier, and determining the snapshot chain where the snapshot corresponding to the snapshot copy identifier is located as the target snapshot chain.

3. The method according to claim 2, wherein The method further includes: In the snapshot version lookup table, if there is no snapshot copy identifier that matches the data copy identifier, determining the snapshot chain where the snapshot containing the data block is located as the target snapshot chain.

4. The method according to claim 1, characterized in that The determining the data sharing status of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot includes: Scanning the target snapshot chain according to the rule of ascending order scanning of the snapshot copy identifier to determine an initial scanning result; If the number of read-only snapshots included in the initial scanning result meets a first preset condition, determining that the data block is in a shared state; If the number of read-only snapshots included in the initial scanning result does not meet the first preset condition, determining the data sharing status of the data block based on the mapping relationship between the logical block address of the data block and the writable snapshot.

5. The method according to claim 1 or 4, characterized in that The determining the data sharing status of the data block based on the mapping relationship between the logical block address of the data block and the writable snapshot includes: For the writable snapshot in the target snapshot chain, querying in the snapshot mapping relationship table whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified; In the case of not being modified, determining that the data block is shared by the current writable snapshot and determining that the data block is in a shared state; In the case of being modified, querying the next writable snapshot of the current writable snapshot in the target snapshot chain, and performing the step of querying whether the mapping relationship between the logical block address of the data block and the current writable snapshot is modified.

6. The method according to claim 1, wherein The method further includes: Receiving a snapshot write request, where the snapshot write request includes logical block address information of the snapshot to be written; Obtaining the metadata node of the snapshot, and determining the number of data blocks of the snapshot based on the logical block address information; Querying an indirect index including the starting address of the logical block address in the metadata node; If the indirect index is a valid value and the data block pointed to by the indirect index is in a shared state, splitting the indirect index to obtain a lower-level indirect index and a direct index, and allocating persistent addresses to each of the indirect indexes and the direct index; Updating the metadata node of the snapshot, and storing the updated metadata node, each layer of indirect index and direct index to the persistent address.

7. The method according to claim 6, characterized in that, The method further includes: If the indirect index is an invalid value, query the lower-level indirect index of the indirect index in the metadata node until the direct index; If there is a lower-level indirect index or the direct index is a valid value and the data block pointed to by the lower-level indirect index or the direct index is in a shared state, perform the step of allocating a persistent address for each of the indirect index and the direct index.

8. The method according to claim 1, wherein The method further includes: Receiving a snapshot deletion request, where the snapshot deletion request includes the logical block address information of the valid snapshot and the metadata node of the snapshot to be deleted; Based on the logical block address information of the valid snapshot, determining the number of data blocks of the snapshot; Querying the number of indirect indexes of the data blocks in the metadata node; the indirect index includes the starting address of the logical block address; If the data block pointed to by the indirect index is in a shared state, query the lower-level indirect index and the direct index corresponding to the indirect index, and based on the data sharing state of the data block pointed to by the lower-level indirect index and the direct index, delete the target mapping relationship between the indirect index and the direct index.

9. A device for determining the space occupancy, characterized in that The apparatus includes: A first determination module, configured to determine a target snapshot chain corresponding to each data block; A second determination module, configured to determine the data sharing state of the data block based on the number of read-only snapshots included in the target snapshot chain and the mapping relationship between the logical block address of the data block and the writable snapshot; A third determination module, configured to determine the target snapshot to which the data block belongs based on the data sharing state and a preset attribution rule, and determine the snapshot space occupancy based on the attribution results of each data block in the storage space.

10. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.