Method, device and electronic equipment for storing all-zero data
By generating an all-zero cache in memory to handle all-zero data requests, the impact of high-concurrency all-zero operations on network bandwidth and storage cluster performance is resolved, achieving efficient all-zero data storage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNITED NETWORK COMM GRP CO LTD
- Filing Date
- 2022-12-12
- Publication Date
- 2026-06-05
AI Technical Summary
In cloud computing applications, high-concurrency all-zero write and all-zero read operations consume a lot of network bandwidth and affect the performance of storage clusters, resulting in a decline in the quality of service for other users' read and write requests.
When a write or read request for all-zero data is received, a corresponding all-zero buffer is allocated in memory, and the all-zero data in the buffer is processed as the request data instead of actually transmitting all-zero data, thereby reducing network bandwidth consumption and the impact on storage cluster performance.
It effectively reduces network bandwidth consumption and storage cluster performance impact, and optimizes the storage process for all-zero data.
Smart Images

Figure CN115904241B_ABST
Abstract
Description
Technical Field
[0001] This application relates to data storage technology, and more particularly to a method, apparatus, and electronic device for storing all-zero data. Background Technology
[0002] In cloud computing applications, virtual machine users, due to business requirements, may perform batch write-zero operations on large contiguous areas of cloud disks mounted on virtual machines to maintain the security of the data originally stored in these areas. For example, after deleting a storage volume, a customer might simultaneously write zeros to the first 10GB of space on cloud disks mounted on 100 virtual machines. Furthermore, due to business needs, there may also be scenarios where a backend distributed storage system reads all-zero data.
[0003] For the aforementioned scenarios of high-concurrency all-zero write or all-zero read operations, high-concurrency all-zero write or all-zero read operations will consume a lot of network bandwidth due to the transmission of multiple data, and will also consume the bandwidth supported by the storage protocol layer of the storage cluster, thus affecting the service quality of read and write requests from other users on the storage cluster. Summary of the Invention
[0004] This application provides a method, apparatus, and electronic device for storing all-zero data, which avoids the transmission of large amounts of all-zero data when it is necessary to read or write large amounts of all-zero data, thereby reducing network bandwidth consumption and minimizing the impact on the performance of the storage cluster.
[0005] On one hand, this application provides a method for storing all-zero data, applied to a distributed storage system, the system including a client and a server, the method applied to the server, the method including:
[0006] When a target write request is received from a client, the write request header of the target write request is obtained. The write request header includes a write request identifier, data length, and data start address. The write request identifier is used to indicate whether the write request body in the target write request carries data.
[0007] If the write request identifier indicates that the write request body does not carry data, then a memory space with the same length as the data is allocated in the server memory, and the memory space is initialized as a write-all-zero buffer.
[0008] The pointer of the write request body is set to the write all-zero buffer so that the all-zero data in the write all-zero buffer is used as the write request data in the write request body;
[0009] Based on the data start address, the write request data in the write request body is stored in the disk.
[0010] In another possible implementation, if the write request identifier indicates that the write request body carries non-all-zero data, the method further includes:
[0011] Based on the data start address, the non-zero data in the write request body is stored in the disk.
[0012] In another possible implementation, the method further includes:
[0013] When a read request is received from the client, the target data corresponding to the read request is read from the disk;
[0014] Determine whether the target data is all zeros, and obtain the determination result;
[0015] Based on the judgment result, a read response is generated and sent to the client. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
[0016] In another possible implementation, generating a read response based on the judgment result includes:
[0017] If the judgment result is that the target data is all zero data, then the read request identifier is set to indicate that the read request body does not carry data, and the read request body does not carry data.
[0018] If the determination result is that the target data is not all zero data, then the read request identifier is set to indicate that the read request body carries data, and the read request body carries data.
[0019] In another possible implementation, determining whether the target data is all zeros includes:
[0020] The preset data and the target data are ORed to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the read request data;
[0021] If the result of the operation is all zeros, then the result is that the target data is all zeros.
[0022] Secondly, this application provides a storage device for zero-data storage, applied to a distributed storage system, the system including a client and a server, the device being applied to the server, the device comprising:
[0023] The acquisition module is used to acquire the write request identifier of the write request body when it receives the write request body corresponding to the write request. The write request body includes the write request data length and the write request start address. The write request identifier is used to indicate whether the target write request body carries data, and the write request identifier is determined by the client based on the write request.
[0024] The first processing module is configured to, when the write request identifier indicates that the write request body does not carry any data, allocate memory space in the server memory that is consistent with the length of the write request data, and initialize it as a write-all-zero buffer.
[0025] The first processing module is further configured to point the pointer of the write request body to the write all-zero buffer, so as to use the all-zero data in the write all-zero buffer as the write request data of the write request body;
[0026] The storage module is used to store the write request data of the write request body into the disk according to the data starting address.
[0027] In another possible implementation, the first processing module is further configured to:
[0028] When the write request identifier indicates that the write request body contains non-all-zero data, the non-all-zero data in the write request body is stored in the disk according to the data start address.
[0029] In another possible implementation, the first processing module is further configured to:
[0030] When a read request is received from the client, the target data corresponding to the read request is read from the disk;
[0031] Determine whether the target data is all zeros, and obtain the determination result;
[0032] Based on the judgment result, a read response is generated and sent to the client. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
[0033] In another possible implementation, generating a read response based on the judgment result includes:
[0034] If the judgment result is that the target data is all zero data, then the read request identifier is set to indicate that the read request body does not carry data, and the read request body does not carry data.
[0035] If the determination result is that the target data is not all zero data, then the read request identifier is set to indicate that the read request body carries data, and the read request body carries data.
[0036] In another possible implementation, determining whether the target data is all zeros includes:
[0037] The preset data and the target data are ORed to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the read request data;
[0038] If the result of the operation is all zeros, then the result is that the target data is all zeros.
[0039] Thirdly, this application provides a method for storing all-zero data, applied to a distributed storage system, the system including a client and a server, the method applied to the client, the method including:
[0040] When a user-triggered original write request is received, it is determined whether the original write request is used to instruct the writing of all-zero data to the disk, and the identification result is obtained.
[0041] Based on the identification result, a target write request is generated; the target write request includes a write request header and a write request body, the write request header includes a write request identifier, data length, and data start address, and the write request identifier is used to indicate whether the write request body in the write request carries data;
[0042] The target write request is sent to the server.
[0043] In another possible implementation, generating the target write request based on the identification result includes:
[0044] If the identification result indicates that the original write request is used to indicate writing non-all-zero data to the disk, then the write request identifier is set to indicate that the write request body in the write request carries data, and the non-all-zero data is carried in the write request body.
[0045] If the identification result indicates that the original write request is used to indicate that all zero data is written to the disk, then the write request identifier is used to indicate that the write request body in the write request does not carry data.
[0046] In another possible implementation, when a user-triggered initial write request is received, identifying whether the initial write request is intended to instruct the writing of all-zero data to the disk includes:
[0047] Obtain the write request data corresponding to the original write request;
[0048] The preset data is ORed with the write request data to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the write request data.
[0049] If the result of the operation is all zeros, then the identification result is that the original write request is used to indicate writing all zero data to the disk.
[0050] In another possible implementation, the method further includes:
[0051] Receive a read response sent by the server. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
[0052] If the read request identifier indicates that the read request body does not carry data, then request memory space from the client memory that is the same length as the read request data, and initialize it as a read all-zero buffer.
[0053] The pointer of the read request body is set to the read all-zero buffer, so that the all-zero data in the read all-zero buffer is used as the read request data of the read request body;
[0054] In response to the read request, return the read request data from the read request body.
[0055] In another possible implementation, if the read request identifier indicates that the read request body carries non-all-zero data, the method further includes:
[0056] In response to the read request, return the non-all-zero data from the read request body.
[0057] Fourthly, this application provides a storage device for zero-data storage, applied to a distributed storage system, the system including a client and a server, the device applied to the client, the device including,
[0058] The identification module is used to identify whether the original write request triggered by the user is used to instruct the writing of all zero data to the disk when the original write request is obtained, and to obtain the identification result.
[0059] The second processing module is used to generate a target write request based on the identification result; the target write request includes a write request header and a write request body, the write request header includes a write request identifier, data length, and data start address, and the write request identifier is used to indicate whether the write request body in the write request carries data;
[0060] The sending module is used to send the target write request to the server.
[0061] In another possible implementation, the second processing module is specifically used for:
[0062] If the identification result indicates that the original write request is used to indicate writing non-all-zero data to the disk, then the write request identifier is set to indicate that the write request body in the write request carries data, and the non-all-zero data is carried in the write request body.
[0063] If the identification result indicates that the original write request is used to indicate that all zero data is written to the disk, then the write request identifier is used to indicate that the write request body in the write request does not carry data.
[0064] In another possible implementation, the identification module is specifically used for:
[0065] Obtain the write request data corresponding to the original write request;
[0066] The preset data is ORed with the write request data to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the write request data.
[0067] If the result of the operation is all zeros, then the identification result is that the original write request is used to indicate writing all zero data to the disk.
[0068] In another possible implementation, the second processing module is further configured to:
[0069] Receive a read response sent by the server. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
[0070] If the read request identifier indicates that the read request body does not carry data, then request memory space from the client memory that is the same length as the read request data, and initialize it as a read all-zero buffer.
[0071] The pointer of the read request body is set to the read all-zero buffer, so that the all-zero data in the read all-zero buffer is used as the read request data of the read request body;
[0072] In response to the read request, return the read request data from the read request body.
[0073] In another possible implementation, the second processing module is further configured to:
[0074] When the read request identifier indicates that the read request body contains non-all-zero data, the system responds to the read request and returns the non-all-zero data from the read request body.
[0075] Fifthly, the present invention provides a server, comprising:
[0076] One or more processors;
[0077] Memory;
[0078] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being used to: perform a method for storing all-zero data as described in any one of the first aspects.
[0079] Sixthly, the present invention provides a client server, comprising:
[0080] One or more processors;
[0081] Memory;
[0082] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being used to: perform a method for storing all-zero data as described in any of the third aspects.
[0083] This application provides a method, apparatus, and electronic device for storing all-zero data. When a client receives an initial write request for writing all-zero data, it generates a target write request based on the initial write request. The target write request includes a write request header and a write request body. A request identifier in the request header indicates that the write request body does not contain data. The target write request is then transmitted to the server. Upon receiving the target write request, the server allocates memory space in its memory matching the data length and initializes this memory space as a write-all-zero buffer. Finally, the pointer of the write request body is set to point to the write-all-zero buffer, so that the all-zero data in the write-all-zero buffer is used as the write request data in the write request body, and the write request data is written to the corresponding location on the disk.
[0084] Furthermore, when the server receives a read request from the client for reading all-zero data, it generates a read response based on the request. The read response includes a read request header and a read request body. The read request identifier in the header indicates that the read request body should not contain any data, thus ensuring that the read request body is empty. Finally, the read response is transmitted to the client. Upon receiving the read response, the client allocates memory space of the same length as the data and initializes it as a read-all-zero buffer. Finally, the client sets the pointer of the read request body to point to the read-all-zero buffer, using the all-zero data in the buffer as the read request data in the read request body, and responds to the read request by returning the requested data.
[0085] In the above process, for all-zero data that needs to be read or written, an all-zero buffer is generated directly in the corresponding memory, and then the pointer of the corresponding read request body or write request body points to the all-zero buffer, thereby avoiding the transmission of all-zero data. In this way, when encountering a large number of read zero or write zero business, the consumption of network bandwidth can be reduced on the one hand, and the impact on the performance of the storage cluster can be reduced on the other hand. Attached Figure Description
[0086] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0087] Figure 1 A flowchart illustrating a method for storing all-zero data as provided in an embodiment of this application;
[0088] Figure 2 A flowchart illustrating a write request processing method provided in an embodiment of this application;
[0089] Figure 3 A flowchart illustrating a read request processing method provided in an embodiment of this application;
[0090] Figure 4 A schematic diagram of a storage device for zero-data applied to a server, provided as an embodiment of this application;
[0091] Figure 5 A schematic diagram of the structure of a storage device for zero data applied to a client side, provided in an embodiment of this application;
[0092] Figure 6 An electronic device provided in an embodiment of this application.
[0093] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0094] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0095] A distributed storage system distributes user data across multiple storage servers, forming a virtual storage device from these distributed resources. The architecture of a distributed storage system includes client servers and server servers. The client is responsible for sending read / write requests and caching requested data, while the server is responsible for responding to read / write requests, writing or returning requested data.
[0096] In cloud computing applications, virtual storage device users may perform write-zero operations on large, contiguous areas of cloud disks mounted on the virtual storage device due to business needs, in order to maintain the security of the data originally stored in that area. Alternatively, there may be situations where a contiguous area storing all zeros is read. For example, after user A deletes a storage volume, to ensure the security of its original stored data, it will perform write-zero operations on the original storage area. When the virtual storage device is provided to user B, if user B needs to read the data before using it, it will read the corresponding length of all-zero data written by user A.
[0097] In the above scenario, high-concurrency all-zero write operations require the client to transmit a large amount of all-zero data to the server, and all-zero read operations require the server to transmit a large amount of all-zero data to the client. During the transmission process, on the one hand, a large amount of network bandwidth will be consumed, and on the other hand, it will easily affect the service quality of read and write requests of other users on the storage cluster, thereby affecting the performance of the storage cluster.
[0098] This application provides a method, apparatus, and electronic device for storing all-zero data. When encountering a read request indicating the reading of all-zero data or a write request indicating the writing of all-zero data, the device allocates corresponding memory space at the appropriate location and initializes the memory space as an all-zero buffer. Ultimately, it responds to the read request by returning the all-zero data from the all-zero buffer, or responds to the write request by writing the all-zero data from the all-zero buffer to the corresponding disk location. This avoids transmitting the all-zero data, thus preventing the consumption of large amounts of network bandwidth due to high-concurrency all-zero write or read operations, and reducing the impact on the performance of the storage cluster.
[0099] Figure 1 This is a flowchart illustrating a method for storing all-zero data according to an embodiment of this application. The method is applied to a distributed storage system, which includes a client and a server. The method is implemented through cooperation between the server and the client.
[0100] like Figure 1 As shown, the method of this application includes the following steps:
[0101] S101, when the client receives the original write request triggered by the user, it identifies whether the original write request is used to indicate writing all zero data to the disk and obtains the identification result.
[0102] Specifically, the original write request is triggered by the user, indicating that data should be written to the disk. When the client server receives the original write request, it identifies the data content that the original write request indicates to be written, either through software or hardware.
[0103] For example, an algorithm is designed or computed to identify whether the original write request indicates that all zeros should be written to the disk. Specifically, a fixed 4K size of all zeros is sequentially ORed with the 4K of data contained in the original write request, and the original write request is identified as indicating that all zeros should be written to the disk only if all the results of the operations are all zeros.
[0104] S102, the client generates a target write request based on the recognition results.
[0105] The target write request includes a write request header and a write request body. The write request header includes a write request identifier, data length, and data start address. The write request identifier is used to indicate whether the write request body carries data.
[0106] Specifically, the data length is used to indicate the size of the data space written to the disk, and the data start address is used to indicate the write location.
[0107] In this embodiment, the client server generates a corresponding target write request based on the identification result. For the original write request indicating the writing of all-zero data, the write request identifier corresponding to the target write request indicates that the write request body does not carry any data. The method to ensure that the write request body does not carry any data is to set the pointer of the write request body to null.
[0108] S103, the client sends the target write request to the server.
[0109] S104. When the server receives the target write request sent by the client, it obtains the write request header of the target write request to obtain the write request identifier.
[0110] S105, when the write request identifier indicates that the write request body does not carry data, the server requests memory space with the same length as the data in the server memory and initializes the memory space as a write-all-zero buffer.
[0111] Specifically, when the server receives the target write request, and the write request identifier indicates that the write request body does not carry data, the server allocates memory space in the server memory that is the same length as the data, and initializes the memory space as a write zero buffer, that is, the write zero buffer contains all zero data of the same size as the data length.
[0112] S106, the server points the pointer of the write request body to the write zero buffer, so that the zero data in the write zero buffer can be used as the write request data in the write request body.
[0113] S107, the server stores the write request data in the write request body into the disk according to the data starting address.
[0114] Specifically, after obtaining the write zero buffer, the server sets the pointer of the write request body to point to the write zero buffer, so that the all-zero data in the write zero buffer is used as the write request data in the write request body. Then, according to the starting address of the data, the write request data in the write request body is stored in the corresponding location on the disk.
[0115] The method provided in this embodiment enables a client to generate a corresponding target write request when it receives a raw write request instructing the writing of all-zero data to the disk. The target write request data structure includes a write request header and a write request body. Specifically, the write request header includes the data length, the data start address, and a write request identifier. The write request identifier of the target write request indicates that the write request body does not contain any data. The target write request is sent to the server. The server allocates memory space in its memory matching the data length and initializes the memory space as a write-all-zero buffer. Then, the pointer of the write request body is set to point to the write-all-zero buffer, so that the all-zero data in the write-all-zero buffer is used as the write request data in the write request body. Finally, the server stores the write request data into the disk according to the data start address.
[0116] In the above process, when storing all-zero data, the client only transmits a write request body pointing to an empty string to the server, that is, only transmits a target write request containing only the necessary header data, thereby avoiding the transmission of all-zero data, reducing the consumption of network bandwidth and the impact on the performance of the storage cluster.
[0117] Figure 2 This is a flowchart illustrating a write request processing method provided in an embodiment of this application. The following is a description of the method in conjunction with... Figure 2 This embodiment will be described in detail. Specifically, based on the above embodiments, this embodiment describes in detail the method for handling all-zero write requests.
[0118] like Figure 2 As shown, the method in this embodiment may include:
[0119] S201, when the client receives the original write request triggered by the user, it obtains the write request data corresponding to the original write request.
[0120] Specifically, when the client receives the original write request, it first obtains the write request data contained within it.
[0121] S202, the client performs an OR operation between the preset data and the write request data to obtain the result.
[0122] The preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the write request data.
[0123] Specifically, in this embodiment, the preset length can be 4K, and the preset data can include an integer number of zero data of the preset length.
[0124] S203, when the calculation result is all zeros, the client sets the identification result as the original write request to indicate that all zeros should be written to the disk.
[0125] Specifically, if the calculation result is all zeros, it means that the write request data is all zeros. In this case, the identification result is set as the original write request to indicate that all zeros are written to the disk.
[0126] S204, when the client identifies that the original write request is used to indicate that all zero data is to be written to the disk, the write request identifier in the generated target write request is used to indicate that the write request body in the write request does not carry data, and the write request body does not carry data.
[0127] Specifically, when the original write request indicates that all zero data should be written to the disk, the client server sets the write request identifier of the generated target write request to indicate that no data is carried in the write request body, and makes the pointer of the write request body point to null.
[0128] S205, when the calculation result is not all zeros, the client sets the identification result as the original write request to indicate that non-all zero data is written to the disk.
[0129] Specifically, if the calculation result is not all zeros, it means that the write request data is not all zeros. In this case, the identification result is set as the original write request to indicate that non-all zeros are written to the disk.
[0130] S206, when the client identifies that the original write request is used to indicate that non-zero data is written to the disk, the client makes the write request identifier in the generated target write request to indicate that the write request body in the write request carries data, and makes the write request body carry non-zero data.
[0131] Specifically, when the client server receives an original write request indicating that non-zero data should be written to the disk, it sets the write request identifier of the generated target write request to indicate that the write request body carries data, and makes the pointer of the write request body point to the write request data cached in the cache.
[0132] S207, the client sends the target write request to the server.
[0133] S208. When the server receives the target write request sent by the client, it obtains the write request header of the target write request to obtain the write request identifier.
[0134] S209, when the write request identifier indicates that the write request body does not carry data, the server allocates memory space in the server memory that is consistent with the length of the data and initializes the memory space as a write zero buffer; the pointer of the write request body is set to the write zero buffer so that the zero data in the write zero buffer is used as the write request data in the write request body; according to the starting address of the data, the write request data in the write request body is stored in the disk.
[0135] S210, when the write request identifier indicates that the write request body carries data, the server stores the non-all-zero data in the write request body into the disk according to the starting address of the data.
[0136] The method provided in this embodiment, when the client receives an original write request, identifies via software whether the original write request indicates writing all-zero data or non-all-zero data to the disk. Based on the identification result, a corresponding target write request is generated. Specifically, for an original write request indicating writing all-zero data, a target write request without a data body is sent to the server. Only for an original write request indicating writing non-all-zero data is a target write request with a non-all-zero data body sent to the server.
[0137] For a target write request that does not carry a data body, the server allocates memory space in its memory with the same length as the original write request data and initializes this memory space as a write zero buffer. The server then uses the zeros in this write zero buffer as the write request data in the aforementioned write request body. Finally, the server stores this write request data in the corresponding location on disk.
[0138] In the above process, for the original write request used to write all-zero data, the target write request generated by the client does not carry any data in the write request body, so as to achieve zero transmission when storing all-zero data. Only for the original write request used to write non-all-zero data, the target write request generated carries data in the write request body, so as to ultimately achieve the storage of non-zero data.
[0139] Figure 3 This is a flowchart illustrating a read request processing method provided in an embodiment of this application. The following is a summary of the process. Figure 3 This document provides a detailed description of the specific implementation process of the embodiments of this application. Specifically, this embodiment details the method for handling all-zero read requests.
[0140] like Figure 3 As shown, the method in this embodiment may include:
[0141] S301: When the server receives a read request from the client, it reads the target data corresponding to the read request from the disk.
[0142] Specifically, the server reads the target data from the corresponding location on the disk based on the read request.
[0143] S302, the server performs an OR operation between the preset data and the target data to obtain the result.
[0144] The preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the read request data.
[0145] Specifically, in this embodiment, the preset length can be 4K, and the preset data can include an integer number of zero data of the preset length.
[0146] S303: When the calculation result is all zeros, the server sets the judgment result to the target data as all zeros.
[0147] Specifically, if the calculation result is all zeros, it means that the target data is all zeros, and the judgment result is set to the target data being all zeros.
[0148] S304, the server sends the generated read response to the client. The read request identifier in the read response is used to indicate that the read request body does not carry data.
[0149] Specifically, when the target data of a read request is all zero data, the server sets the read request identifier of the generated read response to indicate that the read request body does not carry data, and makes the pointer of the read request body point to null, so as to ensure that the read request body does not carry data.
[0150] S305: When the calculation result is not all zeros, the server sets the judgment result to the target data as non-all zeros.
[0151] Specifically, if the calculation result is not all zeros, it means that the target data is not all zeros. In this case, the server will set the judgment result to indicate that the target data is not all zeros.
[0152] S306, the server will send the read response generated based on the judgment result to the client. The read response includes a read request header and a read request body. The read request header includes a read request identifier. The read request identifier is used to indicate that the read request body carries data, and the read request body carries non-all-zero data.
[0153] Specifically, when the target data of a read request is not all zero data, the server sets the read request identifier of the generated read response to indicate that the read request body carries data, and makes the pointer of the read request body point to the cache area that caches the target data, so that the read request body carries the target data.
[0154] S307, the client receives the read response sent by the server to obtain the read request identifier.
[0155] S308: When the read request identifier indicates that the read request body does not carry data, the client requests memory space with the same length as the read request data from the client memory and initializes the memory space as a read zero buffer; the pointer of the read request body is set to the read zero buffer so that the all-zero data in the read zero buffer is used as the read request data of the read request body; the read request body is responded to and the read request data in the read request body is returned.
[0156] S309: When the read request identifier indicates that the read request body contains non-all-zero data, the client responds to the read request and returns the non-all-zero data from the read request body.
[0157] The method provided in this embodiment involves the server, upon receiving a read request, identifying via software whether the read request indicates the reading of all-zero data from the disk. If so, the server uses a read request identifier in the generated read response to indicate that the read request body does not contain data, and sets the pointer of the read request body to null. This read response is then sent to the client, causing the client to generate a read-all-zero buffer in its memory with a length matching the read request data length. The client also modifies the pointer of the read request body to point to the read-all-zero buffer, ultimately using the all-zero data in the read-all-zero buffer as the read request data in the read request body.
[0158] Otherwise, the generated read response will contain a read request identifier indicating that the read request body carries data, and the pointer of the read request body will point to the corresponding location on the disk, indicating that the read request body carries the target data. This read response will then be sent to the client, allowing the client to return the target data based on it.
[0159] In the above process, for read requests that retrieve all-zero data, the server only sends a read response containing only the header data to the client to achieve zero transmission when reading all-zero data. Only for read requests where the target data is not all-zero data, the server returns a read response containing the target data to the client to ultimately retrieve the non-all-zero data.
[0160] The above embodiments describe a method for storing all-zero data from the perspective of process flow. The following embodiments describe a storage device for all-zero data applied to the server and a storage device for all-zero data applied to the client from the perspective of virtual modules or virtual units. For details, please refer to the following embodiments.
[0161] Figure 4 A schematic diagram of a storage device for zero-data applied to a server, provided in an embodiment of this application, is shown below. Figure 4 As shown, the device includes:
[0162] The acquisition module 41 is used to acquire the write request identifier of the write request body when it receives the write request body corresponding to the write request. The write request body contains the write request data length and the write request starting address. The write request identifier is used to indicate whether the write request body carries data, and the write request identifier is determined by the client based on the write request.
[0163] The first processing module 42 is used to allocate memory space in the server memory that is the same length as the write request data when the write request identifier indicates that the write request body does not carry data, and initialize it as a write-all-zero buffer.
[0164] The first processing module 42 is further configured to point the pointer of the write request body to the write all-zero buffer, so as to use the all-zero data in the write all-zero buffer as the write request data of the write request body;
[0165] Storage module 43 is used to store the write request data of the write request body into the disk according to the data starting address.
[0166] In another possible implementation of this application embodiment, the first processing module 42 is further configured to:
[0167] When the write request identifier indicates that the write request body contains non-all-zero data, the non-all-zero data in the write request body will be stored into the disk according to the starting address of the data.
[0168] In another possible implementation of this application embodiment, the first processing module 42 is further configured to:
[0169] When a read request is received from a client, the target data corresponding to the read request is read from the disk;
[0170] Determine whether the target data is all zeros and obtain the result.
[0171] Based on the judgment result, a read response is generated and sent to the client. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
[0172] Another possible implementation of this application embodiment involves generating a read response based on the judgment result, including:
[0173] If the judgment result is that the target data is all zero data, then set the read request flag to indicate that the read request body does not carry data, and make the read request body not carry data;
[0174] If the result indicates that the target data is not all zeros, then a read request flag is set to indicate that the read request body carries data, and the read request body carries data.
[0175] Another possible implementation of this application embodiment, determining whether the target data is all zero data, includes:
[0176] The preset data and the target data are ORed to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the read request data;
[0177] If the calculation result is all zeros, then the recognition result is that the target data is all zeros.
[0178] Figure 5 A schematic diagram of a storage device for zero-data applied to a client side, provided as an embodiment of this application, is shown below. Figure 5 As shown, the device includes:
[0179] The identification module 51 is used to identify whether the original write request triggered by the user is used to indicate writing all zero data to the disk when the original write request is obtained, and to obtain the identification result.
[0180] The second processing module 52 is used to generate a target write request based on the recognition result. The target write request includes a write request header and a write request body. The write request header includes a write request identifier, data length, and data start address. The write request identifier is used to indicate whether the write request body in the write request carries data.
[0181] The sending module 53 is used to send the target write request to the server.
[0182] In another possible implementation of this application embodiment, the second processing module 52 is specifically used for:
[0183] If the identification result is that the original write request is used to indicate that non-zero data is written to the disk, then the write request identifier is set to indicate that the write request body in the write request carries data, and the write request body carries non-zero data.
[0184] If the identification result indicates that the original write request is used to indicate that all zeros are written to the disk, then the write request identifier is used to indicate that the write request body in the write request does not carry data.
[0185] In another possible implementation of this application embodiment, the identification module 51 is specifically used for:
[0186] Retrieve the write request data corresponding to the original write request;
[0187] Perform an OR operation between the preset data and the write request data to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the write request data;
[0188] If the result of the operation is all zeros, the identification result is that the original write request is used to indicate that all zero data is written to the disk.
[0189] In another possible implementation of this application embodiment, the second processing module 52 is further configured to:
[0190] Receive the read response sent by the server. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
[0191] If the read request identifier indicates that the read request body does not carry data, then request memory space from the client memory that is the same length as the read request data, and initialize it as a read zero buffer.
[0192] Set the pointer of the read request body to the read all-zero buffer so that the all-zero data in the read all-zero buffer can be used as the read request data of the read request body;
[0193] In response to a read request, return the read request data from the read request body.
[0194] In another possible implementation of this application embodiment, the second processing module 52 is further configured to:
[0195] When the read request identifier indicates that the read request body contains non-all-zero data, respond to the read request and return the non-all-zero data from the read request body.
[0196] The embodiments of this application provide a storage device for all-zero data applied to a server and a storage device for all-zero data applied to a client, which are applicable to the above method embodiments and will not be described again here.
[0197] This application provides a client server and a server server, such as... Figure 6 As shown, both the client server and the server include a processor 61 and a memory 62. The processor 61 and the memory 62 are connected, for example, via a bus 63. Optionally, the electronic device may also include a transceiver 64. It should be noted that in practical applications, the transceiver 64 is not limited to one, and the structure of this electronic device does not constitute a limitation on the embodiments of this application.
[0198] In this application, processor 61 includes a central processing unit (CPU) and a graphics processing unit (GPU). Processor 61 may also include a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 61 can also be a combination that implements computational functions, such as a combination of one or more microprocessors 61, a combination of a DSP and a microprocessor 61, etc.
[0199] Bus 63 may include a pathway for transmitting information between the aforementioned components. Bus 63 may be a Peripheral Component Interconnect (PCI) bus 63 or an Extended Industry Standard Architecture (EISA) bus 63, etc. Bus 63 can be divided into address bus 63, data bus 63, control bus 63, etc. For ease of representation, Figure 6 The bus 63 is represented by only one thick line, but this does not mean that there is only one bus 63 or one type of bus 63.
[0200] The memory 62 may be a read-only memory 62 (ROM) or other type of static storage device capable of storing static information and instructions, a random access memory 62 (RAM) or other type of dynamic storage device capable of storing information and instructions, or an electrically erasable programmable read-only memory 62 (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.
[0201] The memory 62 is used to store application code that executes the solution of this application, and its execution is controlled by the processor 61. The processor 61 is used to execute the application code stored in the memory 62 to implement the content shown in the foregoing method embodiments.
[0202] Electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), tablet computers (PADs), portable multimedia players (PMPs), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Servers can also be included. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0203] This application provides a computer-readable storage medium storing a computer program that, when run on a computer, enables the computer to execute the corresponding content in the aforementioned method embodiments.
[0204] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.
[0205] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for storing all-zero data, characterized in that, The method is applied to a distributed storage system, which includes a client and a server. The method is applied to the server and includes: When a target write request is received from a client, the write request header of the target write request is obtained. The target write request is obtained by the client when it receives the original write request triggered by the user, by: identifying whether the original write request is used to indicate writing all zero data to the disk, obtaining the identification result, and generating the target write request based on the identification result; the write request header includes a write request identifier, data length, and data start address; the write request identifier is used to indicate whether the write request body in the target write request carries data, and the way to make the write request body not carry data is to make the pointer of the write request body point to null; If the write request identifier indicates that the write request body does not carry data, then a memory space with the same length as the data is allocated in the server memory, and the memory space is initialized as a write-all-zero buffer. The pointer of the write request body is set to the write all-zero buffer so that the all-zero data in the write all-zero buffer is used as the write request data in the write request body; Based on the data start address, the write request data in the write request body is stored in the disk.
2. The method according to claim 1, characterized in that, If the write request identifier indicates that the write request body carries non-all-zero data, the method further includes: Based on the data start address, the non-zero data in the write request body is stored in the disk.
3. The method according to claim 1, characterized in that, The method further includes: When a read request is received from the client, the target data corresponding to the read request is read from the disk; Determine whether the target data is all zeros, and obtain the determination result; Based on the judgment result, a read response is generated and sent to the client. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data.
4. The method according to claim 3, characterized in that, The step of generating a read response based on the judgment result includes: If the judgment result is that the target data is all zero data, then the read request identifier is set to indicate that the read request body does not carry data, and the read request body does not carry data. If the determination result is that the target data is not all zero data, then the read request identifier is set to indicate that the read request body carries data, and the read request body carries data.
5. The method according to claim 3, characterized in that, The step of determining whether the target data is all zeros includes: The preset data and the target data are ORed to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the target data corresponding to the read request. If the result of the operation is all zeros, then the result is that the target data is all zeros.
6. A method for storing all-zero data, characterized in that, The method is applied to a distributed storage system, which includes a client and a server. The method is applied to the client and includes: When a user-triggered original write request is received, it is determined whether the original write request is used to instruct the writing of all-zero data to the disk, and the identification result is obtained. Based on the identification result, a target write request is generated; the target write request includes a write request header and a write request body. The write request header includes a write request identifier, data length, and data start address. The write request identifier is used to indicate whether the write request body in the write request carries data. The way to make the write request body not carry data is to make the pointer of the write request body point to null. The target write request is sent to the server, so that the server: when the write request header of the target write request indicates that the write request body does not carry data, allocates a memory space in the server memory with the same length as the data, and initializes the memory space as a write zero buffer; points the pointer of the write request body to the write zero buffer, so that the all-zero data in the write zero buffer is used as the write request data in the write request body; and stores the write request data in the write request body into the disk according to the data starting address.
7. The method according to claim 6, characterized in that, The step of generating a target write request based on the identification result includes: If the identification result indicates that the original write request is used to indicate writing non-all-zero data to the disk, then the write request identifier is set to indicate that the write request body in the write request carries data, and the non-all-zero data is carried in the write request body. If the identification result indicates that the original write request is used to indicate that all zero data is written to the disk, then the write request identifier is used to indicate that the write request body in the write request does not carry data.
8. The method according to claim 6, characterized in that, When a user-triggered initial write request is received, identifying whether the initial write request is used to instruct the writing of all-zero data to the disk includes: Obtain the write request data corresponding to the original write request; The preset data is ORed with the write request data to obtain the result; the preset data includes at least one set of zeros of a preset length, and the length of the preset data is the same as the length of the write request data. If the result of the operation is all zeros, then the identification result is that the original write request is used to indicate writing all zero data to the disk.
9. The method according to claim 6, characterized in that, The method further includes: Receive a read response sent by the server. The read response includes a read request header and a read request body. The read request header includes a read request identifier, which is used to indicate whether the read request body carries data. If the read request identifier indicates that the read request body does not carry data, then request memory space from the client memory that is the same length as the read request data, and initialize the memory space as a read all-zero buffer. The pointer of the read request body is set to the read all-zero buffer, so that the all-zero data in the read all-zero buffer is used as the read request data of the read request body; In response to the read request, return the target data corresponding to the read request in the read request body.
10. The method according to claim 9, characterized in that, If the read request identifier indicates that the read request body carries non-all-zero data, the method further includes: In response to the read request, return the non-all-zero data from the read request body.
11. A storage device for all-zero data, characterized in that, This device is applied to a distributed storage system, which includes a client and a server. The device is used on the server side and includes: The acquisition module is used to acquire the write request identifier of the write request body when a write request body corresponding to a write request is received. The target write request is acquired by the client when it receives the original write request triggered by the user, by: identifying whether the original write request is used to indicate writing all zero data to the disk, obtaining the identification result, and generating the target write request based on the identification result; the write request body includes the write request data length and the write request starting address; the write request identifier is used to indicate whether the write request body carries data, and the write request identifier is determined by the client based on the write request. The way to make the write request body not carry data is to make the pointer of the write request body point to null; The first processing module is configured to, when the write request identifier indicates that the write request body does not carry any data, allocate memory space in the server memory that is consistent with the length of the write request data, and initialize it as a write-all-zero buffer. The first processing module is further configured to point the pointer of the write request body to the write all-zero buffer, so as to use the all-zero data in the write all-zero buffer as the write request data of the write request body; The storage module is used to store the write request data of the write request body into the disk according to the data starting address.
12. A storage device for all-zero data, characterized in that, This device is applied to a distributed storage system, which includes a client and a server. The device is used on the client side and includes: The identification module is used to identify whether the original write request triggered by the user is used to instruct the writing of all zero data to the disk when the original write request is obtained, and to obtain the identification result. The second processing module is used to generate a target write request based on the identification result. The target write request includes a write request header and a write request body. The write request header includes a write request identifier, data length, and data start address. The write request identifier is used to indicate whether the write request body in the write request carries data. The way to make the write request body not carry data is to make the pointer of the write request body point to null. The sending module is used to send the target write request to the server, so that the server: when the write request header of the target write request indicates that the write request body does not carry data, allocates a memory space in the server memory with the same length as the data, and initializes the memory space as a write zero buffer; points the pointer of the write request body to the write zero buffer, so that the all-zero data in the write zero buffer is used as the write request data in the write request body; and stores the write request data in the write request body into the disk according to the data starting address.
13. A server-side server, characterized in that, include: One or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being used to: execute according to claims The method for storing all-zero data as described in any one of the above.
14. A client server, characterized in that, include: One or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being used to: execute according to claims The method for storing all-zero data as described in any one of the above.