Data storage method, device and server

The data storage method addresses data loss risks by writing data to both cache and storage medium in a server with non-volatile memory, ensuring persistence and improving server performance by offloading storage management, thus enhancing data security and efficiency.

EP3839749B1Active Publication Date: 2024-09-11HUAWEI TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
EP2019860935
Authority / Receiving Office
EP · EP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2018-09-13
Filing Date
2019-07-01
Publication Date
2024-09-11
Estimated Expiration
2039-07-01

AI Technical Summary

Technical Problem

Data stored in servers with non-volatile memory is at risk of loss due to faulty servers, and existing methods lack effective mechanisms for secure and efficient data storage, particularly in scenarios where network resources and computing resources are limited.

Method used

A data storage method where a first server with non-volatile memory receives write instructions from a second server, stores data in both its cache and storage medium, and actively flushes data to the storage medium upon detection of a read instruction, ensuring data persistence and reducing overheads by minimizing unnecessary operations.

Benefits of technology

This approach ensures data integrity by writing data to both cache and storage medium, preventing loss in case of server faults, and improves performance by reducing the computational load on the second server, allowing it to focus on providing network and computing resources without managing storage operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure IMGF0001
    Figure IMGF0001
  • Figure IMGF0002
    Figure IMGF0002
  • Figure IMGF0003
    Figure IMGF0003
Patent Text Reader

Abstract

This disclosure discloses a data storage method and apparatus, and a server. The method includes: receiving, by a first server, a write instruction sent by a second server, storing target data in a cache of a controller, detecting a read instruction for the target data, and storing the target data in a storage medium of a non-volatile memory based on the read instruction. In other words, when the second server needs to write the target data to the first server, the target data is not only written to the cache of the first server, but also written to the storage medium of the first server. This can ensure that the data in the cache is written to the storage medium promptly.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] This disclosure relates to the field of storage technologies, and in particular, to a data storage method and apparatus, and a server.BACKGROUND

[0002] A persistent memory over fabric (persistent memory over fabric, PMoF) service is to transfer, to another server, data that originally needs to be processed in a memory of a service server. This can resolve a problem that a capacity of the memory of the service server is limited. In addition, because a non-volatile memory has advantages of both a high read and write speed and low costs of non-volatile storage, a server deployed with the non-volatile memory may be used to provide the PMoF service for the service server. When the server deployed with the non-volatile memory is used to provide the PMoF service for the service server, a current focus is how to securely and effectively store data in the server deployed with the non-volatile memory.

[0003] The document US 2015 / 261674 A1 shows a computer system using page cache write logging at block-based storage. Especially, the document shows an implementation of page cache write logging.SUMMARY

[0004] The invention is defined in the independent claims. Advantageous features are defined in the dependent claims.

[0005] This disclosure provides a data storage method and apparatus, and a server, to resolve a problem that data is likely lost after the data is stored in a server deployed with a non-volatile memory, to improve security and effectiveness of data storage. The technical solutions are as follows.

[0006] According to a first aspect, a data storage method is provided, and the method includes: receiving, by a first server, a write instruction sent by a second server, where the first server includes a non-volatile memory, the non-volatile memory includes a controller and a storage medium, the first server communicates with the second server through a first network, and the write instruction includes target data; storing, by the first server, the target data in a cache of the controller; detecting, by the first server, a read instruction for target data, where the read instruction is used to instruct the first server to store the target data in the storage medium of the non-volatile memory; and storing, by the first server, the target data in the storage medium of the non-volatile memory according to the read instruction.

[0007] In this disclosure, after the first server stores the target data in the cache of the controller, the first server detects the read instruction for the target data, and stores the target data in the storage medium of the non-volatile memory based on the read instruction. In other words, in this disclosure, when the second server needs to write the target data to the first server, the target data is not only written to the cache of the first server, but also written to the storage medium of the first server. This can ensure that the data in the cache is written to the storage medium promptly. Therefore, a case in which the second server becomes abnormal because the first server is faulty is avoided, and security and effectiveness of a process of storing the data to the first server are improved. In addition, according to the data storage method provided in this disclosure, because the first server provides a data storage service for the second server, only network resources and computing resources may be deployed in the second server, so that performance of the second server is improved.

[0008] In a first claimed alternative, the first server further includes a first network interface card, and the detecting, by the first server, a read instruction for target data includes: when the first network interface card determines that all the target data is written to the cache, generating, by the first network interface card, the read instruction for the target data; and detecting, by the controller, the read instruction.

[0009] In a possible implementation, when the first network interface card in the first server determines that all the target data is written to the cache, the first network interface card actively triggers the read instruction for the target data, to instruct to flush the target data to the storage medium. In this way, the second server does not need to trigger the read instruction, and overheads of the second server are reduced.

[0010] Optionally, after the storing, by the first server, the target data in the storage medium of the non-volatile memory according to the read instruction, the method further includes: sending, by the first server, a first acknowledgment message for the write instruction to the second server.

[0011] For the foregoing possible implementation, because the first server immediately flushes the target data to the storage medium after storing the target data in the cache, the first server needs to send the first acknowledgment message for the write instruction to the second server after flushing the target data to the storage medium. In this way, the second server may determine, based on the first acknowledgment message, that the target data has been flushed to the storage medium, so that the second server learns a storage status of the target data promptly.

[0012] In a second claimed alternative, the detecting, by the first server, a read instruction for target data includes: when the first server determines that all the target data is written to the cache, sending, by the first server, a second acknowledgment message for the write instruction to the second server, to enable the second server to send the read instruction for the target data to the first server when receiving the second acknowledgment message; and receiving, by the first server, the read instruction for the target data, to enable the first server to detect the read instruction.

[0013] In another possible implementation, when the first server determines that all the target data is written to the cache, the second server actively triggers the read instruction for the target data, to instruct the first server to flush the target data to the storage medium. In this way, the target data can be flushed to the storage medium promptly without a need to modify a program in the first server, so that the need to modify the program in the first server is avoided.

[0014] Optionally, the method further includes: returning, by the first server, the target data to the second server.

[0015] For the foregoing possible implementations, because the read instruction is triggered by the second server, the first server further needs to return the target data to the second server after flushing the target data to the storage medium, to respond to the read instruction sent by the second server promptly.

[0016] Optionally, before the detecting, by the first server, a read instruction for target data, the method further includes: setting, by the first server, a storage identifier of the target data in the cache to a first identifier, where the first identifier is used to indicate that the target data has not been written to the storage medium; and after the storing, by the first server, the target data in the storage medium of the non-volatile memory according to the read instruction, the method further includes: updating, by the first server, the storage identifier of the target data in the cache to a second identifier, where the second identifier is used to indicate that the target data has been written to the storage medium.

[0017] In this disclosure, the read instruction for the target data is used to trigger the first server to flush the target data to the storage medium. To prevent the first server from flushing corresponding data to the storage medium each time the first server receives a read instruction, the storage identifier is set for the data in the cache, to indicate whether the corresponding data is flushed to the storage medium. This can reduce unnecessary overheads generated by the controller.

[0018] Optionally, the read instruction for the target data includes a storage address of the target data in the cache; and the storing, by the first server, the target data in the storage medium of the non-volatile memory according to the read instruction includes: obtaining, by the first server, the target data based on the storage address of the target data in the cache, and storing the obtained target data in the storage medium of the non-volatile memory. When writing the target data to the cache, the first server has learned the storage address of the target data. Therefore, when reading the target data, the first server may directly obtain the target data based on the storage address. This avoids that the first server needs to obtain the storage address of the target data again, thereby reducing the overheads of the controller.

[0019] Optionally, the first network includes a remote direct memory access (remote direct memory access, RDMA) network, and the non-volatile memory is a storage class memory (storage class memory, SCM).

[0020] In a possible implementation, the first network may be the RDMA network. Because the RDMA network is a high-speed network, when processing data, a processor of the second server may directly store the data in the first server. This reduces overheads of the processor of the second server, and improves the overall performance of the second server.

[0021] According to a second aspect, a data storage apparatus is provided, and the data storage apparatus has a function of implementing behavior of the data write method in the first aspect. The data storage apparatus includes at least one module, and the at least one module may be integrated into the foregoing first server, to implement the data storage method provided in the first aspect.

[0022] According to a third aspect, this disclosure provides a server, where the server includes a processor, a memory, a communications interface, and a bus. The processor, the memory, and the communications interface are connected to and communicate with each other through the bus. The memory is configured to store a computer-executable instruction. When the server runs, the processor executes the computer-executable instruction in the memory to perform, by using hardware resources in the server, the operation step of the method according to any one of the first aspect or the possible implementations of the first aspect.

[0023] According to a fourth aspect, a data storage method is provided, and the method includes: receiving, by a first network interface card, a write instruction sent by a second network interface card, where the first network interface card is a network interface card in a first server, the second network interface card is a network interface card in a second server, the first server includes a non-volatile memory, the non-volatile memory includes a controller and a storage medium, the first network interface card communicates with the second network interface card through a first network, and the write instruction includes target data; storing, by the first network interface card, the target data in a cache of the controller; detecting, by the first network interface card, a read instruction for the target data, where the read instruction is used to instruct the first network interface card to store the target data in the storage medium of the non-volatile memory; and storing, by the first network interface card, the target data in the storage medium of the non-volatile memory according to the read instruction.

[0024] In this disclosure, after the first network interface card stores the target data in the cache of the controller, the first network interface card detects the read instruction for the target data, and stores the target data in the storage medium of the non-volatile memory according to the read instruction. In other words, in this disclosure, when the second server needs to write the target data to the first server, the target data is not only written to the cache of the first server, but also written to the storage medium of the first server. This can ensure that the data in the cache is written to the storage medium promptly. Therefore, a case in which the second server becomes abnormal because the first server is faulty is avoided. In addition, according to the data storage method provided in this disclosure, because the first server provides a data storage service for the second server, only network resources and computing resources may be deployed in the second server, so that performance of the second server is improved.

[0025] Optionally, the detecting, by the first network interface card, a read instruction for the target data includes: when the first network interface card determines that all the target data is written to the cache, generating, by the first network interface card, the read instruction for the target data; and detecting, by the controller, the read instruction.

[0026] In a possible implementation, when the first network interface card in the first server determines that all the target data is written to the cache, the first network interface card actively triggers the read instruction for the target data, to instruct to flush the target data to the storage medium. In this way, the second server does not need to trigger the read instruction, and overheads of a processor of the second server are reduced.

[0027] Optionally, after the storing, by the first network interface card, the target data in the storage medium of the non-volatile memory according to the read instruction, the method further includes: sending, by the first network interface card, a first acknowledgment message for the write instruction to the second network interface card.

[0028] For the foregoing possible implementation, because the first network interface card immediately flushes the target data to the storage medium after storing the target data in the cache, the first network interface card needs to send the first acknowledgment message for the write instruction to the second server after flushing the target data to the storage medium. In this way, the second server may determine, based on the first acknowledgment message, that the target data has been flushed to the storage medium, so that the second server learns a storage status of the target data promptly.

[0029] Optionally, the detecting, by the first network interface card, a read instruction for the target data includes: when the first network interface card determines that all the target data is written to the cache, sending, by the first network interface card, a second acknowledgment message for the write instruction to the second network interface card, to enable the second network interface card to send the second acknowledgment message to the processor of the second server, to enable the processor of the second server to send the read instruction for the target data to the first network interface card through the second network interface card when receiving the second acknowledgment message; and receiving, by the first network interface card, the read instruction for the target data, to enable the first network interface card to detect the read instruction.

[0030] In another possible implementation, when the first network interface card in the first server determines that all the target data is written to the cache, the second server actively triggers the read instruction for the target data, to instruct the first server to flush the target data to the storage medium. In this way, the target data can be flushed to the storage medium promptly without a need to modify a program in the first server.

[0031] Optionally, the method further includes: returning, by the first network interface card, the target data to the second network interface card.

[0032] For the foregoing possible implementations, because the read instruction is triggered by the second server, the first server further needs to return the target data to the second server after flushing the target data to the storage medium, to respond to the read instruction sent by the second server promptly.

[0033] Optionally, before the detecting, by the first network interface card, a read instruction for the target data, the method further includes: setting, by the controller, a storage identifier of the target data in the cache to a first identifier, where the first identifier is used to indicate that the target data has not been written to the storage medium; and after the storing, by the first network interface card, the target data in the storage medium of the non-volatile memory based on the read instruction, the method further includes: updating, by the controller, the storage identifier of the target data in the cache to a second identifier, where the second identifier is used to indicate that the target data has been written to the storage medium.

[0034] In this disclosure, the read instruction for the target data is used to trigger the first server to flush the target data to the storage medium. To prevent the first server from flushing corresponding data to the storage medium each time the first server receives a read instruction, the storage identifier is set for the data in the cache, to indicate whether the corresponding data is flushed to the storage medium. This can reduce unnecessary overheads generated by the controller.

[0035] Optionally, the read instruction for the target data includes a storage address of the target data in the cache; and the storing, by the first network interface card, the target data in the storage medium of the non-volatile memory based on the read instruction includes: sending, by the first network interface card, the read instruction to the controller, to enable the controller to obtain the target data based on the storage address of the target data in the cache, and store the obtained target data in the storage medium of the non-volatile memory. When writing the target data to the cache, the first server has learned the storage address of the target data. Therefore, when reading the target data, the first server may directly obtain the target data based on the storage address. This avoids that the first server needs to obtain the storage address of the target data again, thereby reducing the overheads of the controller.

[0036] According to a fifth aspect, a data storage system is provided, and the data storage system includes a first server and at least one second server, where each second server is connected to the first server through a first network; the first server provides a data storage service for each second server through the data storage method in the first aspect; and each second server is configured to provide computing resources and network resources for a service application.

[0037] According to the data storage system provided in this disclosure, each second server may provide a computing service and the network resources only for the service application, and the data storage service of the second server is provided by the first server. In this way, even if the second server is faulty, the first server can still ensure that data is not lost, to ensure that the second server can run normally after fault rectification. Therefore, data reliability is improved.

[0038] After the second server sends a write instruction for target data to the first server, and when the second server receives a second determining message that is sent by the first server and that is for the write instruction, the second server sends a read instruction for the target data to the first server, to enable the first server to store the target data in a storage medium of a non-volatile memory based on the read instruction.

[0039] In a possible implementation, when the first server determines that all the target data is written to a cache, the second server actively triggers the read instruction for the target data, to instruct the first server to flush the target data to the storage medium. In this way, the target data can be flushed to the storage medium promptly without a need to modify a program in the first server. This improves flexibility of the data storage method provided in this disclosure.

[0040] According to a sixth aspect, a computer-readable storage medium is provided, the computer-readable storage medium stores an instruction, and when the instruction is run on a computer, the computer performs the foregoing data storage method.

[0041] According to a seventh aspect, a computer program product including an instruction is provided, and when the computer program product is run on a computer, the computer is enabled to perform the foregoing data storage method.BRIEF DESCRIPTION OF DRAWINGS

[0042] FIG 1 is a schematic diagram of a data storage system according to an embodiment of this disclosure; FIG 2 is a schematic diagram of another data storage system according to an embodiment of this disclosure; FIG. 3 is a schematic structural diagram of a server according to an embodiment of this disclosure; FIG 4 is a flowchart of a data storage method according to an embodiment of this disclosure; and FIG 5 is a block diagram of a data storage apparatus according to an embodiment of this disclosure. DESCRIPTION OF EMBODIMENTS

[0043] The following further describes the embodiments of this disclosure in detail with reference to the accompanying drawings.

[0044] FIG 1 is a schematic diagram of a data storage system according to an embodiment of this disclosure. As shown in FIG 1, the system 100 includes a first server 101 and a second server 102. The first server 101 is connected to the second server 102 through a first network for communication.

[0045] As shown in FIG. 1, the first server 101 includes a non-volatile memory (non-volatile memory, PM) 1011 and a first network interface card (network interface card, NIC) 1012. The first network interface card 1012 is connected to the non-volatile memory 1011 for communication. The non-volatile memory includes a controller (PM controller) 10111 and a storage medium 10112. The controller 10111 is connected to the storage medium 10112 for communication, and the controller 10111 further includes a cache 101111. The second server 102 includes a service module 1021 and a second network interface card 1022. The service module 1021 is connected to the second network interface card 1022 for communication. The first network interface card 1012 is connected to the second network interface card 1022 through the first network for communication.

[0046] When the service module 1021 in the second server initiates a write instruction for a piece of data, the service module 1021 sends the write instruction to the first network interface card 1012 of the first server 101 through the second network interface card 1022. The first network interface card 1012 writes the data to the storage medium 10112 in the non-volatile memory 1011 according to a data storage method provided in the embodiments of this disclosure. An implementation in which the first network interface card 1012 writes the data to the storage medium 10112 in the non-volatile memory 1011 according to the data storage method provided in the embodiments of this disclosure is described in detail in the following embodiment.

[0047] In addition, the first network may be an RDMA network. The RDMA network includes a network based on an RDMA protocol and a network based on an RDMA extension protocol. For example, the RDMA network includes a network such as an internet wide-area remote direct memory access protocol (Internet wide-area RDMA protocol, iWARP) network, a remote direct memory access over converged Ethernet (remote direct memory access over converged Ethernet, RoCE) network, or an InfiniBand (InfiniBand, IB) network. This is not specifically limited in the embodiments of this disclosure. In addition, because the first network may be the RDMA network, the first network interface card and the second network interface card may also be collectively referred to as an RDMA network interface card (RNIC). Names of the first network interface card and the second network interface card are not limited in the embodiments of this disclosure. In addition, the RDMA network is a high-speed transmission network. In the embodiments of this disclosure, the first network may alternatively be another type of high-speed transmission network. Examples are not described one by one herein.

[0048] The non-volatile memory in the first server shown in FIG 1 may be an SCM, or may be another non-volatile memory. The first server deployed with the SCM is configured to provide a data storage function for the second server. The SCM includes an AEP or Optane product of Intel.

[0049] In addition, the second server may also be referred to as a service server, and the service server is configured to provide computing resources and network resources for a service application. The computing resources include processors, for example, a central processing unit (central processing unit, CPU) and a system-on-a-chip (system-on-a-chip, SoC). The network resources include a network interface card, for example, the RNIC.

[0050] It should be noted that the system 100 shown in FIG 1 includes only one second server. Optionally, an embodiment of this disclosure further provides a schematic diagram of a data storage system shown in FIG 2. As shown in FIG 2, in this case, the system 100 may include a plurality of second servers, and each second server communicates with the first server through a first network. For a specific connection manner between each second server and the first server, refer to the connection manner shown in FIG 1. Details are not described herein.

[0051] In a possible embodiment, based on the data storage systems shown in FIG. 1 and FIG. 2, an embodiment of this disclosure further provides another data storage system. The data storage system includes a plurality of first servers and a plurality of second servers. A difference between the data storage system and the data storage system shown in FIG. 2 is that, in the data storage system, some second servers communicate with at least one first server through a first network, and the other second servers communicate with other first servers through the first network. In other words, the second servers in the data storage system are divided into two or more sets, and the second server sets use different first server to store data.

[0052] FIG. 3 is a schematic structural diagram of a server according to an embodiment of this disclosure. The first server in FIG. 1 or FIG. 2 may be implemented through the server shown in FIG. 3. Referring to FIG. 3, the server includes at least one processor 301, a bus 302, a non-volatile memory 303, and a network interface card 304. The network interface card 304 is the first network interface card 1012 in the system shown in FIG 1.

[0053] The processor 301 may be a general-purpose central processing unit (Central Processing Unit, CPU), a microprocessor, an application-specific integrated circuit (application-specific integrated circuit, ASIC), or one or more integrated circuits configured to control program execution in the solutions of this disclosure. Each processor may be a single-core (single-CPU) processor, or may be a multi-core (multi-CPU) processor. The processor herein may be one or more devices, circuits, and / or processing cores configured to process data (for example, a computer program instruction).

[0054] The bus 302 may include a path for transmitting information between the processor 301, the non-volatile memory 303, and the network interface card 304. The bus 302 may further include a power bus, a control bus, a status signal bus, and the like, in addition to a data bus. However, for clear description, various types of buses in the figure are marked as the bus 302.

[0055] As shown in FIG 3, the non-volatile memory 303 includes a controller 3031 and a storage medium 3032. The controller 3031 is configured to manage data stored in the storage medium 3032. The controller 3031 is connected to the storage medium 3032 through an internal bus. The internal bus may be a bus based on a storage protocol. For example, the storage protocol may be a data transmission protocol such as RS-232 (a data transmission protocol formulated by the Electronic Industry Association). This is not specifically limited herein.

[0056] In addition, as shown in FIG 3, the controller 3031 further includes a cache 30311. When the controller 3031 receives to-be-stored data, the controller 3031 first stores the data in the cache 30311, and then stores the data from the cache 30311 to the storage medium 3032 based on a related instruction. An implementation in which that the controller 3031 stores the data from the cache 30311 to the storage medium 3032 based on the related instruction is described in detail in the following embodiment, and is not first described in detail herein.

[0057] In addition, the storage medium 3032 is a non-volatile storage medium, configured to store massive data. For example, the storage medium 30311 includes mediums such as a phase change memory, a ferroelectric memory, and a magnetic memory. This is not specifically limited in this embodiment of this disclosure. Currently, the phase change memory includes products such as a 3D XPOINT (a product of Intel), and the ferroelectric memory includes products such as a ferroelectric random access memory and a ferroelectric crystal.

[0058] When the non-volatile memory is an SCM, the SCM may be embedded in a slot of a first server like a dynamic random access memory. Compared with the dynamic random access memory, the SCM can still continuously store data in a power-off state, and has a power-off storage feature. The SCM can provide faster read and write speeds than a flash memory, and is cheaper than the dynamic random access memory in terms of costs. Therefore, in system architectures of some computing devices, the SCM may be used as a memory. In addition, a plurality of computing devices in which the SCM is used as the memory may be connected in an interconnection manner to form an SCM resource pool, to expand a capacity of the SCM. Therefore, data redundancy backup is implemented.

[0059] The network interface card 304 is configured to communicate with the second server. In other words, in this embodiment of this disclosure, the first server is connected to the second server through the network interface card 304, to implement the data storage method provided in the embodiments of this disclosure.

[0060] In addition, as shown in FIG 3, the server may further include a communications interface 305, configured to communicate with another device or a communications network, for example, an Ethernet, a radio access network (RAN), a wireless local area network (Wireless Local Area Networks, WLAN), and the like.

[0061] The foregoing server may be a general-purpose server or a special-purpose server. In a specific implementation, the server may be a device such as various storage servers. A type of the server is not limited in the embodiments of this disclosure.

[0062] The following describes the data storage method provided in the embodiments of this disclosure in detail.

[0063] FIG 4 is a flowchart of a data storage method according to an embodiment of this disclosure. As shown in FIG. 4, the method includes the following steps.

[0064] Step 401: A first server receives a write instruction sent by a second server, where the first server includes a non-volatile memory, the non-volatile memory includes a controller and a storage medium, the first server communicates with the second server through a first network, and the write instruction includes target data.

[0065] In this embodiment of this disclosure, step 401 may be implemented in either of the following two manners.

[0066] Manner 1: The second server first obtains, from the first server, an identifier of an address used to store the target data, and then sends the write instruction to the first server based on the obtained identifier of the address.

[0067] Specifically, when a service module in the second server generates a piece of data in a service processing process, the service module needs to store the data. For ease of subsequent description, the data that needs to be stored is referred to as the target data. An implementation in which the service module stores the target data may be as follows. The service module determines a size of the target data, and sends an address obtaining request to a first network interface card through a second network interface card, where the address obtaining request carries the size of the target data. When the first network interface card receives the address obtaining request, the first network interface card sends the address obtaining request to a processor of the first server. The processor allocates an address to the target data based on the size of the target data and an available address in a cache, to obtain a first address, and the processor returns address obtaining request response information to the second network interface card through the first network interface card. The address obtaining request response information carries an identifier of the first address. When receiving the address obtaining request response information, the second network interface card sends the address obtaining request response information to the service module. The service module determines a storage location of the target data in the first server based on the received address obtaining request response information, and then sends the write instruction to the first network interface card through the second network interface card. The write instruction carries the identifier of the first address and the target data.

[0068] In other words, in the manner 1, when the second server needs to store the target data to the first server, the second server needs to first obtain, based on the processor of the first server, the first address used to store the target data, to ensure that the first data can be successfully stored in the first server.

[0069] Manner 2: The second server directly sends the write instruction including the target data to the first server, to enable the first server to determine, after receiving the write instruction, an identifier of an address used to store the target data.

[0070] Specifically, when a service module in the second server needs to store the target data in the first server, the service module directly sends the write instruction for the target data to the first network interface card through the second network interface card, where the write instruction carries the target data. When receiving the write instruction, the first network interface card may write the target data to a cache through the following step 402.

[0071] In other words, in the manner 2, when the second server needs to store the target data to the first server, the second server does not first obtain a first address used to store the target data, but directly sends the target data to the first server, so that the first server allocates a storage address to the target data in a process of storing the target data. This improves storage efficiency of the target data.

[0072] The foregoing two manners are merely two possible implementations of step 401, and do not constitute a limitation on this embodiment of this disclosure. In an actual disclosure, the first server may receive, in another manner, the write instruction sent by the second server. Examples are not described one by one herein.

[0073] The first address is a storage address allocated by the processor of the first server to the target data, and the storage address is a storage address of the target data in the cache. In addition, it can be learned from FIG 1 that the first network interface card may communicate with the second network interface card through an RDMA protocol-based network connection. Correspondingly, the write instruction may be an RDMA network-based write instruction (RDMA write). Certainly, if the first network interface card is connected to the second network interface card through another network, correspondingly, the write instruction is also a write instruction in another network format. This is not specifically limited in the embodiments of this disclosure.

[0074] Step 402: The first server stores the target data in a cache of the controller.

[0075] For the manner 1 in step 401, because in this case, the write instruction already carries the identifier of the first address used to store the target data, the first server may directly store the target data in the cache of the controller based on the identifier of the first address. Specifically, when receiving the write instruction, the first network interface card obtains the target data and the identifier of the first address that are carried in the write instruction, and writes the target data to the cache of the controller based on the identifier of the first address through the controller.

[0076] For the manner 2 in step 401, because in this case, the write instruction carries only the target data, the first server first needs to determine the storage address used to store the target data, and then stores the target data in the cache of the controller based on the determined storage address. Specifically, when receiving the write instruction, the first network interface card obtains the target data carried in the write instruction, determines a size of the target data, and sends an address obtaining request to the processor, where the address obtaining request carries the size of the target data. When the processor receives the address obtaining request, the processor allocates the address to the target data based on the size of the target data and an available address in the cache, to obtain the first address, and returns an identifier of the first address to the first network interface card. When receiving the identifier of the first address, the first network interface card writes the target data to the cache based on the identifier of the first address through the controller.

[0077] In the foregoing two implementations, an implementation in which the first network interface card writes the target data to the cache through the controller based on the identifier of the first address may be as follows. The first network interface card divides the target data by byte to obtain a plurality of pieces of metadata, and sequentially sends each piece of metadata to the controller based on the identifier of the first address. The controller stores each piece of received metadata in the cache based on the identifier of the first address.

[0078] Similarly, the foregoing two implementations are merely two possible implementations of step 402, and do not constitute a limitation on this embodiment of this disclosure. In an actual application, the first server may further store the target data in the cache of the controller in another manner. Examples are not described one by one herein.

[0079] When the first server stores the target data in the cache of the controller, the target data needs to be stored from the cache to the storage medium of the non-volatile memory promptly, to avoid a loss of the target data caused by a power failure of the first server at this time point. In other words, the target data needs to be flushed from the cache to the storage medium promptly. Specifically, the target data may be flushed from the cache to the storage medium promptly through the following step 403 to step 404. The storage medium mentioned in the embodiments of this disclosure is the storage medium in FIG 1 or FIG 3. In other words, the storage medium in the embodiments of this disclosure is the storage medium in the non-volatile memory deployed in the first server.

[0080] Step 403: The first server detects a read instruction for the target data, where the read instruction is used to instruct the first server to store the target data in the storage medium of the non-volatile memory.

[0081] After storing the target data in the cache of the controller, the first server may trigger the read instruction for the target data, so that the target data is stored from the cache to the storage medium of the non-volatile memory promptly. The read instruction may be triggered by the first server, or may be triggered by the second server. Therefore, step 403 specifically has the following two possible implementations.

[0082] Manner 1 is applied to a scenario in which the read instruction is triggered by the first server.

[0083] In this case, step 403 may be specifically as follows. When the first server determines that the target data is written to the cache, the first network interface card included in the first server generates the read instruction for the target data, to enable the first server to detect the read instruction.

[0084] It can be learned from step 402 that, that the first server stores the target data in a cache of the controller is essentially that the first network interface card sequentially writes the target data to the cache of the controller by byte through the controller. Therefore, when the first network interface card writes all bytes of the target data to the cache, it may be determined that the target data is written to the cache. In this case, the first network interface card actively generates the read instruction, and the controller detects the read instruction.

[0085] The read instruction carries the storage address of the target data in the cache, so that the target data is subsequently read based on the storage address of the target data in the cache. It should be noted that, before the first network interface card writes the target data to the cache, the first network interface card has learned the storage address of the target data. Therefore, in the manner 1, the first network interface card may directly generate the read instruction based on the storage address of the target data in the cache.

[0086] In the scenario described in the manner 1 in step 403, a program in the second server is appropriately modified, so that after the second server triggers the write instruction for the target data, the first server may directly write the target data to both the cache and the storage medium through step 403 and the following step 404. In this way, the target data is flushed to the storage medium promptly. In this manner of storing the target data in the storage medium, resource overheads can be reduced, and network communication is simplified.

[0087] Manner 2 is applied to a scenario in which the read instruction is triggered by the second server.

[0088] When the first server determines that the target data is written to the cache, the first server sends a second acknowledgment message for the write instruction to the second server, to enable the second server to send the read instruction for the target data to the first server when receiving the second acknowledgment message. The first server receives the read instruction for the target data, to enable the first server to detect the read instruction.

[0089] Similarly, it can be learned from step 402 that when the first network interface card writes all bytes of the target data to the cache, it may be determined that the target data is written to the cache. In this case, the first network interface card sends the second acknowledgment message for the write instruction to the service module through the second network interface card. When receiving the second acknowledgment message, the service module may generate the read instruction for the target data, and send the read instruction to the first network interface card through the second network interface card. When the first network interface card receives the read instruction, it is equivalent to that the first server detects the read instruction for the target data.

[0090] It can be learned from FIG 1 that the first network interface card may communicate with the second network interface card through an RDMA network connection. Therefore, in the manner 2 in step 403, the write instruction may be an RDMA network-based read instruction (RDMA read), in other words, the RDMA read is a read instruction transmitted over an RDMA network. Certainly, if the first network interface card is connected to the second network interface card through another network, correspondingly, the read instruction is also a read instruction in another network format. This is not specifically limited in the embodiments of this disclosure.

[0091] In the scenario described in the manner 2 in step 403, after the second server triggers the write instruction for the target data, the first server first stores the target data in the cache, and the second server triggers the read instruction, so that the target data is flushed to the storage medium promptly through the following step 404. In this manner of flushing the target data to the storage medium, a program of the first server does not need to be modified. The target data can be stored in the storage medium promptly through a conventional read after write (read after write, RAW) manner. The conventional RAW manner is a manner in which after sending a write instruction for a piece of data, the second server immediately sends a read instruction for the same data if receiving a second acknowledgment message for the write instruction. However, a disadvantage of the manner 2 is that both the read instruction and the write instruction are triggered by the service module of the second server, and this increases CPU overheads of the second server.

[0092] In addition, the read instruction carries the storage address of the target data in the cache, so that the first server subsequently reads the target data based on the storage address of the target data in the cache. It can be learned from step 401 that, before sending the write instruction, the second server may have learned the storage address of the target data in the cache of the first server, or may not have learned the storage address of the target data in the cache of the first server. Therefore, in the manner 2 in step 403, the service module may generate the read instruction for the target data in the following two implementations. (1) For the manner 1 in step 401, because in this case, the second server has learned the storage address of the target data in the cache before sending the write instruction, the service module may directly generate the read instruction based on the storage address of the target data in the cache. (2) For manner 2 in step 401, because in this case, before sending the write instruction, the second server does not learn the storage address of the target data in the cache, the service module further needs to send the address obtaining request to the first network interface card through the second network interface card when receiving the second acknowledgment message, where the address obtaining request carries the identifier of the target data; when receiving the address obtaining request, the first network interface card determines the storage address of the target data in the cache based on the identifier of the target data, and sends the obtained storage address to the second network interface card through the first network interface card; and when receiving the storage address, the second network interface card sends the storage address to the service module, to enable the service module to generate the read instruction based on the storage address.

[0093] Step 404: The first server stores the target data in the storage medium of the non-volatile memory based on the read instruction.

[0094] It can be learned from step 403 that, regardless of whether the read instruction is triggered by the first server or the second server, the read instruction carries the storage address of the target data. Therefore, in a possible implementation, step 404 may be specifically as follows. The first server obtains the target data based on the storage address of the target data in the cache, and stores the obtained target data in the storage medium of the non-volatile memory.

[0095] An implementation in which the first server obtains the target data based on the storage address of the target data in the cache may be as follows. The first network interface card sends the read instruction to the controller, where the read instruction carries the storage address of the target data in the cache. When receiving the storage address of the target data in the cache, the controller reads the target data based on the storage address of the target data in the cache, and returns the target data to the first network interface card.

[0096] In this embodiment of this disclosure, in the process in which the first server reads the target data based on the read instruction, the first server may store the target data to the storage medium at the same time, so that the target data is flushed from the cache of the controller to the storage medium promptly based on the read instruction. Therefore, in a possible implementation, that the first server stores the obtained target data in the storage medium of the non-volatile memory may be specifically as follows. In a process in which the controller is reading the target data, the controller stores the target data from the cache to the storage medium at the same time.

[0097] In addition, in this embodiment of this disclosure, the read instruction is used to trigger the storage of the target data from the cache to the storage medium. Therefore, to prevent the first server from storing, from the cache to the storage medium each time the first server receives a read instruction, data corresponding to the data read instruction, a storage identifier may be set for each piece of data in the cache. The storage identifier includes a first identifier and a second identifier. The first identifier is used to indicate data that is not written to the storage medium, and the second identifier is used to indicate data that is written to the storage medium. Therefore, in step 402, after the first server stores the target data in the cache of the controller, the first server sets a storage identifier of the target data in the cache to the first identifier. Correspondingly, in step 404, after the first server stores the target data in the storage medium of the non-volatile memory, the first server further updates the storage identifier of the target data in the cache to the second identifier.

[0098] Based on the foregoing setting of the storage identifier, when the first server receives a read instruction for a piece of data, the first server first determines a storage identifier of the data. If the storage identifier of the data is the first identifier, and when the first server obtains the data, the first server flushes the data to the storage medium and updates the storage identifier of the data. If the storage identifier of the data is the second identifier, only the data needs to be obtained.

[0099] In foregoing step 401 to step 404, each time the first server detects a read instruction for a piece of data, the first server determines whether the data is stored from the cache to the storage medium. If the data is not stored from the cache to the storage medium, the first server immediately stores the data from the cache to the storage medium. In this way, data in the cache can be stored in the storage medium promptly. In this way, because the data in the cache is stored in the storage medium promptly, a case in which data in the second server is lost can be avoided even if the first server encounters a fault such as the power failure. Therefore, a case in which the second server becomes abnormal because the first server is faulty is avoided.

[0100] In addition, in a process in which the first server stores the data according to step 401 to step 404, because each piece of data in the cache has the corresponding storage identifier, and the storage identifier is used to indicate whether the corresponding data has been stored from the cache to the storage medium, the first server may further detect the storage identifier of each piece of data periodically or in real time, and store data whose storage identifier is the first identifier from the cache to the storage medium promptly. This further improves security and reliability of data storage.

[0101] In addition, for the manner 1 in step 403, the read instruction is triggered by the first server. In this case, after the first server writes the target data to the cache, the first server directly generates the read instruction, to store the target data in the storage medium through step 404. Therefore, after the first server stores the target data in the storage medium of the non-volatile memory based on the read instruction, the first server further needs to send a first acknowledgment message for the write instruction to the second server, to enable the second server to determine that the target data is written to the first server. An implementation in which the first server sends the first acknowledgment message for the write instruction to the second server may be as follows. The first network interface card sends the first acknowledgment message to the service module through the second network interface card, and when receiving the first acknowledgment message, the service module determines that the target data is written to both the cache and the storage medium.

[0102] For the manner 2 in step 403, the read instruction is triggered by the second server. In this case, after the first server writes the target data to the cache, the second server generates the read instruction, to store the target data to the storage medium through step 404. Therefore, after the first server stores the target data in the storage medium of the non-volatile memory based on the read instruction, the first server returns the target data to the second server, to respond to the read instruction sent by the second server.

[0103] In this embodiment of this disclosure, after the first server stores the target data in the cache of the controller, the first server detects the read instruction for the target data, and stores the target data in the storage medium of the non-volatile memory based on the read instruction. In other words, in this disclosure, when the second server needs to write the target data to the first server, the target data is not only written to the cache of the first server, but also written to the storage medium of the first server. This can ensure that the data in the cache is written to the storage medium promptly. Therefore, the case in which the second server becomes abnormal because the first server is faulty is avoided. In addition, because the first server provides a data storage service for the second server, only network resources and computing resources may be deployed in the second server, and a processor of the second server does not need to pay attention to a process in which data is stored from a cache to a memory, and to a network interface card. Therefore, the computing resources of the second server are saved, and performance of the second server is improved. In addition, because the RDMA network is a high-speed network, when processing data, the processor of the second server may directly store the data in the first server. This reduces overheads of the processor of the second server, and improves the overall performance of the second server. In addition, if the read instruction is triggered by the first server, the second server does not need to trigger the read instruction. In this way, the overheads of the processor of the second server can be reduced, and a plurality of interactions between the first server and the second server can be avoided, to optimize network communication between the first server and the second server.

[0104] FIG 5 shows a data storage apparatus according to an embodiment of this disclosure. As shown in FIG 5, the apparatus 500 includes: a first receiving module 501, configured to receive a write instruction sent by a second server, where the write instruction includes target data; a first storage module 502, configured to store the target data in a cache of a controller, where a first server includes a non-volatile memory, the non-volatile memory includes the controller and a storage medium, and the first server communicates with the second server through a first network; a detection module 503, configured to detect a read instruction for the target data, where the read instruction is used to instruct to store the target data in the storage medium of the non-volatile memory; and a second storage module 504, configured to store the target data in the storage medium of the non-volatile memory based on the read instruction.

[0105] Optionally, the detection module 503 includes a determining module 5031 and a read instruction detection module 5032.

[0106] The determining module 5031 is configured to: when it is determined that the target data is written to the cache, generate the read instruction for the target data; and the read instruction detection module 5032 is configured to detect the read instruction.

[0107] Optionally, the apparatus 500 further includes a first sending module 505.

[0108] The first sending module 505 is configured to send a first acknowledgment message for the write instruction to the second server.

[0109] Optionally, the detection module 503 further includes a second sending module 5033 and a second receiving module 5034.

[0110] The second sending module 5033 is configured to: when it is determined that the target data is written to the cache, send a second acknowledgment message for the write instruction to the second server; and the second receiving module 5034 is configured to receive the read instruction for the target data.

[0111] Optionally, the second storage module 504 is further configured to: obtain the target data based on a storage address of the target data in the cache, and store the obtained target data in the storage medium of the non-volatile memory.

[0112] Optionally, the first network includes an RDMA network, and the non-volatile memory is an SCM.

[0113] It should be noted that, when the data storage apparatus provided in the foregoing embodiment performs data storage, only divisions of the foregoing functional modules are used as an example for description. In an actual application, the foregoing functions may be allocated to and completed by different functional modules based on a requirement, in other words, an internal structure of a device is divided into different functional modules, to complete all or some of the functions described above. In addition, the data storage apparatus provided in the foregoing embodiment and the data storage method embodiments pertain to a same concept. For a specific implementation process of the data storage apparatus, refer to the method embodiments. Details are not described herein again.

[0114] It should be understood that the data storage apparatus provided in this embodiment of this disclosure may be implemented through an application-specific integrated circuit (application-specific integrated circuit, ASIC) or a programmable logic device (programmable logic device, PLD). The PLD may be a complex programmable logical device (complex programmable logical device, CPLD), a field programmable gate array (field-programmable gate array, FPGA), a generic array logic (generic array logic, GAL), or any combination thereof. In addition, the data storage method shown in FIG 4 may also be implemented through software. In this case, the data storage apparatus and modules of the data storage apparatus may also be software modules.

[0115] In addition, the data storage apparatus 500 provided in this embodiment of this disclosure may correspondingly perform the data storage method described in the embodiments of this disclosure. In addition, the foregoing and other operations and / or functions of the units in the provided data storage apparatus 500 are separately used to implement corresponding procedures of the data storage method shown in FIG. 4. For brevity, details are not described herein again. In other words, the foregoing modules may be integrated into the first server shown in FIG. 1 or FIG. 2, to implement the data storage method provided in the foregoing embodiments.

[0116] All or some of the foregoing embodiments may be implemented through software, hardware, firmware, or any combination thereof. When the software is used to implement the embodiments, all or some of the embodiments may be implemented in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on the computer, the procedures or functions according to the embodiments of this disclosure are all or partially generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or another programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or may be transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instruction may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (Digital Subscriber Line, DSL)) or wireless (for example, infrared, radio, microwave, or the like) manner. The computer-readable storage medium may be any usable medium accessible by a computer, or a data storage device such as a server or a data center that integrates one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a digital versatile disc (Digital Versatile Disc, DVD), a semiconductor medium (for example, a solid-state drive (Solid State Disk, SSD)), or the like.

[0117] A person of ordinary skill in the art may understand that all or some of the steps of the embodiments may be implemented by hardware or a program instructing related hardware. The program may be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic disk, a compact disc, or the like.

Examples

Embodiment Construction

[0043]The following further describes the embodiments of this disclosure in detail with reference to the accompanying drawings.

[0044]FIG 1 is a schematic diagram of a data storage system according to an embodiment of this disclosure. As shown in FIG 1, the system 100 includes a first server 101 and a second server 102. The first server 101 is connected to the second server 102 through a first network for communication.

[0045]As shown in FIG. 1, the first server 101 includes a non-volatile memory (non-volatile memory, PM) 1011 and a first network interface card (network interface card, NIC) 1012. The first network interface card 1012 is connected to the non-volatile memory 1011 for communication. The non-volatile memory includes a controller (PM controller) 10111 and a storage medium 10112. The controller 10111 is connected to the storage medium 10112 for communication, and the controller 10111 further includes a cache 101111. The second server 102 includes a service module 1021 and a...

Claims

1. A data storage method, wherein the method comprises: receiving (401), by a first server, a write instruction sent by a second server, wherein the first server comprises a non-volatile memory, the non-volatile memory comprises a controller and a storage medium, the first server communicates with the second server through a first network, and the write instruction comprises target data; storing (402), by the first server, the target data in a cache of the controller; detecting (403), by the first server, a read instruction for the target data, wherein the read instruction is used to instruct the first server to store the target data in the storage medium of the non-volatile memory; and storing (404), by the first server, the target data in the storage medium of the non-volatile memory based on the read instruction, wherein either the first server further comprises a first network interface card, and the detecting (403), by the first server, a read instruction for the target data comprises: when the first network interface card determines that the target data is written to the cache, generating, by the first network interface card, the read instruction for the target data; and detecting, by the controller, the read instruction, OR wherein the detecting (403), by the first server, a read instruction for the target data comprises: when the first server determines that the target data is written to the cache, sending, by the first server, a second acknowledgment message for the write instruction to the second server, to enable the second server to send the read instruction for the target data to the first server when receiving the second acknowledgment message; and receiving, by the first server, the read instruction for the target data, to enable the first server to detect the read instruction.

2. The method according to claim 1, wherein after the storing (404), by the first server, the target data in the storage medium of the non-volatile memory based on the read instruction, the method further comprises: sending, by the first server, a first acknowledgment message for the write instruction to the second server.

3. The method according to any claim 1 or 2, wherein the read instruction for the target data comprises a storage address of the target data in the cache; and the storing (404), by the first server, the target data in the storage medium of the non-volatile memory based on the read instruction comprises: obtaining, by the first server, the target data based on the storage address of the target data in the cache, and storing the obtained target data in the storage medium of the non-volatile memory.

4. The method according to any one of claims 1 to 3, wherein the first network comprises a remote direct memory access, RDMA, network, and the non-volatile memory is a storage class memory SCM.

5. A server, comprising a processor adapted to perform the method any one of claims 1 to 4.

Citation Information

Patent Citations

  • Write- back storage cache based on fast persistent memory

    CN103917963A

  • Computer architecture of heterogeneous hybrid memory, and data protection method when computer architecture is powered down

    CN105786726A

  • Memory system and operation method thereof

    CN107025065A

  • Non-volatile random access system memory with dram program caching

    CN108475235A

  • Page cache write logging at block-based storage

    US20150261674A1