File access method and electronic device
By determining whether a file is cached in the first electronic device, and then reading it directly from the local device or after caching, the problem of long access times to files on the other device is solved, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2023-12-29
- Publication Date
- 2026-04-17
AI Technical Summary
Accessing files on the other end's electronic device takes a long time, causing a lag in the user experience.
By determining whether a file is cached in the first electronic device, if it is cached, it is read directly from the local device; otherwise, it is retrieved from the peer device and cached, thus reducing data interaction time.
This reduces file reading time, avoids lag, and improves the user experience.
Smart Images

Figure CN120282122B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and more specifically, to a file access method and an electronic device. Background Technology
[0002] With the continuous development of terminal technology, the number of electronic devices people own is gradually increasing. To facilitate user operation, multiple electronic devices owned by the same user can typically access and obtain files from each other.
[0003] For example, user A owns both a mobile phone 100 and a portable Android device (Pad) 200. The Pad 200 stores photos 201, and user A can access these photos from the mobile phone 100. In one possible scenario, user A could add photo 201 to a global favorites application (App) on the Pad 200, then open the global favorites app on the mobile phone 100, locate photo 201 in the app, and read it. However, since the mobile phone 100 needs to read photo 201 from the Pad 200 every time, this would result in a longer reading time, potentially causing lag and negatively impacting the user experience.
[0004] Therefore, how to reduce the time required to access files on the other end of an electronic device has become an urgent problem to be solved. Summary of the Invention
[0005] This application provides a file access method that can reduce the time required to access files in a peer electronic device.
[0006] Firstly, a file access method is provided, applied to a first electronic device, the method comprising:
[0007] In response to the first operation, it is determined whether the first file is cached on the first electronic device, the first file is a file stored on the second electronic device, and the first operation is an operation to read the first file;
[0008] If the first file is cached on the first electronic device, read the first file from the first electronic device.
[0009] The file access method provided in this application is applied to a first electronic device. By responding to a first operation, it determines whether a first file stored in a second electronic device is cached in the first electronic device. If the first file is cached in the first electronic device, it is read directly from the first electronic device. Since data interaction between the first and second electronic devices takes a period of time, the file access method provided in this application can avoid the process of the first electronic device obtaining the first file from the second electronic device, reducing the time required to read the first file, thereby avoiding lag caused by long reading time and improving user experience.
[0010] In conjunction with the first aspect, in some embodiments of the first aspect, determining whether the first file is cached in the first electronic device includes: determining first identification information of the first file; searching in the first electronic device based on the first identification information to determine whether the first file is cached in the first electronic device.
[0011] In conjunction with the first aspect, in some embodiments of the first aspect, determining whether a first file is cached in a first electronic device based on the first identification information includes: searching for a second file in the first electronic device based on the first identification information, wherein the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; if the second file exists in the first electronic device, then the second file is the first file.
[0012] In conjunction with the first aspect, in some embodiments of the first aspect, the method further includes: if the first file is not cached in the first electronic device, obtaining the first file from a second electronic device; and caching the first file in the first electronic device.
[0013] The file access method provided in this application embodiment obtains the first file from the second electronic device when the first file is not cached in the first electronic device, and caches the first file in the cache module of the first electronic device. This allows the first file to be read from the cache module of the first electronic device the next time it is read, avoiding the process of the first electronic device obtaining the first file from the second electronic device again. This reduces the time required to read the first file the next time, thereby avoiding lag caused by long reading time and improving the user experience.
[0014] In conjunction with the first aspect, in some embodiments of the first aspect, matching the index information of the first file and the index information of the second file includes: the index information of the first file and the index information of the second file completely matching, and the index information of the first file and the index information of the second file partially matching. If the index information of the first file and the index information of the second file partially match, a first sub-file in the first file is cached in the first electronic device, wherein the first sub-file is a portion of the file whose index information matches the index information of the second file. Reading the first file from the cache module of the first electronic device includes: reading the first sub-file from the first electronic device; the method further includes: reading the second sub-file from the second electronic device, wherein the second sub-file is a sub-file in the first file other than the first sub-file.
[0015] The file access method provided in this application, when determining whether the index information of the first file matches the index information of the second file, if the index information of the first file partially matches the index information of the second file, then reads the first sub-file that matches the index information of the first file from the first electronic device, and reads the second sub-file that matches the index information of the first file from the second electronic device. This allows the cached sub-file to be read when the first file is partially cached in the first electronic device. Compared with reading the entire first file from the second electronic device, this reduces the time required to read the first file, reduces the possibility of lag caused by long retrieval time, and improves the user experience.
[0016] In conjunction with the first aspect, in some embodiments of the first aspect, the method further includes: modifying a first file in a first electronic device in response to a second operation, the second operation being used to modify the first file.
[0017] In conjunction with the first aspect, in some embodiments of the first aspect, the first electronic device includes a disk cache file read / write module and a disk cache data storage module. In response to the first operation, determining whether a first file is cached in the disk cache data storage module includes: in response to the first operation, the disk cache file read / write module determines whether the first file is cached in the disk cache data storage module; if the first file is cached in the first electronic device, reading the first file from the first electronic device includes: if the first file is cached in the disk cache data storage module, the disk cache file read / write module reads the first file from the disk cache data storage module.
[0018] In conjunction with the first aspect, in some embodiments of the first aspect, the disk cache file read / write module determines whether the first file is cached in the disk cache data storage module, including: the disk cache file read / write module determines the first identification information of the first file; the disk cache file read / write module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module.
[0019] In conjunction with the first aspect, in some embodiments of the first aspect, the disk cache file read / write module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module, including: the disk cache file read / write module searches in the disk cache data storage module based on the first identification information, wherein the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; if the second file exists in the disk cache data storage module, then the second file is the first file.
[0020] In conjunction with the first aspect, in some embodiments of the first aspect, the method further includes: if the first file is not cached in the disk cache data storage module, the disk cache file read / write module obtains the first file from the second electronic device; the disk cache file read / write module caches the first file in the disk cache data storage module.
[0021] In conjunction with the first aspect, in some embodiments of the first aspect, the first electronic device includes a disk cache data storage module and a disk cache file read / write module. Matching the index information of the first file and the index information of the second file includes: the index information of the first file and the index information of the second file completely matching, and the index information of the first file and the index information of the second file partially matching. If the index information of the first file and the index information of the second file partially match, a first sub-file of the first file is cached in the disk cache data storage module, wherein the first sub-file is a portion of the file in the first file whose index information matches the index information of the second file. The disk cache file read / write module reads the first file from the disk cache data storage module, including: the disk cache file read / write module reads the first sub-file from the disk cache data storage module. The method further includes: the disk cache file read / write module reads the second sub-file from the second electronic device, wherein the second sub-file is a sub-file in the first file other than the first sub-file.
[0022] In conjunction with the first aspect, in some embodiments of the first aspect, the method further includes: in response to a second operation, the disk cache file read / write module modifies a first file in the disk cache data storage module, the second operation being used to modify the first file.
[0023] In conjunction with the first aspect, in some embodiments of the first aspect, the disk cache file read / write module is further configured to determine whether the remaining space of the disk cache data storage module is less than a preset threshold during the process of modifying the first file of the disk cache data storage module, and if the remaining space of the disk cache data storage module is less than the preset threshold, send the modified first file to the second electronic device.
[0024] In conjunction with the first aspect, in some embodiments of the first aspect, the first electronic device further includes a disk cache upper limit management module, which is used to determine the maximum storage space of the disk cache data storage module based on the remaining memory space of the first electronic device.
[0025] In conjunction with the first aspect, in some embodiments of the first aspect, the first file includes image files, video files, and document files.
[0026] Secondly, a file access apparatus is provided, including a unit for performing any of the methods in the first aspect. The apparatus may be a server, a terminal device, or a chip within a terminal device. The apparatus may include an input unit and a processing unit.
[0027] When the device is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may also include a memory for storing computer program code, which, when the processor executes the computer program code stored in the memory, causes the terminal device to perform any of the methods in the first aspect.
[0028] When the device is a chip within a terminal device, the processing unit can be an internal processing unit of the chip, and the input unit can be an output interface, pin, or circuit, etc.; the chip may also include a memory, which can be an internal memory of the chip (e.g., a register, cache, etc.) or an external memory (e.g., a read-only memory, random access memory, etc.); the memory is used to store computer program code, and when the processor executes the computer program code stored in the memory, the chip performs any of the methods in the first aspect.
[0029] In one possible implementation, the memory is used to store computer program code; the processor executes the computer program code stored in the memory, and when the computer program code stored in the memory is executed, the processor is used to perform: in response to a first operation, determining whether a first file is cached in a first electronic device, the first file being a file stored in a second electronic device, the first operation being an operation to read the first file; if the first file is cached in the first electronic device, reading the first file from the first electronic device.
[0030] Thirdly, a computer-readable storage medium is provided, the computer-readable storage medium storing computer program code, which, when executed by a file access device, causes the file access device to perform any of the file access methods in the first aspect.
[0031] Fourthly, a computer program product is provided, the computer program product comprising: computer program code, which, when executed by a file access device, causes the file access device to perform any of the apparatus methods in the first aspect.
[0032] The file access method provided in this application is applied to a first electronic device. By responding to a first operation, it determines whether a first file stored in a second electronic device is cached in the first electronic device. If the first file is cached in the first electronic device, it is read directly from the first electronic device. Since data interaction between the first and second electronic devices takes a period of time, the file access method provided in this application can avoid the process of the first electronic device obtaining the first file from the second electronic device, reducing the time required to read the first file, thereby avoiding lag caused by long reading time and improving user experience. Attached Figure Description
[0033] Figure 1(a) is a schematic diagram of the interface for two electronic devices to log in to one account;
[0034] Figure 1(b) is a schematic diagram of adding files to global favorites on a tablet computer;
[0035] Figure 1(c) is a schematic diagram of enabling global favorites;
[0036] Figure 1(d) is a schematic diagram of a global collection interface;
[0037] Figure 2 This is a diagram illustrating the process of enabling the display of images in the global collection.
[0038] Figure 3 This is a diagram illustrating the process of enabling videos in the global favorites.
[0039] Figure 4 This is a diagram illustrating the process of enabling the display of documents opened in global favorites;
[0040] Figure 5 This is a schematic diagram of a hardware system for an electronic device applicable to this application;
[0041] Figure 6 This is a schematic diagram of a software system applicable to an electronic device of this application;
[0042] Figure 7 This is a schematic diagram of a software system applicable to an electronic device of this application;
[0043] Figure 8 This is a schematic diagram of a file directory structure applicable to this application;
[0044] Figure 9 This is a schematic diagram of a software system applicable to an electronic device of this application;
[0045] Figure 10 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application;
[0046] Figure 11 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application;
[0047] Figure 12 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application;
[0048] Figure 13 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0049] Figure 14 This is a schematic diagram of an index information provided in an embodiment of this application;
[0050] Figure 15 This is a schematic diagram of an index information provided in an embodiment of this application;
[0051] Figure 16 This is a schematic diagram of metadata information provided in an embodiment of this application;
[0052] Figure 17 This is a schematic diagram of metadata information provided in an embodiment of this application;
[0053] Figure 18 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0054] Figure 19 This is a schematic diagram of an index information provided in an embodiment of this application;
[0055] Figure 20 This is a schematic diagram of metadata information provided in an embodiment of this application;
[0056] Figure 21 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0057] Figure 22 This is a schematic diagram of an index information provided in an embodiment of this application;
[0058] Figure 23 This is a schematic diagram of metadata information provided in an embodiment of this application;
[0059] Figure 24 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0060] Figure 25 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0061] Figure 26 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0062] Figure 27 This is a flowchart illustrating a file access method provided in an embodiment of this application;
[0063] Figure 28 This is a schematic diagram of a file access device provided in this application;
[0064] Figure 29 This is a schematic diagram of an electronic device for image processing provided in this application. Detailed Implementation
[0065] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0066] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.
[0067] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0068] Global Collections is an application that enables file sharing between multiple electronic devices. Users can log in to multiple electronic devices with the same account, and any of these devices can save local files to the Global Collections app, allowing other devices to access those files through the app. Global Collections makes file management easier for users.
[0069] For example, a user logs into account "1111" on both mobile phone 100 and PAD 200, as shown in Figure 1(a). The user can add photos 201, videos 202, and documents 203 from PAD 200 to the Global Collection App 204, as shown in Figure 1(b). When the user clicks to open the Global Collection App 204 on mobile phone 100, as shown in Figure 1(c), thumbnails of photos 201, videos 202, and documents 203 are displayed on the display frame 2041 of the Global Collection App 204 on mobile phone 100, as shown in Figure 1(d).
[0070] When a user clicks on the thumbnail of photo 201, such as Figure 2 As shown in (a) above. In response to the user clicking the thumbnail of photo 201, mobile phone 100 reads photo 201 from PAD 200. After a period of waiting, a loading screen is displayed on mobile phone 100, as shown below. Figure 2 As shown in (b) above. After the phone 100 finishes loading photo 201, the complete image of photo 201 will be displayed on the phone 100, as shown below. Figure 2 As shown in (c) in the figure.
[0071] When a user clicks on the thumbnail of video 202, such as Figure 3 As shown in (a) above. In response to the user clicking the thumbnail of video 202, mobile phone 100 reads video 202 from PAD 200. After a period of waiting, a loading screen is displayed on mobile phone 100, as shown below. Figure 3 As shown in (b) above. After the mobile phone 100 finishes loading video 202, the complete video of video 202 will be displayed on the mobile phone 100, as shown below. Figure 3 As shown in (c) in the figure.
[0072] When a user clicks on the thumbnail of document 203, such as Figure 4 As shown in (a) above. In response to the user clicking the thumbnail of document 203, mobile phone 100 reads document 203 from PAD 200. After a period of waiting, a loading interface is displayed on mobile phone 100, as shown below. Figure 4 As shown in (b) above. After the mobile phone 100 finishes loading document 203, the content of document 203 will be displayed on the mobile phone 100, as shown below. Figure 4 As shown in (c) in the figure.
[0073] However, when the mobile phone 100 reads the photos 201, videos 202, and documents 203 from the PAD 200, it usually takes a long time to retrieve the relevant data from the PAD 200. This may cause the user to experience lag when viewing the photos 201, videos 202, and documents 203 on the mobile phone 100, affecting the user experience.
[0074] In view of this, this application provides a file access method applied to a first electronic device. By responding to a first operation, it determines whether a first file stored in a second electronic device is cached in the cache module of the first electronic device. If the first file is cached in the cache module of the first electronic device, the first file is read directly from the cache module of the first electronic device. Since data interaction between the first and second electronic devices requires a certain amount of time, the file access method provided in this application can avoid the process of the first electronic device obtaining the first file from the second electronic device, reducing the time required to read the first file, thereby avoiding lag caused by long reading time and improving user experience.
[0075] The file access method provided in this application can be applied to a first electronic device. Optionally, the first electronic device includes a terminal device, which can also be called a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device can be a mobile phone, smart TV, wearable device, tablet computer, computer with wireless transceiver function, virtual reality (VR) terminal device, augmented reality (AR) terminal device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, etc. The embodiments of this application do not limit the specific technology or device form used in the terminal device.
[0076] For example, Figure 5A schematic diagram of the structure of the first electronic device 100 is shown. The first electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0077] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0078] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0079] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0080] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0081] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0082] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0083] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0084] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0085] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0086] It should be noted that any electronic device mentioned in the embodiments of this application may include more or fewer modules in electronic device 100.
[0087] The first electronic device and the second electronic device share files. The structure of the second electronic device is similar to that of the first electronic device, so we will not go into the details here.
[0088] The software system of the first electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of the first electronic device 100.
[0089] Figure 6 This is a software structure block diagram of the first electronic device 100 according to an embodiment of this application.
[0090] The layered architecture of the first electronic device 100 divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0091] The application layer can include a series of application packages.
[0092] like Figure 6 As shown, the application package may include applications such as global collections and distributed file client modules.
[0093] The distributed file client module can include a message sending and receiving module, a metadata management module, a file management module, and a disk storage module.
[0094] In one possible case, such as Figure 7 As shown, the disk storage module may include a disk cache logic module and a disk cache storage module. The disk cache logic module may include a disk cache limit management module, a disk cache file read / write module, and a disk cache cleanup module; the disk cache storage module may include a disk cache metadata storage module and a disk cache data storage module.
[0095] The disk cache logic module can be used to manage the upper limit of the disk cache, clear the cache, and manage the read and write logic of cache files. The disk cache storage module can be used to store the metadata and files of files read from a distributed file server of another electronic device.
[0096] The following describes the specific structure of the disk cache storage module and the storage format of the stored files.
[0097] Each file stored in the disk cache storage module has a unique ID. For example, as shown in Table 1, the ID of a file stored in the disk cache storage module can be 32 bits, where the first 6 bits can be used to indicate the file type, and the last 26 bits can be an unsigned integer generated by hashing the absolute path of the file.
[0098] Table 1
[0099]
[0100] Files stored in the disk cache storage module can be stored using a three-level directory structure, such as... Figure 8 As shown in Table 2, the first-level directory is represented by 6 bits for the file type, the second-level directory by the middle 14 bits, and the third-level directory by the last 16 bits. The cached data for each file is stored in two files named `index` and `default`, respectively. The `index` file stores the cached file index information, the specific file fragment cached locally, and file modification information, etc., as shown in Table 2. The `default` file stores the cached file content, which corresponds exactly to the file content stored in the server's electronic device. It should be understood that the `index` information is read from the local cache into memory when the service starts and saved to the local cache when the service is destroyed.
[0101] Table 2
[0102] type information 16-bit unsigned integer Version number 16-bit unsigned integer Has data been written? 64-bit unsigned integer Cache file size 64-bit unsigned integer Write data size 64-bit unsigned integer File segment size (reading index information) 64-bit unsigned integer File segment offset (reading index information) 64-bit unsigned integer File segment offset (written index information) 64-bit unsigned integer File segment offset (written index information)
[0103] The disk cache metadata storage module is used to cache file metadata information. The cached file metadata information can be shown in Table 3, including version number, file ID, last access time, and last modification time. The file metadata information is read from the local cache into memory when the service starts and saved to the local cache when the service is destroyed.
[0104] Table 3
[0105] type information 16-bit unsigned integer Version number 16-bit unsigned integer Do you want to keep this file? 32-bit unsigned integer File ID 64-bit unsigned integer Last access time of the file 64-bit unsigned integer Last modified time of the file
[0106] The disk cache limit management module is used to manage the disk cache limit and adjust the maximum remaining disk cache space based on the remaining disk space on the phone.
[0107] For example:
[0108] When the phone's disk has more than 10GB of free space, the disk cache limit will be set to 2GB.
[0109] When the remaining space on the phone's disk is less than 10GB but greater than 5GB, the upper limit of the disk cache will be set to 10% of the remaining space on the phone's disk.
[0110] When the remaining space on the phone's disk is less than 5GB, the upper limit of the disk cache will be set to 0GB.
[0111] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0112] like Figure 6 As shown, the application framework layer may include standard Portable Operating System Interface (POSIX), etc.
[0113] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0114] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0115] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0116] The system library can include multiple functional modules. For example, a surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc., are not shown in the figure.
[0117] The kernel layer is the layer between hardware and software. It can include the Linux kernel module and the FUSE user-space file system framework module, among others.
[0118] The application-level global collection can sequentially call the distributed file client module through the POSIX, Linux kernel module, and FUSE user-space file system framework module to access the distributed file server module on another electronic device, thereby enabling file sharing between the two electronic devices.
[0119] It should be noted that the first electronic device mentioned in the embodiments of this application may include more or fewer modules of the above-mentioned electronic device.
[0120] The software system of the second electronic device 200 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. Similar to the first electronic device 100, the Android system is divided into four layers, from top to bottom: application layer, application framework layer, Android runtime and system libraries, and kernel layer.
[0121] The application layer can include a series of application packages.
[0122] like Figure 9 As shown, the application package may include applications such as a global collection and a distributed file server module.
[0123] The distributed file server module includes a message sending and receiving module and a file operation processing module.
[0124] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0125] like Figure 9 As shown, the application framework layer may include standard POSIX interfaces, etc.
[0126] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0127] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0128] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0129] The system library can include multiple functional modules. For example, a surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc., are not shown in the figure.
[0130] The kernel layer is the layer between hardware and software. The kernel layer includes modules such as the local file system.
[0131] It should be noted that the second electronic device mentioned in the embodiments of this application may include more or fewer modules of the above-mentioned electronic device.
[0132] It should be understood that the software framework layers of the first electronic device and the second electronic device described above are only examples. Since the first electronic device and the second electronic device may include more or fewer modules, in one possible case, the architecture of the first electronic device and the second electronic device in the software framework layer may be the same. This application embodiment does not limit this.
[0133] It should be understood that the first electronic device can transmit data with the message sending and receiving module in the distributed file client module of the application layer of the second electronic device through the message sending and receiving module in the distributed file server module of the application layer, so as to realize file sharing between the first electronic device and the second electronic device.
[0134] The application scenarios provided by the embodiments of this application are described below with reference to the accompanying drawings.
[0135] As shown in Figure 1(a), the user has logged into the account "1111" on both the mobile phone 100 and the PAD 200. The user can add photos 201, videos 202, and documents 203 from the PAD 200 to the Global Collection App 204, as shown in Figure 1(b). When the user clicks to open the Global Collection App 204 on the 100, as shown in Figure 1(c), thumbnails of photos 201, videos 202, and documents 203 are displayed on the display frame 2041 of the Global Collection App 204 on the mobile phone 100, as shown in Figure 1(d).
[0136] When a user clicks on the thumbnail of photo 201, such as Figure 10As shown in (a) above. In response to the user clicking the thumbnail of photo 201, mobile phone 100 directly reads the cached photo 201 in mobile phone 100 and displays the full image of photo 201 on mobile phone 100, as shown below. Figure 10 As shown in (b) of the diagram. In this case, there is no need to wait for photo 201 to be read from PAD 200 during the process of reading photo 201.
[0137] When a user clicks on the thumbnail of video 202, such as Figure 11 As shown in (a) above. In response to the user clicking the thumbnail of video 202, mobile phone 100 directly reads the cached video 202 in mobile phone 100 and displays the full video of video 202 on mobile phone 100, as shown in (a). Figure 11 As shown in (b) of the diagram. In this case, there is no need to wait for video 202 to be read from PAD 200 during the reading process.
[0138] When a user clicks on the thumbnail of document 203, such as Figure 12 As shown in (a) above. In response to the user clicking the thumbnail of document 203, mobile phone 100 directly reads the cached document 203 in mobile phone 100 and displays the content of document 203 on mobile phone 100, as shown in (a). Figure 12 As shown in (b) above. In this case, there is no need to wait for document 203 to be read from PAD 200 during the process of reading document 203. In one possible scenario, as... Figure 12 As shown in (c), the user modifies document 203 on mobile phone 100. Mobile phone 100 will then send the updated document 203 to PAD 200 so that the document 203 stored on PAD 200 is also the updated document 203, as shown in (c). Figure 12 As shown in (d) in the figure.
[0139] It should be understood that the above are illustrative examples of application scenarios and do not limit the application scenarios of this application in any way.
[0140] The following is combined Figures 13 to 27 The file access method provided in the embodiments of this application will be described in detail.
[0141] For ease of understanding, the following embodiments use the mobile phone 100 as the first electronic device and the PAD 200 as the second electronic device for illustration.
[0142] Firstly, through Figure 13 The illustrated embodiment describes how mobile phone 100 accesses image A stored in PAD 200.
[0143] It should be noted that image data is usually small, so the phone can retrieve all image data at once; it's unlikely that the phone will only cache a portion of the image data. This is understandable. Figure 13 The illustrated embodiment is merely an example, and this application does not limit the types of files accessed. Figure 13 In the illustrated embodiment, mobile phone 100 can access files with relatively small file sizes.
[0144] Figure 13 This is a flowchart illustrating a file access method provided in an embodiment of this application, such as... Figure 13 As shown, the method includes:
[0145] S11, Receive the user's first operation.
[0146] The first operation can refer to the user clicking on the thumbnail of image A in the global collection app on mobile phone 100. It is understood that the first operation can be the aforementioned click operation, or it can be opening image A in the global collection app on mobile phone 100 via voice command, or it can be opening image A in the global collection app on mobile phone 100 via other commands; this embodiment does not limit this.
[0147] S12. In response to the first operation, the Global Collection App sends a request to the Linux kernel module.
[0148] The request is used to retrieve the storage address information of image A. It's understandable that the global collection app cannot directly send messages to the message sending and receiving module in the distributed file client module; it can only send messages to the distributed file client module through the Linux kernel module and the FUSE user-space file system framework module.
[0149] S13, The Linux kernel module sends a request to the FUSE user-space file system framework module.
[0150] S14, the FUSE user-space file system framework module sends a request to the file management module.
[0151] S15, The file management module sends a request to the message sending and receiving module in the mobile phone 100.
[0152] S16, the message transceiver module in mobile phone 100 sends an acquisition request to the message transceiver module in PAD 200.
[0153] The message sending and receiving module in the distributed file client module can send messages to the message sending and receiving module in the distributed file server module. Therefore, message transmission between mobile phone 100 and PAD 200 needs to be transmitted from the message sending and receiving module in mobile phone 100 to the message sending and receiving module in PAD 200.
[0154] S17, the message sending and receiving module in PAD 200 sends a request to the file operation processing module.
[0155] S18. The file operation processing module sends a request to the local file system module.
[0156] S19. The local file system module responds to the retrieval request and obtains the file handle corresponding to image A.
[0157] It is understandable that the file handle corresponding to image A can be a pointer to the storage address of image A, and the storage address of image A can be determined through the file handle corresponding to image A.
[0158] S110, The local file system module returns the file handle corresponding to image A to the file operation processing module.
[0159] S111, The file operation processing module returns the file handle corresponding to image A to the message sending and receiving module in PAD 200.
[0160] S112, the message transceiver module in PAD 200 returns the file handle corresponding to image A to the message transceiver module in mobile phone 100.
[0161] S113, The message sending and receiving module in mobile phone 100 returns the file handle corresponding to image A to the file management module.
[0162] S114. The file management module returns the file handle corresponding to image A to the FUSE user-mode file system framework module.
[0163] S115, the FUSE user-space file system framework module returns the file handle corresponding to image A to the Linux kernel module.
[0164] S116, The Linux kernel module returns the file handle corresponding to image A to the global collection app.
[0165] S117. The Global Collection App generates a read request for image A based on the file handle corresponding to image A.
[0166] It is understandable that the process of obtaining image A can be done by reading all the data of image A from PAD 20 in multiple steps, according to the file size of image A. Each data reading can refer to the steps S118 to S149 below.
[0167] S118, Global Collection App sends a read request to the Linux kernel module.
[0168] The read request is used to read image A. It's understandable that the global collection app cannot directly send messages to the message sending and receiving module in the distributed file client module; it can only send messages to the distributed file client module through the Linux kernel module and the FUSE user-space file system framework module.
[0169] The Global Collection App can read image A by reading file segments of image A multiple times to obtain the complete file data of image A. The file handle corresponding to image A indicates its storage address. Therefore, the Global Collection App can determine the starting address and data size of each file segment read based on the file handle. The Global Collection App can include the starting address and data size of the file segment in the read request and send it to the disk cache file read / write module.
[0170] S119, The Linux kernel module sends a read request to the FUSE user-space file system framework module.
[0171] The S120 and FUSE user-mode file system framework modules send read requests to the file management module.
[0172] S121. The file management module sends a read request to the disk cache limit management module.
[0173] S122. The disk cache upper limit management module determines whether the remaining space of the disk cache is greater than the preset threshold based on the read request.
[0174] If the remaining space of the disk cache is greater than the preset threshold, then execute S123. The determination of the preset threshold can be found in the disk cache upper limit management module's management rules for the disk cache upper limit, which is to adjust the maximum remaining space of the disk cache (equivalent to the preset threshold) based on the remaining space of the phone's disk.
[0175] S123, The disk cache upper limit management module sends a read request to the disk cache file read / write module.
[0176] S124. The disk cache file read / write module determines whether the disk cache data storage module stores the file data corresponding to image A based on the read / write request.
[0177] Understandably, if the mobile phone 100 does not read the file data of image A, then the disk cache data storage module does not store the file data corresponding to image A. Therefore, the mobile phone 100 can first obtain the file data of image A from the PAD 200. For example, the file data of image A can be obtained from the PAD 200 through the following steps S125 to S137.
[0178] The disk cache file read / write module determines whether the file data corresponding to image A is stored in the disk cache data storage module based on the unique ID of image A. This unique ID is stored in the disk cache metadata storage module. The disk cache file read / write module can determine whether image A is stored in the disk cache data module based on whether its ID is present in the disk cache metadata storage module. It can be understood that the unique ID of image A can be... Figure 7 The unique ID recorded in the three-level directory tree shown. The unique ID of image A can be called the identification information of image A.
[0179] For example, if mobile phone 100 reads the file data of image A for the first time, the file index information of image A is usually the initial index information, which is empty, such as... Figure 14 The initial index information is shown below. In the first line, the value "5" on the left indicates the disk cache version number is "5". The value "0" on the right indicates that no data has been written to the file. The "0" in the second line indicates that the file size of image A stored in the disk cache data storage module is 0. The value "0" in the third line indicates that the size of the written file data corresponding to image A stored in the disk cache data storage module is 0.
[0180] The file data size of image A is 3,657,728 bits. Mobile phone 100 can obtain the file data of image A through four reads, each reading 1,048,576 bits. During the first read of a file segment of image A, the disk cache file read / write module determines from the read request that the starting position of the file segment of image A being read is 0, and the file size is 1,048,576 bits. That is, the index information of the first read of the file segment of image A is (0, 1048,576). It can be seen that the index information of the first read of the file segment of image A is different from the initial index information. Based on the difference between the index information of the read file segment of image A and the initial index information, the disk cache file read / write module can determine that the file data corresponding to image A is not stored in the disk cache data storage module. It can be understood that the difference between the index information of the read file segment of image A and the initial index information can result in a miss for reading the file segment of image A.
[0181] After reading the file slice of image A, the file index information of image A is updated with an assignment "(0, 1048576)", such as... Figure 14 The first index information is shown. It should be noted that after the first successful reading of the file fragment of image A, the value in the second line of the index information changes from "0" to "1048576", indicating that 1048576 bits of data have been stored in the disk cache data storage module. The first index information can be used as a comparison index for the second reading of the file fragment of image A.
[0182] Similar to the first time the file fragment of image A was read, the second time the file fragment of image A was read, the starting position of the read image A file fragment was 1048576, and the file size was 1048576 bits. That is to say, the index information for the second read of the file fragment of image A was (1048576, 1048576). Compared with the first index information, it can be seen that the second index information is different from the first index information, meaning that the second read of the file fragment of image A was not successful, and the second read of the file fragment of image A was not stored in the disk cache data storage module.
[0183] After completing the second reading of the file fragment of image A, the file index information for image A adds another assignment: "(1048576, 1048576)". Similarly, the assignment in the second line of the index information changes from "1048576" to "2097152", indicating that the disk cache data storage module has stored 2097152 bits of data. Figure 14 The second index information is shown. This second index information can be used as a comparison index when reading the file fragment of image A for the third time.
[0184] During the third read of image A's file fragment, the starting position of the fragment was 2097152, and the file size was 1048576 bits. This means the index information for the third read of image A's file fragment was (1048576, 1048576). Compared to the second index information, it can be seen that the third index information is different, indicating that the third read of image A's file fragment was not found, and the fragment was not stored in the disk cache data storage module.
[0185] After completing the third reading of the file fragment of image A, the file index information for image A adds an assignment "(2097152, 1048576)" to the second index information. Similarly, the assignment in the second line of the index information changes from "2097152" to "3145728", indicating that the disk cache data storage module has stored 3145728 bits of data. Figure 14 The third index information shown here can be used as a comparison index when reading the file fragment of image A for the fourth time.
[0186] After the fourth reading of the file fragment of image A, the mobile phone 100 completed the file reading of image A. Since this was the last time the file fragment of image A was read, only the remaining file data of file A was read, and the amount of data read was usually small. For example, 512,000 bits of data were read in the fourth reading. The starting position of the file fragment of image A read in the fourth reading was 3145728, and the file size read was 512,000 bits. That is to say, the index information of the file fragment of image A read in the fourth reading was (3145728, 512000). Compared with the index information in the third reading, it can be seen that the index information in the fourth reading is different from the index information in the third reading, that is, the file fragment of image A read in the fourth reading was not found, and the file fragment of image A read in the fourth reading was not stored in the disk cache data storage module.
[0187] After completing the fourth file segment reading of image A, the file index information for image A, based on the third index information, adds an assignment "(3145728, 51200)", indicating that the file segment of image A read this time starts at address 3145728 and has a file size of 51200. Similarly, the assignment in the second line of the index information changes from "3145728" to "3657728", indicating that the disk cache data storage module has already stored 3657728 bits of data. The final file index information for image A is as follows: Figure 14 As shown.
[0188] The disk cache file read / write module can store the final file index information of image A in the disk cache data storage module. When image A is read again, the index information of image A stored in the disk cache data storage module is used as a reference to determine whether the file segment of image A is hit, that is, to determine whether the file segment of image A is stored in the disk cache data storage module.
[0189] If the file data for image A is read again, for example, a second time, the disk cache data storage module may contain the file data corresponding to image A. Therefore, mobile phone 100 can directly obtain the file data for image A from the disk cache data storage module. For example, the file data for image A can be obtained directly from the disk cache data storage module through the following steps S140 to S142.
[0190] For example, when reading the file data of image A for the second time, the disk cache data storage module stores the index information of image A as follows: Figure 15 The initial index information shown is the final index information generated from the first reading of the file data of image A.
[0191] When reading the file fragment of image A for the first time, the disk cache file read / write module determines from the read request that the starting position of the file fragment of image A to be 0, and the file size to be read is 1048576. During the reading of the file fragment of image A, an assignment "(0, 1048576)" is added to the file index information of image A, such as... Figure 14 The first index information is shown. It can be seen that the index information for the first read of the file fragment of image A is the same as the initial index information. Based on the fact that the index information of the read file fragment of image A is the same as the initial index information, the disk cache file read / write module can determine that the file data corresponding to image A is stored in the disk cache data storage module. The disk cache file read / write module can directly read the file fragment starting at position 0 and with a file size of 1048576 from the disk cache data storage module.
[0192] Similar to the first reading of image A's file fragment, the index information for the second reading of image A's file fragment is "(1048576, 1048576)," indicating that the file fragment of image A read this time starts at address 1048576 and has a file size of 1048576. It can be seen that the index information for the second reading of image A's file fragment is the same as the initial index information, meaning that the second reading of image A's file fragment was successful, and this second reading of image A's file fragment is also stored in the disk cache data storage module. The disk cache file read / write module can directly read the file fragment starting at address 1048576 and with a file size of 1048576 from the disk cache data storage module.
[0193] When reading the file segment of image A for the third time, the index information for reading the file segment of image A is "(2097152, 1048576)," indicating that the file segment of image A read this time starts at address 2097152 and has a file size of 1048576. It can be seen that the index information for the third reading of the file segment of image A is the same as the initial index information, meaning that the third reading of the file segment of image A was successful, and this third reading of the file segment of image A is also stored in the disk cache data storage module. The disk cache file read / write module can directly read the file segment starting at address 2097152 and with a file size of 1048576 from the disk cache data storage module.
[0194] After the fourth reading of the file fragment of image A, the mobile phone 100 completes the file reading of image A. Since this is the last time the file fragment of image A is read, only the remaining file data of file A is read, and the amount of data read is usually small. For example, 512,000 bits of data were read in the fourth reading. Therefore, when reading the file fragment of image A for the fourth time, the index information for reading the file fragment of image A is "(3145728, 51200)," indicating that the file fragment of image A read this time starts at address 3145728 and has a file size of 51,200 bits. It can be seen that the index information for the fourth reading of the file fragment of image A is the same as the initial index information, meaning that the fourth reading of the file fragment of image A was successful, and the file fragment of image A read in the fourth reading is also stored in the disk cache data storage module. The disk cache file read / write module can directly read the file fragment starting at address 3145728 and with a file size of 51,200 bits from the disk cache data storage module.
[0195] S125, the disk cache file read / write module sends a read request to the message sending / receiving module in the mobile phone 100.
[0196] S126, the message transceiver module in mobile phone 100 sends a read request to the message transceiver module in PAD 200.
[0197] The message sending and receiving module in S127 and PAD 200 sends a read request to the file operation processing module.
[0198] S128, The file operation processing module sends a read request to the local file system module.
[0199] S129. The local file system module responds to the read request and obtains the file data corresponding to image A.
[0200] S130, The local file system module returns the file data of image A to the file operation processing module.
[0201] S131, The file operation processing module returns the file data of image A to the message sending and receiving module in PAD 200.
[0202] S132, the message transceiver module in PAD 200 sends the file data of image A to the message transceiver module in mobile phone 100.
[0203] S133, the message sending and receiving module in mobile phone 100 sends the file data of image A to the disk cache file read and write module.
[0204] S134. The disk cache file read / write module sends an update request to the disk cache metadata storage module to update the metadata information.
[0205] S135, The disk cache metadata storage module updates metadata information.
[0206] S136. The disk cache metadata storage module sends an indication message to the disk cache file read / write module indicating that the metadata information has been successfully updated.
[0207] S137. The disk cache file read / write module writes the file data of image A to the disk cache data storage module.
[0208] S138. The disk cache data storage module updates the index information of image A.
[0209] Therefore, when reading the file data of image A again, the file index information in the disk cache data storage module can be compared with the starting address and file size carried in the read request to determine whether the file data of image A exists in the disk cache data storage module.
[0210] S139. The disk cache data storage module returns an indication message to the disk cache file read / write module indicating that the file data written to image A was successful.
[0211] S140, The disk cache file read / write module determines whether the file data of image A stored in the disk cache data storage module is valid.
[0212] If the file data of image A stored in the disk cache data storage module is invalid, or is not the file data of image A that can be read, then execute S141.
[0213] If the file data of image A stored in the disk cache data storage module is valid and can be read, then execute S142.
[0214] S141, The disk cache file read / write module deletes the file data of invalid image A stored in the disk cache data storage module.
[0215] The disk cache file read / write module deletes invalid image A file data stored in the disk cache data storage module and retrieves the image A file data from PAD 200. For example, the file data of image A is retrieved from PAD 200 through steps S125 to S133.
[0216] S142. The disk cache file read / write module obtains the file data of image A from the disk cache data storage module.
[0217] S143. The disk cache file read / write module sends an update request to the disk cache metadata storage module based on the received file data of image A.
[0218] The update request is used to update the metadata corresponding to the file data of image A.
[0219] S144. The disk cache metadata storage module updates metadata information based on update requests.
[0220] When the file data for image A is read for the first time, the disk cache metadata storage module stores the initial metadata corresponding to image A, such as... Figure 16 The initial metadata shown in the figure has the following characteristics: the value “5” on the left side of the first line represents the disk cache version number; the value “120449160” on the second line represents the unique ID value of image A; the value “0” on the third line indicates that the file data of image A has not been accessed; and the value “0” on the fourth line indicates that the file data of image A has not been modified.
[0221] As shown in step S124 above, the disk cache read module can read the file data of image A in four separate steps.
[0222] When the file fragment of image A is read for the first time, the value of the third line of image A's metadata is updated from "0" to "1701412556", indicating that the access time of the first read of the file fragment of image A is "1701412556"; the value of the fourth line is updated from "0" to "1701412336", indicating that the modification time of the first read of the file fragment of image A is "1701412336". It should be understood that time can be represented by the count value of a timer in an electronic device. That is to say, the above "1701412556" and "1701412336" could refer to the count value of a counter in mobile phone 100.
[0223] The changes in metadata assignments during the second, third, and fourth readings of image A's file fragment can be referenced. Figure 16As shown, the access and modification times for each file segment of image A are recorded, which will not be elaborated further here. The final metadata of image A can be the metadata generated after the file data of image A is read, that is, the fourth metadata. The fourth metadata can be stored in the disk cache metadata storage module as the initial metadata for the next read of the file data of image A.
[0224] When reading the file data of image A again, for example, when reading the file data of image A for the second time, the initial metadata corresponding to image A stored in the disk cache metadata storage module is as follows: Figure 17 The initial metadata shown is the final metadata from the last time image A's file data was read. The changes in metadata assignment during each read of image A's file fragment can be referenced... Figure 17 As shown, the access time and modification time of each file segment of image A are recorded, which will not be elaborated here.
[0225] S145. The disk cache metadata storage module returns an indication message to the disk cache file read / write module indicating that the disk cache metadata storage module has updated the metadata information.
[0226] The indication information is used to indicate that the disk cache metadata storage module has updated the metadata information.
[0227] S146. The disk cache file read / write module returns the file data of image A to the disk cache upper limit management module.
[0228] S147. The disk cache limit management module returns the file data of image A to the file management module.
[0229] S148. The file management module returns the file data of image A to the FUSE user-mode file system framework module.
[0230] S149, the FUSE user-space file system framework module returns the file data of image A to the Linux kernel module.
[0231] S150, the Linux kernel module returns the file data of image A to the global collection app.
[0232] S151, Global Collection App displays image A.
[0233] The following is through Figure 18 The illustrated embodiment describes how mobile phone 100 accesses video B stored in PAD 200.
[0234] It should be noted that video data is typically large. In one possible scenario, the phone may not be able to retrieve all the video data at once, therefore, the phone may only have a portion of the video data cached. This is understandable. Figure 18 The embodiments shown are merely examples, and the embodiments of this application do not limit the types of files accessed.
[0235] Figure 18 This is a flowchart illustrating a file access method provided in an embodiment of this application, such as... Figure 18 As shown, the method includes:
[0236] S21, Receive the user's second operation.
[0237] The second operation can refer to the user clicking on the thumbnail of video B in the global favorites app on mobile phone 100. It is understood that the first operation can be the aforementioned click operation, or it can be opening video B in the global favorites app on mobile phone 100 via voice command, or it can be opening video B in the global favorites app on mobile phone 100 via other commands; this embodiment does not limit this.
[0238] S22. In response to the second operation, the Global Collection App sends a retrieval request to PAD 200.
[0239] The request is for the storage address information of video B. The Global Collection App can send the request to the message receiving module in PAD 200 sequentially through the Linux kernel module, the FUSE user-space file system framework module, the file management module, and the message receiving module in mobile phone 100. The process of the Global Collection App sending the request to PAD 200 is similar to the steps shown in S12 to S18, and will not be described again here.
[0240] S23, PAD 200 sends the file handle of video B to the global collection app based on the acquisition request.
[0241] PAD 200 can sequentially send the file handle of video B through the message sending and receiving module in PAD 200, the message sending and receiving module in mobile phone 100, the file management module, the FUSE user-space file system framework module, and the Linux kernel module. The specific process of PAD 200 sending the file handle of video B to the global collection app based on the acquisition request is similar to the steps shown in S19 to S117, and will not be repeated here.
[0242] S24. The Global Collection App sends a read request to the disk cache limit management module.
[0243] The read request is used to read video B. The Global Collection App can read video B in multiple steps, reading file segments of video B to obtain the complete file data. The file handle corresponding to video B indicates its storage address; therefore, the Global Collection App can determine the starting address and file segment size for each read based on the file handle. The Global Collection App can include the starting address and file segment size of video B in the read request and send it to the disk cache file read / write module.
[0244] S25. The disk cache upper limit management module determines whether the remaining space of the disk cache is greater than the preset threshold based on the read request.
[0245] If the remaining space in the disk cache is greater than the preset threshold, then execute S26.
[0246] S26. The disk cache upper limit management module sends a read request to the disk cache file read / write module.
[0247] S27. The disk cache file read / write module determines whether the disk cache data storage module stores the file data corresponding to video B based on the read / write request.
[0248] If the disk cache data storage module stores the file data corresponding to video B, then execute S28.
[0249] If the disk cache data storage module does not store the file data corresponding to video B, then the file data corresponding to video B is obtained from PAD 200. Obtaining the file data corresponding to video B from PAD 200 is similar to obtaining the file data corresponding to image A from PAD 200, which is the same as the steps shown in S125 to S139 above, and will not be repeated here.
[0250] S28. The disk cache file read / write module determines whether the file data of video B stored in the disk cache data storage module is valid.
[0251] The disk cache file read / write module can determine the validity of the video B file data stored in the disk cache data storage module by comparing the last modification time of the video B file data with the last modification time of the corresponding metadata. If the last modification time of the video B file data in the disk cache data storage module matches the last modification time of the corresponding metadata, then the video B file data stored in the disk cache data storage module is valid; if the last modification time of the video B file data in the disk cache data storage module does not match the last modification time of the corresponding metadata, then the video B file data stored in the disk cache data storage module is invalid.
[0252] If the file data of video B stored in the disk cache data storage module is invalid, the disk cache file read / write module sends a read request to PAD 200 to retrieve the file data of video B from PAD 200. For example, the step shown in S29 is executed.
[0253] If the file data of video B stored in the disk cache data storage module is valid, the disk cache file read / write module checks whether the file segment of video B has been matched. For example, the step shown in S210 is executed.
[0254] S29. The disk cache file read / write module requests the file data of video B from PAD 200.
[0255] The disk cache file read / write module requests video B's file data from PAD 200 in a similar manner to obtaining image A's file data from PAD 200, that is, the steps from S125 to S133 are similar, and will not be described again here.
[0256] S210, the disk cache file read / write module obtains the file segment of video B.
[0257] Understandably, video files are typically large files. In one possible scenario, the phone 100 may only cache a portion of the video B file data. Therefore, each time a segment of video B is read, it is necessary to first determine whether the currently read segment of video B is stored in the disk cache data storage module; that is, it is necessary to check whether the video B file segment has been matched each time.
[0258] If the file segment of video B is found during this reading, the file segment of video B will be stored in the disk cache data storage module. The disk cache file read / write module can then directly read the file segment of video B from the disk cache data storage module.
[0259] If the file segment of video B is not found during the current read operation, it will not be stored in the disk cache data storage module. The disk cache file read / write module can then read the file segment of video B from PAD 200. After successfully reading the file segment of video B from PAD 200, the disk cache file read / write module can store the file segment of video B in the disk cache data storage module and update the index information of video B.
[0260] For example, during the first reading of a video file segment B, the disk cache data storage module stores the index information of video B, such as... Figure 19The initial index information is shown below. In the first line, the value "5" on the left indicates the disk cache version number; the value "0" on the right indicates that no data has been written to the file; the value "11534336" in the second line indicates that the file has been written to a file of 11534336 bits; the value "0" in the third line indicates that the size of the written file data corresponding to video B stored in the disk cache data storage module is 0; the value "(0,1048576)" in the fourth line indicates that a file segment with a starting address of 0 and a file size of 1048576 bits is stored; the values in the fifth and sixth lines are similar to those in the fourth line and will not be repeated here.
[0261] like Figure 19 As shown, when the disk cache file read / write module reads a file segment of video B for the first time, it determines the address information of the video B file data to be read based on the read / write request: a file segment with a starting address of 0 and a file size of 1048576 bits. This is the same as the value assigned in the fourth line of the initial index information, meaning that the currently read video B file segment has been hit. Therefore, the disk cache file read / write module can directly read the video B file segment with a starting address of 0 and a file size of 1048576 bits from the disk cache data storage module.
[0262] When the disk cache file read / write module reads the video B file segment for the second time, it determines the address information of the video B file data to be read based on the read / write request: a file segment with a starting address of 1048576 and a file size of 1048576 bits. This is the same as the value assigned in the fifth line of the initial index information, meaning that the currently read video B file segment has been hit. Therefore, the disk cache file read / write module can directly read the video B file segment with a starting address of 1048576 and a file size of 1048576 bits from the disk cache data storage module.
[0263] Understandably, since video files are typically large, only a portion of the file was cached during the previous caching of video B. For example, only a 5242880-bit file was cached previously. Therefore, when reading a file segment of video B starting at address 5242880 and with a file size of 1048576 bits, this file segment is not present in the disk cache data storage module. A file miss will occur when trying to read the 1048576-bit file segment of video B starting at address 5242880.
[0264] When the disk cache file read / write module reads a file segment of video B for the i-th time, it determines the address information of the video B file data to be read based on the read / write request: a file segment with a starting address of 5242880 and a file size of 1048576 bits. This address is different from the value assigned in any line of the initial index information, meaning that the current read of video B file segment is not found. Therefore, the disk cache file read / write module cannot directly read the video B file segment with a starting address of 5242880 and a file size of 1048576 bits from the disk cache data storage module. The disk cache file read / write module needs to read the video B file segment with a starting address of 5242880 and a file size of 1048576 bits from PAD 200. Reading the video B file segment with a starting address of 5242880 and a file size of 1048576 bits from PAD 200... Figure 13 In the illustrated embodiment, steps S125 to S133 are similar and will not be repeated here. It should be noted that after the disk cache file read / write module reads the video B file segment with a starting address of 5242880 and a file size of 1048576 bits from PAD 200, it stores the video B file segment with the starting address of 5242880 and a file size of 1048576 bits in the disk cache data storage module and updates the index information of video B. Compared with the initial index information, the updated index information adds an assignment "(5242880, 1048576)", indicating the starting address and file size of the video B file segment read this time.
[0265] It's understandable that when video B was cached last time, some of the cached files were not contiguous. Therefore, after a file segment of video B is not found on the i-th read, it's possible that a file segment of video B will be found on the next read (e.g., the i+2-th read).
[0266] For example, when the disk cache file read / write module reads a file segment of video B for the (i+2)th time, it determines the address information of the video B file data to be read based on the read / write request: a file segment with a starting address of 7340032 and a file size of 1048576 bits. This is the same as the value assigned in one line of the initial index information, meaning that the currently read video B file segment has been hit. Therefore, the disk cache file read / write module can directly read the video B file segment with a starting address of 7340032 and a file size of 1048576 bits from the disk cache data storage module.
[0267] Since the disk cache file read / write module reads the file segment from PAD200 each time a file segment of video B is not found, it updates the index information of video B accordingly. Therefore, the updated index information for this read of video B differs from the initial index information, incorporating the index information of the file segment read from PAD200. Figure 19 The final index information shown.
[0268] S211, The disk cache file read / write module notifies the disk cache metadata storage module to update the metadata.
[0269] Among them, with Figure 13 In the illustrated embodiment, the steps shown in S138 are similar; each time a file segment of video B is read, the third line of the metadata for video B is updated. For example, as... Figure 20 As shown, when the file segment of video B is read for the first time, the third line is assigned the value "1701412887", indicating that the access time of the first read file segment of image A is "1701412887"; when the file segment of video B is read for the last time, the third line is updated to "1701412895", indicating that the access time of the last read file segment of image A is "1701412895".
[0270] S212, The disk cache file read / write module returns the file data of video B to the global collection App.
[0271] Understandably, the disk cache file read / write module can sequentially return the file data of video B to the global collection app through the disk cache limit management module, file management module, FUSE user-space file system framework module, and Linux kernel module. Figure 13 The steps S146 to S150 in the illustrated embodiment are similar and will not be repeated here.
[0272] S213, Global Favorites App displays video B.
[0273] It is understandable that, such as Figure 12 (c) and Figure 12 As shown in (d), the user can also modify the document 203 stored in the PAD 200 from the mobile phone 100. The following is a demonstration... Figure 21 The illustrated embodiment describes how mobile phone 100 modifies document C stored in PAD 200.
[0274] Figure 21 This is a flowchart illustrating a file access method provided in an embodiment of this application, such as... Figure 21 As shown, the method includes:
[0275] S31. Display document C on phone 100 via the global collection app.
[0276] Among them, the process of displaying document C stored on PAD 200 on the phone 100 through the global collection app is similar to the above. Figure 13 and Figure 18 The embodiments shown are similar and will not be described again here.
[0277] S32. In response to the user's modification operation on document C, the App's modified document C is globally bookmarked, and a write request is sent to the disk cache limit management module.
[0278] The write request can carry the file handle, starting position, and file size of document C, and can also carry the modified data for document C. The write request is used to request the writing of relevant data to document C for this modification.
[0279] It is understandable that the global collection app can send write requests to the disk cache limit management module by sequentially sending the write requests to the disk cache limit management module through the Linux kernel module, the FUSE user-space file system framework module, and the file management module.
[0280] S33. The disk cache upper limit management module determines whether the remaining space in the disk cache data storage module is greater than the preset threshold.
[0281] If the remaining space in the disk cache data storage module is greater than the preset threshold, then execute S34, which means sending a write request to the disk cache file read / write module.
[0282] The preset threshold can be the maximum remaining space of the disk cache determined by the disk cache limit management module's management rules for the disk cache limit, which means that the maximum remaining space of the disk cache is adjusted based on the remaining space of the mobile phone's disk.
[0283] S34. The disk cache file read / write module sends a write request to the disk cache data storage module.
[0284] S35, The disk cache data storage module stores the updated document C based on the write request.
[0285] S36. The disk cache data storage module updates the index information of document C.
[0286] It is understandable that the process of writing updated data to document C can also involve writing all the updated data to the disk cache data storage module in multiple installments, with each installment referred to as an updated file fragment of document C. Each time an updated file fragment of document C is written, the index information of document C will be modified.
[0287] For example, such as Figure 22 As shown, the initial index information for document C is as follows: Figure 22 The initial index information is shown below. When the disk cache data storage module stores the updated document C, it is equivalent to writing a piece of data into the disk cache data storage module. For example, as shown below... Figure 22 As shown, the disk cache data storage module wrote data starting at address 0 with a size of 524288. Therefore, the updated index information of document C, based on this written data, is as shown in the index information after the first write. The third line is modified to "524288", indicating that a total of 524288 bits of data were written, and a new line is added with the value "(0, 524288)", indicating that the newly added data starts at address 0 and has a size of 524288. It should be understood that when writing the updated file fragment of document C, the data on the right side of the first line in the index information changes from the initial "0" to "1", indicating that the current data is written data.
[0288] During the second write of the updated file fragment of document C, the disk cache data storage module wrote data starting at address 524288 with a size of 1048576. Therefore, compared to the index information after the first write, the index information after the second write has an additional line, assigned the value "(524288, 1048576)", indicating that the starting address of the newly added data is 524288 and the data size is 1048576. The fourth line in the index information after the second write is assigned the value "1572864", indicating that a total of 524288 + 1048576 = 1572864 bits of data was written. Similarly, during the second write of the updated file fragment of document C, the right side of the first line in the index information is assigned the value "1", indicating that the current data is written data.
[0289] During the third write of the updated file fragment of document C, the disk cache data storage module wrote data starting at address 1572864 with a size of 524288. Therefore, compared to the index information after the second write, the index information after the third write has an additional line, assigned the value "(1572864, 524288)", indicating that the starting address of the newly added data is 1572864 and the data size is 524288. The fourth line in the index information after the third write is assigned the value "2097152", indicating that a total of 1572864 + 524288 = 2097152 bits of data was written. Similarly, during the third write of the updated file fragment of document C, the right side of the first line in the index information is assigned the value "1", indicating that the current data is written data.
[0290] S37. The disk cache data storage module returns an indication message to the disk cache file read / write module indicating that the updated document C was successfully written.
[0291] S38. The disk cache file read / write module sends an update request to the disk cache metadata storage module.
[0292] S39. The disk cache metadata storage module updates the metadata information of document C based on the update request.
[0293] For example, the initial metadata of document C is as follows: Figure 23 The initial metadata shown is modified every time data is written, the metadata write time is changed.
[0294] S310, the disk cache metadata storage module returns a message indicating that the metadata update was successful to the disk cache file read / write module.
[0295] S311, The disk cache file read / write module returns a message indicating that the file was successfully written to the global collection app.
[0296] S312, The disk cache file read / write module determines whether the written data exceeds the preset threshold.
[0297] If the written data exceeds the preset threshold, then S313 to S318 are executed, which means reading the written data from the disk cache data storage module and writing the written data, which is the modified data of document C, to PAD200.
[0298] The preset threshold can be the maximum remaining space of the disk cache determined by the disk cache limit management module's management rules for the disk cache limit, which means that the maximum remaining space of the disk cache is adjusted based on the remaining space of the mobile phone's disk.
[0299] S313, The disk cache file read / write module sends the first read request to the disk cache data storage module.
[0300] The first read request is used to read the current modifications made to document C.
[0301] S314. The disk cache data storage module responds to the first read request and reads the first modified data.
[0302] The first modified data refers to the current modified data of document C, which is the data written to the disk cache data storage module.
[0303] S315, The disk cache data storage module updates index information.
[0304] Since the written data exceeded the preset threshold, the first modified data originally stored in the disk cache data storage module needed to be retrieved. Therefore, the data assignment on the right side of the first row changed from "1" to "0", indicating that the data was read. Furthermore, since the first modified data stored in the disk cache data storage module was retrieved, meaning the first modified data no longer exists in the disk cache data storage module, the corresponding index information did not include the index of the written data; that is, the three rows of index information "(0, 524288)", "(524288, 1048576)", and "(1572864, 1048576)" were deleted.
[0305] S316, The disk cache data storage module sends the first modified data to the disk cache file read / write module.
[0306] S317, The disk cache file read / write module writes the first modified data to PAD 200.
[0307] It is understandable that the specific process of the disk cache file read / write module writing the first modified data to the PAD 200 can be as follows: the disk cache file read / write module sequentially sends the first modified data to the local file system module in the PAD 200 through the message sending / receiving module in the mobile phone 100, the message sending / receiving module in the PAD 200, and the service processing module in the PAD 200, so that the local file system module in the PAD 200 stores the first modified data. After storing the first modified data, the local file system module in the PAD 200 sequentially returns an indication message indicating that the modified data was successfully written to the disk cache file read / write module through the service processing module in the PAD 200, the message sending / receiving module in the PAD 200, and the message sending / receiving module in the mobile phone 100.
[0308] S318, the disk cache file read / write module returns a message indicating that the write is complete to the global collection app.
[0309] When a user finishes modifying document C, they typically close document C. When the user closes document C, mobile phone 100 usually sends all the user's changes to PAD 200, thus achieving the effect of modifying the document on PAD 200 via mobile phone 100.
[0310] S319. In response to the fourth operation, the Global Collection App sends a close command to the disk cache file read / write module.
[0311] The fourth operation can refer to closing document C. For example, the fourth operation can be closing document C by swiping up on the display interface of document C, clicking the close control displayed on the display interface of document C, or closing document C through a voice assistant. This application embodiment does not limit this.
[0312] It is understandable that the global collection app sends a shutdown command to the disk cache file read / write module, which can be done by sending the shutdown request to the disk cache file read / write module sequentially through the Linux kernel module, the FUSE user-space file system framework module, and the file management module.
[0313] S320: In response to the close request, the disk cache file read / write module sends a second read request to the disk cache data storage module.
[0314] The second read request is used to read all the modified data of document C.
[0315] S321, The disk cache data storage module responds to the read request and reads the second modified data.
[0316] The second modified data refers to all the modified data of document C made by the user during the period from when the user opens document C on mobile phone 100 until when the user closes document C. In other words, it is all the modified data of document C written to the disk cache data storage module.
[0317] S322, The disk cache data storage module updates index information.
[0318] Similarly, in S315, updating the index information involves deleting the index information of the written data to obtain the final index information, such as... Figure 22 As shown.
[0319] S323, The disk cache data storage module sends the second modified data to the disk cache file read / write module.
[0320] S324, The disk cache file read / write module writes the second modified data to PAD 200.
[0321] It is understandable that the specific process of the disk cache file read / write module writing the second modified data to the PAD 200 can be as follows: the disk cache file read / write module sequentially sends the second modified data to the local file system module in the PAD 200 through the message sending / receiving module in the mobile phone 100, the message sending / receiving module in the PAD 200, and the service processing module in the PAD 200, so that the local file system module in the PAD 200 stores the second modified data. After storing the second modified data, the local file system module in the PAD 200 sequentially returns an indication message indicating that the second modified data was successfully written to the disk cache file read / write module through the service processing module in the PAD 200, the message sending / receiving module in the PAD 200, and the message sending / receiving module in the mobile phone 100.
[0322] S325, The disk cache file read / write module sends an indication message to the global collection app indicating that the second modified data has been successfully written.
[0323] It is understandable that successfully writing the second modified data is equivalent to completing the task of closing document C. Therefore, the indication message indicating that the second modified data was successfully written is also equivalent to the indication message indicating that document C has been closed.
[0324] The specific process by which the disk cache file read / write module sends an indication message to the global collection app indicating that the second modified data has been successfully written can be as follows: the disk cache file read / write module sequentially sends the indication message to the global collection app indicating that the second modified data has been successfully written through the file management module, the FUSE user-space file system framework module, and the Linux kernel module.
[0325] Since disk cache storage space is limited, it's necessary to clean up the disk cache space regularly to meet user needs. Optionally, disk cache space cleanup can be performed by the aforementioned disk cache cleanup module. Specifically, disk cache space cleanup can be achieved through... Figure 24 The steps shown are complete.
[0326] S41. Determine the storage space occupied by each file in the disk cache.
[0327] S42. Determine the storage space to be deleted based on the ratio between the storage space occupied by each file and the upper limit of the cache space.
[0328] Deleting storage space can mean freeing up files in that storage space so that the space can be used to store other files.
[0329] The ratio between the storage space occupied by each file and the upper limit of the cache space can refer to the ratio of the disk cache space occupied by all files cached in the disk cache. This ratio can be a preset ratio, such as 75%.
[0330] S43. Sort each file in order of access time from earliest to latest.
[0331] S44. Delete the storage space occupied by files that have not been accessed within the preset time period.
[0332] The preset duration can be determined by the user based on experience, such as one week.
[0333] S44. Determine whether the remaining space in the disk cache is less than a preset threshold.
[0334] The preset threshold can be a value determined by the user based on experience. For example, the preset threshold can refer to the percentage of disk cache space occupied by the file (e.g., 75%).
[0335] If the remaining space in the disk cache is less than the preset threshold, then execute S45, which means using the preset algorithm to release the files in the disk cache until the remaining space in the disk cache is greater than or equal to the preset threshold.
[0336] S45. Use a preset algorithm to release files in the disk cache until the remaining space in the disk cache is greater than or equal to a preset threshold.
[0337] The preset algorithm can refer to an algorithm that deletes files at the file level using the LRU algorithm based on access time.
[0338] Figure 25 This is a flowchart illustrating a file access method provided in an embodiment of this application, such as... Figure 25 As shown, the method is applied to a first electronic device, and the method includes:
[0339] S101. In response to the first operation, determine whether the first file is cached in the first electronic device, wherein the first file is a file stored in the second electronic device, and the first operation is an operation to read the first file.
[0340] It is understood that the first operation can be the operation of reading image A as described above, or the operation of reading video B, or the operation of reading document C. This application embodiment does not limit this.
[0341] Optionally, the first file may include image files, video files, and document files.
[0342] The first electronic device may refer to the aforementioned mobile phone 100, and the second electronic device may refer to the aforementioned PAD 200. This application embodiment does not limit this.
[0343] S102. If the first file is cached in the first electronic device, read the first file from the cache module in the first electronic device.
[0344] The file access method provided in this application is applied to a first electronic device. By responding to a first operation, it determines whether a first file stored in a second electronic device is cached in the cache module of the first electronic device. If the first file is cached in the cache module of the first electronic device, the first file is read directly from the cache module of the first electronic device. Since data interaction between the first and second electronic devices takes a period of time, the file access method provided in this application can avoid the process of the first electronic device obtaining the first file from the second electronic device, reducing the time required to read the first file, thereby avoiding lag caused by long reading time and improving user experience.
[0345] Figure 26 This is a flowchart illustrating a file access method provided in an embodiment of this application, such as... Figure 26 As shown, the method is applied to a first electronic device, and the method includes:
[0346] S201. In response to the first operation, determine the first identification information of the first file.
[0347] S202. Based on the first identification information, search for the second file in the first electronic device. The identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file.
[0348] The matching of the index information of the first file and the index information of the second file includes: the index information of the first file and the index information of the second file completely matching, and the index information of the first file and the index information of the second file partially matching.
[0349] If the index information of the first file partially matches the index information of the second file, the first sub-file of the first file is cached in the first electronic device. The first sub-file is the part of the file whose index information in the first file matches the index information in the second file. Reading the first file from the cache module of the first electronic device includes: reading the first sub-file from the first electronic device and reading the second sub-file from the second electronic device. The second sub-file is the sub-file in the first file other than the first sub-file.
[0350] The file access method provided in this application, when determining whether the index information of the first file matches the index information of the second file, if the index information of the first file partially matches the index information of the second file, then reads the first sub-file that matches the index information of the first file from the first electronic device, and reads the second sub-file that matches the index information of the first file from the second electronic device. This allows the cached sub-file to be read when the first file is partially cached in the first electronic device. Compared with reading the entire first file from the second electronic device, this reduces the time required to read the first file, reduces the possibility of lag caused by long retrieval time, and improves the user experience.
[0351] S203. If the second file exists in the first electronic device, the first file is cached in the first electronic device, and the first file is read from the first electronic device.
[0352] S204. If the first file is not cached in the first electronic device, obtain the first file from the second electronic device.
[0353] S205. Cache the first file in the first electronic device.
[0354] The file access method provided in this application embodiment obtains the first file from the second electronic device when the first file is not cached in the first electronic device, and caches the first file in the cache module of the first electronic device. This allows the first file to be read from the cache module of the first electronic device the next time it is read, avoiding the process of the first electronic device obtaining the first file from the second electronic device again. This reduces the time required to read the first file the next time, thereby avoiding lag caused by long reading time and improving the user experience.
[0355] Optionally, the file access method provided in this application embodiment further includes:
[0356] S206. In response to the second operation, modify the first file cached in the first electronic device. The second operation is used to modify the first file.
[0357] Figure 27 This is a flowchart illustrating a file access method provided in an embodiment of this application, such as... Figure 27 As shown, this method is applied to a first electronic device, which includes a disk cache file read / write module and a disk cache data storage module. The method includes:
[0358] S301. In response to the first operation, the disk cache file read / write module determines whether the first file is cached in the disk cache data storage module.
[0359] Optionally, the above-mentioned "disk cache file read / write module determines whether the first file is cached in the disk cache data storage module" can be achieved through the following steps:
[0360] 1. The disk cache file read / write module determines the first identifier information of the first file.
[0361] 2. The disk cache file read / write module searches in the disk cache data storage module based on the first identifier information to determine whether the first file is cached in the disk cache data storage module.
[0362] The disk cache file read / write module searches in the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module. This includes: the disk cache file read / write module searches in the disk cache data storage module for the second file based on the first identification information, where the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; if the second file exists in the disk cache data storage module, then the second file is the first file.
[0363] Optionally, matching the index information of the first file and the index information of the second file includes: the index information of the first file and the index information of the second file completely matching, and the index information of the first file and the index information of the second file partially matching. If the index information of the first file and the index information of the second file partially match, the first sub-file of the first file is cached in the disk cache data storage module, wherein the first sub-file is a portion of the file whose index information matches the index information of the second file. The disk cache file read / write module reads the first file from the disk cache data storage module, including: the disk cache file read / write module reads the first sub-file from the disk cache data storage module. The method further includes: the disk cache file read / write module reads the second sub-file from the second electronic device, wherein the second sub-file is a sub-file of the first file other than the first sub-file.
[0364] S302. If the first file is cached in the disk cache data storage module, the disk cache file read / write module reads the first file from the disk cache data storage module.
[0365] S303. If the first file is not cached in the disk cache data storage module, the disk cache file read / write module obtains the first file from the second electronic device.
[0366] S304, The disk cache file read / write module caches the first file in the disk cache data storage module.
[0367] Optionally, the method further includes: in response to the second operation, the disk cache file read / write module modifies the first file in the disk cache data storage module, the second operation being used to modify the first file.
[0368] Optionally, the disk cache file read / write module is also used to determine whether the remaining space of the disk cache data storage module is less than a preset threshold during the process of modifying the first file of the disk cache data storage module, and to send the modified first file to the second electronic device if the remaining space of the disk cache data storage module is less than the preset threshold.
[0369] Optionally, the first electronic device further includes a disk cache limit management module, which is used to determine the maximum storage space of the disk cache data storage module based on the remaining memory space of the first electronic device.
[0370] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0371] It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0372] This application embodiment can divide an electronic device into functional modules based on the above method examples. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one module. It should be noted that the module division in this application embodiment is illustrative and represents only one logical functional division; other division methods may be used in actual implementation. It should also be noted that the module names in this application embodiment are illustrative, and the names of the modules are not limited in actual implementation.
[0373] Figure 28 This is a schematic diagram of a file access device provided in an embodiment of this application.
[0374] It should be understood that the file access device 600 can perform... Figures 13 to 27 The file access method shown; the file access device 600 includes: an acquisition unit 610 and a processing unit 620.
[0375] Processing unit 620 is configured to, in response to a first operation, determine whether a first file is cached in the first electronic device, wherein the first file is a file stored in a second electronic device, and the first operation is an operation to read the first file;
[0376] The processing unit 620 is configured to read the first file from the first electronic device if the first file is cached in the first electronic device.
[0377] In one embodiment, the processing unit 620 is used to determine the first identification information of the first file; and based on the first identification information, to search in the first electronic device to determine whether the first file is cached in the first electronic device.
[0378] In one embodiment, the processing unit 620 is used to search for a second file in the first electronic device based on the first identification information, wherein the identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file; if the second file exists in the first electronic device, the first file is cached in the first electronic device.
[0379] In one embodiment, the processing unit 620 is further configured to retrieve the first file from the second electronic device if the first file is not cached in the first electronic device; and cache the first file in the first electronic device.
[0380] In one embodiment, matching the index information of the first file and the index information of the second file includes: the index information of the first file completely matching the index information of the second file, and the index information of the first file partially matching the index information of the second file. The processing unit 620 is configured to cache a first sub-file in the first file in the first electronic device if the index information of the first file partially matches the index information of the second file, wherein the first sub-file is a portion of the file whose index information matches the index information of the second file, and to read the first sub-file from the cache module of the first electronic device. The processing unit 620 is further configured to read the second sub-file from the second electronic device, wherein the second sub-file is a sub-file in the first file other than the first sub-file.
[0381] In one embodiment, the processing unit 620 is further configured to modify the first file cached in the first electronic device in response to a second operation, the second operation being configured to modify the first file.
[0382] In one embodiment, the first file includes image files, video files, and document files.
[0383] The file access device provided in this embodiment is used to execute the file access method of the above embodiment. The technical principle and technical effect are similar, and will not be described again here.
[0384] It should be noted that the aforementioned file access device 600 is embodied in the form of a functional unit. The term "unit" here can be implemented in software and / or hardware, without specific limitations.
[0385] For example, a "unit" can be a software program, a hardware circuit, or a combination of both that implements the above functions. The hardware circuit may include an application-specific integrated circuit (ASIC), electronic circuitry, a processor (e.g., a shared processor, a proprietary processor, or a group processor) and memory for executing one or more software or firmware programs, integrated logic circuitry, and / or other suitable components that support the described functions.
[0386] Therefore, the units of the various examples described in the embodiments of this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0387] Figure 29 A schematic diagram of the structure of an electronic device provided in this application is shown. Figure 29 The dashed lines indicate that the unit or module is optional. The electronic device 700 can be used to implement the file access method described in the above method embodiments.
[0388] Electronic device 700 includes one or more processors 701, which support the file access method implemented in the method embodiments of electronic device 700. Processor 701 can be a general-purpose processor or a special-purpose processor. For example, processor 701 can be a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.
[0389] The processor 701 can be used to control the electronic device 700, execute software programs, and process data from the software programs. The electronic device 700 may also include a communication unit 705 for inputting (receiving) and outputting (transmitting) signals.
[0390] For example, electronic device 700 may be a chip, communication unit 705 may be the input and / or output circuit of the chip, or communication unit 705 may be the communication interface of the chip, and the chip may be a component of terminal device or other electronic device.
[0391] For example, electronic device 700 can be a terminal device, communication unit 705 can be the transceiver of the terminal device, or communication unit 705 can be the transceiver circuit of the terminal device.
[0392] The electronic device 700 may include one or more memories 702, which store a program 704. The program 704 can be executed by the processor 701 to generate instructions 703, causing the processor 701 to execute the impedance matching method described in the above method embodiments according to the instructions 703.
[0393] Optionally, the memory 702 may also store data. Optionally, the processor 701 may also read the data stored in the memory 702, which may be stored at the same memory address as the program 704, or the data may be stored at a different memory address than the program 704.
[0394] The processor 701 and memory 702 can be configured separately or integrated together; for example, integrated on the system on chip (SOC) of the terminal device.
[0395] For example, the memory 702 can be used to store the related program 704 of the file access method provided in the embodiments of this application, and the processor 701 can be used to call the related program 704 of the file access method stored in the memory 702 when performing file access, and execute the file access method of the embodiments of this application; including: in response to a first operation, determining whether a first file is cached in a first electronic device, the first file being a file stored in a second electronic device, the first operation being an operation to read the first file; if the first file is cached in the first electronic device, reading the first file from the first electronic device.
[0396] This application also provides a computer program product that, when executed by processor 701, implements the file access method described in any of the method embodiments of this application.
[0397] The computer program product can be stored in memory 702, for example, program 704. Program 704 is finally converted into an executable object file that can be executed by processor 701 after processing such as preprocessing, compilation, assembly and linking.
[0398] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, implements the file access method described in any of the method embodiments of this application. The computer program may be a high-level language program or an executable object program.
[0399] The computer-readable storage medium is, for example, memory 702. Memory 702 can be volatile memory or non-volatile memory, or memory 702 can include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0400] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0401] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0402] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0403] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0404] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and other division methods may exist in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0405] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0406] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0407] 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 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, The method is applied to a first electronic device. When the first electronic device and a second electronic device are logged into the same account, applications in the first electronic device and applications in the second electronic device share files through the first application. The method includes: In response to the first operation, it is determined whether the first file is cached in the first electronic device. The first file is a file stored by the second electronic device through the first application. The first operation is an operation to read the first file through the first application. After the second electronic device stores the first file through the first application, the first display interface of the first application is opened in the first electronic device, and the first display interface displays the first information of the first file. If the first sub-file in the first file is cached in the first electronic device, the first sub-file is read from the first electronic device, and the second sub-file is read from the second electronic device. The first sub-file is a portion of the first file, and the second sub-file is a sub-file in the first file other than the first sub-file.
2. The method according to claim 1, characterized in that, Determining whether the first file is cached in the first electronic device includes: Determine the first identification information of the first file; Based on the first identification information, search in the first electronic device to determine whether the first file is cached in the first electronic device.
3. The method according to claim 2, characterized in that, The step of searching in the first electronic device based on the first identification information to determine whether the first file is cached in the first electronic device includes: Based on the first identification information, a second file is searched in the first electronic device. The identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file. If the second file exists in the first electronic device, then the second file is the first file.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If the first file is not cached in the first electronic device, the first file is retrieved from the second electronic device; The first file is cached in the first electronic device.
5. The method according to claim 3, characterized in that, Matching the index information of the first file and the index information of the second file includes: the index information of the first file completely matching the index information of the second file, and the index information of the first file partially matching the index information of the second file. If the index information of the first file partially matches the index information of the second file, the first sub-file of the first file is cached in the first electronic device, wherein the first sub-file is the part of the file whose index information in the first file matches the index information in the second file.
6. The method according to any one of claims 1 to 3, characterized in that, The method further includes: In response to a second operation, the first file in the first electronic device is modified, wherein the second operation is used to modify the first file.
7. The method according to any one of claims 1 to 3, characterized in that, The first electronic device includes a disk cache file read / write module and a disk cache data storage module. The step of determining whether a first file is cached in the disk cache data storage module in response to a first operation includes: In response to the first operation, the disk cache file read / write module determines whether the first file is cached in the disk cache data storage module; If the first file is cached in the first electronic device, reading the first file from the first electronic device includes: If the first file is cached in the disk cache data storage module, the disk cache file read / write module reads the first file from the disk cache data storage module.
8. The method according to claim 7, characterized in that, The disk cache file read / write module determines whether the first file is cached in the disk cache data storage module, including: The disk cache file read / write module determines the first identification information of the first file; The disk cache file read / write module searches the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module.
9. The method according to claim 8, characterized in that, The disk cache file read / write module searches the disk cache data storage module based on the first identification information to determine whether the first file is cached in the disk cache data storage module, including: The disk cache file read / write module searches for a second file in the disk cache data storage module based on the first identification information. The identification information of the second file is the first identification information, and the index information of the second file matches the index information of the first file. If the second file exists in the disk cache data storage module, then the second file is the first file.
10. The method according to claim 7, characterized in that, The method further includes: If the first file is not cached in the disk cache data storage module, the disk cache file read / write module obtains the first file from the second electronic device; The disk cache file read / write module caches the first file in the disk cache data storage module.
11. The method according to claim 3, characterized in that, The first electronic device includes a disk cache data storage module and a disk cache file read / write module. Matching the index information of the first file with the index information of the second file includes: a complete match between the index information of the first file and the index information of the second file; and a partial match between the index information of the first file and the index information of the second file. If the index information of the first file partially matches the index information of the second file, the first sub-file of the first file is cached in the disk cache data storage module. The first sub-file is the portion of the file whose index information matches the index information of the second file. The disk cache file read / write module reads the first file from the disk cache data storage module, including: The disk cache file read / write module reads the first sub-file from the disk cache data storage module; The method further includes: The disk cache file read / write module reads a second sub-file from the second electronic device. The second sub-file is a sub-file in the first file other than the first sub-file.
12. The method according to claim 7, characterized in that, The method further includes: In response to the second operation, the disk cache file read / write module modifies the first file in the disk cache data storage module, and the second operation is used to modify the first file.
13. The method according to claim 12, characterized in that, The disk cache file read / write module is further configured to determine whether the remaining space of the disk cache data storage module is less than a preset threshold during the process of modifying the first file of the disk cache data storage module, and to send the modified first file to the second electronic device if the remaining space of the disk cache data storage module is less than the preset threshold.
14. The method according to claim 7, characterized in that, The first electronic device further includes a disk cache limit management module, which is used to determine the maximum storage space of the disk cache data storage module based on the remaining memory space of the first electronic device.
15. The method according to any one of claims 1 to 3, characterized in that, The first file includes image files, video files, and document files.
16. An electronic device, characterized in that, The electronic device includes a module for performing the method as described in any one of claims 1 to 15.
17. An electronic device, characterized in that, include: One or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 15.
18. A chip system, characterized in that, The chip system includes a processor for calling and running a computer program from memory, causing an electronic device on which the chip system is installed to perform the method as described in any one of claims 1 to 15.
19. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1 to 15.
Citation Information
Patent Citations
A method of accessing data across devices and a first electronic device
CN109388620A
Data transmission method for mobile storage device
CN113242321A