Cache synchronization method and apparatus, computer device, and storage medium
By establishing an RDMA high-speed cache channel and a dynamic file system in a multi-controller storage system, the high implementation threshold and stability problems of existing cache synchronization methods are solved, enabling fast data synchronization and anomaly recovery, and ensuring data security and system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHANGSHA JINGJIA MICROELECTRONICS
- Filing Date
- 2024-03-22
- Publication Date
- 2026-04-24
AI Technical Summary
In multi-controller storage systems, existing cache synchronization methods require in-depth modifications to the system, which are difficult and have high implementation thresholds, and their stability is hard to guarantee, resulting in a high risk of data loss.
By establishing a high-speed cache channel based on RDMA between the first and second controllers, the data to be written is preferentially stored in the memory block device. A storage pool is built through a dynamic file system, and the SPDK component is used to create memory block devices of the target size, which are then mapped to remote block devices to achieve fast data synchronization and recovery.
It improves data read and write speed, ensures controller processing speed and data security, avoids data loss when the controller malfunctions, reduces development difficulty, and improves system stability and reliability.
Smart Images

Figure CN118210449B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of dual-controller storage device technology, specifically to a cache synchronization method, a cache synchronization device, a computer device, and a computer-readable storage medium. Background Technology
[0002] In multi-controller storage systems, such as dual-controller Network Attached Storage (NAS) systems, cache synchronization between the two controllers is a critical factor affecting the performance and reliability of the dual-controller storage system. To ensure high performance, NAS systems typically use asynchronous write operations. This means that data may be in the NAS cache but not yet written to disk, but the write command has already returned to the client, indicating that the client's write operation has been completed. However, in the event of a system failure or crash, these asynchronous write operations are highly susceptible to data loss, particularly the portion of data not yet written to disk, leading to significant losses.
[0003] In the relevant technical solution, when data is written from controller 1 to the backend disk, write cache data is simultaneously transferred to the memory of controller 2 via a non-transparent bridging (NTB) device channel. When controller 1 loses power, the relevant resources can be swapped to controller 2, and then the dirty data can be flushed to disk in controller 2.
[0004] However, the above technical solutions require in-depth modifications to the system, which are difficult and have high barriers to entry, and their stability is hard to guarantee. Summary of the Invention
[0005] This application provides a cache synchronization method, a cache synchronization method apparatus, a computer device, and a computer-readable storage medium, thereby overcoming, to at least a certain extent, the technical problems of existing cache synchronization methods requiring in-depth modifications to the system during implementation, resulting in high implementation thresholds, high difficulty, and difficulty in guaranteeing stability.
[0006] A first aspect of this application provides a cache synchronization method applied to a first controller. The method includes: receiving write data; recording the write data into memory block devices of a storage pool configured by the first controller, wherein the storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of a second controller mapped to a remote block device in the first controller; and transmitting the write data to the second memory block device of the second controller through a high-speed cache channel between the first controller and the second controller; wherein the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA).
[0007] In an optional embodiment of this application, recording the written data to each memory block device of the storage pool configured by the first controller includes: constructing the storage pool through a dynamic file system; setting the synchronous mount parameter of the dynamic file system to receive the written data synchronously to the maximum value; and synchronously recording the written data to each memory block device based on the maximum value.
[0008] In an optional embodiment of this application, before recording the write data into each memory block device of the storage pool configured by the first controller, the method further includes: creating a first memory block device of a target size using an SPDK component, the target size being determined based on the data port bandwidth and the disk flushing interval of the write data.
[0009] In an optional embodiment of this application, after creating a first memory block device of the target size through the SPDK component, the method further includes: sending a block device creation request to a second controller, so that the second controller creates a second memory block device of the target size according to the block device creation request; receiving storage device information sent by the second controller, and creating a remote block device corresponding to the second memory block device based on the storage device information.
[0010] In an optional embodiment of this application, the first memory block device and the remote block device in the storage pool are disclosed as a first Linux block device via the network block device nbd.
[0011] In an optional embodiment of this application, the method further includes: sending an abnormal storage instruction to a second controller, so that the second controller can restore the storage pool through a second memory block device based on the abnormal storage instruction.
[0012] In an optional embodiment of this application, sending an abnormal storage instruction to the second controller so that the second controller can restore the storage pool through the second memory block device based on the abnormal storage instruction includes: sending an abnormal storage instruction to the second controller so that the second controller exposes the second memory block device as a second Linux block device with the same device name as the first Linux block device through the network block device nbd; the first Linux block device is the Linux block device exposed by the remote block device that stores and writes data during normal storage by the first controller through the network block device nbd.
[0013] A second aspect of this application provides a cache synchronization device applied to a first controller. The device includes: a data receiving module for receiving write data; a data recording module for recording the write data to memory block devices in a storage pool configured by the first controller, wherein the storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of a second controller mapped to a remote block device in the first controller; and a writing module for transmitting the write data to the second memory block device of the second controller through a high-speed cache channel between the first controller and the second controller; wherein the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA).
[0014] In one optional embodiment of this disclosure, the data recording module is used to construct a storage pool through a dynamic file system; set the synchronous mount parameter for synchronously receiving written data in the dynamic file system to the maximum value; and synchronously record the written data to each memory block device based on the maximum value.
[0015] In an optional embodiment of this disclosure, the device may further include a memory block creation module for creating a first memory block device of a target size using an SPDK component, the target size being determined based on the data port bandwidth and the disk flushing interval for writing data.
[0016] In an optional embodiment of this disclosure, the apparatus may further include a request sending module, which is used to send a block device creation request to a second controller so that the second controller can create a second memory block device of a target size according to the block device creation request; and a data receiving module, which is used to receive storage device information sent by the second controller and create a remote block device corresponding to the second memory block device based on the storage device information.
[0017] In an optional embodiment of this disclosure, the first memory block device and the remote block device in the storage pool are disclosed as a first Linux block device via network block device nbd.
[0018] In an optional embodiment of this disclosure, the device may further include an instruction sending module, which can be used to send an abnormal storage instruction to a second controller so that the second controller can restore the storage pool through a second memory block device based on the abnormal storage instruction.
[0019] In an optional embodiment of this disclosure, the instruction sending module can be used to send an abnormal storage instruction to the second controller, so that the second controller exposes the second memory block device as a second Linux block device with the same device name as the first Linux block device through the network block device nbd; the first Linux block device is the Linux block device exposed by the remote block device that stores and writes data during normal storage by the first controller through the network block device nbd.
[0020] A third aspect of this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the above cache synchronization methods.
[0021] A fourth aspect of the embodiments of this application provides a computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the steps of the cache synchronization method as described in any of the above.
[0022] The cache synchronization method receives write data; records the write data into each memory block device of the storage pool configured by the first controller, wherein the storage pool contains at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller mapped to a remote block device in the first controller; and transmits the write data to the second memory block device of the second controller through a high-speed cache channel between the first controller and the second controller; wherein the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA).
[0023] In this method, write data is first stored in memory block devices and then gradually transferred to the disk devices in the storage pool. Compared with related technical solutions that directly write data to the disk, the faster read / write speed of memory allows for quick storage and synchronization of write data to the other controller, improving data read / write speed and ensuring controller processing speed. Furthermore, this method maps the memory of the second controller to the first controller via a high-speed cache channel built using RDMA. The first controller operates the memory block devices mapped from the second controller as if they were local devices, synchronizing local operations on the first controller with the remote second controller. If one controller experiences a power outage, the storage pool can be quickly restored via the memory block devices of the other controller, avoiding data loss due to controller failure and ensuring data security. Moreover, the transmission of write data is based on a standard interface, without modifying the internal details of the file system, ensuring reliability and stability, reducing development difficulty, and further improving system stability. Attached Figure Description
[0024] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0025] Figure 1 This is a schematic diagram illustrating a single storage controller performing a write operation according to one embodiment of this application;
[0026] Figure 2 A schematic diagram of a dual-controller centralized storage technology provided in one embodiment of this application;
[0027] Figure 3 This is a schematic diagram illustrating an application scenario of a cache synchronization method provided in one embodiment of this application;
[0028] Figure 4 A flowchart illustrating a cache synchronization method provided in one embodiment of this application;
[0029] Figure 5 This is a schematic diagram illustrating cache synchronization between multiple controllers according to one embodiment of this application;
[0030] Figure 6 A flowchart of a method for adding a second controller to a remote block device in a first controller according to an embodiment of this application;
[0031] Figure 7 This is a schematic diagram of a cache synchronization device provided in one embodiment of this application;
[0032] Figure 8 This is a schematic diagram of a computer device structure provided in one embodiment of this application. Detailed Implementation
[0033] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0034] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0035] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0036] To help those skilled in the art better understand the technical solutions of this disclosure, the relevant content involved in the technical solutions of this disclosure will be introduced below.
[0037] 1) Network Attached Storage (NAS) system: This refers to a device connected to a network that has data storage capabilities; it can also be called a network storage device.
[0038] 2) Remote Direct Memory Access (RDMA): This refers to the ability of external devices to bypass the central processing unit (CPU) and access the user-mode system memory on another remote host. This allows data to be transferred from one server to another or stored on a server with minimal CPU usage. It is mainly used in high-performance computing and large data centers.
[0039] 3) Storage Performance Development Kit (SPDK): This is a high-performance user-space development kit developed by Intel based on NVMe SSD. It uses user-space polling mode drivers, huge page memory, and lock-free queue processing, and is mainly used for accelerating storage devices.
[0040] 4) Network Block Device (NBD): A technology that maps remote storage devices to local storage via a network connection. With NBD, users can use remote storage devices as if they were local storage devices, thereby achieving the purpose of remote access and data sharing.
[0041] In the context of relevant technologies, write cache synchronization between the two controllers is a critical factor affecting the performance and reliability of dual-controller NAS systems. To ensure high performance, NAS systems typically use asynchronous write operations, meaning that data may exist in the NAS system's cache but not yet written to disk (e.g., ...). Figure 1 (as shown in the NVME disk), but the write command has already been returned to the client, indicating that the client's write operation has been completed.
[0042] Figure 1 This application provides a schematic diagram illustrating a single memory controller performing a write operation according to one embodiment of the present application; as shown below. Figure 1 As shown, in a dual-controller NAS system, a single controller A records data to the file system log or directly writes it to the NVMe disk before returning it to the client (specifically, the steps are: first, the controller receives the write data transmitted by the client; second, the controller transfers the write data to the NVMe disk; third, the controller returns a response to the client). Alternatively, a C2F (Client-to-Factory) function can be added to this system to prioritize the step of sending a response from the memory in controller A to the client, and then execute the step of storing the data in the memory of controller A to the NVMe disk.
[0043] but, Figure 1 The method shown, in which a single storage controller performs write operations, is highly susceptible to failure when the controller malfunctions and crashes. This can prevent the storage from providing write data services, resulting in the loss of some data that has not yet been written to the disk, and consequently causing significant losses.
[0044] In response, the relevant technical solutions also provide a traditional dual-controller centralized storage technology. Figure 2 This is a schematic diagram of a dual-controller centralized storage technology provided in one embodiment of this application. Figure 2 As shown, there is a high-speed channel between the two controllers, typically using the NTB of a PCIe Sift. When data is written from controller 1 to the back-end disk (e.g., an NVMe disk), its write cache is simultaneously transferred to the memory of controller 2 via the NTB channel. Therefore, when controller 1 loses power, the relevant data and resources are transferred to controller 2, and then controller 2 writes the data that controller 1 did not store to the back-end disk.
[0045] However, the above Figure 2 The cache synchronization method shown has the following technical problems:
[0046] 1) The NTB channel is used to transfer write cache data in the disk, and the disk stores the write cache data; and the NTB has low caching efficiency, which leads to low data transfer performance and efficiency.
[0047] 2) Modifications need to be made to the internal workings of the system so that the controller can perform basic management functions (such as the controller's own memory partitioning, cache mirroring, and volume management). This will require a lot of human resources, and the implementation of write synchronization caching between multiple controllers is difficult to achieve and its stability is hard to guarantee.
[0048] To address the aforementioned issues, this application provides a cache synchronization method, which is particularly applicable to write cache synchronization scenarios between multiple controllers (or multiple storage servers). For ease of understanding, a dual-controller example will be used below for illustrative explanation.
[0049] The method involves receiving write data; recording the write data into each memory block device of a storage pool configured by a first controller, wherein the storage pool contains at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller, which are mapped to remote block devices in the first controller; and transmitting the write data to the second memory block device of the second controller through a high-speed cache channel between the first controller and the second controller; wherein the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA).
[0050] In this method, write data is first stored in memory block devices and then gradually transferred to the disk devices in the storage pool. Compared with related technical solutions that directly write data to the disk, the faster read / write speed of memory allows for quick storage and synchronization of write data to the other controller, improving data read / write speed and ensuring controller processing speed. Furthermore, this method maps the memory of the second controller to the first controller via a high-speed cache channel built using RDMA. The first controller operates the memory block devices mapped from the second controller as if they were local devices, synchronizing local operations on the first controller with the remote second controller. If one controller experiences a power outage, the storage pool can be quickly restored via the memory block devices of the other controller, avoiding data loss due to controller failure and ensuring data security. Moreover, the transmission of write data is based on a standard interface, without modifying the internal details of the file system, ensuring reliability and stability, reducing development difficulty, and further improving system stability.
[0051] To make the technical solutions and advantages of the embodiments of this application clearer, the exemplary embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not an exhaustive list of all embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.
[0052] To address the aforementioned problems, this disclosure proposes a cache synchronization method and apparatus, which can be applied to... Figure 1 The system architecture of the exemplary application environment shown is described below. The following is a brief description of the system architecture of the application environment for the cache synchronization method provided in this application embodiment:
[0053] Figure 3 This is a schematic diagram illustrating an application scenario of the cache synchronization method provided in one embodiment of this application. Please refer to [link / reference]. Figure 3 This application takes a dual-controller system as an example. Therefore, the system architecture 300 corresponding to the cache synchronization method provided in this application can include a client 301, a controller 302, a controller 303, and a disk 304 associated with the controllers 302 and 303 respectively. A high-speed cache channel is constructed between the controllers 302 and 303 through a high-speed network card 305 (also known as a high-speed network port) that supports RDMA, enabling data transmission between the controllers 302 and 303.
[0054] For example, in one exemplary embodiment, a first controller (i.e., controller 302) may receive write data sent by client 301 and record the write data into each memory block device of a storage pool configured by the first controller. The storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller (i.e., controller 303) mapped to a remote block device in the first controller. The data is then flushed to disk 304. The first controller then transmits the write data to the second memory block device of the second controller through a cache channel between the first controller and the second controller. The cache channel is created based on a high-speed network card 305 that supports RDMA.
[0055] However, those skilled in the art will readily understand that the above application scenarios are merely illustrative and are not intended to limit the scope of this exemplary embodiment.
[0056] Having understood the system architecture of this application, the following will combine... Figure 4 The cache synchronization method provided in the embodiments of this application will be described by way of example.
[0057] Figure 4 A flowchart illustrating a cache synchronization method provided in one embodiment of this application. Please refer to [link / reference]. Figure 4 The following embodiments use the first controller 302 as the execution subject and apply the method provided in this application to the first controller 302 for specific explanation. The cache synchronization method provided in this application may include the following steps 401-403:
[0058] Step 401: Receive and write data.
[0059] Step 402: Record the written data to each memory block device in the storage pool configured by the first controller. The storage pool contains at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller, which are mapped to remote block devices in the first controller.
[0060] Step 403: The write data is transmitted to the second memory block device of the second controller through the high-speed cache channel between the first controller and the second controller; wherein, the high-speed cache channel is created based on a high-speed network card that supports remote direct data access (RDMA).
[0061] In some embodiments of this disclosure, the technical solutions involve receiving write data; recording the write data into memory block devices of a storage pool configured by a first controller, wherein the storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of a second controller mapped to a remote block device in the first controller; and transmitting the write data to the second memory block device of the second controller via a high-speed cache channel between the first and second controllers. The high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA). In this method, the write data is preferentially stored in the memory block devices of the storage pool and then gradually transferred to the disk. Compared with related technical solutions that directly write the write data to the disk, since the read / write speed of memory is faster than that of disk, the write data can be quickly stored and synchronized to another controller, avoiding data loss due to controller malfunction. Furthermore, this method maps the memory of the second controller to the first controller via a high-speed cache channel constructed using RDMA. When one controller experiences an abnormal power failure, the storage pool can be quickly restored through the memory of the other controller, avoiding the technical problem of data loss due to abnormal power failure of the controller. Furthermore, the transmission of written data is based on a standard interface, without involving modifications to the internal details of the file system, making it reliable and stable, reducing development difficulty, and further improving system stability.
[0062] The following will describe in conjunction with specific embodiments Figure 4 The specific implementation methods of each step in the illustrated embodiment are described in detail below:
[0063] In step 401, the data to be written is received.
[0064] For example, the first controller can synchronously receive write data sent from each client. That is, after receiving write data sent by the client, the first controller first stores the write data in the memory block device, and then stores it in the disk device. The disk can be a file disk, a high-speed disk, a solid-state drive, etc., and this disclosure embodiment does not impose any special limitations on it.
[0065] It's important to explain that storing data in memory (also known as a memory cache) and storing it on a hard drive or solid-state drive (SSD) have different effects. Memory cache has the fastest read / write speed, but the available capacity is limited. In contrast, file disks, high-speed disks, and SSDs have slower read / write speeds compared to memory cache, but offer a larger storage capacity.
[0066] In step 402, the written data is recorded to each memory block device in the storage pool configured by the first controller. The storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller, which are mapped to remote block devices in the first controller.
[0067] In this system, the first controller can be any controller in a multi-controller system, and the second controller can be any controller other than the first controller. The first controller can also be a controller that directly exchanges data with the client, while the second controller is a controller that does not directly exchange data with the client. This disclosure does not impose any special restrictions on this aspect.
[0068] For example, after receiving write data from the client, the first controller adds the write data to each memory block device in the storage pool configured by the first controller. That is, each memory block device in the storage pool needs to store the write data. In one embodiment, the storage pool includes multiple memory block devices, including at least a first memory block device created based on the memory of the first controller, and a second memory block device created based on the memory of the second controller mapped to a remote block device in the first controller.
[0069] It should be explained that the embodiments provided in this application can be applied to write cache synchronization of multiple controllers. Assuming there are three controllers, the corresponding storage pool includes a first memory block device created by the memory of the first controller, a second memory block device created by the memory of the second controller mapped to a remote block device in the first controller, and a third memory block device created by the memory of the third controller mapped to a remote block device in the first controller. This disclosure does not exhaustively list all such examples. The embodiments in this application mainly use a dual-controller model for illustration.
[0070] When performing step 402 to record the written data to each memory block device of the storage pool configured by the first controller, it is necessary to pre-create the storage pool belonging to the first controller in the first controller.
[0071] In one optional embodiment of this application, a storage pool is constructed using a dynamic file system; the synchronous mount parameter for receiving and writing data synchronously in the dynamic file system is set to the maximum value; and the written data is synchronously recorded to each memory block device based on the maximum value.
[0072] Among them, the Dynamic File System is a product with a high scalability file system and supports many extended functions. It is usually called the ZFS file system (Zettabyte File System, where Dynamic File System is an alias for ZFS file system).
[0073] In this system pool, the first memory block device and the second memory block device created based on the memory of the second controller are mapped to the remote block device in the first controller as a log mirror disk, thus forming a storage pool.
[0074] It's important to explain that the ZFS file system differs from traditional file systems that typically map physical storage devices. It completely abandons "volume management," no longer creating virtual volumes, and instead centralizes all devices into a single storage pool for management. Therefore, the storage pool approach built using the ZFS file system in this application simplifies the controller's work, thereby reducing operational complexity.
[0075] For example, the total capacity of the ZFS file system is 1.84 x 10^19 times that of existing 64-bit file systems, and it supports a single storage volume capacity of up to 16 EiB (2^64 bytes, or 16 x 1024 x 1024 TB); a zpool can have 2^64 volumes, with a maximum total capacity of 256 ZiB (2^78 bytes); the entire system can have 2^64 storage pools. Therefore, setting the synchronous mount parameter of the dynamic file system to its maximum value can maximize the reception of write data from each client, ensuring that the ZFS file system records as much synchronous write data as possible to the log device, thus ensuring fast data read and write speed for the controller and improving controller processing efficiency. Furthermore, this method allows data to be automatically recovered even in the event of abnormal power outages, improving data storage security, provided the log exists. In addition, the logs are stored in memory, which is faster than disk read / write speed. Furthermore, data is transferred between memory block devices in the storage pool via SPDK RDMA, thus significantly improving system performance.
[0076] According to some embodiments of this disclosure, if the amount of data to be written is greater than the maximum value of the synchronous mount parameter that the ZFS file system can synchronously receive, then the data exceeding the maximum value needs to be directly written to the disk device of the storage pool.
[0077] In conjunction with the above embodiments, it can be combined Figure 5 The embodiments shown are illustrated by way of example:
[0078] Figure 5 This is a schematic diagram illustrating cache synchronization between multiple controllers according to one embodiment of this application, referring to... Figure 5 As shown, the first controller includes memory (i.e., the memory block device of this disclosure embodiment) that the second controller maps to.
[0079] In step 501, the client sends write data to the first controller. Upon receiving the write data from the client, the first controller prioritizes storing the write data in the log of the memory block device. It then transmits the data to the memory block device of the second controller via the high-speed network established in step 502 for further processing. The processed data is then transmitted to the client in step 503 (this process allows the first controller to store write data on the mapped memory block device of the second controller as if it were a local memory block device). When the amount of write data received by the first controller exceeds the maximum mountable value, step 504 stores the write data in a disk device (e.g., ...). Figure 5 (The NVME disk shown).
[0080] It should be explained that when the frequency of writing data is low or other situations occur, the write data in the memory block device can also be stored in the NVME disk, and this disclosure does not impose any special restrictions on this.
[0081] In the implementation of the above embodiments, relevant attribute parameters need to be set when creating the ZFS file system so that the ZFS file system can adopt the synchronous mounting method to realize the function of synchronous data writing. Then, the synchronously written data is pre-recorded in the log device, and then the internal policy of the ZFS file system writes the written data to the disk device in the storage pool.
[0082] For example, relevant attribute parameters may include: logbias attribute, zfs_immediate_write_sz attribute, etc. Specific attribute parameters can be determined according to the actual application scenario, and this disclosure does not exhaustively list them. For instance, in the application scenario where the ZFS file system synchronously writes data, prioritizing recording synchronously written data to the log device first, and then the file system's internal strategy writes dirty data exceeding the log device's capacity to the disk device in the storage pool, the logbias attribute of the ZFS file system can be set to latency (wherein, the logbias attribute controls how ZFS handles synchronization requests for a specific dataset. If logbias is set to latency, ZFS will use different log devices (if any) in the pool to process requests with low latency. If logbias is set to throughput, ZFS will not use different log devices in the pool. Instead, the ZFS file system will optimize synchronization operations to improve the pool's global throughput and effectively utilize resources. The default value when the attribute parameter is defaulted is latency). And ensure that the value of the ZFSmodule parameter zfs_immediate_write_sz (the synchronous mount parameter is the maximum value) is 16777216.
[0083] It should be noted that this synchronization mount parameter is a system parameter, which is usually modified once in advance and can then be used directly.
[0084] The above embodiments illustrate the creation of a storage pool in the first controller, and the formation of a storage pool based on the first memory block device and the remote block device of the second controller in the first controller as a log mirror disk. The following will describe in detail the process of the controller generating the corresponding memory block device through memory in conjunction with specific embodiments.
[0085] In some example embodiments of this disclosure, the first controller may create a first memory block device of a target size using the SPDK component.
[0086] The target size is determined based on the data port bandwidth and the disk flushing interval for writing data.
[0087] For example, in a multi-control system, a memory of equal size is allocated to each of the first and second controllers, and corresponding memory block devices are created based on the memory.
[0088] For example, the first controller can use the open-source SPDK component to create a memory-based block device ramdisk1 of size size1. The target size of size1 can be determined by multiplying the dirty data flush interval by the data port bandwidth; dirty data refers to data that has not been flushed to disk.
[0089] In some example embodiments of this disclosure, the first memory block device in the storage pool is exposed as a first Linux block device via the network block device nbd.
[0090] For example, the first memory block device ramdisk1, based on memory, is exposed as the first Linux block device (denoted as nbd1) through a network block device (nbd). In this case, a device file named nbd1 exists under / dev in the current system, which is used to store the received written data.
[0091] In this embodiment, the first memory block device ramdisk1 is exposed as the first Linux block device nbd1 through nbd. Since the SPDK component is open source, the controller's memory is transformed into a general-purpose Linux nbd block device using the SPDK component. It has a standard communication interface and can be modified without delving into the details of the file system. This reduces the difficulty and threshold of developing multi-controller professional storage products, improves the write performance of multi-controllers, and ensures the stability and reliability of the system.
[0092] After the first controller creates the first memory block device of the target size, it will be combined Figure 5 An example is provided. Figure 6 A flowchart illustrating a method for adding a second controller to a remote block device in a first controller, as provided in one embodiment of this application. See also... Figure 6 The method for adding a second controller to a remote block device in a first controller provided in this application embodiment may include the following steps 601-602:
[0093] Step 601: The first controller sends a block device creation request to the second controller, so that the second controller can create a second memory block device of the target size according to the block device creation request.
[0094] For example, after the first controller creates the first memory block device internally, it can send a device creation request to the second controller so that the second controller can also create a second memory block device ramdisk2 of the same size, i.e., size1.
[0095] In some example embodiments of this disclosure, after creating a second memory block device ramdisk2 of the same size as the first controller on the second controller, a subsystem is created for the second memory block device ramdisk2, and a unique identifier (ID) (abbreviated as nqnId), serial number, namespace (Namespace) is assigned to the namespace identifier (NVM Queue Namespace, abbreviated as NQN) in the subsystem, and an RDMA type listener is added (i.e., an RDMA type NVMe target is created for the second memory block device ramdisk2), and the above storage device information is sent to the first controller.
[0096] NQN is used to identify remote NVMe storage targets. The principle of NQN is primarily based on two key concepts: queues and namespaces. A queue is a data structure used to store and process input / output requests. In NVM devices, queues are used to manage read and write operations on namespaces. A namespace is a logical region within an NVM device, similar to a partition in a traditional storage device. By combining queues and namespaces, NQN enables efficient management and access to NVM devices.
[0097] Step 602: Receive storage device information sent by the second controller, and create a remote block device corresponding to the second memory block device based on the storage device information.
[0098] The storage device information includes the device name, nqnId, svcid, and nvme target information.
[0099] For example, the first controller can create an NVMe initor (i.e., the remote block device of ramdisk2) corresponding to the second memory block device ramdisk2 in the first controller based on the storage device information sent by the second controller.
[0100] In some example embodiments of this disclosure, the remote block device in the storage pool is disclosed as a first Linux block device via network block device nbd.
[0101] For example, once the remote block device corresponding to the second controller is created in the first controller, it can be exposed as a general Linux block device via nbd, denoted as nbd2. In this case, nbd2 is the remote block device mapped to the second memory block device ramdisk2 in the second controller.
[0102] In this embodiment, the remote block device corresponding to the second controller is exposed as a general Linux block device through NBD, which can use a general standard hardware interface without the need for in-depth modification of the system internals, thus reducing the threshold and difficulty of multi-controller storage.
[0103] In some example embodiments of this disclosure, after the first controller creates the remote block device corresponding to the second memory block device, it can use the ZFS file system to use the first memory block device nbd1 and the remote block device nbd2 as mirrored log disks to build a storage pool.
[0104] In the above embodiments, by constructing a remote block device of the second controller in the first controller, logs can be stored collaboratively with the first memory block device of the first controller. Since mirroring is used between log disks, logs will not be lost as long as one of the log disks exists.
[0105] In step 403, the write data is transmitted to the second memory block device of the second controller through a high-speed cache channel between the first controller and the second controller; wherein, the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA).
[0106] For example, the cache channel between the first controller and the second controller is created based on a high-speed network card that supports Remote Direct Data Access (RDMA). That is, the written data is transferred from the memory of the first controller to the memory of the second controller via RDMA, and then returned to the client.
[0107] During the operation of the above-mentioned multi-controller system, when the first controller experiences an emergency such as abnormal storage (e.g., abnormal crash or power failure), in an optional embodiment of this disclosure, the first controller sends an abnormal storage instruction to the second controller, so that the second controller can restore the storage pool through the second memory block device based on the abnormal storage instruction.
[0108] For example, when an abnormal storage situation occurs in the first controller, an abnormal storage instruction can be sent to the second controller. After receiving the abnormal storage instruction, the second controller needs to perform a failover operation, that is, based on the second memory block device ramdisk2 of the second controller, the storage pool zpool is restored in the second controller.
[0109] Since all the written data is also stored in the second memory block device ramdisk2 and no abnormal power loss has occurred, the logs in the storage pool zpool have not been lost. The storage pool zpool can be restored in the second controller based on the second memory block device, thereby ensuring the consistency of the write cache data.
[0110] In an optional embodiment of this disclosure, when performing the step of sending an abnormal storage instruction to the second controller so that the second controller can restore the storage pool through the second memory block device based on the abnormal storage instruction, the first controller sends an abnormal storage instruction to the second controller so that the second controller exposes the second memory block device through the network block device (nbd) as a second Linux block device with the same device name as the first Linux block device corresponding to the remote block device.
[0111] The first Linux block device is a Linux block device exposed by the network block device nbd, which is a remote block device that stores and writes data when the first controller is storing data normally.
[0112] For example, when the first controller encounters an abnormal situation, the second controller first deletes the NVMe target information of the second memory block device ramdisk2, exposes ramdisk2 as a Linux block device in the second controller via NBD, and names it as a Linux block device with the exact same name as the Linux block device of the remote block device in the first controller, namely nbd2.
[0113] In this embodiment, the name of the second memory block device in the second controller is kept consistent with the name published in the first controller. This is equivalent to the log disk nbd2 being successfully reversed back to the second controller, ensuring that nbd2 has never lost power. This allows the storage pool to be restored and data to be written in the second controller, thus ensuring the consistency of written data in the ZFS file system.
[0114] Therefore, embodiments of this application can, after the first controller fails (goes offline), switch the data disk to the second controller, thereby exporting ramdisk2 as the disk of the second controller and restoring the ZFS storage pool in the second controller. Furthermore, the logs of ramdisk2 can be used to recover dirty data that was not promptly flushed to the disk, improving the security and reliability of multi-controller write caching.
[0115] It should be understood that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order constraint on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the diagram may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0116] To implement the above cache synchronization method, please refer to [link / reference]. Figure 7 One embodiment of this application provides a cache synchronization device 700, which can be applied to a first controller. The device may include a data receiving module 701, a data recording module 702, and a writing module 703.
[0117] The data receiving module 701 is used to receive write data; the data recording module 702 is used to record the write data to each memory block device of the storage pool configured by the first controller, wherein the storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller mapped to a remote block device in the first controller; the writing module 703 is used to transmit the write data to the second memory block device of the second controller through a high-speed cache channel between the first controller and the second controller; wherein the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA).
[0118] In an optional embodiment of this disclosure, the data recording module 702 is used to construct a storage pool through a dynamic file system; set the synchronous mount parameter for synchronously receiving written data in the dynamic file system to a maximum value; and synchronously record the written data to each memory block device based on the maximum value.
[0119] In an optional embodiment of this disclosure, the device may further include a memory block creation module for creating a first memory block device of a target size using an SPDK component, the target size being determined based on the data port bandwidth and the disk flushing interval for writing data.
[0120] In an optional embodiment of this disclosure, the apparatus may further include a request sending module, which is used to send a block device creation request to a second controller so that the second controller can create a second memory block device of a target size according to the block device creation request; and a data receiving module 701, which is used to receive storage device information sent by the second controller and create a remote block device corresponding to the second memory block device based on the storage device information.
[0121] In an optional embodiment of this disclosure, the first memory block device and the remote block device in the storage pool are disclosed as a first Linux block device via network block device nbd.
[0122] In an optional embodiment of this disclosure, the device may further include an instruction sending module, which can be used to send an abnormal storage instruction to a second controller so that the second controller can restore the storage pool through a second memory block device based on the abnormal storage instruction.
[0123] In an optional embodiment of this disclosure, the instruction sending module can be used to send an abnormal storage instruction to the second controller, so that the second controller exposes the second memory block device as a second Linux block device with the same device name as the first Linux block device through the network block device nbd; the first Linux block device is the Linux block device exposed by the remote block device that stores and writes data during normal storage by the first controller through the network block device nbd.
[0124] For specific limitations regarding the aforementioned cache synchronization device, please refer to the limitations of the cache synchronization method above, which will not be repeated here. Each module in the aforementioned cache synchronization device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.
[0125] In one embodiment, a computer device is provided, the internal structure of which can be as shown in the figure. Figure 8 As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements one of the cache synchronization methods described above. This includes: a memory and a processor; the memory stores a computer program; and the processor, when executing the computer program, implements any step of the cache synchronization method described above.
[0126] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, can perform any of the steps in the cache synchronization method described above.
[0127] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0128] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0129] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0130] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0131] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0132] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A cache synchronization method, characterized in that, Applied to a first controller, the method includes: Receive and write data; A first memory block device of a target size is created using the SPDK component, the target size being determined based on the data port bandwidth and the disk flushing interval of the written data. The written data is recorded in each memory block device of the storage pool configured by the first controller. The storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller, which are mapped to a remote block device in the first controller. The first memory block device and the remote block device in the storage pool are exposed as first Linux block devices through the network block device nbd. The write data is transmitted to the second memory block device of the second controller via a high-speed cache channel between the first controller and the second controller; wherein, the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA); The step of recording the written data into each memory block device of the storage pool configured by the first controller includes: The storage pool is constructed using a dynamic file system; the synchronous mount parameter of the dynamic file system for synchronously receiving the written data is set to the maximum value; Based on the maximum value, the written data is synchronously recorded to each memory block device.
2. The cache synchronization method according to claim 1, characterized in that, After creating the first memory block device of the target size using the SPDK component, the method further includes: A block device creation request is sent to the second controller so that the second controller can create the second memory block device of the target size according to the block device creation request; The system receives storage device information sent by the second controller and creates the remote block device corresponding to the second memory block device based on the storage device information.
3. The cache synchronization method according to claim 1, characterized in that, The method further includes: An abnormal storage instruction is sent to the second controller, so that the second controller can restore the storage pool through the second memory block device based on the abnormal storage instruction.
4. The cache synchronization method according to claim 3, characterized in that, Sending an abnormal storage instruction to the second controller, so that the second controller can recover the storage pool through the second memory block device based on the abnormal storage instruction, includes: Send an abnormal storage instruction to the second controller so that the second controller will expose the second memory block device as a second Linux block device with the same device name as the first Linux block device through the network block device nbd; The first Linux block device is the Linux block device exposed by the remote block device (nbd) that stores the written data when the first controller is storing normally.
5. A cache synchronization device, characterized in that, Applied to a first controller, the device includes: A data receiving module is used to receive written data; and to create a first memory block device of a target size using the SPDK component, wherein the target size is determined based on the data port bandwidth and the disk flushing interval of the written data. A data recording module is used to record the written data to each memory block device in the storage pool configured by the first controller. The storage pool includes at least a first memory block device created based on the memory of the first controller and a second memory block device created based on the memory of the second controller, which are mapped to a remote block device in the first controller. The first memory block device and the remote block device in the storage pool are exposed as first Linux block devices through the network block device nbd. A write module is configured to transmit the write data to the second memory block device of the second controller via a high-speed cache channel between the first controller and the second controller; wherein the high-speed cache channel is created based on a high-speed network card that supports Remote Direct Data Access (RDMA); wherein recording the write data to each memory block device of the storage pool configured by the first controller includes: The storage pool is constructed using a dynamic file system; the synchronous mount parameter of the dynamic file system for synchronously receiving the written data is set to the maximum value; Based on the maximum value, the written data is synchronously recorded to each memory block device.
6. A computer device, comprising: The system includes a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the cache synchronization method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the cache synchronization method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Method, equipment and computer readable medium for data synchronization
CN108733506A