File Access Method and Device
By combining file access methods of binding and network mounting, the problems of slow file access speed and large storage space consumption in cloud applications are solved, achieving storage space optimization and access speed improvement, making it suitable for file access devices in cloud applications.
Patent Information
- Application Number
- CN202511232228.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-01
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-09-01
AI Technical Summary
Existing cloud application solutions suffer from slow file access response times and large storage space consumption, especially in multi-instance environments where network file systems become performance bottlenecks with limited storage space.
By combining host-level binding mounts and remote directory network mounts, access requests are determined through a virtual file system, and remote directories are mounted as needed, avoiding unnecessary network connections and local storage copies, thus achieving decoupling.
Reduce storage space usage, improve file access speed, save bandwidth, simplify cloud application expansion and adjustment, and improve cloud application startup and running speed.
Smart Images

Figure CN120743383B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud applications, and in particular to a file access method and apparatus. Background Technology
[0002] In cloud application scenarios (such as cloud gaming), it is necessary to share the application installation package and application hot-update resources among multiple instances (usually using a containerization solution that runs multiple containers on a host). There are generally two methods for sharing:
[0003] 1. Pre-installation solution: Application files are pre-copied from the storage server to the host machine, and the application in the container directly accesses the application files on the host machine. Since the application files have been pre-copied to the host machine, all file access requests from the application in the container occur locally, resulting in fast file access response times. However, because the needs of cloud application users are generally unpredictable, when cloud application users want to use different applications, they need to constantly change the application files copied to the host machine, which is relatively complex to implement. Furthermore, considering the limited storage space on the host machine, too many application files cannot be copied to the host machine.
[0004] 2. No-installation solution: This method uses network file systems such as NFS and CIFS to map application files from the storage server into containers. Then, the application's access requests to these files within the container are translated into network requests to the application files on the storage server. Because the application files are not stored on the host machine, the required storage space is relatively small. However, since file access requests involve the network, the response time is slower. Furthermore, because a single storage server needs to serve multiple instances, it can become a performance bottleneck if there are many instances. Additionally, because the application files are directly mounted within the containers, multiple containers on the same host cannot share the network file system cache.
[0005] In view of this, how to optimize the existing solution to solve at least one of the problems of slow file access response speed and large storage space consumption has become an urgent technical problem to be solved. Summary of the Invention
[0006] Therefore, embodiments of this application provide a file access method and apparatus.
[0007] In a first aspect, embodiments of this application provide a file access method, including:
[0008] When a cloud application running in a container accesses a file in the cloud application directory within the container, if the virtual file system on the host receives a first file access request from the container, it determines whether the first directory on the host has a first identifier. The first file access request carries an access path, which is a path under the second directory on the host. The first directory is any directory between the second directory and its parent directory. The second directory is mapped to the third directory in the container through a binding mount mechanism. The fourth and fifth directories are associated directories of the file system in the container. The third directory is either the fourth directory, its parent directory, or its parent directory. The cloud application directory is either the fifth directory, its parent directory, or its parent directory. The first identifier is used to identify that a remote directory needs to be mounted to the corresponding directory through the first file system. The first file system is a network file system.
[0009] If the first directory has a first identifier, then determine whether the first directory has a second identifier, where the second identifier is used to indicate that the remote directory has been mounted to the corresponding directory through the first file system;
[0010] If the first directory has a second identifier, the virtual file system sends the second file access request to the first file system for processing and returns the processing result to the cloud application; or
[0011] If the first directory does not have a second identifier, the virtual file system notifies the second file system to mount the remote directory to the first directory through the first file system. After the mounting is completed, the second file access request is sent to the first file system for processing, and the processing result is returned to the cloud application. Here, the second file system is the file system in the host.
[0012] Secondly, embodiments of this application also provide a file access device, including:
[0013] The first judgment unit is used to determine whether the first directory in the host has a first identifier when the cloud application running in the container accesses a file under the cloud application directory in the container. The first file access request carries an access path, which is a path under the second directory in the host. The first directory is any directory of the second directory and its parent directory. The second directory is mapped to the third directory in the container through a binding mount mechanism. The fourth and fifth directories are associated directories of the file system in the container. The third directory is the fourth directory or its parent directory or its parent directory. The cloud application directory is the fifth directory or its parent directory or its parent directory. The first identifier is used to identify that the remote directory needs to be mounted to the corresponding directory through the first file system. The first file system is a network file system.
[0014] The second judgment unit is used to determine whether the first directory has a second identifier if the first directory has a first identifier, wherein the second identifier is used to identify that the remote directory has been mounted to the corresponding directory through the first file system.
[0015] The forwarding unit is used to send the second file access request to the first file system for processing if the first directory has a second identifier, and return the processing result to the cloud application; or
[0016] If the first directory does not have a second identifier, the virtual file system notifies the second file system to mount the remote directory to the first directory through the first file system. After the mounting is completed, the second file access request is sent to the first file system for processing, and the processing result is returned to the cloud application. Here, the second file system is the file system in the host.
[0017] In summary, the file access method and apparatus provided in this application combine binding and mounting of a second directory on the host with network mounting of a remote directory. When a cloud application running in a container accesses files in the cloud application directory within the container, and the virtual file system on the host receives a first file access request from the container, it determines whether the first directory has a first identifier. If the first directory has the first identifier, the remote directory is accessed through the network-mounted first file system. Thus, application files in the remote directory do not need to be stored on the host, and the access requirements of different cloud applications can be met by setting multiple first directories with the first identifier. Compared to existing pre-installed solutions, this approach... This approach reduces storage space usage and avoids the complexities of copying different files to the host when running different cloud applications in containers. Furthermore, the same cloud application in different containers on the same host can access the remote directory through the same first directory, allowing these cloud applications to share the same virtual file system cache. Compared to existing installation-free solutions, this reduces the overall memory consumption of the host, reduces network requests, and improves file access speed, thereby saving bandwidth and improving the startup and running speed of cloud applications. In addition, cloud applications in this solution do not need to know the processing logic of the host's virtual file system, which facilitates the expansion / adjustment of the processing logic and achieves decoupling. Attached Figure Description
[0018] Figure 1 A flowchart illustrating an embodiment of a file access method provided in this application;
[0019] Figure 2 This is a schematic diagram of an embodiment of a file access device provided in this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0021] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0022] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0023] Reference Figure 1 As shown in the figure, this application provides a flowchart of a file access method, which includes:
[0024] S10. When a cloud application running in a container accesses a file in the cloud application directory in the container, if the virtual file system in the host receives a first file access request from the container, it determines whether the first directory in the host has a first identifier. The first file access request carries an access path, which is a path in the second directory in the host. The first directory is any directory in the second directory and its parent directory. The second directory is mapped to the third directory in the container through a binding mount mechanism. The fourth and fifth directories are associated directories of the file system in the container. The third directory is the fourth directory or its parent directory or its parent directory. The cloud application directory is the fifth directory or its parent directory or its parent directory. The first identifier is used to identify that a remote directory needs to be mounted to the corresponding directory through the first file system. The first file system is a network file system.
[0025] In this embodiment, it should be noted that the fourth and fifth directories are associated directories of the file system within the container. This means that the fourth directory can be accessed indirectly through the fifth directory, or under certain restrictions, the fourth directory can be accessed indirectly through the fifth directory. The remote directories that need to be shared over the network (for a specific cloud application, the remote directory stores all or part of the cloud application files) can be determined based on certain factors (such as cloud application popularity, package size, etc.). The first directory corresponding to the remote directory is pre-set with a first identifier, but not with a second identifier. Thus, in subsequent steps, step S13 is executed, and the remote directory is mounted only when the cloud application actually needs to access it, achieving on-demand mounting. This avoids the need for continuous connection to the storage server, saving network resource consumption between the host and the storage server. Here, the remote directory is a directory within the storage server. Furthermore, it should be noted that for cloud application directories / files that require local access, they can be copied from the storage server to the host, and the corresponding first directory can be set without a first identifier. Thus, when the cloud application in the container actually accesses the first directory, it accesses it directly locally. In other words, this solution can integrate pre-installed and non-installed solutions. Cloud applications in containers do not need to pay attention to file access logic on the host, thus achieving solution decoupling.
[0026] The following example illustrates this. Example 1: Assume the file system in the container is an OverlayFS file system. An OverlayFS file system 1 exists within the container, but it lacks an upper layer. A cloud application A runs within the container. The installation package APK directory of cloud application A is the merge layer directory (i.e., the fifth directory) of OverlayFS file system 1. A directory different from the fifth directory is the lower layer directory (i.e., the fourth directory) of OverlayFS file system 1. The fourth directory is identical to the third directory. When cloud application A accesses a file in the APK directory, the OverlayFS file system translates the file access request into an access request for the corresponding file in the lower layer directory and forwards the request to the virtual file system (VFS) on the host. Upon receiving the file access request, the VFS file system translates the request into an access request for the corresponding file in the second directory and determines whether a directory with a first identifier exists in the second directory and its parent directories. If it exists (i.e., the first directory has the first identifier), then step S11, and either step S12 or S13, are executed. If the first directory does not exist (i.e., the first directory does not have a first identifier), the VFS file system processes the access request for the corresponding file in the second directory and returns the processing result to cloud application A through OverlayFS file system 1. Additionally, it should be noted that Example 1 uses the APK directory of cloud application A as an example. Because the APK directory is read-only, the OverlayFS file system 1 does not have an upper layer in this example. However, if we use the data directory and sdcard directory of cloud application A as examples, still using the OverlayFS file system, then since the data directory and sdcard directory are read-write, the upper layer of the OverlayFS file system needs to be retained.
[0027] Example 2: Assume the container uses the host's VFS file system, and cloud application B runs in the container. The fourth directory in the container is mapped to the fifth directory in the container through binding. The third directory in the container is the same as the fourth directory in the container. The installation package APK directory of cloud application B in the container is the same as the fifth directory. When cloud application B accesses a file in the APK directory, the VFS file system will sequentially convert the file access request into an access request for the corresponding file in the third directory, and then an access request for the corresponding file in the second directory. It will also determine whether there is a directory with the first identifier in the second directory and its parent directories. The subsequent processing logic is the same as in Example 1, and will not be repeated here.
[0028] S11. If the first directory has a first identifier, then determine whether the first directory has a second identifier, wherein the second identifier is used to identify that the remote directory has been mounted to the corresponding directory through the first file system.
[0029] S12. If the first directory has a second identifier, the virtual file system sends the second file access request to the first file system for processing and returns the processing result to the cloud application; or
[0030] S13. If the first directory does not have a second identifier, the virtual file system notifies the second file system to mount the remote directory to the first directory through the first file system. After the mounting is completed, the second file access request is sent to the first file system for processing, and the processing result is returned to the cloud application. Here, the second file system is the file system in the host.
[0031] In this embodiment, it should be noted that the virtual file system manages the mounting of remote directories through the second file system. Specifically, when a cloud application needs to actually access a remote directory, it must ensure that the remote directory has been mounted to the first directory through the first file system. If the remote directory has not yet been mounted to the first directory through the first file system, the second file system needs to be notified to mount it. Furthermore, if the first directory has not been accessed for a long time, the second file system can unmount the corresponding mount point (i.e., cancel the mount between the remote directory and the first directory through the first file system). Finally, the virtual file system sends the second file access request to the first file system for processing, enabling the cloud application to access the remote directory. The first file access request and the second file access request are different; the second file access request is an access request for the corresponding file / folder under the second directory.
[0032] The file access method provided in this application combines binding and mounting of a second directory on the host with network mounting of a remote directory. When a cloud application running in a container accesses files in the cloud application directory within the container, and the virtual file system on the host receives a first file access request from the container, it determines whether the first directory has a first identifier. If the first directory has the first identifier, the remote directory is accessed through the network-mounted first file system. Thus, application files in the remote directory do not need to be stored on the host, and the access requirements of different cloud applications can be met by setting multiple first directories with the first identifier. Compared to existing pre-installation solutions, this reduces... This solution minimizes storage space usage and avoids the complexities of copying different files to the host machine when running different cloud applications in containers. Furthermore, the same cloud application in different containers on the same host can access remote directories through the same first directory, allowing these cloud applications to share the same virtual file system cache. Compared to existing installation-free solutions, this reduces the overall memory consumption of the host machine, reduces network requests, and improves file access speed, thereby saving bandwidth and improving the startup and running speed of cloud applications. In addition, cloud applications in this solution do not need to know the processing logic of the host's virtual file system, which makes it easier to expand / adjust the processing logic and achieve decoupling.
[0033] Based on the foregoing method embodiments, the method may further include:
[0034] If the first directory does not have a first identifier, the virtual file system processes the file access request and returns the processing result to the cloud application.
[0035] Based on the foregoing method embodiments, the method may further include:
[0036] Delete the configuration item corresponding to the first directory in the configuration file of the user-space program on the second file system, and notify the user-space program on the second file system to load the configuration file and delete the first directory; or
[0037] Instruct the user-space program of the second file system to delete the configuration item corresponding to the first directory in the mount point list, and delete the first directory.
[0038] In this embodiment, it should be noted that when deleting the first directory, it is necessary to determine whether the first directory is associated with a mount point. If it is associated with a mount point (i.e., the remote directory is mounted to the first directory through the first file system), the mount relationship corresponding to the mount point needs to be canceled first (i.e., the mount relationship between the remote directory and the first directory through the first file system) before deleting the first directory. When canceling the mount relationship corresponding to the mount point, an existing user-space program of the second file system can be used for processing, or a new user-space program can be reconstructed to replace the existing user-space program of the second file system and processed by the new user-space program. Specifically, processing using an existing user-space program of the second file system may include: deleting the configuration item corresponding to the first directory in the configuration file of the user-space program of the second file system, notifying the user-space program of the second file system to load the configuration file. In this way, the user-space program of the second file system will compare the differences between the newly loaded configuration file and the previously loaded configuration file, and unload the mount points corresponding to the configuration items that exist in the previously loaded configuration file but not in the newly loaded configuration file. Processing by a new user-space program may include: notifying the new user-space program to delete the configuration item corresponding to the first directory in the mount point list. In this way, the new user-space program will unload the mount point corresponding to the configuration item to be deleted. Alternatively, if the first directory is not associated with a mount point, it can be deleted directly.
[0039] Based on the aforementioned method embodiments, the second file system may include the autofs file system.
[0040] Based on the aforementioned method embodiments, the file system in the container may include an OverlayFS file system or a virtual file system.
[0041] In this embodiment, it should be noted that the file system in the container may include not only the OverlayFS file system and the virtual file system, but also the AUFS file system.
[0042] Reference Figure 2 The diagram shown is a structural schematic of a file access device provided in an embodiment of this application. The device includes:
[0043] The first judgment unit 20 is used to determine whether the first directory in the host has a first identifier when the cloud application running in the container accesses the file under the cloud application directory in the container. If the virtual file system in the host receives the first file access request from the container, the first file access request carries the access path, which is the path under the second directory in the host. The first directory is any directory of the second directory and the parent directory of the second directory. The second directory is mapped to the third directory in the container through the binding mount mechanism. The fourth directory and the fifth directory are the associated directories of the file system in the container. The third directory is the fourth directory or the parent directory of the fourth directory or the parent directory of the fourth directory. The cloud application directory is the fifth directory or the parent directory of the fifth directory or the parent directory of the fifth directory. The first identifier is used to identify that the remote directory needs to be mounted to the corresponding directory through the first file system. The first file system is a network file system.
[0044] The second judgment unit 21 is used to determine whether the first directory has a second identifier if the first directory has a first identifier, wherein the second identifier is used to identify that the remote directory has been mounted to the corresponding directory through the first file system.
[0045] Forwarding unit 22 is configured to, if the first directory has a second identifier, send the second file access request to the first file system for processing, and return the processing result to the cloud application; or
[0046] If the first directory does not have a second identifier, the virtual file system notifies the second file system to mount the remote directory to the first directory through the first file system. After the mounting is completed, the second file access request is sent to the first file system for processing, and the processing result is returned to the cloud application. Here, the second file system is the file system in the host.
[0047] The file access device provided in this application combines binding and mounting of a second directory on the host with network mounting of a remote directory. When a cloud application running in a container accesses files in the cloud application directory within the container, and the virtual file system on the host receives a first file access request from the container, it determines whether the first directory has a first identifier. If the first directory has the first identifier, the remote directory is accessed through the network-mounted first file system. Thus, application files in the remote directory do not need to be stored on the host, and the access requirements of different cloud applications can be met by setting multiple first directories with the first identifier. Compared to existing pre-installed solutions, this reduces... This solution minimizes storage space usage and avoids the complexities of copying different files to the host machine when running different cloud applications in containers. Furthermore, the same cloud application in different containers on the same host can access remote directories through the same first directory, allowing these cloud applications to share the same virtual file system cache. Compared to existing installation-free solutions, this reduces the overall memory consumption of the host machine, reduces network requests, and improves file access speed, thereby saving bandwidth and improving the startup and running speed of cloud applications. In addition, cloud applications in this solution do not need to know the processing logic of the host's virtual file system, which makes it easier to expand / adjust the processing logic and achieve decoupling.
[0048] Based on the aforementioned device embodiments, the forwarding unit can also be used for:
[0049] If the first directory does not have a first identifier, the virtual file system processes the file access request and returns the processing result to the cloud application.
[0050] Based on the foregoing device embodiments, the device may further include:
[0051] The deletion unit is used to delete the configuration item corresponding to the first directory in the configuration file of the user-mode program of the second file system, and to notify the user-mode program of the second file system to load the configuration file and delete the first directory; or
[0052] Instruct the user-space program of the second file system to delete the configuration item corresponding to the first directory in the mount point list, and delete the first directory.
[0053] Based on the aforementioned device embodiments, the second file system may include the autofs file system.
[0054] Based on the aforementioned device embodiments, the file system in the container may include an OverlayFS file system or a virtual file system.
[0055] The file access device provided in this application embodiment is implemented in the same way as the file access method provided in this application embodiment, and the effect it achieves is also the same as the file access method provided in this application embodiment, so it will not be described again here.
[0056] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A file access method, characterized in that, include: When a cloud application running in a container accesses a file in the cloud application directory within the container, if the virtual file system on the host receives a first file access request from the container, it determines whether the first directory on the host has a first identifier. The first file access request carries an access path, which is a path under the second directory on the host. The first directory is any directory between the second directory and its parent directory. The second directory is mapped to the third directory in the container through a binding mount mechanism. The fourth and fifth directories are associated directories of the file system in the container. The third directory is either the fourth directory, its parent directory, or its parent directory. The cloud application directory is either the fifth directory, its parent directory, or its parent directory. The first identifier is used to identify that a remote directory needs to be mounted to the corresponding directory through the first file system. The first file system is a network file system. If the first directory has a first identifier, then determine whether the first directory has a second identifier, where the second identifier is used to indicate that the remote directory has been mounted to the corresponding directory through the first file system; If the first directory has a second identifier, the virtual file system sends the second file access request to the first file system for processing and returns the processing result to the cloud application; or If the first directory does not have a second identifier, the virtual file system notifies the second file system to mount the remote directory to the first directory through the first file system. After the mounting is completed, the second file access request is sent to the first file system for processing, and the processing result is returned to the cloud application. Here, the second file system is the file system in the host.
2. The method as described in claim 1, characterized in that, Also includes: If the first directory does not have a first identifier, the virtual file system processes the file access request and returns the processing result to the cloud application.
3. The method as described in claim 1, characterized in that, Also includes: Delete the configuration item corresponding to the first directory in the configuration file of the user-space program of the second file system, notify the user-space program of the second file system to load the configuration file, and delete the first directory; or Instruct the user-space program of the second file system to delete the configuration item corresponding to the first directory in the mount point list, and delete the first directory.
4. The method as described in claim 1, characterized in that, The second file system includes the autofs file system.
5. The method as described in claim 1, characterized in that, The file system in the container includes the OverlayFS file system or a virtual file system.
6. A file access device, characterized in that, include: The first judgment unit is used to determine whether the first directory in the host has a first identifier when the cloud application running in the container accesses a file under the cloud application directory in the container. The first file access request carries an access path, which is a path under the second directory in the host. The first directory is any directory of the second directory and its parent directory. The second directory is mapped to the third directory in the container through a binding mount mechanism. The fourth and fifth directories are associated directories of the file system in the container. The third directory is the fourth directory or its parent directory or its parent directory. The cloud application directory is the fifth directory or its parent directory or its parent directory. The first identifier is used to identify that the remote directory needs to be mounted to the corresponding directory through the first file system. The first file system is a network file system. The second judgment unit is used to determine whether the first directory has a second identifier if the first directory has a first identifier, wherein the second identifier is used to identify that the remote directory has been mounted to the corresponding directory through the first file system. The forwarding unit is used to send the second file access request to the first file system for processing if the first directory has a second identifier, and return the processing result to the cloud application; or If the first directory does not have a second identifier, the virtual file system notifies the second file system to mount the remote directory to the first directory through the first file system. After the mounting is completed, the second file access request is sent to the first file system for processing, and the processing result is returned to the cloud application. Here, the second file system is the file system in the host.
7. The apparatus as claimed in claim 6, characterized in that, The forwarding unit is further configured to: If the first directory does not have a first identifier, the virtual file system processes the file access request and returns the processing result to the cloud application.
8. The apparatus as claimed in claim 6, characterized in that, Also includes: The deletion unit is used to delete the configuration item corresponding to the first directory in the configuration file of the user-mode program of the second file system, and to notify the user-mode program of the second file system to load the configuration file and delete the first directory. or Instruct the user-space program of the second file system to delete the configuration item corresponding to the first directory in the mount point list, and delete the first directory.
9. The apparatus as claimed in claim 6, characterized in that, The second file system includes the autofs file system.
10. The apparatus as claimed in claim 6, characterized in that, The file system in the container includes the OverlayFS file system or a virtual file system.
Citation Information
Patent Citations
Cloud game mounting method and device, electronic equipment and storage medium
CN115414665A
Sharing Filesystems Between Containers
US20180365238A1