Data processing method and apparatus
This disclosure related a data processing method and apparatus. The method includes: A processor or a network interface card of a client generates a first copy and a second copy of data. The network interface card of the client writes the first copy into a first address in a memory of a storage device and the second copy into a second address in the memory in a one-time unilateral remote memory access RDMA manner. Alternatively, a network interface card of the storage device respectively writes the first copy and the second copy of the data into the first address and the second address in the memory according to a unilateral RDMA write request sent by the client.
1 . A method, comprising:
generating, by a processor or a network interface card of a client, a first copy and a second copy of data, wherein the processor communicates with the network interface card; and
writing, by the network interface card, the first copy of the data into a first address in a memory of a storage device and the second copy of the data into a second address in the memory in a one-time unilateral remote direct memory access (RDMA) manner, wherein writing, by the network interface card, the first copy of the data into the first address and the second copy of the data into the second address in the memory in the one-time RDMA manner comprises writing, in a single RDMA write operation, the first copy of the data to the first address and the second copy of the data to the second address.
2 . The method according to claim 1 , wherein the memory is a persistent memory.
3 . The method according to claim 1 , wherein the method further comprises:
reading, by the network interface card, the first copy of the data from the first address in the unilateral RDMA manner to obtain a read first copy;
reading, by the network interface card, the second copy of the data from the second address in the unilateral RDMA manner to obtain a read second copy; and
checking, by the processor or the network interface card, the read first copy and the read second copy, and determining valid data from the read first copy and the read second copy.
4 . The method according to claim 3 , wherein checking, by the processor or the network interface card, the read first copy and the read second copy, and determining the valid data from the read first copy and the read second copy comprises:
in response to detecting that the read first copy is the same as the read second copy, determining, by the processor or the network interface card, that the read first copy and the read second copy are the valid data.
5 . The method according to claim 3 , wherein the single RDMA operation comprises sequentially writing the second copy of the data into the second address after writing the first copy of the data into the first address.
6 . The method of claim 1 , wherein the single RDMA write operation comprises:
overwriting, with the first copy of the data, a first copy of second data stored in the first address, wherein a content of the second data is different than a content of the data; and
overwriting, with the second copy of the data, a second copy of the second data stored in the second address.
7 . A client, comprising:
at least one processor;
a network interface card configured to communicate with the at least one processor; and
a first memory, the first memory stores a computer program, that when executed by the at least one processor, causes the client to perform operations comprising:
generating, by the at least one processor or the network interface card, a first copy of data and a second copy of the data; and
writing, by the network interface card, the first copy of the data into a first address in a second memory of a storage device and the second copy of the data into a second address in the second memory in a one-time unilateral remote direct memory access (RDMA) manner, wherein writing, by the network interface card, the first copy of the data into the first address and the second copy of the data into the second address in the second memory in the one-time RDMA manner comprises writing, in a single RDMA write operation, the first copy of the data to the first address and the second copy of the data to the second address.
8 . The client according to claim 7 , wherein the second memory is a persistent memory.
9 . The client according to claim 7 , wherein the operations further comprise:
reading, by the network interface card, the first copy of the data from the first address in the unilateral RDMA manner to obtain a read first copy;
reading, by the network interface card, the second copy from the second address in the unilateral RDMA manner to obtain a read second copy; and
checking, by the processor or the network interface card, the read first copy and the read second copy, and determining valid data from the read first copy and the read second copy.
10 . The client according to claim 9 , wherein the operations of checking, by the processor or the network interface card, the read first copy and the read second copy, and determining valid data from the read first copy and the read second copy comprises:
in response to detecting that the read first copy is the same as the read second copy, determining, by the processor or the network interface card, that the read first copy and the read second copy are the valid data.
11 . The client according to claim 7 , wherein the single RDMA write operation comprises sequentially writing the second copy of the data into the second address after writing the first copy of the data into the first address.
12 . The client according to claim 7 , wherein the single RDMA write operation comprises:
overwriting a first copy of second data stored in the first address with the first copy of the data, wherein a content of the second data is different than a content of the data; and
overwriting, with the second copy of the data, a second copy of the second data stored in the second address.
13 . A storage device, comprising:
at least one processor;
a network interface card; and
a memory, the memory stores a computer program, that when executed by the at least one processor, causes the storage device to perform operations comprising:
receiving, by the network interface card, a single unilateral remote direct memory access (RDMA) write request sent by a client, wherein the single unilateral RDMA write request comprises a first copy of data, a second copy of the data, a first address corresponding to the first copy of the data in the memory of the storage device, and a second address corresponding to the second copy of the data in the memory; and
writing, by the network interface card according to the single unilateral RDMA write request, the first copy of the data into the first address and the second copy of the data into the second address in a single RDMA write operation.
14 . The device according to claim 13 , wherein the memory is a persistent memory.
15 . The device according to claim 13 , wherein in response to determining that an interrupt occurs during writing the first copy of the data into the first address and the second copy of the data into the second address, the operations further comprise:
reading, by the network interface card or the at least one processor, the first copy of the data from the first address to obtain a read first copy;
reading, by the network interface card or the at least one processor, the second copy of the data from the second address to obtain a read second copy; and
checking, by the network interface card or the at least one processor, the read first copy and the read second copy, and in response to detecting that the read first copy is inconsistent with the read second copy, performing a data overwrite operation on first data stored in the first address or second data stored in the second address.
16 . The device according to claim 15 , wherein the read first copy comprises the first data and first check code, the read second copy comprises the second data and second check code, and the read first copy is inconsistent with the read second copy when the first data is different from the second data.
17 . The device according to claim 15 , wherein the read first copy comprises the first data and first check code, the read second copy comprises the second data and second check code, and the read first copy is inconsistent with the read second copy when the first check code is different from the second check code.
18 . The device according to claim 15 , wherein the operations of performing the data overwrite operation on the first data stored in the first address or the second data stored in the second address comprises:
in response to checking of the first data based on a first check code of the read first copy succeeding, overwriting the second data stored in the second address with the first data and the first check code.
19 . The device according to claim 18 , wherein the operations of performing the data overwrite operation on data stored in the first address or data stored in the second address comprises:
in response to checking of the first data based on the first check code failing and checking of the second data based on a second check code of the read second copy succeeding, overwriting the first data stored in the first address with the second data and the second check code.
20 . The device according to claim 13 , wherein the operations of writing, by the network interface card, the first copy of the data into the first address and the second copy of the data into the second address according to the unilateral RDMA write request comprises:
writing the second copy of the data into the second address after writing the first copy of the data into the first address.