Data caching method and equipment
By employing an adaptive mirroring caching strategy, the bandwidth limitation of interconnect links between controllers is resolved, enabling efficient data writing in scenarios such as high-performance computing and artificial intelligence training, ensuring data consistency and reliability.
Patent Information
- Application Number
- CN202610122336.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-29
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2046-01-29
AI Technical Summary
Bandwidth limitations in the interconnect links between controllers lead to write performance bottlenecks in storage systems, especially in high-performance computing and artificial intelligence training applications, where they cannot meet the demands of large-scale, large-block writes.
By determining the size of the target data, different mirroring caching strategies are adopted: for data blocks smaller than the preset threshold, the traditional synchronous mirroring strategy is used to write the data to the dual-controller cache; for data blocks larger than the preset threshold, the data is written to the shared disk array and the second controller is notified to delete the old cached data, thereby reducing the bandwidth usage of the interconnection link.
While ensuring data consistency and reliability, it reduces the bandwidth pressure on the interconnection links between controllers, breaks through performance bottlenecks, and can efficiently serve business loads of low-latency transaction processing and high-throughput sequential writes.
Smart Images

Figure CN121597136A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a data caching method and device. Background Technology
[0002] In storage systems, cache mirroring technology is commonly used to ensure high availability and reliability of data. When one controller receives a write request from a host and writes the data to its local cache, it synchronously mirrors the data to the local cache of another controller via the inter-controller interconnect. This strategy ensures that even if one controller fails, the data is still fully backed up in the other controller, effectively preventing data loss. It is particularly suitable for scenarios such as online transaction processing and virtual desktops.
[0003] However, with the widespread adoption of applications such as high-performance computing and artificial intelligence training, the I / O (Input / Output) patterns faced by storage systems have changed. These applications typically involve large-scale, sequential writing of large data blocks, demanding tens or even hundreds of gigabytes per second (GB / s) of write bandwidth from storage systems. In this context, the bandwidth of the interconnect links between controllers has become a key factor limiting the overall write performance of the system. Due to cost and technological limitations, the bandwidth of interconnect links is often insufficient to meet the massive data writing demands of such applications. When large amounts of data need to be mirrored synchronously, the limited link bandwidth is quickly saturated, leading to I / O congestion, increased write latency, and ultimately failing to meet the needs of high-throughput applications.
[0004] In summary, how to solve the performance bottleneck caused by the bandwidth limitation of the interconnection links between controllers is a problem that needs to be solved. Summary of the Invention
[0005] This application provides a data caching method and device to at least solve the problem in the related art where the bandwidth of the interconnection link between controllers has become a constraint on the overall write performance of the system.
[0006] This application provides a data caching method applied to a first controller in a storage system, the storage system also including a second controller, comprising: Obtain the write request sent by the target host that carries the target data; Respond to the write request to write the target data to the first cache, and determine whether the size of the target data is greater than a preset threshold; the first cache is the cache of the first controller; If the value is not greater than the preset threshold, the first mirror caching strategy is executed to transmit the target data to the second controller through the target communication link and write it into the second cache; the second cache is the cache of the second controller. If the value exceeds a preset threshold, the target data is written to the shared disk array, and the second mirror caching strategy is executed to send a notification message carrying the target data identifier to the second controller via the target communication link, so as to notify the second controller to delete the old cached data corresponding to the target data identifier in the second cache; the target data identifier is the data identifier of the target data.
[0007] This application also provides a data caching device, applied to a first controller in a storage system, the storage system further including a second controller, comprising: The request retrieval module is used to retrieve write requests sent by the target host that carry target data. The judgment module is used to respond to write requests, write the target data to the first cache, and determine whether the size of the target data is greater than a preset threshold; the first cache is the cache of the first controller; The first strategy execution module is used to execute the first mirror caching strategy if the target data is not greater than a preset threshold, so as to transmit the target data to the second controller through the target communication link and write it into the second cache; the second cache is the cache of the second controller. The second strategy execution module is used to write the target data to the shared disk array if the target data exceeds a preset threshold, and execute the second mirror caching strategy to send a notification message carrying the target data identifier to the second controller through the target communication link, so as to notify the second controller to delete the old cached data corresponding to the target data identifier in the second cache; the target data identifier is the data identifier of the target data.
[0008] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described data caching methods when executing the computer program.
[0009] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described data caching methods.
[0010] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described data caching methods.
[0011] This application adaptively selects either a first or second mirrored caching strategy by determining whether the size of the target data exceeds a preset threshold. For small data block writes not exceeding the preset threshold, traditional synchronous mirroring is used, writing the target data to both the local cache of the first controller and the local cache of the second controller, ensuring real-time synchronization of the dual-controller caches and guaranteeing immediate data redundancy and low latency. For large data block writes exceeding the preset threshold, the data is written to a shared disk array, and the second controller is notified to delete any existing old cached data. This mechanism ensures data consistency even in large data block write mode, preventing the host from reading expired data from the second controller. Furthermore, since the data is persisted to the shared disk, even if a single controller fails after sending an invalidation message, the data will not be lost, ensuring system reliability. In other words, under the second mirrored caching strategy, this application only notifies the second controller to clear invalid caches while directly writing the data to the shared disk array, significantly reducing bandwidth consumption on the inter-controller interconnection link and thus overcoming the bandwidth bottleneck of the target communication link. This solution enables the system to efficiently serve two distinct business workloads simultaneously: low-latency transaction processing and high-throughput sequential writes. Attached Figure Description
[0012] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A flowchart illustrating the processing of a read request is provided for an embodiment of this application. Figure 2 A flowchart illustrating another read request processing method provided in this application embodiment; Figure 3 A flowchart illustrating the processing of a write request is provided for an embodiment of this application; Figure 4 A flowchart of a data caching method provided in this application embodiment; Figure 5 An execution diagram of a first image caching strategy provided in an embodiment of this application; Figure 6 An execution diagram of a second image caching strategy provided in an embodiment of this application; Figure 7 A mapping relationship diagram in a cache address mapping table provided in this application embodiment; Figure 8This application provides an example of a cache address mapping table update diagram for dual controllers. Figure 9 This is a schematic diagram of a data caching device provided in an embodiment of this application. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0015] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0016] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0017] The specific application environment architecture or specific hardware architecture on which the execution of the data caching method depends is described here.
[0018] The data caching method in this application mainly relies on a storage system with a dual-controller storage array architecture, which mainly includes dual controllers, a shared disk array (Redundant Arrays of Independent Disks, i.e., RAID), and a host.
[0019] In this dual-controller configuration, both controllers can employ high-performance multi-core processors as the main control unit and are equipped with large-capacity DRAM (Dynamic Random Access Memory) caches to achieve data caching. That is, by utilizing the principle of locality of reference in data access, frequently accessed data is placed in DRAM to reduce data access latency. Furthermore, both controllers can provide read and write services, and they operate in an Active-Active peer-to-peer mode, without a primary / backup distinction; each can independently receive read and write requests from the host and directly access the shared disk array. In addition, the two controllers can be interconnected via high-speed links (such as PCIe, Ethernet, or dedicated high-speed links).
[0020] In traditional storage array methods, for read requests, if the data to be accessed is in the cache, the data is read directly from the cache and returned to the host. Figure 1 As shown; if the data is not in the cache, it needs to be read from the backend shared disk array and then returned to the host. Hot data will also be stored in the cache, such as... Figure 2 As shown. For a write request, after data is written to the cache of one controller, the written data is simultaneously sent to the other controller via the high-speed link connecting the two controllers, and written to the cache of that other controller. After the data is written to the caches of both controllers, a write completion message is returned to the host, as shown. Figure 3 As shown.
[0021] The host side can establish connections with the dual controllers through multipath software, supporting load balancing and failover for I / O requests. For example, the host and controllers can be connected via 100G Ethernet or Fibre Channel to ensure high-throughput data transmission between the host and storage systems. Furthermore, the host side can deploy online transaction processing, artificial intelligence training, and other business applications, and can send write requests of different granularities.
[0022] See Figure 4 As shown, an embodiment of this application provides a data caching method applied to a first controller in a storage system, the storage system also including a second controller, the method specifically including: Step S11: Obtain the write request carrying the target data sent by the target host.
[0023] In this embodiment, the storage system includes dual controllers, namely a first controller and a second controller. The first controller and the second controller adopt an Active-Active peer-to-peer mode to independently receive read and write requests from the host. This embodiment describes the overall scheme from the perspective of the first controller, that is, the first controller obtains the write request carrying the target data sent by the target host.
[0024] Step S12: Respond to the write request to write the target data to the first cache, and determine whether the size of the target data is greater than a preset threshold; the first cache is the cache of the first controller.
[0025] In this embodiment, after the first controller responds to the write request of the target host, it first writes the target data into the local first cache and determines whether the data size of the target data is greater than a preset threshold, and then selects the first mirror caching strategy or the second mirror caching strategy based on the determination result.
[0026] This application does not limit the specific value of the preset threshold; it can be set according to the specific scenario. For example, for transaction-type services such as online transaction processing, services with high latency requirements generally access smaller data blocks, typically less than 64KB. For services with high write bandwidth requirements, such as high-performance computing and artificial intelligence training, latency is not a critical requirement; the corresponding bandwidth requirement is the key indicator. These applications typically write larger data blocks, generally greater than 64KB. Therefore, this application can set the preset threshold to 64K.
[0027] Step S13: If the value is not greater than the preset threshold, the first mirror caching strategy is executed to transmit the target data to the second controller through the target communication link and write it into the second cache; the second cache is the cache of the second controller.
[0028] In this embodiment, if the size of the target data is not greater than a preset threshold, it is determined that the current data is being written as a small data block, and therefore the first image caching strategy is executed. Figure 5 As shown, the traditional synchronous mirroring method is used, which writes the target data into both the local cache of the first controller and the local cache of the second controller to ensure real-time synchronization of the dual controller caches, as well as ensuring data redundancy and low latency.
[0029] It should also be noted that in the scenario of writing small data blocks, after the data is written to the caches of the two controllers, the host can be returned with confirmation that the write is complete. Then, at the appropriate time (e.g., when the cache space is insufficient, during periodic flushing, or when the system is idle), the data is flushed from the cache to the disk in batches, with extremely low latency and high performance.
[0030] Step S14: If the value is greater than the preset threshold, the target data is written to the shared disk array and the second mirror caching strategy is executed to send a notification message carrying the target data identifier to the second controller through the target communication link, so as to notify the second controller to delete the old cache data corresponding to the target data identifier in the second cache; the target data identifier is the data identifier of the target data.
[0031] In this embodiment, if the size of the target data is greater than a preset threshold, it is determined that a large data block is being written. Therefore, the target data is written to the shared disk array while simultaneously executing the second mirror caching strategy. For example... Figure 6 As shown, the first controller does not mirror data to the second controller. Instead, it sends a notification message carrying a target data identifier to the second controller via the target communication link. This notifies the second controller to delete any old cached data in the second cache that corresponds to the target data identifier. The target data identifier refers to the data identifier of the target data, specifically used to identify the write address (location) of the data. In other words, the first controller notifies the second controller that data at a certain address has been updated. Upon receiving this notification message, the second controller checks whether it has cached the data at the corresponding address. If it has, it discards the data from its cache because the data at that address has already been updated by the first controller (e.g., updating data A to B). The data in the second controller is no longer up-to-date, and the two controllers are inconsistent. Therefore, the second controller needs to discard the old data (i.e., invalidate data A). This mechanism ensures that even in large data block write mode, the entire system maintains data consistency, preventing the host from reading expired data from the second controller. Simultaneously, since the data is persisted to the shared disk, even if a single controller fails after sending the invalidation message, the data will not be lost, ensuring system reliability.
[0032] In other words, under the second mirroring caching strategy, this application only notifies the second controller to clear invalid caches, while directly writing data to the shared disk array. This significantly reduces the bandwidth consumption of the interconnection links between controllers, thereby overcoming the bandwidth bottleneck of the target communication link. Because the notification message only needs to send location information indicating the target data, which can be represented by just a few bytes, the bandwidth consumption is reduced by three orders of magnitude compared to mirrored data. This solution enables the system to simultaneously and efficiently serve two distinct business workloads: low-latency transaction processing and high-throughput sequential writes.
[0033] It should also be noted that once the second mirror caching strategy is completed and the target data has been written to the backend shared disk array, the response host will be considered to have completed the write.
[0034] Furthermore, when determining whether to implement the second mirrored caching strategy, the decision can be based not only on the data size but also on the current free space and pressure of the local cache. When the controller's own cache space is insufficient, even for medium-sized write requests, the second mirrored caching strategy may be preferred, proactively writing data to disk and notifying the peer of the invalidation to quickly release local cache space. This prevents the cache from being completely occupied by large-volume sequential writes, protects the cache hit rate of small-scale random I / O, and improves the stability of the system under extreme pressure. For example, this application can monitor the current free space of the local cache. If the free space is greater than a space threshold, the current cache space is considered sufficient, and the first or second mirrored caching strategy can be determined solely by referring to the data size. If the free space is less than a space threshold, the threshold value is further reduced based on the original preset threshold, such as from 64K to 48K. In this case, the data originally considered to be written as small data blocks (i.e., the data from 48K to 64K) also only requires the second mirrored caching strategy.
[0035] As can be seen, this application adaptively selects either a first or second mirror caching strategy by determining whether the size of the target data exceeds a preset threshold. Specifically, for small data block writes not exceeding the preset threshold, traditional synchronous mirroring is used, writing the target data to both the local cache of the first controller and the local cache of the second controller, ensuring real-time synchronization of the dual-controller caches and guaranteeing immediate data redundancy and low latency. For large data block writes exceeding the preset threshold, the data is written to the shared disk array, and the second controller is notified to delete any existing old cached data. This mechanism ensures that even in large data block write mode, the entire system maintains data consistency, preventing the host from reading expired data from the second controller. Furthermore, since the data is persisted to the shared disk, even if a single controller fails after sending an invalidation message, the data will not be lost, ensuring system reliability. In other words, under the second mirror caching strategy, this application only notifies the second controller to clear invalid caches while directly writing the data to the shared disk array, greatly reducing the bandwidth consumption of the inter-controller interconnection link, thereby overcoming the bandwidth bottleneck of the target communication link. This solution enables the system to efficiently serve two distinct business workloads simultaneously: low-latency transaction processing and high-throughput sequential writes.
[0036] Based on the foregoing embodiments, this application further discloses the process by which the controller writes data to the cache. In a specific implementation, the target data is identified as the target write address of the target data in the shared disk array. Both the first controller and the second controller maintain a cache address mapping table, which is used to record the mapping relationship between the storage address of data in the shared disk array and the cache address in the cache. Accordingly, the process by which any controller writes the target data to the cache includes: querying the cache address mapping table to see if there is a first storage address corresponding to the target write address, and obtaining a first query result; determining the target cache address in the cache based on the first query result, and writing the target data to the target cache address.
[0037] In other words, the target data identifier specifically refers to the target write address of the target data in the shared disk array. Both the first and second controllers maintain a cache address mapping table to manage the association between storage addresses in the shared disk array and cache addresses in the local cache. It can be understood that when data at a certain storage address in the shared disk array is written to the cache, a mapping relationship is established between the storage address and the cache address, and this mapping relationship is stored in the cache address mapping table. Therefore, when new target data is written to the cache, the system first checks whether the cache address mapping table records a first storage address corresponding to the target write address; that is, it checks whether historical data is already stored at the location corresponding to the target write address in the shared disk array, thus obtaining the first query result. Then, based on the first query result, the target cache address is determined in the controller's local cache, and the target data is written to that target cache address.
[0038] It should be noted that the target write address and the first storage address are actually the same. The target write address refers to the address where the target data is to be written in the shared disk array. After the target data is actually written to the target write address, the address becomes the storage address of the target data.
[0039] Specifically, determining the target cache address in the cache based on the first query result includes: if a first storage address corresponding to the target write address exists in the cache address mapping table, then the first cache address matching the first storage address is obtained from the cache address mapping table, and the first cache address is used as the target cache address; if a first storage address corresponding to the target write address does not exist in the cache address mapping table, then an idle cache address is obtained, and the idle cache address is used as the target cache address, and a mapping relationship between the first storage address and the idle cache address is established in the cache address mapping table.
[0040] In one specific implementation, if a first storage address corresponding to the target write address exists in the cache address mapping table, it indicates that historical data has already been stored at the location corresponding to the target write address in the shared disk array, and this historical data is also already in the cache, meaning that the current operation is an overwrite of existing data. Therefore, this embodiment needs to obtain a first cache address matching the first storage address from the cache address mapping table, i.e., a first cache address that has a mapping relationship with the first storage address, and then use the first cache address as the target cache address to prepare for overwrite writing.
[0041] In another specific implementation, if the cache address mapping table does not contain a first storage address corresponding to the target write address, it indicates that the location corresponding to the target write address in the shared disk array is not stored. Therefore, it is necessary to request the cache to allocate new space, i.e., obtain a free cache address, and use the free cache address as the target cache address. Furthermore, after the target data is written to the target cache address, a mapping relationship between the first storage address and the free cache address needs to be established in the cache address mapping table, that is, a mapping relationship between the target write address and the free cache address needs to be established.
[0042] Furthermore, it should be noted that the cache address mapping table is constructed based on a hash table. The cache address mapping table includes at least two hash buckets, and each hash bucket is pre-assigned a corresponding number. Accordingly, the mapping relationship between the first storage address and the free cache address is established in the cache address mapping table, including: performing a hash calculation on the first storage address to obtain the target hash key; traversing each hash bucket in the cache address mapping table to determine the target hash bucket whose hash bucket number matches the target hash key; and storing the mapping relationship between the first storage address and the free cache address in the target hash bucket. In this embodiment, in order to quickly retrieve a certain mapping information, the massive mapping information in the cache is organized in the form of a hash table. It should be noted that for the query speed of a single cache data block, the time complexity can be O(1) in the absence of hash collisions, and the hash table is simple to implement and easy to maintain later. Furthermore, the hash bucket is the basic storage unit in the hash table. The cache address mapping table of this application includes at least two hash buckets, and each hash bucket is pre-assigned a corresponding number (i.e., bucket 0 - bucket n), such as Figure 7 As shown in the diagram. The hash bucket is primarily used to store cached mapping information that yields the same hash key after being calculated using a hash function. If a hash collision occurs, the conflicting mapping information will be linked together in the same hash bucket, thus ensuring retrieval efficiency.
[0043] Therefore, when establishing the mapping relationship between the first storage address and the free cache address in the cache address mapping table, this application can first use a hash function to perform hash calculation on the first storage address to obtain the target hash key, and then traverse each hash bucket in the cache address mapping table to determine the target hash bucket whose hash bucket number matches the target hash key, and then store the mapping relationship between the first storage address and the free cache address in the target hash bucket.
[0044] It should also be noted that the shared disk array is pre-divided into a predetermined number of logical volumes, and each logical volume is pre-divided into at least two data blocks. Each logical volume corresponds to a different number, each data block is the same size, and each data block is pre-numbered in ascending order of address. Correspondingly, the storage address in the shared disk array recorded in the cache address mapping table is the logical volume location determined based on the logical volume number and the data block number.
[0045] It's understandable that when a host application accesses a storage array, it does so through LUNs (Logical Unit Numbers, or logical volumes in storage) mapped to the host. That is, the storage system partitions physical disks (or disk arrays) into logical volumes as needed. A logical volume can correspond to a single physical disk, or it can be a virtual storage space created by a RAID group composed of multiple physical disks. These are storage units that the host can directly see and access. Disk arrays do not allow the host to directly access the underlying physical storage media (such as a single hard drive or SSD). Instead, they allocate the partitioned logical storage resources (i.e., logical volumes) to specific hosts or host groups through LUN mapping. Therefore, as... Figure 7 As shown, this embodiment divides the shared disk array into multiple logical volumes, each with a different number, such as LUN0, LUN1, etc. Furthermore, the address space of each LUN is also divided into multiple data blocks (tracks), for example, using a 32K granularity. Each 32K data block is called a data block, and these data blocks are numbered sequentially from smallest to largest address (0, 1, 2, ...). Figure 7 As shown in the diagram, the data address can be accurately identified by LUN ID + Track ID. If the cache contains information about a certain data block, a mapping relationship of (LUN ID + Track ID → cache address) will be generated.
[0046] It should also be pointed out that, such as Figure 8As shown, in a dual-controller storage array, each controller internally stores the aforementioned hash table to store mapping information for cached data on its local node. If a data block X is written from the first controller, the first controller, while writing to its own cache, simultaneously mirrors data block X to the second controller. The second controller then writes the data to its own cache. Both controllers will store the same data mapping information in their local hash tables.
[0047] Furthermore, the process of querying the cache address mapping table to determine if a first storage address corresponding to the target write address exists includes: parsing the target write address to obtain the target logical volume number and logical block start address; determining the target data block number based on the logical block start address and the data block size; determining the target logical volume location based on the target logical volume number and the target data block number; and querying the cache address mapping table to determine if the target logical volume location exists. In other words, when a host accesses data on a logical volume, it sends the logical volume number to be accessed and the block start address (LBA) of the logical volume to be accessed to the storage system via the storage protocol. Upon receiving the request, the storage system parses the logical volume number and logical block start address to be accessed, and then queries the cache to determine if the data to be accessed exists. Specifically, this application determines the target data block number based on the logical block start address and the data block size, for example, by dividing the LBA by 32KB to calculate the target data block number (i.e., Track ID). In this way, the target logical volume location can be determined based on the target logical volume number and the target data block number, and the cache address mapping table can be consulted to determine if the target logical volume location exists.
[0048] In a specific implementation, a notification message carrying a target data identifier is sent to the second controller via the target communication link to notify the second controller to delete the old cached data corresponding to the target data identifier in the second cache. This includes: sending a notification message carrying a target write address to the second controller via the target communication link, so that the second controller can parse the target write address from the notification message and query its local cache address mapping table to see if there is a second storage address corresponding to the target write address; if there is a second storage address corresponding to the target write address in the second controller's cache address mapping table, the second controller obtains the second cache address matching the second storage address from its local cache address mapping table to delete the old cached data stored in the second cache address, and deletes the mapping relationship between the second storage address and the second cache address in its local cache address mapping table; if there is no second storage address corresponding to the target write address in the second controller's cache address mapping table, no processing is performed.
[0049] In other words, when the second controller receives a notification message carrying the target write address, it first parses the target write address from the notification message, and then checks its local cache address mapping table to see if a second storage address corresponding to the target write address exists. If it exists, it indicates that the second controller has cached data at the corresponding address. Therefore, the second controller needs to retrieve the second cache address matching the second storage address from its local cache address mapping table to delete the old cached data stored at the second cache address, and delete the mapping relationship between the second storage address and the second cache address from its local cache address mapping table. If the second controller's cache address mapping table does not contain a second storage address corresponding to the target write address, no processing is required.
[0050] Furthermore, this application also discloses a process for processing read requests. The above method further includes: parsing the read request sent by the target host to obtain the target read address; querying the cache address mapping table to find whether there is a third storage address corresponding to the target read address, and obtaining a second query result; reading data based on the second query result, and returning the read data to the target host.
[0051] In other words, when a read request is received, the target read address is first parsed, and then the cache address mapping table is checked to see if a third storage address corresponding to the target read address exists, thus obtaining the second query result. It should be noted that the values of the target read address and the third storage address are actually the same. The target read address refers to the address of the data to be read in the shared disk array. If the data has already been written to the shared disk array, then the target read address is the storage location of the data in that disk array. Then, this application reads the data based on the second query result and returns the read data to the target host.
[0052] Specifically, reading data based on the second query result includes: if a third storage address corresponding to the target read address exists in the cache address mapping table, then the third cache address matching the third storage address is obtained from the cache address mapping table, and data is read from the third cache address; if no third storage address corresponding to the target read address exists in the cache address mapping table, then data is read from the shared disk array. That is, if a third storage address corresponding to the target read address exists in the cache address mapping table, it means that the data to be read has already been written to the cache, therefore the third cache address matching the third storage address is obtained from the cache address mapping table, and then data is read directly from the third cache address; conversely, if no third storage address corresponding to the target read address exists in the cache address mapping table, it means that the data has not been written to the cache, therefore data still needs to be read from the shared disk array.
[0053] As can be seen from the above scheme, this application supports a cache mapping data organization method for high-speed lookup. The space on the logical volume is divided into data blocks according to a certain size granularity. The cached data is organized into a hash table according to the data block granularity, which facilitates fast lookup. Both dual-controller storage arrays maintain a local cache address mapping table to store mapping information.
[0054] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0055] See Figure 9 As shown, an embodiment of this application provides a data caching device, applied to a first controller in a storage system, the storage system further including a second controller, the device comprising: The request acquisition module 11 is used to acquire write requests carrying target data sent by the target host; The judgment module 12 is used to respond to write requests, write the target data into the first cache, and determine whether the size of the target data is greater than a preset threshold; the first cache is the cache of the first controller; The first strategy execution module 13 is used to execute the first mirror caching strategy if the target data is not greater than a preset threshold, so as to transmit the target data to the second controller through the target communication link and write it into the second cache; the second cache is the cache of the second controller. The second strategy execution module 14 is used to write the target data to the shared disk array if the target data exceeds a preset threshold, and execute the second mirror caching strategy to send a notification message carrying the target data identifier to the second controller through the target communication link, so as to notify the second controller to delete the old cached data corresponding to the target data identifier in the second cache; the target data identifier is the data identifier of the target data.
[0056] As can be seen, this application adaptively selects either a first or second mirror caching strategy by determining whether the size of the target data exceeds a preset threshold. Specifically, for small data block writes not exceeding the preset threshold, traditional synchronous mirroring is used, writing the target data to both the local cache of the first controller and the local cache of the second controller, ensuring real-time synchronization of the dual-controller caches and guaranteeing immediate data redundancy and low latency. For large data block writes exceeding the preset threshold, the data is written to the shared disk array, and the second controller is notified to delete any existing old cached data. This mechanism ensures that even in large data block write mode, the entire system maintains data consistency, preventing the host from reading expired data from the second controller. Furthermore, since the data is persisted to the shared disk, even if a single controller fails after sending an invalidation message, the data will not be lost, ensuring system reliability. In other words, under the second mirror caching strategy, this application only notifies the second controller to clear invalid caches while directly writing the data to the shared disk array, greatly reducing the bandwidth consumption of the inter-controller interconnection link, thereby overcoming the bandwidth bottleneck of the target communication link. This solution enables the system to efficiently serve two distinct business workloads simultaneously: low-latency transaction processing and high-throughput sequential writes.
[0057] For a description of the features in the embodiment corresponding to the data caching device, please refer to the relevant description in the embodiment corresponding to the data caching method, which will not be repeated here.
[0058] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above-described data caching method embodiments.
[0059] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described data caching method embodiments at runtime.
[0060] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0061] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data caching method embodiments.
[0062] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data caching method embodiments.
[0063] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0064] The data caching method and device provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A data caching method, characterized in that, A first controller applied in a storage system, the storage system further including a second controller, the method comprising: Obtain the write request sent by the target host that carries the target data; In response to the write request, the target data is written to the first cache, and it is determined whether the size of the target data is greater than a preset threshold; the first cache is the cache of the first controller; If the value is not greater than the preset threshold, the first mirror caching strategy is executed to transmit the target data to the second controller via the target communication link and write it into the second cache; the second cache is the cache of the second controller. If the value exceeds the preset threshold, the target data is written to the shared disk array, and the second mirror caching strategy is executed to send a notification message carrying the target data identifier to the second controller through the target communication link, so as to notify the second controller to delete the old cached data corresponding to the target data identifier in the second cache; the target data identifier is the data identifier of the target data.
2. The data caching method according to claim 1, characterized in that, The target data identifier is the target write address of the target data in the shared disk array. Both the first controller and the second controller maintain a cache address mapping table. The cache address mapping table is used to record the mapping relationship between the storage address of the data in the shared disk array and the cache address in the cache. Accordingly, the process of any controller writing the target data into the cache includes: Query the cache address mapping table to see if there is a first storage address corresponding to the target write address, and obtain the first query result; Based on the first query result, the target cache address is determined in the cache, and the target data is written to the target cache address.
3. The data caching method according to claim 2, characterized in that, Determining the target cache address in the cache based on the first query result includes: If a first storage address corresponding to the target write address exists in the cache address mapping table, then the first cache address matching the first storage address is obtained from the cache address mapping table, and the first cache address is used as the target cache address; If there is no first storage address corresponding to the target write address in the cache address mapping table, then an idle cache address is obtained, and the idle cache address is used as the target cache address. A mapping relationship between the first storage address and the idle cache address is established in the cache address mapping table.
4. The data caching method according to claim 3, characterized in that, The cache address mapping table is constructed based on a hash table, and the cache address mapping table includes at least two hash buckets, each hash bucket being pre-assigned a corresponding number. Accordingly, establishing the mapping relationship between the first storage address and the free cache address in the cache address mapping table includes: Perform a hash calculation on the first storage address to obtain the target hash key; Traverse each hash bucket in the cache address mapping table to determine the target hash bucket whose hash bucket number matches the target hash key; The mapping relationship between the first storage address and the free cache address is stored in the target hash bucket.
5. The data caching method according to claim 2, characterized in that, The step of sending a notification message carrying a target data identifier to the second controller via the target communication link to notify the second controller to delete the old cached data corresponding to the target data identifier in the second cache includes: The target communication link sends a notification message carrying the target write address to the second controller, so that the second controller can parse the target write address from the notification message and query the local cache address mapping table to see if there is a second storage address corresponding to the target write address. If the cache address mapping table of the second controller contains a second storage address corresponding to the target write address, then the second controller obtains the second cache address matching the second storage address from the local cache address mapping table to delete the old cache data stored in the second cache address, and deletes the mapping relationship between the second storage address and the second cache address in the local cache address mapping table. If the second controller's cache address mapping table does not contain a second storage address corresponding to the target write address, no action is taken.
6. The data caching method according to claim 2, characterized in that, The shared disk array is pre-divided into a predetermined number of logical volumes, and each logical volume is pre-divided into at least two data blocks; wherein, each logical volume corresponds to a different number, each data block is the same size, and each data block is pre-numbered in ascending order of address. Accordingly, the storage addresses in the shared disk array recorded in the cache address mapping table are logical volume locations determined based on logical volume numbers and data block numbers.
7. The data caching method according to claim 6, characterized in that, The query to check whether there exists a first storage address corresponding to the target write address in the cache address mapping table includes: Parse the target write address to obtain the target logical volume number and logical block start address; The target data block number is determined based on the logical block start address and the data block size; The location of the target logical volume is determined based on the target logical volume number and the target data block number, and the location of the target logical volume is checked in the cache address mapping table.
8. The data caching method according to claim 2, characterized in that, Also includes: The read request sent by the target host is parsed to obtain the target read address; Query the cache address mapping table to see if there is a third storage address corresponding to the target read address, and obtain the second query result; Data is read based on the second query result and returned to the target host.
9. The data caching method according to claim 8, characterized in that, The step of reading data based on the second query result includes: If a third storage address corresponding to the target read address exists in the cache address mapping table, then a third cache address matching the third storage address is obtained from the cache address mapping table, and data is read from the third cache address; If there is no third storage address corresponding to the target read address in the cache address mapping table, then the data is read from the shared disk array.
10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data caching method as described in any one of claims 1 to 9 when executing the computer program.
Citation Information
Patent Citations
Data processing method and device on multi-control storage system
CN110928496A
Data read-write request processing method, electronic equipment, storage medium and program product
CN120233958A
Data transmission method and electronic equipment
CN120973705A