Data sharing method and system, and device and storage medium

By allocating shared memory windows to virtual machines in a cloud computing environment and the target process module uniformly processing write operations, the problem of data consistency and access performance between virtual machines is solved, and efficient data sharing and operations are achieved.

WO2024183559A1PCT designated stage expired Publication Date: 2024-09-12HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD

Patent Information

Application Number
PCT/CN2024/078720
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-03
Filing Date
2024-02-27
Publication Date
2024-09-12

AI Technical Summary

Technical Problem

In cloud computing scenarios, when data is shared between virtual machines, how to ensure data consistency and improve data access performance at the same time. In the existing technology, access performance is poor due to dispersed data storage and synchronization operations.

Method used

Allocate shared memory windows to multiple virtual machines on the same host, store shared data between virtual machines through local shared memory windows, achieve local access, shorten access paths, and uniformly process write operations through the target process module to avoid data errors , ensuring data consistency without network synchronization.

Benefits of technology

It improves the access performance and consistency of shared data between virtual machines and reduces the latency of subsequent operations. Especially in the case of file metadata, it improves the efficiency and speed of file operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024078720_12092024_PF_FP_ABST
    Figure CN2024078720_12092024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present application are a data sharing method and system, and a device and a storage medium. In the embodiments of the present application, a shared memory window is allocated on a host to virtual machines, which have a data sharing relationship, and shared data of a plurality of virtual machines is stored by means of a local shared memory window, so as to realize local access to the shared data, thereby shortening an access path of the shared data, and improving the access performance of the shared data. In addition, the shared memory window is readable but non-writable to the virtual machines, a target process module is additionally provided on the host, and the target process module is uniformly responsible for the writing-in of the shared data, such that the problem of a possible data error caused by the plurality of virtual machines performing a write operation on the shared memory window at the same time can be avoided. Moreover, any modification to the shared data can be immediately observed by each virtual machine, such that the virtual machines can achieve consistency regarding the shared data, without the need for performing synchronization by means of network transmission, thereby further improving the access performance of the shared data.
Need to check novelty before this filing date? Find Prior Art

Description

Data sharing method, device, system and storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 3, 2023, with application number 202310219577.0 and application name “Data Sharing Method, Device, System and Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of cloud storage technology, and in particular to a data sharing method, device, system and storage medium. Background Art

[0003] In cloud computing, data is distributed across different storage nodes to reduce the risk of data loss. This data is managed through a file system to provide reliable and efficient data access. In a file system, data is divided into files and metadata. Metadata is system data that describes files, including access permissions, file owners, and file data distribution information. To operate a file, a user needs to access its metadata to determine the file's location or related attributes and complete the corresponding file operation.

[0004] In cloud computing, virtual machines (VMs) share some data, such as file metadata. This metadata is stored on remote servers, and the VMs need to access it. When a VM modifies the metadata, the modification must be written back to the remote server and then synchronized with other VMs. This ensures metadata consistency but can degrade metadata access performance. Ensuring both consistency and access performance for shared data between VMs is a pressing technical challenge.

[0005] Summary of the Invention

[0006] Multiple aspects of the present application provide a data sharing method, device, system and storage medium for shortening the access path of shared data and improving the access performance of shared data while ensuring the consistency of shared data between VMs.

[0007] In the first aspect, an embodiment of the present application also provides a data sharing method, which is applied to a data sharing system, wherein the data sharing system includes a target process module deployed on the same host and multiple virtual machines having a data sharing relationship, and the method includes: the target process module allocates a shared memory window from the physical space of the host, and the shared memory window is used to store shared data between the multiple virtual machines, and has a read-only attribute for the multiple virtual machines; the multiple virtual machines read the required first shared data from the shared memory window, and perform corresponding operations based on the first shared data; the target process module writes second shared data into the shared memory window, so that the multiple virtual machines can share the second shared data.

[0008] In a second aspect, an embodiment of the present application provides a host on which a target process module and multiple virtual machines having a data sharing relationship are deployed, the host comprising: a memory and a processor; the memory is used to store program codes corresponding to the target process module and the multiple virtual machines; the processor is coupled to the memory and is used to execute the program code corresponding to the target process module, so as to implement the steps in the data sharing method provided in the first aspect of the present application.

[0009] In a third aspect, an embodiment of the present application provides a data sharing system, comprising a target process module and multiple virtual machines having a data sharing relationship deployed on the same host; the target process module is used to implement the steps executed by the target process module in the method provided in the first aspect, and the multiple virtual machines are used to implement the steps executed by the virtual machines in the method provided in the first aspect.

[0010] In a fourth aspect, an embodiment of the present application also provides a file metadata sharing system, comprising: a target process module, a host file system, and multiple virtual machines with a data sharing relationship deployed on the same host, wherein a client file system is deployed in the multiple virtual machines; the target process module is used to allocate a shared memory window from the physical space of the host, and the shared memory window is used to store file metadata shared between the multiple virtual machines, and has a read-only attribute for the multiple virtual machines; the client file system is used to respond to a file metadata read operation initiated by an upper-level application in the virtual machine to which it belongs, read the first file metadata from the shared memory window and return it to the upper-level application; the target process module is also used to respond to a file metadata data write operation initiated by the host file system, write the second file metadata into the shared memory window, so that the multiple virtual machines can share the second file metadata.

[0011] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement the steps in the data sharing method provided in the first aspect of the present application.

[0012] In an embodiment of the present application, for multiple virtual machines deployed on the same host and having a data sharing relationship, a shared memory window is allocated to these virtual machines on the host, and shared data between the multiple virtual machines is stored through the local shared memory window, thereby realizing local access to the shared data, shortening the access path of the shared data, and improving the access performance of the shared data; in addition, the shared memory window has a read-only attribute for these virtual machines, that is, the virtual machine can read but not write to the shared memory window, and a target process module is added to the host, and the writing of the shared data is uniformly responsible by the target process module, which can avoid data errors that may be caused by multiple virtual machines performing write operations on the shared memory window at the same time, and based on the shared memory window, any modification of the shared data can be immediately observed by each virtual machine, so that the consistency of the shared data can be achieved for each virtual machine, and the consistency of the shared data does not need to be synchronized between different VMs through network transmission, which can further improve the access performance of the shared data. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0014] FIG1 is a schematic diagram of the structure of a data sharing system provided in an embodiment of the present application;

[0015] FIG2 is a schematic diagram showing how a shared memory window provided in an embodiment of the present application is divided into multiple memory areas;

[0016] FIG3 is a schematic diagram showing a memory area divided into multiple slot groups and how the slots are used according to an embodiment of the present application;

[0017] FIG4 is a schematic diagram of a usage of a memory area including slot groups, slots, and a bitmap area provided in an embodiment of the present application;

[0018] FIG5 is a schematic diagram of the structure of a data sharing system for file metadata provided by an embodiment of the present application;

[0019] FIG6 is a flow chart of a data sharing method provided in an embodiment of the present application;

[0020] FIG7 a is a flow chart of another data sharing method provided in an embodiment of the present application;

[0021] FIG7 b is a flow chart of another data sharing method provided in an embodiment of the present application;

[0022] FIG8 is a schematic structural diagram of a data sharing device provided in an embodiment of the present application;

[0023] FIG9 is a schematic structural diagram of another data sharing device provided in an embodiment of the present application;

[0024] FIG10 is a schematic structural diagram of a host provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0026] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0027] In cloud computing scenarios, cloud service providers provide tenants with various cloud computing resources. Tenants can purchase or deploy their own virtual machines (VMs) on these resources. These VMs host their own applications or services. The data generated by these applications or services during operation is stored in different storage nodes. From the perspective of VMs, data sharing may be necessary. However, the existing data is scattered across different storage nodes, resulting in long access paths to shared data. Furthermore, to ensure data consistency, shared data must be synchronized between VMs, resulting in poor access performance. Cloud computing scenarios present the technical challenge of balancing access performance and consistency for shared data.

[0028] In response to the above technical problems, in an embodiment of the present application, a solution is provided based on the host. For multiple virtual machines deployed on the same host with a data sharing relationship, a shared memory window is allocated to these virtual machines on the host. The shared data between the multiple virtual machines is stored through the local shared memory window, thereby realizing local access to the shared data, shortening the access path of the shared data, and improving the access performance of the shared data. At the same time, the shared memory window has a read-only attribute for these virtual machines, that is, the virtual machine can read but not write to the shared memory window, and a target process module is added to the host. The writing of the shared data is uniformly responsible by the target process module, which can avoid data errors that may be caused by multiple virtual machines performing write operations on the shared memory window at the same time. Moreover, based on the shared memory window, any modification of the shared data can be immediately observed by each virtual machine, and the consistency of the shared data can be achieved for each virtual machine. Moreover, the consistency of the shared data does not need to be synchronized between different VMs through network transmission, which can further improve the access performance of the shared data.

[0029] Furthermore, by improving the access performance of shared data, the efficiency of subsequent operations based on the shared data can be improved, and the latency of subsequent operations can be reduced. In particular, when the shared data is file metadata, shortening the access path to the file metadata and increasing the access speed of the file metadata can help improve the efficiency of file operations based on the file metadata and reduce the latency of file operations.

[0030] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.

[0031] Figure 1 is a structural diagram of a data sharing system 100 provided in an embodiment of the present application. As shown in Figure 1, the data sharing system 100 includes: a target process module 11 deployed on the same host 10 and multiple virtual machines 12 with a data sharing relationship. In this embodiment, the host 10 can be one or more. In Figure 1, one host 10 is used as an example for illustration. In the case where there are multiple hosts 10, at least some of the hosts 10 are deployed with the target process module 11 and multiple virtual machines 12 with a data sharing relationship. The embodiment of the present application focuses on the host 10 deployed with the target process module 11 and multiple virtual machines 12 with a data sharing relationship. The host 10 in this embodiment can be any physical device with storage, computing and communication capabilities, for example, it can be a server device such as a traditional server, server array or server cluster, it can also be various terminal devices such as mobile phones, laptops, desktop computers, etc., it can also be various base stations, gateway devices and other network devices.

[0032] In this embodiment, a data sharing relationship between virtual machines 12 refers to the ability to share data between virtual machines 12. Simply put, virtual machines 12 can use the same data. This data shared by virtual machines 12 is referred to as shared data. From the perspective of the data sharing relationship, virtual machines 12 in a data sharing relationship may be distributed on the same host 10 or on different hosts 10, without limitation. This embodiment focuses on the data sharing process between virtual machines in a data sharing relationship deployed on the same host 10 and does not focus on the data sharing process between virtual machines across hosts. For example, virtual machines across hosts can use the standard Message Passing Interface (MPI) communication mechanism to perform data operations between each other through message passing or remote memory access. Whether a data sharing relationship is formed between virtual machines 12 deployed on the same host 10 can be flexibly determined based on application requirements. In some application scenarios, the same tenant can deploy multiple virtual machines that provide the same service. In this case, a data sharing relationship is formed between multiple virtual machines 12 deployed on the same host 10 and belonging to the same tenant. Of course, from the tenant's perspective, the virtual machines they deploy can be distributed on different hosts, and these virtual machines distributed on different hosts can also form a data sharing relationship, which is not a concern. In other application scenarios, different tenants may meet user access control policies. For example, the data of tenant A is authorized to another tenant B. In this case, a data sharing relationship can also be formed between virtual machines 12 across tenants.

[0033] In this embodiment, the number of data sharing relationships existing on the host 10 is not limited, nor is the number of virtual machines 12 having a data sharing relationship. The specific number may depend on the physical resources and processing capabilities of the host 10. For example, for the same host 10, one or more groups of virtual machines 12 having a data sharing relationship may exist thereon, and different groups of virtual machines 12 may have different data sharing relationships. For example, multiple virtual machines 12 of a first tenant and multiple virtual machines 12 of a second tenant may exist on the same host 10 at the same time, and each tenant's virtual machine forms a data sharing relationship. The number of virtual machines 12 having the same data sharing relationship may be 2, 3, 5, or 10, etc., and there is no limitation on this. In addition, the number of data sharing relationships existing on different hosts 10 and the number of virtual machines 12 having a data sharing relationship may be the same or different, and there is no limitation on this.

[0034] In this embodiment, as shown in FIG1 , a shared memory window is allocated on the host 10 for multiple virtual machines 12 deployed on the same host 10 and having the same data sharing relationship. The shared memory window is used to store shared data between the multiple virtual machines, thereby achieving local access to the shared data, shortening the access path to the shared data, and improving the access performance of the shared data. Furthermore, a target process module 11 is added to the host 10, and the target process module 11 maintains and manages the shared memory window process. In this embodiment, the target process module 11 can be a process running on the host 10, such as a daemon process, but is not limited thereto. The target process module 11 can allocate shared memory windows from the physical space of the host 10 for the multiple virtual machines 12 having the same data sharing relationship, so as to store the shared data between the multiple virtual machines 12.

[0035] Furthermore, in order to avoid the problem of shared data errors caused by multiple virtual machines 12 writing to the shared memory window at the same time, the read and write properties of the shared memory window are constrained during the shared memory window allocation process. The shared memory window has a read-only property for multiple virtual machines 12, that is, for multiple virtual machines 12, only read operations can be performed on the shared memory window, but no write operations can be performed on the shared memory window. In simple terms, the shared memory window implements the constraint of only reading but not writing for the virtual machine 12. Since the virtual machine cannot write to the shared memory window, the problem of shared data errors caused by multiple virtual machines 12 writing to the shared memory window at the same time is solved.

[0036] However, the shared data between virtual machines 12 changes dynamically. When new shared data is generated, it needs to be written into the shared memory window so that it can be shared among multiple virtual machines. In the embodiment of the present application, the target process module 11 is responsible for writing the shared data into the shared memory window. This ensures that the new shared data can be written into the shared memory window in a timely manner. At the same time, it can also solve the problem of shared data errors caused by multiple virtual machines 12 writing to the shared memory window at the same time.

[0037] Based on the above, for any virtual machine 12, when shared data in the shared memory window is needed, the required shared data can be directly read from the shared memory window, and corresponding operations can be performed based on the read shared data. In addition, when new shared data that needs to be written to the shared memory window is generated between multiple virtual machines, the target process module 11 writes the new shared data into the shared memory window so that multiple virtual machines 12 can share the new shared data. For the convenience of description and distinction, the shared data that the virtual machine 12 needs to read from the shared memory window is recorded as the first shared data. For different virtual machines 12, the first shared data that needs to be read may be different; the shared data that needs to be written into the shared memory window is recorded as the second shared data. Among them, the generating end of the second shared data can provide the second shared data to the target process module 11. For example, the second shared data can be provided to the target process module 11 by, but not limited to, a remote procedure call (RPC) so that the target process module 11 can write the second shared data into the shared memory window. Among them, the generating end of the second shared data will be different depending on the application scenario. Taking the application scenario shown in Figure 5 as an example, the second shared data is specifically the second file metadata, and its corresponding generating end is the host file system.

[0038] It should be noted that in the embodiments of the present application, the order in which the virtual machine 12 reads the first shared data from the shared memory window and the target process module 11 writes the second shared data into the shared memory window is not limited. If the virtual machine 12 needs the first shared data first, it can first read the first shared data from the shared memory window; then, when the second shared data is generated, the target process module 11 writes the second shared data into the shared memory window. The generation of the second shared data may be related to the process or result of performing the corresponding operation based on the first shared data, or it may be unrelated to the process and result of performing the corresponding operation based on the first shared data. If the second shared data is generated first, the target process module 11 first writes the second shared data into the shared memory window; then, when the virtual machine needs the first shared data, it can read the first shared data from the shared memory window; the first shared data may be the second shared data written previously, or it may be other shared data in the shared memory window other than the second shared data. Of course, the virtual machine 12 reading the first shared data from the shared memory window and the target process module 11 writing the second shared data into the shared memory window can also be performed in parallel.

[0039] In addition, depending on the application scenario, the shared data between virtual machines 12 with a data sharing relationship will be different. Accordingly, the scenarios and methods in which the virtual machine 12 requires the first shared data, the scenarios and methods in which the second shared data is generated, and the corresponding operations performed based on the first shared data will also be different, and this is not limited to this. For example, taking the file management scenario in a virtualized environment as an example, the shared data between virtual machines 12 can be file metadata; file metadata is data used to describe the attributes of a file, such as but not limited to the file type, file owner, file size, the time of the file's last modification, etc. Accordingly, when a virtual machine opens, deletes, moves, or renames a file, it requires the file metadata and can initiate a file metadata read operation to request to read the file metadata from the shared memory window. If the file metadata is successfully read, the corresponding file access operation can be performed based on the read file metadata, such as opening, deleting, moving, or renaming the corresponding file. Accordingly, during the process of executing the file access operation, as the file is accessed, the file attribute information will change accordingly, thereby generating new file metadata. Therefore, a file metadata write operation can be initiated, and the target process module 11 perceives the file metadata write operation and writes the new file metadata into the shared memory window.

[0040] Regardless of the application scenario of shared data, in this embodiment, a solution is provided based on the host. For multiple virtual machines deployed on the same host with a data sharing relationship, a shared memory window is allocated to these virtual machines on the host. The shared data between multiple virtual machines is stored through the local shared memory window, thereby realizing local access to the shared data, shortening the access path of the shared data, and improving the access performance of the shared data. At the same time, the shared memory window has a read-only attribute for these virtual machines, that is, the virtual machine can read but not write to the shared memory window, and a target process module is added to the host. The writing of shared data is uniformly responsible by the target process module, which can avoid data errors that may be caused by multiple virtual machines performing write operations on the shared memory window at the same time. Moreover, based on the shared memory window, any modification of the shared data can be immediately observed by each virtual machine, and the consistency of the shared data can be achieved for each virtual machine. Moreover, the consistency of the shared data does not need to be synchronized between different VMs through network transmission, which can further improve the access performance of the shared data.

[0041] In the embodiment of the present application, the target process module 11 is not limited to the implementation method of allocating shared memory windows to multiple virtual machines 12 having a data sharing relationship. In this embodiment, the allocation of a shared memory window includes the application and exposure of a shared memory window. Regarding the application of a shared memory window: the target process module 11 can call a memory allocation command to apply for a shared memory window from the operating system (OS) of the host 10. For example, as a normally running process, the target process module 11 can respond to the instruction to start the virtual machine and determine that a shared memory window needs to be applied for these virtual machines with shared data relationships. Then, through some standard kernel access interfaces, such as the Application Programming Interface (API) of the Portable Operating System Interface (POSIX), the target process module 11 accesses the OS of the host 10 and applies for a shared memory window from the relevant unit of the OS. The relevant unit of the OS applies for a shared memory window with a read-only attribute for multiple virtual machines 12 from the physical space of the host 10. In other words, the API interface provided by the OS can set the access rights of the shared memory window to read-only. If a write operation is performed in a shared memory window with read-only access rights, an error will be reported, causing the virtual machine to crash. This error reporting mechanism constrains the virtual machine to read only and not write to the shared memory window. In this embodiment, the size of the shared memory window is not limited and can be a fixed size or the size of the shared memory window can be determined by the target process module 11.

[0042] Regarding the exposure of the shared memory window: A virtualization management module (not shown in FIG1 ) is also deployed on the host 10 to provide virtualization services for multiple virtual machines 12. The virtualization management module is responsible for creating the virtual machines 12. During the creation of the virtual machines 12, the module virtualizes the hardware resources required for the virtual machines 12 and reserves a certain amount of physical address space. This physical address space is mounted on the virtual machine as a Peripheral Component Interconnect (PCI) device. To facilitate access to this physical address space by the virtual machine after startup, a base address register (BAR) is added to the PCI device configuration space, and the address of this physical address space is set in the BAR. In this embodiment, the reserved physical address space is used for the virtual machines to cache shared data. In this embodiment, when the target process module 11 applies for a shared memory window, it also provides the physical address of the shared memory window to the virtual machine management module. When multiple virtual machines are started, the virtualization management module maps the physical address space reserved by each of the multiple virtual machines into a shared memory window based on the physical address of the shared memory window, so that the virtual machines can directly access the shared memory window and then read the required first shared data from the shared memory window, thereby completing the exposure of the shared memory window. Furthermore, a small space is reserved in the header area of ​​the reserved physical address space to store description information of the shared memory window. The description information is used to describe which shared data is stored in the shared memory window and the position offset of the shared data in the shared memory window. For example, the address offsets D1 to D2 in the shared memory window are readable shared data, so that the virtual machine can read the corresponding shared data from the shared memory window, and D1 and D2 represent the address offsets in the shared memory window.

[0043] Taking the example of the shared data being the file metadata mentioned below, where the file metadata includes inode data, inode victim cache data, and directory entry data, the description information of the shared memory window may include that the address offsets from A1 (e.g., 0x0000 0000 0000 0000) to A3 (e.g., 0x0000 0000 3F00 0000) in the shared memory window are the inode data, the address offsets from B1 to B3 are the inode victim cache data, and the address offsets from C1 to C3 are the directory entry data. Furthermore, in the case where the inode data includes a slot group and a bitmap area, the above description information may also specifically include that the address offsets from A1 to A2 in the shared memory window are the readable data in the inode data, the address offsets from A2 to A3 are the bitmap area in the inode data, and the same applies to the inode victim and dentry. A1, A2, A3, B1, B3, C1, and C3 represent address offsets in the shared memory space. For example, 0x0000 0000 0000 0000 and 0x0000 0000 3F00 0000 are address offsets represented by hexadecimal, 64-bit integers and are examples of address offsets A1 and A2. For descriptions of various file metadata, slot groups, and bitmap areas, see the following embodiments and are not described in detail here.

[0044] In the embodiments of the present application, the implementation of the virtualization management module is not limited. For example, it can be, but is not limited to, a virtual machine monitor (hypervisor) or a combination of a Quick Emulator (QEMU) and a Kernel-based Virtual Machine (KVM) in the hypervisor. QEMU is responsible for virtual machine creation and related operations, while KVM is responsible for mapping the reserved physical address space to the shared memory window.

[0045] In this embodiment, the usage of the shared memory window is not limited. In an optional embodiment, the shared data between multiple virtual machines in a data-sharing relationship may be of various types. Based on this, the shared memory window can be divided into multiple memory areas according to the type of shared data, with different memory areas being used to store different types of shared data. Figure 2 shows a schematic diagram of a shared memory window divided into multiple memory areas. Taking the shared data as file metadata as an example, assuming that the file metadata includes three types of metadata: index node data, index node victim cache data, and directory entry data, the shared memory window can be divided into three memory areas, denoted as memory area A, memory area B, and memory area C, as shown in Figure 2. Memory area A is used to store index node data, memory area B is used to store index node victim cache data, and memory area C is used to store directory entry data. The index node data is a data structure that represents the corresponding file status. The index node data records the file name, file version number, file size, file access permissions, file disk location, creation / modification time, and whether it is a file or directory. The index node data is indexed by the index node number (inode number). Directory entry data is a kernel data structure that is responsible for mapping file names to corresponding inode numbers. Directory entry data records the correspondence between file names and inode numbers, as well as the inode number of the previous level (referred to as the parent inode number). Based on directory entry data, file operations can be based on the inode number of the file, rather than relying on the file's storage path. The victim cache data of an index node refers to the data stored in the victim cache. The victim cache is a relatively small cache space used to store replaced index node data when the index node data must be replaced from its memory area. In this way, the virtual machine can check whether the latest version of the file data is cached locally through the victim cache data of the index node and the index node data in the memory area.

[0046] When a shared memory window is divided into multiple memory regions, and a virtual machine needs to read first shared data from the shared memory window, it can determine, based on a shared data read request, descriptive information corresponding to the first shared data, the descriptive information including the type and identification information of the first shared data; determine, based on the type of the first shared data, a first memory region that matches the type of the first shared data from the multiple memory regions; and read the first shared data from the first memory region based on the identification information of the first shared data. Depending on the type of the first shared data, the first memory region may also vary. For example, if the first shared data is index node data, the type of the first shared data refers to index node data, not directory entry data or index node victim cache data. The identification information of the first shared data is the inode number in the index node data. Accordingly, the first memory region is memory region A shown in FIG2 . For example, if the first shared data is index node victim cache data, the type of the first shared data refers to index node victim cache data, not directory entry data or index node data. The identification information of the first shared data is the inode number in the index node victim cache data. Accordingly, the first memory region is memory region C shown in FIG2 . Taking the example of the first shared data being directory entry data, the type of the first shared data refers to directory entry data, not index node data or index node sacrifice cache data. The identification information of the first shared data is the inode number in the directory entry data. Accordingly, the first memory area is the memory area B shown in Figure 2.

[0047] Accordingly, when the shared memory window is divided into multiple memory areas, when the target process module 11 writes the second shared data into the shared memory window, it can determine, based on the shared data write request, the descriptive information corresponding to the second shared data, the descriptive information including the type and identification information of the second shared data; determine, based on the type of the second shared data, a second memory area that matches the type of the second shared data from the multiple memory areas; write the second shared data into the second memory area, and read the second shared data. Depending on the type of the second shared data, the second memory area will also vary. For example, if the second shared data is index node data, the type of the second shared data refers to index node data, not directory entry data or index node victim cache data. The identification information of the second shared data is the inode number in the index node data. Accordingly, the second memory area is memory area A shown in FIG2 . For example, if the second shared data is index node victim cache data, the type of the second shared data refers to index node victim cache data, not directory entry data or index node data. The identification information of the second shared data is the inode number in the index node victim cache data. Accordingly, the second memory area is memory area C shown in FIG2 . Taking the second shared data as directory entry data as an example, the type of the second shared data refers to directory entry data, not index node data or index node sacrifice cache data. The identification information of the second shared data is the inode number in the directory entry data. Accordingly, the second memory area is the memory area B shown in Figure 2.

[0048] Further optionally, this embodiment does not limit the size of multiple memory areas and the size relationship between them. Taking memory area A, memory area B, and memory area C shown in Figure 2 as an example, considering that the index node data is relatively large, the size of memory area A can be configured to be, for example, 140 bytes, the size of memory area B can be configured to be, for example, 15 bytes, the size of memory area C can be configured to be, for example, 50 bytes, and so on. Considering that the size of each memory area is limited and that as shared data is continuously generated, the memory area will overflow, this embodiment allows the shared data in each memory area to be replaced.

[0049] Further optionally, when the target process module 11 performs a write operation in each memory area, in order to improve write efficiency, multithreading can be used to perform parallel writes on the same memory area. However, in the case of parallel writes, errors will occur if the same location is written at the same time. In order to avoid errors in parallel writes, in this embodiment, each memory area is further divided into multiple slot groups (slot sets), different shared data is stored in different slot groups, and parallel writes are allowed between different slot groups. That is, write operations can be performed on multiple slot groups at the same time. Since write operations are performed in different slot groups, write errors caused by writing to the same location at the same time can be avoided. Further, each slot group includes multiple slots (slots), and each slot is a small piece of storage space in the memory area for storing a shared data of the corresponding type of the memory area to which it belongs. In this embodiment, the number of slot groups included in the memory area is not limited, nor is the number of slots included in the slot group limited. It can be flexibly determined according to application requirements. As shown in FIG3 , taking any memory area as an example, it is divided into multiple slot groups, namely set_0 to set_N. Each slot group includes 4 slots, and N is a natural number greater than or equal to 1.

[0050] In this embodiment, when a memory region is divided into multiple slot groups, a hashing approach can be used to distribute shared data in the memory region to different slot groups. Furthermore, a hash calculation can be performed on the identification information of each shared data item, and shared data with the same hash result can be stored in the same slot group. A mapping relationship between the slot groups and the hash results can be established. Based on this, when a virtual machine needs to read first shared data from a shared memory window, it can determine the first slot storing the first shared data from the shared memory window and read the first shared data from the first slot. The first slot is a slot in any slot group within the first memory region, and the first memory region is a memory region that matches the type of the first shared data. Specifically, based on a shared data read request, description information corresponding to the first shared data can be determined, the description information including the type and identification information of the first shared data. Based on the type of the first shared data, the first memory region can be determined from multiple memory regions. Then, based on the hash result of the identification information of the first shared data, the first slot group to which the first shared data belongs in the first memory region can be determined. Based on the identification information of the shared data stored in each slot in the first slot group, the first slot where the first shared data is located can be determined from the first slot group. Specifically, the identification information of the first shared data may be compared with the identification information of the shared data stored in each slot in the first slot group, thereby determining the first slot where the first shared data is located.

[0051] Accordingly, when the target process module 11 writes the second shared data to the shared memory window, it can determine the second slot for storing the second shared data from the shared memory window; and write the second shared data into the second slot. The second slot is a slot in any slot group in the second memory area, and the second memory area is a memory area adapted to the type of the second shared data. Specifically, the description information corresponding to the second shared data can be determined according to the shared data write request, and the description information includes the type and identification information of the second shared data; according to the type of the second shared data, the second memory area adapted to the type of the second shared data can be determined from multiple memory areas; according to the hash result of the identification information of the second shared data, the second slot group to which the second shared data belongs in the second memory area is determined; according to the access information of each slot in the second slot group, the second slot for storing the second shared data is determined from the second slot group. Preferably, an idle slot can be selected from the second slot group as the second slot to store the second shared data; when all the slots in the second slot group are occupied, the target process module 11 can replace the shared data in a certain slot according to a certain old data replacement (Evicting older version) method to achieve slot recycling, and use the recycled slot as the second slot to store the second shared data.

[0052] In this embodiment, the old data replacement method adopted by the target process module 11 is not limited. For example, the access frequency and access time of the shared data on each slot can be recorded, and the least recently accessed replacement method can be adopted to replace the shared data with the least recently accessed data; or, the storage time of the shared data on each slot can be counted, and the shared data with the earliest storage time can be replaced. In addition, the embodiment of the present application provides a simple and efficient old data replacement method to achieve slot recycling, which can be called clock algorithm reclaiming slots. As shown in Figure 4, in addition to including multiple slot groups, each memory area also includes a bitmap area. The bitmap area includes bit groups corresponding to each slot group in the memory area to which it belongs. Each bit group is used to record access information of whether each slot in the corresponding slot group has been accessed. One bit corresponds to one slot, and each bit is a small storage space in a shared memory window. In this embodiment, each bit can take two values, denoted as a first value and a second value. The first value indicates that the slot corresponding to the bit has been accessed, that is, the slot has been written with shared data (i.e., occupied). The second value indicates that the slot corresponding to the bit has not been accessed or can be replaced, that is, the slot has not yet been written with shared data (i.e., is in an idle state). In this embodiment, the values ​​of the first value and the second value are not limited. As shown in FIG4 , the first value can be 1 and the second value can be 0. That is, the slot corresponding to the bit with a value of 1 is occupied, and the slot corresponding to the bit with a value of 0 is not accessed or can be replaced.

[0053] Based on the above, when the second slot group is determined, the target process module 11 can traverse the access information of each slot recorded in the bit group corresponding to the second slot group. For each bit position traversed, if the value of the bit position is the first value, the bit position is set to the second value to indicate that the shared data in the slot corresponding to the bit position can be replaced when the bit position is traversed again, and continue to traverse subsequent bits until the target bit position with the second value is traversed for the first time, and the slot corresponding to the target bit position is used as the second slot for storing the second shared data. In a special case, all slots in the second slot group have been accessed. At this time, the value of each bit in the bit group corresponding to the second slot group is the first value, such as 1. In this case, it is necessary to traverse from the beginning to the last bit position, and then start traversing again from the beginning. Since the value of each bit position has been set to the second value, such as 0, during the previous traversal, the shared data in the first slot can be replaced. At this time, the first slot can be used as the second slot to store the second shared data.

[0054] In the embodiments of the present application, the method of storing shared data in the shared memory window is not limited. Any method that can successfully store shared data is applicable to the embodiments of the present application. In an optional embodiment, in order to facilitate simultaneous read and write operations on the same data in the shared memory window, the following structure is used when storing shared data in the shared memory window:

[0055] For each shared data, two data storage units and one version number storage unit are allocated. The two data storage units are used to store the same shared data, and the version number storage unit is used to store a temporary version number. The temporary version number has parity (even / odd), and the parity of the temporary version number is used to identify the data storage unit of the two data storage units that is currently valid for read operations and write operations, respectively. When shared data needs to be read from the shared memory window, it needs to be read from the "data storage unit valid for read operations", and when shared data needs to be written to the shared memory window, it needs to be written to the "data storage unit valid for write operations" to support simultaneous read and write operations on the same shared data. In addition, the parity of the temporary version number can change as write operations occur in the slot to ensure that the most recently written shared data can be valid for read operations after each write operation is completed, so that the virtual machine can read the most recent shared data.

[0056] When a virtual machine reads first shared data from a shared memory window, it can first determine a storage location where the first shared data is stored, which includes two data storage units and a version number storage unit; read a temporary version number from the version number storage unit, and determine the first data storage unit of the two data storage units contained in the storage location that is effective for the read operation based on the parity of the read temporary version number; read the intermediate shared data from the first data storage unit, and after the reading is completed, compare the read temporary version number with the temporary version number in the version number storage unit contained in the storage location; if the two are the same, use the intermediate shared data as the first shared data; if the two are inconsistent, re-execute the operation of reading the first shared data from the first slot according to the above steps. Accordingly, when the target process module writes the second shared data to the shared memory, it can first determine the storage location for storing the second shared data, which includes two data storage units and a version number storage unit; read the temporary version number from the version number storage unit, and determine the second data storage unit that is effective for the write operation among the two data storage units contained in the storage location based on the parity of the read temporary version number; write the second shared data to the second data storage unit, and after the writing is completed, change the parity of the temporary version number to change the second data storage unit to be effective for the read operation. In the embodiment of the present application, the value of the temporary version number is not the focus, but its parity is the focus.

[0057] It is explained here that the method of storing shared data using two data storage units and one version number storage unit may not rely on the division of the shared memory window, and the storage location storing the first shared data or the storage location for storing the second shared data may be determined by traversal or polling, etc., without limitation. In a preferred embodiment, the method of storing shared data using two data storage units and one version number storage unit may be combined with the slots divided by the shared memory window. In this combination, each slot includes two data storage units and one version number storage unit, the two data storage units are used to store the same shared data, and the version number storage unit is used to store a temporary version number, the temporary version number having parity, and the parity of the temporary version number is used to identify the data storage unit of the two data storage units that is currently effective for read operations and write operations, respectively.

[0058] Based on the above, when the virtual machine reads the first shared data from the shared memory window, it can determine the first slot in the manner described above; then read the first shared data from the first slot in the following manner, specifically: read the temporary version number from the first slot, and determine the first data storage unit of the two data storage units contained in the first slot that is effective for the read operation based on the parity of the read temporary version number; read the intermediate shared data from the first data storage unit, and after the reading is completed, compare the read temporary version number with the temporary version number in the first slot; if the two are the same, it means that the target process module 11 has not modified the first shared data during the reading of the first shared data, so the intermediate shared data can be used as the first shared data; if the two are inconsistent, it means that the target process module 11 has modified the first shared data during the reading of the first shared data, and the read intermediate shared data is not the latest version of the data, so it is necessary to re-execute the operation of reading the first shared data from the first slot according to the previous steps.

[0059] Accordingly, when the target process module writes the second shared data into the shared memory, the second slot can be determined in the manner described above; then the second shared data can be written into the second slot in the following manner, specifically: based on the parity of the temporary version number in the second slot, the second data storage unit that is effective for write operations among the two data storage units contained in the second slot is determined; the second shared data is written into the second data storage unit, and after the writing is completed, the parity of the temporary version number is changed to change the second data storage unit to be effective for read operations.

[0060] In this embodiment, the method for changing the parity of the temporary version number is not limited. In an optional embodiment, after each write is completed, the temporary version number can be increased by 1, thereby continuously changing the parity of the temporary version number. In another optional embodiment, two values ​​can be pre-set, one odd number, such as 1, and one even number, such as 2. Then, after each write is completed, the temporary version number is switched between these two values, thereby continuously changing the parity of the temporary version number.

[0061] In addition, in this embodiment, the correspondence between "the parity of the temporary version number" and "the effectiveness of the two data storage units for write operations and for read operations" is not limited. For the convenience of description, the two data storage units are recorded as data storage unit D1 and data storage unit D2. In an optional embodiment, when the temporary version number is an odd number, it means that the shared data in the data storage unit D1 is effective for write operations, and the shared data in the data storage unit D2 is effective for read operations; then when the temporary version number becomes an even number, it means that the shared data in the data storage unit D1 is effective for read operations, and the shared data in the data storage unit D2 is effective for write operations. Alternatively, in another optional embodiment, when the temporary version number is an even number, it means that the shared data in the data storage unit D1 is effective for write operations, and the shared data in the data storage unit D2 is effective for read operations; then when the temporary version number becomes an odd number, it means that the shared data in the data storage unit D1 is effective for read operations, and the shared data in the data storage unit D2 is effective for write operations.

[0062] In each embodiment of the present application, the specific implementation method of sharing data between virtual machines 12 is not limited. In some application scenarios, the virtual machine 12 can be used as a user of shared data to share data between these virtual machines 12; in other application scenarios, upper-layer applications can be deployed in the operating environment provided by the virtual machine 12, and these upper-layer applications deployed in the virtual machine 12 can be used as users of shared data to share data between these upper-layer applications. In the scenario of sharing data between upper-layer applications deployed in the virtual machine 12, as shown in Figure 1, in addition to the upper-layer applications deployed in the virtual machine 12, it also includes a data sharing management module 121. The data sharing management module 121 is responsible for responding to shared data read requests initiated by the upper-layer applications deployed in the virtual machine 12, reading the first shared data from the shared memory window, and performing corresponding operations based on the first shared data. In an optional embodiment, the data sharing management module 121 performs corresponding operations based on the first shared data, specifically: returning the first shared data to the upper-layer application so that the upper-layer application can process the first shared data or perform subsequent operations based on the first shared data. In this embodiment, the implementation method of the upper layer application is not limited, and it may be, for example, various video applications, email applications, instant messaging applications, image processing applications, etc.

[0063] The data sharing solution provided in the embodiment of the present application is applicable to various application scenarios. The following takes file metadata sharing in a cloud computing scenario as an example to describe the technical solution of the embodiment of the present application in detail.

[0064] FIG5 is a schematic diagram of the structure of a file metadata sharing system 200 provided in an embodiment of the present application. System 200 includes a target process module 21 deployed on a single host 20, a host file system 22, and multiple virtual machines 23 sharing data. Each of these virtual machines 23 includes a guest file system 24. FIG5 illustrates multiple hosts 20 as an example. For details regarding the data sharing relationships between virtual machines 23, please refer to the description of the embodiment shown in FIG1 and will not be repeated here.

[0065] In this embodiment, the virtual machine 23 serves as an operating environment that can host various upper-layer applications of the tenant. These upper-layer applications will generate data during operation and will also access data generated by other upper-layer applications or other data. In this embodiment, various data are organized and managed in the form of a file system. A file system is deployed in the virtual machine 23, which is recorded as the client file system 24. Correspondingly, the host 20 has its own file system, which is recorded as the host file system 22. The host file system 22 cooperates with the client file system 24 in each virtual machine 23 to provide file-related services for the upper-layer applications in the virtual machine 23, such as creating files, deleting files, opening files, reading files, renaming files, etc. Further, as shown in Figure 5, the file metadata sharing system 200 also includes: multiple storage nodes 25, which are distributed in different locations and are responsible for each file in the storage system 200.

[0066] When an upper-layer application in virtual machine 23 needs to access a file, it can initiate a file access operation to client file system 24. Client file system 24 obtains the corresponding file metadata and, based on the obtained file metadata, initiates a file access request to host file system 22. Host file system 25 then performs file access operations on the corresponding storage node 25 based on the file metadata provided by client file system 24, such as creating, deleting, opening, reading, and renaming a file. File metadata includes relevant information required to perform file access operations, such as the file name, the file's location on disk, and the file type. A description of file metadata can be found in the above embodiments and will not be repeated here.

[0067] In this embodiment, file metadata is shared between virtual machines 23 having a data sharing relationship. In order to shorten the access path of the virtual machine 23 to the file metadata and solve the consistency problem of the file metadata between the virtual machines 23, in this embodiment, taking the same host 20 as a unit, for multiple virtual machines 12 deployed on the same host 20 that need to share file metadata, a shared memory window is allocated to these virtual machines 23 on the host 20, and the shared file metadata between the multiple virtual machines 23 is stored through the local shared memory window, thereby realizing local access to the file metadata, shortening the access path to the file metadata, and improving the access performance of the file metadata.

[0068] In this embodiment, to allocate shared memory windows for virtual machines 23, a target process module 21 is deployed on host 20. Target process module 21 can be a daemon process on host 20, configured to allocate shared memory windows for multiple virtual machines 23 from the physical space of host 20. The shared memory windows are used to store file metadata shared between multiple virtual machines 23. These shared memory windows are visible to all virtual machines 23 and have read-only properties for them. Of course, the shared memory windows are readable and writable by target process module 21.

[0069] When an upper-layer application in any virtual machine 23 needs to perform a file access operation, it can initiate a file metadata read operation to the client file system 24 in the virtual machine 23 where it is located. The client file system 24 responds to the file metadata read operation initiated by the upper-layer application in the virtual machine 23 to which it belongs, reads the first file metadata from the shared memory window and returns it to the upper-layer application, so that the upper-layer application can perform the file access operation through the host file system 22 based on the first file metadata. The first file metadata refers to the file metadata that needs to be read from the shared memory window, which can be any file metadata. It is explained here that when the upper-layer application needs to query relevant file metadata, it can also initiate a file metadata read operation to the client file system 24 in the virtual machine 23 where it is located, and it is not limited to performing file access operations. Among them, the file metadata read operation can be, but is not limited to: a request to obtain a file attribute value, a request to find a file directory, and a request to open a file. For the upper-layer applications in the virtual machine, the shared memory window is transparent. For example, when the upper-layer application initiates a request to obtain file attribute values, search for file directories, or open files, the upper-layer application is unaware of the client file system 24 performing file metadata-related read operations from the shared memory window. To the upper-layer application, it is as if these operations are completed in the kernel of the virtual machine.

[0070] During the execution of a file access operation, the metadata of the accessed file may change. For example, when the name of a file is modified, the file name in the file metadata will change. For another example, when a file is modified, the most recent modification time of the file in the file metadata will change. These changes will generate new file metadata. In order for each virtual machine 23 to perceive the latest file metadata, the new file metadata needs to be written into the shared memory window. For ease of description, the newly generated file metadata is referred to as second file metadata. In this embodiment, during the execution of a file access operation, the host file system 22 can determine whether to generate new second file metadata based on the result of the file access operation. If it is determined that the second file metadata is to be generated, the second file metadata is generated based on the result of the execution of the file access operation and a file metadata write operation is initiated to the target process module 21; the target process module 21 responds to the file metadata data write operation initiated by the host file system 22 and writes the second file metadata into the shared memory window so that multiple virtual machines can share the second file metadata. Among them, the host file system 22 can provide the second file metadata to the target process module 21. Optionally, the second file metadata can be provided to the target process module 21 by means of, but not limited to: remote procedure call (RPC), so that the target process module 21 can write the second file metadata into the shared memory window.

[0071] In this embodiment, file metadata services are provided in the client file system 24 and the host file system 22 through the target process module 21 and the shared memory window, so that file metadata is shared across virtual machines on the same host, and short-read and long-write of file metadata are realized. Among them, short-read refers to the virtual machine 23 directly reading the required first file metadata from the shared memory window without going through the target process module 21; long-write refers to the writing of the second file metadata to the shared memory window through the target process module 21, rather than the host file system 22 directly writing to the shared memory window. Among them, the long-write method can avoid data errors or security risks caused by multiple virtual machines performing write operations on the shared memory space at the same time. For example, if a virtual machine is attacked, if the virtual machine is still allowed to write file metadata directly to the shared memory window, it may have an adverse effect on other virtual machines due to the malicious writing of the virtual machine. The long-write method provided by this embodiment can solve this problem.

[0072] In this embodiment, the target process module, as a normal process, can access the host file system using an interface supported by the host file system, such as the POSIX API, to ensure compatibility between the target process module and the host file system. Based on this, the target process module can invoke a memory allocation command to instruct the host file system to allocate memory space for it. The target process module then exposes the allocated memory space as a shared memory window to each virtual machine. Specifically, the target process module provides the physical address of the shared memory window to the virtual machine management module. When multiple virtual machines are started, the virtualization management module maps the reserved physical address space of each virtual machine into a shared memory window based on the physical address of the shared memory window, thereby exposing the shared memory window. It should be noted that the reserved physical address space for different virtual machines can be the same or different. In other words, the same shared memory window can be mapped to different private memory addresses (i.e., reserved physical address spaces) for different virtual machines. Furthermore, the reserved physical address space can also include descriptive information about the shared memory window to facilitate virtual machine 23 reading file metadata from the shared memory window based on this descriptive information. For details about the descriptive information of the shared memory window, please refer to the previous embodiment and will not be repeated here.

[0073] In an optional embodiment, after being allocated to the shared memory window, the target process module may perform a zeroing operation on the shared memory window to provide a basis for subsequently writing file metadata into the shared memory window.

[0074] In this embodiment, the shared memory window is managed and maintained from the following dimensions, as shown below:

[0075] 1. Shared data layout:

[0076] In this section, based on the type of file metadata, assuming that file metadata includes three types of metadata: inode data, inode victim cache data, and directory entry data, the shared memory window can be divided into three memory areas, such as memory area A, memory area B, and memory area C shown in Figure 2. Memory area A is used to store inode data, memory area B is used to store inode victim cache data, and memory area C is used to store directory entry data. For a detailed description of the three types of file metadata, please refer to the aforementioned embodiment and will not be repeated here.

[0077] In this embodiment, a storage structure for storing file metadata in a memory area is provided, that is, for each file metadata, two data storage units and one version number storage unit are used to store it, the two data storage units are used to store the same file metadata, the version number storage unit is used to store a temporary version number, the temporary version number has parity (even / odd), and the parity of the temporary version number is used to identify the data storage unit of the two data storage units that is currently effective for read operations and write operations, respectively.

[0078] This embodiment also exemplifies the data structures of index node data, victim cache data, and directory entry data, as well as the storage structure of each type of data when stored in the memory area. Schematic definitions of these data structures and storage structures are as follows:

[0079] It should be noted that in the definitions of the above-mentioned storage structures, the temporary version number ver_ is different from the file version number f_ver, the parity of the temporary version number is meaningful, and the initial value of the temporary version number can be different in each storage structure. In addition, to facilitate the maintenance of these data structures, each data structure is padded to align with the size of the cache line. If the size of the file metadata is smaller than the cache line size, it is aligned to a power of 2, which is conducive to improving the read and write speed when reading the file metadata from the shared memory window. In addition, whether reading file metadata from the shared memory window or writing file metadata from the shared memory window, the data structure of each file metadata and the storage structure of each file metadata in the memory area are followed.

[0080] 2. Division of shared memory windows:

[0081] To fully utilize the memory space of the shared memory window, the memory areas AB shown in Figure 2 are divided into a series of slot sets. Each slot set includes multiple slots for storing different file metadata, which serve as elements within the slots. Each element can be identified by its hash fingerprint. For example, for two types of file metadata, index node data and index node victim cache data, their inode numbers can be hashed and mapped to the corresponding slot set based on the hash result. For directory entry data, their parent inode number and file name can be hashed together and mapped to the corresponding slot set based on the hash result. An example of slot sets and slots can be seen in Figure 3.

[0082] 3. Accessing the metadata:

[0083] In this embodiment, file metadata in a shared memory window has atomic update capabilities. Therefore, multiple client file systems can simultaneously retrieve required file metadata from the shared memory window in a non-blocking manner. This section describes the file metadata reading and writing process based on the aforementioned file metadata data structure, its storage structure in the memory area, and the aforementioned slot groups and slots.

[0084] Read operation of file metadata: According to the file metadata read request, determine the descriptive information corresponding to the first file metadata to be read. For example, if the first file metadata is index node data, its descriptive information may include the inode number; if the first file metadata is the sacrifice cache data of the index node, its descriptive information may include the inode number; if the first file metadata is directory entry data, its descriptive information may include the parent inode number and the file name. Hash the description information corresponding to the first file metadata, and determine the slot group where the first file metadata is located based on the hash result, assuming it is the first slot group; determine the first slot where the first file metadata is located based on the identification information of the shared data stored in each slot in the first slot group; read the temporary version number from the first slot, and determine the first data storage unit of the two data storage units contained in the first slot that is effective for the read operation based on the parity of the read temporary version number; read the intermediate metadata from the first data storage unit, and after the reading is completed, compare the read temporary version number with the temporary version number in the first slot; if the two are the same, it means that the target process module 21 has not modified the first file metadata during the reading of the first file metadata, so the intermediate metadata can be used as the first file metadata; if the two are inconsistent, it means that the target process module 21 has modified the first file metadata during the reading of the first file metadata, and the read intermediate metadata is not the latest version of the data, so it is necessary to re-execute the operation of reading the first file metadata from the first slot according to the previous steps.

[0085] File metadata write operation: Based on the file metadata write request, determine the descriptive information corresponding to the second file metadata to be written. For example, if the second file metadata is index node data, its descriptive information may include the inode number; if the second file metadata is sacrifice cache data of the index node, its descriptive information may include the inode number; if the second file metadata is directory entry data, its descriptive information may include the parent inode number and the file name. Hash the descriptive information corresponding to the second file metadata, and determine the slot group where the second file metadata is located based on the hash result, assuming it is the second slot group; based on the access information of each slot in the second slot group, determine the second slot for storing the second shared data from the second slot group; based on the temporary version number in the second slot, determine the second data storage unit that is effective for write operations among the two data storage units contained in the second slot; write the second shared data to the second data storage unit, and after the write is completed, change the parity of the temporary version number to change the second data storage unit to be effective for read operations.

[0086] 4. Evicting older version:

[0087] As shown in Figure 4, in addition to including multiple slot groups, each memory area also includes a bitmap area. The bitmap area includes bit groups corresponding to each slot group in the memory area to which it belongs. Each bit group is used to record access information of whether each slot in the corresponding slot group has been accessed. One bit corresponds to one slot, and each bit is a small storage space in the shared memory window. Based on this, the slots can be recycled according to the clock algorithm. Based on this, when determining the second slot, the access information of each slot recorded in the bit group corresponding to the second slot group can be traversed. For each bit position traversed, if the value of the bit position is the first value, the bit position is set to the second value to indicate that the file metadata in the slot corresponding to the bit position can be replaced when the bit position is traversed again. The subsequent bits are traversed until the target bit position with the second value is traversed for the first time. The slot corresponding to the target bit position is used as the second slot for storing the second file metadata. The detailed implementation process and description can be found in the aforementioned embodiment and will not be repeated here.

[0088] 5. Serve file requests with shorter metadata paths:

[0089] In this embodiment, the file metadata in the shared memory window is responsible for servicing most non-write requests, including requests to obtain file attribute values, requests to search file directories, and requests to open files. Among them, the request to obtain file attribute values ​​can be implemented by calling the getattr function, the request to search file subdirectories can be implemented by calling the lookup function, and the request to open a file can be implemented by calling the open function. getattr function: used to obtain the attributes of a file, directory, or folder. lookup function: searches for the inode number of the current directory in the parent directory file of the current directory (represented by inode) according to the d_name member of the dentry of the current path. After finding the inode number of the current directory, obtain the index node data corresponding to the inode number according to the inode number, and then bind the directory entry and the inode number to obtain the directory of the file. open function: used to open or create a file. Among them, the getattr function, the lookup function, and the open function are existing functions in traditional file systems and will not be explained in detail.

[0090] Open: Opening a file is a special case requiring all three of the above functions, a combination of operations. The client file system first searches the file path to confirm whether the file exists and reads the file's attributes through the shared memory window to determine whether the user has access rights. The client file system then allocates a file descriptor to the upper-layer application and returns it. The upper-layer application can then use this file descriptor to perform the file open operation.

[0091] Lookup: Indicates that the file path needs to be iterated and the file metadata in the shared memory window needs to be searched. The directory to which the file belongs is determined by checking the file name and parent inode number. If the directory to which the file belongs cannot be found, "Not Found" is returned and a request is sent to the target process module (such as a daemon process) to help retrieve the directory to which the file belongs.

[0092] Getattr: When searching along a file directory, it searches for the index node data under the path in the shared memory window. If the index node data is not found, it helps to retrieve the index node data by sending the request to the target process module (such as a daemon process).

[0093] Based on this, as shown in Figure 5, the system 200 also includes: a master node 26, which is used to store and maintain various file metadata of each file, such as index node data, directory entry data, and sacrifice cache data. The complete file metadata is stored on the master node 26. Optionally, the master node 26 can be a remote server. When the client file system cannot query or retrieve the required file metadata from the shared memory window, it can request the target process module to obtain the required file metadata for it from the master node 26. Based on this, the target process module is also used to: when the first file metadata is not stored in the shared memory window, obtain the first file metadata from the master node 26, write the first metadata into the shared memory window, so that multiple virtual machines can read the first metadata; and when the second file metadata is written into the shared memory window, synchronize the second file metadata to the master node so that the master node saves the second file metadata.

[0094] In this embodiment, for virtual machines on the same host, a shared memory window is allocated to them to cache file metadata that each virtual machine needs to share, and the virtual machine and the target process module can cooperate with each other to achieve local access to the file metadata through short reads and long writes, shortening the access path of the file metadata and improving the access performance of the file metadata. In addition, the shared memory window has a read-only attribute for these virtual machines, that is, the virtual machine can read but not write to the shared memory window. A target process module is added to the host, and the writing of file metadata is uniformly responsible by the target process module, which can avoid data errors that may be caused by multiple virtual machines writing to the shared memory window at the same time. Moreover, based on the shared memory window, any modification of the file metadata can be immediately observed by each virtual machine, so that the consistency of the file metadata can be achieved for each virtual machine, and there is no need for synchronization through network transmission, which can further improve the access performance of the file metadata.

[0095] FIG6 is a flow chart of a data sharing method provided in an embodiment of the present application. The method is applied to a data sharing system, which includes a target process module deployed on the same host and multiple virtual machines with data sharing relationships. A detailed description of the system can be found in the aforementioned embodiment and will not be repeated here. As shown in FIG6 , the method includes:

[0096] 601. The target process module allocates a shared memory window from the physical space of the host, where the shared memory window is used to store shared data between multiple virtual machines deployed on the host and has a read-only attribute for the multiple virtual machines.

[0097] 602. The multiple virtual machines read required first shared data from the shared memory window and perform corresponding operations according to the first shared data.

[0098] 603. The target process module writes the second shared data into the shared memory window, so that the multiple virtual machines can share the second shared data.

[0099] It should be noted that the execution order of step 602 and step 603 is not limited in the embodiment of the present application. The two can be executed sequentially or in parallel, depending on the generation of the second shared data and the situation in which the virtual machine needs the first shared data.

[0100] In an optional embodiment, the target process module allocates a shared memory window from the host's physical space, including: requesting the shared memory window from the host's physical space; and providing the physical address of the shared memory window to the virtual machine management module on the host, so that the virtualization management module can map the physical address space reserved for each of the multiple virtual machines to the shared memory window. Furthermore, the target process module can respond to an instruction to start multiple virtual machines, i.e., request the shared memory window from the host's physical space when the virtual machines are started.

[0101] In an optional embodiment, the shared memory window is divided into multiple memory areas, and different memory areas are used to store different types of shared data; each memory area includes multiple slot groups, each slot group includes multiple slots, and different slots are used to store different shared data.

[0102] Further optionally, each slot includes two data storage units and a version number storage unit, the two data storage units are used to store the same shared data, the version number storage unit is used to store a temporary version number, the parity of the temporary version number is used to identify the data storage unit of the two data storage units that is currently effective for read operations and write operations respectively, and the parity of the temporary version number changes with the occurrence of a write operation in the slot.

[0103] In an optional embodiment, multiple virtual machines read the required first shared data from a shared memory window, including: when the first shared data is needed, determining a first slot storing the first shared data from the shared memory window; reading the first shared data from the first slot; the first slot is a slot in any slot group in a first memory area, and the first memory area is a memory area adapted to the type of the first shared data.

[0104] Further optionally, determining the first slot storing the first shared data from the shared memory window includes: determining first descriptive information corresponding to the first shared data based on a shared data read request, the first descriptive information including the type and identification information of the first shared data; determining the first memory area from multiple memory areas based on the type of the first shared data; determining the first slot group to which the first shared data belongs in the first memory area based on a hash result of the identification information of the first shared data; and determining the first slot where the first shared data is located from the first slot group based on the identification information of the shared data stored on each slot in the first slot group.

[0105] Further optionally, reading the first shared data from the first slot includes: reading a temporary version number from the first slot, and determining the first data storage unit of the two data storage units contained in the first slot that is effective for the read operation based on the parity of the read temporary version number; reading the intermediate shared data from the first data storage unit, and after the reading is completed, comparing the read temporary version number with the temporary version number in the first slot; if the two are the same, using the intermediate shared data as the first shared data; if the two are inconsistent, re-executing the operation of reading the first shared data from the first slot.

[0106] Accordingly, based on the above, the target process module writes the second shared data into the shared memory window, including: when the second shared data is generated between multiple virtual machines, determining a second slot for storing the second shared data from the shared memory window; writing the second shared data into the second slot; the second slot is a slot in any slot group in the second memory area, and the second memory area is a memory area adapted to the type of the second shared data.

[0107] Further optionally, determining a second slot for storing the second shared data from the shared memory window includes: determining second descriptive information corresponding to the second shared data based on a shared data write request, the second descriptive information including the type and identification information of the second shared data; determining a second memory area from multiple memory areas based on the type of the second shared data; determining a second slot group to which the second shared data belongs in the second memory area based on a hash result of the identification information of the second shared data; and determining a second slot for storing the second shared data from the second slot group based on access information of each slot in the second slot group.

[0108] In an optional embodiment, any memory area further includes a bitmap area, the bitmap area including bit groups corresponding to each slot group in the memory area to which it belongs, and one bit group is used to record access information of whether each slot in the corresponding slot group has been accessed. Accordingly, based on the access information of each slot in the second slot group, determining the second slot for storing the second shared data from the second slot group includes: traversing the access information corresponding to each slot recorded in the bit group corresponding to the second slot group, for each traversed bit position, if the value of the bit position is the first value, setting the bit position to the second value, and continuing to traverse subsequent bits until the target bit position with the second value is traversed for the first time, and setting the slot corresponding to the target bit position as the second slot; the first value indicates that the slot corresponding to the bit position has been accessed, and the second value indicates that the slot corresponding to the bit position has not been accessed or can be replaced.

[0109] In an optional embodiment, writing the second shared data into the second slot includes: determining the second data storage unit that is effective for write operations among the two data storage units contained in the second slot based on the parity of the temporary version number in the second slot; writing the second shared data into the second data storage unit, and after the writing is completed, changing the parity of the temporary version number to change the second data storage unit to be effective for read operations.

[0110] Figure 7a is a flow chart of another data sharing method provided in an embodiment of the present application. This method is applied to a data sharing system comprising a target process module deployed on the same host and multiple virtual machines having a data sharing relationship. A detailed description of this system can be found in the aforementioned embodiment and will not be repeated here. The method of this embodiment is described from the perspective of the target process module. As shown in Figure 7a, the method includes:

[0111] 701a. Allocate a shared memory window from the physical space of the host, where the shared memory window is used to store shared data between multiple virtual machines and has a read-only attribute for the multiple virtual machines, so that the multiple virtual machines can read required first shared data from the shared memory window.

[0112] 702a. Write the second shared data into the shared memory window, so that multiple virtual machines can share the second shared data.

[0113] For detailed implementation of step 701a and step 702a, please refer to the corresponding steps in the embodiment shown in FIG6 , which will not be described again here.

[0114] FIG7b is a flow chart of another data sharing method provided in an embodiment of the present application. This method is applied to a data sharing system, which includes a target process module deployed on the same host and multiple virtual machines having a data sharing relationship. A detailed description of this system can be found in the aforementioned embodiment and will not be repeated here. The method of this embodiment is described from the perspective of any virtual machine. As shown in FIG7b , the method includes:

[0115] 701b. Read the required first shared data from the shared memory window; wherein the shared memory window is used to store shared data between multiple virtual machines and has a read-only attribute for multiple virtual machines, and the shared data in the shared memory window is written by the target process module;

[0116] 702b. Perform corresponding operations according to the first shared data.

[0117] The detailed implementation of steps 701b and 702b can be found in the corresponding steps in the embodiment shown in Figure 6 and will not be described in detail here.

[0118] It should be noted that in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel. The sequence numbers of the operations, such as 701a, 702a, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to being different types.

[0119] FIG8 is a schematic diagram of the structure of a data sharing device provided in an embodiment of the present application. The device can be implemented as the target process module in the above embodiment, but is not limited thereto. As shown in FIG8 , the device includes:

[0120] an allocation module 81 for allocating a shared memory window from the physical space of the host, wherein the shared memory window is used to store shared data between multiple virtual machines and has a read-only attribute for the multiple virtual machines so that the multiple virtual machines can read the required first shared data from the shared memory window;

[0121] The writing module 82 is configured to write the second shared data into the shared memory window, so that multiple virtual machines can share the second shared data.

[0122] In an optional embodiment, the allocation module 81 is specifically used to: respond to instructions to start multiple virtual machines, apply for a shared memory window from the physical space of the host; provide the physical address of the shared memory window to the virtual machine management module on the host, so that the virtualization management module can map the physical address space reserved for each of the multiple virtual machines into a shared memory window.

[0123] In an optional embodiment, the shared memory window is divided into multiple memory areas, and different memory areas are used to store different types of shared data; a memory area includes multiple slot groups, a slot group includes multiple slots, and different slots are used to store different shared data.

[0124] Based on the above, the writing module 82 is specifically used to: when second shared data is generated between multiple virtual machines, determine a second slot for storing the second shared data from the shared memory window; write the second shared data into the second slot; the second slot is a slot in any slot group in the second memory area, and the second memory area is a memory area adapted to the type of the second shared data.

[0125] Further optionally, when determining the second slot, the write module 82 is specifically used to: determine the second descriptive information corresponding to the second shared data according to the shared data write request, the second descriptive information including the type and identification information of the second shared data; determine the second memory area from multiple memory areas according to the type of the second shared data; determine the second slot group to which the second shared data belongs in the second memory area according to the hash result of the identification information of the second shared data; and determine the second slot for storing the second shared data from the second slot group according to the access information of each slot in the second slot group.

[0126] In an optional embodiment, any memory region further includes a bitmap region, the bitmap region including bit groups corresponding to each slot group in the memory region to which it belongs, wherein each bit group is used to record access information indicating whether each slot in the corresponding slot group has been accessed. Accordingly, when determining the second slot, the write module 82 is specifically configured to: traverse the access information corresponding to each slot recorded in the bit group corresponding to the second slot group; for a traversed bit position, if the value of the bit position is the first value, set the bit position to the second value; and continue traversing subsequent bits until the target bit position with the second value is first traversed, and set the slot corresponding to the target bit position as the second slot; the first value indicates that the slot corresponding to the bit position has been accessed, and the second value indicates that the slot corresponding to the bit position has not been accessed or can be replaced.

[0127] In an optional embodiment, when the write module 82 writes the second shared data into the second slot, it is specifically used to: determine the second data storage unit that is effective for the write operation among the two data storage units contained in the second slot based on the parity of the temporary version number in the second slot; write the second shared data into the second data storage unit, and after the writing is completed, change the parity of the temporary version number to change the second data storage unit to be effective for the read operation.

[0128] FIG9 is a schematic diagram of the structure of another data sharing device provided in an embodiment of the present application. The device can be implemented as a shared data management module or a client file system in the virtual machine in the above embodiment, but is not limited thereto. As shown in FIG9 , the device includes:

[0129] A reading module 91 is used to read the required first shared data from the shared memory window; wherein the shared memory window is used to store shared data between multiple virtual machines and has a read-only attribute for multiple virtual machines, and the shared data in the shared memory window is written by the target process module; an execution module 92 is used to perform corresponding operations according to the first shared data.

[0130] In an optional embodiment, the shared memory window is divided into multiple memory areas, and different memory areas are used to store different types of shared data; a memory area includes multiple slot groups, a slot group includes multiple slots, and different slots are used to store different shared data.

[0131] In an optional embodiment, the reading module 91 is specifically used to: when the first shared data is needed, determine the first slot storing the first shared data from the shared memory window; read the first shared data from the first slot; the first slot is a slot in any slot group in the first memory area, and the first memory area is a memory area adapted to the type of the first shared data.

[0132] Further optionally, when determining the first slot from the shared memory window, the reading module 91 is specifically used to: determine the first description information corresponding to the first shared data according to the shared data read request, the first description information including the type and identification information of the first shared data; determine the first memory area from multiple memory areas according to the type of the first shared data; determine the first slot group to which the first shared data belongs in the first memory area according to the hash result of the identification information of the first shared data; and determine the first slot where the first shared data is located from the first slot group according to the identification information of the shared data stored on each slot in the first slot group.

[0133] Further optionally, when reading the first shared data from the first slot, the reading module 91 is specifically used to: read the temporary version number from the first slot, and determine the first data storage unit of the two data storage units contained in the first slot that is effective for the read operation based on the parity of the read temporary version number; read the intermediate shared data from the first data storage unit, and after the reading is completed, compare the read temporary version number with the temporary version number in the first slot; if the two are the same, use the intermediate shared data as the first shared data; if the two are inconsistent, re-execute the operation of reading the first shared data from the first slot.

[0134] In addition to the above-mentioned data sharing device, an embodiment of the present application also provides a data sharing device, which includes: an allocation module for allocating a shared memory window from the physical space of the host, the shared memory window being used to store shared data between multiple virtual machines and having a read-only attribute for multiple virtual machines; a reading module for reading the required first shared data from the shared memory window; an execution module for performing a corresponding operation based on the first shared data; and a writing module for writing second shared data into the shared memory window so that multiple virtual machines can share the second shared data. For a detailed description of each functional module in this embodiment, please refer to the description of the corresponding functional modules in the embodiments shown in Figures 8 and 9, and will not be repeated here.

[0135] The detailed description and beneficial effects of each functional module in the above-mentioned device embodiments have been described in detail in the aforementioned embodiments and will not be elaborated here.

[0136] Figure 10 is a schematic diagram of the structure of a host provided by an embodiment of the present application. As shown in Figure 10, the host is deployed with a target process module and multiple virtual machines with a data sharing relationship. The host includes: a memory 1001 and a processor 1002, and the processor 1002 is coupled to the memory 1001.

[0137] Memory 1001 is used to store the target process module and the program code corresponding to the multiple virtual machines, and can be configured to store various other data to support operations on the host. Examples of such data include instructions for any application or method operating on the host, messages, images, videos, etc.

[0138] In some embodiments, the processor 1002 executes the program code corresponding to the target process module in the memory 1001 to: allocate a shared memory window from the physical space of the host, the shared memory window is used to store shared data between multiple virtual machines, and has a read-only attribute for multiple virtual machines, so that multiple virtual machines can read the required first shared data from the shared memory window; write the second shared data into the shared memory window, so that multiple virtual machines can share the second shared data.

[0139] In an optional embodiment, when allocating a shared memory window from the physical space of the host, the processor 1002 is specifically used to: respond to an instruction to start multiple virtual machines and apply for a shared memory window from the physical space of the host; provide the physical address of the shared memory window to the virtual machine management module on the host, so that the virtualization management module can map the physical address space reserved for each of the multiple virtual machines into a shared memory window.

[0140] In an optional embodiment, the shared memory window is divided into multiple memory areas, and different memory areas are used to store different types of shared data; a memory area includes multiple slot groups, a slot group includes multiple slots, and different slots are used to store different shared data.

[0141] In an optional embodiment, when the processor 1002 writes the second shared data into the shared memory window, it is specifically used to: determine a second slot for storing the second shared data from the shared memory window when the second shared data is generated between multiple virtual machines; write the second shared data into the second slot; the second slot is a slot in any slot group in the second memory area, and the second memory area is a memory area adapted to the type of the second shared data.

[0142] In an optional embodiment, when the processor 1002 determines the second slot from the shared memory window, it is specifically used to: determine second description information corresponding to the second shared data based on a shared data write request, the second description information including the type and identification information of the second shared data; determine the second memory area from multiple memory areas based on the type of the second shared data; determine the second slot group to which the second shared data belongs in the second memory area based on a hash result of the identification information of the second shared data; and determine the second slot for storing the second shared data from the second slot group based on the access information of each slot in the second slot group.

[0143] In an optional embodiment, any memory region further includes a bitmap region, the bitmap region including bit groups corresponding to each slot group in the memory region to which it belongs, and one bit group being used to record access information indicating whether each slot in the corresponding slot group has been accessed. Accordingly, when determining the second slot from the second slot group, the processor 1002 is specifically configured to: traverse the access information corresponding to each slot recorded in the bit group corresponding to the second slot group, and for a traversed bit position, if the value of the bit position is the first value, set the bit position to the second value, and continue traversing subsequent bits until the target bit position with the second value is first traversed, and set the slot corresponding to the target bit position as the second slot; the first value indicates that the slot corresponding to the bit position has been accessed, and the second value indicates that the slot corresponding to the bit position has not been accessed or can be replaced.

[0144] In an optional embodiment, when the processor 1002 writes the second shared data into the second slot, it is specifically used to: determine the second data storage unit that is effective for the write operation among the two data storage units included in the second slot based on the parity of the temporary version number in the second slot; write the second shared data into the second data storage unit, and after the writing is completed, change the parity of the temporary version number to change the second data storage unit to be effective for the read operation.

[0145] In other embodiments, the processor 1002 executes the program code corresponding to the virtual machine in the memory 1001 to: read the required first shared data from the shared memory window, and perform corresponding operations based on the first shared data; wherein, the shared memory window is used to store shared data between multiple virtual machines, and has a read-only attribute for multiple virtual machines, and the shared data in the shared memory window is written by the target process module.

[0146] In an optional embodiment, when the processor 1002 reads the required first shared data from the shared memory window, it is specifically used to: determine the first slot storing the first shared data from the shared memory window when the first shared data is required; read the first shared data from the first slot; the first slot is a slot in any slot group in the first memory area, and the first memory area is a memory area adapted to the type of the first shared data.

[0147] In an optional embodiment, when the processor 1002 determines the first slot from the shared memory window, it is specifically used to: determine the first description information corresponding to the first shared data according to the shared data read request, the first description information including the type and identification information of the first shared data; determine the first memory area from multiple memory areas according to the type of the first shared data; determine the first slot group to which the first shared data belongs in the first memory area according to the hash result of the identification information of the first shared data; and determine the first slot where the first shared data is located from the first slot group according to the identification information of the shared data stored on each slot in the first slot group.

[0148] In an optional embodiment, when the processor 1002 reads the first shared data from the first slot, it is specifically used to: read the temporary version number from the first slot, and determine the first data storage unit of the two data storage units contained in the first slot that is effective for the read operation based on the parity of the read temporary version number; read the intermediate shared data from the first data storage unit, and after the reading is completed, compare the read temporary version number with the temporary version number in the first slot; if the two are the same, use the intermediate shared data as the first shared data; if the two are inconsistent, re-execute the operation of reading the first shared data from the first slot.

[0149] In some other embodiments, the processor 1002 executes the program code corresponding to the target process module in the memory 1001 on the one hand, so as to: allocate a shared memory window from the physical space of the host, the shared memory window being used to store shared data between multiple virtual machines and having a read-only attribute for the multiple virtual machines, and write the second shared data into the shared memory window so that the multiple virtual machines can share the second shared data; and on the other hand, executes the program code corresponding to the virtual machine in the memory 1001 on the other hand, so as to: read the first shared data required by the virtual machine from the shared memory window, and perform corresponding operations based on the first shared data. The detailed implementation of each operation can be found in the aforementioned embodiments and will not be repeated here.

[0150] Furthermore, as shown in Figure 10, the host also includes other components such as a communication component 1003, a display 1004, a power supply component 1005, and an audio component 1006. Figure 10 only schematically shows some components, which does not mean that the host only includes the components shown in Figure 10. In addition, the components in the dotted box in Figure 10 are optional components, not mandatory components, and the specific product form of the host may be determined. The host of this embodiment can be implemented as a terminal device such as a desktop computer, a laptop computer, a smart phone or an IOT device, or it can be a server-side device such as a conventional server, a cloud server or a server array. If the host of this embodiment is implemented as a terminal device such as a desktop computer, a laptop computer, a smart phone, etc., it may include the components in the dotted box in Figure 10; if the host of this embodiment is implemented as a server-side device such as a conventional server, a cloud server or a server array, it may not include the components in the dotted box in Figure 10.

[0151] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement the steps in the above-mentioned method embodiments.

[0152] An embodiment of the present application further provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, the processor is enabled to implement the steps in the above-mentioned method embodiments.

[0153] The above-mentioned memory can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0154] The above-mentioned communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0155] The above-mentioned display includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor can not only sense the boundary of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.

[0156] The power supply assembly provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.

[0157] The above-mentioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as call mode, recording mode, and voice recognition mode, the microphone is configured to receive external audio signals. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0158] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to magnetic disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) that contain computer-usable program code.

[0159] The present application is described with reference to the flow chart and / or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.

[0160] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0161] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0162] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.

[0163] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0164] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0165] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0166] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A data sharing method, It is characterized in that Applied to a data sharing system, the data sharing system includes a target process module deployed on the same host and multiple virtual machines having a data sharing relationship, the method includes: The target process module allocates a shared memory window from the physical space of the host, where the shared memory window is used to store shared data between the multiple virtual machines and has a read-only attribute for the multiple virtual machines; The multiple virtual machines read the required first shared data from the shared memory window, and perform corresponding operations according to the first shared data; The target process module writes the second shared data into the shared memory window so that the multiple virtual machines can share the second shared data.

2. The method according to claim 1, It is characterized in that The target process module allocates a shared memory window from the physical space of the host, including: A shared memory window is requested from the physical space of the host, and the physical address of the shared memory window is provided to the virtual machine management module on the host, so that the virtualization management module can map the physical address space reserved by each of the multiple virtual machines to the shared memory window.

3. The method according to claim 1, It is characterized in that The shared memory window is divided into a plurality of memory areas, and different memory areas are used to store different types of shared data; a memory area includes a plurality of slot groups, and a slot group includes a plurality of slots, and different slots are used to store different shared data.

4. The method according to claim 3, It is characterized in that A slot includes two data storage units and a version number storage unit, the two data storage units are used to store the same shared data, the version number storage unit is used to store a temporary version number, the parity of the temporary version number is used to identify the data storage unit in the two data storage units that is currently effective for read operations and write operations respectively, and the parity of the temporary version number changes with the occurrence of a write operation in the slot.

5. The method according to any one of claims 1 to 4, It is characterized in that The multiple virtual machines read the required first shared data from the shared memory window, including: In case that the first shared data is needed, determining a first slot storing the first shared data from the shared memory window; The first shared data is read from the first slot; the first slot is a slot in any slot group in the first memory area, and the first memory area is a memory area adapted to the type of the first shared data.

6. The method according to claim 5, It is characterized in that Determining a first slot storing the first shared data from the shared memory window includes: Determine, according to the shared data read request, first description information corresponding to the first shared data, where the first description information includes type and identification information of the first shared data; determining the first memory area from the multiple memory areas according to the type of the first shared data; determining, according to a hash result of the identification information of the first shared data, a first slot group to which the first shared data belongs in the first memory area; According to the identification information of the shared data stored in each slot in the first slot group, the first slot where the first shared data is located is determined from the first slot group.

7. The method according to claim 5, It is characterized in that Reading the first shared data from the first slot includes: Reading a temporary version number from the first slot, and determining a first data storage unit for which a read operation is effective among two data storage units included in the first slot according to the parity of the read temporary version number; Reading the intermediate shared data from the first data storage unit, and after the reading is completed, comparing the read temporary version number with the temporary version number in the first slot; If the two are the same, the intermediate shared data is used as the first shared data; if the two are inconsistent, the operation of reading the first shared data from the first slot is re-executed.

8. The method according to any one of claims 1 to 4, It is characterized in that The target process module writes the second shared data into the shared memory window, including: In a case where second shared data is generated between the plurality of virtual machines, determining a second slot for storing the second shared data from the shared memory window; The second shared data is written into the second slot; the second slot is a slot in any slot group in the second memory area, and the second memory area is a memory area adapted to the type of the second shared data.

9. The method according to claim 8, It is characterized in that Determining a second slot for storing the second shared data from the shared memory window includes: Determine, according to the shared data write request, second description information corresponding to the second shared data, where the second description information includes type and identification information of the second shared data; determining the second memory area from the multiple memory areas according to the type of the second shared data; determining, according to a hash result of the identification information of the second shared data, a second slot group to which the second shared data belongs in the second memory area; A second slot for storing the second shared data is determined from the second slot group according to the access information of each slot in the second slot group.

10. The method according to claim 9, It is characterized in that Any memory area further includes a bitmap area, the bitmap area including bit groups corresponding to each slot group in the memory area to which it belongs, and one bit group is used to record access information of whether each slot in the slot group corresponding to it has been accessed; Determining, from the second slot group, a second slot for storing the second shared data according to the access information of each slot in the second slot group, includes: Traverse the access information corresponding to each slot recorded in the bit group corresponding to the second slot group. For the traversed bit, if the value of the bit is the first value, set the bit position to the second value, and continue to traverse subsequent bits until the target bit with the second value is traversed for the first time, and use the slot corresponding to the target bit as the second slot; the first value indicates that the slot corresponding to the bit has been visited, and the second value indicates that the slot corresponding to the bit has not been visited or can be replaced.

11. The method according to claim 8, It is characterized in that Writing the second shared data into the second slot includes: Determine, according to the parity of the temporary version number in the second slot, a second data storage unit for which a write operation is effective, among the two data storage units included in the second slot; The second shared data is written into the second data storage unit, and after the writing is completed, the parity of the temporary version number is changed to change the second data storage unit to be effective for the read operation.

12. A host, It is characterized in that The host is deployed with a target process module and a plurality of virtual machines having a data sharing relationship, and the host includes: a memory and a processor; The memory is used to store the program code corresponding to the target process module and the multiple virtual machines; the processor is coupled to the memory and is used to execute the program code corresponding to the target process module to execute the steps in the method described in any one of claims 1-11.

13. A data sharing system, It is characterized in that include: A target process module deployed on the same host and multiple virtual machines with a data sharing relationship; The target process module is used to implement the steps executed by the target process module in the method described in any one of claims 1-11, and the multiple virtual machines are used to implement the steps executed by the virtual machines in the method described in any one of claims 1-11.

14. A file metadata sharing system, It is characterized in that include: A target process module, a host file system, and multiple virtual machines having a data sharing relationship deployed on the same host, wherein a client file system is deployed in the multiple virtual machines; The target process module is used to allocate a shared memory window from the physical space of the host, wherein the shared memory window is used to store file metadata shared between the multiple virtual machines and has a read-only attribute for the multiple virtual machines; The client file system is used to respond to a file metadata reading operation initiated by an upper-layer application in the virtual machine to which it belongs, read the first file metadata from the shared memory window and return it to the upper-layer application; The target process module is further used for: responding to a file metadata data write operation initiated by the host file system, writing the second file metadata into the shared memory window, so that the multiple virtual machines can share the second file metadata.

15. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the processor is enabled to implement the steps of the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Method for process communication among multiple virtual machines on multi-core platform based on shared memory and intercore interruption

    CN102693162A

  • Optimization method and optimization system for task scheduling in large-scale virtualization environment

    CN104331327A

  • Data sharing method and device of virtual machine

    CN106612306A

  • Memory sharing method, memory sharing device and terminal equipment

    CN111679921A

  • Data sharing method, device and system and storage medium

    CN116401004A

Cited By

  • Data and container file reading method, device and system, medium and program product

    CN118860992A

  • Data sharing method and device, electronic equipment and storage medium

    CN120723846A

  • Cross-language execution method and device

    CN121433850A