Shared file access method, electronic device and computer-readable storage medium
By adding a file service interface to the distributed storage system, the virtual machine file data is directly read from the distributed storage system, which solves the problem of data sharing difficulty and resource consumption between virtual machines, and achieves efficient data reading performance.
Patent Information
- Application Number
- CN202111564826.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-12-20
AI Technical Summary
There is difficulty and additional resource overhead in sharing data between existing virtual machines or between virtual machines and hosts. Especially when reading virtual machine file data, it needs to be forwarded over the network, consume virtual machine resources and affect performance.
A file service interface is added to a distributed storage system to read data stored in a distributed storage system. When there is no file modification after the virtual file system is mounted, the data is directly read from the distributed storage system, bypassing the virtual machine, and reducing CPU consumption and memory usage.
Shorten the read path, reduce the risk of virtual machines being attacked, avoid the consumption of virtual machines' memory resources, and greatly improve the performance of data reading.
Smart Images

Figure CN114238236B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a method for accessing a shared file, an electronic device, and a computer-readable storage medium. Background Art
[0002] Hardware-assisted virtualization technology refers to running a process on a physical host machine to simulate computer hardware, thereby virtualizing multiple virtual machines (VMs). A virtual machine (VM) is a virtual environment created on a physical hardware system that acts as a virtual computer system. Each virtual machine is isolated from each other, has its own operating system (OS), and runs its business independently. The isolation of virtual machines brings the advantages of independence and security, but it also makes data sharing between virtual machines or between virtual machines and host machines difficult and requires additional resource overhead.
[0003] Currently, virtual machines share files by starting a shared file system program in the virtual machine. Other virtual machines or physical machines mount the shared file system through the network. All access requests to the shared file system are forwarded to the virtual machine through the network, and the virtual machine performs the final file operation. For example, when the host machine receives a file read request from a user for the virtual file system, it sends the file read request to the virtual machine through the network. After receiving the file read request, the virtual machine reads the corresponding data and then returns it to the host machine through the network. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide a shared file access method, electronic device and computer-readable storage medium to shorten the read path, reduce CPU (Central Process Unit) consumption and improve read performance.
[0005] The embodiment of the present application is implemented as follows:
[0006] In the first aspect, the embodiment of the present application provides a method for accessing a shared file, which is applied to a host machine, in which a virtual file system of a specified virtual machine is mounted, and the files of the specified virtual machine are shared in the virtual file system. The host machine is also used to communicate with a file service interface of a distributed storage system, and the file service interface is used to read data stored in the distributed storage system, which is the data of the specified virtual machine when the virtual file system is mounted. The method includes: receiving a file operation request for the virtual file system; if the file operation request is a read operation request, determining whether there is a file modification after the virtual file system is mounted; if there is no file modification after the virtual file system is mounted, reading data related to the read operation request from the distributed storage system through the file service interface. In the embodiment of the present application, by adding a file service interface for reading data stored in the distributed storage system (the data is the data of the specified virtual machine when the virtual file system is mounted) in the distributed storage system, when reading the file data of the virtual machine, if there is no file modification after the virtual file system is mounted, the distributed storage data can be directly read by bypassing the virtual machine, thereby reducing the risk of the virtual machine being attacked. At the same time, since the data does not need to pass through the virtual machine when reading, the memory resources of the virtual machine will not be consumed, which greatly improves the performance of data reading.
[0007] In combination with a possible implementation of the embodiment of the first aspect, the method further includes: if there is a file modification after the virtual file system is mounted, determining whether the file involved in the modification is irrelevant to the data read by the read operation request; if the file involved in the modification is irrelevant to the data read by the read operation request, reading the data related to the read operation request from the distributed storage system through the file service interface. In the embodiment of the present application, if there is a file modification after the virtual file system is mounted, it can be further determined whether the file involved in the modification is irrelevant to the data read by the read operation request; if the file involved in the modification is irrelevant to the data read by the read operation request, then reading the data related to the read operation request from the distributed storage system through the file service interface to improve the performance of data reading.
[0008] In combination with a possible implementation of the embodiment of the first aspect, the method further includes: if the file involved in the modification is related to the data read by the read operation request, the read operation request is sent to the designated virtual machine through the network, so that the designated virtual machine reads the data related to the read operation request from the distributed storage system. In the embodiment of the present application, only when the file involved is related to the data read by the read operation request, the data related to the read operation request is read from the distributed storage system through the designated virtual machine, thereby reducing the frequency of interaction with the virtual machine.
[0009] In combination with a possible implementation of the embodiment of the first aspect, the method further includes: if a file is modified after the virtual file system is mounted, sending the read operation request to the designated virtual machine through the network, so that the designated virtual machine reads data related to the read operation request from the distributed storage system. In the embodiment of the present application, only when a file is modified after the virtual file system is mounted, the data related to the read operation request is read from the distributed storage system through the designated virtual machine, thereby reducing the frequency of interaction with the virtual machine.
[0010] In combination with a possible implementation of the embodiment of the first aspect, when mounting the virtual file system, a data snapshot is created for the virtual disk of the specified virtual machine on the distributed storage system, and the file service interface for reading the data snapshot is created. In an embodiment of the present application, by creating a data snapshot for the virtual disk of the specified virtual machine on the distributed storage system when mounting the virtual file system, and creating a file service interface for reading the data snapshot, it is possible to quickly implement read access to the files of the virtual machine based on the file service interface later.
[0011] In a second aspect, an embodiment of the present application further provides an electronic device, wherein a virtual machine and a virtual file system client are deployed in the electronic device, and a virtual file system server is deployed in the virtual machine. The virtual file system client communicates with the virtual file system server through a network, and the virtual file system client also communicates with a file service interface of a distributed storage system, and the file service interface is used to read data stored in the distributed storage system, which data is the data of the virtual machine when the virtual file system client mounts the virtual file system of the virtual machine; the virtual file system client is used to receive a file operation request for the virtual file system; if the file operation request is a read operation request, the virtual file system client is also used to determine whether there is any file modification after the virtual file system is mounted; if there is no file modification after the virtual file system is mounted, data related to the read operation request is read from the distributed storage system through the file service interface.
[0012] In combination with a possible implementation manner of the second aspect, if a file is modified after the virtual file system is mounted, the virtual file system client is further used to determine whether the file involved in the modification is irrelevant to the data read by the read operation request; if the file involved in the modification is irrelevant to the data read by the read operation request, read the data related to the read operation request from the distributed storage system through the file service interface.
[0013] In combination with a possible implementation manner of the second aspect, if a file is modified after the virtual file system is mounted, the virtual file system client is further used to send the read operation request to the virtual file system server through the network, so that the virtual file system server reads data related to the read operation request from the distributed storage system.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory and a processor, the processor being connected to the memory; the memory being used to store programs; the processor being used to call the programs stored in the memory to execute the method provided in the above-mentioned first aspect embodiment and / or any possible implementation method in combination with the first aspect embodiment.
[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method provided by the above-mentioned first aspect embodiment and / or any possible implementation method in combination with the first aspect embodiment is executed.
[0016] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by implementing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings without creative work. As shown in the drawings, the above and other purposes, features and advantages of the present application will be clearer. The same reference numerals indicate the same parts in all the drawings. The drawings are not deliberately scaled to the actual size, and the focus is on showing the main purpose of the present application.
[0018] Figure 1 A schematic diagram showing the principles of a method for accessing a shared file provided in an embodiment of the present application is shown.
[0019] Figure 2 A flow chart of a method for accessing a shared file provided in an embodiment of the present application is shown.
[0020] Figure 3 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0022] It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it is not necessary to further define and explain it in the subsequent drawings. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements limited by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements.
[0023] Furthermore, the term "and / or" in this application is merely a term used to describe the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone.
[0024] In order to improve the defects of the existing file sharing methods, the embodiments of the present application provide a method for accessing shared files. In order to securely access the file system of a virtual machine, in the embodiments of the present application, a file service interface for reading data stored in the distributed storage system (the data is the data of the virtual machine specified when mounting the virtual file system) is added to the distributed storage system. When reading the file data of the virtual machine, the host machine does not need to access the virtual machine, but can directly read the distributed storage data from the distributed storage system, thereby reducing the risk of the virtual machine being attacked. At the same time, since the data does not need to pass through the virtual machine when reading, the memory resources of the virtual machine will not be consumed, which greatly improves the performance of data reading.
[0025] In order to efficiently access the file system of the virtual machine, in an embodiment of the present application, the host machine is also used to communicate with the file service interface of the distributed storage system. The file service interface is used to read the virtual machine data stored in the distributed storage system at a specified time. The data is the data of the specified virtual machine when the virtual file system is mounted. In this way, when specific conditions are met, data can be directly obtained from the distributed storage system instead of reading data through the virtual machine, thereby shortening the read path, reducing CPU (Central Process Unit) consumption, and improving read performance.
[0026] For ease of understanding, the following Figure 1 The principle of the shared file access method provided in the embodiment of the present application is explained. In order to safely and efficiently access the file system of a virtual machine, the embodiment of the present application provides an electronic device, in which a virtual machine (multiple can be deployed) and a virtual file system client are deployed, wherein a virtual file system server is further deployed in the virtual machine. The virtual file system client communicates with the virtual file system server through a network, and the virtual machine communicates with the distributed storage system, such as the virtual file system server in the virtual machine writes data to the distributed storage system through access point 1 of the distributed storage system, or reads previously written data. The virtual file system client also communicates with the file service interface (such as access point 2) of the distributed storage system, such as the virtual file system client reads data at a specified time from the distributed storage system through access point 2.
[0027] In order to further improve the reading efficiency, this application also adds a file service interface (access point 2) in the distributed storage system to read the data stored in the distributed storage system. The data is the data of the virtual machine at a specified time, such as the data of the specified virtual machine when the virtual file system of the specified virtual machine is mounted on the virtual file system client. The data of the virtual machine at a specified time can be read through this file service interface. Among them, when mounting the virtual file system, a data snapshot is created for the virtual disk of the specified virtual machine on the distributed storage system (the data snapshot is created to ensure that access point 2 reads the complete data of the virtual machine at a certain time and will not be affected by the virtual write request), and a file service interface for reading the snapshot is created, so that the data snapshot can be read based on the file service interface later.
[0028] Among them, the virtual file system client is used to mount the virtual file system of the specified virtual machine, and the files of the specified virtual machine are shared in the virtual file system. It should be noted that multiple virtual machines can be deployed in the electronic device, for example, virtual machine 1, virtual machine 2, and virtual machine 3 are deployed, and the virtual file system of the specified virtual machine (such as virtual machine 2) can be mounted in the virtual file system client as needed. By mounting the virtual file system of the specified virtual machine on the host machine, the file system on the specified virtual machine can be directly accessed on the host machine, and all file operation requests for the virtual file system, such as creating files, opening files, deleting files, reading / writing files, etc., will be forwarded to the virtual machine through the network, and the virtual machine will complete the final file operation.
[0029] The virtual file system client is used to receive file operation requests for the virtual file system. If the file operation request is a read operation file request, the virtual file system client determines whether there is any file modification after the virtual file system is mounted. If there is no file modification after the virtual file system is mounted, the virtual file system client reads data related to the read operation request from the distributed storage system through the file service interface. If the file operation request is other operation requests except the read operation file request, the virtual file system client directly sends it to the virtual machine through the network, and the virtual machine completes the final file operation.
[0030] It should be noted that after the virtual machine modifies the file, it can notify the virtual file system client of the file modification, or the virtual file system client records the operation request sent to the virtual machine that will cause the virtual machine file to be modified, so that the subsequent virtual file system client can determine whether there is any file modification after the virtual file system is mounted.
[0031] If there are file modifications after the virtual file system is mounted, in one implementation, the virtual file system client is also used to send a read operation request to the virtual file system server in the virtual machine through the network, so that the virtual file system server in the virtual machine reads the data related to the read operation request from the distributed storage system. In this implementation, as long as the virtual file system is mounted, if the file in the virtual machine is modified (such as new additions, content modifications, etc.), the virtual machine will read the data related to the read operation request from the distributed storage system. It should be noted that for normal virtual disk reading and writing, after receiving the read and write request, the virtual machine will send the read and write request to the distributed storage system through access point 1 to complete the read and write operations of the corresponding data.
[0032] If there is a file modification after the virtual file system is mounted, in another implementation mode, the virtual file system client is also used to determine whether the file involved in the modification is irrelevant (or relevant) to the data read by the read operation request. If the file involved in the modification is irrelevant to the data read by the read operation request, the data related to the read operation request can still be read from the distributed storage system through the file service interface. Only when the file involved in the modification is related to the data read by the read operation request, the virtual file system server sends the read operation request to the virtual file system server in the virtual machine through the network, so that the virtual file system server in the virtual machine reads the data related to the read operation request from the distributed storage system. In this implementation mode, after the virtual file system is mounted, if the file in the virtual machine is modified (such as adding, modifying the content, etc.), the virtual machine also needs to inform the virtual file system client of the modified file content, and the virtual file system client also needs to save the file content modified by the virtual machine, so as to facilitate the subsequent judgment of whether the file involved in the modification is irrelevant to the data read by the read operation request.
[0033] To better understand why adding a new file service interface can improve the reading efficiency of shared files, let's combine Figure 1 To explain. When there is no new file service interface, the read path of the shared file is: virtual file system client-->virtual file system server-->virtual disk-->distributed storage system-->virtual disk-->virtual file system server-virtual file system client. After the new file service interface is added, the read path of the shared file is: virtual file system client-->distributed storage system-->virtual file system client, which directly bypasses the virtual machine (when reading data through the virtual machine, the virtual machine kernel and driver are required to read and transmit data). Compared with the method of reading the virtual disk through the virtual machine, it reduces the network communication between the host and the virtual machine, reduces the data forwarding of the virtual machine driver, and avoids the performance degradation caused by the virtual disk. The entire data reading process does not require the participation of the virtual machine, so even if a large amount of data is transmitted, it will not consume any virtual machine CPU and memory resources, and shorten the IO path, and the reading performance is greatly improved.
[0034] The shared file access method provided by the present invention can reduce the frequency of interaction with the virtual machine, thereby reducing the risk of the virtual machine being attacked. At the same time, the read operation of the virtual machine shared file system can be performed with low overhead and faster performance. For example, when it is necessary to perform virus scanning and other operations on the virtual machine, it is necessary to perform a full disk scan on the virtual machine. At this time, it is necessary to read all the files on the file system, and only when a virus is found, it is necessary to delete the virus file. Only then will the write operation of the file system be triggered. If all data reading requires the participation of the virtual machine driver and communication through the network, then a large amount of CPU resources of the virtual machine will be consumed, resulting in poor data reading performance and virtual machine jams. In this application scenario with more reading and less writing, the shared file access method of the present application can bypass the virtual machine to directly read the distributed storage data, directly bypassing the virtual machine, which will not consume the CPU and memory resources of the virtual machine, so there is no need to limit the speed of the virtual file system, which greatly improves the performance of virus scanning.
[0035] After introducing the implementation principle of this application, Figure 2 , the process of the method for accessing shared files applied to a host machine provided in an embodiment of the present application is described. The host machine is mounted with a virtual file system of a specified virtual machine, and the files of the specified virtual machine are shared in the virtual file system.
[0036] S1: receiving a file operation request for the virtual file system.
[0037] The host machine has a designated virtual machine and a virtual file system client, and the virtual file system server is deployed in the virtual machine. The virtual file system is mounted in the virtual file system client, and the virtual file system client in the host machine receives a user's file operation request for the virtual file system.
[0038] S2: If the file operation request is a read operation request, determine whether there is any file modification after the virtual file system is mounted.
[0039] If the file operation request is a read operation request, the virtual file system client in the host machine checks whether there is any file modification after the virtual file system is mounted. If there is no file modification after the virtual file system is mounted, S3 is executed. If there is a file modification after the virtual file system is mounted, in one implementation mode, S4 is executed. In another implementation mode, the virtual file system client in the host machine sends the read operation request to the virtual file system server in the specified virtual machine through the network, so that the virtual file system server in the specified virtual machine reads data related to the read operation request from the distributed storage system.
[0040] If the file operation request is other than a read operation request, the virtual file system client sends it to the virtual machine through the network.
[0041] S3: Reading data related to the read operation request from the distributed storage system through the file service interface.
[0042] If there is no file modification after the virtual file system is mounted, the virtual file system client in the host machine reads data related to the read operation request from the distributed storage system through the file service interface (such as access point 2). When the virtual file system is mounted, a data snapshot is created for the virtual disk of the specified virtual machine on the distributed storage system (the data snapshot is created to ensure that access point 2 reads the complete data of the virtual machine at a certain moment and will not be affected by the virtual write request), and a file service interface for reading the snapshot is created, so that the data snapshot can be read based on the file service interface later.
[0043] S4: Determine whether the file involved in the modification is irrelevant to the data read by the read operation request.
[0044] In one implementation, if a file is modified after the virtual file system is mounted, the virtual file system client in the host machine further determines whether the file involved in the modification is irrelevant to the data read by the read operation request, and if the file involved in the modification is relevant to the data read by the read operation request, S5 is executed. If the file involved in the modification is irrelevant to the data read by the read operation request, S3 is executed.
[0045] S5: Send the read operation request to the designated virtual machine through the network.
[0046] If the file involved in the modification is related to the data read by the read operation request, the virtual file system client in the host machine sends the read operation request to the virtual file system server in the specified virtual machine through the network, so that the virtual file system server in the specified virtual machine reads the data related to the read operation request from the distributed storage system.
[0047] like Figure 3 As shown, Figure 3 The electronic device 200 provided in the embodiment of the present application is shown in the structural block diagram. The electronic device 200 comprises: a transceiver 210, a memory 220, a communication bus 230 and a processor 240.
[0048] Among them, the electronic device deploys a virtual machine (multiple can be deployed) and a virtual file system client, and a virtual file system server is deployed in the virtual machine. The virtual file system client communicates with the virtual file system server through a network, and the virtual file system server in the virtual machine also communicates with the distributed storage system, such as the virtual file system server in the virtual machine writes data to the distributed storage system through access point 1 of the distributed storage system, or reads previously written data. The virtual file system client also communicates with the file service interface (such as access point 2) of the distributed storage system, such as the virtual file system client reads data at a specified time from the distributed storage system through access point 2. The virtual machine and the virtual file system client can be deployed in the processor 240.
[0049] The transceiver 210, the memory 220, and the processor 240 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses 230 or signal lines. Among them, the transceiver 210 is used to send and receive data. The memory 220 is used to store computer programs, such as storing software function modules for executing the above method, including at least one software function module that can be stored in the memory 220 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 200. The processor 240 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the ring network configuration device 100. For example, the processor 240 is used to receive a file operation request for the virtual file system; if the file operation request is a read operation request, it is determined whether there is a file modification after the virtual file system is mounted; if there is no file modification after the virtual file system is mounted, the data related to the read operation request is read from the distributed storage system through the file service interface.
[0050] Among them, the memory 220 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0051] The processor 240 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor 240 may also be any conventional processor, etc.
[0052] The electronic device 200 mentioned above includes but is not limited to a computer, a server, etc.
[0053] An embodiment of the present application further provides a non-volatile computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored. When the computer program is run by a computer such as the electronic device 200 described above, the shared file access method shown above is executed.
[0054] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0055] In several embodiments provided in the present application, it should be understood that the disclosed method can also be implemented in other ways. For example, the flowcharts and block diagrams in the accompanying drawings show the possible implementation architecture, functions and operations of the methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0056] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0057] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a computer-readable storage medium, including several instructions for enabling a computer device (which can be a personal computer, a laptop, a server, or an electronic device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned computer-readable storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0058] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for accessing a shared file, characterized in that: Applied to a host machine, a virtual file system of a specified virtual machine is mounted in the host machine, files of the specified virtual machine are shared in the virtual file system, the host machine is also used to communicate with a file service interface of a distributed storage system, the file service interface is used to read data stored in the distributed storage system, the data is the data of the specified virtual machine when the virtual file system is mounted, the method comprises: Receiving a file operation request for the virtual file system; If the file operation request is a read operation request, determining whether there is any file modification after the virtual file system is mounted; If no file is modified after the virtual file system is mounted, data related to the read operation request is read from the distributed storage system through the file service interface.
2. The method according to claim 1, characterized in that The method further comprises: If there is a file modification after the virtual file system is mounted, determining whether the file involved in the modification is irrelevant to the data read by the read operation request; If the file involved in the modification is irrelevant to the data read by the read operation request, the data related to the read operation request is read from the distributed storage system through the file service interface.
3. The method according to claim 2, characterized in that The method further comprises: If the file involved in the modification is related to the data read by the read operation request, the read operation request is sent to the designated virtual machine through the network, so that the designated virtual machine reads the data related to the read operation request from the distributed storage system.
4. The method according to claim 1, characterized in that: The method further comprises: If there is a file modification after the virtual file system is mounted, the read operation request is sent to the designated virtual machine through the network, so that the designated virtual machine reads data related to the read operation request from the distributed storage system.
5. The method according to claim 1, characterized in that When the virtual file system is mounted, a data snapshot is created for the virtual disk of the designated virtual machine on the distributed storage system, and the file service interface for reading the data snapshot is created.
6. An electronic device, characterized in that: A virtual machine and a virtual file system client are deployed in the electronic device, a virtual file system server is deployed in the virtual machine, the virtual file system client communicates with the virtual file system server through a network, the virtual file system client also communicates with a file service interface of a distributed storage system, the file service interface is used to read data stored in the distributed storage system, the data is the data of the virtual machine when the virtual file system client mounts the virtual file system of the virtual machine; The virtual file system client is used to receive a file operation request for the virtual file system; If the file operation request is a read operation request, the virtual file system client is further used to determine whether there is any file modification after the virtual file system is mounted; if there is no file modification after the virtual file system is mounted, read data related to the read operation request from the distributed storage system through the file service interface.
7. The electronic device according to claim 6, characterized in that: If a file is modified after the virtual file system is mounted, the virtual file system client is further used to determine whether the file involved in the modification is irrelevant to the data read by the read operation request; if the file involved in the modification is irrelevant to the data read by the read operation request, read the data related to the read operation request from the distributed storage system through the file service interface.
8. The electronic device according to claim 6, characterized in that: If a file is modified after the virtual file system is mounted, the virtual file system client is further configured to send the read operation request to the virtual file system server through a network, so that the virtual file system server reads data related to the read operation request from the distributed storage system.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is executed.
Citation Information
Patent Citations
Optimizing method for storing virtual machine mirror images based on CAS (content addressable storage)
CN103034684A
Shared file access method and system and associated equipment
CN105447203A