Data reading and writing method, device, server and computer-readable storage medium
By allocating data read requests to different queues in the server according to the CPU status and storage node delay, the storage system speed restriction caused by excessive storage node delay is solved, and adaptive low-latency data reading is realized, and data reading speed is improved.
Patent Information
- Application Number
- CN202211032995.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-08-26
AI Technical Summary
When reading data, the existing erasure code storage solution has the problem of limited storage system speed due to excessive delay in storage nodes.
According to the server CPU operating status and storage node cluster delay, data read requests are inserted into the first queue or the second queue for processing. The first queue obtains N original data without erasure calculations. The second queue obtains any N erasure data and requires erasure calculations. Combined with the CPU operating status and cluster delay, adaptive low-delay data reading is realized.
By reasonably allocating data read requests to the appropriate queue, the data read speed is improved and the read and write delay of the overall storage system is reduced.
Smart Images

Figure CN115344214B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a data reading and writing method, device, server, and computer-readable storage medium. Background Art
[0002] Erasure Coding (EC) is a coding technology that adds M parity check data to N original data copies. The original data can be restored from any N copies of the N+M copies. If any of the M or fewer copies of data fail, the data can still be restored from the remaining data. Applying erasure coding technology to storage can effectively improve data fault tolerance.
[0003] Current storage solutions using erasure coding technology typically rely on client access requests to obtain the specific location of the requested data within a storage node cluster. The data is then read from each storage node, and the read result is returned to the client after all storage nodes have returned the data. This solution can severely limit the data read speed of the entire storage system if a storage node cluster has very high latency. Summary of the Invention
[0004] In view of this, an object of the present invention is to provide a data reading and writing method, device, server and computer-readable storage medium to improve the data reading speed of a storage system.
[0005] In order to achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:
[0006] In a first aspect, the present invention provides a data reading and writing method, which is applied to a server, wherein the server communicates with a storage node cluster, and the storage node cluster is used to store N+M copies of erasure data obtained by the server performing erasure coding on data to be written, wherein the N+M copies of erasure data include N copies of original data and M copies of check data, where N and M are positive integers. The method comprises:
[0007] When receiving a data read request, determining the CPU operating state of the server and the data read latency corresponding to the storage node cluster;
[0008] inserting the data read request into a first queue or a second queue according to the CPU operating state and the data read latency, and processing the data read requests in the first queue and the second queue respectively;
[0009] When N copies of original data corresponding to the first target data to be read are obtained according to the data read request in the first queue, the first target data is obtained according to the N copies of original data and returned to the corresponding client; when any N copies of erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue, the second target data is obtained according to the N copies of erasure data and returned to the corresponding client.
[0010] In an optional implementation manner, inserting the data read request into the first queue or the second queue according to the CPU operating state and the data read latency includes:
[0011] When the CPU is in an overloaded state, inserting the data read request into a first queue;
[0012] When the CPU operating state is a low-load state and the data read latency is within a preset high latency range, inserting the data read request into the second queue;
[0013] When the CPU operating state is a low-load state and the data read latency is not in a preset high-latency interval, or when the CPU operating state is a normal-load state, the data read request is inserted into one of the first queue and the second queue.
[0014] In an optional implementation manner, obtaining the first target data according to the N pieces of original data and returning the first target data to the corresponding client includes:
[0015] splicing the N copies of original data to obtain the first target data;
[0016] Return the first target data to the corresponding client.
[0017] In an optional implementation, obtaining the second target data according to the N pieces of erasure data and returning the data to the corresponding client includes:
[0018] If the check data does not exist in the N copies of the erasure data, concatenate the N copies of the erasure data to obtain the second target data, and return the second target data to the corresponding client;
[0019] If there is check data in the N copies of the erasure data, erasure calculation is performed on the N copies of the erasure data to obtain the second target data, and the second target data is returned to the corresponding client.
[0020] In an optional implementation manner, the separately processing the data read requests in the first queue and the second queue includes:
[0021] Determine, based on the data read requests in the first queue, a first storage location of N copies of original data and M copies of verification data corresponding to the first target data to be read on each storage node of the storage node cluster; send a first sub-read request to the corresponding storage node based on the first storage location, so that each storage node returns the corresponding original data or verification data based on the received first sub-read request;
[0022] According to the data read request in the second queue, determine the second storage location of N original data and M verification data corresponding to the second target data to be read on each storage node of the storage node cluster; according to the second storage location, send a second sub-read request to the corresponding storage node, so that each storage node returns the corresponding original data or verification data based on the received second sub-read request.
[0023] In an optional embodiment, the method further comprises:
[0024] When receiving a data write request for data to be written, obtaining N+M copies of erasure correction data corresponding to the data to be written;
[0025] Determine a third storage location for the N+M copies of the erasure data on each storage node in the storage node cluster;
[0026] Sending a sub-write request to a corresponding storage node according to the third storage location, so that each storage node stores the N+M copies of the erasure data according to the received sub-write request;
[0027] When N of the N+M copies of erasure data corresponding to the data to be written are successfully written, a write success message is returned to the corresponding client; when more than M of the N+M copies of erasure data corresponding to the data to be written fail to be written, a write failure message is returned to the corresponding client.
[0028] In an optional embodiment, the N+M copies of erasure data correspond to a data group, and the N+M copies of erasure data are stored on N+M blocks corresponding to the data group; wherein, the N+M blocks corresponding to the same data group are respectively placed on different disks of the storage nodes in the storage node cluster, and the number of blocks belonging to the same data group placed by each storage node in the storage node cluster does not exceed M.
[0029] In a second aspect, the present invention provides a data reading and writing device, which is applied to a server, wherein the server communicates with a storage node cluster, and the storage node cluster is used to store N+M copies of erasure data obtained by the server performing erasure coding on data to be written, wherein the N+M copies of erasure data include N copies of original data and M copies of check data, where N and M are positive integers; the device comprises:
[0030] a determination module, configured to determine, upon receiving a data read request, a CPU operating state of the server and a data read latency corresponding to the storage node cluster;
[0031] a request processing module, configured to insert the data read request into the first queue or the second queue according to the CPU operating state and the data read latency, and process the data read requests in the first queue and the second queue respectively;
[0032] A data processing module is used to obtain the first target data based on the N copies of original data and return them to the corresponding client when N copies of original data corresponding to the first target data to be read are obtained according to the data read request in the first queue; and to obtain the second target data based on the N copies of erasure data and return them to the corresponding client when any N copies of erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue.
[0033] In a third aspect, the present invention provides a server comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data reading and writing method as described in any one of the aforementioned embodiments.
[0034] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the data reading and writing method as described in any one of the aforementioned embodiments.
[0035] The data reading and writing method, device, server and computer-readable storage medium provided by the embodiments of the present invention, when receiving a data read request, determine the CPU operating status of the server and the data reading latency corresponding to the storage node cluster; insert the data read request into the first queue or the second queue according to the CPU operating status and the data reading latency; process the data read requests in the first queue and the second queue respectively; when N copies of original data corresponding to the first target data to be read are obtained according to the data read request in the first queue, the first target data is obtained according to the N copies of the original data and returned to the corresponding client; when any N copies of erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue, the second target data is obtained according to the N copies of the erasure data and returned to the corresponding client. The request processing strategy corresponding to the first queue is to obtain N copies of the original data, and the first target data to be read can be obtained without performing erasure calculations; the request processing strategy corresponding to the second queue is to obtain any N copies of erasure data. These N copies of erasure data may contain verification data, and erasure calculations are required to obtain the second target data to be read. Since data can be returned by obtaining only any N copies of erasure data, it takes less time than the method that requires obtaining N copies of the original data. Therefore, by combining the CPU operating status and the current latency of the storage node cluster, the data read request is inserted into the appropriate queue for processing, which can achieve adaptive low-latency data reading, thereby improving the data reading speed.
[0036] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 A schematic diagram of an application scenario applicable to an embodiment of the present invention is shown;
[0039] Figure 2 A schematic diagram of read and write request splitting under 3 storage nodes and a 4+2 erasure ratio is shown;
[0040] Figure 3 A schematic diagram of a flow chart of a data reading and writing method provided by an embodiment of the present invention is shown;
[0041] Figure 4 Shows a schematic diagram of the internal architecture of tgt;
[0042] Figure 5 A two-dimensional graph showing CPU usage and data read latency;
[0043] Figure 6 A schematic diagram of a single data read process with 3 storage nodes and a 2+1 erasure ratio is shown;
[0044] Figure 7 Another schematic diagram of a flow chart of a data reading and writing method provided by an embodiment of the present invention is shown;
[0045] Figure 8 A schematic diagram of a single data write process with 3 storage nodes and a 2+1 erasure ratio is shown;
[0046] Figure 9 A block placement diagram is shown for a case of 3 storage nodes and a 4+2 erasure ratio;
[0047] Figure 10 A block placement diagram is shown for a case with 5 storage nodes and a 4+2 erasure ratio.
[0048] Figure 11 A functional module diagram of a data reading and writing device provided by an embodiment of the present invention is shown;
[0049] Figure 12 A block diagram of a server provided by an embodiment of the present invention is shown.
[0050] Icons: 10-storage system; 100-terminal device; 200-server; 300-storage node cluster; 400-data reading and writing device; 210-memory; 220-processor; 230-communication module; 410-determination module; 420-request processing module; 430-data processing module. DETAILED DESCRIPTION
[0051] The following will be combined with the accompanying drawings to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0052] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but is merely intended to represent selected embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.
[0053] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
[0054] Please refer to Figure 1 , is a schematic diagram of an application scenario applicable to an embodiment of the present invention. Figure 1 As shown, storage system 10 includes a terminal device 100, a server 200, and a storage node cluster 300. Storage node cluster 300 includes multiple storage nodes (e.g., DN1, DN2, ..., DNx). Terminal device 100 is in communication with server 200, and server 200 is in communication with each storage node in storage node cluster 300. Storage node cluster 300 is used to store N+M copies of erasure data obtained by erasure coding the data to be written by server 200. The N+M copies of erasure data include N copies of original data and M copies of parity data, where N and M are positive integers.
[0055] In this embodiment, a client (client) runs on the terminal device 100, and a service process (tgt) runs on the server 200. The client is connected to the tgt through the ISCSI (Internet Small Computer System Interface) protocol. The tgt listens on a certain port (generally 3260) and provides the client with lun (logical unit number) read and write services. Depending on the actual configuration, the tgt can provide read and write services for one or more luns.
[0056] Requests arriving at the TGT side can be described as (lun, write / read, offset, length), indicating that data of length length is written to or read from the offset of the lun. In this embodiment, when read / write requests arrive at the TGT side, the TGT splits the requests and distributes them across the storage nodes to achieve capacity balancing and accelerate read and write operations. By properly splitting read / write requests and returning them when certain conditions are met, the storage system's read and write speeds can be effectively accelerated, reducing overall storage system read and write latency.
[0057] The following describes the read and write request splitting process. Figure 2 As shown in the figure, assuming that TGT provides services to the client in the form of a single lun, when a read or write request arrives at TGT, TGT first calculates the location of the large file to which the read or write request belongs. Because the size of a large file is always specified as 1GB, the large file to which the read or write request belongs (lun, write / read, offset, length) can be expressed as: fileid = offset / 1GB;
[0058] When further decomposing obj (group) and block (block), the erasure ratio N+M is relevant. The erasure ratio N+M indicates that N copies of data can be generated through erasure coding to generate N+M copies of data. The N copies of data remain unchanged before and after erasure coding and are called original data. The M copies of data are newly generated after erasure coding and are called parity data.
[0059] Assuming that the specified block size sizeblock is 64M, then the size of obj is: sizeobj = sizeblock * N;
[0060] From this, we can get the obj splitting situation under different erasure ratios. When the erasure ratio is 4+2, it is split into 4 obj, and when the erasure ratio is 2+1, it is split into 8 obj. The splitting situation of each common erasure ratio is shown in Table 1:
[0061] Table 1
[0062] Erasure ratio (N+M) object size (M) Number of split obj 16+1 1024 1 16+4 1024 1 16+2 1024 1 8+2 512 2 8+1 512 2 4+2 256 4 4+1 256 4 2+1 128 8 1+1 64 16
[0063] In other words, each large file is split into multiple data groups (obj) based on the erasure ratio. Each data group corresponds to N+M blocks. These N+M blocks are distributed across the disks of each storage node in the storage node cluster 300. Each block can be understood as a certain amount of storage space on the disk for storing data. In this way, the ID of obj can be calculated based on the offset and length of the large file, combined with the size of obj, and data can be read and written from each block corresponding to obj.
[0064] For example, when writing data, server 200 performs erasure coding on the data to be written using TGT to obtain N+M copies of erasure data (including N copies of original data and M copies of parity data). These N+M copies of erasure data are then stored in the N+M blocks corresponding to obj. The blocks storing original data are called data blocks, and the blocks storing parity data are called parity blocks.
[0065] In this embodiment, the read and write order from the large file layer to the obj layer is from front to back. If data is to be written to the entire LUN from beginning to end, the write order for the large file layer is to first fill the first 1GB large file, then write the second 1GB large file, writing from front to back. The same order applies to the obj layer. However, at the block layer, writing is no longer done from front to back, but rather "in parallel." As a result, the latency of a particular read or write operation depends on the latency of the slowest storage node. In some cases, if the latency of a storage node is very high, it will seriously restrict the read and write speed of the storage system.
[0066] Based on this, an embodiment of the present invention proposes a data reading and writing method, device, server, and computer-readable storage medium, which distributes data under the same lun in the form of large files to various storage nodes, and adopts an adaptive low-latency reading and writing scheme during reading and writing, which can quickly read and write data and reduce the data reading and writing latency. Among them, for data read requests, it inserts the data read request into the first queue or the second queue for processing according to the CPU operating status and the read data latency of the storage node cluster; the request processing strategy corresponding to the first queue is to obtain N copies of original data, and the data to be read can be obtained without erasure calculation; the request processing strategy corresponding to the second queue is to obtain any N copies of erasure data, which may contain verification data and require erasure calculation to obtain the data to be read. Since only any N copies of erasure data are needed to return data, the time consumption will be shorter than the method of needing to obtain N copies of original data. Therefore, by combining the CPU operating status and cluster latency, the read request is inserted into the appropriate queue for processing, which can achieve adaptive low-latency data reading, thereby improving the data reading speed. For data write requests, it returns to the upper-level client when N copies of data are successfully written or more than M copies of data fail to be written, thereby avoiding the impact of high-latency nodes on the write process.
[0067] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0068] Please refer to Figure 3 , is a flow chart of a data reading and writing method provided by an embodiment of the present invention. It should be noted that the data reading and writing method of the embodiment of the present invention is not based on Figure 3The specific order below is for limitation. It should be understood that in other embodiments, the order of some steps in the data reading and writing method of the embodiment of the present invention can be interchanged according to actual needs, or some steps can be omitted or deleted. The data reading and writing method can be executed by the server 200 mentioned above. Figure 3 The specific process shown is explained in detail.
[0069] Step S301: When a data read request is received, the CPU operating status of the server and the data read latency corresponding to the storage node cluster are determined.
[0070] In this embodiment, when the server receives a data read request from the client, tgt will count the server's current CPU operating status and the corresponding data read latency of the storage node cluster to determine the current working status of the storage system.
[0071] The CPU operating status of the server can be determined by obtaining the CPU usage rate; the data read latency corresponding to the storage node cluster can be obtained by calculating the average latency of each storage node sending and receiving messages.
[0072] Step S302 : inserting the data read request into the first queue or the second queue according to the CPU operating state and the data read latency, and processing the data read requests in the first queue and the second queue respectively.
[0073] In this embodiment, when server 200 writes data to the storage node cluster, it performs erasure coding on the data to be written, generating N+M copies of erasure data. These copies are stored in the N+M blocks corresponding to obj. Due to the characteristics of erasure calculation, when reading data, only any N copies of erasure data need to be read to restore the desired data. If the N copies of erasure data read happen to be the original data, then erasure calculation is not required to restore the desired data. However, if the N copies of erasure data read contain check data, then erasure calculation is required to restore the desired data.
[0074] Based on this, this embodiment designs a first queue and a second queue, and adopts different request processing strategies for data read requests inserted into the first and second queues. The request processing strategy for the first queue is to obtain N copies of the original data so that the desired data can be obtained without erasure calculations. The request processing strategy for the second queue is to obtain N arbitrary copies of erasure data, which may contain check data and require erasure calculations to obtain the desired data.
[0075] like Figure 4As shown, the client's data read request first reaches the tgt statistics module. The statistics module counts the CPU operating status and the corresponding data read latency of the storage node cluster. Then, based on the CPU operating status and data read latency, it decides whether to insert this data read request into the first queue or the second queue. The tgt message processing module processes the data read requests in the first queue and the second queue respectively according to the corresponding request processing strategy.
[0076] Step S303: When N copies of original data corresponding to the first target data to be read are obtained according to the data read request in the first queue, the first target data is obtained according to the N copies of original data and returned to the corresponding client; when any N copies of erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue, the second target data is obtained according to the N copies of erasure data and returned to the corresponding client.
[0077] Optionally, when the server 200 obtains N copies of original data corresponding to the first target data to be read according to the data read request in the first queue, it can splice the N copies of original data to obtain the first target data, and return the first target data to the corresponding client.
[0078] Optionally, when the server 200 obtains any N copies of erasure data corresponding to the second target data to be read based on the data read request in the second queue, if there is no verification data in the N copies of erasure data, the N copies of erasure data are spliced to obtain the second target data, and the second target data are returned to the corresponding client; if there is verification data in the N copies of erasure data, erasure calculation is performed on the N copies of erasure data to obtain the second target data, and the second target data is returned to the corresponding client.
[0079] In this embodiment, when the server 200 processes the data read request in the first queue, it can save CPU because it does not need to perform erasure calculations, but it must wait until N copies of the original data are available to obtain the first target data and return it to the client, so it may take longer; when the server 200 processes the data read request in the second queue, it only needs to obtain any N copies of erasure data to obtain the second target data and return it to the client, so it takes even less time, but the N copies of erasure data may contain verification data, which requires erasure calculations, so it will consume CPU.
[0080] In this way, the server inserts data read requests into the appropriate queue for processing by combining the CPU operating status and the latency of the storage node cluster, effectively balancing CPU consumption and data reading latency, and where appropriate, reducing latency by consuming CPU.
[0081] It can be seen that in the data reading and writing method provided by the embodiment of the present invention, the server inserts the received data read request into the first queue or the second queue for processing according to the CPU operating status and the data reading latency; the request processing strategy corresponding to the first queue is to obtain N copies of original data, and the first target data to be read can be obtained without performing correction and erasure calculations; and the request processing strategy corresponding to the second queue is to obtain any N copies of erasure data, which may contain verification data, and correction and erasure calculations are required to obtain the second target data to be read. Since data can be returned by obtaining any N copies of erasure data, it takes less time than the method of obtaining N copies of original data. Therefore, by combining the CPU operating status and the current latency of the storage node cluster, the data read request is inserted into the appropriate queue for processing, which can achieve adaptive low-latency data reading, thereby improving the data reading speed.
[0082] Optionally, in step S302, inserting the data read request into the first queue or the second queue according to the CPU operating state and the data read latency may include:
[0083] When the CPU is in an overload state, the data read request is inserted into the first queue; when the CPU is in a low load state and the data read latency is in a preset high latency range, the data read request is inserted into the second queue; when the CPU is in a low load state and the data read latency is not in the preset high latency range, or when the CPU is in a normal load state, the data read request is inserted into one of the first queue and the second queue.
[0084] In this embodiment, since processing data read requests in the first queue consumes less CPU but takes more time, while processing data read requests in the second queue consumes more CPU but takes less time, when the CPU operating state is determined to be overloaded, it indicates that the system load has reached its maximum, and the number of requests in the second queue needs to be reduced, and the data read requests need to be inserted into the first queue. When the CPU operating state is determined to be underloaded and the data read latency is within a preset high latency range, it indicates that the system latency is high but the system load is not very high. The number of requests in the second queue can be increased, and the data read requests can be inserted into the second queue to utilize erasure calculation to avoid the impact of high-latency nodes on data reads. When the CPU operating state is determined to be underloaded and the data read latency is not within the preset high latency range, it indicates that neither the system load nor the latency is very high. The data read requests can be inserted into the first queue or the second queue according to the set rules. When the CPU operating state is determined to be normal load, regardless of the system latency, considering that the system already has a certain load, the data read requests are inserted into the first queue or the second queue according to the set rules. The setting rules may be set according to actual needs, such as randomly selecting the first queue or the second queue for insertion, or keeping the ratio of the number of requests in the first queue and the second queue within a set range.
[0085] In one example, the CPU usage and read data latency can be expressed as Figure 5 The two-dimensional graph shown in the figure shows that the horizontal axis represents the CPU usage and the vertical axis represents the data read latency. The data read latency is divided into high and low water levels according to the business needs; the CPU usage is also set at high and low water levels according to the TGT hardware level. The high water level means that the latency has been reached or the CPU has reached the upper limit of the hardware specifications and cannot be increased; the water levels between the high and low water levels represent the normal state of the business; the low water level indicates that the system is in the optimal state. Based on this, the working state of the system can be divided into Figure 5 The nine regions in the figure correspond to CPU overload conditions. Regions ③, ⑥, and ⑨ correspond to situations where the CPU is underloaded, with read latency within the preset high-latency range, and region ① corresponds to situations where the CPU is underloaded and read latency is outside the preset high-latency range. Regions ②, ⑤, and ⑧ correspond to situations where the CPU is under normal load. To minimize the impact of high-latency storage nodes on reads, the system prioritizes region ①, followed by regions ②, ④, and ⑤.
[0086] Assume that the ratio of the number of requests in the first queue and the second queue is α:β, α+β=1;
[0087] When the system's working state is in area ③⑥⑨, it indicates that the load has reached its maximum, and then β needs to be reduced. When β reaches 0, it will no longer be reduced, and no request will be inserted into the second queue.
[0088] When the system's working state is at ①, it indicates that the system is in the optimal state, keeping the current α and β values unchanged or fluctuating within a small range;
[0089] When the system's operating status is in area ②, it indicates that the system has avoided high-latency nodes through erasure calculations, resulting in an increase in CPU usage, but it is still within an acceptable range, maintaining the current α and β values unchanged or fluctuating within a small range.
[0090] When the system's operating status is in areas ④ and ⑦, it indicates that the system latency is high and the β value needs to be increased to utilize erasure calculations to avoid high-latency nodes.
[0091] When the system's operating status is in region ⑤, it indicates that the system is loaded, but the latency is acceptable, and the current α and β values remain unchanged or fluctuate within a small range.
[0092] When the system state is in region ⑧, it indicates that there are nodes with large delays in the system, but the system load is also high, and the current α and β values can only remain unchanged or fluctuate within a small range.
[0093] It should be noted that the above-mentioned use of high and low water levels to divide the system status is only an example; in actual applications, in order to obtain more precise control, more water levels can be divided. The principle is similar to that of high and low water levels and will not be repeated here.
[0094] Optionally, processing the data read requests in the first queue and the second queue respectively in step S302 includes:
[0095] Based on the data read requests in the first queue, determine the first storage location of the N original data and M verification data corresponding to the first target data to be read on each storage node of the storage node cluster; send a first sub-read request to the corresponding storage node based on the first storage location, so that each storage node returns the corresponding original data or verification data based on the received first sub-read request; based on the data read requests in the second queue, determine the second storage location of the N original data and M verification data corresponding to the second target data to be read on each storage node of the storage node cluster; send a second sub-read request to the corresponding storage node based on the second storage location, so that each storage node returns the corresponding original data or verification data based on the received second sub-read request.
[0096] In this embodiment, the process of the server 200 processing the data read requests in the first queue and the second queue is similar, such as Figure 6As shown in the figure, taking 3 storage nodes and a 2+1 erasure ratio as an example, when TGT processes each data read request, it first calculates the storage location of the data to be read on each storage node DN1, DN2, and DN3. It then sends a read version number request to each storage node DN1, DN2, and DN3 respectively. When the number of valid version numbers returned by each storage node DN1, DN2, and DN3 is greater than or equal to N, it sends a sub-read request to each storage node DN1, DN2, and DN3. The redundant read version responses are discarded. Finally, the target data to be read is obtained based on the data returned by each storage node DN1, DN2, and DN3 based on the sub-read requests and returned to the client.
[0097] Alternatively, see Figure 7 The data reading and writing method provided by the embodiment of the present invention may further include:
[0098] Step S701: When a data write request for data to be written is received, N+M copies of erasure correction data corresponding to the data to be written are obtained;
[0099] Step S702: Determine a third storage location for the N+M copies of erasure data on each storage node in the storage node cluster.
[0100] Step S703: Send a sub-write request to the corresponding storage node according to the third storage location, so that each storage node stores the N+M copies of the erasure data according to the received sub-write request.
[0101] Step S704: When N of the N+M erasure data corresponding to the data to be written are successfully written, a write success message is returned to the corresponding client; when more than M of the N+M erasure data corresponding to the data to be written fail to be written, a write failure message is returned to the corresponding client.
[0102] In this embodiment, when tgt receives a data write request for data to be written, it performs erasure coding calculation on the data to be written based on the erasure ratio N+M, and obtains the corresponding N+M copies of erasure data, that is, N copies of original data and M copies of verification data. Then, based on the offset and length carried in the data write request, it calculates the third storage location of the N+M copies of erasure data on each storage node in the storage node cluster, and sends a sub-write request to the corresponding storage node to store the N+M copies of erasure data. When tgt receives a successful write of N copies of data or a failed write of more than M copies of data, it returns to the upper-layer client, thereby avoiding the influence of high-latency nodes on the write process. For the write response reached after the data has returned to the upper layer, data confirmation or rollback is performed in the background. For example, see Figure 8 The data writing process is shown.
[0103] In practical applications, to ensure data recovery in the event of a node or disk failure, blocks must be properly placed within the node storage cluster. Since N+M copies of erasure data correspond to one data group, and N+M copies of erasure data are stored on the N+M blocks corresponding to that data group, the N+M blocks corresponding to the same data group can be placed on different disks within the storage node cluster. Each storage node in the storage node cluster must place no more than M blocks belonging to the same data group.
[0104] That is to say, the total number of disks on all storage nodes in the storage node cluster must be greater than or equal to N+M, and a single storage node can place a maximum of M blocks. When placing blocks, try to evenly distribute the blocks under the same data group on each disk of each storage node. Two blocks of the same data group should not be placed on the same disk at the same time.
[0105] In one implementation, assuming the number of storage nodes is num, for a group of obj, the number of blocks placed by (N+M)%num storage nodes in the storage node cluster is (N+M) / num+1 (in this embodiment, these storage nodes are referred to as type A nodes), and the number of blocks placed by num-(N+M)%num storage nodes is (N+M) / num (in this embodiment, these storage nodes are referred to as type B nodes). Considering that the first N blocks are always read and written first when reading and writing data, type B nodes are preferred when placing the first N blocks of each group of obj.
[0106] Take 3 storage nodes and 4+2 erasure ratio as an example. Figure 9 As shown, the number of type A nodes is (4+2)%3=0, and the number of blocks placed on them is (4+2) / 3+1=3; the number of type B nodes is 3-0=3, and the number of blocks placed on them is (4+2) / 3=2.
[0107] With 5 storage nodes and 4+2 erasure ratio, as Figure 10 As shown, the number of type A nodes is (4+2)%5=1, and the number of blocks placed on them is (4+2) / 5+1=2; the number of type B nodes is 5-1=4, and the number of blocks placed on them is (4+2) / 5=1; the first N blocks give priority to type B nodes.
[0108] In this way, the present invention, through simple block placement and appropriate CPU computation, can mitigate network latency fluctuations across at least M storage nodes. Furthermore, no special caching technology is required, and there's no need to trade storage for time. Instead, CPU computing power within an acceptable load range is leveraged to reduce read and write latency, effectively accelerating the storage system's read and write speeds and reducing overall latency.
[0109] In order to execute the corresponding steps in the above embodiments and various possible methods, a data reading and writing device is provided below. Figure 11 , which is a functional module diagram of a data reading and writing device 400 provided in an embodiment of the present invention. It should be noted that the basic principles and technical effects of the data reading and writing device 400 provided in this embodiment are the same as those in the above-mentioned embodiments. For the sake of brevity, any details not mentioned in this embodiment are referred to the corresponding contents in the above-mentioned embodiments. The data reading and writing device 400 includes a determination module 410, a request processing module 420, and a data processing module 430.
[0110] The determination module 410 is configured to determine the CPU operating status of the server and the data reading latency corresponding to the storage node cluster when receiving a data read request.
[0111] It can be understood that the determination module 410 can execute the above step S301.
[0112] The request processing module 420 is configured to insert a data read request into the first queue or the second queue according to the CPU operating state and the data read latency, and process the data read requests in the first queue and the second queue respectively.
[0113] It can be understood that the request processing module 420 can execute the above step S302.
[0114] The data processing module 430 is used to obtain the first target data based on the N copies of the original data and return it to the corresponding client when N copies of the original data corresponding to the first target data to be read are obtained according to the data read request in the first queue; and to obtain the second target data based on the N copies of the erasure data and return it to the corresponding client when any N copies of the erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue.
[0115] It can be understood that the data processing module 430 can execute the above step S303.
[0116] Optionally, N+M copies of erasure data correspond to one data group, and the N+M copies of erasure data are stored on N+M blocks corresponding to the data group; wherein, the N+M blocks corresponding to the same data group are respectively placed on different disks of storage nodes in the storage node cluster, and the number of blocks belonging to the same data group placed by each storage node in the storage node cluster does not exceed M.
[0117] Optionally, the request processing module 420 is specifically used to insert the data read request into the first queue when the CPU operating state is overloaded; insert the data read request into the second queue when the CPU operating state is low load and the data read latency is in a preset high latency interval; insert the data read request into one of the first queue and the second queue when the CPU operating state is low load and the data read latency is not in the preset high latency interval, or when the CPU operating state is normal load.
[0118] Optionally, the request processing module 420 is also specifically used to determine the first storage location of N copies of original data and M copies of verification data corresponding to the first target data to be read on each storage node of the storage node cluster based on the data read requests in the first queue; send a first sub-read request to the corresponding storage node based on the first storage location, so that each storage node returns the corresponding original data or verification data based on the received first sub-read request; determine the second storage location of N copies of original data and M copies of verification data corresponding to the second target data to be read on each storage node of the storage node cluster based on the data read requests in the second queue; send a second sub-read request to the corresponding storage node based on the second storage location, so that each storage node returns the corresponding original data or verification data based on the received second sub-read request.
[0119] Optionally, the data processing module 430 is specifically configured to concatenate N copies of original data to obtain first target data; and return the first target data to a corresponding client.
[0120] Optionally, the data processing module 430 is further specifically used to, if there is no verification data in the N copies of the erasure data, splice the N copies of the erasure data to obtain second target data, and return the second target data to the corresponding client; if there is verification data in the N copies of the erasure data, perform erasure calculation on the N copies of the erasure data to obtain second target data, and return the second target data to the corresponding client.
[0121] Optionally, the request processing module 420 is also used to obtain N+M copies of erasure data corresponding to the data to be written when a data write request for the data to be written is received; determine a third storage location of the N+M copies of erasure data on each storage node in the storage node cluster; send a sub-write request to the corresponding storage node according to the third storage location, so that each storage node stores the N+M copies of erasure data according to the received sub-write request; when N copies of the erasure data corresponding to the data to be written are successfully written, return a write success message to the corresponding client; when more than M copies of the erasure data corresponding to the N+M copies of erasure data fail to be written, return a write failure message to the corresponding client.
[0122] It can be understood that the request processing module 420 can also execute the above steps S701 to S704.
[0123] It can be seen that the data reading and writing device provided by the embodiment of the present invention includes a determination module, a request processing module and a data processing module; the determination module is used to determine the CPU operating status of the server and the data reading latency corresponding to the storage node cluster when receiving a data read request; the request processing module is used to insert the data read request into the first queue or the second queue according to the CPU operating status and the data reading latency, and process the data read requests in the first queue and the second queue respectively; the data processing module is used to obtain the first target data based on the N copies of the original data and return it to the corresponding client when N copies of the original data corresponding to the first target data to be read are obtained according to the data read request in the first queue; when any N copies of the erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue, the second target data is obtained based on the N copies of the erasure data and return it to the corresponding client. The request processing strategy corresponding to the first queue is to obtain N copies of the original data, and the first target data to be read can be obtained without performing erasure calculations; the request processing strategy corresponding to the second queue is to obtain any N copies of erasure data. These N copies of erasure data may contain verification data, and erasure calculations are required to obtain the second target data to be read. Since data can be returned by obtaining only any N copies of erasure data, it takes less time than the method that requires obtaining N copies of the original data. Therefore, by combining the CPU operating status and the current latency of the storage node cluster, the data read request is inserted into the appropriate queue for processing, which can achieve adaptive low-latency data reading, thereby improving the data reading speed.
[0124] Please refer to Figure 12 , is a block diagram of a server 200 according to an embodiment of the present invention. Server 200 includes a memory 210, a processor 220, and a communication module 230. The memory 210, processor 220, and communication module 230 are electrically connected to each other, directly or indirectly, to enable data transmission or exchange. For example, these components may be electrically connected via one or more communication buses or signal lines.
[0125] The memory 210 is used to store programs or data. The memory 210 can be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0126] The processor 220 is used to read / write data or programs stored in the memory 210 and execute corresponding functions. For example, when the computer program stored in the memory 210 is executed by the processor 220, the data reading and writing methods disclosed in the above embodiments can be implemented.
[0127] The communication module 230 is used to establish a communication connection between the server 200 and other communication terminals through the network, and to send and receive data through the network.
[0128] It should be understood that Figure 12 The structure shown is only a schematic diagram of the structure of the server 200. The server 200 may also include Figure 12 More or fewer components than shown, or with Figure 12 Different configurations shown. Figure 12 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0129] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by the processor 220, the data reading and writing methods disclosed in the above embodiments are implemented.
[0130] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a portion of code, and the module, program segment or a portion of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes 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 flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.
[0131] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0132] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0133] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A data reading and writing method, characterized in that: A method is applied to a server, the server communicating with a storage node cluster, the storage node cluster being used to store N+M copies of erasure data obtained by erasure coding data to be written by the server, the N+M copies of erasure data including N copies of original data and M copies of check data, where N and M are positive integers; the method comprising: When receiving a data read request, determining the CPU operating state of the server and the data read latency corresponding to the storage node cluster; inserting the data read request into a first queue or a second queue according to the CPU operating state and the data read latency, and processing the data read requests in the first queue and the second queue respectively; When N copies of original data corresponding to the first target data to be read are obtained according to the data read request in the first queue, the first target data is obtained according to the N copies of original data and returned to the corresponding client; when any N copies of erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue, the second target data is obtained according to the N copies of erasure data and returned to the corresponding client.
2. The method according to claim 1, characterized in that The step of inserting the data read request into the first queue or the second queue according to the CPU operating state and the data read latency includes: When the CPU is in an overloaded state, inserting the data read request into a first queue; When the CPU operating state is a low-load state and the data read latency is within a preset high latency range, inserting the data read request into the second queue; When the CPU operating state is a low-load state and the data read latency is not in a preset high-latency interval, or when the CPU operating state is a normal-load state, the data read request is inserted into one of the first queue and the second queue.
3. The method according to claim 1, characterized in that The obtaining the first target data according to the N copies of original data and returning the first target data to the corresponding client includes: splicing the N copies of original data to obtain the first target data; Return the first target data to the corresponding client.
4. The method according to claim 1, wherein The obtaining the second target data according to the N pieces of erasure data and returning the data to the corresponding client includes: If the check data does not exist in the N copies of the erasure data, concatenate the N copies of the erasure data to obtain the second target data, and return the second target data to the corresponding client; If there is check data in the N copies of the erasure data, erasure calculation is performed on the N copies of the erasure data to obtain the second target data, and the second target data is returned to the corresponding client.
5. The method according to claim 1, wherein The processing of the data read requests in the first queue and the second queue respectively includes: Determine, based on the data read requests in the first queue, a first storage location of N copies of original data and M copies of verification data corresponding to the first target data to be read on each storage node of the storage node cluster; send a first sub-read request to the corresponding storage node based on the first storage location, so that each storage node returns the corresponding original data or verification data based on the received first sub-read request; According to the data read request in the second queue, determine the second storage location of N original data and M verification data corresponding to the second target data to be read on each storage node of the storage node cluster; according to the second storage location, send a second sub-read request to the corresponding storage node, so that each storage node returns the corresponding original data or verification data based on the received second sub-read request.
6. The method according to claim 1, characterized in that The method further comprises: When receiving a data write request for data to be written, obtaining N+M copies of erasure correction data corresponding to the data to be written; Determine a third storage location for the N+M copies of the erasure data on each storage node in the storage node cluster; Sending a sub-write request to a corresponding storage node according to the third storage location, so that each storage node stores the N+M copies of the erasure data according to the received sub-write request; When N of the N+M copies of erasure data corresponding to the data to be written are successfully written, a write success message is returned to the corresponding client; when more than M of the N+M copies of erasure data corresponding to the data to be written fail to be written, a write failure message is returned to the corresponding client.
7. The method according to any one of claims 1 to 6, characterized in that The N+M copies of erasure data correspond to a data group, and the N+M copies of erasure data are stored on N+M blocks corresponding to the data group; wherein, the N+M blocks corresponding to the same data group are respectively placed on different disks of the storage nodes in the storage node cluster, and the number of blocks belonging to the same data group placed by each storage node in the storage node cluster does not exceed M.
8. A data reading and writing device, characterized in that: The device is applied to a server, the server communicating with a storage node cluster, the storage node cluster being used to store N+M copies of erasure data obtained by erasure coding data to be written by the server, the N+M copies of erasure data including N copies of original data and M copies of check data, where N and M are positive integers; the device comprises: a determination module, configured to determine, upon receiving a data read request, a CPU operating state of the server and a data read latency corresponding to the storage node cluster; a request processing module, configured to insert the data read request into the first queue or the second queue according to the CPU operating state and the data read latency, and process the data read requests in the first queue and the second queue respectively; A data processing module is used to obtain the first target data based on the N copies of original data and return them to the corresponding client when N copies of original data corresponding to the first target data to be read are obtained according to the data read request in the first queue; and to obtain the second target data based on the N copies of erasure data and return them to the corresponding client when any N copies of erasure data corresponding to the second target data to be read are obtained according to the data read request in the second queue.
9. A server, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data reading and writing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data reading and writing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Processing method and device for modifying write operation, electronic equipment and storage medium
CN109992445A
Erasure code read request processing method, system and device and computer medium
CN111858129A