Disclosure of Invention
The invention aims to provide a control method, a control device, control equipment and a computer readable storage medium for write operation of a distributed storage system, which are used for reducing the time delay of the write operation of the distributed storage system.
In order to solve the above technical problem, the present invention provides a method for controlling write operation of a distributed storage system, which is based on a server of the distributed storage system, and comprises:
after receiving data sent by a client, writing the data into a preset cache;
and returning a response of successful writing to the client.
Optionally, after returning a response of successful writing to the client, the method further includes:
and writing the data in the cache into each OSD in the distributed storage system.
Optionally, the writing the data into a preset cache specifically includes:
writing the data into a cache of each OSD preset in the server;
wherein the OSD comprises a main OSD and a sub-OSD.
Optionally, the cache corresponds to the main OSD one to one.
Optionally, after the response of successful write is returned to the client, the method further includes:
and writing the data in the cache into the corresponding main OSD, so that the main OSD writes the data in the cache into the local data partition of the main OSD and the data partition of the sub-OSD corresponding to the main OSD, and then clearing the data in the cache.
Optionally, the cache is specifically a nonvolatile storage medium.
Optionally, the cache is specifically an NVDIMM.
To solve the above technical problem, the present invention further provides a control apparatus for write operation of a distributed storage system, including:
the writing unit is used for writing the data into a preset cache after receiving the data sent by the client;
and the response unit is used for returning a response of successful writing to the client.
To solve the above technical problem, the present invention further provides a control device for write operation of a distributed storage system, including:
a memory for storing instructions, the instructions comprising the steps of the method for controlling write operations of any one of the above-mentioned distributed storage systems;
a processor to execute the instructions.
To solve the above technical problem, the present invention further provides a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the method for controlling write operation of a distributed storage system as described in any one of the above.
According to the control method for the write operation of the distributed storage system, in the server side of the distributed storage system, after the data sent by the client side are received, the data are written into the preset cache, namely, the response of successful write is returned to the client side, so that the write operation is completed for the client side once, the data are not required to be distributed to the OSD, and the OSD completes the execution of the operations of data backup, disk dropping and the like, the problem of high write operation delay of the distributed storage system caused by long write operation IO path is solved, and the write operation flow of the distributed storage system is optimized. The invention also provides a control device, a control device and a computer readable storage medium for write operation of the distributed storage system, which have the beneficial effects and are not described herein again.
Detailed Description
The core of the invention is to provide a control method, a control device, control equipment and a computer readable storage medium for write operation of a distributed storage system, which are used for reducing the time delay of the write operation of the distributed storage system.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart of a method for controlling a write operation of a distributed storage system according to an embodiment of the present invention.
As shown in fig. 1, based on a server of a distributed storage system, a method for controlling write operation of the distributed storage system provided by the embodiment of the present invention includes:
s101: and after receiving the data sent by the client, writing the data into a preset cache.
S102: and returning a response of successful writing to the client.
Data sent by the client to the server is mainly a request sent to the OSD, and in the prior art, after the client sends the data to the server, the client needs to wait for the OSD of the server to process the request. In the method for controlling write operation of the distributed storage system provided by the embodiment of the invention, the cache is arranged at the server side of the distributed storage system in advance, and after the data sent by the client side is received, the data is written into the preset cache. After the operation of writing the data into the cache is completed, a response of successful writing is immediately returned to the client, and then a data processing process is performed, such as data distribution to each OSD and data backup and disk dropping of each OSD are completed. Therefore, after step S102, the method for controlling write operation of a distributed storage system according to an embodiment of the present invention further includes:
s103: and writing the data in the cache into each OSD in the distributed storage system.
In order to ensure that data in the cache is not lost due to abnormal conditions such as system downtime, a nonvolatile storage medium may be used as a preset cache, and further, an NVDIMM (non-volatile dual in-line memory module) may be used.
In the method for controlling write operation of the distributed storage system provided by the embodiment of the invention, in the server of the distributed storage system, after receiving the data sent by the client, the data is written into the preset cache, that is, a response of successful write is returned to the client, so that one write operation is completed for the client, the data does not need to be distributed to each OSD, and the OSD completes execution of operations such as data backup and disk dropping, and the like, so that the problem of high write operation delay of the distributed storage system caused by long write operation IO path is solved, and the write operation flow of the distributed storage system is optimized.
FIG. 2 is a diagram illustrating a write operation processing architecture of a distributed storage system according to an embodiment of the present invention; fig. 3 is a flowchart of a write operation of a server of the distributed storage system according to an embodiment of the present invention.
The server side of the distributed storage system is distributed, data sent to each OSD is calculated through a flush algorithm, and the data volume in each OSD tends to be average as far as possible. In the above embodiment, the data sent by the client to the server is written into the preset cache first, and there are two main implementation manners, one is that a plurality of OSDs share one cache, and the other is that each OSD sets one cache.
In step S101, writing the data into a preset cache specifically as follows:
writing the data into the cache of each OSD preset in the server;
the OSD includes a main OSD and a sub-OSD.
Because the data sent by the client to the server is the request sent to the OSD, each request contains a flag bit, and under the condition that a plurality of OSDs share one cache, a data structure needs to be established to process the requests, so that the data is sent to the corresponding OSDs according to the pre-calculated result. This method has a disadvantage that it needs to be queued to execute when processing requests for each OSD, and the data processing operation (add, delete, modify, check, etc.) needs to be locked, so that the overall processing time is long, and when some OSD fails, the process of processing the data in the buffer at the service end will be affected.
In order to avoid the above problem, a preferred embodiment is to set a buffer for each OSD, so that concurrency among the OSDs can be ensured, and the problem of single point failure is avoided. As shown in fig. 2, a buffer may be added to each storage node and then divided into several partitions, one partition for each OSD (OSD1, OSD2 … …).
Based on the redundant storage rule of the distributed storage system, the OSD comprises a main OSD for receiving the stored data and a sub-OSD for backing up the stored data, so that the cache can correspond to the main OSD one by one, and only a single cache needs to be set for each main OSD. On this basis, after step S102, the method for controlling write operation of a distributed storage system according to an embodiment of the present invention further includes:
and writing the data in the cache into the corresponding main OSD so that the main OSD writes the data in the cache into the local data partition of the main OSD and the data partition of the sub-OSD corresponding to the main OSD, and then clearing the data in the cache.
As shown in fig. 3, with the method for controlling write operation of a distributed storage system according to an embodiment of the present invention, a write operation flow in a server is as follows:
(1) the main OSD writes the data into a corresponding cache after receiving the data, and if the cache is full, the main OSD requests blocking until the cache can be written; if the writing is successful, a response that the write-back operation is successful is returned to the client;
(2) after receiving on _ ack responses returned by all the sub-OSD, the main OSD clears data from the cache;
(3) after the OSD is restarted, the data in the cache needs to be scanned and processed respectively according to the state of the data. The state of the data can be divided into three types:
① dirty state, i.e. data not yet distributed to OSD, at this time, a response of successful writing needs to be sent to the client first, and then the data is sent to the corresponding OSD;
② writeback status, i.e., data that has been sent to the OSD but has not received a OSD response, since the requests sent to the OSD are all idempotent, the write request can be resent to the OSD;
③ clear status, i.e., data for which a OSD response has been received, can be cleared directly.
On the basis of the above detailed description of the various embodiments corresponding to the control method of the write operation of the distributed storage system, the invention also discloses a control device, a control device and a computer readable storage medium of the write operation of the distributed storage system corresponding to the above method.
Fig. 4 is a schematic structural diagram of a control apparatus for write operation of a distributed storage system according to an embodiment of the present invention.
As shown in fig. 4, a control apparatus for write operation of a distributed storage system according to an embodiment of the present invention includes:
the writing unit 401 is configured to write data into a preset cache after receiving the data sent by the client;
a response unit 402, configured to return a response that the write is successful to the client.
Since the embodiments of the apparatus portion and the method portion correspond to each other, please refer to the description of the embodiments of the method portion for the embodiments of the apparatus portion, which is not repeated here.
Fig. 5 is a schematic structural diagram of a control device for write operation of a distributed storage system according to an embodiment of the present invention.
As shown in fig. 5, a control device for write operation of a distributed storage system according to an embodiment of the present invention includes:
a memory 510 for storing instructions, the instructions comprising the steps of the method for controlling write operations of a distributed storage system according to any one of the above embodiments;
a processor 520 for executing the instructions.
Among other things, processor 520 may include one or more processing cores, such as a 3-core processor, an 8-core processor, and so on. The processor 520 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). Processor 520 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also referred to as a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 520 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content that the display screen needs to display. In some embodiments, processor 520 may further include an AI (Artificial Intelligence) processor for processing computational operations related to machine learning.
Memory 510 may include one or more computer-readable storage media, which may be non-transitory. Memory 510 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 510 is at least used for storing the following computer program 511, wherein after the computer program 511 is loaded and executed by the processor 520, the relevant steps in the control method for writing operation of the distributed storage system disclosed in any of the foregoing embodiments can be implemented. In addition, the resources stored in the memory 510 may also include an operating system 512, data 513, and the like, and the storage manner may be a transient storage or a permanent storage. The operating system 512 may be Windows, among others. Data 513 may include, but is not limited to, data involved with the above-described methods.
In some embodiments, the control device for write operations of the distributed storage system may further include a display screen 530, a power supply 540, a communication interface 550, an input output interface 560, a sensor 570, and a communication bus 580.
Those skilled in the art will appreciate that the architecture shown in FIG. 5 does not constitute a limitation of the control device for write operations to a distributed storage system and may include more or fewer components than those shown.
The control device for write operation of the distributed storage system provided by the embodiment of the application comprises the memory and the processor, and when the processor executes the program stored in the memory, the control method for write operation of the distributed storage system can be realized, and the effect is the same as that of the control method for write operation of the distributed storage system.
It should be noted that the above-described embodiments of the apparatus and device are merely illustrative, for example, the division of modules is only one division of logical functions, and there may be other divisions when actually implementing, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form. Modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and performs all or part of the steps of the methods according to the embodiments of the present invention, or all or part of the technical solution.
To this end, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the control method for the write operation of the distributed storage system.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The computer program contained in the computer-readable storage medium provided in this embodiment can implement the steps of the control method for write operation of the distributed storage system described above when executed by the processor, and the effects are the same as above.
The detailed description of the method, the device, the apparatus and the computer readable storage medium for controlling write operations of a distributed storage system provided by the present invention is provided above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device, the apparatus and the computer-readable storage medium disclosed in the embodiments correspond to the method disclosed in the embodiments, so that the description is simple, and the relevant points can be referred to the description of the method. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.