Data writing method, device, equipment and medium

CN114722017BActive Publication Date: 2025-01-24ALIBABA (CHINA) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210163455.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-22
Publication Date
2025-01-24
Estimated Expiration
2042-02-22

AI Technical Summary

Technical Problem

When existing distributed storage systems perform data write operations for multiple users, supporting overwrite writes will lead to high synchronization costs among storage nodes, and users cannot accurately control the write location, affecting the user experience.

Method used

Provide a method of data writing, to obtain the request writing position and length in the request in the request in the request, and obtain the current writing position. When the request writing position is overlapped with the current writing position, it is added Users can accurately control the position of data.

Benefits of technology

It reduces the cost of data writing operations in distributed storage systems, improves users' control accuracy over data writing locations, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114722017B_ABST
    Figure CN114722017B_ABST
Patent Text Reader

Abstract

The disclosed embodiment discloses a data writing method, device, equipment and medium, the method is used in a distributed storage system, including: obtaining at least one data writing request, obtaining the current writing position of the current writing data; in response to the request writing position of the first data writing request in the at least one data writing request coinciding with the current writing position, appending the request writing data corresponding to the first data writing request according to the first data writing request. In a distributed storage system that writes data in an appending manner, this scheme enables the user to accurately control the writing position of the written data, increases the flexibility of data writing, and improves the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of network technology, and in particular to a data writing method, device, equipment and medium. Background Art

[0002] In recent years, with the advancement of science and technology, the amount of data generated in scientific research and daily life has exploded, and the demand for data storage has also increased dramatically. Since local storage systems are difficult to meet the growing demand for data storage, and considering that mobile computing and enterprise-level large-scale computing have put forward higher requirements for the underlying storage system, people are beginning to use more and more distributed storage systems. Distributed storage systems adopt an extensible system structure and use multiple storage nodes that make up the distributed storage system to share the storage load. When using a distributed storage system, users do not need to worry about which storage node the data will be stored on or from which storage node the data is read. They can manage and store data like using a local storage system. It has high reliability and access efficiency and is easy to expand.

[0003] In some existing distributed storage systems, only append writing is supported for the same file or byte stream, and random writing is not supported, that is, the user only specifies the content of the data to be written, and the data will not overwrite the original data when it is written, but will be added after the written data. Among them, when the distributed data storage system executes data writing operations of multiple users, if the distributed data storage system supports overwrite writing, it is necessary to synchronize between different storage nodes after each data writing operation, which requires high costs. By making the distributed storage system support only append writing, there is no need to synchronize between different storage nodes during the process of executing data writing operations of multiple users, thereby reducing costs.

[0004] In the above scheme, although the cost required for the distributed data storage system to execute data writing operations for multiple users is low, since the user can only specify the content of the data to be written and cannot specify the specific writing location of the data to be written, the user cannot accurately control the writing location of the data to be written, which damages the user experience. Summary of the invention

[0005] In order to solve the problems in the related art, the embodiments of the present disclosure provide a data writing method, device, equipment and medium.

[0006] In a first aspect, an embodiment of the present disclosure provides a method for writing data, wherein the method is applied to a distributed storage system, and the method includes:

[0007] Obtain at least one data write request, the at least one data write request is for the same file or byte stream, the data write request includes a requested write position of the corresponding requested write data and a requested write length of the corresponding requested write data;

[0008] Get the current writing position of the currently written data;

[0009] In response to the request write position of a first data write request in the at least one data write request coinciding with the current write position, the request write data corresponding to the first data write request is additionally written according to the first data write request.

[0010] In combination with the first aspect, in a first implementation of the first aspect of the present disclosure, obtaining at least one data write request includes:

[0011] Obtain at least one data write request sorted according to the requested write position;

[0012] In response to the request writing position of the first data writing request in the at least one data writing request coinciding with the current writing position, before the request writing data corresponding to the first data writing request is additionally written according to the first data writing request, the method further includes:

[0013] It is determined in sequence whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position.

[0014] In combination with the first implementation manner of the first aspect, in a second implementation manner of the first aspect of the present disclosure, before sequentially determining whether a requested write position of each data write request in at least one sorted data write request coincides with a current write position, the method further includes:

[0015] Obtain a newly added data write request, and insert the newly added data write request into at least one sorted data write request according to a request write position of the newly added data write request, so as to obtain at least one updated sorted data write request;

[0016] Determining in sequence whether a requested write position of each data write request in at least one sorted data write request coincides with a current write position includes:

[0017] It is determined in sequence whether the requested write position of each data write request in at least one data write request after the update sorting coincides with the current write position.

[0018] In combination with the first aspect, the first implementation of the first aspect, or the second implementation of the first aspect, in a third implementation of the first aspect of the present disclosure, the method further includes:

[0019] In response to a second data write request in at least one data write request having a requested write position before a current write position, request error indication information is returned, the request error indication information being used to indicate an error when writing data according to the second data write request.

[0020] In combination with the first aspect, the first implementation of the first aspect, or the second implementation of the first aspect, in a fourth implementation of the first aspect of the present disclosure, the method further includes:

[0021] The current writing position is updated according to the first data writing request.

[0022] In combination with the fourth implementation of the first aspect, in a fifth implementation of the first aspect of the present disclosure, the method further includes:

[0023] Acquire the written length of the currently written data, and acquire the target written length according to the requested write position of the second data write request and the requested write length of the second data write request in the at least one data write request;

[0024] In response to the target written length being less than the written length, and the target requested write data being different from the target written data, request error indication information is returned, the target requested write data corresponding to the second data write request, the target written data being determined in the currently written data according to the requested write position of the second data write request and the requested write length of the second data write request, and the request error indication information is used to indicate that an error occurs when writing data according to the second data write request;

[0025] Or, in response to the target written length being greater than the written length and the requested write position of the second data write request being before the updated current write position, request error indication information is returned.

[0026] In combination with the first aspect, the first implementation of the first aspect, or the second implementation of the first aspect, in a sixth implementation of the first aspect of the present disclosure, the method further includes:

[0027] Obtaining at least one third data writing request for which data writing fails;

[0028] Get the re-write position of the current re-write data;

[0029] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, request write data corresponding to the target third data write request is additionally written according to the target third data write request.

[0030] In combination with the sixth implementation of the first aspect, in a seventh implementation of the first aspect of the present disclosure,

[0031] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, before additionally writing the requested write data corresponding to the target third data write request according to the target third data write request, the method further includes:

[0032] sorting at least one third data writing request for which data writing fails, to obtain at least one sorted third data writing request;

[0033] sequentially determining whether a requested write position of each of the at least one sorted third data write request coincides with a re-write position;

[0034] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, additionally writing requested write data corresponding to the target third data write request according to the target third data write request comprises:

[0035] In response to the target third data write request in the at least one sorted third data write request having a requested write position coincident with a re-write position, the requested write data corresponding to the target third data write request is additionally written according to the target third data write request.

[0036] In a second aspect, an embodiment of the present disclosure provides a data writing device, wherein the device includes:

[0037] A request acquisition module is configured to acquire at least one data write request, wherein the at least one data write request is for the same file or byte stream, and the data write request includes a request write position corresponding to the requested write data and a request write length corresponding to the requested write data;

[0038] A position acquisition module, configured to acquire a current writing position of currently written data;

[0039] The data writing module is configured to respond to the request writing position of the first data writing request in at least one data writing request coinciding with the current writing position, and to append the request writing data corresponding to the first data writing request according to the first data writing request.

[0040] In a third aspect, an electronic device is provided in an embodiment of the present disclosure, comprising a memory and at least one processor; the memory is used to store one or more computer instructions, and the one or more computer instructions are executed by at least one processor to implement the method steps as described in any one of the first aspect and the first to seventh implementations of the first aspect.

[0041] In a fourth aspect, a computer-readable storage medium is provided in an embodiment of the present disclosure, on which computer instructions are stored. When the computer instructions are executed by a processor, the method steps described in any one of the first aspect and the first to seventh implementations of the first aspect are implemented.

[0042] In a fifth aspect, a computer program product is provided in an embodiment of the present disclosure, comprising computer instructions, which, when executed by a processor, implement the method steps described in any one of the first aspect and the first to seventh implementations of the first aspect.

[0043] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0044] According to the technical solution provided by the embodiment of the present disclosure, at least one data write request including a request write position of the corresponding request write data and a request write length of the corresponding request write data is obtained, and the current write position of the current write data is obtained. Wherein, at least one data write request is for the same file or byte stream, the request write position in the data write request is used to indicate the specific position of the request to write the corresponding request write data to the corresponding file or byte stream, the request write length in the data write request is used to indicate the length of the corresponding request write data, and the current write position is the position of the data that can be currently written when writing data to the file or byte stream corresponding to the data write request. In response to the request write position of the first data write request in at least one data write request coinciding with the current write position, the request write data corresponding to the first data write request is appended and written according to the first data write request, that is, when the position of the data that can be written to the file or byte stream corresponding to the current data write request is the position where the corresponding request write data is written as requested by the first data write request, the request write data corresponding to the first data write request is written in the file or byte stream corresponding to the first data write request in an appended writing manner, after the request write position of the first data write request in the file or byte stream corresponding to the first data write request, and the length is the request write length of the first data write request. Among them, since the user can specify the specific location when writing the written data (that is, the requested write data corresponding to the data write request) and the specific length of the written data when sending a data write request, the user can control the specific write location of the data requested to be written, and when writing the data specifically, the data is written only by appending. Therefore, the above scheme enables the user to accurately control the write location of the written data in a distributed storage system that writes data in an appending manner, increases the flexibility of data writing, and improves the user experience.

[0045] According to the technical solution provided by the embodiment of the present disclosure, by obtaining at least one data write request sorted according to the requested write position, and determining in turn whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position, it is possible to orderly determine whether the requested write position of the data write request coincides with the current write position, thereby avoiding missing the determination of whether the requested write position of a certain data write request coincides with the current write position, and improving the accuracy of determining the data write requests whose requested write positions coincide with the current write position.

[0046] According to the technical solution provided by the embodiment of the present disclosure, by obtaining a new data write request, the new data write request is inserted into at least one sorted data write request according to the request write position of the new data write request to obtain at least one updated sorted data write request, and it is determined in turn whether the request write position of each data write request in the at least one updated sorted data write request coincides with the current write position, so that users can more conveniently add new data write requests at any time, which facilitates user operations and improves user experience.

[0047] According to the technical solution provided by the embodiment of the present disclosure, by returning request error indication information in response to the request write position of the second data write request in at least one data write request being before the current write position, a user who can use the distributed storage service or a control module of the distributed storage system can be informed according to the received request error indication information that an error occurs when writing data according to the second data write request, so as to perform corresponding remedies, thereby avoiding unnecessary data loss during the data writing process.

[0048] According to the technical solution provided by the embodiment of the present disclosure, by updating the current write position according to the first data write request, it can be ensured that the updated current write position can indicate the location where data can currently be written to the file or byte stream corresponding to the data write request after each data writing according to the corresponding data write request, thereby improving the accuracy of subsequent data writing according to the updated current write position.

[0049] According to the technical solution provided by the embodiment of the present disclosure, by obtaining the written length of the data currently written, and obtaining the target written length according to the requested write position of the second data write request in at least one data write request and the requested write length of the second data write request, in response to the target written length being less than the written length, and the target requested write data being different from the target written data, that is, the data written into the file or byte stream corresponding to the second data write request according to the second data write request is different from the data requested by the second data write request to be written to the file or byte stream corresponding to the second data write request, a request error indication message is returned; or, in response to the target written length being greater than the written length, and the requested write position of the second data write request being before the updated current write position, that is, data cannot be written based on the requested write position of the second data write request at present, a request error indication message is returned, thereby ensuring that a user using the distributed storage service or a control module of the distributed storage system can be informed of an error when writing data according to the second data write request according to the received request error indication message, so as to perform corresponding remedies, thereby avoiding unnecessary data loss during data writing.

[0050] According to the technical solution provided by the embodiments of the present disclosure, by obtaining at least one third data write request in which data writing fails, obtaining the re-write position of the current re-write data, and in response to the coincidence of the request write position of the target third data write request in at least one third data write request in which data writing fails and the re-write position, appending the request write data corresponding to the target third data write request according to the target third data write request, in the event that data writing fails according to the data write request, data can be written again in an append write manner according to the data write request in which the data writing fails, thereby improving the probability of successfully writing data according to the data write request.

[0051] According to the technical solution provided by the embodiment of the present disclosure, at least one third data write request in which data writing fails is sorted to obtain at least one sorted third data write request, and whether the request write position of each third data write request in the at least one sorted third data write request coincides with the re-write position is determined in turn. In response to the request write position of the target third data write request in the at least one sorted third data write request coincident with the re-write position, the request write data corresponding to the target third data write request is additionally written according to the target third data write request, so that data write requests that fail to write data can be added at any time more conveniently, so that data can be re-written in time according to the data write request that fails to write data, thereby accelerating the response speed of re-writing data to the data write request that fails to write data.

[0052] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Other features, objectives and advantages of the present disclosure will become more apparent through the following detailed description of non-limiting embodiments in conjunction with the accompanying drawings. In the accompanying drawings:

[0054] Figure 1 A flow chart of a data writing method according to an embodiment of the present disclosure is shown.

[0055] Figure 2 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0056] Figure 3 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0057] Figure 4 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0058] Figure 5 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0059] Figure 6 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0060] Figure 7 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0061] Figure 8 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown.

[0062] Fig. 9 A structural block diagram of a data writing device according to an embodiment of the present disclosure is shown.

[0063] Fig.10 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0064] Fig.11 It is a structural schematic diagram of a computer system suitable for implementing a data writing method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0065] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, parts not related to the description of the exemplary embodiments are omitted in the accompanying drawings.

[0066] In the present disclosure, it should be understood that terms such as "include" or "have" are intended to indicate the presence of labels, numbers, steps, behaviors, components, parts, or combinations thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other labels, numbers, steps, behaviors, components, parts, or combinations thereof exist or are added.

[0067] It should also be noted that, in the absence of conflict, the embodiments and labels in the embodiments of the present disclosure can be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0068] In a distributed storage system, data can be stored on multiple independent data nodes, where different data nodes can store the same data, which can be understood as a replica (copy). When data is stored in multiple copies, if one copy cannot be read, the distributed storage system can switch to other copies for reading, thereby ensuring data redundancy in the distributed system and avoiding data reading failures caused by data loss in the distributed system.

[0069] However, storing data in multiple copies also raises some key issues that need to be resolved, one of which is the need to ensure the consistency of data in different copies. Specifically, when the data in one copy is updated, the data in other copies must be synchronized with the data in the updated copy. Otherwise, if the data in two different copies in the distributed storage system is not continuously consistent, users may not be able to read the same data from different copies, which may cause problems in the corresponding program. Therefore, in the distributed storage system, it is necessary to intermittently perform consistency checks on different copies and determine whether the data in different copies are consistent based on the consistency check results.

[0070] In the related art, in a distributed storage system, if only append writing can be supported for the same file or byte stream, and random writing is not supported, that is, the user only specifies the content of the data to be written, and the data will not overwrite the original data when it is written, but will be added after the written data. Then, when performing consistency checks on different copies, it is only necessary to check whether the data lengths of the data in the two copies are consistent. If the two are consistent, it is determined that the data in the two copies are consistent. If the distributed storage system supports random writing, that is, the data can overwrite the original data when it is written, then even if the data lengths of the data in the two copies are consistent, it is impossible to determine whether the data in the two copies are consistent. During the consistency check, data verification needs to be performed on the data in the two copies, so that the consistency check takes a long time and requires more processing resources. In summary, the distributed storage system only supports append writing, which can make the inspection efficiency higher when performing consistency checks on different copies, and the occupied processing resources are less, reducing the processing cost. Therefore, most of the distributed storage systems in the related art are distributed storage systems that only support writing data in the append writing mode.

[0071] In a distributed storage system that only supports writing data in an appending manner, in order to enable a user to accurately control the writing location of the written data, the inventors of the present disclosure have considered the following solution.

[0072] In the related art, in a distributed storage system, a file or byte stream to be written can be truncated to a specified length through a truncate statement, that is, a portion of the written data in the file or byte stream to be written is removed so that the length of the truncated file or byte stream meets the preset requirements, and then the corresponding data is written to the end of the truncated file or byte stream in an appended manner. Among them, by controlling the length of the file or byte stream to be written after the truncation of the truncate statement, the purpose of controlling the specific writing position of the corresponding data to be written can be achieved.

[0073] Disadvantages of this solution: Although the above solution can control the specific writing location of the corresponding data in a distributed storage system that only supports writing data in an appending manner, it is necessary to truncate the file or byte stream to a specified length through a truncate statement before writing the data, resulting in the data after the specified length in the file or byte stream being discarded, increasing the risk of important data loss in the distributed storage system.

[0074] Considering the shortcomings of the above schemes, the inventors of the present disclosure have proposed a new scheme: the scheme obtains at least one data write request including a request write position corresponding to the requested write data and a request write length corresponding to the requested write data, and obtains the current write position of the current write data. Among them, at least one data write request is for the same file or byte stream, the request write position in the data write request is used to indicate the specific position of the request to write the corresponding requested write data to the corresponding file or byte stream, the request write length in the data write request is used to indicate the length of the corresponding requested write data, and the current write position is the position of the data that can be currently written when writing data to the file or byte stream corresponding to the data write request. In response to the request writing position of the first data writing request in at least one data writing request coinciding with the current writing position, the request writing data corresponding to the first data writing request is additionally written according to the first data writing request, that is, the position of the data that can be written to the file or byte stream corresponding to the current data writing request is the position where the corresponding request writing data is requested to be written by the first data writing request, and the request writing data corresponding to the first data writing request is written in the file or byte stream corresponding to the first data writing request in an additional writing manner, and is written into the data interval with the length of the request writing length of the first data writing request after the request writing position of the first data writing request. Among them, since the user can specify the specific position when writing the written data (that is, the request writing data corresponding to the data writing request) and the specific length of the written data when sending the data writing request, the user can control the specific writing position of the requested writing data, and when writing the data specifically, the data is written only by the additional writing method. Therefore, in the distributed storage system that writes data in an additional manner, the above scheme enables the user to accurately control the writing position of the written data, increases the flexibility of data writing, and improves the user experience.

[0075] In order to solve the above problems, the present disclosure proposes a data writing method, device, equipment and medium.

[0076] Figure 1 A flow chart of a data writing method according to an embodiment of the present disclosure is shown, and the method is applied to a distributed storage system that only supports writing data in an appending manner, such as Figure 1 As shown, the data writing method includes steps S101, S102, and S103.

[0077] In step S101 , at least one data writing request is obtained.

[0078] The data write request includes a requested write position corresponding to the requested write data and a requested write length corresponding to the requested write data.

[0079] In step S102, the current writing position of the currently written data is obtained.

[0080] In step S103, in response to the request write position of a first data write request in at least one data write request coinciding with the current write position, request write data corresponding to the first data write request is additionally written according to the first data write request.

[0081] In one embodiment of the present disclosure, a data write request may be understood as being used to instruct a distributed storage system to write the corresponding requested write data to a corresponding file or byte stream, wherein. A data write request may be understood as being sent by a user end of a distributed storage system. The user end of a distributed storage service may be understood as an actual user of a distributed storage service, other persons other than the actual user of a distributed storage service, or an automatic use program of a distributed storage service. The user end may be a mobile communication device, a computer, a single server, or a server group, wherein the server group may be centralized or distributed. In some embodiments, the middle platform may be local or remote. In some embodiments, the user end may be implemented on a cloud platform; as an example only, a cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an inter-cloud, a multi-cloud, etc., or any combination thereof.

[0082] In one embodiment of the present disclosure, the requested write position can be understood as the specific position (offset) of the corresponding requested write data in the corresponding file or byte stream after the requested write data corresponding to the indicated data write request is written into the corresponding file or byte stream by the distributed storage system.

[0083] In one embodiment of the present disclosure, the requested write length may be understood as a specific length (length) of the requested write data corresponding to the indicated data write request.

[0084] In one embodiment of the present disclosure, the current write position may be understood as the position where data can currently be written to a file or byte stream corresponding to a data write request when the distributed storage system writes data to the file or byte stream.

[0085] In one embodiment of the present disclosure, the requested write data corresponding to the first data write request is additionally written according to the first data write request. It can be understood that, based on the requested write position and the requested write length in the first data write request, the requested write data corresponding to the first data write request is written in an appended manner into a storage space after the requested write position of the first data write request and with a length equal to the requested write length of the first data write request.

[0086] For example, Figure 2 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the control module of the distributed storage system may include an offset write layer 101 and an additional write layer 102, wherein the offset write layer 101 is used to parse and obtain at least one data write request to determine the requested write position and the requested write length of the data write request. The additional write layer 102 is used to write the requested write data corresponding to the data write request into the file or byte stream corresponding to the data write request. At the same time, the offset write layer 101 is also used to obtain the current position where the corresponding file or byte stream can be written when the additional write layer 102 writes data to the file or byte stream corresponding to the data write request, that is, the current write position.

[0087] When the offset write layer 101 obtains the data write request 110, through the analysis of the offset write layer 101, it can be determined that the requested write position and the requested write length of the data write request 110 are <100, 100>. If the current write position 103 obtained by the offset write layer 101 is "100", it means that when the additional write layer 102 writes data to the file or byte stream 111 corresponding to the data write request 110, the current position where the file or byte stream 111 can be written with data is "100". Since the current write position 103 and the requested write position of the data write request 110 are both "100", the two coincide with each other. Therefore, the offset write layer 101 sends the data write request 110 to the additional write layer 102, so that the additional write layer 102 appends the request write data corresponding to the data write request 110 according to the data write request 110.

[0088] Figure 3 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 3 As shown, when the offset write layer 101 obtains the data write request 110, through the analysis of the offset write layer 101, it can be determined that the requested write position and the requested write length of the data write request 110 are <200,100>. If the current write position 103 obtained by the offset write layer 101 is "100", it means that when the additional write layer 102 writes data to the file or byte stream 111 corresponding to the data write request 110, the current position where the file or byte stream 111 can be written is "100". Since there is a difference between the current write position 103 and the requested write position of the data write request 110, the two do not overlap, and therefore the offset write layer 101 temporarily does not send the data write request 110 to the additional write layer 102.

[0089] Figure 4 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 4 As shown, when the offset write layer 101 obtains the data write request 110, through the analysis of the offset write layer 101, it can be determined that the requested write position and the requested write length of the data write request 110 are <200, 100>. If the current write position 103 obtained by the offset write layer 101 is "200", it means that when the additional write layer 102 writes data to the file or byte stream 111 corresponding to the data write request 110, the current position where the file or byte stream 111 can be written with data is "200". Since the current write position 103 and the requested write position of the data write request 110 are both "200", the two coincide, and then the data write request 110 is sent to the additional write layer 102, so that the additional write layer 102 appends the request write data corresponding to the data write request 110 according to the data write request 110.

[0090] According to the technical solution provided by the embodiment of the present disclosure, at least one data write request including a request write position of the corresponding request write data and a request write length of the corresponding request write data is obtained, and the current write position of the current write data is obtained. Wherein, at least one data write request is for the same file or byte stream, the request write position in the data write request is used to indicate the specific position of the request to write the corresponding request write data to the corresponding file or byte stream, the request write length in the data write request is used to indicate the length of the corresponding request write data, and the current write position is the position of the data that can be currently written when writing data to the file or byte stream corresponding to the data write request. In response to the request write position of the first data write request in at least one data write request coinciding with the current write position, the request write data corresponding to the first data write request is appended and written according to the first data write request, that is, when the position of the data that can be written to the file or byte stream corresponding to the current data write request is the position where the corresponding request write data is written as requested by the first data write request, the request write data corresponding to the first data write request is written in the file or byte stream corresponding to the first data write request in an appended writing manner, after the request write position of the first data write request in the file or byte stream corresponding to the first data write request, and the length is the request write length of the first data write request. Among them, since the user can specify the specific location when writing the written data (that is, the requested write data corresponding to the data write request) and the specific length of the written data when sending a data write request, the user can control the specific write location of the data requested to be written, and when writing the data specifically, the data is written only by appending. Therefore, the above scheme enables the user to accurately control the write location of the written data in a distributed storage system that writes data in an appending manner, increases the flexibility of data writing, and improves the user experience.

[0091] In one embodiment of the present disclosure, in step S101, obtaining at least one data write request may be implemented by the following steps:

[0092] Obtain at least one data write request sorted according to the requested write position;

[0093] In step S103, in response to the fact that the requested write position of the first data write request in the at least one data write request coincides with the current write position, before additionally writing the requested write data corresponding to the first data write request according to the first data write request, the method further includes the following steps:

[0094] It is determined in sequence whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position.

[0095] In one embodiment of the present disclosure, the data write requests are sorted according to the requested write positions, which can be understood as placing the data write requests with earlier requested write positions before the data write requests with later data write positions. Exemplarily, when the requested write position and the requested write length of one data write request in at least one data write request are <100, 100>, and the requested write position and the requested write length of another data write request in at least one data write request are <200, 100>, since the requested write position "100" of the one data write request is before the requested write position "200" of the other data write request, the one data write request is before the other data write request in the sorted at least one data write request.

[0096] In one embodiment of the present disclosure, it is determined in turn whether the requested write position of each data write request in at least one sorted data write request coincides with the current write position. This can be understood as comparing the requested write position of each data write request in at least one sorted data write request with the current write position in turn. When the two are the same, it can be considered that the two coincide.

[0097] In one embodiment of the present disclosure, in order to minimize the amount of data calculation required to determine whether the requested write position of each data write request in at least one sorted data write request coincides with the current write position, in the process of sequentially determining whether the requested write position of each data write request in at least one sorted data write request coincides with the current write position, it is possible to determine whether the target data write request coincides with the current write position only on the premise that the requested write position of the previous data write request of the target data write request in at least one sorted data write request coincides with the current write position at a certain moment.

[0098] According to the technical solution provided by the embodiment of the present disclosure, by obtaining at least one data write request sorted according to the requested write position, and determining in turn whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position, it is possible to orderly determine whether the requested write position of the data write request coincides with the current write position, thereby avoiding missing the determination of whether the requested write position of a certain data write request coincides with the current write position, and improving the accuracy of determining the data write requests whose requested write positions coincide with the current write position.

[0099] In one embodiment of the present disclosure, before sequentially determining whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position, the method further includes the following steps:

[0100] Obtain a newly added data write request, and insert the newly added data write request into at least one sorted data write request according to a request write position of the newly added data write request, so as to obtain at least one updated sorted data write request;

[0101] Determining in sequence whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position may be achieved by the following steps:

[0102] It is determined in sequence whether the requested write position of each data write request in at least one data write request after the update sorting coincides with the current write position.

[0103] In one embodiment of the present disclosure, a newly added data write request can be understood as a data write request newly obtained after obtaining at least one data write request. The format of the newly added data write request is the same as that of the data write request, and also includes a requested write position of the corresponding requested write data and a requested write length of the corresponding requested write data.

[0104] In one embodiment of the present disclosure, a new data write request is inserted into at least one sorted data write request according to the request write position of the new data write request. This can be understood as inserting the new data write request into at least one sorted data write request by direct insertion sort or binary insertion sort to obtain at least one updated sorted data write request.

[0105] According to the technical solution provided by the embodiment of the present disclosure, by obtaining a new data write request, the new data write request is inserted into at least one sorted data write request according to the request write position of the new data write request to obtain at least one updated sorted data write request, and it is determined in turn whether the request write position of each data write request in the at least one updated sorted data write request coincides with the current write position, so that users can more conveniently add new data write requests at any time, which facilitates user operations and improves user experience.

[0106] In one embodiment of the present disclosure, the method further comprises the following steps:

[0107] In response to a second data write request in at least one data write request having a requested write position before a current write position, request error indication information is returned, the request error indication information being used to indicate an error when writing data according to the second data write request.

[0108] In one embodiment of the present disclosure, returning the request error indication information can be understood as sending it to the user end of the distributed storage system, and the user using the user end or the corresponding program running on the user end can learn through the user end that the distributed storage system has an error when writing data according to the second data write request sent by the user; returning the request error indication information can also be understood as sending it to the control module of the distributed storage system, so that the control module can learn that the distributed storage system has an error when writing data according to the second data write request, so that the control module can take corresponding remedial measures.

[0109] For example, Figure 5 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 5 As shown, when the offset write layer 101 obtains the data write request 110, through the analysis of the offset write layer 101, it can be determined that the requested write position and the requested write length of the data write request 110 are <100,300>. If the current write position 103 obtained by the offset write layer 101 is "300", it means that when the additional write layer 102 writes data to the file or byte stream 111 corresponding to the data write request 110, the current position where the file or byte stream 111 can be written with data is "300". Since the current write position 103 is before the requested write position of the data write request 110, the requested write data corresponding to the data write request 110 cannot be written to the file or byte stream 111 without overwriting the data. Therefore, the offset write layer 101 returns a request error indication message 106.

[0110] According to the technical solution provided by the embodiment of the present disclosure, by returning request error indication information in response to the request write position of the second data write request in at least one data write request being before the current write position, a user who can use the distributed storage service or a control module of the distributed storage system can be informed according to the received request error indication information that an error occurs when writing data according to the second data write request, so as to perform corresponding remedies, thereby avoiding unnecessary data loss during the data writing process.

[0111] In one embodiment of the present disclosure, the method further comprises the following steps:

[0112] The current writing position is updated according to the first data writing request.

[0113] In one embodiment of the present disclosure, updating the current write position according to the first data write request can be understood as calculating, based on the requested write length in the first data write request, the position where data is allowed to be written to the file or byte stream corresponding to the first data write request after the requested write data corresponding to the first data write request is written to the file or byte stream corresponding to the first data write request.

[0114] Exemplarily, when the requested write length of the first data write request is "100" and the current write position is "200", the updated current write position is "300".

[0115] According to the technical solution provided by the embodiment of the present disclosure, by updating the current write position according to the first data write request, it can be ensured that the updated current write position can indicate the location where data can currently be written to the file or byte stream corresponding to the data write request after each data writing according to the corresponding data write request, thereby improving the accuracy of subsequent data writing according to the updated current write position.

[0116] In one embodiment of the present disclosure, the method further comprises the following steps:

[0117] Acquire the written length of the currently written data, and acquire the target written length according to the requested write position of the second data write request and the requested write length of the second data write request in the at least one data write request;

[0118] In response to the target written length being less than the written length, and the target requested write data being different from the target written data, request error indication information is returned, the target requested write data corresponding to the second data write request, the target written data being determined in the currently written data according to the requested write position of the second data write request and the requested write length of the second data write request, and the request error indication information is used to indicate that an error occurs when writing data according to the second data write request;

[0119] Or, in response to the target written length being greater than the written length and the requested write position of the second data write request being before the updated current write position, request error indication information is returned.

[0120] In one embodiment of the present disclosure, the data currently written can be understood as the file or byte stream corresponding to the data write request, and the written length of the data currently written can be understood as the total length of the data in the file or byte stream corresponding to the data write request.

[0121] In one embodiment of the present disclosure, the target written length can be understood as the total length of data in the corresponding file or byte stream after data is written according to the second data write request. Obtaining the target written length according to the requested write position of the second data write request in at least one data write request and the requested write length of the second data write request can be understood as adding the requested write position of the second data write request and the requested write length of the second data write request to obtain the target written length.

[0122] In one embodiment of the present disclosure, the target written data can be understood as data in the file or byte stream corresponding to the second data write request, whose position is the requested write position of the second data write request and whose length is the requested write length of the second data write request, that is, the target written data is the data that has been written into the file or byte stream corresponding to the second data write request according to the second data write request.

[0123] In one embodiment of the present disclosure, the target request to write data may be understood as data requested by the second data write request to be written to the file or byte stream corresponding to the second data write request.

[0124] In one embodiment of the present disclosure, in response to returning the request error indication information, the second data write request may also be removed from at least one data write request to avoid performing a data write operation based on the second data write request that may cause a data write error.

[0125] For example, Figure 6 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 6As shown, the offset write layer 101 obtains the written length of the currently written data as "400", and the offset write layer 101 can obtain the requested write position and the requested write length of the second data write request 140 as <100,200> by parsing the second data write request 140 in at least one data write request, and adds the requested write position "100" and the requested write length "200" of the second data write request 140 to obtain the target written length "300", wherein the target written length "300" is less than the written length "400", indicating that the second data write request 140 has been written to the second data. The corresponding requested write data is written into the file or byte stream 141 corresponding to the input request, and the additional write layer 102 reads the target written data 142 from the file or byte stream 141 corresponding to the second data write request according to the requested write position of the second data write request and the requested write length of the second data write request. The target written data 142 is the data that has been written into the file or byte stream 141 corresponding to the second data write request according to the second data write request. If the target requested write data is different from the target written data 142, it means that an error occurred when writing data according to the second data write request 140, and the request error indication information 106 is returned.

[0126] For example, Figure 7 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 7 As shown, the offset write layer 101 obtains the written length of the currently written data as "200" and the updated current write position 113 as "200", and the offset write layer 101 can obtain the requested write position and the requested write length of the second data write request 140 as <100,200> by parsing the second data write request 140 in at least one data write request, and adds the requested write position "100" and the requested write length "200" of the second data write request 140 to obtain the target written length "300", wherein the target written length "300" is greater than the target written length The write length "200" indicates that the corresponding requested write data has not actually been written to the file or byte stream 141 corresponding to the second data write request 140. However, since the requested write position "100" of the second data write request 140 is before the updated current write position "200", and considering that data can only be written by appending, data cannot be written based on the requested write position "100" of the second data write request 140. This indicates that an error occurred when writing data according to the second data write request 140, and the request error indication information 106 is returned.

[0127] According to the technical solution provided by the embodiment of the present disclosure, by obtaining the written length of the data currently written, and obtaining the target written length according to the requested write position of the second data write request in at least one data write request and the requested write length of the second data write request, in response to the target written length being less than the written length, and the target requested write data being different from the target written data, that is, the data written into the file or byte stream corresponding to the second data write request according to the second data write request is different from the data requested by the second data write request to be written to the file or byte stream corresponding to the second data write request, a request error indication message is returned; or, in response to the target written length being greater than the written length, and the requested write position of the second data write request being before the updated current write position, that is, data cannot be written based on the requested write position of the second data write request at present, a request error indication message is returned, thereby ensuring that a user using the distributed storage service or a control module of the distributed storage system can be informed of an error when writing data according to the second data write request according to the received request error indication message, so as to perform corresponding remedies, thereby avoiding unnecessary data loss during data writing.

[0128] In one embodiment of the present disclosure, the method further comprises the following steps:

[0129] Obtaining at least one third data writing request for which data writing fails;

[0130] Get the re-write position of the current re-write data;

[0131] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, request write data corresponding to the target third data write request is additionally written according to the target third data write request.

[0132] In one embodiment of the present disclosure, when data is written according to a data write request, the result only includes data write failure or data write success, and there is no partial success or partial failure. The third data write request with data write failure can be understood as failure to write the request write data corresponding to the third data write request into the file or data stream corresponding to the third data write request according to the third data write request.

[0133] In one embodiment of the present disclosure, the re-write position of the current re-written data can be understood as the position where the data is currently allowed to be re-written when the file or data stream corresponding to the data write request is re-written again after the processing of at least one acquired data write request is completed.

[0134] In one embodiment of the present disclosure, the requested write data corresponding to the target third data write request is appended according to the target third data write request. This can be understood as writing the requested write data corresponding to the target third data write request in an appended manner, according to the requested write position and the requested write length in the target third data write request, into a storage space after the requested write position of the target third data write request and with a length equal to the requested write length of the target third data write request.

[0135] According to the technical solution provided by the embodiments of the present disclosure, by obtaining at least one third data write request in which data writing fails, obtaining the re-write position of the current re-write data, and in response to the coincidence of the request write position of the target third data write request in at least one third data write request in which data writing fails and the re-write position, appending the request write data corresponding to the target third data write request according to the target third data write request, in the event that data writing fails according to the data write request, data can be written again in an append write manner according to the data write request in which the data writing fails, thereby improving the probability of successfully writing data according to the data write request.

[0136] In one embodiment of the present disclosure, in response to the request write position of the target third data write request in at least one third data write request in which data writing fails coincides with the re-write position, before the request write data corresponding to the target third data write request is additionally written according to the target third data write request, the method further includes:

[0137] sorting at least one third data writing request for which data writing fails, to obtain at least one sorted third data writing request;

[0138] sequentially determining whether a requested write position of each of the at least one sorted third data write request coincides with a re-write position;

[0139] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, additionally writing requested write data corresponding to the target third data write request according to the target third data write request comprises:

[0140] In response to the target third data write request in the at least one sorted third data write request having a requested write position coincident with a re-write position, the requested write data corresponding to the target third data write request is additionally written according to the target third data write request.

[0141] For example, Figure 8 A schematic block diagram of a data writing method according to an embodiment of the present disclosure is shown as follows: Figure 8As shown, when the offset write layer 101 finds that a data write failure occurs when writing data according to the third data write request 150 of at least one data, the offset write layer 101 obtains the third data write request 150 and sorts the third data write request 150 to obtain at least one sorted third data write request 150. When the additional write layer 102 is closed, the additional write layer operation is reopened to obtain a new additional write layer 112, and the offset write layer 101 obtains the re-write position 152 of the current re-written data, and determines in turn whether the request write position of each third data write request 150 in the at least one sorted third data write request 150 coincides with the re-write position 152. If the requested write position of the target third data write request 153 in at least one of the sorted third data write requests 150 is "500", it means that when the new additional write layer 112 writes data to the file or byte stream 154 corresponding to the third data write request 150, the current position where data can be written to the file or byte stream 154 is "500". If the re-write position 152 is also "500", the requested write position of the target third data write request 153 and the re-write position 152 are both "500", and the two coincide. Therefore, the offset write layer 101 sends the target third data write request 153 to the new additional write layer 112, so that the new additional write layer 112 appends the requested write data corresponding to the target third data write request 153 according to the target third data write request 153.

[0142] According to the technical solution provided by the embodiment of the present disclosure, at least one third data write request in which data writing fails is sorted to obtain at least one sorted third data write request, and whether the request write position of each third data write request in the at least one sorted third data write request coincides with the re-write position is determined in turn. In response to the request write position of the target third data write request in the at least one sorted third data write request coincident with the re-write position, the request write data corresponding to the target third data write request is additionally written according to the target third data write request, so that data write requests that fail to write data can be added at any time more conveniently, so that data can be re-written in time according to the data write request that fails to write data, thereby accelerating the response speed of re-writing data to the data write request that fails to write data.

[0143] The following reference Fig. 9 A data writing device according to an embodiment of the present disclosure is described, where the data writing device is located in a distributed storage system. Fig. 9 A structural block diagram of a data writing device 200 according to an embodiment of the present disclosure is shown.

[0144] like Fig. 9 As shown, the data writing device 200 includes:

[0145] The request acquisition module 201 is configured to acquire at least one data write request, wherein the at least one data write request is for the same file or byte stream, and the data write request includes a request write position corresponding to the requested write data and a request write length corresponding to the requested write data;

[0146] The position acquisition module 202 is configured to acquire the current writing position of the currently written data;

[0147] The data writing module 203 is configured to, in response to the request writing position of a first data writing request in at least one data writing request coinciding with the current writing position, additionally write the request writing data corresponding to the first data writing request according to the first data writing request.

[0148] According to the technical solution provided by the embodiment of the present disclosure, at least one data write request including a request write position of the corresponding request write data and a request write length of the corresponding request write data is obtained, and the current write position of the current write data is obtained. Wherein, at least one data write request is for the same file or byte stream, the request write position in the data write request is used to indicate the specific position of the request to write the corresponding request write data to the corresponding file or byte stream, the request write length in the data write request is used to indicate the length of the corresponding request write data, and the current write position is the position of the data that can be currently written when writing data to the file or byte stream corresponding to the data write request. In response to the request write position of the first data write request in at least one data write request coinciding with the current write position, the request write data corresponding to the first data write request is appended and written according to the first data write request, that is, when the position of the data that can be written to the file or byte stream corresponding to the current data write request is the position where the corresponding request write data is written as requested by the first data write request, the request write data corresponding to the first data write request is written in the file or byte stream corresponding to the first data write request in an appended writing manner, after the request write position of the first data write request in the file or byte stream corresponding to the first data write request, and the length is the request write length of the first data write request. Among them, since the user can specify the specific location when writing the written data (that is, the requested write data corresponding to the data write request) and the specific length of the written data when sending a data write request, the user can control the specific write location of the data requested to be written, and when writing the data specifically, the data is written only by appending. Therefore, the above scheme enables the user to accurately control the write location of the written data in a distributed storage system that writes data in an appending manner, increases the flexibility of data writing, and improves the user experience.

[0149] Those skilled in the art will understand that referring to Fig. 9 The described technical solution can be combined with any of the embodiments described above, so as to have the technical effect achieved by any of the embodiments described above. The specific contents can refer to the description of the above embodiments, and the specific contents will not be repeated here.

[0150] Fig.10 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0151] The present disclosure also provides an electronic device, such as Fig.10 As shown, the electronic device 300 includes at least one processor 301; and a memory 302 that is communicatively connected to the at least one processor 301; characterized in that the memory 302 stores instructions that can be executed by the at least one processor 301, and the instructions are executed by the at least one processor 301 to implement the following steps:

[0152] In a first aspect, an embodiment of the present disclosure provides a method for writing data, wherein the method is applied to a distributed storage system, and the method includes:

[0153] Obtain at least one data write request, the at least one data write request is for the same file or byte stream, the data write request includes a requested write position of the corresponding requested write data and a requested write length of the corresponding requested write data;

[0154] Get the current writing position of the currently written data;

[0155] In response to the request write position of a first data write request in the at least one data write request coinciding with the current write position, the request write data corresponding to the first data write request is additionally written according to the first data write request.

[0156] In combination with the first aspect, in a first implementation of the first aspect of the present disclosure, obtaining at least one data write request includes:

[0157] Obtain at least one data write request sorted according to the requested write position;

[0158] In response to the request writing position of the first data writing request in the at least one data writing request coinciding with the current writing position, before the request writing data corresponding to the first data writing request is additionally written according to the first data writing request, the method further includes:

[0159] It is determined in sequence whether the requested write position of each data write request in the at least one sorted data write request coincides with the current write position.

[0160] In combination with the first implementation manner of the first aspect, in a second implementation manner of the first aspect of the present disclosure, before sequentially determining whether a requested write position of each data write request in at least one sorted data write request coincides with a current write position, the method further includes:

[0161] Obtain a newly added data write request, and insert the newly added data write request into at least one sorted data write request according to a request write position of the newly added data write request, so as to obtain at least one updated sorted data write request;

[0162] Determining in sequence whether a requested write position of each data write request in at least one sorted data write request coincides with a current write position includes:

[0163] It is determined in sequence whether the requested write position of each data write request in at least one data write request after the update sorting coincides with the current write position.

[0164] In combination with the first aspect, the first implementation of the first aspect, or the second implementation of the first aspect, in a third implementation of the first aspect of the present disclosure, the method further includes:

[0165] In response to a second data write request in at least one data write request having a requested write position before a current write position, request error indication information is returned, the request error indication information being used to indicate an error when writing data according to the second data write request.

[0166] In combination with the first aspect, the first implementation of the first aspect, or the second implementation of the first aspect, in a fourth implementation of the first aspect of the present disclosure, the method further includes:

[0167] The current writing position is updated according to the first data writing request.

[0168] In combination with the fourth implementation of the first aspect, in a fifth implementation of the first aspect of the present disclosure, the method further includes:

[0169] Acquire the written length of the currently written data, and acquire the target written length according to the requested write position of the second data write request and the requested write length of the second data write request in the at least one data write request;

[0170] In response to the target written length being less than the written length, and the target requested write data being different from the target written data, request error indication information is returned, the target requested write data corresponding to the second data write request, the target written data being determined in the currently written data according to the requested write position of the second data write request and the requested write length of the second data write request, and the request error indication information is used to indicate that an error occurs when writing data according to the second data write request;

[0171] Or, in response to the target written length being greater than the written length and the requested write position of the second data write request being before the updated current write position, request error indication information is returned.

[0172] In combination with the first aspect, the first implementation of the first aspect, or the second implementation of the first aspect, in a sixth implementation of the first aspect of the present disclosure, the method further includes:

[0173] Obtaining at least one third data writing request for which data writing fails;

[0174] Get the re-write position of the current re-write data;

[0175] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, request write data corresponding to the target third data write request is additionally written according to the target third data write request.

[0176] In combination with the sixth implementation of the first aspect, in a seventh implementation of the first aspect of the present disclosure,

[0177] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, before additionally writing the requested write data corresponding to the target third data write request according to the target third data write request, the method further includes:

[0178] sorting at least one third data writing request for which data writing fails, to obtain at least one sorted third data writing request;

[0179] sequentially determining whether a requested write position of each of the at least one sorted third data write request coincides with a re-write position;

[0180] In response to at least one third data write request in which data writing fails, in which a requested write position of a target third data write request coincides with a re-write position, additionally writing requested write data corresponding to the target third data write request according to the target third data write request comprises:

[0181] In response to the target third data write request in the at least one sorted third data write request having a requested write position coincident with a re-write position, the requested write data corresponding to the target third data write request is additionally written according to the target third data write request.

[0182] Fig.11 It is a structural schematic diagram of a computer system suitable for implementing a data writing method according to an embodiment of the present disclosure.

[0183] like Fig.11 As shown, the computer system 400 includes a processing unit 401, which can perform various processes in the embodiments shown in the above figures according to the program stored in the read-only memory (ROM) 402 or the program loaded from the storage part 408 to the random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the system 400 are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0184] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. The drive 410 is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that the computer program read therefrom is installed into the storage section 408 as needed. It is characterized in that the processing unit 401 can be implemented as a processing unit such as a CPU, a GPU, a TPU, an FPGA, an NPU, etc.

[0185] In particular, according to an embodiment of the present disclosure, the method described above with reference to the accompanying drawings can be implemented as a computer software program. Exemplarily, an embodiment of the present disclosure includes a computer program product, which includes a computer program tangibly contained on a readable medium thereof, and the computer program includes a program code for executing the method in the accompanying drawings. In such an embodiment, the computer program can be downloaded and installed from a network through a communication portion 409, and / or installed from a removable medium 411. Exemplarily, an embodiment of the present disclosure includes a readable storage medium on which computer instructions are stored, and when the computer instructions are executed by a processor, the program code for executing the method in the accompanying drawings is implemented.

[0186] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the road map or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. Exemplary, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0187] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The units or modules described may also be set in a processor, and the names of these units or modules do not constitute limitations on the units or modules themselves in some cases.

[0188] As another aspect, the present disclosure further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the computer system described in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into a device. The computer-readable storage medium stores one or more programs, and the programs are used by one or more processors to execute the method described in the present disclosure.

[0189] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. The above exemplary features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) to form a technical solution.

Claims

1. A data writing method, wherein: The method is applied to a distributed storage system, and the method comprises: Obtaining at least one data write request sorted according to the requested write position, wherein the at least one data write request is for the same file or byte stream, and the data write request includes a requested write position corresponding to the requested write data and a requested write length corresponding to the requested write data; Get the current writing position of the currently written data; determining in sequence whether a requested write position of each data write request in the at least one sorted data write request coincides with the current write position; In response to the request write position of a first data write request in the at least one sorted data write request coinciding with the current write position, additionally writing the request write data corresponding to the first data write request according to the first data write request.

2. The data writing method according to claim 1, wherein: Before sequentially determining whether a requested write position of each data write request in the at least one sorted data write request coincides with the current write position, the method further includes: Obtaining a newly added data write request, and inserting the newly added data write request into the at least one sorted data write request according to a request write position of the newly added data write request, so as to obtain at least one updated sorted data write request; The step of sequentially determining whether a requested write position of each of the at least one sorted data write requests coincides with the current write position includes: It is determined in sequence whether a requested write position of each data write request in the at least one data write request after the update sorting coincides with the current write position.

3. The data writing method according to claim 1 or 2, wherein: The method further comprises: In response to a second data write request in the at least one data write request having a requested write position before the current write position, request error indication information is returned, wherein the request error indication information is used to indicate an error when writing data according to the second data write request.

4. The data writing method according to claim 1 or 2, wherein: The method further comprises: The current writing position is updated according to the first data writing request.

5. The data writing method according to claim 4, wherein: The method further comprises: Acquire the written length of the currently written data, and acquire the target written length according to the requested write position of the second data write request in the at least one data write request and the requested write length of the second data write request; In response to the target written length being less than the written length, and the target requested write data being different from the target written data, returning request error indication information, the target requested write data corresponding to the second data write request, the target written data being determined in the currently written data according to the requested write position of the second data write request and the requested write length of the second data write request, and the request error indication information being used to indicate that an error occurs when writing data according to the second data write request; Or, in response to the target written length being greater than the written length and the requested write position of the second data write request being before the updated current write position, the request error indication information is returned.

6. The data writing method according to claim 1 or 2, wherein: The method further comprises: Obtaining at least one third data writing request for which data writing fails; Get the re-write position of the current re-write data; In response to the request write position of the target third data write request in the at least one third data write request in which data writing fails coincides with the re-write position, the request write data corresponding to the target third data write request is additionally written according to the target third data write request.

7. The data writing method according to claim 6, wherein: In the third data write request in response to the at least one data write failure, the requested write position of the target third data write request coincides with the re-write position, and before additionally writing the requested write data corresponding to the target third data write request according to the target third data write request, the method further includes: sorting the at least one third data writing request for which data writing fails, to obtain at least one sorted third data writing request; sequentially determining whether a requested write position of each of the at least one sorted third data write request coincides with the re-write position; The method of writing the requested write data corresponding to the target third data write request in the third data write request in response to the at least one data write failure coincides with the re-write position, and appending the requested write data corresponding to the target third data write request according to the target third data write request comprises: In response to the request write position of a target third data write request in the at least one sorted third data write request coinciding with the re-write position, request write data corresponding to the target third data write request is additionally written according to the target third data write request.

8. A data writing device, wherein: The device comprises: a request acquisition module, configured to acquire at least one data write request sorted according to a request write position, wherein the at least one data write request is for the same file or byte stream, and the data write request includes a request write position corresponding to the request write data and a request write length corresponding to the request write data; A position acquisition module, configured to acquire a current writing position of currently written data; A data write module is configured to determine in sequence whether a requested write position of each data write request in at least one of the sorted data write requests coincides with the current write position; in response to the requested write position of a first data write request in at least one of the sorted data write requests coincident with the current write position, additionally write the requested write data corresponding to the first data write request according to the first data write request.

9. An electronic device, wherein: The method comprises a memory and at least one processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the at least one processor to implement the method steps described in any one of claims 1 to 7.

10. A computer-readable storage medium having computer instructions stored thereon, wherein: When the computer instructions are executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Data writing and obtaining methods and devices used for distributed storage system

    CN106527958A