Data storage method, device, electronic device and storage medium
By virtualizing the physical disk of the remote target device into a local virtual disk and thread management based on the dependencies of data blocks, the problem of storage bottleneck in mobile terminals is solved, efficient data access and consistent write are achieved, and user experience and data throughput are improved.
Patent Information
- Application Number
- CN202110272092.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-12
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2041-03-12
AI Technical Summary
The storage bottleneck of mobile terminals has led to waste of network bandwidth resources and a decline in user experience, and the existing technology lacks an effective caching mechanism.
Virtualize the physical disk on the remote target device into the terminal's local virtual disk. By detecting the dependence of data blocks, the same thread or parallel thread writes back the data blocks to achieve fine-grained data access and consistent writing.
Improves data transmission rate and instant access efficiency of massive data, reduces response time and improves data throughput.
Smart Images

Figure CN115079932B_ABST
Abstract
Description
Background Art
[0002] As a key entry point for internet services, an important information service platform for new media and e-commerce, and a core hub for the interaction between IoT and network resources, mobile terminals have a profound impact on every aspect of our daily lives. With the development of 5G, artificial intelligence, and chip technologies, the network communication and information processing capabilities of mobile terminals have been significantly improved. However, storage bottlenecks remain a pressing issue.
[0003] In related technologies, terminal data is moved to a network disk for storage, and coarse-grained data access at the file level is achieved by accessing the network disk. However, due to the lack of an effective caching mechanism, this method not only wastes network bandwidth resources when accessing data, but also seriously affects the user experience.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure aims to provide a data storage method, apparatus, electronic device and computer-readable storage medium, which can at least to some extent improve the system overhead and the problem of long request time caused by the methods in the related art.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by practice of the present disclosure.
[0007] According to a first aspect of the present disclosure, a data storage method is provided, comprising: sending authentication information to a target device, and receiving device information fed back by the target device based on the authentication information; mapping the target device to a local virtual disk of the terminal based on the device information; receiving a first data block and a second data block to be stored, and detecting whether the receiving time of the first data block and the second data block satisfies a dependency relationship; when it is detected that the receiving time of the first data block and the second data block satisfies the dependency relationship, based on the dependency relationship and the mapping relationship between the local virtual disk and the target device, using the same thread to write the first data block and the second data block back to the target device; when it is detected that the receiving time of the first data block and the second data block does not satisfy the dependency relationship, based on the mapping relationship, using parallel threads to write the first data block and the second data block back to the target device.
[0008] In one embodiment, detecting whether the reception times of the first data block and the second data block satisfy a dependency relationship includes: detecting whether the completion caching time of the first data block is earlier than the start caching time of the second data block, so as to determine that the dependency relationship is satisfied between the first data block and the second data block when it is detected that the completion caching time is earlier than the start caching time, and determining that the dependency relationship is not satisfied between the first data block and the second data block when it is detected that the completion caching time is not earlier than the start caching time.
[0009] In one embodiment, when it is detected that the completion caching time is earlier than the start caching time, it further includes: generating a first node based on the write operation of the first data block, and generating a second node based on the write operation of the second data block; constructing a directed edge from the first node to the second node, so as to generate a dependency graph based on the first node, the second node and the directed edge, and the dependency graph is used to represent the dependency relationship.
[0010] In one embodiment, writing the first data block and the second data block back to the target device based on the dependency relationship and the mapping relationship between the local virtual disk and the target device includes: encapsulating the first data block, the second data block and the corresponding write-back instruction into a protocol data unit; configuring the same thread based on the dependency relationship; and determining the storage addresses of the first data block and the second data block in the target device based on the mapping relationship; sending the protocol data unit to the target based on the same thread and the storage addresses to perform the write-back operations of the first data block and the second data block.
[0011] In one embodiment, metadata is stored in the memory of the terminal; mapping the target device as the local virtual disk of the terminal based on the device information includes: establishing a hash mapping relationship between the metadata and the block storage area stored in the target device based on the device information; establishing a linear mapping relationship between the metadata and the block storage area of the local cache; and mapping the target device as the local virtual disk by the disk drive based on the hash mapping relationship and the linear mapping relationship.
[0012] In one embodiment, the device information includes disk array information, and mapping the target device as the local virtual disk by the disk drive includes: mapping out a plurality of data block virtual units based on the many-to-many mapping relationship and the disk array information, so as to construct the local virtual disk based on the plurality of data block virtual units.
[0013] In one embodiment, the mapping of the target device to the local virtual disk by the disk drive based on the hash mapping relationship and the linear mapping relationship further includes: in response to the device information, invoking a detection function to perform a detection operation on the device information; transmitting the detection result of the detection operation to the disk drive; and the disk drive generating a mapping relationship between the disk logical address and the physical address based on the hash mapping relationship and the linear mapping relationship, so as to map the target device to the local virtual disk based on the mapping relationship.
[0014] In one embodiment, the sending of the authentication information to the target device includes: performing a classification transmission process on the authentication information based on a preset security protocol, and sending the processed authentication information to the target device.
[0015] In one embodiment, the writing back of the first data block and the second data block to the target device further includes: writing back the first data block and the second data block to the target device based on the Internet Small Computer System Interface (iSCSI) protocol.
[0016] In one embodiment, it further includes: sending an empty transmission instruction to the target device according to a preset detection frequency; when it is determined that the connection with the target device is abnormal based on the empty transmission instruction, re-sending the authentication information to the target device to establish a communication connection with the target device.
[0017] According to a second aspect of the present disclosure, there is provided a data storage method, including: performing a verification operation on the authentication information sent by the terminal; when the authentication information is verified, sending device information to the terminal, so that the terminal maps the target device to the local virtual disk of the terminal based on the device information; and receiving the first data block and the second data block sent by the terminal based on the mapping relationship between the local virtual disk and the target device.
[0018] In one embodiment, the receiving of the first data block and the second data block sent by the terminal based on the mapping relationship between the local virtual disk and the target device further includes: receiving, by a heterogeneous adapter, a protocol data unit sent by the terminal, where the protocol data unit is formed by the terminal encapsulating the first data block, the second data block, and a corresponding write-back instruction; determining, based on the heterogeneous adapter, the operating system of the terminal corresponding to the protocol data unit; routing the protocol data unit to a user-mode communication module that matches the operating system; transmitting the protocol data unit from the user-mode communication module to a kernel-mode processing module; and when the kernel-mode processing module parses that the protocol data unit includes a data write-back instruction, writing the first data block and the second data block based on the mapping relationship.
[0019] In one embodiment, the user-mode communication module includes a northbridge communication module and a southbridge communication module. The process of transmitting the protocol data unit from the user-mode communication module to the kernel-mode processing module includes: The northbridge communication module establishes a communication connection with the heterogeneous adapter to receive the protocol data unit transmitted by the heterogeneous adapter and stores the protocol data unit in the socket buffer queue; when the device bus of the target device is in an idle state, the southbridge communication module extracts the protocol data unit from the socket buffer queue and transmits it to the kernel-mode processing module.
[0020] In one embodiment, when the authentication information is verified to be passed, sending device information to the terminal so that the terminal maps the target device to the local virtual disk of the terminal based on the device information includes: when the authentication verification information is passed, creating a parameter negotiation thread with the terminal based on the authentication information; sending the device information to the terminal based on the parameter negotiation thread so that the terminal maps the target device to the local virtual disk of the terminal based on the device information.
[0021] In one embodiment, it further includes: storing the first data block and the second data block based on a multi-copy and raid storage strategy.
[0022] According to the third aspect of the present disclosure, a data storage device is provided, including: a transceiver module, configured to send authentication information to a target device and receive device information fed back by the target device based on the authentication information; a mapping module, configured to map the target device to the local virtual disk of the terminal based on the device information; a detection module, configured to receive a first data block and a second data block to be stored and detect whether the reception times of the first data block and the second data block satisfy a dependency relationship; a write-back module, configured to, when it is detected that the reception times of the first data block and the second data block satisfy the dependency relationship, write back the first data block and the second data block to the target device using the same thread based on the dependency relationship and the mapping relationship between the local virtual disk and the target device; the write-back module is further configured to, when it is detected that the reception times of the first data block and the second data block do not satisfy the dependency relationship, write back the first data block and the second data block to the target device using parallel threads based on the mapping relationship.
[0023] According to a fourth aspect of the present disclosure, a data storage device is provided, including: a verification module configured to perform a verification operation on authentication information sent by a terminal; a sending module configured to send device information to the terminal when the authentication information passes the verification, so that the terminal maps the target device to a local virtual disk of the terminal based on the device information; and a receiving module configured to receive a first data block and a second data block sent by the terminal based on a mapping relationship between the local virtual disk and the target device.
[0024] According to a fifth aspect of the present disclosure, an electronic device is provided, including: a processor; and a memory configured to store executable instructions of the processor; wherein the processor is configured to execute the data storage method according to any one of the technical solutions in the first aspect described above by executing the executable instructions.
[0025] According to a sixth aspect of the present disclosure, an electronic device is provided, including: a processor; and a memory configured to store executable instructions of the processor; wherein the processor is configured to execute the data storage method according to any one of the technical solutions in the second aspect described above by executing the executable instructions.
[0026] According to a seventh aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the data storage method according to any one of the above is implemented.
[0027] The data storage solution provided by the embodiments of the present disclosure virtualizes a physical disk on a remote target device into a local virtual disk of a terminal by adopting a data block method to achieve fine-grained instant access to stored data. When a file to be stored is received, the file is read and written in the form of data blocks, i.e., a first data block and a second data block. The block-level access is in units of the size of a memory page, which is finer than the access granularity at the file level. Therefore, it is easier to be read and written by the upper-layer file system, which is beneficial to improving the data transmission rate and the instant access efficiency to massive data and applications.
[0028] Further, by detecting whether there is a dependency relationship between the first data block and the second data block, configuring a transmission thread of the data block based on the detection result, and writing the data back to the target device based on the configured transmission thread and the mapping relationship between the generated local virtual disk and the physical disk of the target device, the consistency of the data writing operation of the entire system can be ensured, and further the response time can be reduced and the data throughput can be improved.
[0029] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. Brief Description of the Drawings
[0030] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.
[0031] Figure 1 Schematic diagram showing a data storage system structure in an embodiment of the present disclosure;
[0032] Figure 2 Flowchart showing a data storage method in an embodiment of the present disclosure;
[0033] Figure 3 Schematic diagram showing a parallel IO process in an embodiment of the present disclosure;
[0034] Figure 4 Schematic diagram showing a parallel IO process in the related art;
[0035] Figure 5 Schematic diagram showing the structure of a dependency graph in an embodiment of the present disclosure;
[0036] Figure 6 Flowchart showing another data storage method in an embodiment of the present disclosure;
[0037] Figure 7 Schematic diagram showing the comparison between the write-through mode and the write-back mode in an embodiment of the present disclosure;
[0038] Figure 8 Architecture diagram showing data interaction between a terminal and a target device in an embodiment of the present disclosure;
[0039] Figure 9 Schematic diagram showing a data structure based on the write-back mode in an embodiment of the present disclosure;
[0040] Figure 10 Flowchart showing another data storage method in an embodiment of the present disclosure;
[0041] Figure 11 Schematic diagram showing the structure of an iSCSI protocol stack in an embodiment of the present disclosure;
[0042] Figure 12 Flowchart showing another data storage method in an embodiment of the present disclosure;
[0043] Figure 13 Flowchart showing another data storage method in an embodiment of the present disclosure;
[0044] Figure 14 Flowchart showing another data storage method in an embodiment of the present disclosure;
[0045] Figure 15 Schematic diagram showing a data storage device in an embodiment of the present disclosure;
[0046] Figure 16 Schematic diagram showing a data storage device in an embodiment of the present disclosure;
[0047] Figure 17 Schematic diagram showing an electronic device in an embodiment of the present disclosure. Detailed implementation manners
[0048] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments.
[0049] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repeated description will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0050] For ease of understanding, several terms related to the present application will be explained first below.
[0051] An adapter card refers to a hardware that can be connected to a computer host and has specific functions.
[0052] SCSI (Small Computer System Interface) is an independent processor standard for system-level interfaces between a computer and its peripheral devices (such as hard disks, floppy drives, optical drives, printers, scanners, etc.). The SCSI standard defines commands, communication protocols, and the electrical characteristics of the entity (in terms of the OSI model, it occupies the physical layer, link layer, socket layer, and application layer). The majority of its applications are in storage devices (such as hard disks and tape drives); however, in fact, the devices that SCSI can connect to include scanners, optical devices (such as CDs and DVDs), printers, and so on. There is a list of supported devices in the SCSI commands, namely SCSI peripheral devices. In theory, it is impossible for SCSI to connect to all devices, so there is this parameter "1Fh - unknown or no device type".
[0053] iSCSI (Internet Small Computer System Interface) is a standard for block data transfer over TCP / IP. It was initiated by Cisco and IBM and has received strong support from major storage manufacturers. iSCSI enables the SCSI protocol to run over an IP network, allowing for fast data access and backup operations on high-speed gigabit Ethernet networks.
[0054] RAID (Redundant Arrays of Independent Disks) means "an array with redundancy composed of independent disks". A disk array is composed of many independent disks combined into a large-capacity disk group, using the additive effect of individual disks providing data to improve the performance of the entire disk system. With this technology, data is cut into many segments and stored on each hard disk respectively.
[0055] Write-through (direct write mode): When data is updated, it is written to the cache and the backend storage simultaneously. The advantage of this mode is its simplicity; the disadvantage is that because data modification requires writing to the storage simultaneously, the data write speed is relatively slow.
[0056] Write-back (write-back mode): When data is updated, it is only written to the cache. Only when the data is replaced from the cache will the modified cache data be written to the backend storage. The advantage of this mode is that the data write speed is fast because there is no need to write to the storage; the disadvantage is that in the event of a system power failure before the updated data is written to the storage, the data cannot be retrieved.
[0057] Kernel mode: A special software program that controls the computer's hardware resources, such as coordinating CPU resources, allocating memory resources, and providing a stable environment for application programs to run.
[0058] User mode: Provides a space for application programs to run. In order for application programs to access resources managed by the kernel, such as the CPU, memory, and I / O, the kernel must provide a set of general access interfaces, which are called system calls.
[0059] ACK (Acknowledge character) is an acknowledgment character, a type of transmission control character sent by the receiving station to the sending station in data communication, indicating that the data sent has been received correctly.
[0060] A disk drive, also known as a "disk unit", is a storage device that uses disks as the medium for recording information. The disk drive reads the data on the disk and transfers it to the processor.
[0061] Super block: The superblock is equivalent to the metadata of the file system, storing general information about the file system. For example, if an ext file system is damaged, it is very likely to be recovered if the superblock is okay.
[0062] Figure 1 The schematic structural diagram of a data storage system in an embodiment of the present disclosure is shown, including a plurality of terminals 120 and a server cluster 140.
[0063] The terminal 120 can be a mobile terminal such as a mobile phone, a game console, a tablet computer, an e-book reader, smart glasses, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a smart home device, an AR (Augmented Reality) device, a VR (Virtual Reality) device, etc. Alternatively, the terminal 120 can also be a personal computer (PC), such as a laptop computer and a desktop computer, etc.
[0064] Among them, an application program for providing data storage can be installed in the terminal 120.
[0065] The terminal 120 is connected to the server cluster 140 through a communication network. Optionally, the communication network is a wired network or a wireless network.
[0066] The server cluster 140 is a single server, or consists of several servers, or is a virtualization platform, or is a cloud computing service center. The server cluster 140 is used to provide back-end services for data storage applications. Optionally, the server cluster 140 undertakes the main computing work, and the terminal 120 undertakes the secondary computing work; or, the server cluster 140 undertakes the secondary computing work, and the terminal 120 undertakes the main computing work; or, the terminal 120 and the server cluster 140 perform collaborative computing using a distributed computing architecture.
[0067] In some alternative embodiments, the server cluster 140 is used to store data storage models and the like.
[0068] Optionally, the clients of the applications installed in different terminals 120 are the same, or the clients of the applications installed on two terminals 120 are clients of the same type of application on different control system platforms. Based on the differences in the terminal platforms, the specific forms of the application clients can also be different. For example, the application client can be a mobile phone client, a PC client, or a World Wide Web (Web) client, etc.
[0069] Those skilled in the art can be aware that the number of the above terminals 120 can be more or less. For example, the above terminal can be only one, or there can be dozens or hundreds of the above terminals, or even more. The embodiments of the present application do not limit the number and device types of the terminals.
[0070] Optionally, the system may further include a management device ( Figure 1 (not shown), which is connected to the server cluster 140 through a communication network. Optionally, the communication network is a wired network or a wireless network.
[0071] Optionally, the above-mentioned wireless network or wired network uses standard communication technologies and / or protocols. The network is usually the Internet, but can also be any network, including but not limited to any combination of a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or a virtual private network). In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent the data exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can be used to encrypt all or some of the links. In other embodiments, customized and / or proprietary data communication technologies can also be used to replace or supplement the above data communication technologies.
[0072] Next, each step in the data storage method in the present exemplary embodiment will be described in more detail with reference to the accompanying drawings and embodiments.
[0073] Figure 2 The flowchart of a data storage method in an embodiment of the present disclosure is shown. The method provided by the embodiment of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as the terminal 120 and / or the server cluster 140 in Figure 1 . In the following illustrative examples, the terminal 120 is used as the execution subject for illustration.
[0074] As Figure 2 shown, the terminal 120 executes the data storage method, including the following steps:
[0075] Step S202, send authentication information to the target device and receive the device information fed back by the target device based on the authentication information.
[0076] Among them, the interface of the terminal receives the IP address and port number of the target device, as well as the user account and password input by the user as the authentication information. When the authentication information is verified and passed on the target device, it is determined that the connection to the target device is established, and the device information fed back by the target device is received.
[0077] Step S204: Map the target device to a local virtual disk of the terminal based on the device information.
[0078] Among them, by generating a local virtual disk, the storage space of the terminal is enhanced.
[0079] Step S206: Receive the first data block and the second data block to be stored, and detect whether the reception times of the first data block and the second data block satisfy the dependency relationship.
[0080] Among them, the received file is converted into block-level data of the disk for access to achieve fine-grained data access, which is more easily read and written by the upper-layer file system.
[0081] In addition, the dependency relationship is used to detect whether two data blocks are independent of each other, so that when they are detected to be independent of each other, a parallel processing method is adopted to perform data write-back.
[0082] Those skilled in the art can understand that the first data block and the second data block can be data blocks belonging to the same file, or data blocks belonging to different files respectively.
[0083] Specifically, an implementation manner of detecting whether the reception times of the first data block and the second data block satisfy the dependency relationship includes: detecting whether the completion cache time of the first data block is earlier than the start cache time of the second data block. When it is detected that the completion cache time is earlier than the start cache time, it is determined that the dependency relationship is satisfied between the first data block and the second data block; when it is detected that the completion cache time is not earlier than the start cache time, it is determined that the dependency relationship is not satisfied between the first data block and the second data block.
[0084] Step S208: When it is detected that the reception times of the first data block and the second data block satisfy the dependency relationship, based on the dependency relationship and the mapping relationship between the local virtual disk and the target device, write back the first data block and the second data block to the target device using the same thread.
[0085] Among them, for the first data block and the second data block with a dependency relationship, the read and write operations are completed in one thread.
[0086] Step S210: When it is detected that the reception times of the first data block and the second data block do not satisfy the dependency relationship, based on the mapping relationship, write back the first data block and the second data block to the target device using parallel threads.
[0087] Among them, for the first data block and the second data block without a dependency relationship, by writing back in separate threads, the read and write response time can be reduced.
[0088] In this embodiment, by adopting the data block method, the physical disks on the remote target device are virtualized into local virtual disks of the terminal to achieve fine-grained instant access to stored data. When a file to be stored is received, the file is read and written in the form of data blocks, namely the first data block and the second data block. The block-level access is in units of the size of a memory page, which is finer than the file-level access granularity, so it is easier to be read and written by the upper-level file system, thus facilitating the improvement of the data transmission rate and the instant access efficiency to massive data and applications.
[0089] Furthermore, by detecting whether there is a dependency relationship between the first data block and the second data block, configuring the transmission thread of the data block based on the detection result, and based on the configured transmission thread and the mapping relationship between the generated local virtual disk and the physical disk of the target device, writing the data back to the target device can ensure the consistency of the data writing operation of the entire system, and further reduce the response time and improve the data throughput.
[0090] In one embodiment, when it is detected that the completion cache time is earlier than the start cache time, it further includes: generating a first node based on the write operation of the first data block, and generating a second node based on the write operation of the second data block; constructing a directed edge from the first node to the second node to generate a dependency graph based on the first node, the second node and the directed edge, and the dependency graph is used to represent the dependency relationship.
[0091] Specifically, the key to ensuring write consistency is how to ensure that the order of data written back to the remote disk asynchronously from the local storage is the same as the order of data written by the terminal application to the local storage. The most straightforward method is to store the original write IO (including writing and / or writing out) operation order and the written data. The minimum operation unit of the disk drive is a block data block. In the related art, the data blocks involved in the write IO operation are stored in the form of a linked list in the order of completion time. Although this method can ensure write consistency to a certain extent, there are also serious performance problems. As Figure 3 shown, with time as the horizontal axis, two concurrent processes 1 and 2 are described. On the same time axis, process 1 includes IO1 and IO2 operations and the involved data blocks, and process 2 includes IO3, IO4 and IO5 operations and the involved data blocks. The final recorded data block writing order is as Figure 4 shown, that is, including IO1, IO3, IO4, IO2 and IO5 in sequence. This scheme cannot ensure the parallel operation of non-dependent relationship data blocks.
[0092] As Figure 3 can be seen, {IO1, IO3}, {IO 2, IO 4} and {IO 5} are non-dependent relationships, and the dependencies between 1 and 2, 3 and 4 are dependencies. The generated dependency graph is as Figure 5As shown in the reference Figure 5 In Figure 5 , the nodes in the sets {IO 1, IO 3} and {IO 2, IO 4} are independent of each other and can be processed in parallel, which not only greatly improves the CPU utilization rate, but also helps to shorten the response time of IO.
[0093] In addition, when we access the physical disk of the target device, the response time includes not only disk addressing, waiting time, and read / write time, but also the data encapsulation and decapsulation processes, as well as unpredictable network latency. Therefore, the IO time of a local cache storage must be less than the IO time of the physical disk of the target device. By adding local storage as a cache, not only can network traffic be saved, but also the optimization of data access performance can be achieved.
[0094] As Figure 6 shown in Figure 6 , in one embodiment, an implementation manner of writing the first data block and the second data block back to the target device based on the dependency relationship and the mapping relationship between the local virtual disk and the target device includes:
[0095] Step S602, encapsulate the first data block, the second data block, and the corresponding write-back instruction into a protocol data unit.
[0096] Among them, the protocol data unit (PDU). In a hierarchical network structure, protocol data units (PDUs) need to be established at each layer of the transmission system. The PDU contains information from the upper layer and information added by the entity of the current layer, and this PDU will be transmitted to the next lower layer. The receiving system transmits these packets through the protocol stack from bottom to top and separates the relevant information in the PDU at each layer of the protocol stack.
[0097] Step S604, configure the same thread based on the dependency relationship.
[0098] Step S606, determine the storage addresses of the first data block and the second data block in the target device based on the mapping relationship.
[0099] Step S608, send the protocol data unit to the target based on the same thread and the storage address to perform the write-back operation of the first data block and the second data block.
[0100] In this embodiment, by converting the data block and the corresponding read / write request into a protocol data unit and transmitting it in a write-back manner, the data interaction between the terminal and the target device is realized.
[0101] As Figure 7As shown in the figure. By setting up a local caching scheme, when the terminal 702 accesses the corresponding server for the first time, the received data block is stored in the local cache 704. If the data block is accessed for the second time, the Nth time, it can be directly read from the local cache 704, which not only saves traffic but also improves access performance. Taking IO write as an example, in the write-through mode, the data is first written to the local cache 704, then written to the target device disk 706, and finally a write success signal is returned. The execution process is as follows in Figure 8 The execution order in is 1-3-6; in the write-back mode, as long as the data is successfully written to the local cache 704, a success signal can be returned, and then the local cache data is asynchronously written back to the target device disk 706 at an appropriate time. The execution process is as follows in Figure 8 The execution order in is 1-4-2. It can be seen that compared with the write-through mode, the write-back mode has a shorter response time and can provide better read and write performance. By detecting the dependency relationship between data blocks, the consistency of read and write in the write-back mode is achieved.
[0102] In Figure 8 1 and 5 refer to IO requests, 2 refers to write-back, 3 refers to write-through, and 4 and 6 refer to Ack.
[0103] As Figure 8 shown, the terminal 802 includes an operating system 8022 and a file system 8024. The operating system includes but is not limited to the Android system and the IOS system. Below the file system 8024 is the SCSI layer 8026, which can be divided into three layers. From top to bottom, the top layer is the device driver layer 8026A, the data delivery layer 8026B, and the IO routing layer 8026C. Among them, the device driver layer 8026A is the highest-level interface of the system kernel. It consists of a group of drivers that receive requests from the upper-layer file system 8024, convert them into SCSI requests, and notify the file system 8024 of the status information. The common driver types included are disk drivers, tape drivers, and general drivers. Among them, the present disclosure mainly uses the disk driver method to complete the drive operation. Specifically, it performs self-initialization by calling register_blkdev and represents all devices through a set of functions provided by scsi_register_module. As long as a new device is attached to the system, the detect function will be called for detection and managed by the disk driver, and then the request from the upper layer will be converted into a data read and write command, and the data in the local cache 8028 will be written back to the RAID of the target device.
[0104] In addition, as a sequential access type, the tape drive registers itself as a character device through the st_probe function. What makes the tape drive special is that, if possible, it can perform IO transfers directly from user space; otherwise, the data will be buffered and segmented. The general drive allows terminal applications to send control commands to the device, such as formatting, mode sensing, or diagnostics, etc.
[0105] The middle layer is the data delivery layer 8026B, which designs a data delivery mode sensitive to business scenarios through an extended unit in the iSCSI protocol stack, and designs a write-through mode with strong consistency and a write-back mode with strong availability.
[0106] The bottom layer is the IO routing layer 8026C, which is responsible for intercepting the bearer control plane signaling data SRB of the data request block sent by the upper layer driver, queuing and managing the SRB, and returning the processing result of the SRB to the upper layer driver. This layer consists of some specific drivers that can be linked to physical devices, such as SAS drivers, FC drivers, iSCSI drivers, etc. Each driver provides an interface to a specific underlying hardware and is responsible for handling various different adapter types. Its main functions include establishing a session, queuing and managing commands, encapsulating commands and sending them to the target device, and de-encapsulating the received data, etc.
[0107] Specifically, first set the initialization fields at the driver entry, and then call the initialization function and the adapter discovery function. Once the target is discovered, a query request will be sent, and its object parameters will be passed to the disk driver of the device driver layer 8026A. The disk driver will generate a virtual function object for this physical object, so that the terminal can virtualize the remote disk as a local virtual disk 8030.
[0108] In one embodiment, metadata is stored in the memory of the terminal; mapping the target device to the local virtual disk of the terminal based on device information includes: establishing a hash mapping relationship between the metadata and the block storage area stored in the target device; establishing a linear mapping relationship between the metadata and the local cached block storage area; based on the hash mapping relationship and the linear mapping relationship, the disk drive maps the target device to the local virtual disk.
[0109] Such as Figure 9As shown, at the head of the local cache data structure is a superblock 906, which is used to record some global information of the device, such as the size of the device, the size of the metadata area, etc. When the load instruction is executed, the information of the superblock 906 is first read to obtain the overall information of the device, and then the metadata 910 is loaded to restore the previous state of the device. The size of the metadata 910 in the local cache is calculated according to the size of the local cache, and each item corresponds to a local cache data block 912. The local cache data block 912 is the data 904 in the terminal in write-back mode actually written into the local cache. Similarly, the data block 914 in the physical disk of the target device is the actual data written back by the local cache asynchronously. Each item in the terminal metadata 904 will save the mapping relationship between a local cache data block and the physical disk data block of the target device. Among them, the metadata 904 and the local cache data block are in a linear mapping relationship, and the physical disk data block of the target device is in a hash mapping relationship.
[0110] In addition, the IO-Graph block 902 in the terminal and the O-Graph block 908 in the local cache are connected by a control path 918, and the metadata 904 and the data block 914 are connected by a data path 916.
[0111] To ensure data consistency during cache write-back, dedicated data spaces are opened in the terminal memory and the local cache to store dependency relationships. The dependency relationships will be written from the terminal to the local cache local virtual disk asynchronously at an appropriate time. This cache write-back method and data organization architecture based on dependency relationships ensure the write IO data consistency of the entire system, reduce the response time of the system, and improve the throughput of the system.
[0112] In one embodiment, the device information includes disk array information. Mapping the target device to a local virtual disk by a disk drive includes: mapping out a plurality of data block virtual units based on a many-to-many mapping relationship with the disk array information, and constructing a local virtual disk based on the plurality of data block virtual units.
[0113] In this embodiment, the mapping relationship between the virtual disk and the physical disk is defined as many-to-many. In this way, the data access to a logical disk will be carried by multiple physical disks in parallel, greatly improving the data read and write speed. Combining RAID and the multi-copy storage strategy, the reliability of the data is also guaranteed. The access control verification module listens to the specified port. When a login request is sent by a certain startup device on the network and passes the verification, the target device side establishes a session for the request, binds a unique ID, and creates a thread to negotiate parameters with the mobile device on the mobile device side. At this time, the terminal can access the virtual disk and store and retrieve data just like using a local device, and various application programs can also run stably on this virtual disk. Each access to a file will be converted into a block-level access to the disk. The block-level access is in units of the memory page size, which is finer than the file-level access granularity and is easier to be read and written by the upper-layer file system.
[0114] As Figure 10 shown, in one embodiment, based on the hash mapping relationship and the linear mapping relationship, an implementation method for a disk drive to map a target device to a local virtual disk further includes:
[0115] Step S1002, in response to the device information, call the detection function to perform the detection operation of the device information.
[0116] Step S1004, pass the detection result of the detection operation to the disk drive.
[0117] Step S1006, the disk drive generates the mapping relationship between the disk logical address and the physical address based on the hash mapping relationship and the linear mapping relationship, so as to map the target device to the local virtual disk based on the mapping relationship.
[0118] There is an interface on the terminal responsible for user information input, including the IP address and port number of the target device, the user account and password. After the information verification passes, it can be connected to the target device. The interfaces provided by the SCSI adapter card to the file system are all included in a Scsi_Initiator (Scsi startup) data structure. The iSCSI driver of the IO routing layer 8026C first needs to register a Scsi_Initiator_Template function template with the system, and then call the detect method in the function template, that is, the detection function to detect the SCSI adapter card. The entry of this function points to its own command processing function:
[0119] In the process of virtualizing the physical disk of the target device into a local disk, as Figure 8As shown, the event scheduling mechanism 8030A in the local virtual disk 8030 plays an important role. All requests sent by the initiating device to the target device and the information fed back by the target device to the initiating device are carried out in an event-driven manner, mainly including secure login, session creation, PDU processing, error handling, and status monitoring. The login process mainly involves inputting the username and password, as well as the IP address and port number of the target device. After successful verification, a protocol data unit containing login_cmd is sent to the physical disk of the target device, and the returned information is recorded. A session is established during the secure login process. When the terminal logs in to the physical disk of the target device, the name of the initiating device and the session ID are provided. When the physical disk of the target device responds to the login, the name of the target device and the session ID are generated. After successful login, a session is established between the terminal and the physical disk of the target device, and the generated session ID uniquely identifies different storage nodes. The iSCSI protocol uses PDU to encapsulate SCSI commands and data, but does not provide a security mechanism. During the login authentication process between the initiating device and the target device, confidentiality protection at the packet level is not obtained, which somewhat affects security. Therefore, the PDU is processed for secure transmission according to the Industrial Internet security protocol IPsec. The directly connected devices share the system bus and have no burden of network traffic.
[0120] In one embodiment, sending the authentication information to the target device includes: performing secure transmission processing on the authentication information based on a preset security protocol, and sending the processed authentication information to the target device.
[0121] In this embodiment, the Industrial Internet security protocol is used as the preset security protocol to perform secure transmission processing on the PDU according to the Industrial Internet security protocol IPsec, and the system bus is shared by directly connected devices to reduce the burden of network traffic.
[0122] In one embodiment, writing the first data block and the second data block back to the target device further includes: writing the first data block and the second data block back to the target device based on the Internet Small Computer System Interface iSCSI protocol.
[0123] As Figure 11As shown, the iSCSI protocol is a mapping of the SCSI remote procedure call model to the TCP / IP protocol, involving two types of devices, namely, the initiator for initiating IO requests and the target device for processing IO requests and accessing data. On the initiator side, the driver is responsible for intercepting the IO requests issued by the file system, converting them into protocol data units (PDUs) and sending them out through the network. On the target device side, the driver is loaded into the operating system in user mode. After establishing the links of the disk partitions and files, it waits for the initiator to transfer data access commands and constructs commands according to the information in the PDU for the device to process. The iSCSI protocol stack 1100 includes an IP layer 1120, TCP 1104, an Iscsi layer 1106, and a SCSI command set 1108. Based on IP addressing and routing, and using the link connection mechanism of TCP, it realizes data interaction between the initiator and the target device.
[0124] Among them, the SCSI command set 1108 includes, but is not limited to, operation information feedback, reading and writing logical data blocks, and extended units, etc.
[0125] In one embodiment, it further includes: sending an empty transfer instruction to the target device according to a preset detection frequency; when it is determined that the connection with the target device is abnormal based on the empty transfer instruction, re-sending the authentication information to the target device to establish a communication connection with the target device.
[0126] In this embodiment, various errors may occur when transmitting storage data in an unreliable network environment. To handle errors, at regular intervals according to a preset detection frequency, the physical disks of the initiator and the target device will send an empty iSCSI command to confirm each other's status. Once an anomaly is detected, corresponding processing will be carried out, such as re-logging in, reconstructing the session, etc.
[0127] Figure 12 Shows a flowchart of a data storage method in an embodiment of the present disclosure. The method provided by the embodiment of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as, for example, Figure 1 the initiator 120 and / or the server cluster 140 in. In the following illustrative examples, the server cluster 140 is used as the execution entity for example illustration.
[0128] Such as Figure 12 shown, taking the server cluster 140 as the target device and executing the data storage method, includes the following steps:
[0129] Step S1202, perform a verification operation on the authentication information sent by the initiator.
[0130] Step S1204, when the authentication information is verified, send device information to the initiator so that the initiator maps the target device as the local virtual disk of the initiator based on the device information.
[0131] Step S1206, receive the first data block and the second data block sent by the receiving terminal based on the mapping relationship between the local virtual disk and the target device.
[0132] In this embodiment, by feeding back device information based on the authentication information, the physical disk on the local target device is virtualized into the local virtual disk of the terminal, so as to realize fine-grained instant access to stored data.
[0133] Such as Figure 13 As shown, in one embodiment, receiving the first data block and the second data block sent by the receiving terminal based on the mapping relationship between the local virtual disk and the target device further includes:
[0134] Step S1302, the heterogeneous adapter receives the protocol data unit sent by the terminal, and the protocol data unit is formed by the terminal encapsulating the first data block, the second data block and the corresponding write-back instruction.
[0135] Step S1304, determine the operating system of the terminal corresponding to the protocol data unit based on the heterogeneous adapter.
[0136] Step S1306, route the protocol data unit to the user-mode communication module that matches the operating system.
[0137] Step S1308, transmit the protocol data unit from the user-mode communication module to the kernel-mode processing module.
[0138] Step S1310, when it is parsed in the kernel-mode processing module that the protocol data unit includes a data write-back instruction, write the first data block and the second data block based on the mapping relationship.
[0139] Due to the differences in the embedded system platform, the terminal application does not support direct communication with the kernel at the iSCSI level. In order to ensure the stable operation of the service, the relevant code is refactored, the user-mode communication module 8044 is designed, and the corresponding interfaces are written. According to the latest data statistics, the market share of the Android and IOS operating systems in the terminal system platform is as high as 99.9%. However, due to system isolation, it often causes problems such as secondary development and reinventing the wheel, which is not only a waste of R & D resources, but also seriously affects the robustness and portability of an application. Therefore, the heterogeneous adapter 8042 based on heterogeneous terminal devices is designed and developed.
[0140] In this embodiment, by setting the heterogeneous adapter 8042, it can at least perform transmission adaptation with the Android system and the IOS system respectively, realize the adaptation of the heterogeneous terminal device system based on the user mode, and improve the robustness and portability of the entire system application.
[0141] Specifically, the heterogeneous adapter 8042 routes the PDU to the corresponding Android-based or IOS-based communication link according to different operating environments (including but not limited to Android and IOS). The functions completed by the two communication links are the same. On the one hand, the communication link processes requests from the terminal 802, and on the other hand, it receives messages from the kernel-mode processing module 8046.
[0142] As Figure 8 shown, the operating environment of the data access service on the target device side is divided into kernel mode and user mode. The kernel mode includes the kernel-mode processing module 8046. The kernel-mode processing module 8046 includes a PDU task parsing module 8046A, an access control verification module 8046B, and an SCSI disk initialization module 8046C. The SCSI disk initialization module 8046C first reads various information of the physical disk on the target device, initializes global variables and queues, virtualizes a bus adapter, which is equivalent to an SCSI slot. After being scanned by the disk driver, all disks mounted on the adapter will be added to the system and finally recognized as an SCSI disk by the file system.
[0143] As shown, the PDU parsing process according to the present disclosure includes:
[0144] Step S1402, parsing the PDU using the PDU task parsing module.
[0145] Specifically, the PDU task parsing module 8046A is used to implement PDU task parsing.
[0146] Step S1404, the parsing result includes a request data command.
[0147] Step S1406, the parsing result includes a non-request data command.
[0148] Step S1408, the request data command is a read instruction.
[0149] Step S1410, performing a read operation on the SCSI disk.
[0150] Step S1412, the request data command is a read instruction.
[0151] Step S1414, performing a write operation on the SCSI disk.
[0152] Step S1416, the request data command is a login instruction.
[0153] Step S1418, creating a session with the SCSI disk.
[0154] Step S1420, the request data command is a logout instruction.
[0155] Step S1422, destroy the session with the SCSI disk.
[0156] In one embodiment, as Figure 14 shown, the user-mode communication module 8044 includes a northbridge communication module and a southbridge communication module. For the Android system, the corresponding northbridge communication module and southbridge communication module are the Android northbridge communication module 8044A and the Android southbridge communication module 8044B respectively. For the iOS system, the corresponding northbridge communication module and southbridge communication module are the iOS northbridge communication module 8044C and the iOS southbridge communication module 8044D respectively.
[0157] Transmitting the protocol data unit from the user-mode communication module 8044 to the kernel-mode processing module 8046 includes: the northbridge communication module establishing a communication connection with the heterogeneous adapter 8042 to receive the protocol data unit transmitted by the heterogeneous adapter 8042 and saving the protocol data unit in the socket buffer queue; when the device bus of the target device is in an idle state, the southbridge communication module extracts the protocol data unit from the socket buffer queue and transmits it to the kernel-mode processing module 8046.
[0158] Specifically, the entire communication link is divided into two parts: the northbridge communication module and the southbridge communication module. The northbridge communication module is responsible for communicating with the upper-layer adapter module. After the session connection is successful, it will first initialize the socket interface, set the callback function of the PDU, process the data sent by the southbridge communication module, convert the block-based access into SCSI commands, and then encapsulate them into PDUs for the upper-layer protocol stack to process. The southbridge communication module is responsible for communicating with the kernel, implementing asynchronous message processing based on the netlink interface, and not relying on any other kernel service components. The messages sent by the northbridge communication module are saved in the socket buffer queue without waiting for the confirmation of the southbridge communication module; similarly, when the bus is idle, the southbridge communication module can obtain the messages from the socket buffer queue without caring about when the messages are sent.
[0159] In one embodiment, when the authentication information is verified, sending device information to the terminal so that the terminal maps the target device to the local virtual disk of the terminal includes: when the authentication verification information passes, creating a parameter negotiation thread with the terminal based on the authentication information; sending device information to the terminal based on the parameter negotiation thread so that the terminal maps the target device to the local virtual disk of the terminal.
[0160] In this embodiment, as Figure 8As shown, the access control verification module 8046B monitors the specified port. When a login request from a certain terminal is detected and verified, the target device establishes a session for this request, binds a unique ID, and creates a parameter negotiation thread to negotiate parameters with the mobile device on the mobile device side. At this time, the terminal can access the virtual disk and store and retrieve data just like using a local device, and various application programs can also run stably on this virtual disk. Each access to a file will be converted into a block-level access to the disk. The block-level access is in units of the size of a memory page, which is finer than the access granularity at the file level and is easier to be read and written by the upper-level file system.
[0161] In one embodiment, it further includes: storing the first data block and the second data block based on a multi-copy and RAID storage policy.
[0162] In this embodiment, by combining the RAID and multi-copy storage policies, it is beneficial to ensure the reliability of data storage.
[0163] It should be noted that the above-mentioned drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present invention, rather than for restrictive purposes. It is easy to understand that the processes shown in the above-mentioned drawings do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be executed synchronously or asynchronously, for example, in multiple modules.
[0164] Those skilled in the art of the present technical field can understand that various aspects of the present invention can be implemented as a system, a method, or a program product. Therefore, various aspects of the present invention can be specifically implemented in the following forms, namely: a complete hardware implementation manner, a complete software implementation manner (including firmware, microcode, etc.), or an implementation manner combining hardware and software aspects, which can be collectively referred to as "circuit", "module", or "system" here.
[0165] Next, refer to Figure 8 to describe the data storage device 1500 according to this embodiment of the present invention. Figure 15 The data storage device 1500 shown is only an example and should not bring any limitations to the functions and usage scopes of the embodiments of the present invention.
[0166] The data storage device 1500 is embodied in the form of a hardware module. The components of the data storage device 1500 may include but are not limited to: a transceiver module 1502, configured to send authentication information to a target device and receive device information fed back by the target device based on the authentication information; a mapping module 1504, configured to map the target device to a local virtual disk of the terminal based on the device information; a detection module 1506, configured to receive a first data block and a second data block to be stored and detect whether the reception times of the first data block and the second data block satisfy a dependency relationship; a write-back module 1508, configured to, when it is detected that the reception times of the first data block and the second data block satisfy the dependency relationship, write back the first data block and the second data block to the target device in the same thread based on the dependency relationship and the mapping relationship between the local virtual disk and the target device; the write-back module 1508 is further configured to, when it is detected that the reception times of the first data block and the second data block do not satisfy the dependency relationship, write back the first data block and the second data block to the target device in parallel threads based on the mapping relationship.
[0167] The following refers to Figure 15 to describe the data storage device 1600 according to this embodiment of the present invention. Figure 16 The illustrated data storage device 1600 is merely an example and shall not impose any limitation on the functions and the scope of use of the embodiments of the present invention.
[0168] The data storage device 1600 is embodied in the form of a hardware module. The components of the data storage device 1600 may include but are not limited to: a verification module 1602, configured to perform a verification operation on the authentication information sent by the terminal; a sending module 1604, configured to send device information to the terminal when the authentication information is verified, so that the terminal maps the target device to a local virtual disk of the terminal based on the device information; a receiving module 1606, configured to receive the first data block and the second data block sent by the terminal based on the mapping relationship between the local virtual disk and the target device.
[0169] The following refers to Figure 16 to describe the electronic device 1700 according to this embodiment of the present invention. Figure 17 The illustrated electronic device 1700 is merely an example and shall not impose any limitation on the functions and the scope of use of the embodiments of the present invention.
[0170] As Figure 17 shown, the electronic device 1700 is embodied in the form of a general computing device. The components of the electronic device 1700 may include but are not limited to: the at least one processing unit 1710 described above, the at least one storage unit 1720 described above, and a bus 1730 connecting different system components (including the storage unit 1720 and the processing unit 1710).
[0171] Among them, the storage unit stores program code, which can be executed by the processing unit 1710, so that the processing unit 1710 executes the steps according to various exemplary embodiments of the present invention described in the "Exemplary Method" section above in this specification. For example, the processing unit 1710 can execute steps S202 to S210 as shown in Figure 17 Figure 2 and other steps defined in the data storage method of the present disclosure.
[0172] The storage unit 1720 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 17201 and / or a cache storage unit 17202, and may further include a read-only storage unit (ROM) 17203.
[0173] The storage unit 1720 may also include a program / utilities 17204 having a set (at least one) of program modules 17205. Such program modules 17205 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment.
[0174] The bus 1730 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus structures.
[0175] The electronic device 1700 can also communicate with one or more external devices 1760 (such as a keyboard, a pointing device, a Bluetooth device, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device, and / or communicate with any device that enables the electronic device 1700 to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication can be carried out through the input / output (I / O) interface 1740. And the electronic device 1700 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 1750. As shown in the figure, the network adapter 1750 communicates with other modules of the electronic device 1700 through the bus 1730. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0176] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0177] In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above method of this specification. In some possible implementation manners, various aspects of the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification.
[0178] The program product for implementing the above method according to the embodiments of the present invention can be a portable compact disc read-only memory (CD-ROM) and includes program code, and can run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device.
[0179] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries the readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium can also be any readable medium other than the readable storage medium, and the readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.
[0180] The program code contained on the readable medium can be transmitted by any suitable medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the above.
[0181] The program code for performing the operations of the present invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., by connecting through the Internet using an Internet service provider).
[0182] It should be noted that although several modules or units of a device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more of the above-described modules or units can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0183] In addition, although the steps of the methods in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution, etc.
[0184] Through the description of the above embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal, or a network device, etc.) to execute the methods according to the embodiments of the present disclosure.
[0185] Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the appended claims.
Claims
1. A data storage method, applied to a terminal, characterized in that, Including: Sending authentication information to a target device and receiving device information fed back by the target device based on the authentication information; Mapping the target device to a local virtual disk of the terminal based on the device information; Receiving a first data block and a second data block to be stored, and detecting whether the reception times of the first data block and the second data block satisfy a dependency relationship, including: detecting whether the completion caching moment of the first data block is earlier than the start caching moment of the second data block; When it is detected that the completion caching moment is earlier than the start caching moment, determining that the reception times of the first data block and the second data block satisfy the dependency relationship, and based on the dependency relationship and the mapping relationship between the local virtual disk and the target device, writing back the first data block and the second data block to the target device using the same thread; When it is detected that the completion caching moment is not earlier than the start caching moment, determining that the reception times of the first data block and the second data block do not satisfy the dependency relationship, and based on the mapping relationship, writing back the first data block and the second data block to the target device using parallel threads.
2. The data storage method according to claim 1, wherein When it is detected that the completion caching moment is earlier than the start caching moment, it further includes: Generating a first node based on the write operation of the first data block, and generating a second node based on the write operation of the second data block; Constructing a directed edge from the first node to the second node, so as to generate a dependency graph based on the first node, the second node and the directed edge, and the dependency graph is used to represent the dependency relationship.
3. The data storage method according to claim 1, characterized in that, Based on the dependency relationship and the mapping relationship between the local virtual disk and the target device, writing back the first data block and the second data block to the target device includes: Encapsulating the first data block, the second data block and corresponding write-back instructions into a protocol data unit; Configuring the same thread based on the dependency relationship; and Determining the storage addresses of the first data block and the second data block in the target device based on the mapping relationship; Sending the protocol data unit to the target based on the same thread and the storage addresses to perform the write-back operations of the first data block and the second data block.
4. The data storage method according to claim 1, wherein Storing metadata in the memory of the terminal; based on the device information mapping the target device to the local virtual disk of the terminal includes: Establishing a hash mapping relationship between the metadata and a block storage area stored in the target device based on the device information; Establishing a linear mapping relationship between the metadata and a block storage area in the local cache; Based on the hash mapping relationship and the linear mapping relationship, mapping the target device to the local virtual disk by a disk drive.
5. The data storage method according to claim 4, wherein The device information includes disk array information, and mapping the target device to the local virtual disk by the disk drive includes: Mapping out a plurality of data block virtual units based on a many-to-many mapping relationship and the disk array information, so as to construct the local virtual disk based on the plurality of data block virtual units.
6. The data storage method according to claim 4, wherein Based on the hash mapping relationship and the linear mapping relationship, the disk drive mapping the target device to the local virtual disk further includes: In response to the device information, calling a detection function to perform a detection operation on the device information; Transmitting the detection result of the detection operation to the disk drive; The disk drive generates a mapping relationship between the disk logical address and the physical address based on the hash mapping relationship and the linear mapping relationship, so as to map the target device to the local virtual disk based on the mapping relationship.
7. The data storage method according to claim 1, characterized in that The sending the authentication information to the target device includes: Performing a classification transmission process on the authentication information based on a preset security protocol, and sending the processed authentication information to the target device.
8. The data storage method according to claim 1, wherein The writing the first data block and the second data block back to the target device further includes: Based on the Internet Small Computer System Interface (iSCSI) protocol, writing the first data block and the second data block back to the target device.
9. The data storage method according to any one of claims 1 to 8, characterized in that, Further includes: Sending an empty transmission instruction to the target device according to a preset detection frequency; When it is determined that the connection with the target device is abnormal based on the empty transmission instruction, re-sending the authentication information to the target device to establish a communication connection with the target device.
10. A data storage method, applied to a target device, characterized in that, Includes: Performing a verification operation on the authentication information sent by the terminal; When the authentication information is verified, sending device information to the terminal, so that the terminal maps the target device to the local virtual disk of the terminal based on the device information; Receiving the first data block and the second data block sent by the terminal based on the mapping relationship between the local virtual disk and the target device. Among them, the terminal detects whether the completion cache time of the first data block is earlier than the start cache time of the second data block. When it is detected that the completion cache time is earlier than the start cache time, it is determined that the reception times of the first data block and the second data block satisfy the dependency relationship. The terminal sends the first data block and the second data block using the same thread based on the dependency relationship and the mapping relationship. When it is detected that the completion cache time is not earlier than the start cache time, and it is determined that the reception times of the first data block and the second data block do not satisfy the dependency relationship, the terminal sends the first data block and the second data block using parallel threads based on the mapping relationship.
11. The data storage method according to claim 10, wherein The receiving the first data block and the second data block sent by the terminal based on the mapping relationship between the local virtual disk and the target device further includes: Receiving, by a heterogeneous adapter, a protocol data unit sent by the terminal, where the protocol data unit is formed by the terminal encapsulating the first data block, the second data block, and the corresponding write-back instruction; Determining the operating system of the terminal corresponding to the protocol data unit based on the heterogeneous adapter; Routing the protocol data unit to a user-mode communication module that matches the operating system; Transmitting the protocol data unit from the user-mode communication module to a kernel-mode processing module; When the kernel-mode processing module parses that the protocol data unit includes a data write-back instruction, write the first data block and the second data block based on the mapping relationship.
12. The data storage method according to claim 11, wherein The user-mode communication module includes a northbridge communication module and a southbridge communication module. The process of transmitting the protocol data unit from the user-mode communication module to the kernel-mode processing module includes: The northbridge communication module establishes a communication connection with the heterogeneous adapter to receive the protocol data unit transmitted by the heterogeneous adapter and stores the protocol data unit in the socket buffer queue. When the device bus of the target device is in an idle state, the southbridge communication module extracts the protocol data unit from the socket buffer queue and transmits it to the kernel-mode processing module.
13. The data storage method according to claim 11, characterized in that, When the authentication information is verified, send device information to the terminal so that the terminal maps the target device to the local virtual disk of the terminal based on the device information, including: When the authentication verification information passes, create a parameter negotiation thread with the terminal based on the authentication information. Send the device information to the terminal based on the parameter negotiation thread so that the terminal maps the target device to the local virtual disk of the terminal based on the device information.
14. The data storage method according to any one of claims 10 to 13, characterized in that It also includes: Store the first data block and the second data block based on the multi-copy and raid storage policies.
15. A data storage device, applied to a terminal, characterized in that, It includes: A transceiver module for sending authentication information to a target device and receiving device information fed back by the target device based on the authentication information. A mapping module for mapping the target device to the local virtual disk of the terminal based on the device information. A detection module for receiving the first data block and the second data block to be stored and detecting whether the reception times of the first data block and the second data block satisfy a dependency relationship, including: detecting whether the completion cache time of the first data block is earlier than the start cache time of the second data block, and when it is detected that the completion cache time is earlier than the start cache time, determining that the first data block and the second data block satisfy the dependency relationship, and when it is detected that the completion cache time is not earlier than the start cache time, determining that the first data block and the second data block do not satisfy the dependency relationship. A write-back module for, when it is detected that the reception times of the first data block and the second data block satisfy the dependency relationship, writing back the first data block and the second data block to the target device using the same thread based on the dependency relationship and the mapping relationship between the local virtual disk and the target device. The write-back module is also used for, when it is detected that the reception times of the first data block and the second data block do not satisfy the dependency relationship, writing back the first data block and the second data block to the target device using parallel threads based on the mapping relationship.
16. A data storage device, applied to a target device, characterized in that, It includes: A verification module for performing a verification operation on the authentication information sent by the terminal. A sending module, configured to send device information to the terminal when the authentication information is verified, so that the terminal maps the target device to a local virtual disk of the terminal based on the device information; A receiving module, configured to receive a first data block and a second data block sent by the terminal based on a mapping relationship between the local virtual disk and the target device, wherein the terminal detects whether a completion caching time of the first data block is earlier than a start caching time of the second data block, and when it is detected that the completion caching time is earlier than the start caching time, determines that receiving times of the first data block and the second data block satisfy a dependency relationship, and the terminal sends the first data block and the second data block using the same thread based on the dependency relationship and the mapping relationship, and when it is detected that the completion caching time is not earlier than the start caching time, determines that the receiving times of the first data block and the second data block do not satisfy the dependency relationship, and the terminal sends the first data block and the second data block using parallel threads based on the mapping relationship.
17. An electronic device, characterized in that, Comprising: A processor; And A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the data storage method according to any one of claims 1 to 9 by executing the executable instructions.
18. An electronic device, characterized in that, Comprising: A processor; And A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the data storage method according to any one of claims 10 to 14 by executing the executable instructions.
19. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the data storage method according to any one of claims 1 to 9 and / or 10 to 14.
Citation Information
Patent Citations
Virtual storage method, virtual storage equipment and virtual storage system for terminals
CN105827669A
Distributed data set storage and retrieval
CN108701076A