Data read-write method and device, electronic equipment and nonvolatile storage medium

By introducing virtual disk mapping and target storage device management between the host and physical storage media, the problems of high resource consumption and low utilization of host-directly connected hard drives are solved, achieving efficient and secure data reading and writing.

CN119690355BActive Publication Date: 2026-04-21INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2024-12-29
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, the data read and write method of direct connection of host to hard drive consumes a lot of resources and has low disk utilization, and cannot be effectively utilized when the host is in hibernation or shut down.

Method used

By assembling physical storage media into virtual disks and mapping them to the host, the target storage device manages read and write operation requests, and only performs data read and write operations when the command parameters, storage environment, and hardware conditions are normal, thereby reducing the consumption of host resources.

Benefits of technology

It improves disk data read/write efficiency and security, increases disk utilization, and ensures that host resources are focused on actual business processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690355B_ABST
    Figure CN119690355B_ABST
Patent Text Reader

Abstract

This invention discloses a data read / write method, apparatus, electronic device, and non-volatile storage medium, applied in the field of storage technology. The method includes assembling at least one target physical storage medium into a virtual disk and mapping the virtual disk to a host; receiving a target read / write operation request obtained by converting a disk data read / write operation request sent by the host to the target physical storage medium. When the command parameters of the target read / write operation request are normal, and the current storage environment, the storage path corresponding to the target read / write operation request, and the hardware storage conditions are all in a normal state, then read / write operations are performed on the target physical storage medium based on the target read / write operation request. This invention can solve the problem that the efficiency, security, and resource consumption of disk read / write operations in related technologies cannot meet user needs, and can effectively improve the efficiency and security of disk data read / write while reducing resource consumption and improving disk utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, and in particular to a data read / write method, apparatus, electronic device, and non-volatile storage medium. Background Technology

[0002] Disks store electronic data using magnetic recording technology and enable reading and writing operations on computer data by interacting with the host computer.

[0003] In related technologies, the method of storing computer data by directly connecting the host to the hard drive means that the host directly writes the data that needs to be stored on the disk. This data read and write method not only consumes a lot of host resources, but also has low data storage efficiency and security. In addition, due to the limitations of physical links, the same disk can only be used by one host. When it is used by a host that is in hibernation, powered off, or has low traffic, there is a problem that the disk cannot be used effectively.

[0004] Therefore, improving disk data read / write efficiency and security while reducing resource consumption and increasing disk utilization is a technical problem that needs to be solved by those skilled in the art.

[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0006] This invention provides a data reading and writing method, apparatus, electronic device, and non-volatile storage medium, which can effectively improve the reading and writing efficiency and security of disk data while reducing resource consumption and increasing disk utilization.

[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0008] This invention provides a data read / write method applied to a target storage device, comprising:

[0009] At least one target physical storage medium is pre-configured as a virtual disk, and the virtual disk is mapped to the host;

[0010] The host receives a target read / write operation request; the target read / write operation request is obtained by converting the disk data read / write operation request sent by the host to the target physical storage medium; when the command parameters of the target read / write operation request are normal, and the current storage environment, the storage path corresponding to the target read / write operation request, and the hardware storage conditions are all in a normal state, then read / write operations are performed on the target physical storage medium based on the target read / write operation request.

[0011] In a first exemplary embodiment, after receiving the target read / write operation request sent by the host, the method further includes: pre-constructing a read / write request structure; the read / write request structure includes a command type, a command lifecycle, physical storage medium identification information, and a storage address; the command type includes read commands and write commands; by parsing the target read / write operation request, the target command type, the target command lifecycle, the target physical storage medium identification information, and the logical block address are obtained; based on the target command type, the target command lifecycle, the target physical storage medium identification information, and the logical block address, a read / write request structure corresponding to the target read / write operation request is generated, so as to perform read / write operations on the target physical storage medium based on the read / write request structure.

[0012] In a second exemplary embodiment, after receiving the target read / write operation request sent by the host, the method further includes: pre-constructing a dedicated thread for a silent disk; storing each target read / write operation request in a request waiting queue when the virtual disk is in a silent state; and calling the dedicated thread for the silent disk to process the awakened target read / write operation request when the target read / write operation request in the waiting queue is detected to be awakened.

[0013] In a third exemplary embodiment, before performing read / write operations on the target physical storage medium based on the target read / write operation request, the method further includes: obtaining the current storage state and the disk state of the virtual disk; if the current storage state is processing read / write requests normally and the disk state is online, then the current storage environment is in a normal state; obtaining the first path state between the target storage device and the target physical storage medium, and the second path state between the target storage device and the host; if neither the first path state nor the second path state is in a reset state, then the storage paths corresponding to the target read / write operation request are all in a normal state; if the target physical storage medium has no bad sectors and is in a connected state, then the hardware storage conditions are in a normal state.

[0014] In a fourth exemplary embodiment, before performing read / write operations on the target physical storage medium based on the target read / write operation request, the method further includes: if at least one of the path states of the target storage device, the target physical storage medium, and the host is in a reset state, then sending an error code indicating an incorrect path state to the host; if the target physical storage medium is in a disconnected state, then sending a notification message to the host that data cannot be written or read; if the command type corresponding to the target read / write operation request is a write command, obtaining the bad sector data and the number of disconnections of the target physical storage medium; if the storage address of the data to be written contains the sector where the bad sector is located and / or the number of disconnections of the target physical storage medium exceeds a preset threshold, then sending a notification message that data cannot be written to the host.

[0015] In the fifth exemplary embodiment, after receiving the target read / write operation request sent by the host, the method further includes: obtaining the read / write data range, command type, and data read / write length of the target read / write operation request; obtaining the virtual disk read / write range, the authorization information of the target physical storage medium, and the allowed data length value; when the authorization information is write-protected or read-only, if the command type of the target read / write operation request is a write command, then the command parameters of the target read / write operation request are invalid; if the read / write data range is within the virtual disk read / write range, and the data read / write length is less than the allowed data length value, then the command parameters of the target read / write operation request are normal.

[0016] In a sixth exemplary embodiment, the current storage environment includes the storage state and the disk state of the virtual disk. After receiving the target read / write operation request sent by the host, the method further includes: obtaining the current storage state and the disk state of the virtual disk; if the storage state is damaged or disconnected, all data read / write paths between the host and the storage device are disconnected, and the host enters a timeout processing flow; if the storage state is silent, the processing of read / write operation requests sent by the host is suspended, and the target read / write operation request is stored in a pre-built request waiting queue; if the storage state is starting up, the target read / write operation request is stored in a pre-built request waiting queue. Read and write operation requests are stored in a pre-built request waiting queue. After startup, each target read and write operation request is processed sequentially according to the order in which it was added to the request waiting queue. If the disk is in an offline state, an error code indicating that the virtual disk is offline is sent to the host, and a virtual disk online monitoring thread is started. When the virtual disk is detected to be online, virtual disk recovery information is sent to the host. If the disk is in a silent state, the target read and write operation requests are stored in a pre-built request waiting queue, a request time monitoring thread is started, and read and write operation requests in the request waiting queue whose waiting time exceeds a preset waiting time threshold are discarded.

[0017] Another aspect of the present invention provides a data read / write apparatus, applied to a target storage device, comprising:

[0018] A virtualization module is used to pre-assemble at least one target physical storage medium into a virtual disk and map the virtual disk to the host; a request receiving module is used to receive target read / write operation requests sent by the host; the target read / write operation request is obtained by the host converting the disk data read / write operation request sent to the target physical storage medium; a request processing module is used to perform read / write operations on the target physical storage medium based on the target read / write operation request when the command parameters of the target read / write operation request are normal, and the current storage environment and the storage path and hardware storage conditions corresponding to the target read / write operation request are all in a normal state.

[0019] The present invention also provides an electronic device including a processor, the processor being configured to perform the steps of the data read / write method as described in any of the preceding claims when executing a computer program stored in a memory.

[0020] Finally, the present invention also provides a non-volatile storage medium storing a computer program, which, when executed by a processor, implements the steps of the data read / write method as described in any of the preceding claims.

[0021] The advantages of the technical solution provided by this invention are as follows: After the target storage device constructs a virtual disk using a physical hard drive, it maps the virtual disk to the host, forming a readable and writable block device on the host to store actual business data. The host only needs to convert the disk data read / write operation requests originally sent to the physical storage medium into target read / write operation requests sent to the virtual disk. The target storage device manages and processes these target read / write operation requests, reducing the host's own computing and memory resource consumption. This allows the host to focus on processing actual business operations and ensures the reliability of the host's actual application business. The target storage device only sends the target read / write operation request to the target physical storage medium after successfully verifying the command parameters, current storage environment, storage path, and hardware storage conditions. This not only ensures efficient execution of data read / write operation requests but also improves the security of stored data. Since the underlying physical storage medium is not used by the host, it can be used by multiple hosts simultaneously, effectively improving the utilization rate of the physical storage medium. Ultimately, this achieves improved disk data read / write efficiency and security while reducing resource consumption and increasing disk utilization.

[0022] Furthermore, the present invention also provides corresponding implementation devices, electronic devices, and non-volatile storage media for the data read and write method, further making the method more practical. The devices, electronic devices, and non-volatile storage media have corresponding advantages.

[0023] The technical features mentioned above, those to be mentioned below, and those shown individually in the accompanying drawings can be arbitrarily combined with each other, provided that the combined technical features are not contradictory. All feasible combinations of features are the technical content explicitly described herein. Any one of the multiple sub-features contained in the same statement can be applied independently, without necessarily being applied together with other sub-features. It should be understood that the above general description and the following detailed description are merely exemplary and do not limit the invention. Attached Figure Description

[0024] To more clearly illustrate the technical solutions of the present invention or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 A flowchart illustrating a data reading and writing method provided by the present invention;

[0026] Figure 2 A flowchart illustrating the data reading and writing method provided by the present invention in an exemplary application scenario;

[0027] Figure 3 A flowchart illustrating another data reading and writing method provided by the present invention;

[0028] Figure 4 A structural diagram of a specific embodiment of the data read / write device provided by the present invention;

[0029] Figure 5 This is a structural diagram of a specific embodiment of the electronic device provided by the present invention. Detailed Implementation

[0030] To enable those skilled in the art to better understand the technical solutions of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. In this specification and the aforementioned drawings, the terms "first," "second," etc., are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. The term "exemplary" means "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior to or better than other embodiments.

[0031] With the rapid development of big data management, cloud computing, and artificial intelligence technologies, the requirements for the security and effectiveness of data storage are becoming increasingly stringent. This necessitates improving the utilization rate of physical storage media to achieve efficient and secure data reading and writing. Current technologies use direct server-to-hard drive connections to store electronic data. However, this requires servers to consume significant CPU and memory resources to execute the entire data reading and writing process, resulting in low data access efficiency, low security, high resource consumption, and low specialization. Furthermore, due to physical link limitations, a single disk can only be used by one host. If the host is in a dormant, powered-off, or low-traffic state, the disk bound to that host cannot be effectively utilized, leading to low disk utilization and sharing capabilities.

[0032] Therefore, in order to improve disk utilization and reduce host resource consumption, this invention uses a dedicated storage device to manage the I / O (read / write operation requests) issued by the host to the hard disk, effectively improving the efficiency, security, redundancy, and data I / O rate of hard disk management. After introducing the technical solution of this invention, various non-limiting embodiments are described in detail below. To better illustrate this invention, numerous specific details are provided in the following detailed embodiments. Those skilled in the art should understand that this invention can be implemented without these specific details. In other examples, methods, means, components, and circuits well known to those skilled in the art are not described in detail in order to highlight the main points of this invention.

[0033] Please see first. Figure 1 , Figure 1 This is a flowchart illustrating a data read / write method provided in this embodiment, applied to a target storage device. This embodiment may include the following:

[0034] S101: Pre-configure at least one target physical storage medium as a virtual disk and map the virtual disk to the host.

[0035] In this invention, the physical storage medium refers to the underlying storage components of the host, such as hard disk drives (HDDs) and solid-state drives (SSDs). The target physical storage medium refers to the component selected from these components. The selection criteria can be the storage component for which the host will request read / write operations, or it can be the storage component specified for read / write operations using the method provided in this invention. Once the target physical storage medium is determined, any technology that virtualizes multiple physical storage devices into a single logical storage device can be used to construct a virtual hard disk; this invention does not impose any limitations on this. After the target storage device completes the virtual disk construction using the physical hard disk, the virtual disk can be mapped to the host via a physical line, forming a readable and writable block device on the host to store actual business data. The host refers to any computer device that can connect to a network, including but not limited to servers, personal computers, workstations, smartphones, etc. The host has its own processor, memory, and storage devices and can independently run operating systems and applications.

[0036] S102: Receive the target read / write operation request sent by the host.

[0037] In this step, when the host needs to perform read / write operations on the target storage medium, it sends a read / write operation request to the target storage medium. For ease of description, this can be defined as a disk data read / write operation request. This invention aims to solve the problems existing in direct interaction between the host and the target storage medium, such as... Figure 2 As shown, a target storage device is introduced. Accordingly, disk data read / write operation requests need to be converted to the format required by the target storage device. This conversion can be performed by the host, for example, by modifying the command receiving information to send read / write operation requests originally intended for the target physical storage medium to a virtual disk, which the target storage device then retrieves. Alternatively, the target storage device can perform the conversion itself, meaning the host doesn't need to make any changes. The target storage device can be configured with a monitoring thread. When it detects a disk data read / write operation request sent by the host to the target physical storage medium, it captures the request, converts it into a target read / write operation request, and then executes step S103. In this way, the target storage device and the host will interact, with the host reading or writing data from the target physical storage medium managed by the storage device.

[0038] S103: When the command parameters of the target read / write operation request are normal, and the current storage environment, the storage path corresponding to the target read / write operation request, and the hardware storage conditions are all in a normal state, then read / write operations are performed on the target physical storage medium based on the target read / write operation request.

[0039] When the target storage device receives the read / write operation request originally sent by the host to the target storage medium in the previous step, it will first manage the target read / write operation request from multiple aspects, including thread scheduling, memory management, queue control, timeout control, and storage device exception handling. For example, this step performs status checks on command parameters, the current storage environment path, and hardware storage conditions. Once all conditions are met, the target storage device then sends the target read / write operation request to the target physical storage medium. Further, if the target read / write operation request can be executed normally, a success message can be returned to the host. For a write operation, the host data also needs to be sent to the target storage device. For a read operation, the data on the virtual disk needs to be transferred to the host via the target storage device. If data transfer fails, an error code is returned to the host; if data transfer is successful, the target read / write operation request is considered successfully completed.

[0040] In the technical solution provided in this embodiment, after the target storage device constructs a virtual disk using a physical hard drive, it maps the virtual disk to the host, forming a readable and writable block device on the host to store actual business data. The host only needs to convert the disk data read / write operation requests originally sent to the physical storage medium into target read / write operation requests sent to the virtual disk. The target storage device manages and processes these target read / write operation requests, reducing the host's own computing and memory resource consumption. This allows the host to focus on processing actual business operations and ensures the reliability of the host's actual application business. The target storage device only sends the target read / write operation request to the target physical storage medium after successfully verifying the command parameters, current storage environment, storage path, and hardware storage conditions. This not only ensures the efficient execution of data read / write operation requests but also improves the security of stored data. Since the underlying physical storage medium is not used by the host, it can be used by multiple hosts simultaneously, effectively improving the utilization rate of the physical storage medium. Ultimately, this achieves improved disk data read / write efficiency and security while reducing resource consumption and increasing disk utilization.

[0041] To further improve the processing efficiency of read and write operation requests by the target storage device, based on the above embodiments, the present invention also provides a method for processing requests using a dedicated structure, which may include the following:

[0042] A read / write request structure is pre-constructed; by parsing the target read / write operation request, the target command type, target command lifecycle, target physical storage medium identification information, and logical block address are obtained; based on the target command type, target command lifecycle, target physical storage medium identification information, and logical block address, a read / write request structure corresponding to the target read / write operation request is generated, and read / write operations are performed on the target physical storage medium based on the read / write request structure.

[0043] In this embodiment, the read / write request structure includes a command type, a command lifecycle, physical storage medium identification information, and a storage address. The command type includes read commands and write commands. The physical storage medium identification information can be, for example, a disk number or disk ID. The storage address can include a start address and an end address, used to indicate the location of data on the storage device. The address can be an LBA (Logical Block Address) used to describe the block where the data is located on the virtual disk; that is, the storage address can include a start LBA (start_lba) and an end LBA (end_lba). The command lifecycle can include the command arrival time and the command submission time. For example, the read / write request structure can include a physical storage medium ID, a start LBA, an end LBA, a command type, a command arrival time, and a command submission time. Once the target read / write operation request is obtained, the command type, command lifecycle, physical storage medium identification information, and storage address are read from the target read / write operation request. Then, the corresponding read / write request structure is filled in. This generates a read / write request structure that uniquely corresponds to the target read / write operation request. Each read / write request structure corresponds to a read / write operation request resource, and each read / write operation request resource corresponds to a read command or a write command. The lifecycle of the read / write operation request resource is from command generation to command execution completion.

[0044] As can be seen from the above, this embodiment defines a read / write request structure on the target storage device and processes read / write operation requests through this structure, which helps to improve the execution efficiency of read / write operation requests.

[0045] In the above embodiments, no limitation is made on how to determine whether the command parameters of the read / write operation request are normal. Based on the above embodiments, the present invention provides a method for determining whether the command parameters are normal by whether the parameters are valid, which may include the following:

[0046] Obtain the read / write data range, command type, and data read / write length of the target read / write operation request; obtain the virtual disk read / write range, the authorization information of the target physical storage medium, and the allowed data length; if the authorization information is write-protected or read-only, and the command type of the target read / write operation request is a write command, then the command parameters of the target read / write operation request are invalid; if the read / write data range is within the virtual disk read / write range, and the data read / write length is less than the allowed data length, then the command parameters of the target read / write operation request are normal.

[0047] In this embodiment, the validity of the parameters of the target read / write operation request is determined by the read / write data range, data read / write length, and authorized operations. For example, it checks whether the read / write data range exceeds the data read / write range specified by the virtual disk, whether write protection is enabled, and whether the read / write data length exceeds the range supported by the target storage device. If the command parameters are invalid, the target storage device can set the corresponding error code to inform the host in which aspect the command parameters are invalid, so that the host can adjust its behavior when issuing IO read / write operation requests in a timely manner.

[0048] As can be seen from the above, this embodiment determines whether the command parameters are normal by judging the validity of the parameters, which helps to detect abnormal commands in a timely manner, repair them promptly, and improve the processing efficiency of read and write operation requests.

[0049] To further ensure the stability of the target storage device, based on the above embodiments, the present invention also provides a method for handling read / write operation requests in a silent state using a dedicated thread, which may include the following:

[0050] A dedicated thread for silent disks is pre-built; when the virtual disk is in a silent state, each target read / write operation request is stored in a request waiting queue; when a target read / write operation request in the waiting queue is detected to be awakened, the dedicated thread for silent disks is invoked to process the awakened target read / write operation request.

[0051] In this embodiment, it is considered that a single thread may handle read / write operation requests from multiple virtual disks. When a virtual disk is in a dormant state, read / write operation requests arriving at that virtual disk are not processed but are added to a waiting queue. During the waiting process, to avoid resource waste, thread / CPU resources cannot wait indefinitely for read / write operation requests, causing other virtual disk read / write operation requests to be unable to obtain computing resources and thus remain unprocessed. When read / write operation requests in the waiting queue are awakened, a read / write operation request storm may occur. To prevent affecting the normal processing of read / write operation requests from other virtual disks and causing storage performance fluctuations, a dedicated thread can be used to handle these reawakened read / write operation requests, ensuring the stability of the target storage device.

[0052] As can be seen from the above, this embodiment uses a dedicated thread to handle read and write operation requests that are being woken up, which does not affect the normal operation of other virtual disks, effectively avoids storage performance fluctuations, and ensures the stability of the target storage device.

[0053] The above embodiments do not limit how to verify the storage status. The present invention also provides an exemplary storage status verification method, which may include the following:

[0054] Get the current storage status and the disk status of the virtual disk; if the current storage status is processing read / write requests normally and the disk status is online, then the current storage environment is in a normal state; get the first path status between the target storage device and the target physical storage medium, and the second path status between the target storage device and the host; if neither the first path status nor the second path status is in a reset state, then the storage paths corresponding to the target read / write operation requests are in a normal state; if the target physical storage medium has no bad sectors and is in a connected state, then the hardware storage conditions are in a normal state.

[0055] This embodiment determines whether the storage environment is normal based on the storage status and the disk status of the virtual hard disk. It also judges the data transmission path from the host to the target storage device to the target physical storage medium, and judges whether the hardware storage conditions are normal based on the damage level and online status of the physical storage medium to which the data is written. This ensures that the target read and write operation requests are effectively executed, detects anomalies in a timely manner and repairs them, improves the processing efficiency and security of read and write operation requests, and avoids data loss.

[0056] In the above embodiments, after the host issues a read / write operation request, the target storage device receives the request. Under normal circumstances, it enters the target storage device's management process and finally writes the data to the actual physical storage medium. If an abnormal process occurs, the corresponding processing flow is entered according to different scenarios. This invention provides corresponding processing flows for different abnormal situations, such as... Figure 3 As shown, it may include the following:

[0057] If at least one of the path states of the target storage device, the target physical storage medium, and the host is in a reset state, an error code indicating that the path state is incorrect is sent to the host.

[0058] When the target physical storage medium is disconnected, a notification message is sent to the host that data cannot be written or read.

[0059] If the command type corresponding to the target read / write operation request is a write command, obtain the bad sector data and the number of disconnections on the target physical storage medium; if the storage address of the data to be written contains the sector where the bad sector is located and / or the number of disconnections on the target physical storage medium exceeds a preset threshold, send a notification message to the host that the data cannot be written.

[0060] Obtain the current storage status and virtual disk status; if the storage status is damaged or disconnected, all data read / write paths between the host and the storage device are disconnected, and the host enters the timeout processing flow; if the storage status is silent, pause processing read / write operation requests issued by the host and store the target read / write operation requests in a pre-built request waiting queue; if the storage status is starting up, store the target read / write operation requests in a pre-built request waiting queue, and after startup is completed, process each target read / write operation request in the order they were added to the request waiting queue.

[0061] If the disk is in an offline state, an error code indicating that the virtual disk is offline is sent to the host, and a virtual disk online monitoring thread is started; when the virtual disk is detected to be online, virtual disk recovery information is sent to the host; if the disk is in a silent state, the target read and write operation requests are stored in a pre-built request waiting queue, a request time monitoring thread is started, and read and write operation requests in the request waiting queue that have a waiting time exceeding a preset waiting time threshold are discarded.

[0062] In this embodiment, storage states include normal processing of read / write operation requests, damaged or disconnected state, silent state, and startup state. Normal processing of read / write operation requests indicates that in the normal state, the target storage device processes read / write operation requests normally and proceeds to the next step. In the damaged (disconnected) state, the target storage device is completely unable to process read / write operation requests; it cannot respond to read / write operation requests sent by the host, and the host enters a timeout process. The entire read / write operation request path from the host to the target storage device is lost. In the silent state, the target storage device has higher-priority tasks to process, such as a new storage node needing to be added to the storage cluster. The target storage device processing read / write operation requests needs to pause processing internal read / write operation requests sent by the host. However, due to the negotiation mechanism between the host and the target storage device, and considering that if too many error codes are returned, the host will consider the target storage device to be damaged and no longer capable of processing read / write operation requests, and will no longer process read / write operation requests through the target storage device, therefore, error codes cannot be directly returned; instead, they can be added to the request waiting queue. When the target storage device is in the startup state, some functions of the target storage device are not yet ready. Directly sending read and write operation requests to the physical storage medium in this situation can easily lead to errors such as data inconsistency. Therefore, these read and write operation requests need to be added to a waiting queue. After the target storage device has finished starting up and all functions are ready, the read and write operation requests in the waiting queue are retrieved in chronological order and sent to the physical storage medium.

[0063] The virtual disk status can include online, offline, and silent states. When the virtual disk is online, the target storage device can directly submit read and write operation requests to the virtual disk. When the virtual disk is offline, the target storage device will directly return an error code to the host. After the host receives consecutive error read and write operation request information, it will determine that all paths of the virtual disk are lost. Once the virtual disk comes back online, the target storage device can re-report the recovery information of the virtual disk to the host. When the virtual disk is silent, read and write operation requests sent to the virtual disk will be added to a waiting queue. If read and write operation requests in the waiting queue time out, they can be discarded to save resources.

[0064] When the data transfer path between the target storage device and the host is in a reset state, the target storage device is unable to process read / write requests originating from that path and directly returns an error code to the host. Regarding the success of the read / write request to disk: If the target physical storage medium has bad blocks or the hard drive is disconnected, the read / write request data may fail to be correctly written to or read from the target physical storage medium. In this case, an error code may be returned directly, notifying the host that data cannot be written / read from that area, and the host will then forward the data to other areas of the virtual disk.

[0065] As can be seen from the above, in the process of using the target storage device to manage the internal read and write operation requests generated by the host, different abnormal scenarios correspond to different processing procedures. This not only ensures that the read and write operation requests are executed efficiently, but also effectively guarantees the reliability of the host's actual application business, reduces the consumption of the host's own computing resources and memory resources, and enables the host to focus on the processing of actual business.

[0066] It should be noted that there is no strict order of execution between the steps in this invention. As long as they conform to the logical order, these steps can be executed simultaneously or in a certain preset order. Figures 1-3 This is just an illustrative example and does not mean that this is the only possible execution order.

[0067] The above embodiments do not limit how the virtual disk is mapped to the host. This invention also provides an exemplary mapping method that maps the virtual disk to the host via physical lines such as IP (Internet Protocol) network links, FC (Fiber Optic Connector) fiber optic links, and RDMA (Remote Direct Memory Access) high-speed network links. This method may include the following:

[0068] First, configure matching network parameters according to the virtual machine's network requirements, and then use command-line tools to map the target physical storage medium to the virtual machine. These network parameters include, but are not limited to, the network adapter type and IP address. The network adapter type can be bridged, NAT, or host-only, and the IP address can be static or dynamic. This allows the virtual machine to access external resources and communicate data over the network. Different virtualization platforms provide different command-line tools that can be used to map physical disks to virtual machines. For example, in VMware (a virtualization platform), the `vmkfstools` command (command-line tool) can be used to map physical disks to virtual machines.

[0069] Next, configure the fiber optic switch, target storage device, and server. Create storage areas on the fiber optic switch, divide the storage device into multiple logical storage areas, set access permissions for each logical storage area, configure LUN (Logical Unit Number) mapping, and associate each logical storage area with the server so that the server can access and use the data in the storage device, completing the FC fiber optic link mapping. The configuration parameters for the fiber optic switch include, but are not limited to, the management IP address, creating a VSAN (virtual storage area network), and configuring ports. The target storage device configuration includes, but is not limited to, the management IP address and creating a LUN. The server configuration includes, but is not limited to, the WWN (World Wide Name) of the HBA (Host Bus Adapter) card and installing and configuring the fiber optic driver.

[0070] Finally, install the basic libraries, such as iproute (library name), libibverbs (library name), ibibverbs-utils (library name), and infiniteiband-diags (library name). Check the RDMA connection status; for example, use the command `rdma link show` to view the current RDMA connection status. Configure RXE (RoCE based on pure software, RDMA over Converged Ethernet, achieving efficient data transmission over lossless Ethernet) on the network card. For example, use the command `rxe_cfg addxgbe0` to start the RDMA service or view the loaded RDMA-related modules. Send the QP (Queue Pair) number, LID (Local Identifier), GID (Global Identifier), memory key, and other information through the connection, then close the TCP / IP channel and switch to RDMA communication.

[0071] As can be seen from the above, this embodiment maps the virtual disk to the host through different physical lines to ensure the security and integrity of the data.

[0072] This invention also provides a corresponding apparatus for the data read / write method, further enhancing the practicality of the method. The apparatus can be described from both a functional module perspective and a hardware perspective. The data read / write apparatus provided by this invention is described below. This apparatus is used to implement the data read / write method provided by this invention. In this embodiment, the data read / write apparatus may include or be divided into one or more program modules. These one or more program modules are stored in a storage medium and executed by one or more processors to complete the data read / write method disclosed in Embodiment 1. The program module referred to in this embodiment is a series of computer program instruction segments capable of performing a specific function, which is more suitable than the program itself for describing the execution process of the data read / write apparatus in the storage medium. The following description will specifically introduce the functions of each program module in this embodiment. The data read / write apparatus described below can be referred to in correspondence with the data read / write method described above.

[0073] From the perspective of functional modules, see Figure 4 , Figure 4 This is a structural diagram of the data read / write device provided in this embodiment under one specific implementation. The device may include:

[0074] Virtualization module 401 is used to pre-configure at least one target physical storage medium into a virtual disk and map the virtual disk to the host.

[0075] The request receiving module 402 is used to receive the target read / write operation request sent by the host; the target read / write operation request is obtained by converting the disk data read / write operation request sent by the host to the target physical storage medium.

[0076] The request processing module 403 is used to perform read and write operations on the target physical storage medium based on the target read and write operation request when the command parameters of the target read and write operation request are normal, and the current storage environment, the storage path corresponding to the target read and write operation request, and the hardware storage conditions are all in a normal state.

[0077] For example, in some embodiments of this example, the above-mentioned apparatus may further include a structure generation module, which is used to pre-construct a read / write request structure; the read / write request structure includes a command type, a command lifecycle, physical storage medium identification information, and a storage address; the command type includes read commands and write commands; by parsing the target read / write operation request, the target command type, the target command lifecycle, the target physical storage medium identification information, and the logical block address are obtained; based on the target command type, the target command lifecycle, the target physical storage medium identification information, and the logical block address, a read / write request structure corresponding to the target read / write operation request is generated, so as to perform read / write operations on the target physical storage medium based on the read / write request structure.

[0078] For example, in some other embodiments of this embodiment, the above-mentioned device may further include a dedicated thread processing module, which is used to pre-build a dedicated thread for the silent disk; when the virtual disk is in a silent state, it stores each target read / write operation request to a request waiting queue; when it detects that a target read / write operation request in the waiting queue has been awakened, it calls the dedicated thread for the silent disk to process the awakened target read / write operation request.

[0079] For example, in some other embodiments of this example, the request processing module 403 can also be used to: obtain the current storage state and the disk state of the virtual disk; if the current storage state is processing read / write requests normally and the disk state is online, then the current storage environment is in a normal state; obtain the first path state between the target storage device and the target physical storage medium, and the second path state between the target storage device and the host; if neither the first path state nor the second path state is in a reset state, then the storage paths corresponding to the target read / write operation requests are in a normal state; if the target physical storage medium has no bad sectors and is in a connected state, then the hardware storage conditions are in a normal state.

[0080] For example, in some other embodiments of this embodiment, the above-mentioned device may further include an exception handling module. This module is used to send an error code indicating that the path state is incorrect to the host when at least one of the path states of the target storage device, the target physical storage medium, and the host is in a reset state; when the target physical storage medium is in a disconnected state, it sends a notification message to the host that data cannot be written or read; if the command type corresponding to the target read / write operation request is a write command, it obtains the bad sector data of the target physical storage medium and the number of disconnections; if the storage address of the data to be written contains the sector where the bad sector is located and / or the number of disconnections of the target physical storage medium exceeds a preset threshold, it sends a notification message that data cannot be written to the host.

[0081] For example, in some other embodiments of this embodiment, the request processing module 403 may be further used to: obtain the read / write data range, command type, and data read / write length of the target read / write operation request; obtain the virtual disk read / write range, the authorization information of the target physical storage medium, and the allowed data length value; when the authorization information is write-protected or read-only, if the command type of the target read / write operation request is a write command, then the command parameters of the target read / write operation request are invalid; if the read / write data range is within the virtual disk read / write range, and the data read / write length is less than the allowed data length value, then the command parameters of the target read / write operation request are normal.

[0082] For example, in some other embodiments of this embodiment, the above-mentioned device may further include an exception handling module, which can be used to obtain the current storage status and the disk status of the virtual disk; if the storage status is damaged or disconnected, all data read and write paths between the host and the storage device are disconnected, and the host enters a timeout processing flow; if the storage status is silent, the processing of read and write operation requests issued by the host is suspended, and the target read and write operation requests are stored in a pre-built request waiting queue; if the storage status is starting up, the target read and write operation requests are stored in a pre-built request waiting queue, and after the startup is completed, each target read and write operation request is processed in order of the time it was added to the request waiting queue; if the disk status is disconnected, an error code indicating that the virtual disk is disconnected is sent to the host, and a virtual disk online monitoring thread is started; when the virtual disk is detected to be online, virtual disk recovery information is sent to the host; if the disk status is silent, the target read and write operation requests are stored in a pre-built request waiting queue, a request time monitoring thread is started, and read and write operation requests in the request waiting queue whose waiting time exceeds a preset waiting time threshold are discarded.

[0083] The data read / write device mentioned above is described from the perspective of functional modules. Furthermore, the present invention also provides an electronic device, which is described from the perspective of hardware. Figure 5 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present invention. For example... Figure 5 As shown, the electronic device includes a memory 50 for storing a computer program; and a processor 51 for executing the computer program to implement the steps of the data read / write method as described in any of the above embodiments.

[0084] The processor 51 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 51 may also be a controller, microcontroller, microprocessor, or other data processing chip. The processor 51 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 51 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 51 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, the processor 51 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0085] The memory 50 may include one or more computer non-volatile storage media, which may be non-transitory. The memory 50 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the memory 50 may be an internal storage unit of an electronic device, such as a server hard drive. In other embodiments, the memory 50 may be an external storage device of an electronic device, such as a plug-in hard drive on a server, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Furthermore, the memory 50 may include both internal and external storage units of the electronic device. The memory 50 can be used not only to store application software and various types of data installed on the electronic device, such as program code during the execution of data read / write methods, but also to temporarily store data that has been output or will be output. In this embodiment, the memory 50 is used to store at least the following computer program 501, which, after being loaded and executed by the processor 51, can implement the relevant steps of the data read / write method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 50 may also include an operating system 502 and data 503, and the storage method may be temporary storage or permanent storage. The operating system 502 may include Windows, Unix, Linux, etc. The data 503 may include, but is not limited to, data corresponding to data read / write results.

[0086] In some embodiments, the aforementioned electronic device may further include a display screen 52, an input / output interface 53, a communication interface 54 (or network interface), a power supply 55, and a communication bus 56. The display screen 52 and input / output interface 53, such as a keyboard, are user interfaces. Exemplary user interfaces may also include standard wired interfaces, wireless interfaces, etc. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a display screen or display unit, used to display information processed in the electronic device and to display a visual user interface. The communication interface 54 may exemplary include wired and / or wireless interfaces, such as a Wi-Fi interface, a Bluetooth interface, etc., typically used to establish communication connections between the electronic device and other electronic devices. The communication bus 56 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0087] It is understood that if the data read / write method in the above embodiments is implemented as a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the related technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes, but is not limited to, various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, registers, hard disks, multimedia cards, card-type memories (e.g., SD or DX memories), magnetic memories, removable disks, CD-ROMs, magnetic disks, or optical disks. Based on this, the present invention also provides a non-volatile storage medium storing a computer program, which, when executed by a processor, performs the steps of the data read / write method described in any of the above embodiments.

[0088] It is understood that if the data read / write methods in the above embodiments are implemented as software functional units and sold or used as independent products, the computer software product may not need to be stored in a physical storage medium. For example, it can be directly transmitted to a computer or other device with information processing capabilities via a wired or wireless network to execute all or part of the steps of the methods in the various embodiments of the present invention. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the related technology, or all or part of the technical solution, can be embodied in the form of a software product. Based on this, the present invention also provides a computer program product storing a computer program, which, when executed by a processor, performs the steps of the data read / write method as described in any of the above embodiments.

[0089] The foregoing has provided a detailed description of the data read / write method, electronic device, non-volatile storage medium, computer program product, and server provided by this invention. The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Whether the units and algorithm steps of the various examples described in the disclosed embodiments are executed in electronic hardware or computer software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, and such implementations should not be considered beyond the scope of this invention. Several improvements and modifications can be made to this invention without departing from the principles of this invention, and these improvements and modifications also fall within the protection scope of this invention.

Claims

1. A data read / write method, characterized in that, Applied to target storage devices, including: First, assemble at least one target physical storage medium into a virtual disk and map the virtual disk to the host via an IP network link, FC fiber optic link, or RDMA high-speed network link. Then, configure the network adapter type and IP address according to the virtual machine's network requirements and use command-line tools to map the target physical storage medium to the virtual machine. Configure the fiber optic switch, target storage device, and server. Create a storage area on the fiber optic switch, divide the target storage device into multiple logical storage areas, and associate each logical storage area with the server. Install the basic library, check the RDMA connection status, configure RXE on the network card, and start the RDMA service. Receive a target read / write operation request sent by the host; the target read / write operation request is obtained by converting a disk data read / write operation request sent by the host to the target physical storage medium; The system retrieves the read / write data range, command type, and data read / write length of the target read / write operation request, as well as the read / write range of the virtual disk, the authorization information of the target physical storage medium, and the allowed data length. If the authorization information is write-protected or read-only, and the command type is a write command, the command parameters of the target read / write operation request are deemed invalid. If the read / write data range is within the virtual disk's read / write range, and the data read / write length is less than the allowed data length, the command parameters of the target read / write operation request are deemed normal. The system retrieves the storage status and the disk status of the virtual disk. If the storage status indicates normal read / write request processing, and the disk status is online, the storage environment is deemed to be in a normal state. The system retrieves the first path status between the target storage device and the target physical storage medium, and the second path status between the target storage device and the host. If neither the first nor the second path status is in a reset state, the storage path corresponding to the target read / write operation request is deemed to be in a normal state. If the target physical storage medium has no bad sectors and is in a connected state, the hardware storage conditions are deemed to be in a normal state. When the command parameters of the target read / write operation request are normal, and the current storage environment, the storage path corresponding to the target read / write operation request, and the hardware storage conditions are all in a normal state, then read / write operations are performed on the target physical storage medium based on the target read / write operation request. If the storage is in a damaged or disconnected state, all data read / write paths between the host and the storage device will be lost, and the host will enter a timeout processing flow. If the storage is in a silent state, or is in a startup state, or the disk is in a silent state, the target read / write operation request will be stored in a pre-built request waiting queue. If the disk is in a disconnected state, an error code indicating that the virtual disk is disconnected will be sent to the host, and a virtual disk online monitoring thread will be started. When the virtual disk is detected to be online, virtual disk recovery information will be sent to the host.

2. The data read / write method according to claim 1, characterized in that, After receiving the target read / write operation request sent by the host, the method further includes: A read / write request structure is pre-constructed; the read / write request structure includes command type, command lifecycle, physical storage medium identification information, and storage address; the command type includes read commands and write commands; By parsing the target read / write operation request, the target command type, target command lifecycle, target physical storage medium identification information, and logical block address are obtained; Based on the target command type, the target command lifecycle, the target physical storage medium identification information, and the logical block address, a read / write request structure corresponding to the target read / write operation request is generated, so as to perform read / write operations on the target physical storage medium based on the read / write request structure.

3. The data read / write method according to claim 1, characterized in that, After receiving the target read / write operation request sent by the host, the method further includes: Pre-build a dedicated thread for silent disks; When the virtual disk is in a silent state, each target read / write operation request is stored in the request waiting queue; When a target read / write operation request in the waiting queue is detected to be awakened, the silent disk dedicated thread is invoked to process the awakened target read / write operation request.

4. The data read / write method according to claim 1, characterized in that, Before performing read / write operations on the target physical storage medium based on the target read / write operation request, the method further includes: If at least one of the path states of the target storage device, the target physical storage medium, and the host is in a reset state, an error code indicating that the path state is incorrect is sent to the host. When the target physical storage medium is disconnected, a notification message is sent to the host that data cannot be written or read. If the command type corresponding to the target read / write operation request is a write command, obtain the bad sector data and the number of disconnections of the target physical storage medium; If the storage address of the data to be written contains a sector with bad sectors and / or the number of disconnections of the target physical storage medium exceeds a preset threshold, a notification message indicating that the data cannot be written is sent to the host.

5. The data read / write method according to any one of claims 1 to 4, characterized in that, The current storage environment includes the storage state and the disk state of the virtual disk. After receiving the target read / write operation request sent by the host, the process further includes: Obtain the current storage status and the disk status of the virtual disk; If the storage state is silent, then the processing of read and write operation requests issued by the host will be paused. If the storage status is in the startup state, then after startup is completed, each target read / write operation request will be processed in the order of the time it was added to the request waiting queue. If the disk is in a silent state, a request time monitoring thread is started, and read / write operation requests in the request waiting queue that have a waiting time exceeding a preset waiting time threshold are discarded.

6. A data read / write device, characterized in that, include: The virtualization module is used to pre-assemble at least one target physical storage medium into a virtual disk and map the virtual disk to the host via an IP network link, an FC fiber optic link, or an RDMA high-speed network link. It configures the network adapter type and IP address according to the virtual machine's network requirements, and uses command-line tools to map the target physical storage medium to the virtual machine. It also configures the fiber optic switch, the target storage device, and the server, creates storage areas on the fiber optic switch, divides the target storage device into multiple logical storage areas, and associates each logical storage area with the server. Install the basic library, check the RDMA connection status, configure RXE on the network card, and start the RDMA service; The request receiving module is used to receive the target read / write operation request sent by the host; the target read / write operation request is obtained by converting the disk data read / write operation request sent by the host to the target physical storage medium; The request processing module is used to perform read and write operations on the target physical storage medium based on the target read and write operation request when the command parameters of the target read and write operation request are normal, and the current storage environment, the storage path corresponding to the target read and write operation request, and the hardware storage conditions are all in a normal state. The request processing module is further configured to: obtain the read / write data range, command type, and data read / write length of the target read / write operation request, and obtain the read / write range of the virtual disk, the authorization information of the target physical storage medium, and the allowed data length value; when the authorization information is write-protected or read-only, and the command type is a write command, determine that the command parameters of the target read / write operation request are invalid; when the read / write data range is within the read / write range of the virtual disk, and the data read / write length is less than the allowed data length value, determine that the command parameters of the target read / write operation request are normal. Get the storage status and the disk status of the virtual disk. If the storage status is processing read and write requests normally and the disk status is online, then the storage environment is determined to be in a normal state. The system obtains the first path status between the target storage device and the target physical storage medium, and the second path status between the target storage device and the host. If neither the first path status nor the second path status is in a reset state, it is determined that the storage path corresponding to the target read / write operation request is in a normal state. If the target physical storage medium has no bad sectors and is in a connected state, then the hardware storage conditions are considered to be in a normal state. The exception handling module is used to prevent the host from entering a timeout process if the storage is in a damaged or disconnected state, in which case all data read and write paths between the host and the storage device will be lost. If the storage status is silent, or the disk status is silent, then the target read / write operation request is stored in a pre-built request waiting queue. If the disk is in an offline state, an error code indicating that the virtual disk is offline is sent to the host, and a virtual disk online monitoring thread is started. When the virtual disk is detected to be online, virtual disk recovery information is sent to the host.

7. An electronic device, characterized in that, It includes a processor and a memory, wherein the processor is configured to implement the steps of the data read / write method as described in any one of claims 1 to 5 when executing a computer program stored in the memory.

8. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores a computer program, which, when executed by a processor, implements the steps of the data read / write method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Virtual storage method and equipment thereof

    CN103516755A

  • Read-write optimization method and system of disk cache system

    CN105843559A