A multi-copy storage method and multi-copy storage system for file data

In the distributed file storage system, the client receives the result of successful writing within the preset timeout period, selects multiple storage nodes and restores the data asynchronously, solving the problem of multiple copies caused by storage node downtime or slow writing speed. The problem of low storage efficiency is improved by improving the writing efficiency of file data.

CN112486942BActive Publication Date: 2024-08-30BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202011448185.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-09
Publication Date
2024-08-30
Estimated Expiration
2040-12-09

AI Technical Summary

Technical Problem

The existing multi-copy storage method of file data will lead to a decrease in writing speed and low efficiency when the storage node is down or the writing speed is slow, affecting the writing process of the entire target file.

Method used

The client receives the storage node address information returned by the control node, selects multiple storage nodes to be written, and sends a write request within the preset timeout period to determine the number of nodes successfully written, and if successful, updates the metadata information; If it fails, try again or recover the data asynchronously to avoid the impact of a single point of failure.

Benefits of technology

It improves the efficiency of multi-copy storage of file data, promptly detects and handles storage node failures or slow writing problems, implements asynchronous recovery and metadata updates, and avoids writing failures caused by failures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112486942B
    Figure CN112486942B
Patent Text Reader

Abstract

The embodiment of the present invention provides a multi-copy storage method and multi-copy storage system for file data, including: a control node verifies a second write request sent by a client, selects a first preset number of storage nodes when the verification is successful, and sends address information corresponding to the first preset number of storage nodes to the client; the client selects a storage node to be written, sends a first write request to the storage node to be written, and when it is determined that the number of write result information indicating successful writing received within a preset timeout period is not zero, determines the information corresponding to the storage node that has been successfully written as storage result information and sends it to the control node; when the number of storage nodes that have been successfully written is different from the second preset number, the control node backs up the data corresponding to the target file to storage nodes other than the storage node to be written, and updates the metadata information corresponding to the target file. The embodiment of the present invention can improve the efficiency of multi-copy storage of file data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a multi-copy storage method and a multi-copy storage system for file data. Background Art

[0002] A distributed file storage system refers to a file system that manages physical storage resources that are not necessarily directly connected to a local node, but are connected to a node (which can be simply understood as a computer) through a computer network; or a complete hierarchical file system formed by combining several different logical disk partitions or volumes. A distributed file storage system stores large amounts of data in different nodes, greatly reducing the risk of data loss.

[0003] The existing client performs a multi-copy storage method for file data as follows: the client sends a write request for a target file to a control node; the control node receives and verifies the write request, and when the verification is successful, returns the address information of a preset number of storage nodes to the client; the client receives the address information, and sends a data write request containing the data to be written to each storage node; the storage node receives and executes the write operation corresponding to the data write request, and then returns the write result information to the client; when the client receives the write result information returned by the preset number of storage nodes and each write result indicates that the write is successful, the client sends the write result information to the control node; when the control node receives the write result indicating that the write is successful, it updates the metadata information corresponding to the target file.

[0004] However, the inventors have discovered that in the process of storing file data using the existing multi-copy storage method for file data, due to reasons such as storage node crashes, the target file may fail to be written in one or more storage nodes, which will affect the writing speed of the entire target file, resulting in low multi-copy storage efficiency; or a certain storage node writes data slowly, resulting in slow writing of the entire target file, making the multi-copy storage efficiency of the entire file data low. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a method and system for storing multiple copies of file data to improve the storage efficiency of multiple copies of file data. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a method for storing multiple copies of file data, which is applied to a client in a distributed file storage system, wherein the distributed file storage system includes: a client, a control node, and a storage node, and the method includes:

[0007] receiving address information corresponding to a first preset number of storage nodes returned by the control node, and selecting a second preset number of storage nodes from the first preset number of storage nodes to obtain storage nodes to be written;

[0008] Sending a first write request to each storage node to be written respectively;

[0009] Determine the number of write result information indicating successful write received within a preset timeout period, wherein the write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request;

[0010] When the number of received write result information indicating successful writing is not zero, the information corresponding to the storage node where the writing is successful is determined as the storage result information;

[0011] The storage result information is sent to the control node, so that the control node updates the metadata information corresponding to the target file based on the storage result information.

[0012] Optionally, before receiving the address information corresponding to the first preset number of storage nodes returned by the control node, the method further includes:

[0013] A second write request for the target file is sent to the control node, so that the control node verifies the second write request and returns address information corresponding to a first preset number of storage nodes if the verification is successful.

[0014] Optionally, the method further includes:

[0015] When the number of received write result information indicating successful writing is zero, determining whether the number of times the first write request is sent to each of the storage nodes to be written reaches a preset number;

[0016] If the number of times the first write request is sent to each of the storage nodes to be written reaches a preset number, information on the failure of storing multiple copies of the target file is determined as storage result information, and a step of sending the storage result information to the control node is performed;

[0017] If the number of times the first write request is sent to each of the storage nodes to be written does not reach a preset number, the step of selecting a second preset number of storage nodes from the first preset number of storage nodes is performed.

[0018] In a second aspect, an embodiment of the present invention provides a method for storing multiple copies of file data, which is applied to a control node in a distributed file storage system, wherein the distributed file storage system includes: a client, a control node, and a storage node, and the method includes:

[0019] Verifying a second write request for a target file sent by the client, wherein the second write request corresponds to corresponding data to be written;

[0020] When the verification of the second write request succeeds, selecting a first preset number of storage nodes for the data to be written, and obtaining address information corresponding to the first preset number of storage nodes;

[0021] Sending address information corresponding to the first preset number of storage nodes to the client, so that the client sends a first write request to the storage node to be written, and the storage node to be written respectively performs corresponding write operations according to the first write request and returns write result information to the client; wherein the storage node to be written is selected from the first preset number of storage nodes, and the first write request includes the data to be written corresponding to the second write request for the target file;

[0022] Receiving storage result information returned by the client;

[0023] In the case where the storage result information includes corresponding information of storage nodes that are successfully written, determining whether the number of storage nodes that are successfully written is the same as a second preset number;

[0024] If the number of storage nodes that have been written successfully is different from the second preset number, the data corresponding to the target file in the storage nodes that have been written successfully is backed up to storage nodes other than the storage nodes to be written, and the metadata information corresponding to the target file is updated.

[0025] Optionally, the method further includes:

[0026] If the number of storage nodes to which the data is written successfully is the same as the second preset number, the metadata information corresponding to the target file is updated.

[0027] Optionally, the step of backing up the data corresponding to the target file in the storage node that has been written successfully to storage nodes other than the storage nodes to be written includes:

[0028] Based on the number of storage nodes where writing succeeds, determine the number of storage nodes where writing fails as a first number;

[0029] The data corresponding to the target file in the storage node that has been written successfully is backed up to a first number of storage nodes among a first preset number of storage nodes except the storage nodes to be written.

[0030] Optionally, the step of selecting a first preset number of storage nodes for the data to be written includes:

[0031] According to the size of the data to be written corresponding to the second write request and the remaining space size of each storage node, a first preset number of storage nodes is selected for the data to be written.

[0032] Optionally, the method further includes:

[0033] In a case where the storage result information includes information about a failure in storing multiple copies of a target file, metadata information corresponding to the target file is not updated.

[0034] Optionally, the method further includes:

[0035] The self-state information sent by the storage node is received, wherein the self-state information of the storage node includes: the node state of the storage node and the remaining space size of the storage node.

[0036] In a third aspect, an embodiment of the present invention provides a multi-copy storage system for file data, the multi-copy storage system for file data comprising: a client and a control node;

[0037] The client is used to send a second write request for the target file to the control node, and receive address information corresponding to a first preset number of storage nodes returned by the control node, and select a second preset number of storage nodes from the first preset number of storage nodes to obtain each storage node to be written, send a first write request to each storage node to be written respectively, determine the number of write result information indicating successful writing received within a preset timeout period, and when the number of write result information indicating successful writing received is not zero, determine the information corresponding to the storage node that has been successfully written as storage result information, and send the storage result information to the control node; wherein, the write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request;

[0038] The control node is used to verify the second write request for the target file sent by the client, and when the second write request is successfully verified, select a first preset number of storage nodes for the data to be written, obtain address information corresponding to the first preset number of storage nodes, send the address information corresponding to the first preset number of storage nodes to the client, and receive storage result information returned by the client. When the storage result information contains the corresponding information of the storage nodes that are successfully written, determine whether the number of storage nodes that are successfully written is the same as the second preset number; if the number of storage nodes that are successfully written is different from the second preset number, back up the data corresponding to the target file in the storage nodes that are successfully written to the storage nodes other than the storage nodes to be written, and update the metadata information corresponding to the target file; wherein, the second write request corresponds to the corresponding data to be written.

[0039] Optionally, the system further includes a storage node;

[0040] The storage node is used to receive a first write request sent by a client, perform a corresponding write operation according to the first write request, and return write result information to the client.

[0041] Optionally, the client is further used to:

[0042] When the number of received write result information indicating successful writing is zero, determining whether the number of times the first write request is sent to each of the storage nodes to be written reaches a preset number;

[0043] If the number of times the first write request is sent to each storage node to be written reaches a preset number, information on the failure of storing multiple copies of the target file is determined as storage result information, and an operation of sending the storage result information to the control node is performed;

[0044] If the number of times the first write request is sent to each of the storage nodes to be written does not reach a preset number, an operation of selecting a second preset number of storage nodes from the first preset number of storage nodes is performed.

[0045] Optionally, the control node is further used to:

[0046] When the number of storage nodes to which the data is written successfully is the same as the second preset number, the metadata information corresponding to the target file is updated.

[0047] Optionally, the control node is specifically used to:

[0048] Based on the number of storage nodes where writing succeeds, determine the number of storage nodes where writing fails as a first number;

[0049] The data corresponding to the target file in the storage node that has been written successfully is backed up to a first number of storage nodes among a first preset number of storage nodes except the storage nodes to be written.

[0050] Optionally, the control node is further used to:

[0051] In a case where the storage result information includes information about a failure in storing multiple copies of a target file, metadata information corresponding to the target file is not updated.

[0052] Optionally, the storage node is further used for:

[0053] Sending its own status information to the control node, wherein the own status information includes: the node status and the remaining space size.

[0054] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of a method for storing multiple copies of file data described in the first aspect above are implemented.

[0055] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of a method for storing multiple copies of file data described in the second aspect above are implemented.

[0056] Beneficial effects of the embodiments of the present invention:

[0057] The embodiment of the present invention provides a method and system for storing multiple copies of file data. The client can send a first write request to each storage node to be written to realize concurrent writing of multiple copy files, and the client sets a preset timeout period, and then determines the number of write result information indicating successful writing received within the preset timeout period, so as to timely discover the situation where data writing fails due to storage node crash or storage node writes data slowly, and send the storage result information to the control node. When the number of storage nodes that have been successfully written is different from the second preset number, the control node backs up the data corresponding to the target file in the storage node that has been successfully written to the storage node, and realizes asynchronous recovery of the failed writing data, and updates the metadata information corresponding to the target file, thereby avoiding the problem of low efficiency of multi-copy storage caused by data writing failure due to storage node crash or storage node writes data slowly, and can improve the efficiency of multi-copy storage of file data.

[0058] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.

[0060] Figure 1 A schematic diagram of a flow chart of a first method for storing multiple copies of file data provided by an embodiment of the present invention;

[0061] Figure 2 A schematic diagram of a flow chart of a second method for storing multiple copies of file data provided by an embodiment of the present invention;

[0062] Figure 3 A schematic diagram of a flow chart of a third method for storing multiple copies of file data provided by an embodiment of the present invention;

[0063] Figure 4 A schematic diagram of a flow chart of an asynchronous data recovery implementation method provided by an embodiment of the present invention;

[0064] Figure 5 An interactive schematic diagram of a method for storing multiple copies of file data provided by an embodiment of the present invention;

[0065] Figure 6 A schematic diagram of the structure of a multi-copy storage system for file data provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0067] The distributed file storage system has redundancy. The failure of some nodes does not affect the normal operation of the whole system. Even if the data stored in the failed computer is damaged, other nodes can restore the damaged data. A typical distributed file storage system is generally composed of a control node (or metadata server) and a storage node (or data server). The main functions of the control node are: managing the directory tree, managing the metadata information of the files uploaded by the client (or user) (such as file directory, file name, file upload time, file size, which storage nodes the file data is distributed on, etc.), and managing all storage nodes in the distributed file storage system. The main functions of the storage node are: storing the file data uploaded by the client.

[0068] In order to solve the problem that the target file writing in one or more storage nodes fails due to reasons such as storage node downtime, which affects the writing speed of the entire target file and leads to low efficiency of multi-copy storage; or a certain storage node writes data slowly, resulting in slow writing of the entire target file, making the multi-copy storage efficiency of the entire file data low, an embodiment of the present invention provides a multi-copy storage method for file data, which is applied to a client in a distributed file storage system, the distributed file storage system includes: a client, a control node and a storage node, and the method may include:

[0069] receiving address information corresponding to a first preset number of storage nodes returned by the control node, and selecting a second preset number of storage nodes from the first preset number of storage nodes to obtain storage nodes to be written;

[0070] Sending a first write request to each storage node to be written respectively;

[0071] Determine the number of write result information indicating successful write received within a preset timeout period, wherein the write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request;

[0072] When the number of received write result information indicating successful writing is not zero, the information corresponding to the storage node where the writing is successful is determined as the storage result information;

[0073] The storage result information is sent to the control node, so that the control node updates the metadata information corresponding to the target file based on the storage result information.

[0074] The embodiment of the present invention provides a method and system for storing multiple copies of file data. The client can send a first write request to each storage node to be written to realize concurrent writing of multiple copy files, and the client sets a preset timeout period, and then determines the number of write result information indicating successful writing received within the preset timeout period, so as to timely discover the situation where data writing fails due to storage node crash or storage node writes data slowly, and send the storage result information to the control node. When the number of storage nodes that have been successfully written is different from the second preset number, the control node backs up the data corresponding to the target file in the storage node that has been successfully written to the storage node, and realizes asynchronous recovery of the failed writing data, and updates the metadata information corresponding to the target file, thereby avoiding the problem of low efficiency of multi-copy storage caused by data writing failure due to storage node crash or storage node writes data slowly, and can improve the efficiency of multi-copy storage of file data.

[0075] The following is a detailed description of a method for storing multiple copies of file data provided by an embodiment of the present invention:

[0076] In an embodiment of the present invention, a method for storing multiple copies of file data is applied to a distributed file storage system, which may include a client, a control node, and multiple storage nodes. Exemplarily, the control node and the multiple storage nodes may be data storage modules respectively arranged on different servers.

[0077] like Figure 1 As shown, an embodiment of the present invention provides a first method for storing multiple copies of file data, which is applied to a client in a distributed file storage system. The method may include the following steps:

[0078] S101, receiving address information corresponding to a first preset number of storage nodes returned by a control node, and selecting a second preset number of storage nodes from the first preset number of storage nodes to obtain storage nodes to be written.

[0079] As an optional implementation of the embodiment of the present invention, before receiving the address information corresponding to the first preset number of storage nodes returned by the control node in step S101, the following steps may also be performed:

[0080] A second write request for the target file is sent to the control node, so that the control node verifies the second write request and returns address information corresponding to a first preset number of storage nodes if the verification is successful.

[0081] In an embodiment of the present invention, when data needs to be written to a target file, the client may send a second write request for the target file to the control node. As an optional implementation of the embodiment of the present invention, the second write request sent by the client may include: an identifier of the client, the size of the amount of data to be written corresponding to the second write request for the target file, and other information, so that the control node can verify the second write request.

[0082] When the client receives the address information corresponding to the first preset number of storage nodes returned by the control node after the second write request is successfully verified, the client selects the second preset number of storage nodes from the first preset number of storage nodes and determines them as the storage nodes to be written. Those skilled in the art can set the first preset number and the second preset number according to actual needs.

[0083] Exemplarily, when the client interacts with the control node, if the control node successfully verifies the second write request, it can return the address information corresponding to 5-6 storage nodes. The client selects 3 storage nodes from the 5-6 storage nodes as the storage nodes to be written. The specific selection basis may be the remaining storage space of each storage node, etc.

[0084] S102, sending a first write request to each storage node to be written.

[0085] The first write request may include the to-be-written data corresponding to the second write request for the target file.

[0086] S103, determining the number of writing result information indicating successful writing received within a preset timeout period.

[0087] The client may pre-set a preset timeout period, which may be the time required for most storage nodes in the distributed file storage system to normally write data. Specific technicians in this field may set it according to actual needs.

[0088] After the client sends a first write request to each storage node to be written, each storage node to be written executes the write operation corresponding to the first write request and returns write result information. The client can determine the number of write result information indicating successful write received within a preset timeout period. The write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request.

[0089] S104: When the number of received write result information indicating successful writing is not zero, information corresponding to the storage node that has been successfully written is determined as storage result information.

[0090] When the number of received write result information indicating successful writing is not zero, it means that the target file is successfully written to the storage node to be written within the preset timeout period, and at this time, the information corresponding to the storage node that is successfully written is determined as the storage result information. The information corresponding to the storage node that is successfully written may include the identification of the storage node that is successfully written, address information, and remaining storage space and other information.

[0091] S105: Send the storage result information to the control node, so that the control node updates the metadata information corresponding to the target file based on the storage result information.

[0092] The metadata information corresponding to the target file may include: the size of the target file, and the information of the storage node where the target file is written.

[0093] An embodiment of the present invention provides a method for storing multiple copies of file data. The client can send a first write request to each storage node to be written to realize concurrent writing of multiple copy files. In addition, the client sets a preset timeout period, and then determines the number of write result information indicating successful writing received within the preset timeout period. It can timely discover the situation where data writing fails due to storage node crash or storage node writes data slowly, and send the storage result information to the control node. When the number of storage nodes that have been successfully written is different from the second preset number, the control node backs up the data corresponding to the target file in the storage node that has been successfully written to the storage node, and backs it up to the storage node other than the storage node to be written, realizing asynchronous recovery of the failed writing data, and updating the metadata information corresponding to the target file, avoiding the problem of low efficiency of multi-copy storage caused by data writing failure due to storage node crash or storage node write data slowly, and can improve the efficiency of multi-copy storage of file data.

[0094] like Figure 2 As shown, an embodiment of the present invention provides a second method for storing multiple copies of file data, which is applied to a client in a distributed file storage system. The method may include the following steps:

[0095] S201, sending a second write request for a target file to a control node, so that the control node verifies the second write request and returns address information corresponding to a first preset number of storage nodes if the verification is successful.

[0096] S202, receiving address information corresponding to a first preset number of storage nodes returned by the control node, and selecting a second preset number of storage nodes from the first preset number of storage nodes to obtain storage nodes to be written.

[0097] S203, sending a first write request to each storage node to be written.

[0098] S204, determining the number of writing result information indicating successful writing received within a preset timeout period.

[0099] The write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request.

[0100] S205: When the number of received write result information indicating successful writing is not zero, information corresponding to the storage node that has been successfully written is determined as storage result information.

[0101] S206: Send the storage result information to the control node, so that the control node updates the metadata information corresponding to the target file based on the storage result information.

[0102] The metadata information corresponding to the target file includes: the size of the target file and the information of the storage node where the target file is written.

[0103] The implementation process of steps S201-S206 may be the same as the above-mentioned steps S101-S105, and the embodiments of the present invention will not be described in detail here.

[0104] S207: When the number of received write result information indicating successful write is zero, determine whether the number of times the first write request is sent to each storage node to be written reaches a preset number.

[0105] When the number of write result information received indicating successful writing is zero, it means that no storage node to be written successfully wrote the target file within the preset timeout period. At this time, it is determined whether the number of times the first write request is sent to each storage node to be written reaches the preset number. The preset number can be a preset number of target file retry writes, which can be set by those skilled in the art according to actual needs. For example, the preset number can be set to 3 times or 5 times.

[0106] Exemplarily, in an embodiment of the present invention, the client may count the number of times the first write request is sent to the storage node to be written, compare the number with a preset number of retry writes, and retry writing of the corresponding data of the target file when the writing of the target file fails.

[0107] S208: If the number of times the first write request is sent to each storage node to be written reaches a preset number, the information that the target file multiple copies have failed to be stored is determined as storage result information, and the operation of step S206 is performed.

[0108] When it is determined that the number of times the first write request is sent to each storage node to be written reaches the preset number, that is, when the number of retry writes of the target file reaches the preset number, the target file will no longer be retried, the information on the failure of storing multiple copies of the target file will be determined as storage result information, and step S206 will be executed to send the storage result information to the control node.

[0109] When it is determined that the number of times the first write request is sent to each storage node to be written does not reach the preset number, that is, the number of retry writes of the target file does not reach the preset number, return to executing the operation of selecting a second preset number of storage nodes from the first preset number of storage nodes in step S202.

[0110] As an optional implementation manner of an embodiment of the present invention, when it is determined that the number of times the first write request is sent to each storage node to be written does not reach a preset number of times, a second preset number of storage nodes other than the selected storage nodes to be written can be selected from the first preset number of storage nodes as the storage nodes to be written for retrying to write the target file, so as to increase the probability of successful writing of the target file.

[0111] The embodiment of the present invention provides a method for storing multiple copies of file data. The client can send a first write request to each storage node to be written to realize concurrent writing of multiple copy files. The client sets a preset timeout period, and then determines the number of write result information indicating successful writing received within the preset timeout period. The situation that data writing fails due to storage node downtime or storage node writes data slowly can be discovered in time, and the storage result information is sent to the control node. At the same time, when no target file is successfully written within the preset timeout period, the number of retries is set to retry writing the target file to increase the probability of successful writing of the target file. When the number of storage nodes that are successfully written is different from the second preset number, the control node backs up the data corresponding to the target file in the storage node that is successfully written to the storage node to the storage node other than the storage nodes to be written, realizes asynchronous recovery of the failed writing data, and updates the metadata information corresponding to the target file, avoiding the problem of low efficiency of multi-copy storage caused by data writing failure due to storage node downtime or storage node writing data slowly, and can improve the efficiency of multi-copy storage of file data.

[0112] like Figure 3 As shown, an embodiment of the present invention provides a third method for storing multiple copies of file data, which is applied to a control node in a distributed file storage system. The method may include the following steps:

[0113] S301, verifying a second write request for a target file sent by a client, wherein the second write request corresponds to corresponding data to be written.

[0114] As an optional implementation of an embodiment of the present invention, the second write request for the target file sent by the client may include: the client's identification, the size of the data to be written corresponding to the second write request for the target file, and other information. Then, the control node verifies the second write request for the target file sent by the client, which may be a verification of the client's authority. For example, when receiving the second write request for the target file sent by the client, it can be determined whether the client has the authority to perform the write operation on the target file. The control node verifies the second write request for the target file sent by the client, and may also verify the size of the data to be written corresponding to the second write request.

[0115] S302: When the second write request is verified successfully, a first preset number of storage nodes are selected for the data to be written, and address information corresponding to the first preset number of storage nodes is obtained.

[0116] In an embodiment of the present invention, a control node may store a management directory tree of different files, metadata information of the files, and storage node information, etc. The metadata information may include: file directory, file name, file upload time, file size, storage nodes on which the file data is distributed, etc. The storage node information may include the remaining space size of the storage node, or the availability of the remaining space of the storage node, etc.

[0117] When the control node successfully verifies the second write request, a first preset number of storage nodes can be selected for the data to be written to the target file, and address information corresponding to the first preset number of storage nodes can be obtained. The first preset number can be set by a person skilled in the art according to actual needs. For example, to ensure the reliability of the file data and the success rate of writing the target file, the preset number can be set to 5-6, so that the client can select 3 storage nodes from 5-6 storage nodes to be determined as the storage nodes to be written.

[0118] As an optional implementation of the embodiment of the present invention, the step of selecting a first preset number of storage nodes for the data to be written may include:

[0119] According to the size of the data to be written corresponding to the second write request and the remaining space size of each storage node, a first preset number of storage nodes is selected for the data to be written.

[0120] In an embodiment of the present invention, the control node can sort the storage nodes that can store the data to be written according to the size of the data amount to be written corresponding to the second write request and the remaining space size of each storage node, obtain a storage node sequence, and then select a preset number of storage nodes from the storage node sequence.

[0121] S303, sending address information corresponding to a first preset number of storage nodes to the client, so that the client sends a first write request to the storage nodes to be written, and the storage nodes to be written respectively perform corresponding write operations according to the first write request and return write result information to the client.

[0122] The storage node to be written is selected from a first preset number of storage nodes, and the first write request includes the data to be written corresponding to the second write request for the target file.

[0123] S304, receiving storage result information returned by the client.

[0124] S305: When the storage result information includes corresponding information of storage nodes that have been written successfully, determine whether the number of storage nodes that have been written successfully is the same as a second preset number.

[0125] The control node receives the storage result information returned by the client, and further determines whether the number of storage nodes that have been successfully written is the same as the second preset number when the storage result information contains the corresponding information of the storage nodes that have been successfully written. If the number of storage nodes that have been successfully written is the same as the second preset number, it means that the expected number of multiple copies of the target file have been successfully stored. If the number of storage nodes that have been successfully written is different from the second preset number, it means that the storage of multiple copies of the expected number of target files has not been completed, and only the storage of copies of some target files has been completed. At this time, step S306 is executed.

[0126] S306, if the number of storage nodes successfully written is different from the second preset number, the data corresponding to the target file in the storage nodes successfully written is backed up to the storage nodes other than the storage nodes to be written, and the metadata information corresponding to the target file is updated.

[0127] If the number of storage nodes that are successfully written is different from the second preset number, that is, the multi-copy storage of the expected number of target files is not completed, and only the copy storage of some target files is completed, the data corresponding to the target files in the storage nodes that are successfully written are backed up to the storage nodes other than the storage nodes to be written, and the data corresponding to the target files are asynchronously restored to complete the multi-copy storage of the expected number of target files, and the metadata information corresponding to the target files is updated. The metadata information corresponding to the target files includes: the size of the target files, and the information of the storage nodes where the target files are written.

[0128] An embodiment of the present invention provides a method for storing multiple copies of file data. When the number of storage nodes to which writing has been successful is different from a second preset number, the control node backs up the data corresponding to the target file in the storage node to which writing has been successful to storage nodes other than the storage nodes to be written, thereby realizing asynchronous recovery of the writing failed data, so as to complete the storage of multiple copies of the expected number of target files, and update the metadata information corresponding to the target files, thereby avoiding the problem of low efficiency of multiple copy storage caused by data writing failure due to storage node crash or slow data writing of the storage node, and being able to improve the efficiency of multiple copy storage of file data.

[0129] As an optional implementation of the embodiment of the present invention, the third method for storing multiple copies of file data may further include:

[0130] When the storage result information includes information about the failure of storing multiple copies of the target file, the metadata information corresponding to the target file is not updated.

[0131] In the embodiment of the present invention, when the received storage result information includes the target file multiple copy storage failure information, that is, when the target file multiple copy storage fails, the control node does not update the metadata information corresponding to the target file.

[0132] As an optional implementation of the embodiment of the present invention, the third method for storing multiple copies of file data may further include:

[0133] If the number of storage nodes to which the data is written successfully is the same as the second preset number, the metadata information corresponding to the target file is updated.

[0134] If the number of storage nodes that are successfully written is the same as the second preset number, it means that the expected number of multiple copies of the target file are successfully stored. At this time, the metadata information corresponding to the target file is directly updated.

[0135] As an optional implementation of the embodiment of the present invention, Figure 4 As shown, in step S306, the implementation method of backing up the data corresponding to the target file in the storage node that has been written successfully to the storage nodes other than the storage nodes to be written may include:

[0136] S3061: Based on the number of storage nodes where writing succeeds, determine the number of storage nodes where writing fails as a first number.

[0137] Based on the expected number of multiple copies of the target file stored (i.e., the second preset number) and the number of storage nodes to which writing is successful, the number of storage nodes to which writing fails is determined as the first number. Exemplarily, the difference between the second preset number and the number of storage nodes to which writing is successful can be determined as the number of storage nodes to which writing fails, i.e., the first number.

[0138] S3062, backing up the data corresponding to the target file in the storage node that has been written successfully to a first number of storage nodes among a first preset number of storage nodes excluding the storage nodes to be written.

[0139] After determining the number of storage nodes where writing fails, the data corresponding to the target file in the storage nodes where writing succeeds can be backed up to a first number of storage nodes among a first preset number of storage nodes, excluding each storage node to be written, to increase the probability of successful storage of the data to be written corresponding to the target file. The storage nodes to be written are: each storage node corresponding to the first write request corresponding to the storage node where writing succeeds.

[0140] As an optional implementation of the embodiment of the present invention, the control node may also receive its own status information sent by the storage node, wherein the storage node's own status information may include: the node status of the storage node, and the remaining space size of the storage node. Exemplarily, the status of the storage node may include information such as whether the storage node is working normally, the normal speed of data writing, etc., and the remaining space size of the storage node is the size of the space that the storage node can currently use.

[0141] In the embodiment of the present invention, the control node may receive its own status information sent by the storage node, and then update the status information of the storage node stored in the control node, so as to more accurately select the storage node to be written for the data to be written.

[0142] Exemplarily, client A sends a second write request for the target file to the control node. After the control node receives the second write request for the target file sent by client A, it can verify the second write request sent by client A. When the verification is successful, six storage nodes B, C, D, E, F and G are selected for the data to be written, and the address information corresponding to the storage nodes B, C, D, E, F and G is sent to client A.

[0143] Client A receives the address information corresponding to the storage nodes B, C, D, E, F and G returned by the control node, selects a second preset number (3) of storage nodes B, C, D from B, C, D, E, F and G as the storage nodes to be written, and sends a first write request to the storage nodes B, C, D respectively.

[0144] Client A determines that the number of write result information indicating successful writing received within the preset timeout period is 1, determines the information corresponding to the storage node where the writing is successful as the storage result information and sends it to the control node. The control node receives the storage result information, determines that the number of storage nodes where the writing is successful is different from the second preset number, backs up the data corresponding to the target file in the storage node where the writing is successful (assuming that the data is successfully written in the storage node B) to the storage nodes (any two of E, F and G) other than the storage nodes to be written (i.e., storage nodes B, C, and D), and updates the metadata information corresponding to the target file.

[0145] Alternatively, client A determines that the number of write result information indicating successful writing received within the preset timeout period is 0, and further determines whether the number of times the first write request is sent to each storage node to be written reaches the preset number of times. If the number of times the first write request is sent to each storage node to be written (the third time) reaches the preset number of times (three times), the information on the failure to store multiple copies of the target file is determined as the storage result information, and the storage result information is sent to the control node. The control node receives the storage result information containing the information on the failure to store multiple copies of the target file, and does not update the metadata information corresponding to the target file. If the number of times the first write request is sent to each storage node to be written (the first time) does not reach the preset number of times (three times), select storage nodes E, F and G from B, C, D, E, F and G as the storage nodes to be written, and send the first write request to storage nodes E, F and G respectively, and perform subsequent operations (the same as above).

[0146] like Figure 5 As shown, Figure 5 An interactive schematic diagram of a method for storing multiple copies of file data provided by an embodiment of the present invention.

[0147] The client sends a second write request for the target file to the control node.

[0148] The control node verifies the second write request for the target data sent by the client. When the verification of the second write request is successful, a first preset number of storage nodes are selected for the data to be written, address information corresponding to the first preset number of storage nodes is obtained, and the address information corresponding to the first preset number of storage nodes is sent to the client.

[0149] The client receives address information corresponding to a first preset number of storage nodes returned by the control node, selects a second preset number of storage nodes from the first preset number of storage nodes, obtains each storage node to be written, and sends a first write request to each storage node to be written.

[0150] The client determines the number of write result information indicating successful writing received within a preset timeout period. When the number of write result information indicating successful writing received is not zero, the information corresponding to the storage node to which the writing is successful is determined as the storage result information; when the number of write result information indicating successful writing received is zero, it is determined whether the number of times the first write request is sent to each storage node to be written reaches the preset number. If the number of times the first write request is sent to each storage node to be written reaches the preset number, the information on the failure of storing multiple copies of the target file is determined as the storage result information. If the number of times the first write request is sent to each storage node to be written does not reach the preset number, the step of selecting a second preset number of storage nodes from the first preset number of storage nodes is executed; and the storage result information is sent to the control node.

[0151] The control node receives the storage result information returned by the client, and in the case where the storage result information includes the corresponding information of the storage nodes that are successfully written, determines whether the number of the storage nodes that are successfully written is the same as the second preset number. If the number of the storage nodes that are successfully written is different from the second preset number, the data corresponding to the target file in the storage nodes that are successfully written is backed up to the storage nodes other than the storage nodes to be written, and the metadata information corresponding to the target file is updated; if the number of the storage nodes that are successfully written is the same as the second preset number, the metadata information corresponding to the target file is updated. In the case where the storage result information includes the information that the storage of multiple copies of the target file fails, the metadata information corresponding to the target file is not updated.

[0152] Corresponding to the above method embodiments, the embodiments of the present invention also provide corresponding system embodiments.

[0153] like Figure 6 As shown, an embodiment of the present invention provides a multi-copy storage system for file data, and the multi-copy storage system for file data includes: a client and a control node;

[0154] The client 402 is used to send a second write request for a target file to the control node 401, and receive address information corresponding to a first preset number of storage nodes returned by the control node 401, and select a second preset number of storage nodes from the first preset number of storage nodes to obtain each storage node to be written, and send a first write request to each storage node to be written respectively, and determine the number of write result information indicating successful writing received within a preset timeout period, and when the number of write result information indicating successful writing received is not zero, determine the information corresponding to the storage node that has been successfully written as the storage result information, and send the storage result information to the control node 401; wherein, the write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request.

[0155] The control node 401 is used to verify the second write request for the target file sent by the client 402. When the second write request is successfully verified, a first preset number of storage nodes are selected for the data to be written, and address information corresponding to the first preset number of storage nodes is obtained, and the address information corresponding to the first preset number of storage nodes is sent to the client 402, and storage result information returned by the client 402 is received. When the storage result information includes the corresponding information of the storage nodes that are successfully written, it is determined whether the number of the storage nodes that are successfully written is the same as the second preset number. If the number of the storage nodes that are successfully written is different from the second preset number, the data corresponding to the target file in the storage nodes that are successfully written is backed up to the storage nodes other than the storage nodes to be written, and the metadata information corresponding to the target file is updated; wherein, the second write request corresponds to the corresponding data to be written.

[0156] The embodiment of the present invention provides a multi-copy storage system for file data, in which a client can send a first write request to each storage node to be written to realize concurrent writing of multiple copy files, and the client sets a preset timeout period, and then determines the number of write result information indicating successful writing received within the preset timeout period, so as to timely discover the situation where data writing fails due to storage node crash or storage node writes data slowly, and send the storage result information to the control node. When the number of storage nodes that have been successfully written is different from the second preset number, the control node backs up the data corresponding to the target file in the storage node that has been successfully written to the storage node, and backs up the data corresponding to the target file in the storage node except for each storage node to be written, so as to realize asynchronous recovery of the failed writing data, and update the metadata information corresponding to the target file, so as to avoid the problem of low efficiency of multi-copy storage caused by data writing failure due to storage node crash or storage node write data slowly, and can improve the efficiency of multi-copy storage of file data.

[0157] Optionally, the system further includes a storage node 403:

[0158] The storage node 403 is used to receive the first write request sent by the client 402 , perform a corresponding write operation according to the first write request, and return write result information to the client 402 .

[0159] Optionally, client 402 is also used to:

[0160] When the number of received write result information indicating successful writing is zero, determining whether the number of times the first write request is sent to each storage node to be written reaches a preset number;

[0161] If the number of times the first write request is sent to each storage node to be written reaches a preset number, the information that the target file multiple copies have failed to be stored is determined as storage result information, and an operation of sending the storage result information to the control node 401 is performed;

[0162] If the number of times the first write request is sent to each storage node to be written does not reach the preset number, an operation of selecting a second preset number of storage nodes from the first preset number of storage nodes is performed.

[0163] Optionally, the control node 401 is further configured to:

[0164] When the number of storage nodes 403 to which the data is written successfully is the same as the second preset number, the metadata information corresponding to the target file is updated.

[0165] Optionally, the control node 401 is specifically used for:

[0166] Based on the number of storage nodes to which writing succeeds, determine the number of storage nodes to which writing fails as a first number;

[0167] The data corresponding to the target file in the storage node that has been written successfully is backed up to a first number of storage nodes among the first preset number of storage nodes except for each storage node to be written.

[0168] Optionally, the control node 401 is further configured to:

[0169] When the storage result information includes information about the failure of storing multiple copies of the target file, the metadata information corresponding to the target file is not updated.

[0170] Optionally, the storage node 403 is further used for:

[0171] The node sends its own status information to the control node 401, where the status information includes: node status and remaining space size.

[0172] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, which stores a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned multiple-copy storage methods for file data are implemented to achieve the same effect.

[0173] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0174] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0175] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for storing multiple copies of file data, characterized in that: The method is applied to a client in a distributed file storage system, wherein the distributed file storage system comprises: a client, a control node and a storage node, and the method comprises: receiving address information corresponding to a first preset number of storage nodes returned by the control node, and selecting a second preset number of storage nodes from the first preset number of storage nodes to obtain storage nodes to be written; Sending a first write request to each storage node to be written respectively; Determine the number of write result information indicating successful write received within a preset timeout period, wherein the write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request; When the number of received write result information indicating successful writing is not zero, the information corresponding to the storage node where the writing is successful is determined as the storage result information; Sending the storage result information to the control node, so that the control node updates the metadata information corresponding to the target file based on the storage result information; the target file is the file to be written data corresponding to the first write request; When the number of received write result information indicating successful writing is zero, determining whether the number of times the first write request is sent to each of the storage nodes to be written reaches a preset number; If the number of times the first write request is sent to each of the storage nodes to be written reaches a preset number, information on the failure of storing multiple copies of the target file is determined as storage result information, and a step of sending the storage result information to the control node is performed; If the number of times the first write request is sent to each of the storage nodes to be written does not reach a preset number, the step of selecting a second preset number of storage nodes from the first preset number of storage nodes is performed.

2. The method according to claim 1, characterized in that Before receiving address information corresponding to a first preset number of storage nodes returned by the control node, the method further includes: A second write request for the target file is sent to the control node, so that the control node verifies the second write request and returns address information corresponding to a first preset number of storage nodes if the verification is successful.

3. A method for storing multiple copies of file data, characterized in that: A control node applied to a distributed file storage system, the distributed file storage system comprising: a client, a control node and a storage node, the method comprising: Verifying a second write request for a target file sent by the client, wherein the second write request corresponds to corresponding data to be written; When the verification of the second write request succeeds, selecting a first preset number of storage nodes for the data to be written, and obtaining address information corresponding to the first preset number of storage nodes; Sending address information corresponding to the first preset number of storage nodes to the client, so that the client sends a first write request to the storage node to be written, and the storage node to be written respectively performs corresponding write operations according to the first write request, and returns write result information to the client; wherein the storage node to be written is selected from the first preset number of storage nodes, and the first write request contains the data to be written corresponding to the second write request for the target file; Receiving storage result information returned by the client; In the case where the storage result information includes corresponding information of storage nodes that are successfully written, determining whether the number of storage nodes that are successfully written is the same as a second preset number; If the number of storage nodes that have been written successfully is different from the second preset number, the data corresponding to the target file in the storage nodes that have been written successfully is backed up to storage nodes other than the storage nodes to be written, and the metadata information corresponding to the target file is updated.

4. The method according to claim 3, characterized in that The method further comprises: If the number of storage nodes to which the data is written successfully is the same as the second preset number, the metadata information corresponding to the target file is updated.

5. The method according to claim 3 or 4, characterized in that: The step of backing up the data corresponding to the target file in the storage node that has been written successfully to storage nodes other than the storage nodes to be written comprises: Based on the number of storage nodes where writing succeeds, determine the number of storage nodes where writing fails as a first number; The data corresponding to the target file in the storage node that has been written successfully is backed up to a first number of storage nodes among a first preset number of storage nodes except the storage nodes to be written.

6. The method according to claim 3, characterized in that The step of selecting a first preset number of storage nodes for the data to be written includes: According to the size of the data to be written corresponding to the second write request and the remaining space size of each storage node, a first preset number of storage nodes is selected for the data to be written.

7. The method according to claim 3, characterized in that The method further comprises: In a case where the storage result information includes information about a failure to store multiple copies of a target file, metadata information corresponding to the target file is not updated.

8. The method according to claim 3, characterized in that The method further comprises: The self-state information sent by the storage node is received, wherein the self-state information of the storage node includes: the node state of the storage node and the remaining space size of the storage node.

9. A multi-copy storage system for file data, characterized in that: The multi-copy storage system for file data includes: a client and a control node; The client is used to send a second write request for the target file to the control node, and receive address information corresponding to a first preset number of storage nodes returned by the control node, and select a second preset number of storage nodes from the first preset number of storage nodes to obtain each storage node to be written, send a first write request to each storage node to be written respectively, determine the number of write result information indicating successful writing received within a preset timeout period, and when the number of write result information indicating successful writing received is not zero, determine the information corresponding to the storage node that has been successfully written as storage result information, and send the storage result information to the control node; wherein the write result information indicates the result of the storage node to be written executing the write operation corresponding to the first write request; the second write request corresponds to the corresponding data to be written; the first write request contains the data to be written corresponding to the second write request for the target file; the target file is the file to be written data corresponding to the first write request; The control node is used to verify the second write request for the target file sent by the client, and when the second write request is successfully verified, select a first preset number of storage nodes for the data to be written, obtain address information corresponding to the first preset number of storage nodes, send the address information corresponding to the first preset number of storage nodes to the client, and receive storage result information returned by the client. When the storage result information contains the corresponding information of the storage nodes that are successfully written, determine whether the number of storage nodes that are successfully written is the same as the second preset number; if the number of storage nodes that are successfully written is different from the second preset number, back up the data corresponding to the target file in the storage nodes that are successfully written to storage nodes other than the storage nodes to be written, and update the metadata information corresponding to the target file.

10. The system according to claim 9, characterized in that The system also includes a storage node; The storage node is used to receive a first write request sent by a client, perform a corresponding write operation according to the first write request, and return write result information to the client.

11. The system according to claim 9 or 10, characterized in that: The client is also used for: When the number of received write result information indicating successful writing is zero, determining whether the number of times the first write request is sent to each of the storage nodes to be written reaches a preset number; If the number of times the first write request is sent to each storage node to be written reaches a preset number, information on the failure of storing multiple copies of the target file is determined as storage result information, and an operation of sending the storage result information to the control node is performed; If the number of times the first write request is sent to each of the storage nodes to be written does not reach a preset number, an operation of selecting a second preset number of storage nodes from the first preset number of storage nodes is performed.

12. The system according to claim 9 or 10, characterized in that The control node is further used for: When the number of storage nodes to which the data is written successfully is the same as the second preset number, the metadata information corresponding to the target file is updated.

13. The system according to claim 9 or 10, characterized in that The control node is specifically used for: Based on the number of storage nodes where writing succeeds, determine the number of storage nodes where writing fails as a first number; The data corresponding to the target file in the storage node that has been written successfully is backed up to a first number of storage nodes among a first preset number of storage nodes except the storage nodes to be written.

14. The system according to claim 9 or 10, characterized in that The control node is further used for: In a case where the storage result information includes information about a failure to store multiple copies of a target file, metadata information corresponding to the target file is not updated.

15. The system according to claim 9 or 10, characterized in that The storage node is further used for: Sending its own status information to the control node, wherein the own status information includes: the node status and the remaining space size.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1-2 are implemented.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 3 to 8 are implemented.

Citation Information

Patent Citations

  • Low-time delay high-throughput multi-copy file read-write optimization method

    CN105760556A

  • Distributed storage method, device and apparatus and computer readable storage medium

    CN109992219A

  • Methods and apparatus for backing-up and restoring files using multiple trails

    US6505216B1