Cross-device data access method and device, electronic device, and storage medium
By pre-caching data in the cache space and truncating operation requests using the eBPF module, latency and efficiency issues in cross-device data access are resolved, resulting in faster data access speeds and a better user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies suffer from latency and inefficiency in cross-device data access, especially when dealing with large files, which require multiple copies and network transfers, resulting in cumbersome and time-consuming operations.
By pre-caching data in the cache space and using the eBPF module to truncate operation requests in the kernel space, the number of interactions with the FUSE network file system is reduced, and operation results are obtained directly from the cache space, avoiding multiple switches between user mode and kernel mode and data copying.
It improves the efficiency of cross-device data access, reduces latency, and enhances data access speed and user experience.
Smart Images

Figure CN119232751B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a cross-device data access method and device, electronic equipment and storage medium. BACKGROUND
[0002] Nowadays, people mostly have more than one electronic device, and different files can be stored in different electronic devices, for example, work files are stored on a computer, materials are downloaded on a pad, and photos are taken on a mobile phone or a vehicle-mounted device, etc. In some scenarios, a user wants to obtain photos on a camera or a car on a computer. In other scenarios, a user wants to obtain work files on a computer on a pad. It can be seen that cross-device data access has become a hot spot of people's needs. SUMMARY
[0003] Embodiments of the present application are dedicated to providing a cross-device data access method and device, electronic equipment and storage medium, which are introduced from the following aspects.
[0004] In a first aspect, a cross-device data access method is provided. The method is applied to an electronic device, and an operating system of the electronic device includes a user space and a kernel space. The user space is arranged with an application program and a FUSE network file system, and the kernel space is arranged with a virtual file system, a network file system kernel driver and an eBPF module. The FUSE network file system and the eBPF module share a cache space. The method includes: obtaining an operation request generated by the application program, and forwarding the operation request to the network file system kernel driver through the virtual file system in response to the operation request; calling the eBPF module to perform a target operation on the cache space through the network file system kernel driver, and obtaining a first target operation result; the cache space is used to cache data read from other electronic devices or data written to other electronic devices; and feeding back the first target operation result to the application program through the virtual file system.
[0005] In one of the embodiments, after the eBPF module is called to perform the target operation on the cache space through the network file system kernel driver, the method further includes, in the case that the target operation fails, sending the operation request to the FUSE network file system through the network file system kernel driver; performing the target operation on a target electronic device associated with the operation request through the FUSE network file system to obtain the first target operation result; updating the first target operation result to the cache space through the FUSE network file system, feeding back the first target operation result to the network file system kernel driver, and feeding back the first target operation result to the application program through the virtual file system.
[0006] In one embodiment, the operation request is a read operation request, the target operation is a read operation, and the target operation is performed on the cache space by calling the eBPF module through the network file system kernel driver to obtain the first target operation result, including: calling the eBPF module through the network file system kernel driver to search for the first target data corresponding to the read operation request in the cache space; if the first target data is found, the first target data is read and the first target operation result is determined based on the read first target data.
[0007] In one embodiment, the method further includes: if the first target data is not found, reporting a target operation failure to the network file system kernel driver.
[0008] In one embodiment, the operation request is a write operation request, the target operation is a write operation, and the target operation is performed on the cache space by calling the eBPF module through the network file system kernel driver to obtain the first target operation result, including: updating the second target data corresponding to the write operation request in the cache space by calling the eBPF module through the network file system kernel driver; and feeding back the operation success message as the first target operation result to the network file system kernel driver.
[0009] In one embodiment, the method further includes: when the size of the second target data in the cache space exceeds a preset threshold, writing the second target data to the corresponding target electronic device through the FUSE network file system.
[0010] In one embodiment, the method further includes: evicting cached data in the cache space using a sliding window algorithm and / or an LRU algorithm.
[0011] Secondly, a cross-device data access apparatus is provided, applied to an electronic device. The operating system of the electronic device includes user space and kernel space. The user space contains applications and a FUSE network file system, while the kernel space contains a virtual file system, a network file system kernel driver, and an eBPF module. The FUSE network file system and the eBPF module share a cache space. The apparatus includes: an acquisition module for acquiring operation requests generated by the application and forwarding the operation requests to the network file system kernel driver via the virtual file system in response to the operation requests; an access module for calling the eBPF module through the network file system kernel driver to perform a target operation on the cache space and acquiring a first target operation result; the cache space is used to cache data read from or written to other electronic devices; and a feedback module for feeding back the first target operation result to the application via the virtual file system.
[0012] Thirdly, an electronic device is provided, the operating system of which includes a user space and a kernel space. The user space contains applications and a FUSE network file system, and the kernel space contains a virtual file system, a network file system kernel driver, and an eBPF module. The FUSE network file system and the eBPF module share a cache space. The electronic device also includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method of any one of the first aspects above.
[0013] Fourthly, a computer storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the method of any one of the first aspects above.
[0014] The cross-device data access method provided in this application pre-caches data in the cache space and then truncates operation requests in the kernel space through the eBPF module. This eliminates the need for operation requests to reach the FUSE network file system. In this way, the FUSE Driver can directly retrieve the result of the first target operation from the cache space through the eBPF module and return it to the application. This reduces the number of interactions between the kernel space FUSE Driver and the user space FUSE network file system for each operation request, thereby helping to reduce multiple switches between user mode and kernel mode and repeated data copying between user mode and kernel mode, thus improving the efficiency of cross-device data access and reducing latency. Attached Figure Description
[0015] Figure 1 A schematic diagram illustrating the interconnection of multiple electronic devices is shown.
[0016] Figure 2 A schematic diagram of the architecture of a user-space file system is shown.
[0017] Figure 3 An architecture diagram of a user-space file system provided in an embodiment of this application is shown.
[0018] Figure 4 A flowchart of a cross-device data access method provided in an embodiment of this application is shown.
[0019] Figure 5 A flowchart of another method for cross-device data access is shown.
[0020] Figure 6 A logical diagram of a user-space file system is shown.
[0021] Figure 7 A schematic diagram of the working logic of a FUSE Driver in handling read operation requests is shown.
[0022] Figure 8A schematic diagram of the data eviction mechanism for the cache space is shown.
[0023] Figure 9 A schematic diagram of the working logic of a FUSE Driver in handling write operation requests is shown.
[0024] Figure 10 A logical diagram of a user-space file system is shown.
[0025] Figure 11 A logical diagram of another user-space file system is shown.
[0026] Figure 12 A block diagram of a cross-device data access apparatus is shown.
[0027] Figure 13 A block diagram of an electronic device is shown. Detailed Implementation
[0028] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0029] In modern life, electronic devices play an increasingly important role in people's lives. They enable data reading, writing, adding / deleting, and modifying data. Furthermore, most people now own more than one electronic device, storing different files on different devices—for example, work documents on a computer, downloaded materials on a tablet, and photos on a mobile phone or in-car device.
[0030] In some scenarios, users may need to process data stored on multiple different electronic devices. Traditionally, this involves users activating different electronic devices and processing the data on each device separately. Alternatively, users manually copy data from different devices to a single device for processing. Clearly, both methods are inconvenient and inefficient.
[0031] Based on this, the concept of cross-device data access was proposed. Cross-device data access enables electronic devices to access and edit data across different devices. For example, a computer can directly access and edit data on a mobile phone / tablet. Or a computer can directly access data on other computers, thereby enabling efficient office work.
[0032] To enable cross-device data access, the following requirements generally need to be met: First, an electronic device should be able to access and edit files saved on other electronic devices. Second, an electronic device should be able to save files from other electronic devices to its local storage. Third, an electronic device should be able to directly add files to other electronic devices.
[0033] The three requirements mentioned above essentially all involve local electronic devices accessing file directories and performing file read / write operations on other electronic devices over a network. Clearly, users want all operations to be fast and seamless, just like local operations. Therefore, the most crucial question is how to improve file read / write speeds to achieve a near-local file read / write experience.
[0034] Currently, the traditional approach involves the local electronic device copying the original file the user wants to access from another electronic device to the local device, where the user directly manipulates the copied file. If modifications are made, the modified file is synchronized back to the original electronic device.
[0035] This implementation method is simple; you only need to copy the file, and all subsequent operations are no different from operating on a local file. However, this solution involves multiple steps, including copying the original file, editing the file, copying the modified file, and overwriting the original file, which is quite cumbersome. Furthermore, when processing large files, copying the original file is very time-consuming; even minor modifications require copying and transferring the entire large file twice over the network, resulting in very low efficiency.
[0036] Based on this, a traditional solution also proposes an implementation method in which local electronic devices mount files and directories shared by other electronic devices to the local device through the Network File System (NFS), allowing users to access shared files on other devices as if they were local files.
[0037] This implementation method mounts shared files and directories from other electronic devices to the local electronic device via a network file system. The local electronic device then performs cross-device read and write operations based on the network file system, allowing users to operate shared files on other electronic devices as if they were local files. However, cross-device read and write operations often suffer from latency issues.
[0038] To better address the latency issues associated with cross-device read / write operations, this application provides a cross-device data access method, apparatus, electronic device, and storage medium. This cross-device data access method can improve the speed of accessing data on other electronic devices and reduce latency while meeting user needs.
[0039] The following describes the application scenarios and user-space file system (FUSE) involved in the embodiments of this application.
[0040] The technical solutions provided in this application can be applied to various scenarios such as cross-device data access and editing, and are the cornerstone of distributed data / file management. The network connection relationships between different electronic devices can be as follows: Figure 1 As shown, Figure 1 A schematic diagram illustrating the interconnection of multiple electronic devices is shown, exemplarily illustrating four electronic devices: a computer, a mobile phone, an in-vehicle device, and a tablet. Each of these electronic devices is connected to the other three via a network.
[0041] Taking a computer as the local electronic device and mobile phones, in-vehicle devices, and tablets as other electronic devices, FUSE network file system is installed and enabled on both the local and other electronic devices. The local electronic device obtains the IP address and shared folder path of the other electronic devices and uses commands to mount the IP address and shared folder path of the other electronic devices to the local electronic device, so that it can connect to the shared folder of the other electronic devices. In this way, the local electronic device can use commands to access the shared folder of the other electronic devices.
[0042] It should be noted that, Figure 1 The electronic devices shown can all be used as local electronic devices and are not limited to the examples above. In the embodiments of this application, the electronic devices to which the solution of this application applies are not limited to... Figure 1 The types shown can also include, for example, servers, cloud servers, server clusters, wearable devices, barcode scanners, routers, smart home devices, etc.
[0043] In this embodiment, the operating system of the local electronic device includes user space and kernel space. The core of the operating system is the kernel. To protect the security of the operating system kernel, existing operating systems generally prohibit user processes from directly manipulating the kernel. Instead, the operating system divides the virtual address space into two parts: user space and kernel space. User space is used by various processes, while kernel space is used by the kernel itself.
[0044] like Figure 2 As shown, Figure 2A schematic diagram of a user-mode file system architecture is shown. In this embodiment, the user-mode file system is distributed across the user space and kernel space of the electronic device's operating system. The user space contains applications (APPs) and the FUSE network file system, while the kernel space contains virtual file systems (VFS) and the network file system kernel driver (FUSE driver). When a process runs in user space, it is in user mode. The executed code is subject to numerous checks by the central processing unit (CPU), and can only access virtual addresses of pages accessible in user mode as specified in page table entries mapping other address spaces. When a process runs in kernel space, it is in kernel mode. In this state, the CPU can execute any instruction, and the running code is unrestricted, freely accessing any valid address.
[0045] The user-space file system FUSE provides users with a set of application program interfaces (APIs), allowing users to implement their own file systems in user space.
[0046] The following is combined with Figure 2 This section explains the implementation process of cross-device data access, using reading a block of data from a file as an example:
[0047] 1) Local electronic devices mount shared files and directories from other electronic devices to the local machine using the user-space file system. For example, the mount directory is / mnt / device2 / files. Here, device2 represents electronic device 2. Multiple other electronic devices can be mounted on a single local electronic device.
[0048] 2) When the application interface of the user space application APP receives a read request to read a block of data from the file / mnt / device2 / files, this read request is forwarded by the VFS in the kernel space to the FUSEDriver in the kernel space, and finally the read request is sent to the FUSE network file system in the user space.
[0049] 3) The FUSE network file system processes this read request and actually reads the corresponding data from other electronic devices across devices via network communication.
[0050] 4) The FUSE network file system returns the read data to the FUSE Driver in kernel space, and finally returns it to the APP in user space through the VFS in kernel space, completing the file data read process.
[0051] pass Figure 2 As can be seen from the above process, there are four switches between user space and kernel space. For applications with high throughput, high concurrency, and low latency requirements, such overhead is unacceptable.
[0052] Based on this, please refer to Figure 3 , Figure 3 This illustration shows an architecture diagram of a user-space file system provided in an embodiment of this application. Figure 3 As shown in this embodiment, an eBPF module is also arranged in the kernel space. The eBPF module is connected to the network file system kernel driver and is used by the network file system kernel driver for invocation. The eBPF module is used to run hook functions based on eBPF (extended Berkeley Packet Filter).
[0053] A hook function is a function that executes automatically when a specific event occurs. It is typically used to perform specific operations at different stages of program execution. In this embodiment, when the network file system kernel driver receives an operation request, it triggers the hook function of the eBPF module to run, thereby executing the target operation.
[0054] In this embodiment, a cache space is also configured. The FUSE network file system and the eBPF module can share the cache space via memory sharing. This cache space is used to cache data read from other electronic devices or data written to other electronic devices. The FUSE network file system and / or the eBPF module can store data in this cache space, and the eBPF module can also retrieve data from this cache space. The FUSE network file system can also delete data in the cache space based on preset rules.
[0055] The following is combined with Figure 3 and Figure 4 The implementation process of the cross-device data access method provided in the embodiments of this application will be described. Figure 4 A flowchart of a cross-device data access method provided in an embodiment of this application is shown. The method is applied to the aforementioned electronic device, which is a local electronic device, and includes steps 401 to 403.
[0056] Step 401: Obtain the operation request generated by the application, and in response to the operation request, forward the operation request to the network file system kernel driver through the virtual file system.
[0057] Step 402: Call the eBPF module through the network file system kernel driver to perform the target operation on the cache space and obtain the result of the first target operation.
[0058] Step 403: Feedback the result of the first target operation to the application through the virtual file system.
[0059] In this embodiment, the application (APP) runs in the user space of the electronic device's operating system. The APP generates an operation request in response to user actions and sends the operation request to the Virtual File System (VFS) in the kernel space. The VFS is a programming interface provided by the operating system kernel for applications, used for forwarding data. In this embodiment, the VFS can forward the operation request to the Network File System kernel driver (FUSE Driver).
[0060] An operation request is a cross-device data access request used to instruct an electronic device to access data from other electronic devices. Operation requests can be categorized into read and write operation types.
[0061] It should be noted that an operation request is used only to indicate access to another electronic device. Furthermore, an operation request can indicate access to multiple data items on another electronic device.
[0062] In this embodiment, after receiving an operation request, the FUSE Driver calls the eBPF module. The eBPF program is then executed by calling the eBPF module to implement the hook function. In this embodiment, the process of the hook function processing the operation request is the process of performing the target operation on the cache space.
[0063] In some implementations, the target operation can include multiple operations targeting different data.
[0064] In this embodiment of the application, the cache space is a storage space specifically allocated for the user-mode file system, used to cache data read from other electronic devices or data written to other electronic devices. Performing a target operation on the cache space is, for example, performing a read operation or a write operation on the data cached in the cache space.
[0065] In this embodiment, a first target operation result can be obtained after the target operation is completed. The FUSE Driver can then feed back the first target operation result to the APP in user space via VFS.
[0066] Combination Figure 3 and Figure 4 As can be seen, in this embodiment, by pre-caching data in the cache space and then truncating the operation request in the kernel space through the eBPF module, the operation request does not need to reach the FUSE network file system. In this way, the FUSE Driver can directly obtain the first target operation result from the cache space through the eBPF module and return it to the APP. Compared to the above-mentioned approach...Figure 2 The data processing flow is improved, reducing the number of interactions between the FUSEDriver in kernel space and the FUSE network file system in user space for each operation request. This helps to reduce the number of switches between user mode and kernel mode and the repeated copying of data between user mode and kernel mode, thereby improving the efficiency of cross-device data access and reducing latency.
[0067] In practical applications, various factors can influence the execution of target operations on the cache space, leading to either success or failure. For successful execution, the result of the first target operation can be directly obtained, which will not be elaborated upon here. For failure, the following section discusses... Figure 5 and Figure 6 To explain, Figure 5 A flowchart of another method for cross-device data access is shown. Figure 6 A logical diagram of a user-space file system is shown, the method including steps 501 to 503.
[0068] Step 501: In the event that the target operation fails, send an operation request to the FUSE network file system via the network file system kernel driver.
[0069] Step 502: Perform the target operation on the target electronic device associated with the operation request through the FUSE network file system to obtain the first target operation result.
[0070] Step 503: Update the first target operation result to the cache space through the FUSE network file system, and feed back the first target operation result to the network file system kernel driver, and feed back the first target operation result to the application through the virtual file system.
[0071] In this embodiment, when the eBPF module cannot find the required data in the cache space, or when the cache space is full and the eBPF module cannot write data, the target operation on the cache space will fail. The eBPF module will then report the execution status to the FUSE Driver, which will determine the subsequent execution logic based on the feedback.
[0072] In this embodiment of the application, when the FUSE Driver determines that the target operation has failed based on the execution feedback, such as Figure 6 As shown by the dashed arrow, the FUSE Driver can send this operation request to the FUSE network file system in user space.
[0073] After receiving the operation request, the FUSE network file system determines the target electronic device based on the device information associated with the operation request. The target electronic device is one of several other electronic devices mounted on the local electronic device. Then, the FUSE network file system performs the target operation on the target electronic device to obtain the first target operation result.
[0074] On the one hand, the FUSE network file system can return the result of the first target operation obtained after cross-device data access to the FUSE Driver in the kernel space, which then sends it to the VFS, and the VFS forwards it to the APP, so that the user can obtain the result of the first target operation through the APP.
[0075] On the other hand, the FUSE network file system can also update the cache space with the result of the first target operation. In this way, when the APP sends operation requests for the same data continuously, it can directly access the data from the cache space based on the content disclosed in steps 401 to 403, thereby improving data access efficiency.
[0076] In this embodiment, when the target operation fails to be executed in the cache space, the target operation is then executed across devices to the target electronic device through the FUSE network file system. This helps to reduce the number of times the target operation is executed across devices and also helps to reduce the number of user mode and kernel mode switches, thereby minimizing latency and improving efficiency.
[0077] Based on the above embodiments, the following is combined with Figure 7 This application describes the process of implementing cross-device data reading using the cross-device data access method provided in the embodiments of this application. The operation request is a read operation request, and the target operation is a read operation. Figure 7 A schematic diagram of the working logic of a FUSE Driver in processing read operation requests is shown, which includes steps 701 to 704.
[0078] Step 701: The FUSE Driver receives a read operation request forwarded by the VFS.
[0079] The read operation request includes an identifier for the data that the user needs to read.
[0080] Step 702: The eBPF module is invoked through the network file system kernel driver to search for the first target data corresponding to the read operation request in the cache space.
[0081] In this embodiment of the application, the data that the user needs to read is defined as the first target data.
[0082] Specifically, the eBPF module is invoked to perform target operations on the cache space, that is, the eBPF module is invoked to process the search for the first target data in the cache space through the read hook function of the eBPF program.
[0083] Step 703: Determine whether to return data. If so, return the first target data to VFS.
[0084] If the first target data is found, the first target data is read, and the result of the first target operation is determined based on the read first target data.
[0085] In this embodiment, the first target operation result includes the first target data. The eBPF module can return the first target data to the FUSE Driver, which can then send the first target operation result containing the first target data to the VFS, and finally the VFS sends the first target operation result to the APP.
[0086] Step 704: If not, read the first target data across devices via the FUSE network file system and return the first target data to the VFS.
[0087] In this embodiment of the application, if the first target data is not found in the cache space, the target operation failure is reported to the FUSE Driver. In this case, the FUSE Driver sends a read operation request to the FUSE network file system. In response to the read operation request, the FUSE network file system performs the target operation on the target electronic device associated with the read operation request, that is, reads the first target data from the target electronic device.
[0088] In one implementation, the FUSE network file system simultaneously caches the first target data and returns the result of the first target operation containing the first target data to the FUSEDriver.
[0089] In another implementation, the FUSE network file system simultaneously caches several data items following the initial target data, such as data from several pages after the read request, and updates the cache space. Finally, it returns the result of the first target operation, containing the initial target data, to the FUSEDriver. This pre-caching of data not yet accessed by the user facilitates direct retrieval from the cache for subsequent user accesses, thus improving data access efficiency.
[0090] The cross-device data access method provided in this application, through data pre-caching and truncating read operation requests based on the eBPF module, achieves the goal of obtaining cross-device data access from the local file system. This helps avoid multiple kernel-mode and user-mode switches and multiple data copies between user-mode and kernel-mode. It improves the performance of cross-device data reading and enhances the user experience in cross-device data access scenarios.
[0091] Since cache space requires memory, it cannot be infinitely large. Therefore, it is inevitable to consider the possibility of the cache space becoming full. Based on the above embodiments, this application provides a data management mechanism for cache space. The following, in conjunction with... Figure 8 Please provide an explanation. Figure 8 A schematic diagram of the data eviction mechanism for the cache space is shown.
[0092] like Figure 8 As shown, a cache space is added to the FUSE network file system to cache the data currently being read across devices (hereinafter referred to as files for ease of description), and the maximum value that each file can be cached and the maximum value of all cached files are set.
[0093] For example, if the page size is set to 4KB, the maximum cacheable size for a single file is (page size * N), where N is set to 1024. Setting the maximum data size for all cached files to 40MB allows for the simultaneous caching of 10 files, reaching the maximum cacheable size of 4MB for each file.
[0094] Specifically, when the cache size of a single file reaches 4MB, if further data for the file needs to be cached, a sliding window approach is used to evict lower-order pages. The sliding window mechanism manages the maximum amount of cached data for a single file. For example... Figure 8 As shown, when page(2+N) needs to be cached, page1 is evicted through a sliding window.
[0095] When the total size of all cached files reaches the maximum cacheable data size, if a new file needs to be cached, the LRU (Least Recently Used) algorithm is used to evict an already cached file.
[0096] This application embodiment uses a sliding window algorithm and an LRU algorithm to manage the eviction of data in the cache space, which can make the cache space more efficient and improve the efficiency of cross-device data access.
[0097] Based on the above embodiments, the following is combined with Figure 9 to Figure 11This application describes the process of implementing cross-device data writing using the cross-device data access method provided in the embodiments of this application. The operation request is a write operation request, and the target operation is a write operation. Figure 9 This diagram illustrates the working logic of a FUSE Driver in handling write operation requests. Figure 10 A logical diagram of a user-space file system is shown. Figure 11 A logical diagram of another user-space file system is shown. The process includes steps 901 to 902.
[0098] Step 901: The eBPF module is invoked through the network file system kernel driver to update the second target data corresponding to the write operation request in the cache space.
[0099] In this embodiment of the application, data written by a user to other electronic devices through a local electronic device is defined as second target data, wherein the second target data is associated with the identifier of the target electronic device to be written and a data identifier.
[0100] like Figure 10 As shown, when the FUSE Driver receives a write operation request, it calls the eBPF module to run the eBPF program to implement the hook function. In this embodiment, the hook function may include a read hook function and a write hook function. When the target operation is a read operation, the eBPF read hook function is run. When the target operation is a write operation, the eBPF write hook function is run.
[0101] In this embodiment, the second target data can be updated to the cache space by running the eBPF write hook function. When a user writes to the same file multiple times, by caching the second target data, the user can write or modify the cached second target data multiple times, thus avoiding frequent cross-device writes and saving resources.
[0102] In some implementations, the cache space includes a read data cache space and a write data cache space. The read data cache space is used to cache the first target data corresponding to the read operation, and the write data cache space is used to cache the second target data corresponding to the write operation.
[0103] In this embodiment of the application, multiple second target data can be cached in the cache space, and the multiple second target data can correspond to the same other electronic device or to different other electronic devices.
[0104] In practical applications, cache space is not infinitely large. Therefore, after the second target data is cached, it needs to be written to its final location—the target electronic device corresponding to the second target data—as soon as possible. Based on this, such as Figure 11As shown by the dashed line, in this embodiment of the application, the FUSE network file system writes the second target data cached in the cache space across devices to the corresponding target electronic device. The FUSE network file system can obtain feedback information from the target electronic device.
[0105] Optionally, the FUSE network file system can send feedback information to the FUSE Driver, which is then fed back to the application by the VFS.
[0106] In one implementation, when the size of the second target data in the cache space exceeds a preset threshold, the second target data is written to the corresponding target electronic device through the FUSE network file system.
[0107] In another implementation, the second target data is periodically written to the corresponding target electronic device via the FUSE network file system.
[0108] Step 902: The operation success message is fed back to the network file system kernel driver as the first target operation result.
[0109] In this embodiment, after the second target data is successfully updated in the cache space, the eBPF module can send a success message to the network file system kernel driver and use the success message as the result of the first target operation. Finally, the VFS sends the result of the first target operation to the APP.
[0110] This application embodiment improves the write performance of the FUSE network file system through an eBPF program. Write requests to the FUSE network file system are truncated in the kernel, and the written data is written to a cache. After caching a certain size of file data, the user-space FUSE network file system writes the data to other devices all at once.
[0111] The above text combined Figure 1 to Figure 11 The method embodiments of this application are described in detail below, in conjunction with... Figure 12 The present application provides a detailed description of the apparatus embodiments. It should be understood that the descriptions of the method embodiments correspond to the descriptions of the apparatus embodiments; therefore, any parts not described in detail can be found in the foregoing method embodiments.
[0112] This application provides a cross-device data access device, such as... Figure 12 As shown, Figure 12A block diagram of a cross-device data access apparatus is shown. This apparatus is applied to an electronic device whose operating system includes user space and kernel space. The user space contains applications and a FUSE network file system, while the kernel space contains a virtual file system, a network file system kernel driver, and an eBPF module. The FUSE network file system and the eBPF module share a cache space. The apparatus includes: an acquisition module 1201, used to acquire operation requests generated by the application and, in response to the operation requests, forward the operation requests to the network file system kernel driver via the virtual file system; an access module 1202, used to invoke the eBPF module through the network file system kernel driver to perform a target operation on the cache space and acquire a first target operation result; the cache space is used to cache data read from or written to other electronic devices; and a feedback module 1203, used to feed back the first target operation result to the application via the virtual file system.
[0113] In one embodiment, the access module 1202 is further configured to: send an operation request to the FUSE network file system via the network file system kernel driver in the event of a target operation failure; perform the target operation on the target electronic device associated with the operation request via the FUSE network file system to obtain a first target operation result; update the first target operation result to the cache space via the FUSE network file system; and feed back the first target operation result to the network file system kernel driver, and feed back the first target operation result to the application via the virtual file system.
[0114] In one embodiment, the operation request is a read operation request, the target operation is a read operation, and the access module 1202 is further configured to: call the eBPF module through the network file system kernel driver to search for the first target data corresponding to the read operation request in the cache space; if the first target data is found, read the first target data and determine the first target operation result based on the read first target data.
[0115] In one embodiment, the access module 1202 is further configured to: if the first target data is not found, report a target operation failure to the network file system kernel driver.
[0116] In one embodiment, the operation request is a write operation request, the target operation is a write operation, and the access module 1202 is further configured to: call the eBPF module through the network file system kernel driver to update the second target data corresponding to the write operation request in the cache space; and feed back the operation success message as the result of the first target operation to the network file system kernel driver.
[0117] In one embodiment, the access module 1202 is further configured to: when the size of the second target data in the cache space exceeds a preset threshold, write the second target data to the corresponding target electronic device through the FUSE network file system.
[0118] In one embodiment, the access module 1202 is further configured to: evict cached data in the cache space using a sliding window algorithm and / or an LRU algorithm.
[0119] Specific limitations regarding the cross-device data access device can be found in the limitations of the cross-device data access method described above, and will not be repeated here. Each module in the aforementioned cross-device data access device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations of each module.
[0120] Figure 13 A block diagram of an electronic device is shown. Figure 13 The illustrated electronic device 1300 may include a memory 1310, a processor 1320, and an input / output interface 1330. The memory 1310, processor 1320, and input / output interface 1330 are connected via internal interconnections. The memory 1310 stores instructions, and the processor 1320 executes the instructions stored in the memory 1310 to control the input / output interface 1330 to receive input data and information, and output operation results and other data.
[0121] The electronic device may further include a baseband unit, a radio frequency integrated circuit (RFIC), a radio frequency front end (RFFE) device, and an antenna (ANT), which can be coupled via various interconnect buses or other electrical connection methods. This electronic device can implement the cross-device data access method disclosed in any of the above embodiments.
[0122] It should be understood that in the embodiments of this application, the processor 1320 may be a general-purpose central processing unit (CPU), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits to execute relevant programs in order to implement the technical solutions provided in the embodiments of this application.
[0123] The memory 1310 may include read-only memory and random access memory, and provides instructions and data to the processor 1320. A portion of the processor 1320 may also include non-volatile random access memory. For example, the processor 1320 may also store device type information.
[0124] In implementation, each step of the above method can be completed by the integrated logic circuitry of the hardware in the processor 1320 or by instructions in software form. The cross-device data access method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules in the processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 1310, and the processor 1320 reads the information in memory 1310 and completes the steps of the above method in conjunction with its hardware. To avoid repetition, detailed descriptions are not provided here.
[0125] It should be understood that in the embodiments of this application, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0126] In one embodiment of this application, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the cross-device data access method described in the above embodiments. The implementation process can be referred to the content disclosed in the above embodiments, and will not be repeated here.
[0127] The above description is merely a specific embodiment 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 scope of the technology 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 method for cross-device data access, characterized in that, The method is applied to an electronic device, wherein the operating system of the electronic device includes a user space and a kernel space, the user space is configured with applications and a FUSE network file system, and the kernel space is configured with a virtual file system, a network file system kernel driver, and an eBPF module, the FUSE network file system and the eBPF module sharing a cache space, the method comprising: Obtain the operation request generated by the application, and in response to the operation request, forward the operation request to the network file system kernel driver through the virtual file system; The network file system kernel driver calls the eBPF module to perform a target operation on the cache space and obtains the first target operation result; the cache space is used to cache data read from other electronic devices or data written to other electronic devices. The result of the first target operation is fed back to the application through the virtual file system; The method further includes: In the event that the target operation fails, the operation request is sent to the FUSE network file system via the network file system kernel driver. The target operation is performed on the target electronic device associated with the operation request through the FUSE network file system to obtain the first target operation result, which includes the first target data; The first target data is updated to the cache space through the FUSE network file system, and several data items following the first target data are cached in the cache space.
2. The method according to claim 1, characterized in that, The operation request is a read operation request, the target operation is a read operation, and the step of calling the eBPF module through the network file system kernel driver to perform the target operation on the cache space and obtain the first target operation result includes: The network file system kernel driver calls the eBPF module to search for the first target data corresponding to the read operation request in the cache space; If the first target data is found, the first target data is read and the result of the first target operation is determined based on the read first target data.
3. The method according to claim 2, characterized in that, The method further includes: If the first target data is not found, a target operation failure is reported to the network file system kernel driver.
4. The method according to claim 1, characterized in that, The operation request is a write operation request, the target operation is a write operation, and the step of calling the eBPF module through the network file system kernel driver to perform the target operation on the cache space and obtain the first target operation result includes: The network file system kernel driver calls the eBPF module to update the second target data corresponding to the write operation request in the cache space; The operation success message is fed back to the network file system kernel driver as the result of the first target operation.
5. The method according to claim 4, characterized in that, The method further includes: When the size of the second target data in the cache space exceeds a preset threshold, the second target data is written to the corresponding target electronic device through the FUSE network file system.
6. The method according to claim 1, characterized in that, The method further includes: The cached data in the cache space is evicted using a sliding window algorithm and / or an LRU algorithm.
7. A cross-device data access device, characterized in that, An electronic device, wherein the operating system of the electronic device includes a user space and a kernel space, the user space hosting applications and a FUSE network file system, and the kernel space hosting a virtual file system, a network file system kernel driver, and an eBPF module, wherein the FUSE network file system shares a cache space with the eBPF module, the device comprising: The acquisition module is used to acquire the operation request generated by the application, and in response to the operation request, forward the operation request to the network file system kernel driver through the virtual file system; An access module is used to call the eBPF module through the network file system kernel driver to perform a target operation on the cache space and obtain a first target operation result; the cache space is used to cache data read from other electronic devices or data written to other electronic devices. The feedback module is used to feed back the result of the first target operation to the application through the virtual file system; The device is also used for: In the event that the target operation fails, the operation request is sent to the FUSE network file system via the network file system kernel driver. The target operation is performed on the target electronic device associated with the operation request through the FUSE network file system to obtain the first target operation result, which includes the first target data; The first target data is updated to the cache space through the FUSE network file system, and several data items following the first target data are cached in the cache space.
8. An electronic device, characterized in that, The operating system of the electronic device includes a user space and a kernel space. The user space contains applications and a FUSE network file system. The kernel space contains a virtual file system, a network file system kernel driver, and an eBPF module. The FUSE network file system shares a cache space with the eBPF module. The electronic device also includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, it implements the method of any one of claims 1 to 6.
9. A computer storage medium, characterized in that, It stores a computer program thereon, which, when executed by a processor, implements the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
File operation method of user space file system and user space file system
CN114860670A