Method, apparatus, and computer device for writing or reading data from a virtual disk
By not configuring the state cache in the virtual disk cache structure, but configuring the status information on the virtual queue, the PCIe bus bandwidth occupation problem when the VIRTIO-based virtual disk frequently writes or reads out data, improving performance.
Patent Information
- Application Number
- CN202210758317.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2042-06-30
AI Technical Summary
When VIRTIO-based virtual disks frequently write or read out data, they will occupy a large amount of PCIe bus bandwidth, resulting in a degradation of read and write performance.
In the cache structure of the virtual disk, the state information is not configured, but the state information is configured in the virtual queue to reduce memory read and write operations, and the data writing or reading process is realized through the interaction between the front-end disk drive and the back-end disk device.
By reducing memory read and write operations, the PCIe bus bandwidth usage is reduced and the writing or read performance of virtual disks is improved.
Smart Images

Figure CN115098030B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and particularly to a method, apparatus, and computer device for writing or reading data from a virtual disk. Background Art
[0002] VIRTIO (Virtual I / O Device) is a commonly used semi-virtualized I / O framework protocol. In the prior art, for a virtual disk based on VIRTIO, since a status cache is required to specifically store the status information (such as success / failure / unsupported) after each write data request or read data request is executed, during the execution of a write data request or a read data request, when filling the cache address of the status cache into an entry of the descriptor table of Virtqueue (Virtual queue), 1 memory read operation is required; after completing a write data request or a read data request, when writing the status information back to the status cache, 1 memory write operation is also required. In other words, for each write data request or read data request, in order to write the status information back to the status cache, 1 memory read operation and 1 memory write operation are required, which altogether occupy 2 PCIe (Peripheral Component Interconnect express) bus bandwidths. Therefore, when a virtual disk based on VIRTIO frequently writes or reads data, it will occupy a large amount of PCIe bus bandwidth, thus reducing the read / write performance of the virtual disk based on VIRTIO. Summary of the Invention
[0003] This application provides a method, apparatus, and computer device for writing or reading data from a virtual disk, which can solve the problem that when a virtual disk frequently writes or reads data, it will occupy a large amount of PCIe bus bandwidth, thus reducing the read / write performance of the virtual disk based on VIRTIO.
[0004] In a first aspect of this application, a method for writing data to a virtual disk is provided. The virtual disk includes a front-end disk driver, a virtual queue, and a back-end disk device. The method includes:
[0005] When receiving a write data request, the front-end disk driver configures a cache structure including a header cache and a data cache, and fills the write guidance information carried in the request into the header cache, and fills the data to be written carried in the request into the data cache, where the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed;
[0006] The front - end disk drive configures the address information of the cache structure in the virtual queue and sends a first notification to the back - end disk device;
[0007] When receiving the first notification, the back - end disk device obtains the address information of the cache structure from the virtual queue, and according to the address information of the cache structure, reads the write guidance information from the head cache of the cache structure and reads the data to be written from the data cache of the cache structure;
[0008] The back - end disk device writes the data to be written into the physical disk according to the write guidance information and configures the status information in the virtual queue.
[0009] In a second aspect of the present application, a method for reading data from a virtual disk is provided. The virtual disk includes a front - end disk drive, a virtual queue, and a back - end disk device. The method includes:
[0010] When receiving a request for reading data, the front - end disk drive configures a cache structure including a head cache and a data cache, and fills the read - out guidance information carried by the request into the head cache, where the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed;
[0011] The front - end disk drive configures the address information of the cache structure in the virtual queue and sends a second notification to the back - end disk device;
[0012] When receiving the second notification, the back - end disk device obtains the address information of the cache structure from the virtual queue, and according to the address information of the cache structure, reads the read - out guidance information from the head cache of the cache structure;
[0013] The back - end disk device reads the data to be read out from the physical disk according to the read - out guidance information and fills it into the data cache of the cache structure;
[0014] After filling the data to be read out into the data cache, the back - end disk device configures the status information in the virtual queue.
[0015] In a third aspect of the present application, a device for writing data to a virtual disk is provided. The virtual disk includes a front - end disk drive, a virtual queue, and a back - end disk device. The device includes:
[0016] A configuration and filling module, which is used to, when receiving a request for writing data, configure a cache structure including a header cache and a data cache through the front-end disk drive, and fill the writing guidance information carried by the request into the header cache, and fill the data to be written carried by the request into the data cache, wherein the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed;
[0017] A configuration and notification module, which is used to configure the address information of the cache structure into a virtual queue through the front-end disk drive, and send a first notification to the back-end disk device;
[0018] An acquisition and reading module, which is used to, when receiving the first notification, acquire the address information of the cache structure from the virtual queue through the back-end disk device, and according to the address information of the cache structure, read the writing guidance information from the header cache of the cache structure and read the data to be written from the data cache of the cache structure;
[0019] A writing and configuration module, which is used to write the data to be written into a physical disk according to the writing guidance information through the back-end disk device, and configure the status information into the virtual queue.
[0020] In a fourth aspect of the present application, there is provided a device for reading data from a virtual disk. The virtual disk includes a front-end disk drive, a virtual queue, and a back-end disk device. The method includes:
[0021] A configuration and filling module, which is used to, when receiving a request for reading data, configure a cache structure including a header cache and a data cache through the front-end disk drive, and fill the reading guidance information carried by the request into the header cache, wherein the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed;
[0022] A configuration and notification module, which is used to configure the address information of the cache structure into the virtual queue through the front-end disk drive, and send a second notification to the back-end disk device;
[0023] An acquisition and reading module, which is used to, when receiving the second notification, acquire the address information of the cache structure from the virtual queue through the back-end disk device, and according to the address information of the cache structure, read the reading guidance information from the header cache of the cache structure;
[0024] A reading and filling module, which is used to read the data to be read from the physical disk according to the reading guidance information through the back-end disk device, and fill it into the data cache of the cache structure;
[0025] A configuration module, after filling the data to be read into the data cache, configures the status information in the virtual queue through the backend disk device.
[0026] In a fifth aspect of the present application, there is provided a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method provided in the first aspect or the second aspect of the present application are implemented.
[0027] In a sixth aspect of the present application, there is provided a computer-readable medium storing a computer program, and when the computer program is executed by a processor, the steps of the method provided in the first aspect or the second aspect of the present application are implemented.
[0028] In a seventh aspect of the present application, there is provided a computer program product including a computer program, and when the computer program is executed by a processor, the steps of the method provided in the first aspect or the second aspect of the present application are implemented. Description of the Drawings
[0029] In order to more clearly illustrate the technical solutions in the specific embodiments of the present application, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced herein. Obviously, the drawings presented herein are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0030] Figure 1 It is a schematic flowchart of a method for writing data to a virtual disk provided in the first embodiment of the present application;
[0031] Figure 2 It is a schematic flowchart of a method for reading data from a virtual disk provided in the second embodiment of the present application;
[0032] Figure 3 It is a schematic diagram of a device for writing data to a virtual disk provided in the third embodiment of the present application;
[0033] Figure 4 It is a schematic diagram of a device for reading data from a virtual disk provided in the fourth embodiment of the present application;
[0034] Figure 5 It is a schematic diagram of a computer device provided in the fifth embodiment of the present application. Detailed Embodiments
[0035] Embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not used to limit the protection scope of the present application.
[0036] In addition, it should be noted that for the convenience of description, only the parts related to the present application are shown in the drawings. Without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
[0037] It should be noted that the concepts such as "first", "second", etc. mentioned in the present application are only used to distinguish different systems, devices, modules or units, etc., and are not used to limit the order of functions performed by these systems, devices, modules or units, etc. or their interdependent relationships.
[0038] It should be noted that the modifications of "one" and "plural" mentioned in the present application are illustrative rather than restrictive. Those skilled in the art should understand that unless clearly specified otherwise in the context, it should be understood as "one or more".
[0039] The present application provides a method for writing data to or reading data from a virtual disk. In the present application, the virtual disk is a virtual I / O device based on Virtio (Virtual I / O Device). Generally, multiple virtual machines can run simultaneously on the host operating system of a server. Inside a virtual machine, there can be multiple virtual I / O devices based on Virtio (for example, common virtual network devices and virtual disk devices, etc.).
[0040] The virtual disk may include a front - end disk driver, a virtual queue (Virtqueue), and a back - end disk device. Among them, the front - end disk driver is a Virtio - based front - end driver, that is, the driver of the virtual disk loaded by the guest operating system running inside the virtual machine, which is used to receive requests in the user plane (for example, a request to write data to the virtual disk or a request to read data from the virtual disk), and then encapsulate the request according to the Virtio protocol and send it to the back - end disk device. The back - end disk device is a Virtio - based back - end device, which is used to receive and parse the request sent by the front - end disk driver according to the Virtio protocol, complete the request from the actual physical disk, and notify the front - end disk driver through the interrupt mechanism. The front - end disk driver and the back - end disk device interact relying on the Virtio - based virtual queue.
[0041] Please refer to Figure 1 , Figure 1 FIG. is a schematic flow chart of a method for writing data to a virtual disk provided in the first embodiment of the present application. In the first embodiment of the present application, the method for writing data to the virtual disk may include the following steps:
[0042] Step S101, when receiving a request to write data, the front - end disk driver configures a cache structure including a header cache and a data cache, and fills the write guidance information carried by the request into the header cache, and fills the data to be written carried by the request into the data cache. Among them, the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed.
[0043] Specifically, when a user operates on the guest operating system of the virtual machine to write data to the virtual disk, the guest operating system sends a request to write data to the front - end disk driver of the virtual disk. When receiving the request to write data, the front - end disk driver configures a cache structure. The cache structure includes a header cache and a data cache. In the present application, the cache structure does not include a status cache. The status cache is a 1 - byte cache that can be used to store the status information after the request to write data is executed. For example, the status information may include success, failure, not supported, etc. The header cache is used to store the write guidance information carried by the request to write data. The data cache is used to store the data to be written carried by the request to write data. The data to be written is the data to be written to the virtual disk.
[0044] In a modified embodiment of the first embodiment of the present application, the write guidance information may include information such as the disk sector where the data to be written is located.
[0045] Step S103, the front-end disk driver configures the address information of the cache structure in the virtual queue, and sends a first notification to the back-end disk device.
[0046] Specifically, after the cache structure is configured and the write guidance information and the data to be written are respectively filled into the header cache and the data cache, the front-end disk driver configures the address information of the cache structure in the virtual queue.
[0047] In a modified embodiment of the first embodiment of the present application, the virtual queue may include a descriptor table and an available ring table. The step of the front-end disk driver configuring the address information of the cache structure in the virtual queue specifically includes:
[0048] The front-end disk driver configures the address information of the cache structure in an entry of the descriptor table.
[0049] The front-end disk driver configures the address information of the entry of the descriptor table in the storage location pointed to by the current index of the available ring table.
[0050] Specifically, the descriptor table is used to store the address information of the cache structure. The descriptor table may include multiple entries. Adjacent two entries are linked by pointers. The cache structure may include multiple cache blocks. Each entry may be used to store the address information of one cache block. The header cache may occupy one or more cache blocks, and the data cache may also occupy one or more cache blocks. When the header cache occupies one cache block, one entry can store the address information of the header cache. When the data cache occupies multiple cache blocks, multiple entries are required to store the address information of the data cache, where the number of the multiple entries is the same as the number of the multiple cache blocks.
[0051] The available ring table is used to store the address information of the entries of the descriptor table. In other words, the available ring table stores pointers pointing to the entries of the descriptor table. When the front-end disk driver configures the address information of the entry of the descriptor table in the storage location pointed to by the current index of the available ring table, the index value of the current index of the available ring table is updated, where the update method may be index value + 1.
[0052] In the first embodiment of the present application, after the address information of the cache structure is configured in the virtual queue, the front-end disk driver sends a first notification to the back-end disk device to notify the back-end disk device to read the data to be written from the cache structure.
[0053] In a modified embodiment of the first embodiment of the present application, the front - end disk drive sends a first notification to the back - end disk device by writing to a notification register located in the back - end disk device.
[0054] The method for writing data to a virtual disk provided in the first embodiment of the present application does not configure a status cache in the cache structure. Then, during the process of executing a write - data request, it is not necessary to fill the cache address of the 1 - byte status cache into a 16 - byte entry in the descriptor table of the virtual queue, thus saving one memory read operation.
[0055] Step S105: When receiving the first notification, the back - end disk device obtains the address information of the cache structure from the virtual queue, and, according to the address information of the cache structure, reads the write guidance information from the header cache of the cache structure and reads the data to be written from the data cache of the cache structure.
[0056] Specifically, in a modified embodiment of the first embodiment of the present application, the back - end disk device can receive the first notification by polling the notification register. When receiving the first notification, the back - end disk device can obtain the address information of the cache structure configured in the entry of the descriptor table according to the address information of the storage location pointed to by the current index of the available ring table.
[0057] In the first embodiment of the present application, after obtaining the address information of the cache structure from the virtual queue, the back - end disk device reads the write guidance information and the data to be written from the header cache and the data cache of the cache structure respectively according to the address information of the cache structure.
[0058] Step S107: The back - end disk device writes the data to be written to the physical disk according to the write guidance information, and configures the status information in the virtual queue.
[0059] Specifically, in the first embodiment of the present application, after obtaining the write guidance information and the data to be written, the back - end disk device writes the data to be written to the physical disk according to the write guidance information.
[0060] In a modified embodiment of the first embodiment of the present application, the virtual queue further includes a used ring table. The used ring table is used to store the address information of the entries of the descriptor table. In other words, the used ring table stores pointers pointing to the entries of the descriptor table.
[0061] In the first embodiment of the present application, after writing the data to be written into the physical disk, the backend disk device configures the status information in the virtual queue.
[0062] In a modified embodiment of the first embodiment of the present application, the step of the backend disk device configuring the status information in the virtual queue specifically includes:
[0063] The backend disk device configures the address information of the entry in the descriptor table and the status information at the storage location pointed to by the current index of the used ring table.
[0064] In a modified embodiment of the first embodiment of the present application, after configuring the status information, the backend disk device issues an interrupt to the front-end disk driver to notify that the request for writing the data has been completed; and, the front-end disk driver reclaims the cache structure according to the status information.
[0065] The method for writing data to a virtual disk provided by the first embodiment of the present application configures the status information in the used ring table of the virtual queue, rather than in the cache structure. After the request for writing data is completed, there is no need to write the status information back to the cache structure, thus saving one memory write operation.
[0066] The method for writing data to a virtual disk provided by the first embodiment of the present application configures the status information in the virtual queue by not configuring a status cache in the cache structure, rather than in the cache structure. When executing a request for writing data, one memory read operation and one memory write operation can be saved respectively, and the occupation of the PCIe bus bandwidth can be reduced by two times. When writing data frequently to a virtual disk based on VIRTIO, the number of times of occupying the PCIe bus bandwidth can be reduced, thereby improving the writing performance of the virtual disk based on VIRTIO.
[0067] Please refer to Figure 2 , Figure 2 is a schematic flowchart of the method for reading data from a virtual disk provided by the second embodiment of the present application. In the second embodiment of the present application, the method for reading data from the virtual disk may include the following steps:
[0068] Step S201, when receiving a request for reading data, the front-end disk driver configures a cache structure including a header cache and a data cache, and fills the read guidance information carried by the request into the header cache. Wherein, the cache structure does not include a status cache, and the status cache is used to store the status information after the request is completed.
[0069] Specifically, when the user operates on the guest operating system of the virtual machine to read data from the virtual disk, the guest operating system sends a request to read data from the virtual disk to the front-end disk driver of the virtual disk. When receiving the request to read data, the front-end disk driver configures a cache structure. The cache structure includes a header cache and a data cache. In this application, the cache structure does not include a status cache. The status cache is a 1-byte cache that can be used to store the status information after the request to read data is executed. For example, the status information may include success, failure, unsupported, etc. The header cache is used to store the read guidance information carried by the request to read data. The data cache is used to store the data to be read. The data to be read is the data to be read from the physical disk.
[0070] It should be noted that in the second embodiment of this application, after configuring the cache structure, the front-end disk driver fills the read guidance information carried by the request to read data into the header cache, and keeps the data cache as an empty cache.
[0071] In a variant embodiment of the second embodiment of this application, the read guidance information may include information such as the disk sector where the data to be read is located.
[0072] Step S203, the front-end disk driver configures the address information of the cache structure in the virtual queue, and sends a second notification to the back-end disk device;
[0073] Specifically, after configuring the cache structure and filling the read guidance information into the header cache, the front-end disk driver configures the address information of the cache structure in the virtual queue.
[0074] In a variant embodiment of the second embodiment of this application, the virtual queue may include a descriptor table and an available ring table. The step of the front-end disk driver configuring the address information of the cache structure in the virtual queue specifically includes:
[0075] The front-end disk driver configures the address information of the cache structure in an entry of the descriptor table.
[0076] The front-end disk driver configures the address information of the entry of the descriptor table in the storage location pointed to by the current index of the available ring table.
[0077] Specifically, the descriptor table is used to store the address information of the cache structure. The descriptor table may include multiple table entries. Adjacent table entries are linked by pointers. The cache structure may include multiple cache blocks. Each table entry may be used to store the address information of a cache block. The header cache may occupy one or more cache blocks, and the data cache may also occupy one or more cache blocks. When the header cache occupies one cache block, one table entry can store the address information of the header cache. When the data cache occupies multiple cache blocks, multiple table entries are required to store the address information of the data cache, where the number of the multiple table entries is the same as the number of the multiple cache blocks.
[0078] The available ring table is used to store the address information of the table entries of the descriptor table. In other words, the available ring table stores pointers to the table entries of the descriptor table. When the front-end disk drive configures the address information of the table entry of the descriptor table at the storage location pointed to by the current index of the available ring table, the index value of the current index of the available ring table is updated, where the update method may be index value + 1.
[0079] In the second embodiment of the present application, after configuring the address information of the cache structure in the virtual queue, the front-end disk drive sends a second notification to the back-end disk device to notify the back-end disk device to read the data to be read out from the physical disk and fill it into the data cache of the cache structure.
[0080] In a modified embodiment of the second embodiment of the present application, the front-end disk drive sends the second notification to the back-end disk device by writing to the notification register located in the back-end disk device.
[0081] The method for reading out data from the virtual disk provided in the second embodiment of the present application does not configure a status cache in the cache structure. During the process of executing the request for reading out data, it is not necessary to fill the cache address of the 1-byte status cache into a 16-byte table entry of the descriptor table of the virtual queue, thereby saving one memory read operation.
[0082] Step S205, when receiving the second notification, the back-end disk device obtains the address information of the cache structure from the virtual queue, and according to the address information of the cache structure, reads the read-out guidance information from the header cache of the cache structure;
[0083] Specifically, in the modified embodiment of the second embodiment of the present application, the backend disk device can receive the second notification by polling the notification register. When receiving the second notification, the backend disk device can obtain the address information of the cache structure configured in the entry of the descriptor table according to the address information of the entry of the descriptor table stored at the storage location pointed to by the current index of the available ring table.
[0084] In the second embodiment of the present application, after obtaining the address information of the cache structure from the virtual queue, the backend disk device reads the read guidance information from the head cache of the cache structure according to the address information of the cache structure.
[0085] Step S207, the backend disk device reads the data to be read out from the physical disk according to the read guidance information and fills it into the data cache of the cache structure;
[0086] Specifically, in the second embodiment of the present application, after reading the read guidance information from the head cache of the cache structure, the backend disk device reads the data to be read out from the physical disk according to the read guidance information, and fills the data to be read out into the data cache of the cache structure according to the address information of the data cache of the cache structure.
[0087] Step S209, after filling the data to be read out into the data cache, the backend disk device configures the status information in the virtual queue.
[0088] Specifically, in the modified embodiment of the second embodiment of the present application, the virtual queue further includes a used ring table. The used ring table is used to store the address information of the entries of the descriptor table. In other words, the used ring table stores pointers pointing to the entries of the descriptor table. Further, the step of the backend disk device configuring the status information in the virtual queue specifically includes:
[0089] The backend disk device configures the address information of the entry of the descriptor table and the status information at the storage location pointed to by the current index of the used ring table.
[0090] In the modified embodiment of the second embodiment of the present application, after configuring the status information, the backend disk device initiates an interrupt to the front-end disk driver to notify that the request for writing data has been executed and completed; and, the front-end disk driver reclaims the cache structure according to the status information.
[0091] The method for reading data from a virtual disk provided by the second embodiment of the present application configures the status information in the used ring table of the virtual queue, rather than in the cache structure. After completing the request for reading data, there is no need to write the status information back to the cache structure, thus saving one memory write operation.
[0092] The method for reading data from a virtual disk provided by the second embodiment of the present application saves one memory read operation and one memory write operation respectively and reduces the occupation of the PCIe bus bandwidth by two times by not configuring a status cache in the cache structure, configuring the status information in the virtual queue, rather than in the cache structure, and executing one request for reading data. When frequently reading data from a VIRTIO-based virtual disk, the number of times of occupying the PCIe bus bandwidth can be reduced, thereby improving the reading performance of the VIRTIO-based virtual disk.
[0093] Please refer to Figure 3 , Figure 3 FIG. is a schematic diagram of an apparatus for writing data to a virtual disk provided by the third embodiment of the present application. In the third embodiment of the present application, the apparatus for writing data to the virtual disk may include: a configuration and filling module 301, a configuration and notification module 303, an acquisition and reading module 305, and a writing and configuration module 307.
[0094] The configuration and filling module 301 is configured to, when receiving a request for writing data, configure a cache structure including a header cache and a data cache through the front-end disk driver, and fill the writing guidance information carried in the request into the header cache, and fill the data to be written carried in the request into the data cache. The cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed.
[0095] Specifically, when a user operates on the guest operating system of a virtual machine to write data to a virtual disk, the guest operating system sends a request for writing data to the front-end disk driver of the virtual disk. When receiving the request for writing data, the front-end disk driver configures a cache structure. The cache structure includes a header cache and a data cache. In the present application, the cache structure does not include a status cache. The status cache is a 1-byte cache and can be used to store the status information after the request for writing data is executed. For example, the status information may include success, failure, not supported, etc. The header cache is used to store the writing guidance information carried in the request for writing data. The data cache is used to store the data to be written carried in the request for writing data. The data to be written is the data to be written to the virtual disk.
[0096] In a modified embodiment of the third embodiment of the present application, the write guidance information may include information such as the disk sector where the data to be written is located.
[0097] The configuration and notification module 303 is configured to configure the address information of the cache structure into the virtual queue through the front-end disk drive, and send a first notification to the back-end disk device.
[0098] Specifically, after the cache structure is configured and the write guidance information and the data to be written are filled into the header cache and the data cache respectively, the front-end disk drive configures the address information of the cache structure into the virtual queue.
[0099] In a modified embodiment of the third embodiment of the present application, the virtual queue may include a descriptor table and an available ring table. The configuration and notification module 303 is specifically configured to: configure the address information of the cache structure into an entry of the descriptor table through the front-end disk drive; configure the address information of the entry of the descriptor table into the storage location pointed to by the current index of the available ring table through the front-end disk drive.
[0100] Specifically, the descriptor table is used to store the address information of the cache structure. The descriptor table may include multiple entries. Adjacent two entries are linked by pointers. The cache structure may include multiple cache blocks. Each entry may be used to store the address information of one cache block. The header cache may occupy one or more cache blocks, and the data cache may also occupy one or more cache blocks. When the header cache occupies one cache block, one entry can store the address information of the header cache. When the data cache occupies multiple cache blocks, multiple entries are required to store the address information of the data cache, where the number of the multiple entries is the same as the number of the multiple cache blocks.
[0101] The available ring table is used to store the address information of the entries of the descriptor table. In other words, the available ring table stores pointers pointing to the entries of the descriptor table. When the front-end disk drive configures the address information of the entry of the descriptor table into the storage location pointed to by the current index of the available ring table, the index value of the current index of the available ring table is updated, where the update method may be index value + 1.
[0102] In the third embodiment of the present application, after the address information of the cache structure is configured into the virtual queue, the front-end disk drive sends a first notification to the back-end disk device to notify the back-end disk device to read the data to be written from the cache structure.
[0103] In a modified embodiment of the third embodiment of the present application, the front-end disk drive sends a first notification to the back-end disk device by writing to a notification register located in the back-end disk device.
[0104] The apparatus for writing data to a virtual disk provided in the third embodiment of the present application does not configure a status cache in the cache structure. During the process of executing a request for writing data, it is not necessary to fill the cache address of the 1-byte status cache into a 16-byte entry in the descriptor table of the virtual queue, thereby saving one memory read operation.
[0105] The obtaining and reading module 305 is configured to, when receiving the first notification, obtain the address information of the cache structure from the virtual queue through the back-end disk device, and according to the address information of the cache structure, read the write guidance information from the header cache of the cache structure and read the data to be written from the data cache of the cache structure.
[0106] Specifically, in a modified embodiment of the third embodiment of the present application, the back-end disk device can receive the first notification by polling the notification register. When receiving the first notification, the back-end disk device can obtain the address information of the cache structure configured in the entry of the descriptor table according to the address information of the storage location pointed to by the current index of the available ring table.
[0107] In the third embodiment of the present application, after obtaining the address information of the cache structure from the virtual queue, the back-end disk device reads the write guidance information and the data to be written from the header cache and the data cache of the cache structure respectively.
[0108] The writing and configuration module 307 is configured to write the data to be written to a physical disk through the back-end disk device according to the write guidance information, and configure the status information in the virtual queue.
[0109] Specifically, in the third embodiment of the present application, after obtaining the write guidance information and the data to be written, the back-end disk device writes the data to be written to a physical disk according to the write guidance information.
[0110] In a modified embodiment of the third embodiment of the present application, the virtual queue further includes a used ring table. The used ring table is used to store the address information of the entries of the descriptor table. In other words, the used ring table stores pointers pointing to the entries of the descriptor table.
[0111] In the third embodiment of the present application, after writing the data to be written into the physical disk, the backend disk device configures the status information in the virtual queue.
[0112] In a modified embodiment of the third embodiment of the present application, the writing and configuration module 307 is specifically configured to: configure the address information of the entry of the descriptor table and the status information at the storage location pointed to by the current index of the used ring table through the backend disk device.
[0113] In a modified embodiment of the third embodiment of the present application, the apparatus for writing data to the virtual disk further includes a recycling module. The recycling module is used to initiate an interrupt to the front-end disk driver through the backend disk device after the backend disk device configures the status information, so as to notify that the request for writing data is completed; and, recycle the cache structure according to the status information through the front-end disk driver.
[0114] The apparatus for writing data to the virtual disk provided in the third embodiment of the present application configures the status information in the used ring table of the virtual queue, rather than in the cache structure. After the request for writing data is completed, there is no need to write the status information back to the cache structure, thus saving one memory write operation.
[0115] The apparatus for writing data to the virtual disk provided in the third embodiment of the present application configures the status information in the virtual queue by not configuring the status cache in the cache structure, rather than in the cache structure. When executing a request for writing data, one memory read operation and one memory write operation can be saved respectively, and the occupation of the PCIe bus bandwidth is reduced by 2 times. When writing data frequently to the virtual disk based on VIRTIO, the number of times of occupying the PCIe bus bandwidth can be reduced, thereby improving the writing performance of the virtual disk based on VIRTIO.
[0116] Please refer to Figure 4 , Figure 4 is a schematic flowchart of an apparatus for reading data from a virtual disk provided in the fourth embodiment of the present application. In the fourth embodiment of the present application, the apparatus for reading data from the virtual disk may include: a configuration and filling module, a configuration and notification module, an acquisition and reading module, a reading and filling module, and a configuration module.
[0117] The configuration and filling module 401 is configured to, when receiving a request for reading data, configure a cache structure including a header cache and a data cache through the front-end disk driver, and fill the header cache with the read guiding information carried by the request. Wherein, the cache structure does not include a status cache, and the status cache is used to store the status information after the request is completed.
[0118] Specifically, when the user operates on the guest operating system of the virtual machine to read data from the virtual disk, the guest operating system sends a request to read data from the virtual disk to the front-end disk driver of the virtual disk. When receiving the request to read data, the front-end disk driver configures a cache structure. The cache structure includes a header cache and a data cache. In this application, the cache structure does not include a status cache. The status cache is a 1-byte cache that can be used to store the status information after the request to read data is executed. For example, the status information may include success, failure, not supported, etc. The header cache is used to store the read guidance information carried by the request to read data. The data cache is used to store the data to be read. The data to be read is the data to be read from the physical disk.
[0119] It should be noted that in the fourth embodiment of this application, after the cache structure is configured, the front-end disk driver fills the read guidance information carried by the request to read data into the header cache, and keeps the data cache as an empty cache.
[0120] In a modified embodiment of the fourth embodiment of this application, the read guidance information may include information such as the disk sector where the data to be read is located.
[0121] The configuration and notification module 403 configures the address information of the cache structure in the virtual queue through the front-end disk driver, and sends a second notification to the back-end disk device;
[0122] Specifically, after the cache structure is configured and the read guidance information is filled into the header cache, the front-end disk driver configures the address information of the cache structure in the virtual queue.
[0123] In a modified embodiment of the fourth embodiment of this application, the virtual queue may include a descriptor table and an available ring table. The configuration and notification module 403 is specifically used for: configuring the address information of the cache structure in the entry of the descriptor table through the front-end disk driver; configuring the address information of the entry of the descriptor table in the storage location pointed to by the current index of the available ring table through the front-end disk driver.
[0124] Specifically, the descriptor table is used to store the address information of the cache structure. The descriptor table may include multiple table entries. Adjacent two table entries are linked by pointers. The cache structure may include multiple cache blocks. Each table entry may be used to store the address information of one cache block. The header cache may occupy one or more cache blocks, and the data cache may also occupy one or more cache blocks. When the header cache occupies one cache block, one table entry can store the address information of the header cache. When the data cache occupies multiple cache blocks, multiple table entries are required to store the address information of the data cache, where the number of the multiple table entries is the same as the number of the multiple cache blocks.
[0125] The available ring table is used to store the address information of the table entries of the descriptor table. In other words, the available ring table stores pointers pointing to the table entries of the descriptor table. When the front-end disk drive configures the address information of the table entry of the descriptor table at the storage location pointed to by the current index of the available ring table, the index value of the current index of the available ring table is updated, where the update method may be index value + 1.
[0126] In the fourth embodiment of the present application, after configuring the address information of the cache structure in the virtual queue, the front-end disk drive sends a second notification to the back-end disk device to notify the back-end disk device to read the data to be read out from the physical disk and fill it into the data cache of the cache structure.
[0127] In a modified embodiment of the fourth embodiment of the present application, the front-end disk drive sends the second notification to the back-end disk device by writing to the notification register located in the back-end disk device.
[0128] The device for reading out virtual disk data provided in the fourth embodiment of the present application does not configure a status cache in the cache structure. During the process of executing the request for reading out data, it is not necessary to fill the cache address of the 1-byte status cache into a 16-byte table entry of the descriptor table of the virtual queue, thereby saving one memory read operation.
[0129] The obtaining and reading module 405 is configured to, when receiving the second notification, obtain the address information of the cache structure from the virtual queue through the back-end disk device, and according to the address information of the cache structure, read the read-out guiding information from the header cache of the cache structure;
[0130] Specifically, in the modified embodiment of the fourth embodiment of the present application, the backend disk device may receive the second notification by polling the notification register. When receiving the second notification, the backend disk device may obtain the address information of the cache structure configured in the entry of the descriptor table according to the address information of the entry of the descriptor table stored at the storage location pointed to by the current index of the available ring table.
[0131] In the fourth embodiment of the present application, after obtaining the address information of the cache structure from the virtual queue, the backend disk device reads the read guidance information from the head cache of the cache structure according to the address information of the cache structure.
[0132] The read and fill module 407 is configured to read the data to be read from the physical disk according to the read guidance information through the backend disk device and fill it into the data cache of the cache structure.
[0133] Specifically, in the fourth embodiment of the present application, after reading the read guidance information from the head cache of the cache structure, the backend disk device reads the data to be read from the physical disk according to the read guidance information, and fills the data to be read into the data cache of the cache structure according to the address information of the data cache of the cache structure.
[0134] The configuration module 409 is configured to configure the status information in the virtual queue through the backend disk device after filling the data to be read into the data cache.
[0135] Specifically, in the modified embodiment of the fourth embodiment of the present application, the virtual queue further includes a used ring table. The used ring table is used to store the address information of the entries of the descriptor table. In other words, the used ring table stores pointers pointing to the entries of the descriptor table. Further, the configuration module 409 is specifically configured to: configure the address information of the entry of the descriptor table and the status information at the storage location pointed to by the current index of the used ring table through the backend disk device.
[0136] In the modified embodiment of the fourth embodiment of the present application, the device for reading data from the virtual disk further includes a recovery module. The recovery module is configured to initiate an interrupt to the front-end disk driver through the backend disk device to notify that the request for reading data has been completed after the backend disk device configures the status information; and recycle the cache structure according to the status information through the front-end disk driver.
[0137] The apparatus for reading out data from a virtual disk according to the fourth embodiment of the present application configures the status information in the used ring table of the virtual queue, rather than in the cache structure. After completing the request for reading out data, there is no need to write the status information back to the cache structure, thus saving one memory write operation.
[0138] The apparatus for reading out data from a virtual disk according to the fourth embodiment of the present application saves one memory read operation and one memory write operation respectively and reduces the occupation of the PCIe bus bandwidth by two times by not configuring a status cache in the cache structure and configuring the status information in the virtual queue rather than in the cache structure when executing a request for reading out data. When frequently reading out data from a VIRTIO-based virtual disk, the number of times of occupying the PCIe bus bandwidth can be reduced, thereby improving the read performance of the VIRTIO-based virtual disk.
[0139] Please refer to Figure 5 , Figure 5 FIG. is a schematic diagram of a computer device provided by the fifth embodiment of the present application. The computer device 500 may include a processing device (such as a central processing unit CPU, a graphics processing unit GPU, a data processing unit DPU, etc.) 501, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the computer device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0140] Generally, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the computer device 500 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 5 FIG. shows a computer device 500 having various devices, it should be understood that it is not required to implement or include all the shown devices. Instead, more or fewer devices may be implemented or included. Figure 5 Each block shown in FIG. may represent a device or, as needed, multiple devices.
[0141] In particular, according to some embodiments of the present application, the processes described above with reference to the process schematic diagrams can be implemented as computer software programs. For example, some embodiments of the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for executing the methods shown in the process schematic diagrams. In other words, the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps of the methods described in the first embodiment or the second embodiment. In such some embodiments, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, it executes the above functions defined in the methods of some embodiments of the present application.
[0142] It should be noted that the above-mentioned computer-readable medium in some embodiments of the present application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present application, the computer-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. In some embodiments of the present application, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program codes. 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 computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program codes contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0143] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LANs"), wide area networks ("WANs"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0144] The above computer-readable medium may be included in the above device; or may exist separately without being assembled into the computer device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the computer device, the computer device can implement the method provided in the first embodiment or the second embodiment.
[0145] Computer program code for performing the operations of some embodiments of the present application can be written in one or more programming languages or combinations thereof. The above programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0146] The flowchart illustrations and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of methods, apparatuses, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart illustration or block diagram may represent a module, a segment of a program, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than that noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowchart illustrations, and combinations of blocks in the block diagrams and / or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0147] The modules described in some embodiments of the present application can be implemented in software or in hardware.
[0148] The functions described above can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGA), Application Specific Integrated Circuits (ASIC), Application Specific Standard Products (ASSP), System on a Chip (SOC), Complex Programmable Logic Devices (CPLD), and the like.
[0149] The above description is only some preferred embodiments of the present application and an explanation of the technical principles applied. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present application is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, technical solutions formed by mutually replacing the above features with (but not limited to) technical features having similar functions disclosed in the embodiments of the present application.
Claims
1. A method for writing data to a virtual disk, characterized in that The virtual disk includes a front - end disk driver, a virtual queue, and a back - end disk device. The method includes: When a request for writing data is received, the front - end disk driver configures a cache structure including a header cache and a data cache, and fills the write - guiding information carried in the request into the header cache, and fills the data to be written carried in the request into the data cache. Wherein, the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed and completed; The front - end disk driver configures the address information of the cache structure in the virtual queue, and sends a first notification to the back - end disk device; When receiving the first notification, the back - end disk device obtains the address information of the cache structure from the virtual queue, and according to the address information of the cache structure, reads the write - guiding information from the header cache of the cache structure and reads the data to be written from the data cache of the cache structure; The back - end disk device writes the data to be written into the physical disk according to the write - guiding information, and configures the status information in the virtual queue.
2. The method according to claim 1, wherein The virtual queue includes a descriptor table and an available ring table. The step that the front - end disk driver configures the address information of the cache structure in the virtual queue includes: The front - end disk driver configures the address information of the cache structure in an entry of the descriptor table; The front - end disk driver configures the address information of the entry of the descriptor table in the storage location pointed to by the current index of the available ring table.
3. The method according to claim 2, wherein The step that when receiving the first notification, the back - end disk device obtains the address information of the cache structure from the virtual queue includes: When receiving the first notification, the back - end disk device obtains the address information of the cache structure configured in the entry of the descriptor table according to the address information of the entry of the descriptor table stored in the storage location pointed to by the current index of the available ring table.
4. The method according to claim 3, characterized in that, The virtual queue further includes a used ring table. The step that the back - end disk device configures the status information in the virtual queue includes: The back - end disk device configures the address information of the entry of the descriptor table and the status information in the storage location pointed to by the current index of the used ring table.
5. The method according to claim 1, wherein The method includes: After configuring the status information, the back - end disk device initiates an interrupt to the front - end disk driver to notify that the request has been executed and completed; The front - end disk driver reclaims the cache structure according to the status information.
6. The method according to claim 1, characterized in that The write - guiding information includes the disk sector where the data to be written is located.
7. The method according to claim 1, wherein The method includes: The front - end disk driver sends the first notification to the back - end disk device by writing to the notification register located in the back - end disk device.
8. A method for reading data from a virtual disk, characterized in that, The virtual disk includes a front - end disk driver, a virtual queue, and a back - end disk device. The method includes: When a request for reading out data is received, the front-end disk drive configures a cache structure including a head cache and a data cache, and fills the read-out guidance information carried in the request into the head cache, where the cache structure does not include a status cache for storing status information after the request is executed and completed; The front-end disk drive configures the address information of the cache structure in the virtual queue and sends a second notification to the back-end disk device; When receiving the second notification, the back-end disk device obtains the address information of the cache structure from the virtual queue and reads the read-out guidance information from the head cache of the cache structure according to the address information of the cache structure; The back-end disk device reads out the data to be read out from the physical disk according to the read-out guidance information and fills it into the data cache of the cache structure; After filling the data to be read out into the data cache, the back-end disk device configures the status information in the virtual queue.
9. The method according to claim 8, wherein The virtual queue includes a descriptor table and an available ring table. The step of the front-end disk drive configuring the address information of the cache structure in the virtual queue includes: The front-end disk drive configures the address information of the cache structure in an entry of the descriptor table; The front-end disk drive configures the address information of the entry of the descriptor table in the storage location pointed to by the current index of the available ring table.
10. The method according to claim 9, wherein The step that when receiving the second notification, the back-end disk device obtains the address information of the cache structure from the virtual queue includes: When receiving the second notification, the back-end disk device obtains the address information of the cache structure configured in the entry of the descriptor table according to the address information of the entry of the descriptor table stored in the storage location pointed to by the current index of the available ring table.
11. The method according to claim 10, wherein The virtual queue further includes a used ring table. The step that after filling the data to be read out into the data cache, the back-end disk device configures the status information in the virtual queue includes: After filling the data to be read out into the data cache, the back-end disk device configures the address information of the entry of the descriptor table and the status information in the storage location pointed to by the current index of the used ring table.
12. The method according to claim 8, wherein The method includes: After configuring the status information, the back-end disk device initiates an interrupt to the front-end disk drive to notify that the request has been executed and completed; The front-end disk drive reclaims the cache structure according to the status information.
13. The method according to claim 8, wherein The read-out guidance information includes the disk sector where the data to be read out is located.
14. The method according to claim 8, wherein The method includes: The front-end disk drive sends a second notification to the back-end disk device by writing to the notification register located in the back-end disk device.
15. A device for writing data to a virtual disk, characterized in that, The virtual disk includes a front-end disk drive, a virtual queue, and a back-end disk device. The device includes: A configuration and filling module, which is used to, when receiving a request for writing data, configure a cache structure including a header cache and a data cache through the front-end disk drive, and fill the write guidance information carried by the request into the header cache, and fill the data to be written carried by the request into the data cache, wherein the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed; A configuration and notification module, which is used to configure the address information of the cache structure into the virtual queue through the front-end disk drive, and send a first notification to the back-end disk device; An acquisition and reading module, which is used to, when receiving the first notification, acquire the address information of the cache structure from the virtual queue through the back-end disk device, and according to the address information of the cache structure, read the write guidance information from the header cache of the cache structure and read the data to be written from the data cache of the cache structure; A writing and configuration module, which is used to write the data to be written into the physical disk according to the write guidance information through the back-end disk device, and configure the status information into the virtual queue; 16. An apparatus for reading data from a virtual disk, characterized in that, The virtual disk includes a front-end disk drive, a virtual queue, and a back-end disk device, and the device includes: A configuration and filling module, which is used to, when receiving a request for reading out data, configure a cache structure including a header cache and a data cache through the front-end disk drive, and fill the read-out guidance information carried by the request into the header cache, wherein the cache structure does not include a status cache, and the status cache is used to store the status information after the request is executed; A configuration and notification module, which is used to configure the address information of the cache structure into the virtual queue through the front-end disk drive, and send a second notification to the back-end disk device; An acquisition and reading module, which is used to, when receiving the second notification, acquire the address information of the cache structure from the virtual queue through the back-end disk device, and according to the address information of the cache structure, read the read-out guidance information from the header cache of the cache structure; A read-out and filling module, which is used to read out the data to be read out from the physical disk according to the read-out guidance information through the back-end disk device, and fill it into the data cache of the cache structure; A configuration module, which is used to, after filling the data to be read out into the data cache, configure the status information into the virtual queue through the back-end disk device; 17. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 14.
18. A computer-readable medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 14.
19. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Data transmitting and routing method facing to virtual machine based on FPGA
CN101540764A
Intelligent network card equipment and bypass detection method of intelligent network card equipment
CN113472571A