File system access method and apparatus

By storing file system metadata in a hash table in kernel space, the performance issues caused by switching between kernel mode and user mode of terminal devices are resolved, enabling more efficient file system access.

WO2025260673A1PCT designated stage Publication Date: 2025-12-26HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/141202
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-08-14
Filing Date
2024-12-20
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

In traditional file systems, the frequent switching between kernel mode and user mode by terminal devices results in high system overhead and latency, affecting access performance, especially inefficient during large-scale access.

Method used

The file system metadata is stored in a hash table in kernel space, and the metadata is retrieved directly from the hash table by hash value, avoiding the need to switch between kernel mode and user mode.

Benefits of technology

It reduces system overhead and latency caused by state switching and improves file system access performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024141202_26122025_PF_FP_ABST
    Figure CN2024141202_26122025_PF_FP_ABST
Patent Text Reader

Abstract

A file system access method and an apparatus. The method comprises: a terminal device receives a query request, wherein the query request comprises a path name of a first directory, the query request is used for querying metadata of a file system object comprised in the first directory, and the file system object comprises a file and / or a sub-directory; on the basis of the path name, determining a hash value corresponding to the first directory, and acquiring, from a position corresponding to the hash value in a hash table, the metadata of the file system object comprised in the first directory, wherein the hash table comprises at least one entry, the at least one entry comprises a first entry corresponding to the first directory, the first entry comprises the metadata of the file system object comprised in the first directory, and the hash table is stored in a kernel memory; and outputting the metadata of the file system object comprised in the first directory.
Need to check novelty before this filing date? Find Prior Art

Description

A file system access method and device

[0001] Cross-reference to Related Applications

[0002] This application claims priority to a Chinese patent application with the application number 202410807916.1, the title of which is "A file system access, management method and device", filed on June 20, 2024, with the State Intellectual Property Office of the People's Republic of China, and to a Chinese patent application with the application number 202411118855.4, the title of which is "A file system access method and device", filed on August 14, 2024, with the State Intellectual Property Office of the People's Republic of China, the contents of which are incorporated herein by reference in their entirety. TECHNICAL FIELD

[0003] The present application relates to the technical field of file systems, and in particular to a file system access method and device. BACKGROUND

[0004] In a traditional file system, file system metadata is stored in a database, which can be accessed when a terminal device is in a user state. When a directory or file attribute information of the file system is requested to be queried, the terminal device needs to enter a kernel state, call a user space file system through a virtual file system in the kernel, and then enter the user state to read the file system metadata in the database, so as to obtain the attribute information of the directory and the file based on the file system metadata.

[0005] When the access amount is large, the system overhead caused by switching between the kernel state and the user state by the terminal device is high, resulting in poor file system access performance. SUMMARY

[0006] Embodiments of the present application provide a file system access method and device to improve file system access performance.

[0007] In a first aspect, a file system access method is provided, which can be applied to a terminal device. The terminal device can be a device, or a module (such as a chip) in the device, or software (such as a control subsystem) containing terminal device functions. The method comprises: receiving a query request, the query request comprising a path name of a first directory, the query request being used to query metadata of file system objects contained in the first directory, the file system objects comprising files and / or subdirectories; determining a hash value corresponding to the first directory according to the path name, and obtaining metadata of the file system objects contained in the first directory from a position in a hash table corresponding to the hash value; wherein the hash table comprises at least one entry, the at least one entry comprising a first entry corresponding to the first directory, the first entry containing metadata of the file system objects contained in the first directory, and the hash table being stored in kernel memory; and outputting the metadata of the file system objects contained in the first directory.

[0008] In the above implementation, since the hash table is located in the kernel space, the terminal device can complete metadata query in the kernel mode, without switching between the kernel mode and the user mode, thereby reducing system overhead and latency caused by switching between the kernel mode and the user mode, and improving access performance.

[0009] In a possible implementation, the step of determining a hash value corresponding to the first directory according to the path name, and obtaining metadata of the file system objects contained in the first directory from a position in a hash table corresponding to the hash value comprises: sending, by a file manager, a directory access request to a user space file system driver in the kernel space, the directory access request comprising the path name of the first directory; and determining, by the user space file system driver, the hash value corresponding to the first directory according to the path name, and obtaining metadata of the file system objects contained in the first directory from a position in the hash table corresponding to the hash value.

[0010] In a possible implementation, the step of determining a hash value corresponding to the first directory according to the path name, and obtaining metadata of the file system objects contained in the first directory from a position in a hash table corresponding to the hash value comprises: determining the hash value corresponding to the first directory according to the path name; determining a position of a first sub-table in the hash table according to the hash value, the first sub-table comprising at least one entry, the at least one entry comprising the first entry; determining a position of the first entry in the first sub-table according to the hash value and a maximum number of entries that can be accommodated by the first sub-table; and obtaining metadata of the file system objects contained in the first directory according to the position of the first entry in the first sub-table.

[0011] In a possible implementation, the first sub-table includes an entry field and a name field, the entry field is configured to store all entries included in the first sub-table, and the name field is configured to store the name of a file system object included in a directory corresponding to each of the entries included in the first sub-table; and the obtaining of the metadata of the file system object included in the first directory according to the position of the first entry in the first sub-table includes: obtaining the names of all file system objects included in the first directory from the name field; and obtaining the attribute information of each file system object from the first entry stored in the entry field according to the hash value of the name of each file system object included in the first directory.

[0012] In a possible implementation, the metadata of the file system object included in the first directory includes indication information, and the indication information is used to indicate that the first directory belongs to a local file system or a cloud file system.

[0013] In a possible implementation, the indication information indicates that the first directory belongs to a cloud file system, and the outputting of the metadata of the file system object included in the first directory includes: displaying the metadata of the file system object included in the first directory and marking that the file system object belongs to a cloud file system.

[0014] In the implementation, the metadata belonging to a local file system and the metadata belonging to a cloud file system can be distinguished when the query result is displayed, and therefore, the user experience can be improved.

[0015] In a possible implementation, the method further includes: receiving a downlink synchronization message, wherein the downlink synchronization message includes the path name of the first directory and operation type indication information, and the operation type indication information is used to indicate an operation type; determining the hash value corresponding to the first directory according to the path name, and performing corresponding processing on the first entry corresponding to the first directory in the hash table according to the hash value and the operation type indicated by the operation type indication information; and performing corresponding processing on the metadata of the file system object included in the first directory in the metadata database according to the path name of the first directory and the operation type indicated by the operation type indication information.

[0016] In a possible implementation, the downlink synchronization message further includes the metadata of the file system object included in the first directory; and the performing of the corresponding processing on the first entry corresponding to the first directory in the hash table includes: adding the metadata in the first entry, deleting the metadata from the first entry, or updating the metadata in the first entry according to the metadata.

[0017] In a possible implementation, the method further includes: in response to a change in the metadata of the file system object contained in the first directory, performing the following operations: determining a hash value corresponding to the first directory according to a pathname of the first directory, obtaining the metadata of the file system object contained in the first directory from the hash table according to the hash value, and updating the metadata of the file system object contained in the first directory in the hash table according to the change in the metadata of the file system object contained in the first directory; and updating the metadata of the file system object contained in the first directory in the metadata database according to the change in the metadata of the file system object contained in the first directory.

[0018] In a possible implementation, the method further includes: sending an uplink synchronization message, wherein the uplink synchronization message includes the pathname of the first directory and operation type indication information, and the operation type indication information is used to indicate an operation type.

[0019] In a second aspect, an apparatus is provided, which includes units or modules for performing the method of any one of the first aspect.

[0020] Specifically, the apparatus can include a processing unit and a transceiver unit. The transceiver unit is configured to receive a query request, wherein the query request includes a pathname of a first directory, and the query request is used to query metadata of a file system object contained in the first directory, and the file system object includes a file and / or a subdirectory. The processing unit is configured to determine a hash value corresponding to the first directory according to the pathname, and obtain the metadata of the file system object contained in the first directory from a position corresponding to the hash value in a hash table; wherein the hash table includes at least one entry, the at least one entry includes a first entry corresponding to the first directory, the first entry contains the metadata of the file system object contained in the first directory, and the hash table is stored in a kernel memory; and output the metadata of the file system object contained in the first directory.

[0021] In a possible implementation, the processing unit is specifically configured to: a file manager in the processing unit sends a directory access request to a user space file system driver in a kernel space, wherein the directory access request includes the pathname of the first directory; and the user space file system driver determines a hash value corresponding to the first directory according to the pathname, and obtains the metadata of the file system object contained in the first directory from a position corresponding to the hash value in a hash table.

[0022] In a possible implementation, the processing unit is specifically configured to: determine a hash value corresponding to the first directory according to the path name; determine a position of a first sub-table in the hash table according to the hash value, the first sub-table including at least one entry, and the first entry being included in the at least one entry; determine a position of the first entry in the first sub-table according to the hash value and a maximum number of entries that can be accommodated by the first sub-table; and obtain metadata of the file system object included in the first directory according to the position of the first entry in the first sub-table.

[0023] In a possible implementation, the first sub-table includes an entry field and a name field, the entry field being configured to store all entries included in the first sub-table, and the name field being configured to store a name of a file system object included in a directory corresponding to each of the entries included in the first sub-table. The processing unit is specifically configured to: obtain the names of all file system objects included in the first directory from the name field; and obtain attribute information of each file system object from the first entry stored in the entry field according to a hash value of the name of the file system object.

[0024] In a possible implementation, the metadata of the file system object included in the first directory includes indication information, the indication information being configured to indicate that the first directory belongs to a local file system or a cloud file system.

[0025] In a possible implementation, the indication information indicates that the first directory belongs to a cloud file system. The processing unit is specifically configured to: display the metadata of the file system object included in the first directory, and mark that the file system object belongs to a cloud file system.

[0026] In a possible implementation, the transceiving unit is further configured to: receive a downlink synchronization message, the downlink synchronization message including a path name of the first directory and operation type indication information, the operation type indication information being configured to indicate an operation type; and the processing unit is further configured to: determine a hash value corresponding to the first directory according to the path name, perform corresponding processing on the first entry corresponding to the first directory in the hash table according to the hash value and the operation type indicated by the operation type indication information; and perform corresponding processing on the metadata of the file system object included in the first directory in the metadata database according to the path name of the first directory and the operation type indicated by the operation type indication information.

[0027] In a possible implementation, the downlink synchronization message further comprises metadata of the file system object contained in the first directory; and the processing unit is specifically configured to: add the metadata in the first entry; or delete the metadata from the first entry; or update the metadata in the first entry according to the metadata.

[0028] In a possible implementation, the processing unit is further configured to: in response to a change in the metadata of the file system object contained in the first directory, perform the following operations: determine the hash value corresponding to the first directory according to the pathname of the first directory, acquire the metadata of the file system object contained in the first directory from the hash table according to the hash value, and update the metadata of the file system object contained in the first directory in the hash table according to the change in the metadata of the file system object contained in the first directory; and update the metadata of the file system object contained in the first directory in the metadata database according to the change in the metadata of the file system object contained in the first directory.

[0029] In a possible implementation, the transceiving unit further comprises: a sending unit configured to send an uplink synchronization message, wherein the uplink synchronization message comprises the pathname of the first directory and operation type indication information, and the operation type indication information is used to indicate an operation type.

[0030] In a third aspect, an apparatus is provided, which comprises one or more processors configured to perform the method of any one of the first aspect.

[0031] In a fourth aspect, a readable storage medium is provided, which stores a program or instructions, and when the program or instructions are run on an apparatus, the program or instructions cause the apparatus to perform the method of any one of the first aspect.

[0032] In a fifth aspect, a chip or chip system is provided, which comprises a processor configured to support a computer apparatus to perform the method of any one of the first aspect.

[0033] In a sixth aspect, a program product is provided, which comprises a program; and when the program is run on a computer, the program causes the computer to perform the method of any one of the first aspect. BRIEF DESCRIPTION OF DRAWINGS

[0034] FIG. 1 is a schematic diagram of an architecture of a conventional file system;

[0035] FIG. 2 is a schematic diagram of a metadata access process implemented based on the architecture of the conventional file system;

[0036] FIG. 3 is a schematic diagram of an application scenario of an embodiment of the present application;

[0037] FIG. 4 is a schematic diagram of a hardware structure of a terminal device according to an embodiment of the present application;

[0038] FIG. 5 is a software system architecture block diagram of a terminal device according to an embodiment of the present application;

[0039] FIG. 6 is a schematic diagram of a simplified structure of a terminal device according to an embodiment of the present application;

[0040] FIG. 7 is a schematic diagram of a software system architecture of a terminal device according to an embodiment of the present application;

[0041] FIG. 8 is a schematic diagram of a software system architecture of a terminal device based on components such as a file manager, VFS and FUSE according to an embodiment of the present application;

[0042] FIG. 9 is a schematic diagram of a flow of downlink synchronization according to an embodiment of the present application;

[0043] FIG. 10 is a schematic diagram of a flow of updating a local file system by a terminal device according to an embodiment of the present application;

[0044] FIG. 11 is a schematic diagram of a flow of uplink synchronization according to an embodiment of the present application;

[0045] FIG. 12 is a schematic diagram of a query flow according to an embodiment of the present application;

[0046] FIG. 13 is a schematic diagram of a user interface provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to more clearly understand the embodiments of the present application, first, technical terms related to the embodiments of the present application are introduced.

[0048] (1) File System

[0049] A computer manages and stores data through a file system. The file system is a method and data structure for organizing files and storing the files on a hard disk drive, flash drive, or any other storage device. The file system divides data on a storage device into single pieces called files. In addition, the file system can store data about the files, such as a file name, permission, creation time, modification time, and other attributes.

[0050] The file system can further provide an indexing mechanism so that a user can access files stored in a storage device. For example, the file system can be organized into multiple levels of directories. In order to reach a specific file system object in the file system, such as a file or a subdirectory under a certain directory, a path can be used to specify the file system object storage location in the file system. The path includes a string indicating a directory, a subdirectory, and / or a file name.

[0051] The "file system object" in the embodiments of this application includes a file and / or a directory. For example, for a multi-level directory, the file system object is the collection of files and / or sub-directories under the multi-level directory. For example, the file system object under a first directory refers to the files / sub-directories contained in the first directory.

[0052] Currently, there are multiple different types of file systems. Different types of file systems can have different structures, logics, speeds, flexibilities, securities, and / or sizes.

[0053] (2) Distributed file system

[0054] A distributed file system (DFS) refers to a file system that manages physical storage resources that are not necessarily directly connected to a local node, but are connected to the node (which can be simply understood as a computer) through a computer network; or is a complete hierarchical file system formed by combining several different logical disk partitions or volume labels together. DFS can provide a logical tree file system structure for resources distributed at any location on the network, thereby making it more convenient for users to access shared files distributed on the network.

[0055] In simple terms, DFS is to expand a file system fixed at a certain location to any number of locations / multiple file systems, and numerous nodes form a file system network. Each node can be distributed at different locations and communicate and transfer data between nodes through a network.

[0056] The embodiments of this application can be applicable to a distributed file system.

[0057] (3) Metadata

[0058] The data about a file / directory can be referred to as the metadata (or simply metadata) of the file. Metadata refers to any data and / or information related to a file / directory.

[0059] In the embodiments of this application, some examples of the metadata of a file can include the base name of the file, the path name of the file, and / or any file system attribute, such as the file type (for example, a text document type), the file extension (for example,.doc for a document or.exe for an executable file), the file size, the file access time, the file modification time, the number of links associated with the file, the user identity (ID), the group ID, and the file permissions, etc.

[0060] For example, for a file "documentl.doc" stored under the directory " / a / b / c", the base file name (which can also be referred to as the file name) is "documentl", the file extension is ".doc", and the storage path name of the file is / a / b / c.

[0061] In addition, the metadata can also include custom attributes and / or tags, such as file characteristics (e.g., audio and video) and / or content-based information (e.g., motion picture experts group layer 4 video (mpeg4)). The custom attributes can be regarded as specific metadata customized for the file.

[0062] Similarly, some examples of the metadata of a directory or a subdirectory can include the name, the path name and / or any file system attributes of the directory / subdirectory, such as the access time, the modification time, the access permission, etc.

[0063] It should be understood that in this application, the directory name and the path name are equivalent and can be used interchangeably.

[0064] Referring to FIG. 1, a schematic diagram of an architecture of a conventional file system is shown.

[0065] As shown in FIG. 1, the system architecture includes a file manager, a virtual file system (VFS), a filesystem in userspace (FUSE) and a metadata database (DB).

[0066] The file manager can implement file management operations by invoking the VFS in response to file management requests from the application layer. The VFS is a software layer in the kernel, which provides file system interfaces for programs in the user space, and also provides an abstraction function in the kernel, allowing different file systems to coexist. The VFS can establish a structure model in the memory, which includes a plurality of inodes corresponding to each file (and directory), i.e., each file (and directory) is mapped to an inode and has only one corresponding inode, which contains metadata (such as access permission, last modified date, etc.) and a pointer to the execution file data. The FUSE is a user-space filesystem framework, which allows file systems to be implemented in the user space. The FUSE includes a kernel module and a FUSE daemon. The kernel module is registered as a FUSE driver when it is loaded. The metadata DB is used to store the metadata of the file system.

[0067] In the architecture, the file manager and the FUSE daemon are located in the user space, and the VFS and the FUSE driver are located in the kernel space.

[0068] Based on the file system architecture shown in FIG. 1, the metadata access flow can be as shown in FIG. 2.

[0069] Referring to FIG. 2, a schematic diagram of a metadata access flow implemented based on a conventional file system architecture is shown.

[0070] As shown in FIG. 2, the file manager, in response to an access request (shown as readir in the figure) for a specified directory, sends the access request to the VFS; the VFS, based on the virtual file system architecture, converts the access request into an access request for a corresponding inode in the virtual file system architecture, and passes the access request to the FUSE driver; the FUSE driver forwards the request to the FUSE daemon; the FUSE daemon, in response to the request, obtains the file names (may also include the names of subdirectories) of the files contained in the corresponding directory from the metadata DB, and returns a response. The response returns to the file manager along the original route.

[0071] Based on the mechanism of the Unix operating system, after receiving the response, the file manager initiates a flow of querying the metadata (such as file attributes) of each file name (may also include the names of subdirectories) under the directory (see the lookup flow in FIG. 2). If the directory includes multiple files / subdirectories, the query flow will be executed multiple times until the metadata of all files / subdirectories under the directory is obtained.

[0072] In the flow shown in FIG. 2, the file manager and the FUSE daemon are located in the user space, the metadata DB is also located in the user space because it provides business-oriented (or user-oriented) functions, and therefore the terminal device needs to be in the user state during the running of the file manager and the FUSE daemon; the VFS and the FUSE driver are located in the kernel space, and the terminal device needs to be in the kernel state during the running of the VFS and the FUSE driver. Therefore, in the flow shown in FIG. 2, the terminal device needs to switch between the user state and the kernel state multiple times, resulting in large system overheads such as scheduling overhead, message communication overhead, and data transmission overhead, long access latency, and low access efficiency. If there are a large number of files under the directory requested to be accessed, the switching between the user state and the kernel state of the terminal device will also be more frequent, which will further increase the access latency. For example, when there are more than 1000 files under a directory, the access latency can be more than 1 minute.

[0073] In addition, in the conventional end-to-cloud and distributed file system, the metadata is saved in the metadata DB, and when the data volume of the metadata is large, the performance of the metadata DB will also decrease, which will also increase the access latency and reduce the access efficiency.

[0074] To this end, the embodiments of the present application provide a file system access method and a management method, and related devices that can implement the above methods. In the embodiments of the present application, the metadata of the file system is stored in a hash table located in the kernel space (kernel memory), so that during metadata access, the metadata can be obtained from the hash table in the kernel mode without switching to the user mode to query the metadata database, thereby reducing the system overhead caused by switching between the kernel mode and the user mode, and thus reducing the access latency and improving the access efficiency.

[0075] The embodiments of the present application can be applied to various file systems, such as a distributed file system.

[0076] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0077] Referring to FIG. 3, it is a schematic diagram of an application scenario of the embodiments of the present application. In the scenario 1000 as shown in FIG. 3, the terminal device (1001a, 1001b, 1001c) communicates with the server 1002 through the network 1003.

[0078] The terminal device (1001a, 1001b, 1001c) can download the metadata of the file system from the server 1002, or receive the metadata of the file system synchronized to the terminal device by the server 1002. The terminal device (1001a, 1001b, 1001c) stores the metadata from the server 1002 into a hash table located in the kernel space of the terminal device. The terminal device (1001a, 1001b, 1001c) can query the metadata of the file system from the network side based on the hash table.

[0079] The terminal device (1001a, 1001b, 1001c) can be a mobile phone, a wearable device, a tablet computer, a notebook computer, a smart screen, a vehicle-mounted terminal, a computer, a computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a vehicle-mounted terminal, a virtual reality (VR) device / augmented reality (AR) device, an artificial intelligence (AI) device, and the like. The operating system installed on the terminal device includes but is not limited to or other operating systems. The present application does not limit the specific type of the terminal device and the operating system installed thereon.

[0080] The server 1002 can provide cloud computing services. The server 1002 can also be replaced by a cloud server platform. In embodiments of the present application, the file on the server or the cloud server platform is referred to as a cloud file or a cloud-end file.

[0081] The network 1003 can be any type of network, for example, an electrical network and / or an optical network, etc.

[0082] Referring to FIG. 4, a possible hardware structure of the terminal device 100 in embodiments of the present application is shown. The terminal device can execute the method provided in embodiments of the present application. The terminal device 100 can 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 loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0083] The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 108C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, and a bone conduction sensor 108M.

[0084] The processor 110 can include one or more processing units. For example, the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, a display processing unit (DPU), a neural-network processing unit (NPU), and / or the like. Different processing units can be independent devices or integrated in one or more processors. In some embodiments, the terminal device 100 can also include one or more processors 110. The processor is the nerve center and command center of the terminal device 100. The processor can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions. The processor 110 can also be provided with a memory for storing instructions and data.

[0085] The terminal device 100 can realize display functions through a GPU, a display screen 194, and an application processor AP, and the like. The display screen 194 is used to display images, videos, and the like.

[0086] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware.

[0087] FIG. 5 is a software system architecture block diagram of a terminal device according to an embodiment of the present application. As shown in FIG. 5, the software system architecture of the terminal device can be a layered architecture, for example, the software can be divided into several layers, and the layers communicate through software interfaces. In some embodiments, the operating system is divided into five layers, from top to bottom, the application layer, the application framework layer (FWK), the runtime and system library, the kernel layer, and the hardware layer.

[0088] The application program layer can include a series of application packages. As shown in FIG. 5, the application program layer can include a camera, settings, a skin module, a user interface (UI), third-party applications, and the like. Among them, the third-party applications can include a wireless local area network (WLAN), music, a call, Bluetooth, a video, a memo, a note, and the like.

[0089] In a possible implementation, the application program can be developed using the java language, and is completed by calling an application programming interface (API) provided by the application program framework layer. A developer can interact with the underlying layer (such as a hardware layer, a kernel layer, and the like) of the operating system through the application program framework layer to develop an application program. The application program framework layer is mainly a series of services and management systems of the operating system.

[0090] The application program framework layer provides an application programming interface and a programming framework for the application program of the application program layer. The application program framework layer includes some predefined functions. As shown in FIG. 5, the application program framework layer can include an activity manager, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0091] The runtime includes a core library and a virtual machine. The runtime is responsible for scheduling and management of the operating system. The core library includes two parts: one part is a function function required to be called by the java language, and the other part is a core library of the operating system. The application program layer and the application program framework layer run in the virtual machine. The virtual machine executes the java files of the application program layer and the application program framework layer into binary files. The virtual machine is used to perform functions such as management of an object life cycle, stack management, thread management, security and exception management, and garbage collection.

[0092] The system library can include a plurality of functional modules. For example, a surface manager, a media framework, a three-dimensional graphics processing library (e.g., OpenGL ES), a two-dimensional graphics engine (e.g., SGL), etc. The surface manager is used to manage the display subsystem and provides a plurality of applications with a fusion of two-dimensional and three-dimensional layers. The media framework supports a plurality of commonly used audio, video format playback and recording, and static image files, etc. The media framework can support a plurality of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The three-dimensional graphics processing library is used to implement three-dimensional graphics drawing, image rendering, synthesis, and layer processing, etc. The two-dimensional graphics engine is a drawing engine for two-dimensional drawing. In some embodiments, the three-dimensional graphics processing library can be used to draw three-dimensional motion trajectory images, and the two-dimensional graphics engine can be used to draw two-dimensional motion trajectory images.

[0093] The kernel layer is a layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.

[0094] The hardware layer can include various sensors, such as an acceleration sensor, a gravity sensor, a touch sensor, etc.

[0095] It should be understood that the hardware structure of the terminal device can be as shown in FIG. 4, and the software system architecture can be as shown in FIG. 5, where the software system architecture in the terminal device corresponds to software programs and / or modules stored in the internal memory 121, and the processor 110 can run the software programs and applications stored in the internal memory 121 to execute the method processes provided in the embodiments of the present application.

[0096] The embodiments of the present application can enhance the functions of the kernel layer, the system library, the application program framework layer, etc., to implement the methods provided in the embodiments of the present application.

[0097] The terminal device 200 shown in FIG. 6 can be a terminal device (1001a, 1001b, 1001c) in the system 1000 shown in, for example, FIG. 3, the hardware structure of which can refer to the architecture shown in FIG. 4, and the software structure of which can refer to the architecture shown in FIG. 5, and FIG. 6 only shows some structures related to the present application. At least some of the features and / or methods described in the present application can be implemented in the apparatuses or modules of the terminal device 200. For example, the features and / or methods in the present application can be implemented using hardware, firmware, and / or software installed to run on hardware.

[0098] As shown in FIG. 6, the terminal device 200 can include one or more input / output (I / O) interfaces 220 and one or more network interfaces 230. The I / O interface 220 can be coupled to an I / O device (e.g., a display screen with touch functionality) and can include hardware logic and / or components for reading data from and / or writing data to the I / O device. The network interface 230 can be coupled to a computer data network and can include hardware logic and / or components for receiving files and / or metadata from other network nodes in the network, e.g., from a server, and for synchronizing files and / or metadata to the server.

[0099] The processor 210 can include one or more multi-core processors and / or memories that can be used as data storage devices, buffers, etc. The processor 210 can be implemented as a general-purpose processor or can be part of one or more application specific integrated circuits (ASICs) and / or digital signal processors (DSPs). The processor 210 can include (or said to run) a processing unit 710 and an application / service 720, which can be used to implement and / or support a metadata indexing and / or searching mechanism, which will be described more fully in FIG. 7. In alternative embodiments, the file system metadata indexing function and the searching processing function can be implemented as instructions stored in the memory 240 that can be executed by the processor 210.

[0100] The memory 240 can include a cache memory, e.g., a random-access memory (RAM), for temporarily storing content. In addition, the memory 240 can include a long-term storage device, e.g., a read-only memory (ROM), for relatively longer storing content. For example, the cache memory and the long-term storage device can include a dynamic RAM (DRAM), a solid-state drive (SSD), a hard disk, or a combination thereof. The memory 240 can be used to store a metadata DB, a hash table, etc., such as the metadata DB. The memory 240 can be an external memory of the processor or an internal memory of the processor, e.g., the memory 240 can be an external memory connected to the processor through an external memory interface in FIG. 4 or an internal memory 121.

[0101] It should be understood that by programming and / or loading executable instructions onto terminal device 200, at least one of processor 210 and / or memory 240 is modified, thereby partially transforming terminal device 200 into a specific machine or apparatus capable of implementing the methods provided in this application, such as a multi-core forwarding architecture. Importantly for electrical engineering and software engineering techniques, functionality that can be implemented by loading executable software into a computer can be translated into a hardware implementation using well-known design rules. The decision between implementing a concept in software or hardware typically depends on considerations of design stability and the number of units to be produced, rather than any issues involved in migrating from the software domain to the hardware domain.

[0102] Figure 7 is a schematic diagram of the software system architecture of the terminal device 200 shown in Figure 6.

[0103] Application / service 720 may include one or more of the following modules: synchronization module, update module, and query module.

[0104] The synchronization module enables the downlink synchronization of metadata from the cloud file system and cloud files. For example, the synchronization module receives a downlink synchronization message from the server via a network interface, which includes file system metadata. The synchronization module parses the downlink synchronization message to obtain the metadata it carries and sends the metadata to the processing unit 710. The indexing engine 711 in the processing unit 710 stores the metadata in both the metadata database 730 and the hash table 740. As another example, after the terminal device sends a request to the server to download a cloud file, the synchronization module receives the cloud file from the server via the network interface and sends the cloud file to the processing unit 710. The processing unit 710 then stores the cloud file in the terminal device's local file system 713.

[0105] The update module can implement the update of metadata and files of the local file system of the terminal device and the uplink synchronization. For example, when the metadata of a file / subdirectory under a certain directory changes (e.g., a new file or subdirectory is created, or the original file or subdirectory is modified, etc.), the event can be detected, and an update request can be generated based on the event and sent to the update module. The update module can respond to the update request for updating the metadata (e.g., including modifying or deleting or adding metadata) from the I / O interface 220, format the request, and send the request to the processing unit 710; the indexing engine 711 in the processing unit 710 responds to the request and updates the metadata in the metadata database 730 and the hash table 740, respectively. For another example, the update module can also respond to the request for updating the file (e.g., modifying or deleting or adding the file) from the I / O interface 220, send the request to the processing unit 710, and the processing unit 710 responds to the request and updates the local file system 713 of the terminal device.

[0106] The query module can implement the function of querying the metadata stored locally by the terminal device. For example, the query module can respond to the query request for querying the metadata from the I / O interface 220, format the query request, send the request to the processing unit 710, and the search engine 712 in the processing unit 710 responds to the request and obtains the metadata from the hash table 740.

[0107] The indexing engine 711 is a software component for managing the indexing stored in the metadata database and the hash table. The indexing engine 711 indexes the files by metadata.

[0108] The indexing engine 711 can store the metadata associated with the file system 713 into the hash table 740 by applying a hash function to the directory name. For example, the indexing engine 711 can employ any hash scheme that provides a uniform random distribution, such as the BuzHash scheme that generates a hash value by applying a bit shift and XOR function to a pseudo-random number. The indexing engine 711 generates an entry for each file system directory in the hash table 740, as explained more fully below.

[0109] The indexing engine 711 can also generate the metadata database 730 for storing the metadata associated with the file system 713. In an embodiment, the indexing engine 711 separately examines each file in the file system 713 to generate the metadata of the file, for example, by employing the Unix system call stat() to retrieve file attributes. The indexing engine 711 can map the metadata to an inode.

[0110] The search engine 712 is a software component configured to receive a query request from the query module, search metadata based on the hash table, and send a query result to the query module.

[0111] The file system 713 is a software component, for example, an I / O interface, communicatively coupled to the memory and configured to manage the naming and storage location of files stored in the memory. For example, the file system 713 can include a multi-level directory of files stored on the memory.

[0112] It should be understood that the system of the terminal device shown in FIG. 7 can be in the form as shown or other forms that can be constructed by those skilled in the art, and the present application does not limit this.

[0113] In one possible implementation, in the system architecture shown in FIG. 7, the functions of the indexing engine 711 and the search engine 712 can be implemented based on the following components: a file manager, a VFS, a FUSE, and the like. For example, FIG. 8 shows a software system architecture based on the file manager, the VFS, and the FUSE, and the like, according to an embodiment of the present application.

[0114] As shown in FIG. 8, the software system architecture of the terminal device can include a file manager, a VFS, and a FUSE. The FUSE includes a FUSE driver running in the kernel space and a FUSE daemon running in the user space.

[0115] Optionally, the FUSE daemon can include a synchronization module and an update module. The synchronization module is configured to implement the downlink synchronization of files and / or metadata, and the update module is configured to implement the local update and uplink synchronization of files and / or metadata.

[0116] It should be understood that the above-mentioned software system architecture can be in the form as shown or other forms that can be constructed by those skilled in the art, and the present application does not limit this. For example, the “FUSE” in FIG. 8 can be replaced by a harmonyOS distributed file system (MDFS).

[0117] Based on the system architecture shown in FIG. 8, the downlink synchronization process can be as shown in FIG. 9.

[0118] Referring to FIG. 9, FIG. 9 is a flowchart of the downlink synchronization process according to an embodiment of the present application. As shown in the figure, the process can include the following steps:

[0119] Step 901: The server sends a downlink synchronization message to the terminal device.

[0120] The downlink synchronization message is used to synchronize the metadata in the file system in the cloud to the terminal device.

[0121] The downlink synchronization message can include operation type indication information and a path name of the first directory, where the first directory is a target of the metadata to be synchronized. Optionally, the downlink synchronization message can also include metadata of files / subdirectories contained in the first directory. The operation type indication information is used to indicate the operation type, that is, to indicate the operation mode of the first directory or the metadata of the files / subdirectories contained in the first directory, for example, the operation mode can include one of adding, modifying, and deleting.

[0122] In a possible implementation, the downlink synchronization message can be periodically sent.

[0123] In another possible implementation, the downlink synchronization message can also be sent when the metadata in the file system in the cloud changes. For example, when a file in the file system in the cloud is updated by a terminal device A, the metadata in the file system is also updated accordingly. In this case, the server can send a downlink synchronization message to a terminal device B to synchronize the metadata in the file system in the cloud to the terminal device B. The terminal device A and the terminal device B can be terminal devices associated with the same user account.

[0124] At step 902, after the terminal device receives the downlink synchronization message, the synchronization module in the FUSE daemon in the terminal device can update the hash table according to the downlink synchronization message.

[0125] In this step, the terminal device can process a first entry corresponding to the first directory in the hash table according to the operation type indication information and the path name of the first directory in the downlink synchronization message. The first entry is an entry corresponding to the first directory.

[0126] For example, if the downlink synchronization message includes the path name of the first directory and the metadata of the files / subdirectories contained in the first directory, and the operation type indication information in the downlink synchronization message indicates an adding operation, if the terminal device finds the first entry corresponding to the first directory in the hash table, the terminal device adds the metadata in the downlink synchronization message to the first entry; if the terminal device does not find the first entry in the hash table, the terminal device adds the first entry to the hash table and adds the metadata in the downlink synchronization message to the first entry.

[0127] For another example, if the path name of the first directory and the metadata of the files / sub-directories contained in the first directory are included in the down synchronization message, and the operation type indication information in the down synchronization message indicates a deletion operation, the terminal device finds the first entry corresponding to the first directory in the hash table, and deletes the corresponding metadata in the first entry according to the metadata included in the down synchronization message.

[0128] For another example, if the path name of the first directory and the metadata of the files / sub-directories contained in the first directory are included in the down synchronization message, and the operation type indication information in the down synchronization message indicates a deletion operation, the terminal device finds the first entry corresponding to the first directory in the hash table, and deletes the corresponding metadata in the first entry according to the metadata included in the down synchronization message.

[0129] For another example, if the path name of the first directory is included in the down synchronization message, and the operation type indication information in the down synchronization message indicates a deletion operation, the terminal device deletes the first entry corresponding to the first directory in the hash table.

[0130] Step 903: The synchronization module in the FUSE daemon updates the metadata DB according to the received down synchronization message.

[0131] In this step, the terminal device can perform corresponding processing on the metadata of the file system objects contained in the first directory in the metadata DB according to the operation type indication information in the down synchronization message and the path name of the first directory and the like.

[0132] For example, if the path name of the first directory and the metadata of the files / sub-directories contained in the first directory are included in the down synchronization message, and the operation type indication information in the down synchronization message indicates an addition operation, the terminal device adds the metadata in the down synchronization message to the first table entry in the metadata DB if the first table entry corresponding to the first directory is found in the metadata DB; and the terminal device adds the first table entry in the metadata DB if the first table entry is not found in the metadata DB, and adds the metadata in the down synchronization message to the first table entry.

[0133] For another example, if the path name of the first directory and the metadata of the files / sub-directories contained in the first directory are included in the down synchronization message, and the operation type indication information in the down synchronization message indicates a modification operation, the terminal device finds the first table entry corresponding to the first directory in the metadata DB, and updates the metadata in the first table entry according to the metadata included in the down synchronization message.

[0134] For another example, if the path name of the first directory and the metadata of the files / sub-directories contained in the first directory are included in the downlink synchronization message, and the operation type indication information in the downlink synchronization message indicates a deletion operation, the terminal device finds the first entry corresponding to the first directory in the metadata DB, and deletes the corresponding metadata in the first entry according to the metadata included in the downlink synchronization message.

[0135] For another example, if the path name of the first directory is included in the downlink synchronization message, and the operation type indication information in the downlink synchronization message indicates a deletion operation, the terminal device deletes the first entry corresponding to the first directory in the metadata DB.

[0136] Step 904: The FUSE daemon sends a response message to the server. This step is optional.

[0137] It should be understood that the order of the steps in the flow shown in FIG. 9 above is only one possible example, and the present application is not limited in this regard. For example, step 902 and step 903 can be exchanged in order, or executed synchronously.

[0138] Based on the system architecture shown in FIG. 8, the flow of the terminal device updating the local file system can include: when the metadata of the files / sub-directories under the first directory changes (for example, when the terminal device detects that the user performs an operation of adding, modifying or deleting the files / sub-directories under the first directory in the file system), the event can be detected, and an update request can be generated based on the event and sent to the update module in the FUSE daemon.

[0139] The update module in the FUSE daemon receives the update request, which includes the path name of the first directory and the operation type indication information. Optionally, the update request can also include the metadata of the files / sub-directories under the first directory. The update module performs corresponding operations on the hash table and the metadata DB according to the update request. The implementation of the update module performing corresponding operations on the hash table and the metadata DB can refer to the implementation of the synchronization module performing corresponding operations on the hash table and the metadata DB.

[0140] Optionally, in the case where the user operation also requests to update the file, the update module can also update the file in the file system, for example, create a new file in the file system, or modify the data of the file in the file system, or delete the file in the file system.

[0141] In one possible implementation, if the metadata DB fails to update, the update module rolls back the data in the hash table to the state before this update, so as to ensure that the metadata stored in the hash table is consistent with the metadata stored in the metadata DB. Similarly, if the hash table fails to update, the metadata DB is rolled back.

[0142] It should be understood that the "update request" above can also be replaced by other requests, such as a management request or an xth request, etc., which are not limited in the present application. Depending on the different update operations, the update request can be a request for requesting to create file / directory metadata, or a request for requesting to modify file / directory metadata, or a request for requesting to delete a file / directory, etc.

[0143] Based on the system architecture shown in FIG. 8, the uplink synchronization process can include that the update module in the FUSE daemon sends an uplink synchronization message to the server, which includes the path name of the first directory and operation type indication information, and optionally, can also include the metadata of the files / subdirectories contained in the first directory.

[0144] Optionally, the update module can obtain the metadata from the metadata DB or from the hash table, and carry the metadata in the uplink synchronization message. The metadata obtained by the update module can be the newly stored metadata after the last uplink synchronization process. That is, the uplink synchronization process can be periodically executed.

[0145] Optionally, the update module can respond to the metadata change of the first directory or the files / subdirectories contained in the first directory, update the hash table and the metadata DB, and then send an uplink synchronization message to the server, which carries the changed metadata. That is, the uplink synchronization process can be triggered by the metadata change of the local file system of the terminal device.

[0146] It should be understood that the "update request" above can also be replaced by other requests, such as a management request or an xth request, etc., which are not limited in the present application. Depending on the different update operations, the update request can be a request for requesting to create file / directory metadata, or a request for requesting to modify file / directory metadata, or a request for requesting to delete a file / directory, etc.

[0147] Based on the system architecture shown in FIG. 8, the metadata query process can include that the file manager responds to a query request for a specified directory (e.g., the first directory), sends the query request to the VFS; the VFS sends a directory access request to the FUSE driver according to the access request; the FUSE driver obtains the metadata by querying the hash table, and returns the obtained metadata to the file manager, which will be described more fully below.

[0148] It should be understood that the "query request" and "directory access request" above can also be replaced by other requests, such as a management request or an xth request, etc., which are not limited in the present application.

[0149] In the embodiments of the present application, the metadata can be stored in a hash table. The hash table can exist in a core memory. The core memory is also referred to as kernel memory, which is memory allocated by an operating system for kernel objects. In one possible manner, the hash table is stored in a non-volatile storage medium and loaded into the kernel memory when the system starts. In another possible implementation, the hash table can be established when the system starts and eliminated when the system shuts down. For example, the hash table can be established by traversing the metadata DB when the system starts.

[0150] Unlike the metadata DB which cannot be accessed in the kernel mode, the hash table is located in the kernel space and can be accessed in the kernel mode. In this way, the switching between the kernel mode and the user mode is not required in the process of accessing the metadata, so that the system overhead and latency caused thereby can be reduced, and the access performance can be improved.

[0151] The hash table can include a plurality of entries, each of which corresponds to and uniquely corresponds to a directory in the file system, and each of which stores the metadata of the file system objects (including files and / or subdirectories) contained in the corresponding directory.

[0152] The position of the entry corresponding to a directory in the hash table can be determined according to the hash value of the path name of the directory. That is, the storage position of the entry corresponding to a directory in the hash table can be determined according to the hash value of the path name of the directory.

[0153] The hash value corresponding to the path name of a directory can be obtained by a hash function. Optionally, any hash function providing uniform random distribution can be used, for example, the BuzHash function which generates a hash value by applying a bit shift and XOR function to a pseudo-random number. The embodiments of the present application do not limit the type of hash function.

[0154] Referring to FIG. 10, it is a schematic diagram of the correspondence between an entry and a directory according to the embodiments of the present application. As shown in the figure, the file system of an application program includes a plurality of directories, such as directory 1 and directory 2, and the directory 1 includes files 1 and 2, and subdirectories 1_1 and 1_2. Correspondingly, the hash table includes a plurality of entries, such as entry 1, entry 1_1, entry 1_2 and entry 2. The number of entries in the hash table is the same as the number of directories (including subdirectories) in the file system.

[0155] In the item 1, the metadata of all files and the related information of sub-directories contained in the directory 1 are stored, for example, the name, path name and file attribute of the file 1, the name, path name and file attribute of the file 2, the path name of the sub-directory 1, and the path name of the sub-directory 2. Similarly, the item 1_1 corresponds to the sub-directory 1_1, and the metadata of all files and the related information of sub-directories contained in the sub-directory 1_1 are stored in the item 1_1; the item 1_2 corresponds to the sub-directory 1_2, and the metadata of all files and the related information of sub-directories contained in the sub-directory 1_2 are stored in the item 1_2; the item 2 corresponds to the sub-directory 2, and the metadata of all files and the related information of sub-directories contained in the sub-directory 2 are stored in the item 2.

[0156] In some embodiments, in the distributed file system scenario, the metadata of the file system objects contained in the corresponding directory can be stored in the item, and indication information can also be stored in the item, the indication information being used to indicate whether the directory corresponding to the item is a local directory or a cloud directory. The directory in the file system of the cloud server is referred to as a cloud directory, and the directory in the file system of the terminal device is referred to as a local directory.

[0157] Each item in the hash table can contain the following information domains (or fields):

[0158] Metadata domain: used to store metadata, such as the name of a file and the attribute information of the file.

[0159] Optionally, the metadata domain can include one or more of the following information domains:

[0160] Name domain: used to store the hash value (or Hash value) of the name of a file / sub-directory; wherein the name of the sub-directory is the path name of the sub-directory.

[0161] Mode domain: used to store the access permission of a file / sub-directory.

[0162] User ids domain: used to store the identifier of the owner of a file / sub-directory.

[0163] Namelen domain: used to store the length information of the name of a file / sub-directory.

[0164] Size domain: used to store the length information of a file.

[0165] Times domain: used to store time-related information, for example, the mtime domain can be included in the times domain, and used to store the time of last modification.

[0166] Optionally, the metadata field can further include the following information fields:

[0167] - flag field: used to store indication information indicating whether the file / subdirectory belongs to the local file system or the cloud file system.

[0168] Optionally, each entry in the hash table can further include some reserved information fields, which can be used for subsequent evolution technology.

[0169] It should be understood that the above only exemplarily lists the information that the entry in the hash table can include, and the present application does not limit this.

[0170] In some embodiments, an open hash mechanism can be used to reduce the depth of the hash table, so as to accelerate the search speed and efficiency. The number of sub-tables (also referred to as hash buckets) can be determined in advance, and a hash function is designed such that the directory can be mapped to one of the sub-tables. The sub-table includes one or more entries, each of which corresponds to a directory. The entries included in the sub-table are connected by a single linked list, and the head byte (or the first address) of the single linked list is stored in the hash table, and the correspondence between the entries and the directories in the sub-table can be ensured to be identified.

[0171] The number of sub-tables included in the hash table can be set according to the size of the file system (for example, the number of directories included), the demand for search efficiency, and other factors. For example, the hash function is the value of the path name of the directory modulo 2 N-1 , and the directory can be mapped to 2 N-1 sub-tables according to the remainder obtained by the modulo operation of the value of the path name modulo 2 N-1 . Exemplarily, when N = 5, the number of sub-tables is 16.

[0172] Taking the example of 16 sub-tables included in the hash table, referring to FIG. 11, a structure diagram of the hash table based on the open hash mechanism provided by the embodiments of the present application is shown.

[0173] As shown in FIG. 11, the hash table includes 16 sub-tables. Taking sub-table 1 as an example, sub-table 1 can include the following information fields:

[0174] (1) version number field: used to store the version number of the sub-table. The version number is an identifier of the technology evolution. This information field is an optional information field.

[0175] (2) bit sequence field: used to store a bitmap. The number of bits occupied by the bitmap is the number of entries that can be accommodated by sub-table 1, and each bit in the bitmap corresponds to an entry, and the bit value is used to indicate whether the corresponding entry is empty. This information field is an optional information field.

[0176] (3) Entry field: used to store entries. One or more entries can be stored in the entry field. The information contained in each entry can refer to the foregoing.

[0177] Taking the example of the sub-table 1 containing 3 entries, the 3 entries correspond to directory 1, directory 2 and directory 3 respectively. In this case, the entry field contains the names of the files / subdirectories under the 3 directories, and the length of the entry field is the total length of the names of the files / subdirectories under the 3 directories.

[0178] The maximum length of the entry field is related to the number of entries that can be accommodated by the sub-table 1, or the length of the bitmap. Taking the example of the number of entries that can be accommodated by the sub-table 1 being K, and each entry occupying L bytes, the maximum length of the entry field is L*K bytes.

[0179] (4) Name field: used to store the names of the files / subdirectories under the directory corresponding to the entry.

[0180] Taking the example of the sub-table 1 containing 3 entries, the 3 entries correspond to directory 1, directory 2 and directory 3 respectively. In this case, the name field contains the names of the files / subdirectories under the 3 directories, and the length of the entry field is the total length of the names of the files / subdirectories under the 3 directories.

[0181] The maximum length of the name field is related to the number of entries that can be accommodated by the sub-table 1. Taking the example of the number of entries that can be accommodated by the sub-table 1 being K, and the name field of each entry occupying S bytes, the maximum length of the name field is S*K bytes.

[0182] (5) Reserved information field: the information field can be used for subsequent expansion. The information field is an optional information field.

[0183] Each entry contains the metadata of all the files contained in the directory corresponding to the entry. For example, as shown in FIG. 11, the metadata of file 1 and file 2 respectively includes: the hash value of the file name (such as the hash in the figure), the access permission of the file (such as the mode in the figure), the length of the file (such as the size in the figure), the modification time of the file (such as the times in the figure), the flag used to indicate whether the file is a cloud file or a local file (such as the flag in the figure), etc. Optionally, the metadata field corresponding to the file / subdirectory such as file 1 or file 2 can also include indication information used to indicate whether it is a file or a directory, which can be stored in an independent information field or located in the mode information field (for example, occupying one bit in the mode information field).

[0184] Compared with the metadata database, the structure of the above hash table does not need to support business-oriented functions, and the data structure is simple, so better access performance can be obtained.

[0185] Taking the hash table structure shown in FIG. 10 and FIG. 11 as an example, the operation of updating the hash table can include the following cases:

[0186] Case 1: creating a new file or creating a new subdirectory under the first directory.

[0187] Taking the creation of a new file under the first directory as an example, the updating module or the synchronization module can obtain the path name of the first directory and the name of the newly created file. Optionally, the attribute information of the file, such as the access permission, the creation time, etc. of the file can also be obtained.

[0188] Taking the creation of a new file in the above case 1 as an example, after the updating module or the synchronization module determines the storage location of the entry corresponding to the first directory (hereinafter referred to as the first entry) in the hash table according to the hash value of the path name of the first directory, the metadata of the new file is added in the first entry. Taking the hash table shown in FIG. 11 as an example, entry 1 is the first entry corresponding to the first directory. The updating module or the synchronization module adds the information field corresponding to file 3 (the newly created file) in entry 1, stores the metadata of file 3 in the information field, and the structure of the information field is the same as that of the metadata information field of file 1 and file 2; in the "name" field in the information field corresponding to subtable 1, the name of file 3 is added in the file / subdirectory name corresponding to entry 1.

[0189] Taking the creation of a new subdirectory in the above case 1 as an example, after the updating module or the synchronization module determines the storage location of the first entry corresponding to the first directory in the hash table according to the hash value of the path name of the first directory, the metadata of the new subdirectory is added in the first entry, and an entry corresponding to the first subdirectory is added in the hash table. Taking the hash table shown in FIG. 11 as an example, entry 1 is the first entry corresponding to the first directory. The updating module or the synchronization module adds the information field corresponding to subdirectory 1_1 (the newly created subdirectory) in entry 1, stores the metadata of subdirectory 1_1 in the information field, and the structure of the information field is similar to that of the metadata information field of file 1 and file 2; in the "name" field in the information field corresponding to subtable 1, the name of subdirectory 1_1 is added in the file / subdirectory name corresponding to entry 1. The updating module or the synchronization module also determines the location in the hash table according to the hash value of the path name of subdirectory 1_1, taking entry 2 corresponding to the entry of subdirectory 1_1 as an example, the updating module adds entry 2 (entry 2 is used to store the metadata of the file / subdirectory contained in subdirectory 1_1) at the location, and updates the bitmap.

[0190] Case 2: modifying a file or a subdirectory under the first directory.

[0191] Modifying a file in the first directory can include modifying content of the file or modifying attributes of the file (e.g., modifying access permissions of the file, etc.). Accordingly, the updating module can obtain the path name of the first directory, the updated file name of the file, the updated attributes of the file (e.g., access permissions, last modification time, etc.).

[0192] Modifying a subdirectory in the first directory can include modifying the name of the subdirectory. Accordingly, the updating module can obtain the path name of the first directory and the updated name of the subdirectory.

[0193] Taking the modification of the file in case 2 above as an example, after the updating module determines the storage location of the first entry corresponding to the first directory in the hash table according to the hash value of the path name of the first directory, the updating module updates the metadata of the file in the first entry. Taking the hash table shown in FIG. 11 as an example, entry 1 is the first entry corresponding to the first directory. The updating module updates the last modification time and the file length of the file 3 (the modified file) in the information field corresponding to the file 3 in entry 1, such as updating the "size" field and the "times" field of the file 3.

[0194] Case 3: deleting a file or a subdirectory in the first directory.

[0195] When deleting a file in the first directory, the updating module or the synchronization module can obtain the path name of the first directory and the file name of the deleted file.

[0196] When deleting a subdirectory in the first directory, the updating module or the synchronization module can obtain the path name of the first directory and the name of the deleted subdirectory.

[0197] Taking the deletion of the file in case 3 above as an example, after the updating module or the synchronization module determines the storage location of the first entry corresponding to the first directory in the hash table according to the hash value of the path name of the first directory, the updating module or the synchronization module deletes the metadata of the file in the first entry. Taking the hash table shown in FIG. 11 as an example, entry 1 is the first entry corresponding to the first directory. If it is requested to delete the file 3 in the first directory, the updating module deletes the metadata information field of the file 3 in the information field corresponding to the file 3 in entry 1, and deletes the name of the file 3 in the name of the file / subdirectory corresponding to entry 1 in the "name" field in the information field corresponding to the subtable 1.

[0198] Taking the deletion of the subdirectory in case 3 above as an example, after determining the storage location of the first entry corresponding to the first directory in the hash table according to the hash value of the path name of the first directory, the updating module or the synchronization module deletes the relevant information of the subdirectory in the first entry, and deletes the entry corresponding to the subdirectory. Taking the hash table shown in FIG. 11 as an example, entry 1 is the first entry corresponding to the first directory. If it is requested to delete the subdirectory 1_1 under the first directory, the updating module or the synchronization module deletes the metadata information field of the subdirectory 1_1 in the information field corresponding to the directory 1, and deletes the name of the subdirectory 1_1 corresponding to entry 1 in the "name" field in the information field corresponding to the subtable 1. The updating module or the synchronization module further determines the entry corresponding to the subdirectory 1_1 in the hash table according to the hash value of the path name of the subdirectory 1_1, taking entry 2 corresponding to the subdirectory 1_1 as an example, the updating module deletes entry 2 in the "entry" field in the subtable 1, and deletes the names of all files / subdirectories under the subdirectory 1_1 in the "name" field, and updates the bitmap.

[0199] Case 4: deleting the first directory.

[0200] The updating module or the synchronization module can obtain the path name of the first directory.

[0201] Taking case 4 above as an example, after determining the storage location of the first entry corresponding to the first directory in the hash table according to the hash value of the path name of the first directory, the updating module or the synchronization module deletes the first entry. Taking the hash table shown in FIG. 11 as an example, entry 1 is the first entry corresponding to the first directory. If it is requested to delete the first directory, the updating module or the synchronization module deletes entry 1 in the subtable 1, updates the bitmap in the subtable 1, and deletes all file / subdirectory names corresponding to entry 1 in the "name" field of the subtable 1.

[0202] It should be understood that FIG. 11 only exemplarily shows a possible structure of the hash table based on the open hash mechanism, and the structure of the hash table is not limited in the present application.

[0203] According to the above architecture shown in FIG. 6, FIG. 7 or FIG. 8, and the hash table described above, when performing metadata access, it can be performed only in the kernel mode, without switching between the kernel mode and the user mode, so that the system overhead can be reduced and the access performance can be improved.

[0204] The metadata access process provided by the embodiments of the present application will be described below with reference to FIG. 12.

[0205] Referring to FIG. 12, it is a flowchart of accessing a file system object provided by the embodiments of the present application. As shown in the figure, the flowchart can include the following steps:

[0206] Step 1201: The file manager sends a directory access request to the VFS, the directory access request including the path name of the first directory.

[0207] Based on the architecture shown in FIG. 8, after the query module receives the query request from the I / O interface (carrying the path name of the first directory), the query module can send the query request to the file manager. After receiving the query request, the file manager can send a directory access request to the VFS according to the query request, the directory access request carrying the path name of the first directory.

[0208] For example, when the user clicks the identifier or the name of the first directory displayed on the terminal device, the hardware layer of the terminal device can detect the user operation, and the kernel layer or the application framework layer of the terminal device can generate a directory access request based on the event and send the directory access request to the query module through the I / O interface.

[0209] For example, when the user clicks the identifier or the name of the first directory displayed on the terminal device, the hardware layer of the terminal device can detect the user operation, and the kernel layer or the application framework layer of the terminal device can generate a directory access request based on the event and send the directory access request to the query module through the I / O interface.

[0210] Step 1202: The VFS sends a directory access request to the FUSE driver, the directory access request including the path name of the first directory.

[0211] Step 1203: The FUSE driver calculates the hash value of the path name of the first directory based on the hash function, and queries the hash table based on the hash value to obtain the file / subdirectory list under the first directory.

[0212] The file / subdirectory list can include the names of the files / subdirectories under the first directory.

[0213] Optionally, in the kernel mode, the hash value corresponding to the first directory is determined according to the path name of the first directory; the position of the first entry corresponding to the first directory in the hash table is determined according to the hash value; and the first entry is obtained from the hash table according to the position, so as to obtain the attribute information of the files under the first directory and / or the names of the subdirectories stored in the first entry.

[0214] Optionally, the hash table can include a plurality of sub-tables, indexes of the plurality of sub-tables being associated with hash values of path names of corresponding directories. For example, the specific implementation of determining the position of the first entry corresponding to the first directory in the hash table according to the hash value can be: determining the position of the first sub-table (i.e., the sub-table in which the first entry corresponding to the first directory is located) in the hash table according to the result of the modulo operation of the hash value and the number of sub-tables; and then determining the position of the first entry corresponding to the first directory in the sub-table according to the result of the modulo operation of the hash value and the maximum number of entries that can be accommodated by the first sub-table.

[0215] For example, the hash table shown in FIG. 11, the FUSE driver can determine the sub-table in which the entry corresponding to the first directory is located according to the hash value of the path name of the first directory; for example, the entry corresponding to the first directory is located in the first sub-table, the FUSE driver determines the position of the entry corresponding to the first directory in the first sub-table; for example, the entry corresponding to the first directory is entry 1 in the first sub-table, the FUSE driver obtains the names of all files / subdirectories under entry 1 from the "name" field in the information field corresponding to the first sub-table, thereby obtaining the file / subdirectory list under the first directory.

[0216] Step 1204: The FUSE driver returns a response to the VFS, wherein the response carries the file / subdirectory list under the first directory.

[0217] Step 1205: The VFS sends a response to the file manager, wherein the response carries the file / subdirectory list under the first directory.

[0218] After the file manager receives the file / subdirectory list, it initiates a file attribute query process. As shown in FIG. 12, the query process can include the following steps:

[0219] Step 1206: The file manager sends a lookup request to the VFS, wherein the lookup request carries the name of the file / subdirectory under the first directory.

[0220] Step 1207: The VFS determines to send a lookup request to the FUSE file system, wherein the lookup request carries the name of the file / subdirectory under the first directory.

[0221] Step 1208: The FUSE driver queries the hash table to obtain the attributes of the file / subdirectory.

[0222] Step 1209: The FUSE driver sends a response to the VFS, wherein the response carries the attributes of the file / subdirectory.

[0223] Step 1210: The VFS sends a response to the file manager, wherein the response carries the attributes of the file / subdirectory.

[0224] In the search process, the search process can be performed once for each file / subdirectory under the first directory, so that the attributes of all files / subdirectories under the first directory can be obtained.

[0225] In an alternative, the search process can be performed once to obtain the attributes of all files / subdirectories under the first directory.

[0226] In another alternative, the search process can be performed multiple times, and each search process can obtain the attributes of a certain number of files / subdirectories until the attributes of all files / subdirectories under the first directory are obtained, such as 10 files / subdirectories each time.

[0227] Based on the architecture shown in FIG. 8, after receiving the response, the file manager can send the response to the query module. The query module can trigger the display module to display the names and attributes of the files contained in the first directory on the screen of the terminal device, and display the names of the subdirectories contained in the first directory.

[0228] Based on the process shown in FIG. 12, in one possible implementation, the directory access request received by the file manager is triggered based on the cloud file application, and thus the metadata obtained in response to the directory access request is the metadata in the cloud file system saved in the terminal device.

[0229] Based on the process shown in FIG. 12, in another possible implementation, the target query request can specify whether to query the local file system, or to query the cloud file system, or to query both the local file system and the cloud file system. For example, the directory access request can include indication information indicating whether to query the local file system, or to query the cloud file system, or to query both the local file system and the cloud file system. For example, the user interface of the application can include a function option (such as an option control) for the user to select whether to query the local file system, or to query the cloud file system, or to query both the local file system and the cloud file system, so that the value of the indication information in the directory access request can be set based on the user's selection.

[0230] If the directory access request specifies to query the local file system, or specifies to query the cloud file system, the FUSE driver can determine whether the file / subdirectory belongs to the local file system or the cloud file system according to the flag field in the corresponding entry in the hash table, so as to return only the metadata of the specified file system.

[0231] Based on the flow shown in FIG. 12, in another possible implementation, the directory access request can specify by default to query the local file system, or to query the cloud file system, or to query both the local file system and the cloud file system. Accordingly, the FUSE driver can query the metadata in the file system specified by default by the directory access request.

[0232] Based on the flow shown in FIG. 12, in another possible implementation, the directory access request does not specify the file system, and the FUSE driver can first query the metadata belonging to the local file system, and if no metadata is queried, then query the metadata belonging to the cloud file system.

[0233] In a possible implementation, if the queried metadata includes the metadata belonging to the local file system and the metadata belonging to the cloud file system, the terminal device can display the query results belonging to the local file system and the query results belonging to the cloud file system separately. For example, the query results belonging to the local file system and the query results belonging to the cloud file system can be displayed in different areas, or different marks can be displayed for the query results belonging to the local file system and the query results belonging to the cloud file system, to distinguish them.

[0234] For example, FIG. 13 shows a schematic diagram of a user interface provided by an embodiment of the present application, which displays a directory query result including the names of subdirectories and the names and update dates of files belonging to the local file system, and the names of subdirectories and the names and update dates of files belonging to the cloud file system. The icons of the subdirectories and the icons of the files belonging to the cloud file system have cloud marks in the upper right corners, to indicate that these files and subdirectories are files and subdirectories in the cloud file system. For example, folder 3 in the interface shown in FIG. 13 is a cloud folder, and presentation 2 and spreadsheet 1 are cloud files.

[0235] In the flow shown in FIG. 12, since the hash table and the FUSE driver for performing metadata query are both located in the kernel space, the terminal device can complete the metadata query in the kernel mode, without switching between the kernel mode and the user mode, thereby reducing the system overhead and the time delay caused by switching between the kernel mode and the user mode, and improving the access performance.

[0236] The present application also provides a computer readable storage medium for storing a computer program, which, when executed by a computer, can implement the method provided by the method embodiments.

[0237] The embodiment of the present application further provides a computer program product for storing a computer program, which, when executed by a computer, can implement the method provided by the method embodiment.

[0238] The embodiment of the present application further provides a chip, comprising a processor coupled with a memory, for invoking a program in the memory to make the chip implement the method provided by the method embodiment.

[0239] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) containing computer-usable program code.

[0240] The present application is described with reference to the flowcharts and / or block diagrams of the method, device (system) and computer program product according to the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce the functions specified in one or more flows in the flowcharts and / or one or more blocks in the block diagrams.

[0241] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including instruction means, which implements the functions specified in one or more flows in the flowcharts and / or one or more blocks in the block diagrams.

[0242] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide steps for implementing the functions specified in one or more flows in the flowcharts and / or one or more blocks in the block diagrams.

[0243] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A file system access method, characterized in that, Applied to a terminal device, the method includes: Receive a query request, the query request including the pathname of a first directory, the query request being used to query the metadata of a file system object contained in the first directory, the file system object including files and / or subdirectories; The hash value corresponding to the first directory is determined based on the path name, and the metadata of the file system object contained in the first directory is obtained from the position corresponding to the hash value in the hash table; wherein, the hash table includes at least one entry, the at least one entry includes a first entry corresponding to the first directory, the first entry contains the metadata of the file system object contained in the first directory, and the hash table is stored in kernel memory; Output the metadata of the file system objects contained in the first directory.

2. The method as described in claim 1, characterized in that, The step of determining the hash value corresponding to the first directory based on the path name, and retrieving the metadata of the file system object contained in the first directory from the position corresponding to the hash value in the hash table, includes: The file manager sends a directory access request to the user-space file system driver in the kernel space, the directory access request including the path name of the first directory; The user-space file system driver determines the hash value corresponding to the first directory based on the path name, and retrieves the metadata of the file system object contained in the first directory from the position corresponding to the hash value in the hash table.

3. The method according to any one of claims 1-2, characterized in that, The step of determining the hash value corresponding to the first directory based on the path name, and retrieving the metadata of the file system object contained in the first directory from the position corresponding to the hash value in the hash table, includes: The hash value corresponding to the first directory is determined based on the path name; The position of the first sub-table in the hash table is determined based on the hash value. The first sub-table includes at least one entry, and the at least one entry includes the first entry. The position of the first entry in the first sub-table is determined based on the hash value and the maximum number of entries that the first sub-table can hold; Based on the position of the first entry in the first sub-table, obtain the metadata of the file system objects contained in the first directory.

4. The method as described in claim 3, characterized in that, The first sub-table includes an entry field and a name field. The entry field is used to store all entries included in the first sub-table, and the name field is used to store the name of the file system object contained in the directory corresponding to each entry in the first sub-table. The step of obtaining the metadata of the file system objects contained in the first directory based on the position of the first entry in the first sub-table includes: Obtain the names of all file system objects contained in the first directory from the name field; Based on the hash values ​​of the names of all file system objects contained in the first directory, the attribute information of each file system object is obtained from the first entry stored in the entry field.

5. The method according to any one of claims 1-4, characterized in that, The metadata of the file system objects contained in the first directory includes indication information, which indicates whether the first directory belongs to a local file system or to a cloud file system.

6. The method as described in claim 5, characterized in that, The indication information indicates that the first directory belongs to a cloud-based file system, and the output of the metadata of the file system objects contained in the first directory includes: Display the metadata of the file system objects contained in the first directory, and mark the file system objects as belonging to the file system in the cloud.

7. The method according to any one of claims 1-6, characterized in that, Also includes: Receive a downlink synchronization message, the downlink synchronization message including the path name of the first directory and operation type indication information, the operation type indication information being used to indicate the operation type; The hash value corresponding to the first directory is determined based on the path name, and the first entry corresponding to the first directory in the hash table is processed accordingly based on the hash value and the operation type indicated by the operation type indication information. Based on the path name of the first directory and the operation type indicated by the operation type indication information, the metadata of the file system objects contained in the first directory in the metadata database is processed accordingly.

8. The method as described in claim 7, characterized in that, The downlink synchronization message also includes metadata of the file system objects contained in the first directory; The corresponding processing of the first entry corresponding to the first directory in the hash table includes: Add the metadata to the first entry; or Delete the metadata from the first entry: or Update the metadata in the first entry based on the metadata.

9. The method according to any one of claims 1-8, characterized in that, Also includes: In response to changes in the metadata of the file system objects contained in the first directory, perform the following operations: The hash value corresponding to the first directory is determined based on the path name of the first directory. The metadata of the file system object contained in the first directory is obtained from the hash table based on the hash value. The metadata of the file system object contained in the first directory in the hash table is updated based on the changes in the metadata of the file system object contained in the first directory. Update the metadata of the file system objects contained in the first directory in the metadata database according to the changes in the metadata of the file system objects contained in the first directory.

10. The method as described in claim 9, characterized in that, Also includes: Send an uplink synchronization message, which includes the path name of the first directory and operation type indication information, the operation type indication information being used to indicate the operation type.

11. An apparatus, characterized in that, Includes units or modules for performing the method as described in any one of claims 1-10.

12. An apparatus, characterized in that, include: One or more processors are configured to perform the method as described in any one of claims 1-10.

13. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed on the device, cause the device to perform the method as described in any one of claims 1-10.

14. A chip system, characterized in that, Includes a processor for enabling a computer device to implement the method as described in any one of claims 1-10.

15. A program product, characterized in that, The program product includes a program; when the program is run on a computer, it causes the computer to perform the method as described in any one of claims 1-10.

Citation Information

Patent Citations

  • Method for operation system inner core component cross-domain operating

    CN101038545A

  • Method for managing and allocating resource in parallel file system

    CN101567003A

  • Management method for data cache distribution in Linux system

    CN101826055A

  • Cuckoo Hash-based file system directory management method and system

    CN113094336A

  • Method and System for Dynamic Storage Scaling

    US20220019364A1