File system, operating system, and compute device

A second file system overlays multiple first file systems to perform fault tolerance checks on memory metadata, addressing the lack of metadata fault tolerance in existing systems and improving reliability with reduced memory overheads.

US20260386972A1Pending Publication Date: 2026-12-03HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
US19/764395
Authority / Receiving Office
US · United States
Patent Type
Applications(United States)
Current Assignee / Owner
Priority Date
2024-02-07
Filing Date
2026-08-04
Publication Date
2026-12-03

AI Technical Summary

Technical Problem

Existing file systems lack adequate fault tolerance for metadata stored in memory, leading to severe impacts such as unavailability and loss of files/directories when faults occur.

Method used

Implement a second file system that overlays multiple first file systems, performing fault tolerance checks on consistent and inconsistent data in memory metadata, reducing the need for redundancy backups and minimizing memory overheads.

Benefits of technology

Enhances file system reliability by covering both memory and storage faults with low memory overheads, ensuring consistent and inconsistent data integrity without requiring full redundancy backups.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US20260386972A1-D00000_ABST
    Figure US20260386972A1-D00000_ABST
Patent Text Reader

Abstract

A file system includes: multiple first file systems, where the multiple first file systems are mounted to different partitions of a same storage medium or mounted to different storage media; and a second file system, mounted to the multiple first file systems, and configured to perform, among the multiple first file systems, fault tolerance check on consistent data in memory metadata of the multiple first file systems. In this way, the second file system is overlaid on the existing first file system, so that fault tolerance check can be performed among the first file systems on the consistent data in the memory metadata of the first file system, and there is no need to perform redundancy backup on the consistent data in the first file system, thereby reducing memory overheads and implementing memory fault coverage with low memory overheads.
Need to check novelty before this filing date? Find Prior Art

Description

CROSS-REFERENCE TO RELATED APPLICATIONS

[0001] This application is a continuation of International Application No. PCT / CN2024 / 116211, filed on Sep. 2, 2024, which claims priority to Chinese Patent Application No. 202410175776.0, filed on Feb. 7, 2024. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.TECHNICAL FIELD

[0002] This disclosure relates to the information technology (IT) field, and in particular, to a file system, an operating system, and a compute device.BACKGROUND

[0003] In a computer operating system (OS), a software mechanism that is responsible for managing and storing file data may be referred to as a file system. The file system defines a structure of file data and directories and provides interfaces for accessing, modifying, and managing the file data. Reliability of the file system directly affects reliability of the OS, and reliability of the OS directly affects reliability of a device configured with the OS. Currently, to improve reliability of a file system, fault tolerance is usually performed on stored file data, to resolve a problem that a file system is faulty due to a storage fault. Although this manner can improve reliability of the file system to some extent, it lacks a fault tolerance capability for metadata of the file system that exists in a memory managed by the OS. Therefore, when a fault occurs in the metadata of the file system stored in the memory, severe impact such as unavailability of the file system and loss of files / directories are caused.SUMMARY

[0004] This disclosure provides a file system, an operating system, a memory management method, a memory management apparatus, a compute device, a computer storage medium, and a computer product, to cover a memory fault with low memory overheads, thereby improving reliability of the file system.

[0005] According to a first aspect, this disclosure provides a file system, including: multiple first file systems, where the multiple first file systems are mounted to different partitions of a same storage medium or mounted to different storage media; and a second file system, mounted to the multiple first file systems, and configured to perform, among the multiple first file systems, fault tolerance check on consistent data in memory metadata of the multiple first file systems.

[0006] In this way, the second file system is overlaid on the existing first file system, so that fault tolerance check can be performed among the first file systems on the consistent data in the memory metadata of the first file system, and there is no need to perform redundancy backup on the consistent data in the first file system, thereby reducing memory overheads and implementing memory fault coverage with low memory overheads.

[0007] In an embodiment, the second file system is further configured to perform fault tolerance check on file data of the multiple first file systems. In this way, both a memory fault and a storage fault can be covered with low memory overheads, thereby improving reliability of the file system.

[0008] In an embodiment, the second file system is further configured to separately perform, in each of the first file systems, fault tolerance check on inconsistent data in the memory metadata of the multiple first file systems. In this way, fault tolerance check can be performed on all data in the memory metadata, thereby further improving reliability of the file system.

[0009] In an embodiment, the file system further includes a virtual file system, and the virtual file system is mounted to the second file system.

[0010] In an embodiment, one copy of consistent data in memory metadata of one of the first file systems is stored in a memory; and multiple copies of inconsistent data in memory metadata of one of the first file systems are stored in the memory. In this way, there is no need to perform redundancy backup on all data in the memory metadata of the first file system, thereby reducing memory overheads.

[0011] In an embodiment, one copy of consistent data in memory metadata of one of the first file systems is stored in the memory; and one copy of inconsistent data in memory metadata of one of the first file systems is stored in the memory, and an erasure code is added to each copy of inconsistent data. In this way, there is no need to perform redundancy backup on the memory metadata of the first file system, thereby reducing memory overheads.

[0012] In an embodiment, one copy of consistent data in memory metadata of one of the first file systems is stored in the memory; and one copy of first sub-data included in inconsistent data in memory metadata of one of the first file systems is stored in the memory, an erasure code is added to the first sub-data, and multiple copies of second sub-data included in the inconsistent data are stored in the memory. In this way, there is no need to perform redundancy backup on all data in the memory metadata of the first file system, thereby reducing memory overheads.

[0013] In an embodiment, the consistent data in the memory metadata includes one or more of a file name, an access permission, and a group identifier; and the inconsistent data in the memory metadata includes a timestamp and / or a superblock pointer.

[0014] In an embodiment, a mounting relationship between the first file system and the second file system is specified by a user. In this way, mounting flexibility is improved, and user experience is improved.

[0015] In an embodiment, a quantity of the first file systems is specified by the user. In this way, mounting flexibility is improved, and user experience is improved.

[0016] In an embodiment, both consistent data and inconsistent data in the memory metadata of the first file system are specified by the user. In this way, flexibility of memory metadata redundancy backup is improved, and user experience is improved.

[0017] In an embodiment, the second file system is further configured to: determine, based on a file attribute and / or an operation type included in a read / write request, multi-modular information of a target file to which the read / write request is directed, where the multi-modular information indicates a quantity of backups and a backup file location of the target file; and when the multi-modular information indicates that there are multiple backups of the target file, initiate a read / write operation to a first file system to which each backup file location belongs; or when the multi-modular information indicates that there is a single backup of the target file, initiate a read / write operation to a first file system to which the backup file location belongs. In this way, the data read / write operation is completed.

[0018] In an embodiment, the file attribute includes one or more of a user identifier, a group identifier, a process identifier, a file name, and a file type.

[0019] According to a second aspect, this disclosure provides an operating system. The file system described in any one of the first aspect or the possible implementations of the first aspect may be mounted to the operating system.

[0020] According to a third aspect, this disclosure provides a compute device, including a memory, a processor, and a computer program that is stored in the memory and that can be run on the processor, where the file system described in any one of the first aspect or the possible implementations of the first aspect is deployed on the processor, and when executing the computer program, the processor implements running of the file system.

[0021] According to a fourth aspect, this disclosure provides a memory management method, applied to an operating system to which multiple file systems are mounted, where the multiple file systems are mounted to different partitions of a same storage medium or mounted to different storage media. The method includes: separately reading metadata of each of the file systems from the storage media or partitions to which the multiple file systems are mounted; storing one copy of first sub-data in the metadata of each of the file systems in a memory, where the first sub-data is consistent data in metadata of the multiple file systems; and storing multiple copies of second sub-data in the metadata of each of the file systems in the memory, and / or adding an erasure code to the second sub-data and storing the second sub-data in the memory, where the second sub-data is inconsistent data in the metadata of the multiple file systems.

[0022] In an embodiment, the method further includes: in response to an obtained file read operation, separately reading a target file from at least two file systems in the multiple file systems, and separately reading metadata of the at least two file systems from the memory; performing fault tolerance check on the read target file in a consistency arbitration manner; and performing fault tolerance check on the read first sub-data in a consistency arbitration manner, and performing, for any file system in the multiple file systems, fault tolerance check on the read second sub-data of the any file system in a consistency arbitration manner or an erasure code fault detection manner.

[0023] In an embodiment, the first sub-data includes one or more of a file name, an access permission, and a group identifier; and the second sub-data includes a timestamp and / or a superblock pointer.

[0024] According to a fifth aspect, this disclosure provides a memory management apparatus, deployed in an operating system to which multiple file systems are mounted, where the multiple file systems are mounted to different partitions of a same storage medium or mounted to different storage media. The apparatus includes: a reading module, configured to read metadata of each of the file systems from the storage media or partitions to which the multiple file systems are mounted; and a processing module, configured to store one copy of first sub-data in the metadata of each of the file systems in a memory, where the first sub-data is consistent data in metadata of the multiple file systems. The processing module is further configured to store multiple copies of second sub-data in the metadata of each of the file systems in the memory, and / or add an erasure code to the second sub-data and store the second sub-data in the memory, where the second sub-data is inconsistent data in the metadata of the multiple file systems.

[0025] In an embodiment, the reading module is further configured to: in response to an obtained file read operation, separately read a target file from at least two file systems in the multiple file systems, and separately read metadata of the at least two file systems from the memory; and the processing module is further configured to perform fault tolerance check on the read target file in a consistency arbitration manner; and perform fault tolerance check on the read first sub-data in a consistency arbitration manner, and perform, for any file system in the multiple file systems, fault tolerance check on the read second sub-data of the any file system in a consistency arbitration manner or an erasure code fault detection manner.

[0026] In an embodiment, the first sub-data includes one or more of a file name, an access permission, and a group identifier; and the second sub-data includes a timestamp and / or a superblock pointer.

[0027] According to a sixth aspect, this disclosure provides a compute device, including: one or more processors; a memory, configured to store one or more programs; and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method described in any one of the fourth aspect or the possible implementations of the fourth aspect.

[0028] According to a seventh aspect, this disclosure provides a computer-readable storage medium, including computer program instructions. When the computer program instructions are executed by a compute device cluster, the compute device cluster is enabled to perform the method described in any one of the fourth aspect or the possible implementations of the fourth aspect. For example, the compute device cluster may include one or more compute devices.

[0029] According to an eighth aspect, this disclosure provides a computer program product including instructions. When the instructions are run by a compute device cluster, the compute device cluster is enabled to perform the method described in any one of the fourth aspect or the possible implementations of the fourth aspect. For example, the compute device cluster may include one or more compute devices.

[0030] It can be understood that, for beneficial effects of the second aspect to the eighth aspect, refer to related descriptions in the first aspect. Details are not described herein again.BRIEF DESCRIPTION OF DRAWINGS

[0031] FIG. 1A and FIG. 1B are diagrams of a running environment of an OS according to an embodiment of this disclosure;

[0032] FIG. 2A to FIG. 2C are diagrams of data in different partitions and metadata of the data in a memory according to an embodiment of this disclosure;

[0033] FIG. 3 is a diagram of a data writing process according to an embodiment of this disclosure;

[0034] FIG. 4A and FIG. 4B are a diagram of a data reading process according to an embodiment of this disclosure;

[0035] FIG. 5 is a schematic flowchart of a memory management method according to an embodiment of this disclosure; and

[0036] FIG. 6 is a diagram of a structure of a memory management apparatus according to an embodiment of this disclosure.DESCRIPTION OF EMBODIMENTS

[0037] The term “and / or” in this specification describes an association relationship between associated objects and represents that three relationships may exist. For example, A and / or B may represent the following three cases: Only A exists, both A and B exist, and only B exists. The character “ / ” in this specification indicates an “or” relationship between the associated objects. For example, A / B indicates A or B.

[0038] In the specification and claims of this disclosure, the terms “first”, “second”, and the like are intended to distinguish between different objects, but do not indicate a particular order of the objects. For example, a first response message, a second response message, and the like are intended to distinguish between different response messages, but do not indicate a particular order of the response messages.

[0039] In embodiments of this disclosure, the word “example” or “for example” is used to represent giving an example, an illustration, or a description. Any embodiment or design scheme described as an “example” or “for example” in embodiments of this disclosure should not be explained as being more preferred or having more advantages than another embodiment or design scheme. To be precise, use of the words such as “example” or “for example” is intended to present a relative concept in a manner.

[0040] In descriptions of embodiments of this disclosure, unless otherwise specified, “multiple” means two or more. For example, multiple processing units mean two or more processing units, and multiple elements mean two or more elements.

[0041] For example, FIG. 1A and FIG. 1B are a diagram of a running environment of an OS according to an embodiment of this disclosure. As shown in FIG. 1A, the running environment of the OS includes an application (APP), multiple file systems (FS), a highly reliable multi-modular file system (NMRFS), and a storage medium (such as a hard disk, a partition, or a network storage). In a running process of the OS, multiple FSs may be mounted to different storage media or different partitions of a same storage medium, and the NMRFS may be mounted to the multiple FSs. A quantity of FSs that have a mounting relationship with the NMRFS may be but is not limited to being specified by a user. For example, the user can specify the quantity of FSs in a form of a configuration file or a command line. In addition, both mounting the FS to the storage medium and mounting the NMRFS to the multiple FSs may be implemented in automatic mounting or manual mounting mode. For example, in a Linux system, the user can use a mount command “mount −t yaffs / dev / mtdblock1 / tmp / yaffs1” to mount a file system yaffs1 to a partition mtdblock1, and use a mount command “mount −t yaffs / dev / mtdblock2 / tmp / yaffs2” to mount a file system yaffs2 to a partition mtdblock2. Then, the user can use a mount command “mount −t nmrfs −o dir1= / tmp / yaffs1,dir2= / tmp / yaffs2 none / tmp / nmrfs” to mount the NMRFS to the two file systems yaffs1 and yaffs2. After the NMRFS is mounted, a subsequent read / write operation needs to be performed only on / tmp / nmrfs, and the NMRFS automatically distributes the read / write operation to / tmp / yaffs1 and / tmp / yaffs2. When data in a file a. txt needs to be read, a file path in a read request may be / tmp / nmrfs / a.txt. Then, the NMRFS separately forwards the request for reading the file a.txt to yaffs1 and yaffs2. In an embodiment, as shown in FIG. 1B, the running environment of the OS may further include a virtual file system (VFS). The VFS may be in a kernel mode, and is located between the APP and the NMRFS, that is, the APP communicates with the NMRFS via the VFS. The VFS can be mounted to the NMRFS. In some embodiments, the multiple FSs and the NMRFS may form a new FS, and the new FS may be mounted to the OS. Certainly, the multiple FSs, the NMRFS, and the VFS may also form a new FS, and the FS may also be mounted to the OS.

[0042] In this embodiment, the APP is a set of a series of instructions and code written by the user or another software entity, and may execute a task, provide a function, or resolve a problem. For example, the APP may initiate a read / write request to the NMRFS. The read / write request may include a file path.

[0043] The FS is mainly used to organize and manage files in a computer. The FS provides functions such as creating files and directories, reading and writing files, deleting files and directories, searching for files, and protecting files. For example, the FS may be yet another flash file system (YAFFS), an internet flash file system (IFFS), a hybrid flash file system (HFFS), or a temporary file system (TMPFS).

[0044] The NMRFS may be configured to determine, after the APP initiates a read / write request, multi-modular information of a file to which the read / write request is directed. The multi-modular information indicates a quantity of backups and a backup file location of the file. After determining the multi-modular information of the file to which the read / write request is directed, the NMRFS may initiate a read / write operation to at least one FS based on the determined multi-modular information. When the multi-modular information indicates that there is a single backup of the file, the NMRFS may initiate a read / write operation to one FS. When the multi-modular information indicates that there are multiple backups of the file, the NMRFS may initiate a read / write operation to multiple FSs. In some embodiments, the user may specify data that needs redundancy backup. The user can specify, in a form of a configuration file or a command line, the data that needs the redundancy backup. For example, the user can specify that the redundancy backup is performed on all data processed by a process, or specify that the redundancy backup is performed on all data in a file. In addition, a quantity of redundancy backups of data can be specified by the user.

[0045] In addition, the NMRFS may be further configured to perform fault tolerance check (for example, consistency arbitration) on file data in the multiple FSs. The NMRFS may also be configured to perform, among the FSs, fault tolerance check (for example, consistency arbitration) on consistent data in memory metadata of the multiple FSs. The NMRFS may also be configured to separately perform, in each FS, fault tolerance check (for example, consistency arbitration or erasure code fault detection) on inconsistent data in the memory metadata of the multiple FSs. In addition, the NMRFS may be further configured to perform fault tolerance check on two or three of the file data in the multiple FSs, the consistent data in the memory metadata of the multiple FSs, and the inconsistent data in the memory metadata of the multiple FSs. In this way, fault tolerance is implemented for the file data and / or the memory metadata of the FS, thereby covering a memory fault and a storage fault. In a manner of performing, among the FSs, fault tolerance check on the consistent data in the memory metadata of the multiple FSs, only one copy of the consistent data in the memory metadata of each FS needs to be stored in the memory. In this way, memory overheads can be reduced. In addition, an erasure code may be added to the inconsistent data in the memory metadata of the FS. Because the erasure code occupies small space, when the erasure code is used to perform fault detection in the FS on the inconsistent data in the memory metadata of the FS, memory overheads can also be reduced. However, when fault detection is performed in the FS on the inconsistent data in the memory metadata of the FS in a consistency arbitration manner, for each FS, multiple copies of inconsistent data in the memory metadata of the FS may be stored in the memory. Compared with the erasure code fault detection manner, this manner consumes high memory overheads. However, for each FS, only one copy of consistent data in the memory metadata of the FS needs to be stored in the memory. Therefore, compared with a manner in which all memory metadata is stored in multiple copies, the fault tolerance check manner in this embodiment can also reduce memory overheads. For example, the consistent data in the memory metadata of the multiple FSs may include one or more of a file name, an access permission, a group identifier (ID), and the like in the metadata. The inconsistent data in the memory metadata of the multiple FSs may include a timestamp and / or a superblock pointer, and the like. In some embodiments, the user may also specify, in a form of a configuration file or a command line, sub-data that is included in the memory metadata and that needs to enter the fault tolerance check.

[0046] For ease of understanding, the following uses examples for description.

[0047] For example, as shown in FIG. 2A to FIG. 2C, FIG. 2A shows that memory metadata of an FS 1, an FS 2, and an FS 3 is separately backed up in a memory. However, memory metadata of different FSs is not sensed by each other. When fault tolerance check is performed on the memory metadata of the FSs, consistency arbitration is performed only in the FSs on the memory metadata, and fault tolerance check cannot be performed across FSs. In FIG. 2A, it is equivalent to that a triple-modular memory (that is, three copies of metadata are stored for each FS) is directly overlaid on a triple-modular storage (that is, three copies of same data are stored). This causes 3×3 memory overheads.

[0048] FIG. 2B shows that inconsistent data (for example, i_atime and i_sb) in the memory metadata of the FS 1, the FS 2, and the FS 3 is separately backed up in the memory, and consistent data (for example, i_mode, i_uqid, and i_flags) in the memory metadata of the FS 1, the FS 2, and the FS 3 is no longer backed up. In FIG. 2B, the consistent data in the memory metadata of the FS 1, the FS 2, and the FS 3 is sensed by each other. Therefore, the NMRFS may perform, among different FSs, fault tolerance check on the consistent data in the memory metadata of the FSs in a consistency arbitration manner. In FIG. 2B, the inconsistent data in the memory metadata of the FS 1, the FS 2, and the FS 3 is not sensed by each other. Therefore, for any FS, the NMRFS may perform, in the FS, fault tolerance check on the inconsistent data in the memory metadata of the FS in a consistency arbitration manner.

[0049] FIG. 2C shows that an erasure code is separately added to the inconsistent data (for example, i_atime and i_sb) in the memory metadata of the FS 1, the FS 2, and the FS 3 in the memory, the inconsistent data is no longer backed up, and the consistent data (for example, i_mode, i_uqid, and i_flags) in the memory metadata of the FS 1, the FS 2, and the FS 3 is not backed up. In FIG. 2C, the consistent data in the memory metadata of the FS 1, the FS 2, and the FS 3 is sensed by each other. Therefore, the NMRFS may perform, among different FSs, fault tolerance check on the consistent data in the memory metadata of the FSs in a consistency arbitration manner. In FIG. 2C, the inconsistent data in the memory metadata of the FS 1, the FS 2, and the FS 3 is not sensed by each other. Therefore, for any FS, the NMRFS may perform, in the FS, fault tolerance check on the inconsistent data in the memory metadata of the FS in an erasure code fault detection manner.

[0050] It can be learned from comparison between FIG. 2A, FIG. 2B, and FIG. 2C that the fault tolerance check manner for the memory metadata of the FSs in the memory shown in FIG. 2A needs high memory overheads. In comparison with FIG. 2A, the fault tolerance check manner for the memory metadata of the FSs in the memory shown in FIG. 2B can reduce some memory overheads. In comparison with FIG. 2B, the fault tolerance check manner for the memory metadata of the FSs in the memory shown in FIG. 2C can further reduce some memory overheads.

[0051] The foregoing describes the running environment of the OS provided in embodiments of this disclosure. The following describes a data reading / writing process in the running environment of the OS.

[0052] For example, FIG. 3 is a diagram of a data writing process according to an embodiment of this disclosure. As shown in FIG. 3, the data writing process may include the following operations.

[0053] S301. An APP sends a write request to an NMRFS. For example, the write request may include a file attribute and / or an operation type of a file to which the write request is directed, and the like. In some embodiments, the APP may send the write request to the NMRFS via, but not limited to, a VFS.

[0054] S302. The NMRFS determines, based on the file attribute and / or the operation type included in the write request, multi-modular information of the file to which the write request is directed. The NMRFS may query a preconfigured redundancy range based on the file attribute and / or the operation type included in the write request, to determine whether the file to which the write request is directed needs redundancy backup. When the redundancy backup is needed, the multi-modular information of the file is obtained through querying in metadata of the NMFRS and / or metadata of an FS based on, but not limited to, metadata of the file to which the write request is directed. The multi-modular information may indicate a quantity of backups and a backup file location of the file. When the redundancy backup is not needed, a needed write location of the file to which the write request is directed, that is, the backup file location, may be obtained through querying based on, but not limited to, a file path included in the write request. In this case, the multi-modular information of the file is obtained, that is, the multi-modular information indicates that there is one backup, and the backup file location is a location determined based on the file path. For example, the file attribute may include one or more of a user identifier (UID), a group identifier (GID), a process identifier (PID), a file name, and a file type. For example, a redundancy range may be, but is not limited to, specified by a user. For example, the user may specify that a file whose file name is “foo” has three backups. In some embodiments, the NMRFS may also parse the file path included in the write request, to obtain a directory path and a file name. Then, the NMRFS may view a mount table based on a start point of the directory path, to learn of an FS to which a file corresponding to the file path belongs. When the file belongs to multiple FSs, it indicates that the file needs to be backed up in multiple copies, and the FS to which the file belongs is the backup file location.

[0055] S303. The NMRFS determines whether the determined multi-modular information of the file indicates that there are multiple backups of the file. When there are not multiple copies, that is, when there is a single copy, S304 and S305 may be performed; or when there are multiple copies, S306 and S307 may be performed.

[0056] S304. When the multi-modular information indicates that there is a single backup of the file, the NMRFS initiates a write operation to an FS associated with the backup file location in the multi-modular information. For example, the write operation initiated by the NMRFS may include to-be-written data content and a data write location. For example, after obtaining the directory path by parsing the file path included in the write request, the NMRFS may view the mount table based on a start point of the directory path, to learn of an FS to which a file corresponding to a file name included in the file path belongs. The mount table may record information about each FS to which the NMRFS is mounted. For ease of description, the following describes a case in which the NMRFS initiates a write operation to an FS 1.

[0057] S305. After receiving the write operation initiated by the NMRFS, the FS 1 may write data into a partition 1 to which the FS 1 is mounted, and update memory metadata of the FS 1 in a memory.

[0058] S306. The NMRFS separately initiates a write operation to multiple FSs when the multi-modular information indicates that there are multiple backups of the file. In addition, the NMRFS may first perform processing such as erasure coding and encryption on to-be-written data, and then initiate the write operation. In addition, when initiating the write operation, the NMRFS may also optimize a data flushing process in a manner like asynchronous flushing and load balancing. For ease of description, the following describes a case in which the NMRFS separately initiates a write operation to the FS 1, an FS 2, and an FS 3.

[0059] S307. After receiving the write operation initiated by the NMRFS, the FS 1 may write, based on a data write location in the write operation, the to-be-written data into the partition 1 to which the FS 1 is mounted, and update memory metadata 1 of the FS 1 in the memory. After receiving the write operation initiated by the NMRFS, an FS 2 may write the data into a partition 2 to which the FS 2 is mounted, and update memory metadata 2 of the FS 2 in the memory. After receiving the write operation initiated by the NMRFS, an FS 3 may write the data into a partition 3 to which the FS 3 is mounted, and update memory metadata 3 of the FS 3 in the memory. For example, when each FS updates the memory metadata of the FS in the memory, for consistent data in the memory metadata, one copy may be stored in the memory, and for inconsistent data in the memory metadata, multiple copies may be stored in the memory, or an erasure code may be added to the inconsistent data, or a combination of the two may be used.

[0060] In this way, the data writing process is completed. It should be understood that FIG. 3 is described by using an example in which the running environment of the OS includes three FSs. When the running environment of the OS includes another quantity of FSs, for a data writing process, refer to descriptions in FIG. 3. Details are not described herein again.

[0061] For example, FIG. 4A and FIG. 4B are a diagram of a data reading process according to an embodiment of this disclosure. As shown in FIG. 4A and FIG. 4B, the data reading process may include the following operations.

[0062] S401. An APP sends a read request to an NMRFS. For example, the read request may include a file attribute and / or an operation type of a file to which the read request is directed, and the like. In some embodiments, the APP may send the read request to the NMRFS via, but not limited to, a VFS.

[0063] S402. The NMRFS determines, based on the file attribute and / or the operation type included in the read request, multi-modular information of the file to which the read request is directed. For this operation, refer to the descriptions in S202 in FIG. 2A to FIG. 2C. Details are not described herein again.

[0064] S403. The NMRFS determines whether the determined multi-modular information of the file indicates that there are multiple backups of the file. When there are not multiple copies, that is, when there is a single copy, S404 to S407 may be performed, or when there are multiple copies, S408 to S412 may be performed.

[0065] S404. When the multi-modular information indicates that there is a single backup of the file, the NMRFS initiates a read operation to one of multiple FSs. For example, the read operation initiated by the NMRFS may include a data read location. For example, after obtaining a directory path by parsing a file path included in the read request, the NMRFS may view a mount table based on a start point of the directory path, to learn of an FS to which a file corresponding to a file name included in the file path belongs. The mount table may record information about each FS to which the NMRFS is mounted. For ease of description, the following describes a case in which the NMRFS initiates a read operation to an FS 1.

[0066] S405. After receiving the read operation initiated by the NMRFS, the FS 1 may read, based on the data read location in the read operation, target data from a partition 1 to which the FS 1 is mounted.

[0067] S406. The FS 1 transmits the read target data to the NMRFS.

[0068] S407. The NMRFS returns the target data to the APP.

[0069] S408. The NMRFS separately initiates a read operation to multiple FSs when the multi-modular information indicates that there are multiple backups of the file. For ease of description, the following describes a case in which the NMRFS separately initiates a read operation to the FS 1, an FS 2, and an FS 3.

[0070] S409. After receiving the read operation initiated by the NMRFS, the FS 1 may read, based on the data read location in the read operation, target data 1 from the partition 1 to which the FS 1 is mounted, and update memory metadata 1 of the FS 1 in a memory. After receiving the read operation initiated by the NMRFS, the FS 2 may read, based on the data read location in the read operation, target data 2 from a partition 2 to which the FS 2 is mounted, and update memory metadata 2 of the FS 2 in the memory. After receiving the read operation initiated by the NMRFS, the FS 3 may read, based on the data read location in the read operation, target data 3 from a partition 3 to which the FS 3 is mounted, and update memory metadata 3 of the FS 3 in the memory. For example, when each FS updates the memory metadata of the FS in the memory, for consistent data in the memory metadata, one copy may be stored in the memory, and for inconsistent data in the memory metadata, multiple copies may be stored in the memory, or an erasure code may be added to the inconsistent data, or a combination of the two may be used.

[0071] S410. The FS 1 sends the target data 1 and the memory metadata 1 of the target data 1 to the NMRFS; the FS 2 sends the target data 2 and the memory metadata 2 of the target data 2 to the NMRFS; and the FS 3 sends the target data 3 and the memory metadata 3 of the target data 3 to the NMRFS. For consistent data in the metadata 1, 2, and 3, Each FS sends one copy to the NMRFS. For inconsistent data in the metadata 1, 2, and 3, the FS 1 may send one copy to the NMRFS and send the erasure code at the same time, the FS 2 may send one copy to the NMRFS and send the erasure code at the same time, and the FS 3 may send one copy to the NMRFS and send the erasure code at the same time. In addition, for the inconsistent data in the metadata 1, 2, and 3, the FS 1 may send multiple copies to the NMRFS, the FS 2 may send multiple copies to the NMRFS, and the FS 3 may send multiple copies to the NMRFS. In addition, for the inconsistent data in the metadata 1, 2, and 3, the FS 1, the FS 2, and the FS 3 may also choose, based on an actual situation, to send the erasure code or the multiple copies of data. This is not limited herein.

[0072] S411. The NMRFS separately performs fault tolerance check on the target data and the metadata. The NMRFS may perform consistency arbitration on the target data 1, the target data 2, and the target data 3, and perform consistency arbitration on consistent data in the memory metadata 1, the memory metadata 2, and the memory metadata 3. In addition, the NMRFS may perform erasure code fault detection, consistency arbitration, or the like in each FS on the inconsistent data in the memory metadata of each FS. For details, refer to related descriptions in FIG. 2B and FIG. 2C. Details are not described herein again.

[0073] S412. When the fault tolerance check indicates that both the target data and the metadata are correct, the NMRFS returns any one of the target data 1, the target data 2, and the target data 3 to the APP.

[0074] In this way, the data reading process is completed.

[0075] It can be learned from the foregoing data writing and reading processes that, in the running environment of the OS shown in FIG. 1A and FIG. 1B, the foregoing NMRFS is overlaid on the existing FS to implement fault tolerance for both the file data and the memory metadata of the FS, so that a memory fault and a storage fault can be covered at the same time, and the existing FS does not need to be replaced or intrusively modified. In addition, there is no need to perform redundancy backup on all data in the memory metadata of each FS in the memory managed by the OS. This reduces memory overheads, and implements end-to-end coverage of file storage and memory reliability with minimum overheads.

[0076] It should be noted that before data is written and read, the NMRFS needs to be mounted to the FS. The FSs may be first mounted to different partitions of a same storage medium or mounted to different storage media, and then the NMRFS is mounted to the FSs. For example, a mounting process of the FS and / or the NMRFS may be automatically completed by a system, or may be completed by a user by entering a mount command in a form of a configuration file or a command line. In addition, the user may also specify a path, a quantity, a destination location, or the like for an FS to which the NMRFS needs to be mounted in the form of the configuration file or command line. In this way, the user can configure a quantity and locations of data redundancy backups.

[0077] Further, after the NMRFS is mounted to the FS, the user may also configure the NMRFS, for example, configure which data needs redundancy backup, a quantity of backups of the data that needs the redundancy backup, and which data needs fault tolerance check. The user may configure the NMRFS in a form of a configuration file or a command line. In this way, the user can flexibly configure different redundancy granularities and fault tolerance behaviors for the file data and the memory metadata of the FS. Certainly, the user may not configure the NMRFS, but use a default configuration of the NMRFS. This may be determined based on an actual situation, and is not limited herein.

[0078] It may be understood that the memory metadata of the FS may be read into the memory when the FS is mounted to the OS, or may be read into the memory when the APP opens a file, or may be read into the memory in a file operation process, or may be read into the memory when the NMRFS parses a file path. This may be determined based on an actual situation, and is not limited herein.

[0079] The foregoing describes the running environment and the data reading / writing process of the OS provided in embodiments of this disclosure. The following describes, based on the foregoing content, a memory management method provided in embodiments of this disclosure.

[0080] For example, FIG. 5 is a schematic flowchart of a memory management method according to an embodiment of this disclosure. It may be understood that the method may be performed by any apparatus, device, platform, or device cluster having computing and processing capabilities. For example, the memory management method may be applied to an operating system in which multiple file systems are mounted, and the multiple file systems may be mounted to different partitions of a same storage medium or mounted to different storage media. As shown in FIG. 5, the memory management method may include the following operations.

[0081] S501. Separately read metadata of each file system from the storage media or partitions to which the multiple file systems are mounted.

[0082] In this embodiment, when a file system is mounted to an operating system, and an APP opens a file in a file system, or a file in a file system is operated, metadata of the file system may be read from a storage medium or partition to which the file system is mounted.

[0083] S502. Store one copy of first sub-data in the metadata of each file system in a memory, where the first sub-data is consistent data in metadata of the multiple file systems.

[0084] In this embodiment, after metadata of a file system is read, one copy of first sub-data in the metadata of the file system may be stored in the memory. The first sub-data is consistent data in the metadata of the multiple file systems, for example, a file name, an access permission, or a group identifier. In this way, in the memory, one copy of the consistent data in the metadata of each file system is stored.

[0085] S503. Store multiple copies of second sub-data in the metadata of each file system in the memory, and / or add an erasure code to the second sub-data and store the second sub-data in the memory, where the second sub-data is inconsistent data in the metadata of multiple file systems.

[0086] In this embodiment, after metadata of a file system is read, multiple copies of second sub-data in the metadata of the file system may be stored in the memory, or one copy of the second sub-data may be stored in the memory, and an erasure code is added to the second sub-data. The second sub-data is inconsistent data in the metadata of the multiple file systems, for example, a timestamp and / or a superblock pointer.

[0087] In this way, in a subsequent file reading process, the target file may be read from the multiple file systems, and the metadata of the multiple file systems may be separately read from the memory. Then, fault tolerance check is performed on the read target file in a consistency arbitration manner, fault tolerance check is performed on the read first sub-data in a consistency arbitration manner, and for any file system in the multiple file systems, fault tolerance check is performed on the read second sub-data of the any file system in a consistency arbitration manner or an erasure code fault detection manner. In this way, both a memory fault and a storage fault are covered, and memory overheads are reduced.

[0088] It may be understood that sequence numbers of the operations in the foregoing embodiments do not mean an execution order, and the execution order of the processes should be determined based on functions and internal logic of the processes, and should not constitute any limitation on the implementation process of embodiments of this disclosure. In addition, the foregoing described embodiments may be combined based on an actual situation, and a combined solution still falls within the protection scope of this disclosure.

[0089] Based on the content in the foregoing embodiments, an embodiment of this disclosure provides a memory management apparatus.

[0090] For example, FIG. 6 is a diagram of a structure of a memory management apparatus. The memory management apparatus may be deployed in an operating system to which multiple file systems are mounted. In addition, different file systems are mounted to different partitions of a same storage medium or mounted to different storage media, and different file systems back up each other. As shown in FIG. 6, the memory management apparatus 600 may include a reading module 601 and a processing module 602. The reading module 601 is configured to read metadata of each file system from the storage media or partitions to which the multiple file systems are mounted. The processing module 602 is configured to: store one copy of first sub-data in the metadata of each file system in a memory, where the first sub-data is consistent data in metadata of the multiple file systems; and store multiple copies of second sub-data in the metadata of each file system in the memory, and / or add an erasure code to the second sub-data and store the second sub-data in the memory, where the second sub-data is inconsistent data in the metadata of the multiple file systems.

[0091] In some embodiments, the reading module 601 is further configured to: in response to an obtained file read operation, separately read a target file from each file system, and separately read the metadata of each file system from the memory. The processing module 602 is further configured to: perform fault tolerance check on the read target file in a consistency arbitration manner; and perform fault tolerance check on the read first sub-data in a consistency arbitration manner, and perform, for any file system in the multiple file systems, fault tolerance check on second sub-data of the any file system in a consistency arbitration manner or an erasure code fault detection manner.

[0092] In some embodiments, the first sub-data includes one or more of a file name, an access permission, and a group identifier; and the second sub-data includes a timestamp and / or a superblock pointer.

[0093] It should be understood that the foregoing apparatus is configured to perform the method in the foregoing embodiment. Implementation principles and technical effect of corresponding program modules in the apparatus are similar to those described in the foregoing method. For a working process of the apparatus, refer to the corresponding process in the foregoing method. Details are not described herein again.

[0094] An embodiment of this disclosure further provides a compute device. The compute device may include a memory, a processor, and a computer program that is stored in the memory and that can be run on the processor. A file system including at least the foregoing described FS and NMRFS is deployed on the processor. When executing the computer program, the processor implements running of the file system.

[0095] An embodiment of this disclosure further provides another compute device. The compute device may include one or more processors; and a memory, configured to store one or more programs, where when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method in the foregoing embodiment.

[0096] Based on the method in the foregoing embodiments, an embodiment of this disclosure provides a computer-readable storage medium, including computer program instructions. When the computer program instructions are executed by a compute device, the compute device performs the method in the foregoing embodiment. For example, the computer-readable storage medium may be any usable medium that can be stored by a compute device, or a data storage device, for example, a data center, including one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for example, a solid state disk), or the like.

[0097] Based on the method in the foregoing embodiments, an embodiment of this disclosure provides a computer program product including instructions. When the instructions are run by a compute device, the compute device is enabled to perform the method in the foregoing embodiment.

[0098] It can be understood that the processor in embodiments of this disclosure may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or another programmable logic device, a transistor logic device, a hardware component, or any combination thereof. The general-purpose processor may be a microprocessor, any regular processor, or the like.

[0099] The method operations in embodiments of this disclosure may be implemented in a hardware manner, or may be implemented in a manner of executing software instructions by the processor. The software instructions may include corresponding software modules. The software modules may be stored in a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a register, a hard disk, a removable hard disk, a CD-ROM, or any other form of storage medium well-known in the art. For example, a storage medium is coupled to the processor, so that the processor can read information from the storage medium and write information into the storage medium. Certainly, the storage medium may be a component of the processor. The processor and the storage medium may be disposed in an ASIC.

[0100] All or a part of the foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When software is used to implement the embodiments, all or a part of the embodiments may be implemented in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the procedure or functions according to embodiments of this disclosure are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable apparatuses. The computer instruction may be stored in a computer-readable storage medium, or may be transmitted by using the computer-readable storage medium. The computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (DSL)) or wireless (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by the computer, or a data storage device, for example, a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for example, a solid state disk (SSD)), or the like.

[0101] It may be understood that various numbers in embodiments of this disclosure are merely used for differentiation for ease of description, and are not used to limit the scope of embodiments of this disclosure.

[0102] Finally, it should be noted that the foregoing embodiments are merely intended for describing the technical solutions of this disclosure but not for limiting this disclosure. Although this disclosure is described in detail with reference to the foregoing embodiments, one of ordinary skilled in the art should understand that modifications may still be made to the technical solutions described in the foregoing embodiments or equivalent replacements may still be made to some technical features thereof, without departing from the protection scope of the technical solutions in embodiments of this disclosure.

Claims

1. A file system, comprising:multiple first file systems mounted to different partitions of a same storage medium or mounted to different storage media; anda second file system, mounted to the multiple first file systems, and configured to perform, among the multiple first file systems, fault tolerance check on consistent data in memory metadata of the multiple first file systems.

2. The file system according to claim 1, wherein the second file system is further configured to perform fault tolerance check on file data of the multiple first file systems.

3. The file system according to claim 1, wherein the second file system is further configured to separately perform, in each of the first file systems, fault tolerance check on inconsistent data in the memory metadata of the multiple first file systems.

4. The file system according to claim 1, further comprising:a virtual file system mounted to the second file system.

5. The file system according to claim 1, wherein one copy of consistent data in memory metadata of one of the first file systems is stored in a memory; andmultiple copies of inconsistent data in memory metadata of one of the first file systems are stored in the memory.

6. The file system according to claim 1, wherein one copy of consistent data in memory metadata of one of the first file systems is stored in the memory; andone copy of inconsistent data in memory metadata of one of the first file systems is stored in the memory, and an erasure code is added to each copy of inconsistent data.

7. The file system according to claim 1, wherein one copy of consistent data in memory metadata of one of the first file systems is stored in the memory; andone copy of first sub-data comprised in inconsistent data in memory metadata of one of the first file systems is stored in the memory, an erasure code is added to the first sub-data, and multiple copies of second sub-data comprised in the inconsistent data are stored in the memory.

8. The file system according to claim 1, wherein the consistent data in the memory metadata comprises one or more of a file name, an access permission, and a group identifier; andinconsistent data in the memory metadata comprises a timestamp and / or a superblock pointer.

9. The file system according to claim 1, wherein the second file system is further configured to:determine, based on a file attribute and / or an operation type comprised in a read / write request, multi-modular information of a target file to which the read / write request is directed, wherein the multi-modular information indicates a quantity of backups and a backup file location of the target file; and search the multi-modular information based on the metadata of the file; andwhen the multi-modular information indicates that there are multiple backups of the target file, initiate a read / write operation to a first file system to which each backup file location belongs; orwhen the multi-modular information indicates that there is a single backup of the target file, initiate a read / write operation to a first file system to which the backup file location belongs.

10. A compute device, comprising:a processor, anda memory coupled to the processor to store instructions, which when executed by the processor, cause the compute device to implement running of a file system, the file system comprising:multiple first file systems mounted to different partitions of a same storage medium or mounted to different storage media; anda second file system, mounted to the multiple first file systems, and configured to perform, among the multiple first file systems, fault tolerance check on consistent data in memory metadata of the multiple first file systems.

11. The compute device according to claim 10, wherein the second file system is further configured to perform fault tolerance check on file data of the multiple first file systems.

12. The compute device according to claim 10, wherein the second file system is further configured to separately perform, in each of the first file systems, fault tolerance check on inconsistent data in the memory metadata of the multiple first file systems.

13. The compute device according to claim 10, the file system further comprising:a virtual file system mounted to the second file system.

14. The compute device according to claim 10, wherein one copy of consistent data in memory metadata of one of the first file systems is stored in a memory; andmultiple copies of inconsistent data in memory metadata of one of the first file systems are stored in the memory.

15. The compute device according to claim 10, wherein one copy of consistent data in memory metadata of one of the first file systems is stored in the memory; andone copy of inconsistent data in memory metadata of one of the first file systems is stored in the memory, and an erasure code is added to each copy of inconsistent data.

16. The compute device according to claim 10, wherein one copy of consistent data in memory metadata of one of the first file systems is stored in the memory; andone copy of first sub-data comprised in inconsistent data in memory metadata of one of the first file systems is stored in the memory, an erasure code is added to the first sub-data, and multiple copies of second sub-data comprised in the inconsistent data are stored in the memory.

17. The compute device according to claim 10, wherein the consistent data in the memory metadata comprises one or more of a file name, an access permission, and a group identifier; andinconsistent data in the memory metadata comprises a timestamp and / or a superblock pointer.

18. A memory management method, comprising:separately reading metadata of each of multiple file systems of an operating system from storage media or partitions to which the multiple file systems are mounted, wherein the multiple file systems are mounted to different partitions of a same storage medium or mounted to different storage media;storing one copy of first sub-data in the metadata of each of the file systems in a memory, wherein the first sub-data is consistent data in metadata of the multiple file systems; andstoring multiple copies of second sub-data in the metadata of each of the file systems in the memory, and / or adding an erasure code to the second sub-data and storing the second sub-data in the memory, wherein the second sub-data is inconsistent data in the metadata of the multiple file systems.

19. The method according to claim 18, wherein the method further comprises:in response to an obtained file read operation, separately reading a target file from at least two file systems in the multiple file systems, and separately reading metadata of the at least two file systems from the memory;performing fault tolerance check on the read target file in a consistency arbitration manner; andperforming fault tolerance check on the read first sub-data in a consistency arbitration manner, and performing, for any file system in the at least two file systems, fault tolerance check on the read second sub-data of the any file system in a consistency arbitration manner or an erasure code fault detection manner.

20. The method according to claim 18, wherein the first sub-data comprises one or more of a file name, an access permission, and a group identifier; andthe second sub-data comprises a timestamp and / or a superblock pointer.