WO2019237791A1 - 虚拟化缓存的实现方法及物理机 - Google Patents

虚拟化缓存的实现方法及物理机 Download PDF

Info

Publication number
WO2019237791A1
WO2019237791A1 PCT/CN2019/080074 CN2019080074W WO2019237791A1 WO 2019237791 A1 WO2019237791 A1 WO 2019237791A1 CN 2019080074 W CN2019080074 W CN 2019080074W WO 2019237791 A1 WO2019237791 A1 WO 2019237791A1
Authority
WO
WIPO (PCT)
Prior art keywords
cache
physical
virtual
machine
address
Prior art date
Application number
PCT/CN2019/080074
Other languages
English (en)
French (fr)
Inventor
陆丽娜
陈现
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP19819486.2A priority Critical patent/EP3783480B1/en
Publication of WO2019237791A1 publication Critical patent/WO2019237791A1/zh
Priority to US17/115,273 priority patent/US11397690B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
    • G06F12/0646Configuration or reconfiguration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0806Multiuser, multiprocessor or multiprocessing cache systems
    • G06F12/0842Multiuser, multiprocessor or multiprocessing cache systems for multiprocessing or multitasking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0868Data transfer between cache memory and other subsystems, e.g. storage devices or host systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0871Allocation or management of cache space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0873Mapping of cache memory to specific storage devices or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1027Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
    • G06F12/1036Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB] for multiple virtual address spaces, e.g. segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1027Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
    • G06F12/1045Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB] associated with a data cache
    • G06F12/1063Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB] associated with a data cache the data cache being concurrently virtually addressed
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0662Virtualisation aspects
    • G06F3/0664Virtualisation aspects at device level, e.g. emulation of a storage device or system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0662Virtualisation aspects
    • G06F3/0665Virtualisation aspects at area level, e.g. provisioning of virtual or logical volumes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/0292User address space allocation, e.g. contiguous or non contiguous base addressing using tables or multilevel address translation means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0806Multiuser, multiprocessor or multiprocessing cache systems
    • G06F12/084Multiuser, multiprocessor or multiprocessing cache systems with a shared cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0893Caches characterised by their organisation or structure
    • G06F12/0897Caches characterised by their organisation or structure with two or more cache hierarchy levels
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/14Protection against unauthorised use of memory or access to memory
    • G06F12/1458Protection against unauthorised use of memory or access to memory by checking the subject access rights
    • G06F12/1491Protection against unauthorised use of memory or access to memory by checking the subject access rights in a hierarchical protection system, e.g. privilege levels, memory rings
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • G06F2212/1024Latency reduction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/15Use in a specific computing environment
    • G06F2212/151Emulated environment, e.g. virtual machine
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/31Providing disk cache in a specific location of a storage system
    • G06F2212/311In host system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/31Providing disk cache in a specific location of a storage system
    • G06F2212/313In storage device
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/60Details of cache memory
    • G06F2212/601Reconfiguration of cache memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/65Details of virtual memory and virtual address translation
    • G06F2212/651Multi-level translation tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7201Logical to physical mapping or translation of blocks or pages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device

Definitions

  • the embodiments of the present application relate to the field of virtualization technology, and in particular, to a method and a physical machine for implementing a virtualized cache.
  • Virtualization technology uses software to redefine IT resources and virtualize one physical machine into many virtual machines with different hardware. Each virtual machine can run a different operating system, and the virtual machines are independent of each other. Therefore, in a virtualized environment, many applications originally running on physical machines will be migrated to virtual machines to achieve dynamic allocation and flexible scheduling of IT resources, improve IT resource utilization, and save IT costs.
  • Cache (Cache) technology is a scheme to improve data access performance by storing hot data stored on low-speed hardware media to high-speed media. As applications migrate to virtualized environments, caching, as a commonly used storage performance optimization technology, will also migrate to virtualized environments.
  • a virtual machine running on a physical machine is provided with a cache service through a physical machine memory or a high-performance storage medium; or, a storage server connected to the physical machine, such as a storage area network (storage area (network, SAN) equipment to provide caching services for virtual machines running on physical machines.
  • a virtual machine issues an input / output (I / O) operation request (also called a write / read request)
  • the virtual machine switches from non-root mode to root mode, and the I / O operation request is issued to the physical Machine or storage server, the virtual machine accesses the cache on the physical machine or storage server; after the cache access is complete, the virtual machine also needs to switch from root mode to non-root mode. That is, when a virtual machine accesses a cache, there is a virtualization switching overhead.
  • the embodiments of the present application provide a method and a physical machine for implementing a virtual cache, which can reduce the access delay of the virtual cache and improve the cache performance.
  • an embodiment of the present application provides a method for implementing a virtualized cache, which is applied to a physical machine.
  • a virtual machine runs on the physical machine, and cache metadata is stored on the physical machine.
  • the cache metadata includes a one-to-one mapping relationship between a plurality of virtual addresses and a plurality of first physical addresses.
  • the virtual address is used to indicate a position in a virtual disk, and the first physical address is a physical address cached by the virtual machine.
  • the method includes: obtaining an operation request issued by a virtual machine, where the operation request includes a first virtual address, and the operation request is used to request reading or writing data at a position indicated by the first virtual address in the virtual disk; if the metadata is cached If there is a target first physical address corresponding to the first virtual address, the target second physical address corresponding to the target first physical address is determined according to the pre-configured mapping relationship between the plurality of first physical addresses and the plurality of second physical addresses. Address, the second physical address is the physical address of the physical disk of the physical machine; and then, read or write data at the location indicated by the target second physical address in the physical disk of the physical machine.
  • the data in the virtual machine cache can be accessed without switching between the non-root mode and the root mode, thus saving time occupied by virtualization overhead, improving cache access rate and cache access performance.
  • reading or writing to-be-operated data at a position indicated by the target second physical address in the virtual machine cache specifically includes: in a non-root mode, the target second physical address is in the virtual machine cache.
  • the indicated position reads or writes the data to be operated, that is, accesses the data in the virtual machine cache in non-root mode.
  • the physical disk is a byte-addressable storage medium.
  • cache metadata is stored in the virtual machine's memory.
  • cache metadata stored on the virtual machine can be accessed without virtualization overhead.
  • the data is written into the virtual machine cache, and the position of the data in the virtual machine cache is expressed as Target the first physical address, and determine a target second physical address corresponding to the first target physical address according to a pre-configured mapping relationship between the plurality of first physical addresses and the plurality of second physical addresses;
  • the mapping relationship of the first virtual address is stored in the cache metadata.
  • the target first physical address corresponding to the first virtual address does not exist in the cache metadata, it can be determined that the virtual machine cache is not hit, and the data requested to be read or written by the operation request is not in the virtual machine cache. Then the data needs to be written into the virtual machine cache so that the data can be read directly from the virtual machine cache next time.
  • the first data is determined according to a quality of service (Qos) parameter of a virtual machine or a quality of service Qos parameter of a virtual disk in the virtual machine.
  • the Qos parameter includes at least one of a reserved value of the cache, an upper limit of the cache, or a priority of the cache.
  • This management includes cache allocation, cache flushing, cache elimination, cache size modification, cache attribute modification, and cache reuse.
  • unified management of the caches of each virtual machine can make cache management more flexible and lower management costs.
  • caches can be managed according to the QoS of different virtual machines, so as to provide better cache services for virtual machines.
  • the method further includes: allocating a part of the physical addresses in the physical disk to a cache of the virtual machine; establishing a mapping relationship between a plurality of first physical addresses and a plurality of second physical addresses.
  • the method further includes: the physical machine determines the first data from the caches of the N virtual machines, and then the first data is Delete from the caches of the N virtual machines, and delete the mapping relationship between the virtual address corresponding to the first data in the cache metadata and the first physical address.
  • the cache metadata can also be updated in a timely manner, so that the cache metadata is consistent with the cache condition of the virtual machine in real time.
  • determining the first data specifically includes: determining the first data according to a Qos parameter of a virtual machine or a Qos parameter of a virtual disk in the virtual machine.
  • the physical machine can eliminate the cache in the virtual machine according to the QoS corresponding to the different virtual machine.
  • the cache metadata further includes a cache state, and the cache state is used to indicate whether data in the virtual machine cache is flushed to the physical disk.
  • the method further includes: the physical machine from the N virtual machines Determine the second data in the cache, then flush the second data to the physical disk, and update the cache status of the second data in the cache metadata.
  • the physical machine can comprehensively consider the situation of each virtual machine, so as to determine the data in the cache of all virtual machines that need to be flushed most.
  • the method further includes: modifying a range of the physical address of the cache allocated to the virtual machine; and updating a plurality of first physical addresses according to the modified range of the physical address of the cache allocated to the virtual machine.
  • the method further includes: flashing back and deleting the third data in the virtual machine cache.
  • the operation of writing to the virtual machine cache can be suspended, so as to avoid the accumulation of too much data in the cache and the inability to reduce the cache space.
  • a second physical address corresponds to the first physical addresses of multiple virtual machines.
  • the respective first physical addresses of multiple virtual machines can be mapped to the same second physical address on the physical disk, and some of the physical addresses on the physical disk can be used by multiple virtual machine caches, thereby achieving reuse of cache space and saving The effect of cache cost.
  • an embodiment of the present application provides a physical machine including a virtual machine and a front-end driver, a physical disk, a virtual machine cache, a virtual disk, and a virtual machine memory.
  • the cache metadata is stored in the virtual machine memory.
  • the cache metadata includes a one-to-one mapping relationship between a plurality of virtual addresses and a plurality of first physical addresses.
  • the virtual addresses are used to represent positions in the virtual disk.
  • the address is the physical address of the virtual machine's cache;
  • the virtual machine is used to send an operation request to the front-end driver, and the operation request includes a first virtual address, and is used to request reading or writing data at a location indicated by the first virtual address in the virtual disk;
  • the front-end driver is used to obtain the operation request and operation request issued by the virtual machine; if the target first physical address corresponding to the first virtual address exists in the cache metadata, according to the pre-configured multiple first physical addresses and multiple The mapping relationship of the second physical address determines the target second physical address corresponding to the target first physical address, and the second physical address is the physical address of the physical disk of the physical machine; the target second physical address indicates in the physical disk of the physical machine Read or write data to the location.
  • the physical machine further includes a cache management module.
  • the cache management module is configured to write data into a virtual machine cache, and a position of the data in the virtual machine cache is represented as a target first physical address. And determining a target second physical address corresponding to the first target physical address according to a mapping relationship between a plurality of first physical addresses and a plurality of second physical addresses configured in advance; and mapping the target first physical address to the first virtual address Relationships are saved to cache metadata.
  • the cache management module is further configured to: allocate a part of the physical addresses in the physical disk to the cache of the virtual machine; and establish a mapping relationship between multiple first physical addresses and multiple second physical addresses.
  • the cache management module is further configured to: determine the first data from the caches of the N virtual machines; Deleted from the cache of N virtual machines;
  • the front-end driver is further configured to delete the mapping relationship between the virtual address corresponding to the first data in the cache metadata and the first physical address.
  • the management module is specifically configured to determine the first data according to the quality of service Qos parameter of the virtual machine or the quality of service Qos parameter of the virtual disk in the virtual machine.
  • the Qos parameter includes a cached reserve value, At least one of a cache upper limit value and a cache priority.
  • the cache metadata also includes a cache state, and the cache state is used to indicate whether the data in the virtual cache is flushed back to the physical disk
  • the cache management module is further configured to determine the second data from the caches of the N virtual machines; flash back the second data to the physical disk; and the processing module is further configured to update the cache status of the second data in the cache metadata.
  • the cache management module is specifically configured to determine the second data according to the quality of service Qos parameter of the virtual machine or the quality of service Qos parameter of the virtual disk in the virtual machine, and the Qos parameter includes a reserved value of the cache. , At least one of a cached upper limit or a cached priority.
  • the cache management module is further configured to: modify a range of a physical address of the cache allocated to the virtual machine; and update a plurality of first caches according to the modified range of the physical address of the cache allocated to the virtual machine.
  • an embodiment of the present application provides a physical machine, and a virtual machine runs on the physical machine.
  • the cache metadata of the virtual machine is stored in the cache, and the cache metadata includes a one-to-one mapping relationship between multiple virtual addresses and multiple first physical addresses.
  • the virtual addresses are used to indicate positions in the virtual disk.
  • the physical address is the physical address of the virtual machine's cache.
  • the physical machine includes:
  • An obtaining module configured to obtain an operation request issued by a virtual machine, where the operation request includes a first virtual address, and is used to request reading or writing data at a position indicated by the first virtual address in the virtual disk;
  • a processing module configured to: if the target first physical address corresponding to the first virtual address exists in the cache metadata, determine the target physical address according to a mapping relationship between a plurality of pre-configured first physical addresses and a plurality of second physical addresses; A target second physical address corresponding to the first physical address, and the second physical address is a physical address of a physical disk of a physical machine;
  • the read-write module is configured to read or write data at a position indicated by a target second physical address in a physical disk of a physical machine.
  • the physical disk is a byte-addressable storage medium.
  • the physical machine further includes a cache management module, configured to write data into the virtual machine cache if the target first physical address corresponding to the first virtual address does not exist in the cache metadata.
  • the position of the data in the virtual machine cache is expressed as a target first physical address, and a target number corresponding to the first target physical address is determined according to a mapping relationship between a plurality of pre-configured first physical addresses and a plurality of second physical addresses Two physical addresses.
  • the physical machine further includes a cache management module.
  • the cache management module is configured to: before the front-end driver obtains the operation request issued by the virtual machine, allocate a physical address space for the virtual machine cache; establish a physical address space A correspondence relationship between a plurality of first physical addresses and a plurality of second physical addresses in.
  • the cache management module is further configured to: allocate a physical address for the virtual machine cache; specifically, allocate a part of the physical address in the physical disk to the virtual machine cache, and establish a plurality of first physical addresses A mapping relationship between an address and a plurality of second physical addresses.
  • N virtual machines there are N virtual machines running on the physical machine, and N is a positive integer.
  • the physical machine includes a cache management module, and the cache management module is configured to determine the first data from the caches of the N virtual machines. Deleting the first data from the caches of the N virtual machines; the processing module is further configured to delete the correspondence between the virtual address corresponding to the first data and the first physical address in the cache metadata.
  • the cache management unit for determining the first data specifically includes: determining the first data according to the quality of service Qos parameter of the virtual machine or the quality of service Qos parameter of the virtual disk in the virtual machine, and the Qos parameter Including at least one of the reserved value of the cache, the upper limit of the cache, or the priority of the cache.
  • the cache metadata also includes a cache state, and the cache state is used to indicate whether the data in the virtual cache is flushed back to the physical disk
  • the physical machine includes a cache management module.
  • the cache management module is configured to: determine the second data from the caches of the N virtual machines; flash back the second data to the physical disk; and the processing module is further configured to update the second metadata in the cache metadata. The cache status of the data.
  • the cache management module is further configured to modify the range of the physical address of the cache allocated to the virtual machine; according to the modified range of the physical address in the partial physical disk of the cache allocated to the virtual machine To update the mapping relationship between the plurality of first physical addresses and the plurality of second physical addresses.
  • a second physical address corresponds to the first physical addresses of multiple virtual machines.
  • the respective first physical addresses of multiple virtual machines can be mapped to the same second physical address on the physical disk, and some of the physical addresses on the physical disk can be used by multiple virtual machine caches, thereby achieving reuse of cache space and saving The effect of cache cost.
  • an embodiment of the present application provides a physical machine including a processor and a computer-readable storage medium storing a computer program.
  • the processor is coupled to a computer-readable storage medium, and when the computer program is executed by the processor, the method for implementing a virtualized cache in any one of the foregoing possible implementation manners of the first aspect is implemented.
  • an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, which is characterized in that when the computer program is executed by a processor, any one of the possible implementation manners of the first aspect is implemented Implementation method of virtual cache.
  • an embodiment of the present application provides a computer program product.
  • the computer program product runs on a computer, the computer is caused to execute the method for implementing a virtual cache in any one of the possible implementation manners of the first aspect.
  • an embodiment of the present application provides a chip.
  • the chip includes a processor, and is configured to support a physical machine to implement a virtual cache implementation method in any one of the possible implementation manners of the first aspect.
  • FIG. 1 is a schematic diagram of a virtualization system provided by the prior art
  • FIG. 2 is a schematic diagram of a virtualization system according to an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of a device according to an embodiment of the present application.
  • FIG. 4 is a flowchart of a method for implementing a virtualized cache according to an embodiment of the present application
  • FIG. 5 is a flowchart of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 6 is a schematic diagram of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 7 is a flowchart of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 8 is a flowchart of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 9 is a flowchart of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 10 is a flowchart of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 11 is a flowchart of another method for implementing a virtualized cache according to an embodiment of the present application.
  • FIG. 12 is a correspondence diagram of a first physical address and a second physical address according to an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of a physical machine according to an embodiment of the present application.
  • Virtualization overhead refers to the cost of the central processing unit (CPU) switching between non-root mode (that is, client mode) and root mode (that is, kernel mode) during the implementation of the virtualized cache. time.
  • non-root mode that is, client mode
  • root mode that is, kernel mode
  • Virtualization technology considering system security, virtual machines usually cannot directly access various physical devices (such as network cards, disk devices, etc.) on the device.
  • input / output input / output, I / O
  • Operations such as read / write cache, read / write disk, etc.
  • issue sensitive instructions or generate certain interrupts, you need to switch from non-root mode to root mode.
  • the client state domain in the non-root mode needs to be saved, that is, the running state value of the virtual machine CPU, such as the control register (CR), code segment register (CS), and stack segment register , SS) or data segment register (DS).
  • the CPU needs to switch from root mode to non-root mode.
  • the CPU needs to load the client state domain that was saved when switching to root mode before. Among them, saving and loading the client state domain will make the switching process between root mode and non-root mode take a long time.
  • Virtual disk (Virtual disk) is a virtual disk in a remote computer in the local computer. It feels like a hard drive on this machine.
  • a virtual disk is a virtual disk with one or more disks in memory, which can speed up the data exchange speed of the disks, thereby increasing the speed of the computer.
  • the physical disk is the local disk of the physical machine.
  • Virtual machine memory is such that the virtual machine has its own memory space like a physical machine, and the physical machine can be allocated to the virtual machine's memory space.
  • the cache of the virtual machine is such that the virtual machine has its own cache like a physical machine, which can store data that the virtual machine frequently accesses.
  • Read cache principle Put hot data on storage hardware, that is, frequently accessed data, into the cache. In this way, when an application accesses the storage hardware, it can directly read the hot data from the cache to achieve the effect of improving read access performance.
  • Write cache principle Write data to the cache first, and then flush the data from the cache to the physical disk after a delay. In this way, when an application frequently writes data to the same area, it often accesses the cache, which can improve the performance of write access.
  • Flashback Writes the data in the cache to the physical disk.
  • the implementation method of the virtualized cache provided in the embodiment of the present application can enable the virtual machine to implement management of the virtual machine cache without switching between the non-root mode and the root mode, thereby saving time occupied by virtualization overhead and improving the virtual machine. Cache performance.
  • FIG. 2 shows a schematic architecture diagram of a virtualization system applicable to the method for implementing a virtualization cache provided by an embodiment of the present application.
  • the system 100 includes a physical machine 101 and a storage device 102.
  • Physical machine 101 runs N (positive integer) virtual machines 103, virtual machine monitor (VMM) 104, front-end driver 105 of the virtual machine, back-end driver of the virtual machine (back -end driver) 106 and cache management module 107.
  • N positive integer
  • VMM virtual machine monitor
  • each virtual machine 103 runs multiple application programs (applications, APPs), which can provide a variety of application services to users, and the physical machine 101 can be used to provide hardware support for the virtual machine 103.
  • the virtual machine monitor 104 for example, an open source system-based virtual machine (KVM) module or a XEN module, is used to manage the physical resources of the physical machine 101 and provide an interface for the virtual machine 103.
  • the front-end driver 105 is used to drive the virtual disk of the virtual machine, and cooperates with the cache management module 107 on the physical machine 101 to complete functions such as cache access, elimination, and flushing.
  • the front-end driver 105 is also used to manage the physical address and cache metadata of the virtual machine cache, and the cache metadata is used to determine whether to hit the virtual machine cache.
  • the front-end driver 105 may be specifically used to modify the range of the physical address space of the virtual machine cache, access and update cache metadata, and the like.
  • the back-end driver 106 (such as the open source QEMU software) is used to simulate a virtual disk with a cache to the virtual machine, including analyzing the cache configuration and cache policy set by the user, such as cache size, cache type, and cache priority. Simulate a virtual disk with a virtual machine cache that meets the user's configuration, and provide the simulation of the first physical address required by the front-end driver.
  • the cache management module 107 is configured to uniformly manage the caches of the N virtual machines on the physical machine 101, and specifically includes management tasks such as cache allocation, cache elimination, cache flushing, cache size modification, cache attribute modification, and regular synchronization of cache status.
  • the storage device 102 is configured to provide hardware storage for the physical machine 101 and the virtual machine 103.
  • the storage device 102 is a device for storing information.
  • the storage device 102 is a medium that uses information such as electricity, magnetism, or optics after digitizing the information, and may be referred to as a physical disk.
  • the storage device may specifically be a part of the physical machine 101, or may be another device other than the physical machine 101.
  • the storage device 102 may be a hard disk drive (HDD), a solid state drive (SSD), or a SAN device.
  • the system 100 may also include other modules, such as a memory device 108, which are not described in detail here.
  • the memory device 108 is configured to provide memory for a physical machine and a virtual machine, for example, to provide a memory space for the cache management module 107.
  • the memory device 108 may specifically be a part of the physical machine 101, or may be another device other than the physical machine 101.
  • the memory device 108 may be a random access memory (RAM) or a non-volatile memory (NVM).
  • RAM random access memory
  • NVM non-volatile memory
  • the physical machine 101 in FIG. 2 may be implemented by the computer system 300 in FIG. 3.
  • the computer system 300 includes at least one processor 301, a communication bus 302, a memory 303, and at least one communication interface 304.
  • the processor 301 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrations for controlling the execution of the program program of the present application. Circuit.
  • CPU central processing unit
  • ASIC application-specific integrated circuit
  • the communication bus 302 may include a path for transmitting information between the aforementioned components.
  • the communication interface 304 uses any device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc. .
  • RAN radio access network
  • WLAN wireless local area networks
  • the memory 303 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or an electronic memory device.
  • ROM read-only memory
  • EEPROM Erasable programmable read-only memory
  • EEPROM read-only memory
  • CD-ROM compact disc
  • optical disc storage including compact discs, laser discs, optical discs, Digital Versatile Disc, Blu-ray Disc, etc.
  • disk storage media or other magnetic storage devices or any other media that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.
  • the memory may exist independently and be connected to the processor through a bus.
  • the memory can also be integrated with the processor.
  • the memory 303 is configured to store application program code that executes the solution of the present application, and is controlled and executed by the processor 301.
  • the processor 301 is configured to execute application program code stored in the memory 303, thereby implementing a method for implementing a virtualized cache provided in the following embodiments of the present application.
  • the computer-executable instructions in the embodiments of the present application may also be referred to as application program codes, which are not specifically limited in the embodiments of the present application.
  • the processor 301 may include one or more CPUs, such as CPU0 and CPU1 in FIG. 3, and each CPU may support multiple virtual CPUs, which are also called VCPUs.
  • the computer system 300 may include multiple processors, such as the processor 301 and the processor 308 in FIG. 3. Each of these processors can be a single-CPU processor or a multi-CPU processor.
  • a processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
  • the computer system 300 may further include an output device 305 and an input device 306.
  • the output device 305 communicates with the processor 301 and can display information in a variety of ways.
  • the output device 305 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. Wait.
  • the input device 306 communicates with the processor 301 and can accept user input in a variety of ways.
  • the input device 306 may be a mouse, a keyboard, a touch screen device, or a sensing device.
  • the computer system 300 described above may be a general-purpose communication device or a special-purpose communication device.
  • the embodiment of the present application does not limit the type of the computer system 300.
  • the computer system 300 may be a desktop computer, a portable computer, a network server, a personal digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, an embedded device, or a similar structure in FIG. 3 device.
  • PDA personal digital assistant
  • Each component in the computer system 300 may be deployed in the same computer device at the same time, or may be deployed in different computer devices located in a distributed system.
  • the embodiment of the present application provides a method for implementing a virtualized cache, which can be applied to a physical machine, where N virtual machines are running on the physical machine, and N is a positive integer.
  • Cache metadata is stored in the memory of the virtual machine, and the cache metadata includes a one-to-one mapping relationship between a plurality of virtual addresses and a plurality of first physical addresses.
  • the virtual address is used to indicate a position in the virtual disk, and the first physical address is a physical address cached by the virtual machine.
  • the front end of the virtual machine can see a first physical address space, that is, a physical address space represented by a physical address cached by the virtual machine.
  • the cache metadata is held in the virtual machine's memory.
  • a virtual address may correspond to a first physical address.
  • the mapping relationship between the virtual address and the first physical address can be expressed in multiple ways, such as a mapping table or a tree structure. Exemplarily, the mapping relationship between the virtual address and the first physical address can be seen in Table 1 below.
  • Operation address First physical address Operation address 1 First physical address 1 Operation address 2 First physical address 2 ... ...
  • a method for implementing a virtualized cache may include:
  • the operation request includes a first virtual address, and is used to request reading or writing data at a location indicated by the first virtual address in the virtual disk.
  • the operation request can also be called an I / O request, an I request is an input request or a write request, and an O request is an output request or a read request.
  • the operation request can be initiated by a storage-related application in the virtual machine, and these applications run on the VCPU, which can also be understood as a VCPU-issued storage-related operation request. Because the VCPU runs on the CPU of the physical machine, it can be understood as the CPU's operation request for obtaining the physical machine.
  • the operation request includes a first virtual address, and the first virtual address is used to indicate a position where the data to be operated is read or written in the virtual disk.
  • the specific form of the first virtual address may be various, for example, it may be the position offset O of the data to be operated on being read or written in the virtual disk, or it may be the data to be operated on being read or written in the virtual disk.
  • the input position offset O and the length L of the data to be operated may be the starting address of the position where the data to be operated is read or written in the virtual disk, or the data to be operated is read in the virtual disk.
  • the start address and the end address of the position to be fetched or written, or the start address and the length L of the position to be operated on where the data to be operated is read or written in the virtual disk, are not limited here.
  • the following description will be made by taking the first virtual address as a position offset O of data to be read or written in a virtual disk and a length L of the data to be operated.
  • the operation request is: reading data on disk D with offset O and length L.
  • disk D refers to the virtual disk of the virtual machine; "the offset on disk D is O and the length is L" can represent the first virtual address, which indicates that the area on virtual disk D is offset by O and the length is L Read the data to be operated (that is, the data to be read) at the position of the data; the data to be read is the data in the area of the disk D with an offset of O and a length of L.
  • the operation request is: write "hzujalbazkozujapzila" on disk D with an offset of 0, and the data length is L.
  • disk D refers to the virtual disk of the virtual machine; "offset on disk D is O” or “offset on disk D is O, and the length is L" indicates the first virtual address and indicates offset on virtual disk D It is 0, and the data to be operated (that is, data to be written) is written at the position where the area of length L is; the data to be written is data "hzujalbazkozujapzila" of length L.
  • the corresponding target second physical address, and the second physical address is the physical address of the physical disk of the physical machine.
  • the target first physical address refers to a first physical address corresponding to the first virtual address. If the target first physical address corresponding to the first virtual address exists in the cache metadata, the virtual machine cache is hit, that is, the data requested by the operation request is in the virtual machine cache. At this time, the cache metadata is stored in the virtual machine's memory, and the cache metadata in the virtual machine's memory can be directly accessed to find whether a target first physical address corresponding to the first virtual address exists, without the need to switch modes.
  • the operation request is to read data with offset 0 and length L on disk D
  • the first virtual address is offset 0 and length L on disk D
  • the upper offset is 0 and the length is the correspondence between the first physical address and the virtual machine cache.
  • the operation request is at an offset of 0 on disk D
  • "hzujalbazkozujapzila" is written, the data length is L
  • the first virtual address is O on disk D, and the length is L.
  • the cache metadata if the offset between the disk D is 0 and the length L corresponds to the first physical address, the virtual machine cache is hit.
  • the data at the location indicated by the first virtual address may be stored.
  • the physical machine if the target first physical address corresponding to the first virtual address exists in the cache metadata, the physical machine has allocated a cache for the virtual machine, the requested data is stored in the virtual machine cache, and the physical A correspondence relationship between a plurality of pre-configured first physical addresses and a plurality of second physical addresses is stored on the machine.
  • the second physical address refers to a physical address of a physical disk that provides a physical address space for a virtual machine cache.
  • the physical disk may be a hardware storage device 102 (or a hardware storage medium) in the virtualization system shown in FIG. 2.
  • the hardware device may be an HDD, an SSD, or a SAN device.
  • the target second physical address refers to a second physical address corresponding to the target first physical address.
  • the physical machine may search for the target second physical address corresponding to the target first physical address according to the saved correspondence between the plurality of first physical addresses and the plurality of second physical addresses.
  • an extended page table (EPT) is stored in a register of the CPU of the physical machine, and is used to save the correspondence between multiple first physical addresses and multiple second physical addresses.
  • the CPU passes the EPT Find a target second physical address corresponding to the target first physical address.
  • Second physical address First physical address 1 Second physical address 1 First physical address 2 Second physical address 1 First physical address 3 Second physical address 2 ... ...
  • each first physical address may correspond to a second physical address
  • each second physical address may correspond to one or more first physical addresses.
  • the physical machine can implement cache multiplexing. For details, see the detailed description of cache multiplexing below.
  • the physical machine After determining the target second physical address corresponding to the target first physical address, the physical machine reads or writes the data to be operated in the virtual machine cache at the position indicated by the target second physical address, so that it can be improved by accessing the virtual machine cache. Read or write access performance.
  • the operation request is to read data to be operated with an offset of O and a length of L on disk D
  • the cache metadata includes the target first physical corresponding to the offset of O on disk D and a length of L Address
  • the physical machine searches for the target second physical address corresponding to the target first physical address, and reads data at the location indicated by the target second physical address in the virtual machine cache.
  • the operation request is at an offset of 0 on disk D
  • "hzujalbazkozujapzila” is written, and the data length is L.
  • the cache metadata includes the offset of O on disk D, the length is L.
  • the target first physical address is, the physical machine searches for the target second physical address corresponding to the target first physical address, and writes data “hzujalbazkozujapzila” at the position indicated by the target second physical address in the virtual machine cache.
  • the physical machine does not need to switch between the non-root mode and the root mode, and the cache metadata may exist in the cache metadata corresponding to the first virtual address of the data to be operated.
  • the target second physical address corresponding to the target first physical address is determined according to the correspondence between the first physical address and the second physical address, so that data is read or written in the location indicated by the target second physical address in the virtual machine cache. Therefore, it can save time occupied by virtualization overhead, and improve cache access rate and cache access performance. That is to say, the above steps 401 to 403 can be completed in the non-root mode without executing the switch to the root mode.
  • the cache metadata may further include other information such as a cache type, a cache state, and an access time.
  • the cache type may include a read cache or a write cache.
  • the cache status is used to indicate whether the data in the cache has been flushed to the physical disk corresponding to the virtual disk. For example, the data that has not been flushed in the cache can be called dirty data, and the corresponding cache state can be dirty; the cache state corresponding to the data that has been flushed in the cache can be clean.
  • the access time is used to indicate when the cached data was most recently accessed.
  • the physical machine can perform cache management statistics such as cache utilization statistics, cache hit rate statistics, and dirty rate statistics by accessing cache metadata and perform cache management.
  • the physical machine determines that the ratio of the used first physical address to all the first physical addresses corresponding to the cache is greater than or equal to the first preset value according to the correspondence between the operation address and the first physical address in the cache metadata. It can be explained that the cache utilization is large, and the current cache may not be sufficient for the virtual machine to use. At this time, the physical machine can configure the cache to be larger. As another example, when the physical machine determines that the dirty rate is greater than or equal to a second preset value according to the cache state in the cache metadata, a flush operation may be triggered to prevent the accumulation of dirty data in the cache and overflow.
  • the cache metadata is stored in the memory of the virtual machine, not on the storage device of the physical machine. Therefore, the cache metadata can be directly accessed for cache statistics, without the need to be in non-root mode and root mode. Switching between them can save time occupied by virtualization overhead and improve processing efficiency.
  • This scenario can include two situations: 1. The physical machine has allocated a cache for the virtual machine, but there is no corresponding relationship between the first virtual address and the target first physical address in the cache metadata; 2. The physical machine has not yet allocated the virtual machine. Cache.
  • the method for implementing a virtualized cache provided by the embodiment of the present application may further include:
  • Write data to the virtual machine cache, and the position of the data in the virtual machine cache is expressed as a target first physical address, and determined according to a mapping relationship between a plurality of preconfigured first physical addresses and a plurality of second physical addresses.
  • the physical machine may perform step 404 and the following step 405 after switching from the non-root mode to the root mode.
  • the target number corresponding to the target first physical address may be determined according to the pre-configured correspondence between the first physical address and the second physical address.
  • Two physical addresses, so that the corresponding relationship between the first virtual address and the target first physical address is stored in the cache metadata, so that the physical machine can determine that it hits the virtual after receiving the operation request carrying the first virtual address next time Machine cache, so as to directly access the virtual machine cache according to the method described in step 402 and step 403.
  • the operation request is a read request
  • the virtual machine cache is not hit, before the above step 404, after switching from the non-root mode to the root mode, the data to be operated can also be read from the position indicated by the first virtual address. . Then, in step 404, the data read from the position indicated by the first virtual address may be written into the virtual machine cache.
  • the physical machine includes a front-end driver, a back-end driver, and a cache management module (CMM).
  • CCM cache management module
  • a communication channel is established between the modules.
  • the method for implementing the virtualized cache in steps 401 to 405 described above is implemented through cooperation. The following uses the read cache access process and the write cache access process as examples for illustration.
  • Another embodiment of the present application provides an implementation method for reading a virtualized cache. As shown in FIG. 6, the method may include:
  • the front-end driver obtains a read request issued by a virtual machine.
  • the read request is: reading the content on the disk D with an offset of O and a length of L; the first virtual address is: the offset on the disk D is O and the length is L.
  • the virtual machine is configured to send a read request to the front-end driver, where the read request includes a first virtual address, and is used to request to read data at a location indicated by the first virtual address in the virtual disk;
  • the front-end driver determines whether a target first physical address corresponding to the first virtual address exists in the cache metadata.
  • the front-end driver determines whether there is a target first physical address corresponding to the offset 0 and the length L on the disk D in the cache metadata. If it exists, the virtual machine cache is hit; if it does not exist, the virtual machine cache is missed.
  • the target first physical address corresponding to the first virtual address exists in the cache metadata, the virtual machine cache is hit, and the front-end driver requests to access the virtual machine cache.
  • the first virtual address (that is, the offset on disk D is 0, The data in the target first physical address corresponding to the length L).
  • the front-end driver searches for a second target physical address corresponding to the target first physical address, reads data in the target second physical address in the virtual cache, and updates the access time of the cached data in the cache metadata to the current time. It can be seen that the virtual machine cache access process does not need to switch modes, and no virtualization is trapped in the overhead.
  • the target first physical address corresponding to the first virtual address does not exist in the cache metadata, the virtual machine cache is missed, the front-end driver issues a read disk request, and switches to root mode to read the data in the disk.
  • the method may further include:
  • the front-end driver sends a cache request to the CMM.
  • the front-end driver transmits a cache request to the CMM through a communication channel with the CMM.
  • the cache request is: cache data
  • the disk corresponding to the cache data is D
  • the disk offset is O
  • the length is L.
  • the front-end driver does not initiate a cache request. For example, suppose the physical machine allocates 10G space for the cache of N virtual machines according to the user's configuration. If the 10G space is used up, the front-end driver does not initiate a cache request to the CMM; if the cache is not used up, the front-end driver can request The CMM initiates a cache request.
  • the CMM determines whether there is any remaining cache space in the current virtual machine.
  • 604a If the cache space of the current virtual machine is left, the CMM writes the read data to the cache of the current virtual machine. For example, suppose that the physical machine is configured with 100M of space for the current virtual machine's cache according to the user's configuration. At present, there is still 60M of space that has not been used. The CMM does not need to reallocate the space and can directly write the read data to the 60M. Space, and the space where data is written is marked as used.
  • the CMM reallocates the cache space, and then writes the read data into the cache of the virtual machine. For example, if there is no remaining 100M space currently allocated, the CMM may re-allocate the 100M space cache, write the read data into the new 100M space, and mark the space where the data is written as used.
  • This step involves the allocation of the cache of the virtual machine.
  • the main body of the allocation is the CMM.
  • the allocation algorithm can be based on the cache properties selected by the user, such as read cache, write cache, etc .; select a suitable storage medium as the cache hardware, which can be memory. It can also be an NVM high-speed storage device, or a byte-addressable storage device.
  • the target first physical address of the written data in the virtual machine cache can be obtained.
  • the CMM notifies the front-end driver to update the cache metadata.
  • the CMM After switching from root mode to non-root mode, the CMM notifies the front-end driver to update the cache metadata.
  • the front-end driver updates the cache metadata after receiving the notification from the CMM.
  • the content of the front-end driver update includes: saving the correspondence between the target first physical address and the first virtual address, and updating the cache access time to the current time.
  • step 602 When a subsequent request for read access to the first virtual address is subsequently requested, in step 602 above, a virtual machine cache hit process is performed, that is, a branch of 602a is taken, so that the virtual machine cache can be accessed directly without a mode switch.
  • Another embodiment of the present application provides a method for implementing a write virtualization cache, which is implemented through cooperation between modules such as a front-end driver, a back-end driver, and a cache management module in a physical machine. As shown in FIG. 7, the method include:
  • the front-end driver obtains a write request issued by a virtual machine.
  • the write request is: write "hzujalbazkozujapzila" at a position offset 0 on the disk D, and the data length is L.
  • the front-end driver determines whether there is a target first physical address corresponding to the first virtual address in the cache metadata.
  • the front-end driver determines whether there is a target first physical address corresponding to the offset 0 and the length L on the disk D in the cache metadata.
  • the target first physical address corresponding to the first virtual address exists in the cache metadata, the virtual machine cache is hit, and the front-end driver requests to access the virtual machine cache.
  • the first virtual address (that is, the offset on disk D is 0, The data in the target first physical address corresponding to the length L).
  • the front-end driver searches for a second target physical address corresponding to the target first physical address, writes data at the position indicated by the target second physical address in the virtual cache, and updates the cache of the data block corresponding to the target second physical address in the cache metadata.
  • the state is dirty. It can be seen that the virtual machine cache access process does not need to switch modes, and no virtualization is trapped in the overhead.
  • the target first physical address corresponding to the first virtual address does not exist in the cache metadata, the virtual machine cache is missed, the front-end driver issues a write disk request, and switches from the non-root mode to the root mode.
  • the method may further include:
  • the front-end driver initiates a cache request to the CMM.
  • the front-end driver transmits a cache request to the CMM through a communication channel with the CMM.
  • the cache request is: write data
  • the disk corresponding to the write data is D
  • the disk offset is O
  • the length is L.
  • the front-end driver may initiate a cache request in some cases and cannot initiate a cache request in another case. If the front-end driver cannot initiate a cache request, the physical machine writes the data to be written to the physical disk.
  • the CMM After receiving the cache request, the CMM queries whether the cache space of the current virtual machine is left.
  • the CMM If the cache space of the current virtual machine does not remain, the CMM reallocates the cache space, and then writes the read data into the cache of the virtual machine.
  • the target first physical address of the written data in the virtual machine cache can be obtained.
  • the CMM notifies the front-end driver to update the cache metadata.
  • the CMM After switching from root mode to non-root mode, the CMM notifies the front-end driver to update the cache metadata.
  • the front-end driver updates the cache metadata after receiving the notification from the CMM.
  • the content of the front-end driver update includes: saving the correspondence with the target first physical address and the first virtual address, and the cache state is dirty.
  • step 702 When the subsequent request for write access to disk D has an offset of O and a length of the first virtual address, in step 702 above, the virtual machine cache hit process will be performed, that is, branch 702a will be taken, so that direct access is possible without mode switching. Virtual machine cache.
  • the method for implementing a virtualized cache may further include a cache initialization process.
  • the cache initialization process is triggered when the virtual machine starts or mounts the virtual disk.
  • the cache policy configured by the user or the administrator may include the cache size of the virtual machine, the cache type (read cache / write cache) of the virtual machine, and the cache priority of the virtual machine.
  • the cache initialization process may include:
  • the back-end driver initializes a virtual machine cache according to a cache configuration set by a user.
  • the back-end driver initializing the virtual machine cache may include initializing a range of the first physical address space accessible by the virtual machine, a cache priority, and the like, and passing relevant parameters of the cache configuration to the CMM.
  • the front-end driver initializes a physical address space and cache metadata of the virtual machine cache.
  • the front-end driver after the back-end driver initializes the range of the first physical address space accessible by the virtual machine, the front-end driver also initializes the range of the first physical address (that is, the physical address cached by the virtual machine). In addition, the front-end driver applies for a piece of memory space of the virtual machine for storing cache metadata and initializes the cache metadata. During the initialization phase, the cache metadata is initialized as invalid. With the subsequent use of the virtual machine's cache by the virtual machine, the cache metadata will be dynamically updated, and information such as the correspondence between the first physical address and the operation address, the cache status, and the access time are saved, so as to transition from an invalid state to a valid state so that Used during cache access.
  • the CMM initializes a communication channel with the front-end driver.
  • the initialization communication channel here refers to initializing a shared memory connection or initializing a socket connection.
  • the communication channel between the front-end driver and the back-end driver, and between the back-end driver and the CMM can be initialized during the initialization process, which will not be repeated here.
  • the physical machine can uniformly manage the caches of the N virtual machines, and allocate cache resources among the N virtual machines, thereby making cache management more flexible and lowering the cache cost.
  • the management may include tasks such as cache allocation, cache elimination, cache flushing, cache size modification, cache attribute modification, and cache reuse.
  • cache attributes include cache type and cache priority
  • cache types include read cache and write cache.
  • the cache of the virtual machine may be uniformly managed according to the Qos parameter of the virtual machine or the Qos parameter of the virtual disk included in the virtual machine, so as to provide a better cache service for each virtual machine.
  • the Qos parameter may include at least one of parameters such as a reserved value of the cache, an upper limit of the cache, or a priority of the cache.
  • the cache before accessing the cache of the virtual machine, the cache may also be allocated to the virtual machine, so that the virtual machine can use the cache during the running process.
  • Cache allocation refers to opening a piece of physical address space from hardware currently providing high-performance storage services on a physical machine, and establishing a mapping relationship between a first physical address and a second physical address of the physical address space.
  • the virtual machine may be allocated a cache when the above cache is initialized.
  • the method may further include:
  • the CMM allocates a physical address space for the virtual machine cache, and allocates a part of the physical addresses in the physical disk to the virtual machine cache.
  • the CMM establishes a mapping relationship between multiple first physical addresses and multiple second physical addresses.
  • a physical machine can dynamically allocate a cache for a virtual machine when it needs to access the virtual machine cache. Before the above step 404, if the physical machine has not allocated a cache to the virtual machine, the physical machine executes the above steps 406 and 407 to allocate a cache to the virtual machine when needed.
  • the CMM allocates a physical address space for the virtual machine cache. Specifically, the CMM selects appropriate storage hardware to simulate the cache according to the user's cache configuration and the characteristics of the storage hardware on the physical machine. Specifically, the CMM can allocate physical address space for N virtual machines from a global perspective, and consider which storage hardware to choose as the cache medium for a virtual machine in combination with the cache configuration set by the user, and allocate cache resources among the N virtual machines. To reduce cache costs.
  • a cache may be allocated to a virtual machine according to a Qos parameter of the virtual machine or a Qos parameter of a virtual disk included in the virtual machine. For example, you can assign caches to the virtual machines with higher priority among the N virtual machines to ensure that the virtual machines with higher priority use the cache; or, considering that there may be multiple virtual disks in the virtual machine, you can Reserve a part of the cache space for the virtual disks with higher priority in the virtual machine. These cache spaces cannot be used by the virtual machine or virtual disk with lower priority, so that when the cache of the virtual disk with higher priority is needed, it can be allocated in time. Cache.
  • the CMM establishes a correspondence relationship between a plurality of first physical addresses and a plurality of second physical addresses.
  • the CMM uses a byte-mapping technology such as Intel's hardware-assisted virtualization technology (VT) to establish a mapping relationship from the second physical address to the first physical address.
  • VT hardware-assisted virtualization technology
  • data can be added to the virtual machine cache.
  • the virtual machine cache is a read cache, if you keep adding data to the virtual machine cache, it may cause the virtual machine cache to overflow.
  • data that has not been accessed in the cache for a long time may be eliminated according to a preset elimination policy, so that the virtual machine cache has sufficient space to receive new hot data.
  • N there are N virtual machines running on the physical machine, where N is a positive integer.
  • the cache elimination process can include:
  • the CMM determines the first data from the caches of the N virtual machines.
  • the first data to be eliminated may be determined from the caches of the N virtual machines according to the first preset policy, and the first data is data that needs to be eliminated from the caches of the at least one virtual machine.
  • data to be eliminated in each of the N virtual machines may be determined first, and then the first data is determined therefrom;
  • the CMM may first determine M (M is less than or equal to N) virtual machines from the N virtual machines, and then determine the data to be eliminated from the M virtual machines, and the M virtual machines
  • the data that needs to be eliminated is the first data.
  • the CMM can take a global perspective and comprehensively consider the situation in the caches of each virtual machine to more effectively and accurately determine which data in which virtual machine caches are non-hot data that need to be eliminated as soon as possible, so as to eliminate them.
  • the first data may be determined according to a least recently used (LRU) algorithm, a least frequently used (LFU) algorithm, or a first-in-first-out (FIFO) algorithm.
  • LRU least recently used
  • LFU least frequently used
  • FIFO first-in-first-out
  • the corresponding relationship between the access time and the first physical address is also stored in the cache metadata.
  • the access time in the cache metadata can be used to determine the time when the data corresponding to the first physical address in the cache was recently accessed, thereby facilitating determining the data in the cache that needs to be eliminated.
  • the first data to be eliminated may be determined according to the Qos parameter of the virtual machine or the first data to be eliminated may be determined according to the Qos parameter of the virtual disk in the virtual machine.
  • the Qos parameter includes the reserved value of the cache, At least one of a limit or a cached priority.
  • the data in the virtual machine cache with a lower priority can be preferentially eliminated, or the data in the cache with a lower priority virtual disk can be preferentially eliminated, or the data in the virtual machine cache with a lower cache upper limit can be preferentially eliminated.
  • the CMM deletes the first data from the caches of the N virtual machines.
  • the front-end driver deletes the mapping relationship between the virtual address corresponding to the first data in the cache metadata and the first physical address.
  • the first data is deleted from the caches of the N virtual machines, the first data is not in the virtual machine cache, so the correspondence between the operation address corresponding to the first data in the cache metadata and the first physical address can be deleted, so as to timely
  • the correspondence between the operation address in the cache metadata and the first physical address is updated, so that the correspondence in the cache metadata is consistent with the data cache situation in the current virtual machine cache in real time.
  • this also facilitates accurate cache situation statistics and cache management such as cache utilization statistics, cache hit rate statistics, and the like according to cache metadata.
  • the cache resources occupied by the first data can also be released for use by other virtual machines. When there are subsequent hot data of other virtual machines, they can be added to the released cache resources.
  • data can be added to the virtual machine cache.
  • write requests issued by the virtual machine can preferentially fall into the cache medium of the virtual machine cache to improve the performance of write access; however, on the one hand, due to the limited cache space; on the other hand, the cache medium It may be volatile, so when a physical machine loses power, etc., the data in the cache medium will be lost. Therefore, the virtual machine cache needs to flush the data written by the virtual machine to the physical disk in time to ensure the reliability and availability of the virtual machine cache.
  • the physical disk may be a physical storage medium in the storage device shown in FIG. 2.
  • Cache flashback can include active flashback and regular flashback.
  • the cache elimination and flushing method may include:
  • the CMM determines the second data from the caches of the N virtual machines.
  • the second data to be flushed may be determined from the caches of the N virtual machines according to the second preset policy, and the second data is data that needs to be flushed in the caches of the at least one virtual machine.
  • the physical machine may first determine the data that needs to be flushed out of the N virtual machines, and then determine the second data from it; in another specific implementation manner, the physical machine may first determine that it needs to be flushed.
  • M is less than or equal to N
  • the physical machine can comprehensively consider the situation in the caches of each virtual machine from a global perspective, and more effectively and accurately determine which data in which virtual machine caches are data that need to be flashed back to the physical disk as soon as possible.
  • a physical machine may determine that the virtual machine cache is first written into the cache of N virtual machines according to the access time in the cache metadata, and the cache state is dirty data, and these data need to be flushed back to the physical disk as soon as possible.
  • the second data that needs to be flushed is determined according to the Qos parameter of the virtual machine or the Qos parameter of the virtual disk in the virtual machine. For example, data in the cache of a virtual machine with a higher priority can be flushed first, or data in the cache of a virtual disk with a higher priority can be flushed in priority, or virtual disks with a smaller upper limit can be flushed in priority. Data in the machine cache.
  • the CMM flashes the second data back to the physical disk.
  • the determined second data to be flushed is written into the physical disk.
  • the front-end driver updates the cache status of the second data in the cache metadata.
  • the cache status of the second data in the cache metadata can be changed from dirty to clean to indicate that the second data has been flushed to the physical disk and timely Update the cache state information in the cache metadata so that the cache state is consistent with the state of the data in the current virtual machine cache in real time. In this way, it is also convenient for the physical machine to accurately perform cache situation statistics and cache management such as cache dirty rate statistics according to cache metadata.
  • the CMM when the user or the administrator modifies the cache configuration, the CMM may modify the content of the virtual machine cache, the attributes of the virtual machine cache, and the like online according to the modified cache configuration, making the use of cache resources more flexible.
  • the “online” modification refers to the modification of the virtual machine cache without restarting the physical machine or the virtual machine, so that the modification can take effect immediately.
  • the following describes the modification of the cache size and the modification of the cache attributes, respectively.
  • the method for modifying the cache size may include:
  • the CMM modifies the range of cached physical addresses allocated to a virtual machine.
  • the CMM may modify the range of the first physical address space corresponding to the cache, where the first physical address space is the part of the physical disk that is allocated to the virtual machine cache. For example, when the virtual machine cache needs to be expanded, the CMM changes the physical address range of the virtual machine cache from 0x001-0x100 to 0x001-0x200; when the virtual machine cache needs to be reduced, the CMM changes the first physical address of the virtual machine cache. The range is changed from 0x001-0x100 to 0x001-0x050. When the virtual machine cache needs to be expanded, the first physical address range of the virtual machine cache is expanded, and when the virtual machine cache needs to be reduced, the first physical address range of the virtual machine cache is reduced.
  • the CMM updates the mapping relationship between multiple first physical addresses and multiple second physical addresses according to the modified range of cached physical addresses allocated to the virtual machine.
  • the CMM updates the correspondence between the second physical address and the first physical address according to the modified range of the first physical address.
  • the front-end driver can determine the target second physical address corresponding to the target first physical address in real time according to the correspondence between the updated second physical address and the first physical address, thereby directly obtaining data according to the target second physical address, and achieving Virtualization cache.
  • the method for modifying the cache size may further include:
  • the CMM refreshes and deletes the third data in the virtual machine cache.
  • the CMM needs to flush and delete the third data in the cache space to be deleted to ensure that the data in the cache space to be deleted will not be lost.
  • the physical machine can resume the write operation to the virtual machine cache, and the virtual machine can use the cache normally.
  • the cache attribute may include a cache priority and a cache type.
  • the method may cooperate with a front-end driver, a back-end driver, and a cache management module of a physical machine. to realise.
  • the method may include: the back-end driver notifies the CMM to change the cache priority or the cache type, and then the CMM changes the cache priority or the cache type.
  • the write cache can be triggered to write dirty data to a physical disk, and then the write cache is modified into a read cache.
  • the front-end driver can also update the cache type in the cache metadata in a timely manner, so that the cache metadata is consistent with the situation of the modified virtual machine cache in real time.
  • one second physical address may correspond to the first physical addresses of multiple virtual machines.
  • the same second physical address can be used by multiple virtual machine caches, thereby reusing physical cache space and saving cache costs.
  • multiple virtual machines share a virtual disk, so that the second physical addresses corresponding to the multiple virtual machine caches are also the same, thereby facilitating the use of cache reuse technology.
  • Another embodiment of the present application provides a method for cache multiplexing, which is implemented through cooperation between a front-end driver, a back-end driver, and a cache management module of a physical machine.
  • the method may include:
  • the CMM determines whether the cache metadata of the N virtual machines on the physical machine includes the target first physical address corresponding to the first virtual address in the read request. address.
  • the CMM establishes a first Correspondence between a physical address 2 and a second physical address 1.
  • the CMM notifies the front-end driver to update the cache metadata.
  • the front-end driver completes updating the cache metadata.
  • the update includes: saving the correspondence between the first virtual address and the first physical address 2.
  • the cache access time is the current time.
  • the second virtual machine has a correspondence relationship between the first virtual address, the first physical address 1, and the second physical address 1. That is, the two virtual machines can share the second physical address 1. Therefore, when multiple virtual machines access the same second physical address, a situation in which the same second physical address is mapped to the first physical addresses of multiple virtual machines will be achieved, so that the effect of cache reuse can be achieved.
  • cache deduplication refers to deleting duplicate data in the cache.
  • online deduplication means that when data is written to the virtual machine cache, it is determined whether the same data exists in other areas, and if so, the mapping relationship between the first physical address and the second physical address is directly modified.
  • Offline deduplication refers to the existence of a scheduled task on the physical machine, which periodically scans the data in the caches of N virtual machines. If the same data is found, the mapping relationship between the first physical address and the second physical address is modified, so that Multiple first physical addresses point to the same second physical address.
  • a storage device generally used as storage may provide storage space for a virtual machine cache.
  • the storage device may be a byte-based addressing device.
  • the physical machine can directly access the virtual machine cache without the need for virtualization overhead, and the physical machine can also access the virtual machine cache through the front-end area, back-end driver, and
  • the cooperation between the cache management modules uniformly implements cache management content such as cache allocation, cache flushing, cache elimination, cache size modification, cache attribute modification, and cache reuse on the N virtual machines on the physical machine, thereby realizing the virtual machine cache.
  • cache management content such as cache allocation, cache flushing, cache elimination, cache size modification, cache attribute modification, and cache reuse on the N virtual machines on the physical machine, thereby realizing the virtual machine cache.
  • the prior art also provides a virtual cache solution, that is, a storage medium (or storage device) of a high-performance peripheral component interconnect (PCI) interface is directly passed to a virtual machine as a cache, or directly used Virtual machine memory acts as a cache.
  • a virtual cache solution that is, a storage medium (or storage device) of a high-performance peripheral component interconnect (PCI) interface is directly passed to a virtual machine as a cache, or directly used Virtual machine memory acts as a cache.
  • PCI peripheral component interconnect
  • the physical machine can manage the memory of each virtual machine in a unified manner, but the cache and memory of the virtual machine belong to different management levels, and the physical machine cannot implement the cache of each virtual machine. Unified management.
  • each network element such as a server and a terminal, includes a hardware structure and / or a software module corresponding to each function.
  • this application can be implemented in hardware or a combination of hardware and computer software. Whether a certain function is performed by hardware or computer software-driven hardware depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above integrated modules can be implemented in the form of hardware or software functional modules. It should be noted that the division of the modules in the embodiments of the present application is schematic, and is only a logical function division. In actual implementation, there may be another division manner.
  • FIG. 13 shows a possible composition diagram of the physical machine 1300 involved in the foregoing embodiment.
  • the physical machine 1300 may include a virtual machine 1301, a front-end driver 1302, a back-end driver 1303, and a cache management module 1304.
  • the virtual machine 1301 is configured to send an operation request to the front-end driver, where the operation request includes a first virtual address, and is used to request reading or writing of data at a location indicated by the first virtual address in the virtual disk.
  • the front-end driver 1302 can be used to support the physical machine to perform steps 401-420, step 403, step 405, step 601-603, step 606, step 701-703, step 802, step 903, step 1003, step 1101, step 1102, Step 1104, step 1204, etc .; and / or other processes for the techniques described herein.
  • the back-end driver 1303 may be used to support a physical machine to perform step 801, and may also be used to initiate a modification of a cache size or a modification of a cache attribute; and / or other processes used in the techniques described herein.
  • the cache management module 1304 can be used to support the physical machine to perform steps 404, 406-407, steps 604-605, steps 704-705, step 803, steps 901-902, steps 1001-1002, steps 1103, step 1105, steps 1106, steps 1107, steps 1201-1203, etc .; and / or other processes for the techniques described herein.
  • the physical machine provided in the embodiment of the present application is configured to execute the foregoing implementation method of the virtualized cache, and thus can achieve the same effect as the foregoing implementation method of the virtualized cache.
  • the physical machine may include: an acquisition module, a processing module, a read-write module, and a cache management module. among them:
  • An acquisition module for performing steps 401, 601, 701, and / or other processes for the techniques described herein.
  • Processing module for performing steps 402, 405, 602, 603, 603, 606, 702, 703, 706, 802, 903, 1003, and / or other techniques used in the techniques described herein process.
  • a read-write module for performing step 403 and / or other processes for the techniques described herein.
  • the acquisition module, the processing module, and the read-write module can be implemented by the front-end driver 1302.
  • the physical machine may include a processing module and a storage module.
  • the processing module is used to control and manage the actions of the physical machine.
  • the processing module can be used to support the physical machine to perform the steps performed by the front-end driver 1302, the back-end driver 1303, and the cache management module 1304, and / or used in the description herein.
  • Other processes of technology can be used to support a physical machine to implement a cache, and store program code and data.
  • the processing module may be a processor or a controller. It may implement or execute various exemplary logical blocks, modules, and circuits described in connection with the disclosure of this application.
  • the processor may also be a combination that implements computing functions, such as a combination including one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and so on.
  • the memory module may be a memory.
  • the processing module is a processor and the storage module is a memory
  • the physical machine involved in the embodiment of the present application may be a device having the computer system shown in FIG. 3.
  • An embodiment of the present application further provides a computer storage medium.
  • the computer storage medium stores computer instructions.
  • the computer instructions When the computer instructions are run on a physical machine, the physical machine is caused to execute the foregoing related method steps to implement the virtualized cache in the foregoing embodiment. Implementation.
  • the embodiment of the present application further provides a computer program product, when the computer program product is run on a computer, the computer is caused to execute the foregoing related steps, so as to implement the method for implementing a virtualized cache in the foregoing embodiment.
  • an embodiment of the present application further provides a device.
  • the device may specifically be a chip, a component, or a module.
  • the device may include a connected processor and a memory.
  • the memory is used to store a computer to execute instructions.
  • the processor may execute computer execution instructions stored in the memory, so that the chip executes the implementation method of the virtualized cache in the foregoing method embodiments.
  • the physical machine, computer storage medium, computer program product, or chip provided in the embodiments of the present application are used to execute the corresponding methods provided above. Therefore, for the beneficial effects that can be achieved, refer to the corresponding methods provided above. The beneficial effects in the method are not repeated here.
  • the disclosed apparatus and method may be implemented in other ways.
  • the device embodiments described above are only schematic.
  • the division of modules or units is only a logical function division.
  • multiple units or components may be combined or It can be integrated into another device, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, which may be electrical, mechanical or other forms.
  • the units described as separate parts may or may not be physically separated, and the parts shown as units may be one physical unit or multiple physical units, that is, they may be located in one place, or may be distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the objective of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each of the units may exist separately physically, or two or more units may be integrated into one unit.
  • the above integrated unit may be implemented in the form of hardware or in the form of software functional unit.
  • the integrated unit When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application essentially or partly contribute to the existing technology or all or part of the technical solutions may be embodied in the form of a software product, which is stored in a storage medium
  • the instructions include a number of instructions for causing a device (which can be a single-chip microcomputer, a chip, or the like) or a processor to execute all or part of the steps of the methods in the embodiments of the present application.
  • the foregoing storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

本申请实施例提供一种虚拟化缓存的实现方案,在虚拟机内存上保存缓存元数据,缓存元数据中包括多个虚拟地址与多个第一物理地址的一一映射关系;获取虚拟机下发的包括第一虚拟地址的操作请求后,若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的对应关系,查找与目标第一物理地址对应的目标第二物理地址,并在目标第二物理地址表示的位置读取或写入数据。本申请实施例提供的虚拟化缓存实现方案相比于现有方案有更好的缓存性能。

Description

虚拟化缓存的实现方法及物理机
本申请要求于2018年6月12日提交中国国家知识产权局、申请号为201810603891.8、申请名称为“一种虚拟化缓存的实现方法及物理机”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及虚拟化技术领域,尤其涉及一种虚拟化缓存的实现方法及物理机。
背景技术
虚拟化技术使用软件的方法重新定义划分IT资源,将一台物理机虚拟成很多台拥有不同硬件的虚拟机。每个虚拟机可运行不同的操作系统,并且虚拟机相互独立。因此,在虚拟化环境中,原来运行在物理机上的很多应用都会迁移到虚拟机中去,以此来实现IT资源的动态分配和灵活调度,提高IT资源利用率,节省IT成本。
缓存(Cache)技术是一种将存储于低速硬件介质上的热点数据通过存放到高速介质来提升数据访问性能的方案。随着应用向虚拟化环境的迁移,缓存作为一种常用的存储性能优化技术手段,也会向虚拟化环境迁移。
现有的虚拟化缓存方案中,参见图1,通过物理机内存或高性能存储介质为物理机上运行的虚拟机提供缓存服务;或者,在物理机连接的存储服务端,例如存储区域网络(storage area network,SAN)设备上,为物理机上运行的虚拟机提供缓存服务。当虚拟机下发输入/输出(input/output,I/O)操作请求(或称为写/读请求)时,虚拟机从非根模式切换到根模式,I/O操作请求下发至物理机或存储服务端,虚拟机访问物理机或存储服务端上的缓存;在缓存访问完成后,虚拟机还需要从根模式切换回非根模式。即,当虚拟机访问缓存时,存在虚拟化切换开销。
在现有技术方案中,缓存访问过程中的虚拟化切换开销(通常在40us-60us之间)会导致缓存访问时延较大,影响缓存性能。
发明内容
本申请实施例提供一种虚拟化缓存的实现方法及物理机,能够降低虚拟化缓存的访问时延,提高缓存性能。
为达到上述目的,本申请实施例采用如下技术方案:
第一方面,本申请实施例提供了一种虚拟化缓存的实现方法,应用于物理机,物理机上运行有虚拟机,物理机上保存有缓存元数据。其中,缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系,虚拟地址用于表示虚拟磁盘中的位置,第一物理地址为虚拟机缓存的物理地址。该方法包括:获取虚拟机下发的操作请求,其中操作请求包括第一虚拟地址,操作请求用于请求在虚拟磁盘中第一虚拟地址 所指示的位置读取或写入数据;若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与目标第一物理地址对应的目标第二物理地址,第二物理地址为物理机的物理磁盘的物理地址;而后,在物理机的物理磁盘中目标第二物理地址指示的位置读取或写入数据。
在该方案中,不需要进行非根模式和根模式之间的切换就可以访问虚拟机缓存中的数据,因而可以节省虚拟化开销占用的时间,提高缓存访问速率和缓存访问性能。
在一种可能的实现方式中,在虚拟机缓存中目标第二物理地址表示的位置读取或写入待操作数据,具体包括:在非根模式下,在虚拟机缓存中目标第二物理地址表示的位置读取或写入待操作数据也就是说,在非根模式下访问虚拟机缓存中的数据。
在另一种可能的实现方式中,物理磁盘为以字节寻址的存储介质。
在另一种可能的实现方式中,虚拟机的内存中保存有缓存元数据。
在该方案中,可以无需虚拟化开销就可访问虚拟机上保存的缓存元数据。
在另一种可能的实现方式中,若缓存元数据中不存在与第一虚拟地址对应的目标第一物理地址,则将数据写入虚拟机缓存中,数据在虚拟机缓存中的位置表示为目标第一物理地址,并根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与第一目标物理地址对应的目标第二物理地址;将目标第一物理地址与第一虚拟地址的映射关系保存至缓存元数据中。
也就是说,如果缓存元数据中不存在与第一虚拟地址对应的目标第一物理地址,则可以判断没有命中虚拟机缓存,操作请求所要请求读取或写入的数据不在虚拟机缓存中,那么需要将该数据写入虚拟机缓存中,便于下次可以直接从虚拟机缓存中读取该数据。
在另一种可能的实现方式中,根据虚拟机的服务质量(quality of service,Qos)参数,或虚拟机中虚拟磁盘的服务质量Qos参数,确定第一数据。该Qos参数包括缓存的预留值、缓存的上限值或缓存的优先级中的至少一种。该管理包括缓存分配、缓存回刷、缓存淘汰、缓存大小修改、缓存属性修改以及缓存复用等。
在该方案中,统一管理各虚拟机的缓存可以使得缓存管理更为灵活,管理成本更低。并且,可以根据不同虚拟机的Qos来管理缓存,从而为虚拟机提供更好的缓存服务。
在另一种可能的实现方式中,该方法还包括:将物理磁盘中的一部分物理地址分配给虚拟机的缓存;建立多个第一物理地址与多个第二物理地址的映射关系。
在另一种可能的实现方式中,物理机上运行的虚拟机有N个,N为正整数,该方法还包括:物理机从N个虚拟机的缓存中确定第一数据,然后将第一数据从N个虚拟机的缓存中删除,并删除缓存元数据中第一数据对应的虚拟地址与第一物理地址的映射关系。在该方案中,可以从全局的角度确定哪些虚拟机对应的缓存中的数据需要尽快被淘汰掉,以尽量使得各虚拟机缓存中的数据为热点数据。并且,还可以及时更新缓存元数据,以使得缓存元数据与虚拟机的缓存情况实时保持一致。
在另一种可能的实现方式中,确定第一数据具体包括:根据虚拟机的Qos参数,或虚拟机中虚拟磁盘的Qos参数,确定第一数据。
在该方案中,物理机可以根据不同虚拟机对应的Qos淘汰虚拟机中的缓存。
在另一种可能的实现方式中,缓存元数据还包括缓存状态,缓存状态用于表示虚拟机缓存中的数据是否被回刷至物理磁盘,该方法还包括:物理机从N个虚拟机的缓存中确定第二数据,然后将第二数据回刷至物理磁盘,并更新缓存元数据中第二数据的缓存状态。
在该方案中,物理机可以综合考虑各虚拟机的情况,从而确定所有虚拟机的缓存中最需要被回刷的数据。
在另一种可能的实现方式中,该方法还包括:修改分配给虚拟机的缓存的物理地址的范围;根据修改后的分配给虚拟机的缓存的物理地址的范围,更新多个第一物理地址与多个第二物理地址的映射关系。在该方案中,可以在不需要重启虚拟机的情况下在线修改虚拟机缓存的物理地址范围,使得虚拟机缓存的修改能够实时生效。
在另一种可能的实现方式中,若虚拟机缓存为写缓存,该方法还包括:回刷并删除虚拟机缓存中的第三数据。在虚拟机缓存在线减容的过程中,可以暂停写入虚拟机缓存的操作,避免缓存中的数据累积过多而无法缩减缓存空间。
在另一种可能的实现方式中,一个第二物理地址对应多个虚拟机的第一物理地址。这样,多个虚拟机各自的第一物理地址可以映射到物理磁盘上的同一第二物理地址,物理磁盘上的部分物理地址可以供多个虚拟机缓存使用,从而可以达到复用缓存空间,节省缓存成本的效果。
第二方面,本申请实施例提供一种物理机,该物理机包括:虚拟机和前端驱动、物理磁盘、虚拟机缓存、虚拟磁盘和虚拟机内存。其中,虚拟机内存上保存有缓存元数据,缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系,虚拟地址用于表示虚拟磁盘中的位置,第一物理地址为虚拟机的缓存的物理地址;
虚拟机用于,发送操作请求给前端驱动,操作请求包括第一虚拟地址,用于请求在虚拟磁盘中第一虚拟地址所指示的位置读取或写入数据;
前端驱动用于:获取虚拟机下发的操作请求,操作请求;若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与目标第一物理地址对应的目标第二物理地址,第二物理地址为物理机的物理磁盘的物理地址;在物理机的物理磁盘中目标第二物理地址指示的位置读取或写入数据。
在另一种可能的实现方式中,物理机还包括缓存管理模块,缓存管理模块用于:将数据写入虚拟机缓存中,该数据在虚拟机缓存中的位置表示为目标第一物理地址,并根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与第一目标物理地址对应的目标第二物理地址;将目标第一物理地址与第一虚拟地址的对应关系保存至缓存元数据中。
在另一种可能的实现方式中,缓存管理模块还用于:将物理磁盘中的一部分物理地址分配给虚拟机的缓存;建立多个第一物理地址与多个第二物理地址的映射关系。
在另一种可能的实现方式中,物理机上运行的虚拟机有N个,N为正整数,缓存管理模块还用于:从N个虚拟机的缓存中确定第一数据;将第一数据从N个虚拟机的缓存中删除;
前端驱动还用于,删除缓存元数据中第一数据对应的虚拟地址与第一物理地址的映射关系。
在另一种可能的实现方式中,管理模块具体用于:根据虚拟机的服务质量Qos参数或虚拟机中虚拟磁盘的服务质量Qos参数,确定第一数据,Qos参数包括缓存的预留值、缓存的上限值或缓存的优先级中的至少一种。
在另一种可能的实现方式中,物理机上运行的虚拟机有N个,N为正整数,缓存元数据还包括缓存状态,缓存状态用于表示虚拟缓存中的数据是否被回刷至物理磁盘,缓存管理模块还用于:从N个虚拟机的缓存中确定第二数据;将第二数据回刷至物理磁盘;处理模块还用于,更新缓存元数据中第二数据的缓存状态。
在另一种可能的实现方式中,缓存管理模块具体用于:根据虚拟机的服务质量Qos参数或虚拟机中虚拟磁盘的服务质量Qos参数,确定第二数据,Qos参数包括缓存的预留值、缓存的上限值或缓存的优先级中的至少一种。
在另一种可能的实现方式中,缓存管理模块还用于:修改分配给虚拟机的缓存的物理地址的范围;根据修改后的分配给虚拟机的缓存的物理地址的范围,更新多个第一物理地址与多个第二物理地址的映射关系。
第三方面,本申请实施例提供了一种物理机,该物理机上运行有虚拟机。其中,虚拟机的内存上保存有缓存元数据,缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系,虚拟地址用于表示虚拟磁盘中的位置,第一物理地址为虚拟机的缓存的物理地址。该物理机包括:
获取模块,用于:获取虚拟机下发的操作请求,操作请求包括第一虚拟地址,用于请求在虚拟磁盘中第一虚拟地址所指示的位置读取或写入数据;
处理模块,用于:若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与目标第一物理地址对应的目标第二物理地址,第二物理地址为物理机的物理磁盘的物理地址;
读写模块,用于:在物理机的物理磁盘中目标第二物理地址指示的位置读取或写入数据。在另一种可能的实现方式中,物理磁盘为以字节寻址的存储介质。
在另一种可能的实现方式中,物理机还包括缓存管理模块,用于:若缓存元数据中不存在与第一虚拟地址对应的目标第一物理地址,则将数据写入虚拟机缓存中,数据在虚拟机缓存中的位置表示为目标第一物理地址,并根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与第一目标物理地址对应的目标第二物理地址。
在另一种可能的实现方式中,物理机还包括缓存管理模块,缓存管理模块用于:在前端驱动获取虚拟机下发的操作请求之前,为虚拟机缓存分配物理地址空间;建立物理地址空间中的多个第一物理地址与多个第二物理地址的对应关系。
在另一种可能的实现方式中,缓存管理模块还用于:为虚拟机缓存分配物理地址;具体的,将物理磁盘中的一部分物理地址分配给虚拟机的缓存,并建立多个第一物理地址与多个第二物理地址的映射关系。
在另一种可能的实现方式中,物理机上运行的虚拟机有N个,N为正整数,物理机包括缓存管理模块,缓存管理模块用于:从N个虚拟机的缓存中确定第一数据;将 第一数据从N个虚拟机的缓存中删除;处理模块还用于,删除缓存元数据中第一数据对应的虚拟地址与第一物理地址的对应关系。
在另一种可能的实现方式中,缓存管理单元用于确定第一数据具体包括:根据虚拟机的服务质量Qos参数,或虚拟机中虚拟磁盘的服务质量Qos参数,确定第一数据,Qos参数包括缓存的预留值、缓存的上限值或缓存的优先级中的至少一种。
在另一种可能的实现方式中,物理机上运行的虚拟机有N个,N为正整数,缓存元数据还包括缓存状态,缓存状态用于表示虚拟缓存中的数据是否被回刷至物理磁盘,物理机包括缓存管理模块,缓存管理模块用于:从N个虚拟机的缓存中确定第二数据;将第二数据回刷至物理磁盘;处理模块还用于,更新缓存元数据中第二数据的缓存状态。
在另一种可能的实现方式中,缓存管理模块还用于,修改分配给虚拟机的缓存的物理地址的范围;根据修改后的分配给虚拟机的缓存的部分物理磁盘中的物理地址的范围,更新多个第一物理地址与多个第二物理地址的映射关系。
在另一种可能的实现方式中,一个第二物理地址对应多个虚拟机的第一物理地址。这样,多个虚拟机各自的第一物理地址可以映射到物理磁盘上的同一第二物理地址,物理磁盘上的部分物理地址可以供多个虚拟机缓存使用,从而可以达到复用缓存空间,节省缓存成本的效果。
第四方面,本申请实施例提供了一种物理机,包括处理器和存储有计算机程序的计算机可读存储介质。其中,处理器与计算机可读存储介质耦合,计算机程序被处理器执行时实现上述第一方面任一项可能的实现方式中的虚拟化缓存的实现方法。
第五方面,本申请实施例提供了一种计算机可读存储介质,其上存储有计算机程序,其特征在于,计算机程序被处理器执行时实现上述第一方面任一项可能的实现方式中的虚拟化缓存的实现方法。
第六方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行上述第一方面任一项可能的实现方式中的虚拟化缓存的实现方法。
第七方面,本申请实施例提供了一种芯片,芯片包括处理器,用于支持物理机实现上述第一方面任一项可能的实现方式中的虚拟化缓存的实现方法。
附图说明
图1为现有技术提供的一种虚拟化系统的示意图;
图2为本申请实施例提供的一种虚拟化系统的示意图;
图3为本申请实施例提供的一种设备的结构示意图;
图4为本申请实施例提供的一种虚拟化缓存的实现方法流程图;
图5为本申请实施例提供的另一种虚拟化缓存的实现方法流程图;
图6为本申请实施例提供的另一种虚拟化缓存的实现方法的示意图;
图7为本申请实施例提供的另一种虚拟化缓存的实现方法流程图;
图8为本申请实施例提供的另一种虚拟化缓存的实现方法流程图;
图9为本申请实施例提供的另一种虚拟化缓存的实现方法流程图;
图10为本申请实施例提供的另一种虚拟化缓存的实现方法流程图;
图11为本申请实施例提供的另一种虚拟化缓存的实现方法流程图;
图12为本申请实施例提供的一种第一物理地址与第二物理地址的对应关系图;
图13为本申请实施例提供的一种物理机的结构示意图。
具体实施方式
为了便于理解,示例的给出了部分与本申请实施例相关概念的说明以供参考。如下所示:
虚拟化开销:是指在虚拟化缓存的实现过程中,中央处理器(central processing unit,CPU)在非根模式(即客户机模式)与根模式(即内核模式)之间进行切换所花费的时间。在虚拟化技术中,考虑到系统的安全性,虚拟机通常不能直接访问装置上的各种物理设备(例如:网卡、磁盘设备等),当需要进行输入/输出(input/output,I/O)操作(例如读/写缓存、读/写磁盘等)、下发敏感指令或产生某些中断时,需要从非根模式切换到根模式。此时,需要保存非根模式下的客户机状态域,即虚拟机CPU的运行状态值,例如控制寄存器(control register,CR)、代码段寄存器(code segment,CS)、堆栈段寄存器(stack segment,SS)或数据段寄存器(data segment,DS)等寄存器中保存的内容。当处理完上述I/O操作、敏感指令等之后,CPU需要从根模式切换回非根模式。此时,CPU需要加载之前切换至根模式时保存的客户机状态域。其中,保存和加载客户机状态域将使得根模式与非根模式的切换过程耗时较长。
虚拟磁盘(Virtual disk),就是在本地电脑里面虚拟出一个远程电脑里面的磁盘。感觉像是在本机上的硬盘一样。虚拟磁盘就是用内存中虚拟出一个或者多个磁盘,可以加快磁盘的数据交换速度,从而提高电脑的运行速度。
物理磁盘,就是物理机的本地磁盘。
虚拟机内存,虚拟机的内存就是使得虚拟机像物理机一样有自己的内存空间,可以为物理机分配给虚拟机使用的内存空间。
虚拟机的缓存,虚拟机的缓存就是使得虚拟机像物理机一样有自己的缓存,可以存储虚拟机经常访问的数据。
读缓存原理:将存储硬件上的热点数据,也就是经常访问的数据放到缓存中,这样,当应用访问存储硬件时,可以直接从缓存中读取热点数据,达到提升读访问性能的效果。
写缓存原理:将写数据先写入缓存中,延时一段时间后,再将数据从缓存回刷至物理磁盘。这样,当应用经常向同一块区域写入数据时,经常访问的都是缓存,从而能够提升写访问性能。
回刷:将缓存中的数据写入物理磁盘。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,以及单独存在B这三种情况。另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
本申请实施例提供的虚拟化缓存的实现方法可以使得虚拟机不经过非根模式与根模式之间的切换就可以实现虚拟机缓存的管理,因而可以节省虚拟化开销占用的时间,提高虚拟机缓存性能。
图2示出了本申请实施例提供的虚拟化缓存的实现方法可应用的虚拟化系统的架构示意图。如图2所示,该系统100包括物理机101和存储设备102。物理机101上运行有N(正整数)个虚拟机103、虚拟机监控器(virtual machine monitor,VMM)104、虚拟机的前端驱动(front-end driver)105、虚拟机的后端驱动(back-end driver)106和缓存管理模块107。
其中,每个虚拟机103上运行有多个应用程序(application,APP),用于可为用户提供多种应用服务,物理机101可用于为虚拟机103提供硬件支持。虚拟机监控器104,例如开源的系统虚拟化(kernel-based virtual machine,KVM)模块或XEN模块,用于管理物理机101的物理资源,为虚拟机103提供接口。前端驱动105用于驱动虚拟机的虚拟磁盘,与物理机101上的缓存管理模块107配合完成缓存访问、淘汰和回刷等功能。前端驱动105还用于管理虚拟机的缓存的物理地址和缓存元数据(metadata),缓存元数据用于确定是否命中虚拟机缓存。例如,前端驱动105具体可以用于修改虚拟机的缓存的物理地址空间的范围,访问和更新缓存元数据等。后端驱动106(例如开源的QEMU等软件)用于向虚拟机模拟带缓存的虚拟磁盘,包括解析用户设置的缓存配置和缓存策略,例如缓存大小、缓存类型和缓存优先级等,为虚拟机模拟一个符合用户配置的带虚拟机缓存的虚拟磁盘,提供前端驱动所需的第一物理地址的模拟,负责虚拟化管理中涉及到修改缓存属性的管理操作,例如发起缓存在线扩容、减容等任务。缓存管理模块107用于统一管理物理机101上N个虚拟机的缓存,具体包括缓存分配、缓存淘汰、缓存回刷、缓存大小修改、缓存属性修改、定期同步缓存状态等管理任务。存储设备102用于为物理机101和虚拟机103提供硬件存储。
其中,存储设备102是用于储存信息的设备,通常是将信息数字化后再以利用电、磁或光学等方式的媒体,可以称为物理磁盘。存储设备具体可以是物理机101中的一部分,也可以是物理机101之外的其它设备。例如,存储设备102可以是机械硬盘(hard disk drive,HDD)、固态硬盘(solid state drives,SSD)或SAN设备等。
此外,该系统100还可以包括其他模块,例如内存设备108,这里不再一一赘述。内存设备108用于为物理机和虚拟机提供内存,例如用于为缓存管理模块107提供内存空间。其中,内存设备108具体可以是物理机101中的一部分,也可以是物理机101之外的其它设备。例如,内存设备108可以是随机存取存储器(random access memory,RAM)或非易失存储器(non-volatile memory,NVM)等。
如图3所示,图2中的物理机101可以通过图3中的计算机系统300来实现。计算机系统300包括至少一个处理器301,通信总线302,存储器303以及至少一个通信接口304。
处理器301可以是一个通用中央处理器(central processing unit,CPU),微处理器,特定应用集成电路(application specific integrated circuit,ASIC),或一个或多个用于控制本申请方案程序执行的集成电路。
通信总线302可包括一通路,在上述组件之间传送信息。
通信接口304,使用任何收发器一类的装置,用于与其他设备或通信网络通信,如以太网,无线接入网(radio access network,RAN),无线局域网(wireless local area networks,WLAN)等。
存储器303可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,RAM或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,通过总线与处理器相连接。存储器也可以和处理器集成在一起。
其中,存储器303用于存储执行本申请方案的应用程序代码,并由处理器301来控制执行。处理器301用于执行存储器303中存储的应用程序代码,从而实现本申请下述实施例提供的虚拟化缓存的实现方法。
可选的,本申请实施例中的计算机执行指令也可以称之为应用程序代码,本申请实施例对此不作具体限定。
在具体实现中,作为一种实施例,处理器301可以包括一个或多个CPU,例如图3中的CPU0和CPU1,每个CPU可以支持多个虚拟CPU,虚拟CPU又称VCPU。
在具体实现中,作为一种实施例,计算机系统300可以包括多个处理器,例如图3中的处理器301和处理器308。这些处理器中的每一个可以是一个单核(single-CPU)处理器,也可以是一个多核(multi-CPU)处理器。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(例如计算机程序指令)的处理核。
在具体实现中,作为一种实施例,计算机系统300还可以包括输出设备305和输入设备306。输出设备305和处理器301通信,可以以多种方式来显示信息。例如,输出设备305可以是液晶显示器(liquid crystal display,LCD),发光二级管(light emitting diode,LED)显示设备,阴极射线管(cathode ray tube,CRT)显示设备,或投影仪(projector)等。输入设备306和处理器301通信,可以以多种方式接受用户的输入。例如,输入设备306可以是鼠标、键盘、触摸屏设备或传感设备等。
上述的计算机系统300可以是一个通用通信设备或者是一个专用通信设备。本申请实施例不限定计算机系统300的类型。在具体实现中,计算机系统300可以是台式机、便携式电脑、网络服务器、掌上电脑(personal digital assistant,PDA)、移动手机、平板电脑、无线终端设备、嵌入式设备或有图3中类似结构的设备。计算机系统300中的各个部件可以同时部署在同一个计算机设备中,也可以部署在位于分布式系统中的不同计算机设备中。
以下将结合图2所示的虚拟化系统,以图3所示的计算机系统为物理机为例,对本申请实施例提供的虚拟化缓存的实现方法进行具体阐述。
本申请实施例提供了一种虚拟化缓存的实现方法,可以应用于物理机,该物理机上运行有N个虚拟机,N为正整数。虚拟机的内存上保存有缓存元数据,该缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系。其中,虚拟地址用 于表示虚拟磁盘中的位置,第一物理地址为虚拟机缓存的物理地址。
具体的,虚拟机前端可见一段第一物理地址空间,即虚拟机缓存的物理地址表示的物理地址空间。缓存元数据保存在虚拟机的内存中。在缓存元数据中,一个虚拟地址可以对应一个第一物理地址。其中,缓存元数据中可以通过映射表或树形结构等多种方式表示虚拟地址与第一物理地址的对应关系。示例性的,虚拟地址与第一物理地址的映射关系可以参见如下表1。
表1
操作地址 第一物理地址
操作地址1 第一物理地址1
操作地址2 第一物理地址2
参见图4,本申请实施例提供的虚拟化缓存的实现方法可以包括:
401、获取虚拟机下发的操作请求,操作请求包括第一虚拟地址,用于请求在虚拟磁盘中第一虚拟地址所指示的位置读取或写入数据;
其中,操作请求也可以称为I/O请求,I请求即为输入请求或写请求,O请求即为输出请求或读请求。操作请求可以由虚拟机中与存储相关的应用发起,这些应用运行于VCPU上,也可以理解为VCPU下发存储相关的操作请求。又由于VCPU运行于物理机的CPU上,因而可以理解为物理机的CPU获取操作请求。
操作请求中包括第一虚拟地址,第一虚拟地址用于表示待操作数据在虚拟磁盘中被读取或写入的位置。第一虚拟地址的具体形式可以有多种,例如可以是待操作数据在虚拟磁盘中被读取或写入的位置偏移量O,或者可以是待操作数据在虚拟磁盘中被读取或写入的位置偏移量O和待操作数据的长度L,或者可以是待操作数据在虚拟磁盘中被读取或写入的位置的起始地址,或者可以是待操作数据在虚拟磁盘中被读取或写入的位置的起始地址和终止地址,或者可以是待操作数据在虚拟磁盘中被读取或写入的位置的起始地址和待操作数据的长度L等,这里不予限定。以下将以第一虚拟地址为待操作数据在虚拟磁盘中被读取或写入的位置偏移量O和待操作数据的长度L为例进行说明。
示例性的,该操作请求为:读取磁盘D上偏移为O,长度为L的数据。其中,磁盘D指的是虚拟机的虚拟磁盘;“磁盘D上偏移为O,长度为L”可以表示第一虚拟地址,表示在虚拟磁盘D上偏移为O,长度为L的区域所在的位置读取待操作数据(即待读取数据);待读取数据为磁盘D上偏移为O,长度为L的区域中的数据。
再示例性的,操作请求为:在磁盘D上偏移为O的位置,写入“hzujalbazkozujapzila”,数据长度为L。其中,磁盘D指的是虚拟机的虚拟磁盘;“磁盘D上偏移为O”或者“磁盘D上偏移为O,长度为L”表示第一虚拟地址,表示在虚拟磁盘D上偏移为O,长度为L的区域所在的位置写入待操作数据(即待写入数据);待写入数据为长度为L的数据“hzujalbazkozujapzila”。
402、若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与目标第一物理地址对应的目标第二物理地址,第二物理地址为物理机的物理磁盘的物理地址。
其中,目标第一物理地址是指第一虚拟地址对应的第一物理地址。若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则命中虚拟机缓存,即操作请求所请求的数据在虚拟机缓存中。此时,虚拟机的内存中保存有缓存元数据,可以直接访问虚拟机内存中的缓存元数据来查找是否存在与第一虚拟地址对应的目标第一物理地址,而不需要进行模式切换。
示例性的,当操作请求为读取磁盘D上偏移为O,长度为L的数据,第一虚拟地址为磁盘D上偏移为O,长度为L时,若缓存元数据中存在磁盘D上偏移为O,长度为L与第一物理地址的对应关系,则命中虚拟机缓存。再示例性的,当操作请求为在磁盘D上偏移为O的位置,写入“hzujalbazkozujapzila”,数据长度为L,第一虚拟地址为磁盘D上偏移为O,长度为L时,若缓存元数据中存在磁盘D上偏移为O,长度为L与第一物理地址的对应关系,则命中虚拟机缓存。例如,缓存元数据中存在与第一虚拟地址“磁盘D上偏移为O,长度为L”对应的目标第一物理地址为0x1253,则可以表明第一虚拟地址表示的位置处的数据,保存在虚拟机缓存中第一物理地址0x1253表示的位置。
在本申请实施例中,若缓存元数据中存在与第一虚拟地址对应的目标第一物理地址中,则物理机已经为虚拟机分配了缓存,请求的数据存储在虚拟机缓存中,并且物理机上保存有预先配置的多个第一物理地址与多个第二物理地址的对应关系。其中,第二物理地址是指为虚拟机缓存提供物理地址空间的物理磁盘的物理地址。该物理磁盘可以是图2所示虚拟化系统中的硬件存储设备102(或称硬件存储介质)。例如,该硬件设备可以是HDD、SSD或SAN设备等。目标第二物理地址是指目标第一物理地址对应的第二物理地址。此时,物理机可以根据保存的多个第一物理地址与多个第二物理地址的对应关系,查找与目标第一物理地址对应的目标第二物理地址。
在一种具体实现方式中,物理机CPU的寄存器中保存有扩展页表(extended page tables,EPT),用于保存多个第一物理地址与多个第二物理地址的对应关系,CPU通过EPT查找与目标第一物理地址对应的目标第二物理地址。
示例性的,该多个第一物理地址与多个第二物理地址的对应关系可以参见如下表2。
表2
第一物理地址 第二物理地址
第一物理地址1 第二物理地址1
第一物理地址2 第二物理地址1
第一物理地址3 第二物理地址2
需要说明的是,在本申请实施例中,每个第一物理地址可以对应一个第二物理地址,每个第二物理地址可以对应一个或多个第一物理地址。当一个第二物理地址对应多个第一物理地址时,物理机可以实现缓存复用,具体见后文关于缓存复用的详细描述。
403、在物理机的物理磁盘中目标第二物理地址指示的位置读取或写入数据。
物理机在确定与目标第一物理地址对应的目标第二物理地址后,在目标第二物理 地址表示的位置将待操作数据读取或写入虚拟机缓存中,从而可以通过访问虚拟机缓存提升读访问或写访问性能。
示例性的,当操作请求为读取磁盘D上偏移为O,长度为L的待操作数据时,若缓存元数据中包括磁盘D上偏移为O,长度为L对应的目标第一物理地址,则物理机查找目标第一物理地址对应的目标第二物理地址,并在虚拟机缓存中目标第二物理地址表示的位置读取数据。
再示例性的,当操作请求为在磁盘D上偏移为O的位置,写入“hzujalbazkozujapzila”,数据长度为L时,若缓存元数据中包括磁盘D上偏移为O,长度为L对应的目标第一物理地址,则物理机查找目标第一物理地址对应的目标第二物理地址,则在虚拟机缓存中目标第二物理地址表示的位置写入数据“hzujalbazkozujapzila”。
在本申请实施例提供的缓存访问过程中,物理机不需要进行非根模式和根模式之间的切换,就可以在缓存元数据中存在与待操作数据的第一虚拟地址对应目标第一物理地址时,根据第一物理地址与第二物理地址的对应关系确定目标第一物理地址对应的目标第二物理地址,从而在虚拟机缓存中目标第二物理地址表示的位置读取或写入数据,因而可以节省虚拟化开销占用的时间,提高缓存访问速率和缓存访问性能。也就是说,上述步骤401-步骤403在非根模式下就可以完成,而不用切换到根模式下来执行。
此外,在本申请实施例中,缓存元数据中还可以包括缓存类型、缓存状态和访问时间等其他信息。其中,缓存类型可以包括读缓存或写缓存。缓存状态用于表示缓存中的数据是否已被回刷至虚拟磁盘对应的物理磁盘。例如,缓存中未被回刷的数据可以称为脏数据,对应的缓存状态可以为dirty状态;缓存中已被回刷的数据对应的缓存状态可以为clean状态。访问时间用于表示缓存数据最近被访问的时间。物理机可以通过访问缓存元数据进行缓存利用率统计、缓存命中率统计、脏率统计等缓存情况统计并进行缓存管理。例如,当物理机根据缓存元数据中操作地址与第一物理地址的对应关系,确定已使用的第一物理地址占缓存对应的所有第一物理地址的比例大于或者等于第一预设值时,可以说明缓存利用率较大,当前缓存可能不足以供虚拟机使用,此时物理机可以将缓存配的更大一些。再例如,当物理机根据缓存元数据中的缓存状态确定脏率大于或者等于第二预设值时,可以触发回刷操作避免缓存中的脏数据累积而溢出。
需要说明的是,缓存元数据保存在虚拟机的内存中,而不是保存在物理机的存储设备上,因而可以直接访问缓存元数据进行缓存情况统计,而不需要在非根模式和根模式之间进行切换,因而可以节省虚拟化开销占用的时间,提高处理效率。
若缓存元数据中不存在第一虚拟地址与目标第一物理地址的对应关系,则未命中虚拟机缓存。该场景可以包括两种情况:一、物理机已经为虚拟机分配了缓存,但缓存元数据中不存在第一虚拟地址与目标第一物理地址的对应关系;二、物理机尚未给虚拟机分配缓存。
由于在此次访问第一操作区域后,再次访问第一操作区域的概率较大,因而在未命中虚拟机缓存的情况下,物理机可以将待操作数据写入虚拟机缓存,以便后续访问 该数据时,可以命中虚拟机缓存,从而可以不需要虚拟化开销而直接访问虚拟机缓存中的数据,提高访问性能。具体的,参见图5,若未命中虚拟机缓存,则本申请实施例提供的虚拟化缓存的实现方法还可以包括:
404、将数据写入虚拟机缓存中,数据在虚拟机缓存中的位置表示为目标第一物理地址,并根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与目标第一物理地址对应的目标第二物理地址;
若未命中虚拟机缓存,则将待操作数据写入虚拟机缓存,并获取写入的位置即目标第一物理地址。具体的,若未命中虚拟机缓存,则物理机可以从非根模式切换到根模式后执行步骤404和以下步骤405。
405、将目标第一物理地址与第一虚拟地址的映射关系保存至缓存元数据中。
在将待操作数据写入虚拟机缓存中目标第一物理地址表示的位置之后,可以根据预先配置的第一物理地址与第二物理地址的对应关系,确定与目标第一物理地址对应的目标第二物理地址,从而在缓存元数据中保存第一虚拟地址与目标第一物理地址之间的对应关系,以便于物理机在下次接收到携带有第一虚拟地址的操作请求后,可以确定命中虚拟机缓存,从而根据步骤402和步骤403描述的方法直接访问虚拟机缓存。
其中,当操作请求为读请求时,若未命中虚拟机缓存,则在上述步骤404之前,在从非根模式切换到根模式之后,还可以从第一虚拟地址表示的位置读取待操作数据。而后,在步骤404中,可以将从第一虚拟地址表示的位置读取的数据写入虚拟机缓存中。
在本申请其他一些实施例中,物理机包括前端驱动、后端驱动和缓存管理模块(cache management,CMM),各模块之间建立有通信通道,通过前端驱动、后端驱动和CMM各模块之间的配合实现上述步骤401-步骤405中的虚拟化缓存的实现方法。以下分别以读缓存访问流程和写缓存访问流程为例进行说明。
本申请另一实施例提供了一种读虚拟化缓存的实现方法,如图6所示,该方法可以包括:
601、前端驱动获取虚拟机下发的读请求。
示例性的,该读请求为:读取磁盘D上偏移为O,长度为L的内容;第一虚拟地址为:磁盘D上偏移为O,长度为L。
虚拟机用于,发送读请求给前端驱动,读请求包括第一虚拟地址,用于请求在虚拟磁盘中第一虚拟地址所指示的位置读取数据;
602、前端驱动确定缓存元数据中是否存在与第一虚拟地址对应的目标第一物理地址。
具体的,前端驱动确定缓存元数据中是否存在与磁盘D上偏移为O,长度为L对应的目标第一物理地址。若存在,则命中虚拟机缓存;若不存在,则未命中虚拟机缓存。
602a、如果缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则命中虚拟机缓存,前端驱动请求访问虚拟机缓存中,第一虚拟地址(即磁盘D上偏移为O,长度为L)对应的目标第一物理地址中的数据。前端驱动查找与目标第一物理地址对应的第二目标物理地址,读取虚拟缓存中目标第二物理地址中的数据,并更新缓存元 数据中缓存数据的访问时间为当前时间。可见,该虚拟机缓存访问过程不需要进行模式切换,没有虚拟化陷入陷出开销。
602b、如果缓存元数据中不存在与第一虚拟地址对应的目标第一物理地址,则未命中虚拟机缓存,前端驱动下发读磁盘请求,并切换到根模式读取磁盘中的数据。
若未命中虚拟机缓存,则在步骤602b之后,该方法还可以包括:
603、前端驱动向CMM发起缓存请求。
具体的,前端驱动通过与CMM之间的通信通道将缓存请求传递给CMM。示例性的,该缓存请求为:缓存数据,缓存数据对应的磁盘为D,磁盘偏移为O,长度为L。
其中,考虑到虚拟机缓存大小的限制,有些情况下,前端驱动并不会发起缓存请求。例如,假设按照用户的配置物理机为N个虚拟机的缓存配置了10G的空间,如果10G空间已用完,则前端驱动不向CMM发起缓存请求;如果缓存没有用完,则前端驱动可以向CMM发起缓存请求。
604、CMM在收到缓存请求后确定当前虚拟机的缓存空间是否有剩余。
604a、如果当前虚拟机的缓存空间还有剩余,则CMM将读取的数据写入当前虚拟机的缓存中。例如,假设按照用户的配置物理机为当前虚拟机的缓存配置了100M的空间,目前还有60M空间尚未被使用,则CMM不需要重新分配空间,可以直接将读取的数据写入这60M的空间中,并将写入数据的空间标记为已被使用。
604b、如果当前虚拟机的缓存空间没有剩余,则CMM重新分配缓存空间,再将读取的数据写入虚拟机的缓存中。例如,若当前已经分配的100M空间没有剩余,则CMM可以重新分配100M空间的缓存,再将读取的数据写入新的100M空间中,并将写入数据的空间标记为已被使用。
这一步骤中涉及到虚拟机缓存的分配,分配的主体是CMM;分配的算法可以根据用户选择的缓存属性,如读缓存、写缓存等;选择合适的存储介质作为缓存硬件,可以是内存,也可以是NVM高速存储设备,或者是以字节寻址的存储设备。
在CMM将读取的数据写入当前虚拟机的缓存之后,可以获取写入的数据在虚拟机缓存中的目标第一物理地址。
605、CMM通知前端驱动更新缓存元数据。
在由根模式切换回非根模式后,CMM通知前端驱动更新缓存元数据。
606、前端驱动接收到CMM的通知后更新缓存元数据。
其中,前端驱动更新的内容包括:保存目标第一物理地址和第一虚拟地址的对应关系,更新缓存访问时间为当前时间。
后续当再次请求读访问第一虚拟地址时,在上述步骤602中,将执行虚拟机缓存命中流程,即走602a分支,从而无需模式切换即可直接访问虚拟机缓存。
本申请另一实施例提供了一种写虚拟化缓存的实现方法,通过物理机中前端驱动、后端驱动和缓存管理模块等模块之间的相互配合来实现,如图7所示,该方法包括:
701、前端驱动获取虚拟机下发的写请求。
示例性的,该写请求为:在磁盘D上偏移为O的位置,写入“hzujalbazkozujapzila”,数据长度为L。
702、前端驱动确定缓存元数据中是否存在与第一虚拟地址对应的目标第一物理地 址。
具体的,前端驱动确定缓存元数据中是否存在与磁盘D上偏移为O,长度为L对应的目标第一物理地址。
702a、如果缓存元数据中存在与第一虚拟地址对应的目标第一物理地址,则命中虚拟机缓存,前端驱动请求访问虚拟机缓存中,第一虚拟地址(即磁盘D上偏移为O,长度为L)对应的目标第一物理地址中的数据。前端驱动查找与目标第一物理地址对应的第二目标物理地址,在虚拟缓存中目标第二物理地址表示的位置写入数据,并更新缓存元数据中目标第二物理地址对应的数据块的缓存状态为脏(dirty)状态。可见,该虚拟机缓存访问过程不需要进行模式切换,没有虚拟化陷入陷出开销。
702b、如果缓存元数据中不存在与第一虚拟地址对应的目标第一物理地址,则未命中虚拟机缓存,前端驱动下发写磁盘请求,并由非根模式切换到根模式。
若未命中虚拟机缓存,则在步骤702b之后,该方法还可以包括:
703、前端驱动向CMM发起缓存请求。
具体的,前端驱动通过与CMM之间的通信通道将缓存请求传递给CMM。示例性的,该缓存请求为:写入数据,写入数据对应的磁盘为D,磁盘偏移为O,长度为L。
其中,与步骤703所描述的情况类似,前端驱动可以在某些情况下发起缓存请求,在另一情况下不能发起缓存请求。若前端驱动不能发起缓存请求,则物理机将待写入数据写入物理磁盘中。
704、CMM在收到缓存请求后查询当前虚拟机的缓存空间是否有剩余。
704a、如果当前虚拟机的缓存空间还有剩余,则CMM将读取的数据写入当前虚拟机的缓存中。
704b、如果当前虚拟机的缓存空间没有剩余,则CMM重新分配缓存空间,再将读取的数据写入虚拟机的缓存中。
在CMM将待写入数据写入当前虚拟机的缓存之后,可以获取写入的数据在虚拟机缓存中的目标第一物理地址。
705、CMM通知前端驱动更新缓存元数据。
在由根模式切换回非根模式后,CMM通知前端驱动更新缓存元数据。
706、前端驱动接收到CMM的通知后更新缓存元数据。
其中,前端驱动更新的内容包括:保存与目标第一物理地址和第一虚拟地址的对应关系,缓存状态为dirty。
后续当再次请求写访问磁盘D的偏移为O,长度为L第一虚拟地址时,在上述步骤702中,将执行虚拟机缓存命中流程,即走702a分支,从而无需模式切换即可直接访问虚拟机缓存。
为了向虚拟机模拟带虚拟机缓存的虚拟磁盘,本申请实施例提供的虚拟化缓存的实现方法还可以包括一个缓存初始化流程。在用户或管理员配置缓存策略后,当虚拟机启动或挂载虚拟磁盘时,触发缓存初始化流程。其中,用户或管理员配置的缓存策略可以包括虚拟机的缓存大小、虚拟机的缓存类型(读缓存/写缓存)以及虚拟机的缓存优先级等。具体的,如图8所示,缓存初始化过程可以包括:
801、后端驱动根据用户设置的缓存配置初始化虚拟机缓存。
具体的,后端驱动初始化虚拟机缓存可以包括,初始化虚拟机可访问的第一物理地址空间的范围、缓存优先级等,并将缓存配置的相关参数传递给CMM。
802、前端驱动初始化虚拟机缓存的物理地址空间和缓存元数据。
具体的,在后端驱动初始化虚拟机可访问的第一物理地址空间的范围后,前端驱动也初始化第一物理地址(即虚拟机缓存的物理地址)空间的范围。并且,前端驱动申请虚拟机的一段内存空间用于存放缓存元数据,并初始化缓存元数据。在初始化阶段,缓存元数据被初始化为无效。随着虚拟机后续对虚拟机缓存的使用,缓存元数据会被动态更新,保存第一物理地址与操作地址的对应关系、缓存状态以及访问时间等信息,从而从无效状态转化为有效状态,以便缓存访问时使用。
803、CMM初始化与前端驱动的通信通道。
其中,前端驱动与CMM之间的通信通道可以有多种,例如可以是共享内存通信通道或套接字(socket)通信通道等。这里的初始化通信通道,是指初始化共享内存连接或初始化socket连接等。
此外,初始化过程中还可以初始化前端驱动与后端驱动之间,以及后端驱动与CMM之间的通信通道,这里不予赘述。
在本申请实施例中,物理机可以对N个虚拟机的缓存进行统一管理,在N个虚拟机之间调配缓存资源,从而使得缓存管理更加灵活,缓存成本更低。例如,该管理可以包括缓存分配、缓存淘汰、缓存回刷、缓存大小修改、缓存属性修改以及缓存复用等任务。其中,缓存属性包括缓存类型和缓存优先级,缓存类型包括读缓存和写缓存。
可选地,可以根据虚拟机的Qos参数,或者虚拟机包括的虚拟磁盘的Qos参数对虚拟机的缓存进行统一管理,从而为每个虚拟机提供更好的缓存服务。其中,Qos参数可以包括缓存的预留值、缓存的上限值或缓存的优先级等参数中的至少一种。
以下将对各项缓存管理任务分别进行说明:
A、缓存分配
在本申请实施例中,在访问虚拟机的缓存之前,还可以为虚拟机分配缓存,以便于虚拟机在运行过程中可以使用缓存。缓存分配是指从物理机上当前提供高性能存储服务的硬件上,开辟一段物理地址空间,并建立该物理地址空间的第一物理地址与第二物理地址的映射关系。
在一种情况下,可以在上述缓存初始化时为虚拟机分配缓存。该种情况下,如图5所示,在上述步骤401之前,该方法还可以包括:
406、CMM为虚拟机缓存分配物理地址空间,将物理磁盘中的一部分物理地址分配给虚拟机的缓存。
407、CMM建立多个第一物理地址与多个第二物理地址的映射关系。
在另一种情况下,物理机可以在需要访问虚拟机缓存时动态地为虚拟机分配缓存。在上述步骤404之前,若物理机尚未给虚拟机分配缓存,则物理机执行上述步骤406和步骤407从而在需要时为虚拟机分配缓存。
主要通过物理机中的CMM来实现,即CMM执行上述步骤406和步骤407:
在上述步骤406中,CMM为虚拟机缓存分配物理地址空间。具体的,CMM根据用户的缓存配置和物理机上的存储硬件特性,选择合适的存储硬件来模拟缓存。具体 的,CMM可以从全局角度为N个虚拟机分配物理地址空间,并结合用户设置的缓存配置考虑选择何种存储硬件作为某个虚拟机的缓存介质,在N个虚拟机之间调配缓存资源,从而降低缓存成本。
并且,还可以根据虚拟机的Qos参数或虚拟机包括的虚拟磁盘的Qos参数为虚拟机分配缓存。举例来说,可以优先为N个虚拟机中优先级高的虚拟机分配缓存,以保证优先级高的虚拟机对缓存的使用;或者,考虑到虚拟机中可能有多个虚拟磁盘,则可以为虚拟机中优先级高的虚拟磁盘预留一部分缓存空间,这些缓存空间不能被优先级低的虚拟机或虚拟磁盘使用,以使得在需要使用优先级高的虚拟磁盘的缓存时能够及时分配到缓存。
在上述步骤407中,CMM建立多个第一物理地址与多个第二物理地址的对应关系。具体的,CMM采用intel的硬件辅助虚拟化技术(virtualization technology,VT)等按字节映射的技术,建立第二物理地址到第一物理地址的映射关系。
B、缓存淘汰
通过上述实施例中的虚拟化缓存的实现方法,可以将数据添加到虚拟机缓存中。当虚拟机缓存为读缓存时,如果一直向虚拟机缓存中添加数据,则可能导致虚拟机缓存溢出。为了使得虚拟机缓存能够实时保存热点数据,可以根据预设的淘汰策略将缓存中长期不访问的数据淘汰出去,以使得虚拟机缓存有足够的空间接收新的热点数据。如图9所示,物理机上运行的虚拟机有N个,N为正整数,缓存淘汰过程可以包括:
901、CMM从N个虚拟机的缓存中确定第一数据。
可以根据第一预设策略从N个虚拟机的缓存中确定待淘汰的第一数据,该第一数据是至少一个虚拟机的缓存中需要被淘汰的数据。在一种具体实现方式中,可以先确定N个虚拟机中每个虚拟机中需要被淘汰的数据,再从中确定第一数据;
在另一种具体实现方式中,CMM可以先从N个虚拟机中确定M(M小于或者等于N)个虚拟机,再确定该M个虚拟机中需要被淘汰的数据,该M个虚拟机中需要被淘汰的数据即为第一数据。也就是说,CMM可以从全局角度出发,综合考虑各虚拟机缓存中的情况,更为有效、准确地判断哪些虚拟机缓存中的哪些数据是需要被尽快淘汰的非热点数据,从而予以淘汰。例如,可以根据最近最少使用(least recently used,LRU)算法,最不经常使用(least frequently used,LFU)算法,或先进先出(first in first out,FIFO)算法确定第一数据。
此外,在本申请实施例中,缓存元数据中还保存有访问时间与第一物理地址的对应关系。缓存元数据中的访问时间可以用于确定缓存中第一物理地址对应的数据最近被访问的时间,从而便于确定缓存中需要被淘汰的数据。
可选地,可以根据虚拟机的Qos参数确定需要被淘汰的第一数据或根据虚拟机中虚拟磁盘的Qos参数确定需要被淘汰的第一数据,Qos参数包括缓存的预留值、缓存的上限值或缓存的优先级中的至少一种。举例来说,可以优先淘汰优先级低的虚拟机缓存中的数据,或者优先淘汰优先级低的虚拟磁盘的缓存中的数据,或者可以优先淘汰缓存上限值小的虚拟机缓存中的数据等或者可以优先淘汰缓存预留值小的虚拟机缓存中的数据。
902、CMM将第一数据从N个虚拟机的缓存中删除。
903、前端驱动删除缓存元数据中第一数据对应的虚拟地址与第一物理地址的映射关系。
在将第一数据从N个虚拟机的缓存中删除后,第一数据不在虚拟机缓存中,因而可以删除缓存元数据中第一数据对应的操作地址与第一物理地址的对应关系,从而及时更新缓存元数据中的操作地址与第一物理地址的对应关系,使得缓存元数据中的对应关系与当前虚拟机缓存中的数据缓存情况保持实时一致。并且,这样还便于根据缓存元数据准确地进行缓存利用率统计、缓存命中率统计等缓存情况统计和缓存管理。在删除第一数据后,还可以释放第一数据所占用的缓存资源,以供其他虚拟机使用。后续有其他虚拟机的热点数据时,可以加入到被释放的缓存资源中。
C、缓存回刷
通过上述实施例中的虚拟化缓存的实现方法,可以将数据添加到虚拟机缓存中。对于写缓存来说,虚拟机下发的写请求可以优先落入虚拟机缓存的缓存介质中,以此来提升写访问的性能;但是,一方面,由于缓存空间有限;另一方面,缓存介质可能是易失的,因此当物理机掉电等情况发生时,缓存介质中的数据就会丢失。因此,虚拟机缓存需要及时将虚拟机写入的数据回刷(flush)到物理磁盘上,才能保证虚拟机缓存的可靠性和可用性。其中,物理磁盘可以是图2所示存储设备中的物理存储介质。缓存回刷可以包括主动回刷和定期回刷。主动回刷通常发生在虚拟机内写入了关键数据时,虚拟机主动触发回刷操作,保证数据及时写入磁盘中。定期回刷是指定期将虚拟机缓存中的数据回刷至物理磁盘。如图10所示,该缓存淘汰回刷方法可以包括:
1001、CMM从N个虚拟机的缓存中确定第二数据。
可以根据第二预设策略从N个虚拟机的缓存中确定待回刷的第二数据,该第二数据是至少一个虚拟机的缓存中需要被回刷的数据。在一种具体实现方式中,物理机可以先确定N个虚拟机中需要被回刷的数据,再从中确定第二数据;在另一种具体实现方式中,物理机可以先确定需要被回刷的M(M小于或者等于N)个虚拟机,再确定该M个虚拟机中需要被回刷的数据,该M个虚拟机中需要被回刷的数据即为第二数据。也就是说,物理机可以从全局角度综合考虑各虚拟机缓存中的情况,更为有效、准确地判断哪些虚拟机缓存中的哪些数据是需要被尽快回刷至物理磁盘的数据。例如,物理机可以根据缓存元数据中的访问时间确定N个虚拟机的缓存中最先写入虚拟机缓存,缓存状态为dirty的数据,这些数据需要被尽快回刷至物理磁盘。
可选地,以根据虚拟机的Qos参数或虚拟机中虚拟磁盘的Qos参数确定需要被回刷的第二数据。举例来说,可以优先回刷优先级高的虚拟机的缓存中的数据,或者物理机可以优先回刷优先级高的虚拟磁盘的缓存中的数据,或者可以优先回刷上限值小的虚拟机缓存中的数据等。
1002、CMM将第二数据回刷至物理磁盘。
在该步骤中,将确定的待回刷的第二数据写入物理磁盘。
1003、前端驱动更新缓存元数据中第二数据的缓存状态。
在将第二数据从缓存中回刷至物理磁盘后,可以将缓存元数据中第二数据的缓存状态由dirty状态转为clean状态,以表明第二数据已被回刷至物理磁盘,并及时更新缓存元数据中缓存状态信息,以使得缓存状态与当前虚拟机缓存中数据的状态实时保 持一致。这样,还可以便于物理机根据缓存元数据准确地进行缓存脏率统计等缓存情况统计和缓存管理。
在本申请实施例中,当用户或管理员修改缓存配置时,CMM可以根据修改后的缓存配置在线修改虚拟机缓存的大小和虚拟机缓存的属性等内容,使得缓存资源使用更为灵活。其中,“在线”修改是指,不需要重新启动物理机或虚拟机就可以实现虚拟机缓存的修改,使得修改能够即时生效。以下分别对修改缓存大小和修改缓存属性进行说明。
D、缓存大小在线修改
如图11所示,本申请实施例提供的修改缓存大小的方法可以包括:
1101、CMM修改分配给虚拟机的缓存的物理地址的范围。
在需要修改虚拟机缓存的大小时,CMM可以修改缓存对应的第一物理地址空间的范围,第一物理地址空间为物理磁盘中分配给虚拟机缓存的那部分物理地址。例如,当虚拟机缓存需要扩容时,CMM将虚拟机缓存的物理地址的范围由0x001-0x100修改为0x001-0x200;当虚拟机缓存需要减容时,CMM将虚拟机缓存的第一物理地址的范围由0x001-0x100,修改为0x001-0x050。在虚拟机缓存需要扩容时,扩大虚拟机缓存的第一物理地址的范围,在虚拟机缓存需要减容时,缩小虚拟机缓存的第一物理地址的范围。
1102、CMM根据修改后的分配给虚拟机的缓存的物理地址的范围,更新多个第一物理地址与多个第二物理地址的映射关系。
CMM根据修改后的第一物理地址的范围,更新第二物理地址与第一物理地址的对应关系。这样,前端驱动可以实时根据更新后的第二物理地址与第一物理地址的对应关系,确定与目标第一物理地址对应的目标第二物理地址,从而根据目标第二物理地址直接获取数据,实现虚拟化缓存。
此外,当待修改大小的虚拟机缓存为写缓存且需要减容时,在上述步骤1101之前,该修改缓存大小的方法还可以包括:
1103、CMM回刷并删除虚拟机缓存中的第三数据。
在减容之前,CMM需要先将待删减的缓存空间中的第三数据回刷和删除,以保证待删减的缓存空间中的数据不会丢失。
在减容完成后,物理机可以恢复写入虚拟机缓存的操作,虚拟机可以正常使用缓存。
E、缓存属性在线修改
本申请另一实施例提供了一种修改缓存属性的方法,该缓存属性可以包括缓存优先级和缓存类型,该方法可以通过物理机的前端驱动、后端驱动和缓存管理模块之间的相互配合来实现。附图虽未示出,但该方法可以包括:后端驱动通知CMM改变缓存优先级或缓存类型,然后CMM改变缓存优先级或缓存类型。
其中,如果需要将写缓存修改为读缓存,则可以在触发缓存回刷流程将脏数据写到物理磁盘后,再将写缓存修改为读缓存。并且,前端驱动还可以及时更新缓存元数据中的缓存类型,以使得缓存元数据与修改后的虚拟机缓存的情况实时保持一致。
F、缓存复用
在本申请实施例中,在第一物理地址与第二物理地址的对应关系中,如图12所示,一个第二物理地址可以对应多个虚拟机的第一物理地址。这样,同一第二物理地址可以供多个虚拟机缓存使用,从而可以复用物理缓存空间,节省缓存成本。在缓存复用场景下,多个虚拟机共享虚拟磁盘,这样多个虚拟机缓存对应的第二物理地址也是相同的,从而便于使用缓存复用技术。
本申请另一实施例提供了一种缓存复用的方法,通过物理机的前端驱动、后端驱动和缓存管理模块之间的相互配合来实现。附图虽未示出,但该方法可以包括:
1201、当第一虚拟机的前端驱动向后端驱动下发读请求时,CMM确定物理机上N个虚拟机的缓存元数据中是否包括与读请求中的第一虚拟地址对应的目标第一物理地址。
1202、如果第二虚拟机缓存的缓存元数据中存在与该读请求中的第一虚拟地址对应的第一物理地址1,且第一物理地址1与第二物理地址1对应,则CMM建立第一物理地址2与第二物理地址1的对应关系。
1203、CMM通知前端驱动更新缓存元数据。
1204、前端驱动完成缓存元数据的更新,更新内容包括:保存第一虚拟地址与第一物理地址2的对应关系,缓存访问时间为当前时间。
这样,就建立了第一虚拟机对应的第一虚拟地址、第一物理地址2以及第二物理地址1之间的对应关系。而第二虚拟机存在第一虚拟地址、第一物理地址1以及第二物理地址1之间的对应关系。也就是说,这两个虚拟机可以公用第二物理地址1。因此,当多台虚拟机访问同一第二物理地址时,将会构成同一个第二物理地址映射到多个虚拟机的第一物理地址的情况,这样可以达成缓存复用的效果。
与缓存复用类似,本申请实施例提供的虚拟化缓存的实现方法还可以实现缓存重删等技术,从而进一步降低虚拟机缓存的成本。其中,缓存重删是指删除缓存中的重复数据。缓存重删可以有两种方式:在线重删和离线重删。在线重删是指当向虚拟机缓存中写入数据时,判断是否已经有其他区域存在相同的数据,如果有,直接修改第一物理地址到第二物理地址的映射关系。离线重删是指在物理机存在一个定时任务,该任务定时扫描N个虚拟机的缓存中的数据,如果发现有相同的数据,则修改第一物理地址到第二物理地址的映射关系,让多个第一物理地址指向同一个第二物理地址。
需要说明的是,在本申请实施例中,通常作为存储使用的存储设备可以为虚拟机缓存提供存储空间。并且,该存储设备可以是基于字节寻址的设备。当采用存储设备为虚拟机缓存提供存储空间时,基于本申请实施例提供的方案,物理机可以不需要虚拟化开销而直接访问虚拟机缓存,并且物理机还可以通过前端区域、后端驱动和缓存管理模块之间的配合,统一对物理机上的N个虚拟机进行缓存分配、缓存回刷、缓存淘汰、缓存大小修改、缓存属性修改以及缓存复用等缓存管理内容,从而实现虚拟机缓存的灵活管理,降低缓存管理成本。
现有技术还提供了一种虚拟缓存方案,即将高性能的外设部件互连标准(peripheral component interconnect,PCI)接口的存储介质(或称存储设备)直通给虚拟机作为缓存使用,或者直接使用虚拟机内存作为缓存。在该方案中,虚拟机内访问直通存储介质不需要虚拟化软件的参与,虚拟机可像物理机一样直接访问存储介质,因此物理机 可以无需虚拟化开销而直接访问虚拟机缓存。但是,在该方案中,由于每个虚拟机各自管理自己的缓存,虚拟机之间无法共享缓存,缓存也无法动态扩容或减容,因而无法实现物理机对各虚拟机缓存的统一管理,无法达到管理灵活、降低成本的效果。并且,在直接使用虚拟机内存作为虚拟机缓存的方案中,物理机可以统一管理各虚拟机的内存,但虚拟机的缓存与内存属于不同的管理层面,物理机无法实现对各虚拟机缓存的统一管理。
上述主要从各个网元之间交互的角度对本申请实施例提供的方案进行了介绍。可以理解的是,各个网元,例如服务器、终端为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对服务器、终端进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在采用对应各个功能划分各个功能模块的情况下,图13示出了上述实施例中涉及的物理机1300的一种可能的组成示意图,如图13所示,该物理机1300可以包括:虚拟机1301、前端驱动1302、后端驱动1303和缓存管理模块1304。
其中,虚拟机1301用于发送操作请求给前端驱动,其中操作请求包括第一虚拟地址,用于请求在虚拟磁盘中第一虚拟地址所指示的位置读取或写入数据。
前端驱动1302,可以用于支持物理机执行步骤401-402,步骤403,步骤405,步骤601-603,步骤606,步骤701-703,步骤802,步骤903,步骤1003,步骤1101,步骤1102,步骤1104,步骤1204等;和/或用于本文所描述的技术的其他过程。
后端驱动1303,可以用于支持物理机执行步骤801,还可以用于发起缓存大小修改或缓存属性修改;和/或用于本文所描述的技术的其他过程。
缓存管理模块1304,可以用于支持物理机执行步骤404,步骤406-407,步骤604-605,步骤704-705,步骤803,步骤901-902,步骤1001-1002,步骤1103,步骤1105,步骤1106,步骤1107,步骤1201-1203等;和/或用于本文所描述的技术的其他过程。
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
本申请实施例提供的物理机,用于执行上述虚拟化缓存的实现方法,因此可以达到与上述虚拟化缓存的实现方法相同的效果。
在采用对应各个功能划分各个功能模块的情况下,该物理机可以包括:获取模块、处理模块、读写模块和缓存管理模块。其中:
获取模块,用于执行步骤401、步骤601、步骤701和/或用于本文所描述的技术 的其他过程。
处理模块,用于执行步骤402、步骤405、步骤602、步骤603、步骤606、步骤702、步骤703、步骤706、步骤802、步骤903、步骤1003和/或用于本文所描述的技术的其他过程。
读写模块,用于执行步骤403和/或用于本文所描述的技术的其他过程。
获取模块、处理模块和读写模块具体可以由前端驱动1302来实现。
在采用集成的单元的情况下,物理机可以包括处理模块和存储模块。其中,处理模块用于对物理机的动作进行控制管理,例如,可以用于支持物理机执行上述前端驱动1302、后端驱动1303和缓存管理模块1304执行的步骤,和/或用于本文所描述的技术的其他过程。存储模块用于支持物理机实现缓存,存储程序代码和数据。
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。
在一个简单的实施例中,当处理模块为处理器,存储模块为存储器时,本申请实施例所涉及的物理机可以为具有图3所示计算机系统的设备。
本申请实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在物理机上运行时,使得物理机执行上述相关方法步骤实现上述实施例中的虚拟化缓存的实现方法。
本申请实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的虚拟化缓存的实现方法。
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的虚拟化缓存的实现方法。
其中,本申请实施例提供的物理机、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的 部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种虚拟化缓存的实现方法,应用于物理机,所述物理机上运行有虚拟机,其特征在于,所述虚拟机的内存上保存有缓存元数据,所述缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系,所述虚拟地址指示虚拟磁盘中的位置,所述第一物理地址为所述虚拟机的缓存的物理地址,所述方法包括:
    获取所述虚拟机下发的操作请求,所述操作请求包括第一虚拟地址,用于请求在所述虚拟磁盘中所述第一虚拟地址所指示的位置读取或写入数据;
    若所述缓存元数据中存在与所述第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与所述目标第一物理地址对应的目标第二物理地址,所述第二物理地址为所述物理机的物理磁盘的物理地址;
    在所述物理机的物理磁盘中所述目标第二物理地址指示的位置读取或写入所述数据。
  2. 根据权利要求1所述的虚拟化缓存的实现方法,其特征在于,所述方法还包括:
    若所述缓存元数据中不存在与所述第一虚拟地址对应的目标第一物理地址,则
    将所述数据写入所述虚拟机缓存中,所述数据在所述虚拟机缓存中的位置表示为所述目标第一物理地址,并根据所述预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与所述第一目标物理地址对应的所述目标第二物理地址;
    将所述目标第一物理地址与所述第一虚拟地址的映射关系保存至所述缓存元数据中。
  3. 根据权利要求1或2所述的虚拟化缓存的实现方法,其特征在于,所述方法还包括:
    将所述物理磁盘中的一部分物理地址分配给所述虚拟机的缓存;
    建立所述多个第一物理地址与所述多个第二物理地址的映射关系。
  4. 根据权利要求1-3任一项所述的虚拟化缓存的实现方法,其特征在于,所述物理机上运行的虚拟机有N个,N为正整数,所述方法还包括:
    从所述N个虚拟机的缓存中确定第一数据;
    将所述第一数据从所述N个虚拟机的缓存中删除;
    删除所述缓存元数据中所述第一数据对应的虚拟地址与第一物理地址的映射关系。
  5. 根据权利要求4所述的虚拟化缓存的实现方法,其特征在于,所述确定第一数据具体包括:
    根据所述虚拟机的服务质量Qos参数或所述虚拟机中虚拟磁盘的服务质量Qos参数,确定所述第一数据,所述Qos参数包括所述缓存的预留值、所述缓存的上限值或所述缓存的优先级中的至少一种。
  6. 根据权利要求1-5任一项所述的虚拟化缓存的实现方法,其特征在于,所述物理机上运行的虚拟机有N个,N为正整数,所述缓存元数据还包括缓存状态,所述缓存状态用于表示所述虚拟机缓存中的数据是否被回刷至所述物理磁盘,所述方法还包括:
    从所述N个虚拟机的缓存中确定第二数据;
    将所述第二数据回刷至所述物理磁盘;
    更新所述缓存元数据中所述第二数据的缓存状态。
  7. 根据权利要求6所述的虚拟化缓存的实现方法,其特征在于,所述确定第二数据具体包括:
    根据所述虚拟机的服务质量Qos参数或所述虚拟机中虚拟磁盘的服务质量Qos参数,确定所述第二数据,所述Qos参数包括所述缓存的预留值、所述缓存的上限值或所述缓存的优先级中的至少一种。
  8. 根据权利要求3-7任一项所述的虚拟化缓存的实现方法,其特征在于,所述方法还包括:
    修改所述分配给所述虚拟机的缓存的物理地址的范围;
    根据修改后的所述分配给所述虚拟机的缓存的物理地址的范围,更新所述多个第一物理地址与所述多个第二物理地址的映射关系。
  9. 一种物理机,包括:虚拟机和前端驱动、物理磁盘、虚拟机缓存、虚拟磁盘和虚拟机内存,其特征在于,所述虚拟机内存上保存有缓存元数据,所述缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系,所述虚拟地址用于表示虚拟磁盘中的位置,所述第一物理地址为虚拟机的缓存的物理地址;
    所述虚拟机用于,发送操作请求给所述前端驱动,所述操作请求包括第一虚拟地址,用于请求在所述虚拟磁盘中所述第一虚拟地址所指示的位置读取或写入数据;
    所述前端驱动用于:
    获取所述虚拟机下发的操作请求,所述操作请求;若所述缓存元数据中存在与所述第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与所述目标第一物理地址对应的目标第二物理地址,所述第二物理地址为所述物理机的物理磁盘的物理地址;在所述物理机的物理磁盘中所述目标第二物理地址指示的位置读取或写入所述数据。
  10. 根据权利要求9所述的物理机,其特征在于,所述物理机还包括缓存管理模块,所述缓存管理模块用于:
    将所述数据写入所述虚拟机缓存中,所述数据在所述虚拟机缓存中的位置表示为所述目标第一物理地址,并根据所述预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与所述第一目标物理地址对应的所述目标第二物理地址;将所述目标第一物理地址与所述第一虚拟地址的对应关系保存至所述缓存元数据中。
  11. 一种物理机,所述物理机上运行有虚拟机,其特征在于,所述虚拟机的内存上保存有缓存元数据,所述缓存元数据中包括多个虚拟地址与多个第一物理地址之间的一一映射关系,所述虚拟地址用于表示虚拟磁盘中的位置,所述第一物理地址为虚拟机的缓存的物理地址;所述物理机包括:
    获取模块,所述获取模块用于:获取所述虚拟机下发的操作请求,所述操作请求包括第一虚拟地址,用于请求在所述虚拟磁盘中所述第一虚拟地址所指示的位置读取或写入数据;
    处理模块,所述处理模块用于:若所述缓存元数据中存在与所述第一虚拟地址对应的目标第一物理地址,则根据预先配置的多个第一物理地址与多个第二物理地址的 映射关系,确定与所述目标第一物理地址对应的目标第二物理地址,所述第二物理地址为所述物理机的物理磁盘的物理地址;
    读写模块,所述读写模块用于:在所述物理机的物理磁盘中所述目标第二物理地址指示的位置读取或写入所述数据。
  12. 根据权利要求11所述的物理机,其特征在于,所述物理机还包括缓存管理模块,
    所述缓存管理模块用于:若所述缓存元数据中不存在与所述第一虚拟地址对应的目标第一物理地址,则将所述数据写入所述虚拟机缓存中,所述数据在所述虚拟机缓存中的位置表示为所述目标第一物理地址,并根据所述预先配置的多个第一物理地址与多个第二物理地址的映射关系,确定与所述第一目标物理地址对应的所述目标第二物理地址;
    所述处理模块还用于,将所述目标第一物理地址与所述第一虚拟地址的映射关系保存至所述缓存元数据中。
  13. 根据权利要求11或12所述的物理机,其特征在于,所述物理机包括缓存管理模块,所述缓存管理模块用于:
    将所述物理磁盘中的一部分物理地址分配给所述虚拟机的缓存;
    建立所述多个第一物理地址与所述多个第二物理地址的映射关系。
  14. 根据权利要求10-13任一项所述的物理机,其特征在于,所述物理机上运行的虚拟机有N个,N为正整数,所述缓存管理模块还用于:
    从所述N个虚拟机的缓存中确定第一数据;
    将所述第一数据从所述N个虚拟机的缓存中删除;
    所述处理模块还用于,删除所述缓存元数据中所述第一数据对应的虚拟地址与第一物理地址的映射关系。
  15. 根据权利要求14所述的物理机,其特征在于,所述缓存管理单元具体用于:
    根据所述虚拟机的服务质量Qos参数或所述虚拟机中虚拟磁盘的服务质量Qos参数,确定所述第一数据,所述Qos参数包括所述缓存的预留值、所述缓存的上限值或所述缓存的优先级中的至少一种。
  16. 根据权利要求10-15任一项所述的物理机,其特征在于,所述物理机上运行的虚拟机有N个,N为正整数,所述缓存元数据还包括缓存状态,所述缓存状态用于表示所述虚拟缓存中的数据是否被回刷至所述物理磁盘,所述物理机包括缓存管理模块,所述缓存管理模块用于:
    从所述N个虚拟机的缓存中确定第二数据;
    将所述第二数据回刷至所述物理磁盘;
    所述处理模块还用于,更新所述缓存元数据中所述第二数据的缓存状态。
  17. 根据权利要求16所述的物理机,其特征在于,所述缓存管理单元具体用于:
    根据所述虚拟机的服务质量Qos参数或所述虚拟机中虚拟磁盘的服务质量Qos参数,确定所述第二数据,所述Qos参数包括所述缓存的预留值、所述缓存的上限值或所述缓存的优先级中的至少一种。
  18. 根据权利要求10-17任一项所述的物理机,其特征在于,所述物理机包括缓 存管理模块,
    所述缓存管理模块还用于:修改所述分配给所述虚拟机的缓存的物理地址的范围;根据修改后的所述分配给所述虚拟机的缓存的物理地址的范围,更新所述多个第一物理地址与所述多个第二物理地址的映射关系。
  19. 一种物理机,其特征在于,包括处理器和存储有计算机程序的计算机可读存储介质;
    所述处理器与所述计算机可读存储介质耦合,所述计算机程序被所述处理器执行时实现如权利要求1-8任一项所述的虚拟化缓存的实现方法。
  20. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1-8任一项所述的虚拟化缓存的实现方法。
PCT/CN2019/080074 2018-06-12 2019-03-28 虚拟化缓存的实现方法及物理机 WO2019237791A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP19819486.2A EP3783480B1 (en) 2018-06-12 2019-03-28 Virtualized cache implementation method and physical machine
US17/115,273 US11397690B2 (en) 2018-06-12 2020-12-08 Virtualized cache implementation method and physical machine

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810603891.8A CN110597451B (zh) 2018-06-12 2018-06-12 一种虚拟化缓存的实现方法及物理机
CN201810603891.8 2018-06-12

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/115,273 Continuation US11397690B2 (en) 2018-06-12 2020-12-08 Virtualized cache implementation method and physical machine

Publications (1)

Publication Number Publication Date
WO2019237791A1 true WO2019237791A1 (zh) 2019-12-19

Family

ID=68842761

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/080074 WO2019237791A1 (zh) 2018-06-12 2019-03-28 虚拟化缓存的实现方法及物理机

Country Status (4)

Country Link
US (1) US11397690B2 (zh)
EP (1) EP3783480B1 (zh)
CN (1) CN110597451B (zh)
WO (1) WO2019237791A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113010452A (zh) * 2021-03-17 2021-06-22 中国科学技术大学 一种高效且支持QoS的虚拟内存架构

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10419243B2 (en) * 2016-09-09 2019-09-17 Johnson Controls Technology Company Smart gateway devices, systems and methods for providing communication between HVAC system networks
CN111209229B (zh) * 2019-12-30 2021-12-21 苏州艾利特机器人有限公司 一种基于虚拟设备的现场总线方法
US11487654B2 (en) * 2020-03-02 2022-11-01 Silicon Motion, Inc. Method for controlling write buffer based on states of sectors of write buffer and associated all flash array server
CN111988394B (zh) * 2020-08-18 2022-11-01 北京金山云网络技术有限公司 一种虚拟化环境中优化p2p数据传输的方法、装置及设备
CN112241308B (zh) * 2020-10-21 2022-07-29 海光信息技术股份有限公司 一种虚拟机标识处理方法、装置及相关设备
US20220229552A1 (en) * 2021-01-15 2022-07-21 SK Hynix Inc. Computer system including main memory device having heterogeneous memories, and data management method thereof
CN115373957A (zh) * 2021-05-21 2022-11-22 荣耀终端有限公司 杀应用的方法及设备
CN113590309B (zh) * 2021-06-30 2024-01-23 郑州云海信息技术有限公司 一种数据处理方法、装置、设备及存储介质
WO2023279334A1 (zh) * 2021-07-08 2023-01-12 华为技术有限公司 存储装置、方法及电子设备
CN114844833A (zh) * 2022-03-30 2022-08-02 阿里云计算有限公司 报文处理方法和系统,存储介质及计算机终端
CN116578392B (zh) * 2023-07-11 2023-09-26 天津卓朗昆仑云软件技术有限公司 虚拟机数据交互方法、系统及电子设备
CN116991542B (zh) * 2023-09-26 2024-02-13 苏州元脑智能科技有限公司 一种虚拟机快照方法、系统、电子设备及计算机存储介质
CN117850985A (zh) * 2024-03-07 2024-04-09 济南浪潮数据技术有限公司 一种虚拟机内存资源管理方法、装置、设备及介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150122A (zh) * 2011-12-07 2013-06-12 华为技术有限公司 一种磁盘缓存空间管理方法和装置
CN103777926A (zh) * 2012-10-25 2014-05-07 辉达公司 多线程处理单元中的高效存储器虚拟化
CN104765574A (zh) * 2015-04-23 2015-07-08 成都博元时代软件有限公司 数据云端存储方法

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008070802A2 (en) * 2006-12-06 2008-06-12 Fusion Multisystems, Inc. (Dba Fusion-Io) Apparatus, system, and method for an in-server storage area network
CN101763226B (zh) * 2010-01-19 2012-05-16 北京航空航天大学 一种虚拟存储设备的缓存方法
US8898664B2 (en) 2010-06-01 2014-11-25 Microsoft Corporation Exposure of virtual cache topology to a guest operating system
CN101968746B (zh) * 2010-09-02 2016-03-02 北京航空航天大学 一种内核虚拟机组织架构模式的实现方法
CN102591702B (zh) * 2011-12-31 2015-04-15 华为技术有限公司 虚拟化处理方法及相关装置和计算机系统
US8856443B2 (en) * 2012-03-12 2014-10-07 Infinidat Ltd. Avoiding duplication of data units in a cache memory of a storage system
CN103902348B (zh) * 2012-12-25 2017-07-14 华为技术有限公司 一种虚拟化环境下用户数据的读写方法、系统及物理机
US9842053B2 (en) * 2013-03-15 2017-12-12 Sandisk Technologies Llc Systems and methods for persistent cache logging
CN103593147B (zh) * 2013-11-07 2016-08-17 华为技术有限公司 一种数据读取的方法及装置
US10055136B2 (en) * 2015-07-29 2018-08-21 Red Hat Israel, Ltd. Maintaining guest input/output tables in swappable memory

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150122A (zh) * 2011-12-07 2013-06-12 华为技术有限公司 一种磁盘缓存空间管理方法和装置
CN103777926A (zh) * 2012-10-25 2014-05-07 辉达公司 多线程处理单元中的高效存储器虚拟化
CN104765574A (zh) * 2015-04-23 2015-07-08 成都博元时代软件有限公司 数据云端存储方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3783480A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113010452A (zh) * 2021-03-17 2021-06-22 中国科学技术大学 一种高效且支持QoS的虚拟内存架构
CN113010452B (zh) * 2021-03-17 2023-11-28 中国科学技术大学 一种高效且支持QoS的虚拟内存架构

Also Published As

Publication number Publication date
CN110597451B (zh) 2021-02-23
CN110597451A (zh) 2019-12-20
EP3783480A1 (en) 2021-02-24
EP3783480A4 (en) 2021-08-11
US20210089471A1 (en) 2021-03-25
US11397690B2 (en) 2022-07-26
EP3783480B1 (en) 2024-04-24

Similar Documents

Publication Publication Date Title
WO2019237791A1 (zh) 虚拟化缓存的实现方法及物理机
Kwon et al. Coordinated and efficient huge page management with ingens
JP6709245B2 (ja) 適応持続性システム、方法、インタフェース
US10289555B1 (en) Memory read-ahead using learned memory access patterns
US10552337B2 (en) Memory management and device
US9405476B2 (en) Systems and methods for a file-level cache
US9612966B2 (en) Systems, methods and apparatus for a virtual machine cache
US8996807B2 (en) Systems and methods for a multi-level cache
US9652405B1 (en) Persistence of page access heuristics in a memory centric architecture
US10339056B2 (en) Systems, methods and apparatus for cache transfers
US10534720B2 (en) Application aware memory resource management
US9658957B2 (en) Systems and methods for managing data input/output operations
US10698829B2 (en) Direct host-to-host transfer for local cache in virtualized systems wherein hosting history stores previous hosts that serve as currently-designated host for said data object prior to migration of said data object, and said hosting history is checked during said migration
US9760493B1 (en) System and methods of a CPU-efficient cache replacement algorithm
US20160266923A1 (en) Information processing system and method for controlling information processing system
US20180285276A1 (en) Method and apparatus for persistently caching storage data in a page cache
WO2023066124A1 (zh) 缓存管理方法、缓存管理装置、处理器
JP6653710B2 (ja) 計算機および計算機の制御方法
WO2013023090A2 (en) Systems and methods for a file-level cache
US20200401530A1 (en) Flatflash system for byte granularity accessibility of memory in a unified memory-storage hierarchy
Kwon et al. Ingens: Huge page support for the OS and hypervisor
US20240119006A1 (en) Dual personality memory for autonomous multi-tenant cloud environment
US20230004417A1 (en) Method and apparatus to select assignable device interfaces for virtual device composition
Muhammed Unais P et al. SymFlex: Elastic, Persistent and Symbiotic SSD Caching in Virtualization Environments.
Caldwell FluidMem: Open source full memory disaggregation

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19819486

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2019819486

Country of ref document: EP

Effective date: 20201119

NENP Non-entry into the national phase

Ref country code: DE