Data access method and device
By setting up a cache device in the host and processing write requests, calculating hash values and recording cache addresses, the problem of low efficiency of HDD storage media is solved and the efficiency and acceleration effect of data writing are significantly improved.
Patent Information
- Application Number
- CN202410807200.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-10-22
AI Technical Summary
The existing distributed file system uses HDD as the data storage medium, which results in data writing needing to go through all the IO processes of the back-end storage and the iSCSI protocol layer, resulting in low efficiency and poor acceleration.
Set up a cache device in the host, calculate the hash value after receiving the write request, write the data to the cache device and record the hash value and cache address, and finally send the data and back-end storage address to the back-end storage system. In this way Speed up the data writing process.
By setting the cache device in the host, the cache usage efficiency is improved, the acceleration effect is significantly improved, the network crossing and protocol layer processing during data writing are reduced, and the read and write performance is improved.
Smart Images

Figure CN118819409A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data access method and device. Background Art
[0002] iSCSI (Internet Small Computer System Interface) is a remote storage protocol. The host can connect to the iSCSI-based distributed file system through the iSCSI initator tool, and form a corresponding system data block (sdb) on the host to allocate to the virtual machine.
[0003] The distributed file system of the related technology uses HDD (Hard Disk Drive) as the data storage medium, and the reading and writing speed is slow. For this reason, SSD (Solid State Drive) can be added to the distributed file system as a cache device for acceleration, that is, before the data is written to the HDD, it is first written to the SSD, and then flushed from the SSD to the HDD according to a certain strategy. The problem with this method is that the data needs to go through all the IO (input and output) processes of the backend storage before being written to the SSD, and it also needs to go through the iSCSI protocol layer, so the efficiency is relatively low and the acceleration effect is poor. Summary of the invention
[0004] To overcome the problems existing in the related art, this specification provides a data access method and device.
[0005] According to a first aspect of an embodiment of the present specification, there is provided a data access method, which is applied to a host, wherein the host includes a first cache device, and the method includes: receiving a write request, wherein the write request includes data to be written and a first back-end storage address; calculating a first hash value according to a cache identifier and the first back-end storage address; writing the data to be written to the first cache device to obtain a first cache address of the data to be written in the first cache device; writing the first hash value and the first cache address into a memory; and sending the data to be written in the first cache device and the first back-end storage address to a back-end storage system.
[0006] According to a second aspect of an embodiment of the present specification, there is provided a data access apparatus, which is applied to a host, wherein the host includes a first cache device, including: a write request receiving module, for receiving a write request, wherein the write request includes data to be written and a first back-end storage address; a first hash calculation module, for calculating a first hash value according to a cache identifier and the first back-end storage address; a first cache write module, for writing the data to be written into the first cache device, and obtaining a first cache address of the data to be written in the first cache device; a first memory write module, for writing the first hash value and the first cache address into a memory; and a sending module, for sending the data to be written in the first cache device and the first back-end storage address to a back-end storage system.
[0007] According to a third aspect of an embodiment of this specification, a data access device is provided, including:
[0008] processor;
[0009] a memory for storing processor-executable instructions;
[0010] Wherein, the processor is configured to: receive a write request, the write request including the data to be written and a first back-end storage address; calculate a first hash value according to the cache identifier and the first back-end storage address; write the data to be written into the first cache device to obtain the first cache address of the data to be written in the first cache device; write the first hash value and the first cache address into the memory; send the data to be written in the first cache device and the first back-end storage address to the back-end storage system.
[0011] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0012] In the embodiments of this specification, by setting the cache device in the host, cache acceleration can be brought closer to the computing side, thereby improving the cache usage efficiency and achieving a better acceleration effect.
[0013] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.
[0015] Figure 1 It is a schematic diagram of a system architecture shown in this specification according to an exemplary embodiment.
[0016] Figure 2It is a flow chart of a data access method shown in this specification according to an exemplary embodiment.
[0017] Figure 3 It is a flowchart of another data access method according to an exemplary embodiment of this specification.
[0018] Figure 4 It is a hardware structure diagram of the computer device where the file processing device in the embodiment of this specification is located.
[0019] Figure 5 It is a block diagram of a data access device according to an exemplary embodiment of the present specification. DETAILED DESCRIPTION
[0020] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.
[0021] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0022] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0023] Next, the embodiments of this specification are described in detail.
[0024] The following combination Figure 1 The system architecture to which the data access method and device in the embodiments of this specification can be applied is described. It should be noted that: Figure 1What is shown is merely an example of a system architecture to which the embodiments of this specification can be applied, to help those skilled in the art understand the technical content of this specification, but it does not mean that the embodiments of this specification cannot be used in other devices, systems, environments or scenarios.
[0025] Figure 1 It is a schematic diagram of a system architecture shown in this specification according to an exemplary embodiment.
[0026] like Figure 1 As shown, the system architecture may include, for example, a backend storage system, a host, a primary cache device, and a secondary cache device. Among them, the secondary cache device may be one or more. The backend storage system may be a distributed file system, such as Ceph. The backend storage system may include multiple LUNs (Logical Unit Numbers), each of which is an independent logical unit in the storage device and can be identified and accessed by an operating system or application. The host may include a virtual machine. The primary cache device and the secondary cache device may be high-speed memories, such as SSDs. The primary cache device may be located in the host. The secondary cache device may be located in the host, or the secondary cache device may be located outside the host and connected to the host via a network.
[0027] Exemplarily, in this embodiment, the backend storage system may include LUN1 and LUN2. The host may include host 1 and host 2, for example. Host 1 may include virtual machine VM1, a primary cache device (used to store the master copy of cache1), and a secondary cache device (used to store the copy of cache1). Host 1 may include virtual machine VM2, a primary cache device (used to store the master copy of cache2), and a secondary cache device (used to store the copy of cache1).
[0028] The data access method provided in the embodiments of this specification is described in detail below. Figure 2 As shown, Figure 2 The flowchart of a data access method according to an exemplary embodiment of the present specification is shown, and the method can be applied to a host, and the host can include a first cache device. The data access method provided in the embodiment of the present specification can include the following steps.
[0029] In step 210, a write request is received, where the write request includes data to be written and a first backend storage address.
[0030] According to an embodiment of the present specification, a write request may be used to request a data write operation. Optionally, a virtual machine may be deployed in the host. When a user wants to store data, the virtual machine may be used to perform a data write operation, and the virtual machine may generate a write request in response to the operation.
[0031] According to an embodiment of the present specification, the data to be written may include text, audio, video, executable file, etc. The present specification does not specifically limit the type of data to be written.
[0032] According to an embodiment of the present specification, the backend storage address may represent the storage location of the data to be written in the backend storage system. Exemplarily, the backend storage address may include, for example, the location offset of the data to be written in the backend storage system.
[0033] In step 220, a first hash value is calculated according to the cache identifier and the first backend storage address.
[0034] According to an embodiment of the present specification, each data may correspond to a cache unit in a cache device. A cache identifier may be used to identify a cache unit. In order to improve data reliability, a cache unit may have multiple copies, and the multiple copies correspond to the same cache identifier.
[0035] According to an embodiment of the present specification, for example, a hash function may be applied to the cache identifier and the first backend storage address to generate a hash value, ie, a first hash value. Exemplarily, the hash function may include MD5, SHA-1, SHA-256, and the like.
[0036] In step 230, the data to be written is written into the first cache device, and a first cache address of the data to be written in the first cache device is obtained.
[0037] According to an embodiment of the present specification, the first cache address may represent a storage location of the to-be-written data in the first cache device. Exemplarily, the first cache address may include, for example, a location offset of the to-be-written data in the first cache device.
[0038] In step 240, the first hash value and the first cache address are written into the memory.
[0039] In step 250, the data to be written in the first cache device and the first back-end storage address are sent to the back-end storage system.
[0040] According to an embodiment of the present specification, after receiving the data to be written and the first back-end storage address, the back-end storage system may store the data to be written according to the first back-end storage address.
[0041] According to an embodiment of the present specification, each time data is written to the first cache device, the data and the corresponding backend storage address can be sent to the backend storage system. Alternatively, it is also possible to periodically check whether there is new data written to the first cache device, and send each data written in this period and the corresponding backend storage address to the backend storage system.
[0042] The cache device of the related technology is set in the backend storage system. Before writing the cache device, the data needs to go through all the IO (input and output) processes of the backend storage and also needs to go through the iSCSI protocol layer. Therefore, the efficiency is relatively low and the acceleration effect is poor.
[0043] According to the embodiments of the present specification, by setting the cache device in the host, cache acceleration can be brought closer to the computing side, thereby improving the cache usage efficiency and achieving a better acceleration effect.
[0044] In addition, the cache device and the virtual machine are located in the same host, which can ensure that the cache read and write processes do not cross the network, thereby improving the read and write performance.
[0045] like Figure 3 FIG. 1 is a flowchart of another data access method according to an exemplary embodiment of the present specification. Based on the above-mentioned embodiment, this embodiment describes a data reading process, including the following steps:
[0046] In step 310, a read request is received through the virtual machine, where the read request includes a second backend storage address of data to be read.
[0047] According to an embodiment of the present specification, when a user wants to read data, a virtual machine may be used to perform a data reading operation, and the virtual machine may generate a read request in response to the operation.
[0048] According to an embodiment of the present specification, the second backend storage address may represent a storage location of the to-be-read data in the backend storage system.
[0049] In step 320, a target hash value is calculated according to the cache identifier and the second backend storage address.
[0050] According to an embodiment of the present specification, a hash function may be applied to the cache identifier and the second backend storage address to generate a hash value, ie, a target hash value, wherein the hash function is the same as the hash function used when writing data.
[0051] In step 330, the target hash value is searched in the memory. If the target hash value exists in the memory, steps 340 to 350 are executed. If the target hash value does not exist in the memory, steps 360 to 370 are executed.
[0052] According to an embodiment of the present specification, if the target hash value exists in the memory, it means that there is data to be read in the cache device. If the target hash value does not exist in the memory, it means that there is no data to be read in the cache device.
[0053] In step 340, a target cache address in the memory corresponding to the target hash value is determined.
[0054] According to an embodiment of the present specification, the target cache address indicates a storage location of the to-be-read data in the first cache device.
[0055] In step 350, the to-be-read data is read from the first cache device according to the target cache address.
[0056] In step 360, a backend read request is sent to the backend storage system, where the backend read request includes the second backend storage address.
[0057] According to an embodiment of the present specification, after receiving the read request, the backend storage system can search for the data to be read according to the second backend storage address, and then send the data to be read to the host.
[0058] In step 370, the data to be read sent by the backend storage system is received.
[0059] According to an embodiment of the present specification, after receiving the data to be read sent by the backend storage system, the data to be read can be output through the virtual machine.
[0060] Optionally, the cache can be set with multiple copies, and reliability can be improved by multiple copies. Based on this, the host can include a primary cache device and a secondary cache device. The primary cache device can be used as a data cache of the backend storage system, and the secondary cache device can be used to replace the primary cache device when the primary cache device is abnormal. Exemplarily, in this embodiment, the host can include a first cache device and a second cache device, the first cache device can be used as a primary cache device, and the second cache device can be used as a secondary cache device.
[0061] Based on this, after receiving the write request, the data to be written can also be written into the second cache device to obtain the second cache address of the data to be written in the second cache device. Then, the second hash value can be calculated according to the second cache identifier of the second cache device and the first backend storage address. The second hash value and the second cache address are written into the memory. In this way, the data can be stored in the first cache device and the second cache device at the same time, so that when the state of the first cache device is abnormal, the data can be read from the second cache device. It can be understood that the method of reading data from the second cache device can refer to the method of reading data from the first cache device, and will not be repeated here.
[0062] Optionally, the master-copy attribute can be used to distinguish between the primary cache device and the secondary cache device. For example, in this embodiment, the master-copy attribute of the first cache device can be set to master-copy, indicating that the first cache device is used as the primary cache device. The master-copy attribute of the second cache device can be set to copy, indicating that the second cache device is used as the secondary cache device.
[0063] Optionally, a first table entry may be generated according to the primary copy attribute of the first cache device, the first cache address and the first hash value, and the first table entry may be written into the memory. A second table entry may be generated according to the primary copy attribute of the second cache device, the second cache address and the second hash value, and the second table entry may be written into the memory.
[0064] Based on this, when it is necessary to store the data to be written in the back-end storage system, for each first table entry in the memory, the data to be stored in the first cache device can be read according to the first cache address in the first table entry, and the read data to be written and the first back-end storage address in the first table entry can be sent to the back-end storage system.
[0065] In addition, in the process of reading data, when determining the target cache address corresponding to the target hash value in the memory, the original table item containing the target hash value in the memory can be searched. If there is one original table item and the master copy attribute in the original table item is the master copy, the cache address in the original table item is determined as the target cache address. If there are multiple original table items, the target table item whose master copy attribute is the master copy is filtered out from the multiple original table items, and the cache address in the target table item is used as the target cache address.
[0066] Optionally, the operating state of the first cache device may be detected. If an abnormality is detected in the operating state of the first cache device, the first table entry in the memory is deleted, and the master copy attribute of the second table entry in the memory is set to the master copy, so that the second cache device replaces the first cache device as the master cache device.
[0067] Optionally, the metadata may be organized in the memory in a hash linked list manner, for example, and each row of the metadata is a table entry of cache data. The metadata is shown in Table 1, where N is a positive integer.
[0068] Table 1
[0069]
[0070] As shown in Table 1, the metadata may include fields such as Hash Key, cache identifier, primary copy attribute, cache address, backend storage address, whether the backend has been flushed, and location attribute.
[0071] The Hash Key is a hash value, which can be calculated based on the cache identifier and the backend storage address.
[0072] The cache identifier can identify which data lun the cache unit cache corresponds to, and each data lun that needs to be cached is assigned a cache identifier. Exemplarily, the cache identifier can include a cache number, for example.
[0073] The master-copy attribute represents whether the current cache is a master copy or a copy. In this embodiment, data is read from the master copy first and then flushed to the backend storage device.
[0074] The cache address may indicate the offset of the data in the cache device.
[0075] The backend storage address may represent the offset of the data corresponding to the backend storage data lun.
[0076] The "Whether the backend has been flushed" field is used to indicate whether the data has been flushed to the backend storage system. If the data has been flushed, the entry can be deleted from the cache. Otherwise, the entry cannot be deleted.
[0077] The location attribute can indicate the cache location. If the location attribute is local, it means that a cache is available locally. If it is remote, it means that a cache is available remotely.
[0078] The data access method is described below in conjunction with specific embodiments.
[0079] Illustratively, in this embodiment, each data lun has a cache lun on the cache device, named CacheX, where X can be any number.
[0080] The cache LUN may use multiple copies to achieve data reliability. For example, in this embodiment, two copies may be used, one of which is the primary copy and the other is the copy.
[0081] You can set a custom interface for the virtual machine to access the cache device for read and write operations. By using a custom interface, you can improve efficiency.
[0082] In this embodiment, the first cache device may be a cache device in a host, and the host may include a master cache processing module. The second cache device may be a cache device in another host other than the host, and the other host may include a replica cache processing module. The first cache device and the second cache device may be SSDs. The backend storage system may include a backend storage processing module. The backend storage system may be a ceph system.
[0083] The following embodiment, based on the above embodiment, describes a process of writing data into a cache device, including the following steps:
[0084] The master cache processing module receives write requests from the upper virtual machine.
[0085] The master cache processing module obtains the backend storage address from the write request and calculates the hash value HASH key according to the cache identifier and the backend storage address.
[0086] The master cache processing module writes data to the first cache disk in the host and records the cache address;
[0087] The master cache processing module organizes cache entries, sets the cache status therein to local, adds the cache entries to the memory, generates metadata, and persists the metadata to the first cache disk corresponding to the master cache processing module.
[0088] The cache processing module of the first cache device sends a synchronization command synccache to the replica cache processing modules of other hosts. The synchronization command sync cache may include a command word: sync cache, and command parameters: a cache identifier, cached data, and a backend storage address.
[0089] The replica cache processing module receives a synchronization command sync cache and synchronization content.
[0090] The copy cache processing module writes data to the second cache device of the host and records the cache address;
[0091] The replica cache processing module calculates the HASH key according to the cache identifier and the backend storage address, organizes the cache table entries, sets the cache status in the table entries to remote, adds the cache table entries to the memory, generates metadata, and persists the metadata to the first cache device of the host where the primary cache processing module is located.
[0092] The replica cache processing module sends a success response sync cache to the primary cache processing module. The successful response sync cache may include a command word: sync cache finish, and command parameters: the cache identifier and the backend storage address.
[0093] The master cache processing module returns the success of the storage write operation to the upper-level virtual machine.
[0094] The following embodiment describes a processing process for reading data based on the above embodiment, including the following steps:
[0095] The master cache processing module receives read requests from the upper virtual machine;
[0096] The master cache processing module obtains the backend storage address from the read request and calculates the HASH key according to the cache identifier and the backend storage address.
[0097] The master cache processing module searches for the corresponding entry from the metadata linked list according to the HASH key. If found, it directly reads data from the cache device according to the cache address in the entry and returns it to the upper virtual machine.
[0098] If no corresponding table entry is found, the master cache processing module sends a read command iSCSI operate to the backend storage. The read command iSCSI operate may include a command word: iSCSI read, and a command parameter: backend storage address.
[0099] The master cache processing module receives the data returned by the backend storage and returns it to the upper layer business.
[0100] The following embodiment, based on the above embodiment, describes a process of flushing data in the cache to the backend storage system, including the following steps:
[0101] The master cache processing module traverses each table item in the entire metadata linked list. For each table item in the linked list, the master cache processing module sends a data flush command to the backend storage system. The data flush command may include a command word: flush cache, and command content: cache address, physical address of cache data.
[0102] The backend storage processing module receives the synchronization command flush cache command and cache data.
[0103] The back-end storage processing module writes the cache data according to the physical address and returns a write success response to the primary cache processing module through the iSCSI protocol.
[0104] The master cache processing module modifies the backend flag of the metadata whether it has been flushed, marks it as flushed, and synchronizes it to the replica cache processing module, which also marks the backend flag whether it has been flushed as flushed.
[0105] The following embodiment, based on the above embodiment, describes a process of flushing data in the cache to the backend storage system, including the following steps:
[0106] The master cache processing module periodically detects the status of the cache device. If it finds that the status of the master cache device is abnormal, it initiates a switch and notifies the replica cache processing module to upgrade the corresponding replica to the master.
[0107] The master cache processing module applies the bypass cache strategy. When the status of the master cache device is abnormal, new write operations are directly performed by the backend storage system. New read operations are redirected to the replica cache processing module for processing.
[0108] The replica cache processing module initiates the replica upgrade process and flushes all unflushed data (also called dirty data) to the backend storage system. After the flush is completed, the master cache processing module is notified that the data flush is complete and the corresponding metadata table entries are cleared.
[0109] The master cache processing module clears all metadata entries.
[0110] Corresponding to the embodiments of the aforementioned method, this specification also provides embodiments of a data access device and a terminal to which it is applied.
[0111] The embodiments of the data access device of this specification can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented by software, hardware, or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them. From the hardware level, if Figure 4 The figure is a hardware structure diagram of the computer device where the data access device of the embodiment of this specification is located, except Figure 4 In addition to the processor 410, memory 430, network interface 420, and non-volatile memory 440 shown, the server or electronic device where the device 431 is located in the embodiment may also include other hardware according to the actual function of the computer device, which will not be described in detail.
[0112] like Figure 5 As shown, Figure 5 1 is a block diagram of a data access device according to an exemplary embodiment of the present specification, the device can be applied to a host, and the device includes:
[0113] A write request receiving module 510, configured to receive a write request, wherein the write request includes data to be written and a first backend storage address;
[0114] A first hash calculation module 520, configured to calculate a first hash value according to a cache identifier and a first backend storage address;
[0115] A first cache writing module 530, used to write the data to be written into the first cache device, and obtain a first cache address of the data to be written in the first cache device;
[0116] A first memory writing module 540, used to write the first hash value and the first cache address into the memory;
[0117] The sending module 550 is used to send the data to be written in the first cache device and the first back-end storage address to the back-end storage system.
[0118] Optionally, the device may further include:
[0119] A read request receiving module, used for receiving a read request, wherein the read request includes a second backend storage address of data to be read;
[0120] A target hash calculation module, used to calculate a target hash value according to the cache identifier and the second backend storage address;
[0121] A first reading module is used to determine a target cache address in the memory corresponding to the target hash value if the target hash value exists in the memory; and read the to-be-read data from the first cache device according to the target cache address;
[0122] The second reading module is used to send a backend reading request to the backend storage system if the target hash value does not exist in the memory, and the backend reading request includes a second backend storage address; and receive the data to be read sent by the backend storage system.
[0123] Optionally, the device may further include:
[0124] A second cache writing module, used to write the data to be written into the second cache device, and obtain a second cache address of the data to be written in the second cache device;
[0125] A second hash calculation module, used to calculate a second hash value according to a second cache identifier of a second cache device and a first backend storage address;
[0126] The second memory writing module is used to write the second hash value and the second cache address into the memory.
[0127] Optionally, the primary copy attribute of the first cache device is set to the primary copy; and the first memory writing module may include:
[0128] A first generating submodule, configured to generate a first table entry according to a primary and secondary attribute of a first cache device, a first cache address, and a first hash value;
[0129] The first writing submodule is used to write the first table entry into the memory.
[0130] Optionally, the master copy attribute of the second cache device is set to copy; the second memory writing module may include:
[0131] A second generating submodule, used to generate a second table entry according to the primary copy attribute of the second cache device, the second cache address, and the second hash value;
[0132] The second writing submodule is used to write the second table entry into the memory.
[0133] Optionally, the first reading module may include:
[0134] The search submodule is used to search the original table entry containing the target hash value in the memory;
[0135] A first determination submodule is used to determine the cache address in the original table entry as the target cache address if there is one original table entry and the primary copy attribute in the original table entry is the primary copy;
[0136] The second determination submodule is used for filtering out a target entry whose master copy attribute is the master copy from the multiple original entries if there are multiple original entries, and using the cache address in the target entry as the target cache address.
[0137] Optionally, the device may further include:
[0138] A checking module, used for detecting the operating status of the first cache device;
[0139] The switching module is used to delete the first table entry in the memory and set the master copy attribute of the second table entry in the memory to the master copy if it is detected that the operation state of the first cache device is abnormal.
[0140] Optionally, the sending module may include:
[0141] The sending submodule is used to read the data to be stored in the first cache device according to the first cache address in each first table entry in the memory, and send the read data to be written and the first backend storage address in the first table entry to the backend storage system.
[0142] Correspondingly, the present specification also provides a data access device, which includes a processor; a memory for storing processor executable instructions; wherein the processor is configured to: receive a write request, the write request includes data to be written and a first back-end storage address; calculate a first hash value based on a cache identifier and the first back-end storage address; write the data to be written into the first cache device to obtain a first cache address of the data to be written in the first cache device; write the first hash value and the first cache address into the memory; send the data to be written in the first cache device and the first back-end storage address to the back-end storage system.
[0143] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0144] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0145] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0146] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.
[0147] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
[0148] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.
Claims
1. A data access method, applied to a host, characterized in that: The host includes a first cache device, and the method includes: receiving a write request, wherein the write request includes data to be written and a first backend storage address; Calculate a first hash value according to the cache identifier and the first backend storage address; Writing the data to be written into a first cache device to obtain a first cache address of the data to be written in the first cache device; Writing the first hash value and the first cache address into a memory; The data to be written in the first cache device and the first back-end storage address are sent to a back-end storage system.
2. The method according to claim 1, characterized in that The method further comprises: receiving a read request, wherein the read request includes a second backend storage address of data to be read; Calculate a target hash value according to the cache identifier and the second backend storage address; If the target hash value exists in the memory, determining a target cache address in the memory corresponding to the target hash value; and reading the to-be-read data from the first cache device according to the target cache address; If the target hash value does not exist in the memory, a backend read request is sent to the backend storage system, where the backend read request includes the second backend storage address; and the to-be-read data sent by the backend storage system is received.
3. The method according to claim 2, characterized in that The method further comprises: Writing the data to be written into a second cache device to obtain a second cache address of the data to be written in the second cache device; Calculating a second hash value according to a second cache identifier of the second cache device and the first backend storage address; The second hash value and the second cache address are written into a memory.
4. The method according to claim 3, characterized in that The primary copy attribute of the first cache device is set to primary copy; Writing the first hash value and the first cache address into a memory includes: Generate a first table entry according to the primary copy attribute of the first cache device, the first cache address and the first hash value; The first table entry is written into the memory.
5. The method according to claim 4, characterized in that The master copy attribute of the second cache device is set to copy; Writing the second hash value and the second cache address into a memory comprises: Generate a second table entry according to the master copy attribute of the second cache device, the second cache address and the second hash value; The second table entry is written into the memory.
6. The method according to claim 5, characterized in that The determining a target cache address in the memory corresponding to the target hash value includes: Searching the memory for an original entry containing the target hash value; If there is one original entry and the master copy attribute in the original entry is master copy, determining the cache address in the original entry as the target cache address; If there are multiple original entries, a target entry whose master copy attribute is the master copy is selected from the multiple original entries, and the cache address in the target entry is used as the target cache address.
7. The method according to claim 5 or 6, characterized in that: The method further comprises: Detecting the operating status of the first cache device; If it is detected that the running state of the first cache device is abnormal, the first table entry in the memory is deleted, and the master copy attribute of the second table entry in the memory is set to the master copy.
8. The method according to claim 3, characterized in that The sending the to-be-written data in the first cache device and the first back-end storage address to the back-end storage system comprises: For each first table entry in the memory, the data to be stored in the first cache device is read according to the first cache address in the first table entry, and the read data to be written and the first backend storage address in the first table entry are sent to the backend storage system.
9. A data access device, applied to a host, characterized in that: The host includes a first cache device, and the apparatus includes: A write request receiving module, used for receiving a write request, wherein the write request includes data to be written and a first backend storage address; A first hash calculation module, used for calculating a first hash value according to a cache identifier and the first backend storage address; A first cache writing module, used for writing the data to be written into a first cache device, and obtaining a first cache address of the data to be written in the first cache device; A first memory writing module, used for writing the first hash value and the first cache address into a memory; A sending module is used to send the data to be written in the first cache device and the first back-end storage address to a back-end storage system.
10. The device according to claim 9, characterized in that The device also includes: A read request receiving module, used to receive a read request, wherein the read request includes a second backend storage address of data to be read; A target hash calculation module, used to calculate a target hash value according to the cache identifier and the second backend storage address; A first reading module, configured to determine a target cache address in the memory corresponding to the target hash value if the target hash value exists in the memory; and read the to-be-read data from the first cache device according to the target cache address; The second reading module is used to send a backend reading request to the backend storage system if the target hash value does not exist in the memory, and the backend reading request includes the second backend storage address; and receive the data to be read sent by the backend storage system.
11. The device according to claim 10, characterized in that The device also includes: A second cache writing module, used for writing the data to be written into a second cache device, and obtaining a second cache address of the data to be written in the second cache device; A second hash calculation module, configured to calculate a second hash value according to a second cache identifier of the second cache device and the first backend storage address; The second memory writing module is used to write the second hash value and the second cache address into the memory.
12. The device according to claim 11, characterized in that The primary copy attribute of the first cache device is set to primary copy; The first memory writing module comprises: A first generating submodule, configured to generate a first table entry according to a primary copy attribute of the first cache device, the first cache address, and the first hash value; The first writing submodule is used to write the first table entry into the memory.
13. The device according to claim 12, characterized in that The master copy attribute of the second cache device is set to copy; The second memory writing module comprises: A second generating submodule, configured to generate a second table entry according to the primary and secondary attributes of the second cache device, the second cache address and the second hash value; The second writing submodule is used to write the second table item into the memory.
14. The device according to claim 13, characterized in that The first reading module comprises: A search submodule, used to search the original table entry containing the target hash value in the memory; A first determination submodule is configured to determine a cache address in the original entry as the target cache address if there is one original entry and the primary copy attribute in the original entry is the primary copy; The second determining submodule is used for filtering out a target entry whose master copy attribute is the master copy from the multiple original entries if there are multiple original entries, and using the cache address in the target entry as the target cache address.
15. The device according to claim 13 or 14, characterized in that The device also includes: A checking module, used for detecting the operating status of the first cache device; The switching module is used to delete the first table entry in the memory and set the master copy attribute of the second table entry in the memory to the master copy if it is detected that the running state of the first cache device is abnormal.
16. The device according to claim 11, characterized in that The sending module comprises: The sending submodule is used to read the data to be stored in the first cache device for each first table entry in the memory according to the first cache address in the first table entry, and send the read data to be written and the first back-end storage address in the first table entry to the back-end storage system.
17. A data access device, characterized in that: The device comprises: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: receiving a write request, wherein the write request includes data to be written and a first backend storage address; Calculate a first hash value according to the cache identifier and the first backend storage address; Writing the data to be written into a first cache device to obtain a first cache address of the data to be written in the first cache device; Writing the first hash value and the first cache address into a memory; The data to be written in the first cache device and the first back-end storage address are sent to a back-end storage system.
