CN115033525B - File system management method and electronic equipment - Google Patents

File system management method and electronic equipment Download PDF

Info

Publication number
CN115033525B
CN115033525B CN202110244081.XA CN202110244081A CN115033525B CN 115033525 B CN115033525 B CN 115033525B CN 202110244081 A CN202110244081 A CN 202110244081A CN 115033525 B CN115033525 B CN 115033525B
Authority
CN
China
Prior art keywords
file system
node
main thread
thread
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110244081.XA
Other languages
Chinese (zh)
Other versions
CN115033525A (en
Inventor
俞超
陈锐
龚晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202110244081.XA priority Critical patent/CN115033525B/en
Publication of CN115033525A publication Critical patent/CN115033525A/en
Application granted granted Critical
Publication of CN115033525B publication Critical patent/CN115033525B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a file system management method, which is applied to electronic equipment and comprises the following steps: the file system checking tool creates a main thread and at least one sub thread; the file system checking tool performs consistency check and repair on the file system through the main thread and the sub thread. According to the file system management method, the file system checking tool creates the main thread and at least one sub thread to perform consistency checking and repairing on the file system, so that the consistency checking and repairing time of the file system can be reduced, and the consistency checking and repairing efficiency is improved. The file system can be mounted in time, so that a user can use the file system in time, and the use experience of the user is effectively improved. The application also discloses electronic equipment, which can provide better use experience for users by executing the file system management method.

Description

File system management method and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a file system management method and an electronic device.
Background
A File System (FS) is a System for logical storage and retrieval of named files and placed files in electronic devices. The file system includes data and metadata, which refers to data for describing attributes of the data. File systems require that the data structures of the file systems be consistent, such as between metadata, between metadata and data, etc. However, under the conditions of power failure, disk failure and the like of the system of the electronic equipment, the consistency of the file system can be destroyed, so that file nodes or data contents in the file system can not be normally accessed. A file system checking (file system consistency check, fsck) tool may be used to check and repair the consistency of the file system.
The processing time required by fsck tools to check and repair the consistency of a file system is proportional to the size of the file system, i.e., the larger the number of files in the file system, the longer the processing time required. The fsck tool usually checks and repairs consistency of the file system before the file system is mounted, and the processing time is too long, so that the file system cannot be mounted in time, a user cannot use the file system in time, and the problem of influencing use experience of the user exists.
Disclosure of Invention
The application provides a file system management method and electronic equipment, which are used for solving the problems that when fsck tools check and repair the system consistency of files, the processing time is too long, so that users cannot use the file system in time, and the use experience of the users is affected.
In order to solve the above technical problem, in a first aspect, an embodiment of the present application provides a file system management method, which is applied to an electronic device, and the method includes: the file system checking tool creates a main thread and at least one sub thread; the file system checking tool performs consistency check and repair on the file system through the main thread and the sub thread.
According to the file system management method, the file system checking tool creates the main thread and at least one sub thread to perform consistency checking and repairing on the file system, so that the consistency checking and repairing time of the file system can be reduced, and the consistency checking and repairing efficiency is improved. For example, when the electronic equipment is started, consistency check and repair are carried out on the file system, so that the file system can be mounted in time, the starting speed of the electronic equipment is improved, a user can use the file system in time, namely, the electronic equipment can be used in time, the user experience can be improved, and the use experience sense of the user can be improved.
In a possible implementation of the first aspect, the main thread is configured to perform consistency checking and repairing on a directory entry, a directory node, and metadata of the file system; the sub-threads are used for carrying out consistency check and repair on file nodes of the file system.
If the directory entry has consistency problem, the main thread repairs the data of the directory. If the directory node has consistency problems, the main thread repairs metadata of the directory. If the metadata of the file system has consistency problems, the main thread repairs the metadata of the file system. If the file node has consistency problems, the sub-thread repairs the metadata of the file.
In a possible implementation of the first aspect, the method further includes: determining a file node of a file system by a main thread; the main thread adds the information of the file node into a preset linked list; and the child thread performs consistency check and repair on the file nodes in the linked list.
In a possible implementation of the first aspect, the method further includes: the sub-thread records comparison information in a preset data area, wherein the comparison information is information corresponding to metadata of a file system, which is obtained in the process that the sub-thread performs consistency check and repair on file nodes in a linked list; and the main thread acquires the comparison information from the data area, and performs consistency check and repair on the metadata of the file system according to the metadata and the comparison information of the file system.
The metadata of the file system comprises information such as block statistical information, metadata bitmap information, orphan node information, quota information, metadata node information and the like. The comparison information also includes information such as block statistics, metadata bitmap information, orphan node information, quota information, and metadata node information. In addition, the preset data area may be a global data area in the memory.
In one possible implementation of the first aspect, the determining, by the main thread, a file node of the file system includes: the main thread checks the directory of the file system and determines the directory entry of the file system; the main thread determines the node type of the node corresponding to the directory entry, wherein the node type comprises file nodes.
In a possible implementation of the first aspect, the node type further includes a directory node, and the method further includes: if the main thread determines that the node type of the node corresponding to the directory entry is the directory node, the main thread performs consistency check and repair on the directory node.
In a possible implementation of the first aspect, the method further includes: and the main thread performs consistency check and repair on the directory entry of the determined file system.
In a possible implementation of the first aspect, the method includes: the main thread checks the root directory of the file system, sequentially traverses and scans all directory entries in the root directory, and performs consistency check and repair on the directory entries. And the main thread determines the node type of the node corresponding to the directory entry, and if the node is a file node, the main thread adds the information of the file node into the linked list. If the node is a directory node, the main thread performs consistency check and repair on the directory node. And then the main thread performs consistency check and repair on the directory entries corresponding to the next-layer directory until the consistency check and repair on all the directory entries are completed.
In a possible implementation of the first aspect, the method further includes determining, by the file system checking tool, a device performance capability value according to hardware resource information of the electronic device, and determining a number of sub-threads according to the device performance capability value.
In a possible implementation of the first aspect, the method further includes, the hardware resource information includes the following information: memory size; a memory base value; the number of CPU cores; CPU core base value; CPU frequency; CPU frequency base value.
In one possible implementation of the first aspect described above, the file system checking tool calculates the device performance capability value by the following formula:
Figure BDA0002963432020000021
wherein Z is a device performance capability value, M is a device memory size, M0 is a device memory base value, H is a device CPU core number, H0 is a device CPU core base value, F is a device CPU frequency, F0 is a device CPU frequency base value, and K1, K2 and K3 are weight coefficients.
In a possible implementation of the first aspect, the method further includes the file system checking tool creating the main thread and the sub-thread in any of the following cases: the file system checking tool checks that file system checking mark information exists in a file system image corresponding to the file system; the file system checking tool checks that the electronic equipment is started; the file system checking tool checks that the electronic device has been system upgraded.
In a possible implementation of the first aspect, the file system check flag information may be fsck flag bits in a superblock in a file system image. Of course, it may be other information.
In a possible implementation of the first aspect, the method further includes: if the file system detects consistency problems in the running process, the file system adds file system checking mark information in the corresponding file system image.
In a possible implementation of the first aspect, the method further includes: and the file system checking tool performs consistency check and repair on the file system corresponding to the file system image comprising the file system checking mark information through the main thread and the sub thread.
In a second aspect, embodiments of the present application provide an electronic device, including: a memory for storing a computer program, the computer program comprising program instructions; control means for executing program instructions to cause an electronic device to perform a file system management method as provided in the first aspect and/or any one of the possible implementation manners of the first aspect.
In a third aspect, an embodiment of the present application provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program includes program instructions that are executed by a computer to cause an electronic device to perform a file system management method as provided in the first aspect and/or any one of the possible implementations of the first aspect.
It will be appreciated that the advantages of the second to third aspects may be found in the relevant description of the first aspect, and are not described in detail herein.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the following description will briefly explain the drawings used in the description of the embodiments.
Fig. 1 is a schematic diagram illustrating a mobile phone 100 provided herein, according to some embodiments of the present application;
2A-2C are diagrams illustrating interfaces of a mobile phone 100 provided herein, according to some embodiments of the present application;
fig. 3 is a schematic diagram illustrating a structure of a mobile phone 100 according to some embodiments of the present application;
fig. 4 is a system framework diagram illustrating a mobile phone 100, according to some embodiments of the present application;
FIG. 5 is a flow chart illustrating a method of file system management provided herein, according to some embodiments of the present application;
FIG. 6 is a schematic diagram illustrating a process of a main thread and a sub-thread for consistency check and repair, according to some embodiments of the present application;
FIG. 7 is another process diagram illustrating a main thread and sub-threads for consistency check and repair, according to some embodiments of the present application;
FIG. 8 is a schematic diagram illustrating the structure of an electronic device, according to some embodiments of the present application;
fig. 9 is a schematic diagram illustrating the architecture of a system on a chip (SoC) according to some embodiments of the present application.
Detailed Description
The technical solutions of the present application will be further clearly and completely described below with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 provides a mobile phone 100 as an example of an electronic device provided herein. The handset 100 includes a file system and a file system image, the file system image including files. The file system is used to manage the file system image and the file system is used to name the files in the handset 100 and place the logical storage and recovery of the files.
In some cases, the consistency of the file system of the mobile phone 100 may be destroyed, so that a problem of inconsistent file system occurs. A file system suffers from a consistency problem, which may mean that consistency between metadata included in the file system, or between metadata and data, is broken. The file system thus experiences consistency problems, which may also be referred to as file system occurrence metadata consistency problems. The metadata included in the file system is core data of the file system, and relates to the reliability of the storage system.
The file system consistency problem occurs in a number of cases including: first, in the running process of the file system, the file system has defects (bugs) to cause inconsistent data, and consistency problems occur. Second, when an abnormality occurs in a storage device (such as universal flash storage (Universal Flash Storage, UFS) or embedded multimedia card (Embedded Multi Media Card, eMMC)), a driver (such as host) in the mobile phone 100 actively resets (reset) the device, so that data in the cache memory is lost, resulting in data not actually being dropped. The file system does not sense the device reset and thus consistency issues may also occur. Third, since the file system uses the remote update and garbage collection mechanism (Garbage Collection, GC) moving technology, the location of the physical blocks of the file may not be always unchanged, and if the service layer obtains the physical location of the file through the interface, the service layer bypasses the file system to directly operate the block device through the discard/write (discard/write) interface, and then the service layer may compete with the update and GC operation of the file system, resulting in damage to the file system and data, and consistency problems may occur. Fourth, the mobile phone 100 causes node (node) address access errors due to a central processing unit (Central Processing Unit, CPU) or Double Data Rate RAM (DDR) exception during system operation, or Data in the cache memory is stepped on, so that a consistency problem occurs. Fifth, a storage device (e.g., UFS or eMMC, etc.) has a media defect or a controller firmware defect, resulting in an error in the stored data and a consistency problem.
If the number of files in the file system is huge, the fsck tool needs a long processing time to check and repair the inconsistent file system when the file system has consistency problems.
For example, for the current mobile phone 100, when using chat, video, music, etc. application programs, the mobile phone 100 generates a large number of user files and temporary files, and when changing the phone, the user often selects a cloning mode to clone the files in the old mobile phone to the mobile phone 100 as a new mobile phone, so that the number of files in the file system of the mobile phone 100 is accumulated and is larger, and can even reach the millions. As shown in fig. 2A, the stored file analysis of the mobile phone 100 clearly shows that the number of files in the mobile phone 100 reaches the millions.
In the use process of the mobile phone 100, once the file system has consistency problem under certain conditions, the mobile phone 100 is restarted, and the operating system of the mobile phone 100 triggers the fsck tool to perform consistency check and repair on the file system during the restarting process. In the existing fsck tool, the consistency of the file system is checked and repaired by directly executing one fsck thread (the thread can also be called a process), and the checking and repairing of millions of files can be completed in at least 4 minutes, so that the consistency checking and repairing time is long and the efficiency is low. For example, as shown in fig. 2B, the fsck tool takes more than 4 minutes to check and repair the cell phone 100 for consistency.
When the mobile phone 100 is started, the fsck tool performs consistency check and repair on the file system, and if the file data size in the mobile phone 100 is large, the mobile phone 100 cannot be started quickly, and is always in a black screen state or in a starting interface as shown in fig. 2C, for example. In this case, the user may easily misunderstand that the mobile phone 100 is not started. If the user strongly presses the power key to restart the mobile phone 100 under the condition of impatience, the mobile phone 100 continues to perform consistency check and repair on the file system again because the fsck tool has not completed the previous check and repair on the file system, so that the mobile phone 100 enters a file system consistency check and repair cycle process, and cannot be started quickly, thereby affecting the use experience of the user.
The application provides a management method of a file system, which can be applied to the mobile phone 100, when the mobile phone 100 needs to perform consistency check and repair on the file system, a fsck tool in the mobile phone 100 simultaneously creates a main thread and a sub thread, and the main thread and the sub thread simultaneously cooperate to perform consistency check and repair on the file system. The inconsistent file system can be checked and repaired more quickly and efficiently, the time for checking and repairing the consistency is reduced, and the efficiency of checking and repairing the consistency is improved. The file system can be mounted in time, so that a user can use the file system in time, and the use experience of the user is improved.
In the present application, the number of main threads may be one, or the number of sub threads may be multiple, which may be determined according to the hardware resource information such as the memory size, the number of CPU cores, the CPU frequency, etc. of the mobile phone 100, or may be specifically set according to other needs.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a mobile phone 100 provided as an example in the embodiment of the present application.
The handset 100 may include a processor 110, an external memory interface 120, an internal memory 121, a usb interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, a SIM card interface 195, and the like. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It should be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the handset 100 may include more or fewer components than shown, or certain components may be combined, certain components may be split, or different arrangements of components.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (Application Processor, AP), a modem processor, a graphics processor (Graphics Processing Unit, GPU), an image signal processor (Image Signal Processor, ISP), a controller, a video codec, a digital signal processor (Digital Signal Processor, DSP), a baseband processor, and/or a Neural network processor (Neural-network Processing Unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The processor 110 may generate operation control signals according to the instruction operation code and the timing signals to complete the control of reading instructions and executing instructions.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an integrated circuit (Inter-integrated Circuit, I2C) interface, an integrated circuit built-in audio (Inter-integrated Circuit Sound, I2S) interface, a pulse code modulation (Pulse Code Modulation, PCM) interface, a universal asynchronous receiver Transmitter (Universal Asynchronous Receiver/Transmitter, UART) interface, a mobile industry processor interface (Mobile Industry Processor Interface, MIPI), a General-Purpose Input/Output (GPIO) interface, a subscriber identity module (Subscriber Identity Module, SIM) interface.
USB connector 130 is a connector that meets the USB standard specification and can be used to connect cell phone 100 to a peripheral device.
The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 to power the processor 110, the internal memory 121, the display 194, the camera 193, the wireless communication module 160, and the like.
The wireless communication function of the mobile phone 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc. applied to the handset 100.
The wireless communication module 160 may provide solutions for wireless communication including WLAN (e.g., wi-Fi), bluetooth, global navigation satellite system (Global Navigation Satellite System, GNSS), frequency modulation (Frequency Modulation, FM), near field wireless communication technology (Near Field Communication, NFC), infrared technology (IR), etc., applied to the handset 100. The wireless communication module 160 may be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via the antenna 2.
In some embodiments, the antenna 1 and the mobile communication module 150 of the handset 100 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the handset 100 can communicate with a network and other devices through wireless communication technology.
The mobile phone 100 implements display functions through a GPU, a display 194, an application processor, and the like. The display screen 194 is used to display images, videos, and the like. The display 194 includes a display panel. In some embodiments, the cell phone 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
The NPU is a neural-network (NN) computing processor, and can rapidly process input information by referencing a biological neural network structure, for example, referencing a transmission mode between human brain neurons, and can also continuously perform self-learning. Applications such as intelligent cognition of the mobile phone 100 can be realized through the NPU, for example: image recognition, face recognition, speech recognition, text understanding, etc.
The internal memory 121 may be used to store computer executable program code including instructions. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data (e.g., audio data, phonebook, etc.) created during use of the handset 100, etc. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like. The processor 110 performs various functional applications of the mobile phone 100 and data processing, for example, performs the file system management method provided herein, by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
The pressure sensor 180A is used to sense a pressure signal, and may convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194.
The touch sensor 180K, also referred to as a "touch device". The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen".
The keys 190 include a power-on key, a volume key, etc. The keys 190 may be mechanical keys. Or may be a touch key. The handset 100 may receive key inputs, generating key signal inputs related to user settings and function control of the handset 100.
Referring to fig. 4, a system frame diagram of a mobile phone 100 is provided. The handset 100 includes at least an application layer and a system layer, wherein the application layer includes an application program and fsck tools. The system layer includes an operating system kernel that includes a file system driver and a block device driver. The system layer also includes block devices (e.g., disks) that include file system images (or may also be referred to as mirrored file systems).
It should be noted that, the file of the file system is stored by the image file in the file system image, so in this application, the operation of the file system and the consistency check and repair are also understood as the operation of the file system image and the consistency check and repair.
For example, an application program invoking a file system interface may operate on a file system image via a file system driver and a block device driver, such as an online write operation on an image file in the file system image. And the fsck tool can drive the offline checking and repairing of the mirror image files in the file system mirror image through the block equipment so as to achieve the purpose of consistency checking and repairing of the file system. Offline means that the file system image is not in a non-mount state during use of the file system.
It should be noted that, the mobile phone 100 may further include an application layer and a system layer, and other functional modules, which may be set as required, which are not described in detail in this application.
The file system management method provided by the application can be applied to the mobile phone 100. When the file system of the handset 100 is inconsistent, the file system may flag the inconsistency. When the handset 100 is restarted, the fsck tool performs consistency checking and repair on the file system.
Referring to fig. 5, in one implementation of the present application, the process of managing the file system by the mobile phone 100 includes the following steps:
S100, in the running process of the file system of the mobile phone 100, the condition of inconsistent file systems is checked.
The file system checks that a file system inconsistency occurs, for example, the file system checks that a file node in the file system is inconsistent. For example, during operation of a file system, checking the metadata of a file in the file system indicates that the file has 1 block (e.g., 1 data block), but in reality the file has 2 blocks, indicates that the metadata of the file is inconsistent.
Further, in this implementation manner, for S100, the file system may check that the file system is inconsistent, or the file system may check that the directory node of the file system is inconsistent, or the file system may check that the directory entry of the file system is inconsistent, or the file system may check that metadata of the file system is inconsistent, or the like.
Wherein, the directory entries are data of the directory node, each directory entry is a key value pair, a key word (or key) in the key value pair is a name of a child node of the directory node, and a key value in the key value pair is entry information of the child node of the directory node. The file system may find the directory entry containing the specified name by searching all directory entries to determine the location of the child node to which the directory entry corresponds.
In addition, if there is a consistency problem in the directory entry, the data of the directory needs to be repaired. If there is a consistency problem for the directory nodes, the metadata of the directory needs to be repaired. If the metadata of the file system has consistency problems, the metadata of the file system needs to be repaired. If the file node has consistency problem, the metadata of the file needs to be repaired.
S200, the file system carries out fsck marking.
The fsck marking by the file system may be, for example, that the file system adds a specific fsck marking bit to a super block of the file system image to perform fsck marking. The next time handset 100 is powered on, the fsck tool may determine if the file system is inconsistent and if consistency checks and repairs are made by checking if the fsck flag bit is present.
The fsck flag bit may be, for example, "1". Of course, it may be other file system check mark information.
S300, the mobile phone 100 restarts the power-on.
The mobile phone 100 is restarted to start, and the system of the mobile phone 100 is started, so that a file system needs to be mounted.
S400, performing fsck mark check on the super block of the file system image by the fsck tool to judge whether fsck mark bits exist or not. If so, the fsck tool determines that the file systems are inconsistent, and the fsck tool performs S500. If not, the fsck tool determines that the file system is consistent, i.e., no abnormality has occurred in the file system, and the fsck tool performs S800, i.e., the handset 100 does not need to perform the check and repair processing of the fsck tool for the consistency of the system file.
S500, the fsck tool creates a main thread and n sub-threads, wherein n is a positive integer greater than or equal to 1.
In the implementation mode, the fsck tool creates a main thread and n sub threads to perform multi-thread collaborative consistency check and repair, so that the time for consistency check and repair can be reduced, and the efficiency of consistency check and repair can be improved.
The number of threads may affect the efficiency with which fsck tools perform consistency checks and repairs. The greater the number of threads, the greater the efficiency of fsck inspection and repair, without being limited to the hardware resources of the handset 100. However, the hardware resources (such as CPU, memory, etc.) of the mobile phone 100 are limited, and the difference between the hardware resources is relatively large due to different model specifications. Thus, in this implementation, the fsck tool may automatically set the number of threads according to the hardware resources of the handset 100.
The fsck tool sets the thread number of the threads according to the hardware resource, and may be the fsck tool determines the device performance capability value according to the hardware resource information, and then determines the number of the created threads according to the device performance capability value. The hardware resource information may include information such as a memory size, a memory base value, the number of CPU cores, a CPU core base value, a CPU frequency, and a CPU frequency base value of the mobile phone 100.
In one implementation of the present application, the device performance capability value may be calculated as follows:
Figure BDA0002963432020000081
wherein Z is a device performance capability value, M is a memory size, M0 is a memory base value, H is the number of CPU cores, H0 is a CPU core base value, F is a CPU frequency, F0 is a CPU frequency base value, and K1, K2 and K3 are weight coefficients.
In one implementation of the present application, the weight coefficient k1=0.4, the weight coefficient k2=0.3, and the weight coefficient k3=0.3. Memory base m0=0.6, cpu core base h0=1, cpu frequency base f0=1.8.
For example, in the present embodiment, the DDR memory of the mobile phone 100 is 8gb, the number of cpu cores is 8, and the cpu frequency (main frequency) is 2.4GHz. By calculation, the device performance capability value z=0.4×8/0.6+0.3×8+0.3×2.4/1.8=8.13 for the handset 100. The mobile phone 100 may determine that the number of created main threads is 1 and the number of created sub threads is 8 according to the device performance capability value Z. Or the mobile phone 100 may determine that the number of created main threads is 1 and the number of created sub threads is 9 according to the device performance capability value Z. Or the mobile phone 100 may determine that the number of created main threads is 1 and the number of created sub threads is 7 according to the device performance capability value Z.
In other implementations of the present application, the weight coefficient K1 may have a value ranging from 0.3 to 0.6, the weight coefficient K2 may have a value ranging from 0.2 to 0.5, and the weight coefficient K3 may have a value ranging from 0.2 to 0.5. The value range of the memory basic value M0 can be 0.5-0.7, the value range of the CPU core basic value H0 can be 0.8-1.2, and the value range of the CPU frequency basic value F0 can be 0.6-2.0. Of course, the weight coefficient K1, the weight coefficient K2, the weight coefficient K3, the memory base value M0, the CPU core base value H0, and the CPU frequency base value F0 may be any other values, and may be set as needed.
S600, performing file system consistency check and repair by the fsck tool.
The fsck tool performs file system consistency check and repair by performing multithreading cooperation between a main thread and a plurality of sub-threads such as sub-thread 1, sub-thread 2, sub-thread 3 and … …, and sub-thread n, so as to perform file system consistency check and repair. Each thread needs to determine data and metadata in a file system which is responsible for checking and repairing, and consistency checking and repairing are carried out on the data and the metadata in the file system which is responsible for checking and repairing, so that the problem that new inconsistency is caused by competing interference among threads can be avoided.
For example, the main thread is used to check and repair directory node inconsistency problems in the file system, directory entry inconsistency problems, and metadata inconsistency problems of the file system. The sub-threads are used to check and repair inconsistent problems for file nodes in the file system.
The process by which the fsck tool performs file system consistency checks and repairs will be described in detail below.
S700, the fsck tool completes consistency checking and repairing, removes fsck mark bits in the file system mirror super block, and recovers thread resources.
S800, the fsck tool exits the consistency check and repair flow and ends the consistency check and repair.
Referring to fig. 6, for S600 described above, in some embodiments of the present application, the fsck tool performs the consistency check and repair as the main thread and the sub thread perform the consistency check and repair, respectively, and the process may include the following steps:
s601, the main thread starts up, and the main Cheng Qi sub-thread. The main thread executes S602, and each sub-thread executes S614, and the main thread and the sub-thread cooperate to start scanning the entire data structure of the file system.
The data structure of the file system includes root nodes, which may also be referred to as root directories, and various levels of subdirectories and files. The root node records directory entries of files and directories of the file system. The directory entry records information such as the type of the node, the name of the node, entry information of the node (e.g., node number or node ID), and the like. The directory entries are the data of the directory (i.e. the directory nodes), as described above, each directory entry is a key pair, the key in the key pair (or may also be called a key) is the name of the child node of the directory node, and the key in the key pair is the entry information of the child node of the directory node. The main thread may find the directory entry containing the specified name by searching all directory entries to determine the location of the child node to which the directory entry corresponds. I.e. the main thread can determine the location of the node (i.e. child node) corresponding to each directory entry from the directory entry.
S602, the main thread checks root nodes of a file system directory structure.
S603, the main thread determines the directory entry and starts traversing all directory entries corresponding to the scanned directory.
For example, the main thread first scans all directory entries corresponding to the root node.
S604, the main thread determines whether a directory entry is scanned, i.e., whether there are unset directory entries scanned. If yes, the main thread executes S605. If not, the main thread executes S619.
S605, the main thread determines a directory entry.
S606, the main thread checks the consistency of the directory entry, and the main thread executes S607.
The main thread checks the consistency of the directory entries, for example, it may be that the main thread determines the consistency of the directory entries according to whether the entry information of the nodes recorded in the directory entries finds the corresponding nodes. For example, if the main thread does not find a corresponding node according to entry information of the node recorded in the directory entry, the main thread determines that the directory entry is inconsistent. If the main thread finds a corresponding node according to the entry information of the node recorded in the directory entry, the main thread determines that the directory entries are consistent.
The main thread checks the consistency of the directory entry, for example, it may also be that the main thread determines whether the node type recorded in the directory entry and the node type actually detected by the main thread are consistent to determine the consistency of the directory entry. For example, the main thread determines that the node type recorded in the directory entry is a directory node, but the node type actually detected by the main thread is a file node, the main thread determines that the directory entry is inconsistent. If the main thread determines that the node type recorded in the directory entry is the directory node, and the node type actually detected by the main thread is the directory node, the main thread determines that the directory entry is consistent.
The main thread may check the consistency of the directory entries, for example, the main thread may determine the node number recorded in the directory entry to determine the corresponding node, and determine whether the directory entries are inconsistent by determining whether the address of the node is a valid address. If the address is an effective address, the directory entries are considered to be consistent, and if the address is an invalid address, the directory entries are considered to be inconsistent.
Of course, the main thread may also determine the consistency of the directory entries by examining other information.
S607, the main thread determines whether to perform repair of directory entry consistency.
If the main thread checks that the directory entry is inconsistent, the main thread determines to repair the directory entry consistency, and the main thread performs S608. If the main thread checks that the directory entry is consistent, the main thread determines that the repair of the directory entry consistency is not performed, and the main thread performs S609.
S608, the main thread repairs the directory entry.
For example, if the main thread detects that the node type recorded in the directory entry is inconsistent with the node type corresponding to the directory entry actually detected by the main thread, the main thread repair directory entry may be, for example, that the main thread modifies the node type recorded in the directory entry to be consistent with the node type actually detected by the main thread. That is, the main thread restores the information of the original directory entry according to the actually detected information of the directory entry by the main thread so as to restore the consistency of the directory entry.
S609, the main thread determines the node type of the node corresponding to the directory entry. If the node is a file node, the main thread executes S610. If the node is a directory node, the main thread executes S611.
S610, the main thread adds the information of the file node to a preset linked list.
The information of the file node includes node number information corresponding to the file node, type information of the file node, context information (e.g., parent node information) of the file node, and the like.
The preset linked list refers to a global linked list preset in the memory of the mobile phone 100 (or in a system that may be called as the mobile phone 100) and used for storing the information of the file node, and the global linked list may be selected and set according to the need, so that the main thread may access the linked list to store the information of the file node.
After the main thread adds the information of the file node into a preset linked list, the sub-thread can be awakened, so that the sub-thread determines whether a newly added file node exists in the linked list.
In addition, the main thread then executes S605 to determine the next directory entry in the root node.
S611, the main thread checks consistency of metadata related to the data index in the directory node, and performs S612.
The metadata associated with the data index may be, for example, block information in metadata of a directory corresponding to the directory node. The main thread checks the consistency of the metadata related to the data index in the directory node, which may be that the main thread determines the consistency of the metadata related to the data index according to whether the block information recorded by the metadata related to the data index and the block information actually detected by the main thread are consistent. For example, if the main thread determines that there are 5 blocks based on the metadata associated with the data index, but the main thread actually detects 4 blocks, the main thread determines that the metadata associated with the data index is inconsistent. If the main thread determines that there are 5 blocks according to the metadata related to the data index and the main thread actually detects 5 blocks, the main thread determines that the metadata related to the data index is consistent.
S612, the main thread determines whether to repair the directory node according to whether metadata related to the data index in the directory node is inconsistent. If not, the main thread needs to repair the directory node, and the main thread performs S613. If so, the main thread determines that it is not necessary to repair the directory node, and the main thread performs S603.
S613, the main thread repairs the directory node.
The main thread repairing directory node may be, for example, the main thread modifying the block information in the metadata of the directory corresponding to the directory node from 5 to 4.
In addition, the main thread then executes S603, recursively traversing the next-level directory. That is, the main thread selects one of the subdirectories of the next layer of the root node, and traverses all the directory entries corresponding to the subdirectories, and the steps S604 to S613 are executed.
The main thread scans the entire data structure of the file system by executing S602 to S613 described above, and can determine the file node in the file system. And the main thread adds the information of the file node into the linked list and is used for checking and repairing the consistency of the file node by the sub thread.
In addition, in the present implementation, the main thread scans the entire data structure of the file system by executing S602 to S613 described above, and can check and repair the consistency problem of the directory entry of the file system and the consistency problem of the directory node in the file system.
S614, the child thread is started, and S615 is executed after the child thread is awakened.
When the main thread adds the information of the file node into the linked list, the main thread wakes up the started sub thread, that is, the sub thread executes S615 after being waken up by the main thread to determine whether a newly added file node exists in the linked list.
S615, the sub-thread determines whether a newly added file node exists in the linked list. If so, the child thread executes S616. If not, the child thread sends notification of completion of checking and repair to the main thread, and the main thread performs S619.
The sub-threads determine whether a newly added file node exists in the linked list, and may queue each sub-thread to determine whether the newly added file node exists in the linked list. For example, the sub-thread 1 may first determine whether or not there is a new file node in the linked list, and if the sub-thread 1 detects a new file node from the linked list, the sub-thread 1 executes S616. Then, the sub-thread 2 determines whether there is a new file node in the linked list, and if the sub-thread 2 detects the new file node from the linked list, the sub-thread 2 executes S616. The other sub-threads may check in sequence to determine if there are additional file nodes in the linked list, and if so, the sub-thread performs S616.
In addition, each sub-thread can determine whether a newly added file node exists in the linked list according to a preset checking time interval, and the value range of the checking time interval can be 0 seconds to 3 seconds, for example, the checking time interval can be 0 seconds (that is, the sub-thread continuously determines whether the newly added file node exists in the linked list in sequence), 0.5 seconds, 1 second, 2 seconds, 2.4 seconds, 3 seconds and the like. Of course, the checking time interval may be any other value.
S616, the sub-thread checks the consistency of the metadata related to the data index in the file node, and performs S617.
The metadata related to the data index in the file node may be, for example, block information in metadata of a file corresponding to the file node. The sub-thread checks the consistency of the metadata related to the data index in the file node, and may be that the sub-thread determines the consistency of the metadata related to the data index according to whether the block information recorded by the metadata related to the data index and the block information actually detected by the sub-thread are consistent. For example, if the sub-thread determines that there are 20 blocks according to the metadata associated with the data index, but the sub-thread actually detects 9 blocks, the sub-thread determines that the metadata associated with the data index in the file node is inconsistent. If the sub-thread determines that 20 blocks exist according to the metadata related to the data index, and the sub-thread actually detects 20 blocks, the sub-thread determines that the metadata related to the data index of the file node is consistent.
Of course, the sub-thread may check consistency of metadata related to the data index in the file node, or may check whether other metadata information in the file node is consistent to determine consistency of the file node.
S617, the sub-thread determines whether to repair the file node according to whether metadata related to the data index in the file node is inconsistent. If not, the sub-thread determines that the file node needs to be repaired, and the sub-thread performs S618. If so, the sub-thread determines that the file node does not need to be repaired, and the sub-thread continues to execute S615 to determine whether there are newly added nodes in the linked list.
S618, repairing the file node by the sub-thread.
The sub-thread repairing the file node may be, for example, the sub-thread modifying the block information in the metadata associated with the data index in the file node from 20 to 9.
In the process of executing the above steps S615 to S618 to perform consistency detection and repair of the file node by the sub-thread, if the sub-thread detects that there is the contrast information related to the consistency of metadata of the file system, the sub-thread may record (or store) the contrast information in the memory, for example, record a certain preset data area in the memory, where the data area may be a global data area of the memory, and may be selected and set according to needs, so that the main thread may access the data area to obtain the contrast information. As for the control information, detailed description will be made later.
After the sub-thread repairs the file node, the sub-thread may continue to execute S614 described above, where the queuing detection determines whether a newly added file node exists in the linked list until no newly added file node exists in the linked list. At this point, the sub-thread may inform the main thread that the sub-thread scan check is complete.
S619, the main thread checks the consistency of the metadata of the file system.
If the main thread does not scan the directory entry, i.e. the main thread determines that all directory entries have been scanned, there are no non-scanned directory entries, and the main thread Cheng Dengdai sub-thread scanning is completed, i.e. the main thread Cheng Dengdai sub-thread completes the consistency check and repair processes of S615 to S618, the main thread starts to check the consistency of the metadata of the file system.
The main thread checks the consistency of the metadata of the file system, which may be that the main thread accesses the aforementioned data area to obtain the comparison information, and the main thread determines whether the metadata of the file system is consistent according to the metadata of the file system and the comparison information.
For example, if the metadata of the file system records that the file system includes 10 file nodes, but the main thread determines that the file nodes are only 8 according to the comparison information, the metadata of the file system is inconsistent. If the metadata of the file system records that the file system comprises 10 file nodes, but the main thread determines that the file system comprises 10 file nodes according to the comparison information, the metadata of the file system is consistent.
S620, the main thread determines whether to repair the metadata of the file system according to the consistency check result of the metadata of the file system. If the main thread check determines that the metadata of the file system is inconsistent, the main thread determines that metadata repair of the file system is required, and the main thread performs S621. If the main thread checking determines that the metadata of the file system is consistent, the main thread determines that the metadata of the file system is not required to be repaired, and the main thread finishes checking and repairing the consistency of the file system.
S621, the main thread repairs metadata of the file system.
Referring to fig. 7, fig. 7 is a schematic diagram illustrating functional modules of a main thread and a sub thread, and a process of performing consistency detection and repair on corresponding metadata nodes by the main thread and the sub thread. The main thread and the sub thread both comprise a scanning module and a repairing module, wherein the scanning module is used for the thread to carry out consistency check scanning on the corresponding metadata nodes (namely file nodes) so as to determine whether the metadata nodes are inconsistent. The repair module is used for carrying out consistency repair processing on the corresponding metadata nodes by the threads. The metadata node corresponding to the main thread may be metadata of the file system. The metadata node corresponding to the child thread may be the file node described above.
In addition, each sub-thread may record the comparison information of the metadata of the file system, for example, the comparison information may be recorded in the aforementioned data area during the consistency detection and repair process of the file node.
The metadata of the file system comprises information such as block statistical information, metadata bitmap information, orphan node information, quota information, metadata node information and the like. Wherein the block statistics are statistics of blocks in the file system related to the data storage. The orphan node information is information such as node numbers of orphan nodes. The quota information is statistical information such as the number of file nodes, the number of blocks and the like corresponding to different types of quota IDs. The metadata node information is information such as node number and number of metadata.
The comparison information is statistical information, metadata bitmap information, orphan node information, quota information, metadata node information and the like.
The metadata of the main thread repair file system is, for example, information "including 10 file nodes" described in the metadata of the file system, and is modified to "including 8 file nodes" information.
The main thread then ends the checking and repair of file system consistency. I.e., fsck checking and repair are completed, the above-described S700 is performed.
After the main thread repairs the metadata of the file system, the fsck checking and repairing is completed, and the fsck tool exits the checking and repairing process. The mobile phone 100 then mounts the file system.
In this implementation, when the main thread executes S607 described above, the main thread may also refer to other information at the same time to determine whether to perform inconsistent repair. For example, if the main thread determines that the directory entry is an unnecessary repair object, the main thread may not perform a consistency repair on the directory entry. If the main thread determines that the directory entry is an object which must be repaired, the main thread performs consistency repair on the directory entry. Of course, the main thread may also refer to the information of the information at the same time to determine whether to perform inconsistent repair on the directory entry. In addition, when the main thread performs S612 and S620 described above, the main thread may also refer to other information at the same time to determine whether to perform inconsistent repair. While the sub-thread is executing S617 described above, the sub-thread may also refer to other information to determine whether to perform inconsistent repair on the file node.
In this implementation, for S601 described above, the main thread may not start the sub thread first after the main thread is started. When the main thread executes S610 described above, after adding the file node information to the linked list, the main thread restarts and wakes up the sub-thread, so that the sub-thread determines whether there is a new node in the linked list. The waiting time of the sub-thread can be effectively reduced, and the system resource is saved.
In addition, in the present application, the mobile phone 100 may take events such as the above-mentioned consistency problem of the file system, the fsck tool creating the master thread and the slave thread, and the process of checking and repairing the consistency of the file system by the fsck tool into the event log.
In other implementations of the present application, fsck tools may also perform consistency checking and repair of file systems in other coordinated ways through the main thread and the sub-threads.
According to the file system management method provided by the application, after the file system in the mobile phone 100 detects the condition that the file system is inconsistent, for example, in the restarting process of the mobile phone 100, the mobile phone 100 can detect and repair the occurrence of the file system consistency problem through the fsck tool. And the fsck tool can create a main thread and a sub thread, and perform consistency check and repair on the file system in a multithreading cooperative mode, compared with the mode that the fsck tool only performs consistency check and repair on the file system through the main thread, the fsck tool can solve the problem of long time consumption for consistency check and repair on the file system, greatly improves the efficiency of consistency check and repair on the file system, shortens the starting-up time of the mobile phone 100, and improves the use experience of a user on the mobile phone 100. In addition, through experiments and comparison of efficiency of file system consistency check and repair performed in two modes, the fsck tool provided by the implementation manner can improve efficiency of file system consistency check and repair by creating a mode of carrying out consistency check and repair on a file system by cooperation of a main thread and a sub thread, for example, by more than 70%.
In other implementations of the present application, the node types of the file system include directory nodes, unknown node files, common node files, directory files, character files, soft link files, FIFO files, block device files, socket files, and the like. The file node may be a non-directory node, that is, all nodes of other types except the directory node, for example, the file node may include a common node file, a directory file, a character file, a soft link file, a FIFO file, a block device file, a socket file, and the like.
In other implementations of the present application, in a scenario where the mobile phone 100 performs a system (i.e., an operating system) upgrade, in order to avoid a problem of consistency of a file system, the mobile phone 100 may also perform consistency check and repair on the file system according to the file system management method provided in the present application. For example, after the mobile phone 100 performs a system upgrade, or the mobile phone 100 performs a system upgrade, the file system actively invokes the fsck tool to perform the foregoing S500 and S600 for consistency check and repair, and directly performs the foregoing S800 after the consistency check and repair are completed, and the fsck tool exits the consistency check and repair process to end the consistency check and repair. In this case, the mobile phone 100 does not need to execute S100 to S400 and S700 described above.
The file system management method provided by the implementation manner can carry out consistency check and repair on the file system in the system upgrading scene, solves the problem of long time consumption of the consistency check and repair of the file system, greatly improves the efficiency of the consistency check and repair of the file system, can enable the updated new file system to be used more quickly, and improves the use experience of a user on the mobile phone 100.
In other implementations of the present application, the mobile phone 100 may also automatically perform the fsck tool checking and repairing consistency after the installation or updating of the application program is completed.
In this application, the file system runs in kernel mode and the fsck tool runs in user mode as a user mode tool for checking and repairing consistency of the file system.
In other implementations of the present application, when a discrepancy is detected, the mobile phone 100 displays a reminder on the display interface to remind the user to manually determine to repair.
Or if the other mobile phone 100 checks that file system consistency has occurred, the fsck check and repair consistency described above is performed.
In other implementations of the present application, the mobile phone 100 may also be other electronic devices such as tablet computers, televisions, notebook computers, personal computers (Personal Computer, PCs), ultra-mobile personal computers (Ultra-mobile Personal Computer, UMPCs), handheld computers, netbooks, personal digital assistants (Personal Digital Assistant, PDAs), smart devices (e.g., speakers, routers, smart screens, etc.), internet of things (Internet of Things, ioT) devices, etc. that include file storage related file systems. The file system management method provided by the application can also be applied to the electronic equipment.
According to the file system management method, the mobile phone 100 can perform consistency check and repair on the file system through the fsck tool. And the fsck tool can create a main thread and a sub thread, and perform consistency check and repair on the file system in a multithreading cooperative mode, compared with the mode that the fsck tool only performs consistency check and repair on the file system through the main thread, the fsck tool can solve the problem of long time consumption for consistency check and repair of the file system, greatly improves the efficiency of consistency check and repair of the file system, and improves the use experience of a user on the mobile phone 100.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an electronic device 900 according to an embodiment of the present application. The electronic device 900 may include one or more processors 901 coupled to a controller hub 904. For at least one embodiment, controller hub 904 communicates with processor 901 via a multi-drop bus, such as a Front Side Bus (FSB), a point-to-point interface, such as a Quick Path Interconnect (QPI), or similar connection. The processor 901 executes instructions that control the general type of data processing operations. In one embodiment, controller hub 904 includes, but is not limited to, a Graphics Memory Controller Hub (GMCH) (not shown) and an input/output hub (IOH) (which may be on separate chips) (not shown), where the GMCH includes memory and graphics controllers and is coupled to the IOH.
Electronic device 900 may also include a coprocessor 906 and memory 902 coupled to controller hub 904. Alternatively, one or both of the memory 902 and GMCH may be integrated within the processor 901 (as described herein), with the memory 902 and co-processor 906 being directly coupled to the processor 901 and the controller hub 904, the controller hub 904 being in a single chip with the IOH.
The memory 902 may be, for example, dynamic Random Access Memory (DRAM), phase Change Memory (PCM), or a combination of both.
In one embodiment, coprocessor 906 is a special-purpose processor, such as, for example, a high-throughput MIC processor, a network or communication processor, compression engine, graphics processor, GPGPU, embedded processor, or the like. Optional properties of coprocessor 906 are shown in fig. 8 with dashed lines.
In one embodiment, electronic device 900 may further include a Network Interface (NIC) 903. The network interface 903 may include a transceiver to provide a radio interface for the electronic device 900 to communicate with any other suitable device (e.g., front end module, antenna, etc.). In various embodiments, the network interface 903 may be integrated with other components of the electronic device 900. The network interface 903 may implement the functions of the communication units in the above-described embodiments.
The electronic device 900 may further include an input/output (I/O) device 905. Input/output (I/O) devices 905 may include: a user interface, the design enabling a user to interact with the electronic device 900; the design of the peripheral component interface enables the peripheral component to also interact with the electronic device 900; and/or sensors designed to determine environmental conditions and/or location information associated with the electronic device 900.
It is noted that fig. 8 is merely exemplary. That is, although fig. 8 shows that the electronic apparatus 900 includes a plurality of devices such as a processor 901, a controller hub 904, and a memory 902, in practical applications, the apparatus using the methods of the present application may include only a part of the devices of the electronic apparatus 900, for example, may include only the processor 901 and the NIC903. The nature of the alternative device is shown in dashed lines in fig. 8.
One or more tangible, non-transitory computer-readable media for storing data and/or instructions may be included in the memory of the electronic device 900. The computer-readable storage medium has stored therein instructions, and in particular, temporary and permanent copies of the instructions.
In this application, the electronic device 900 may be a terminal device such as a mobile phone, a tablet computer, a personal digital assistant (Personal Digital Assistant, PDA), or a desktop computer. The instructions stored in the memory of the electronic device may include: instructions that, when executed by at least one unit in the processor, cause the electronic device to implement the file system management method as previously mentioned.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an SoC (System on Chip) 1000 according to an embodiment of the present application. In fig. 9, similar parts have the same reference numerals. In addition, the dashed box is an optional feature of the more advanced SoC 1000. The SoC1000 may be used in any electronic device according to the present application, and may implement corresponding functions according to the device in which it is located and the instructions stored therein.
In fig. 9, the SoC1000 includes: an interconnect unit 1002 coupled to the processor 1001; a system agent unit 1006; a bus controller unit 1005; an integrated memory controller unit 1003; a set or one or more coprocessors 1007 which may include integrated graphics logic, image processors, audio processors, and video processors; an SRAM (static random access memory) unit 1008; a DMA (direct memory access) unit 1004. In one embodiment, coprocessor 1007 includes a special-purpose processor, such as, for example, a network or communication processor, compression engine, GPGPU, high-throughput MIC processor, embedded processor, or the like.
One or more computer-readable media for storing data and/or instructions may be included in the SRAM cell 1008. The computer-readable storage medium may have stored therein instructions, and in particular, temporary and permanent copies of the instructions. The instructions may include: instructions that when executed by at least one unit in the processor cause the electronic device to implement the file system management method as mentioned above.
Embodiments of the mechanisms disclosed herein may be implemented in software, hardware, firmware, or a combination of these implementations. Embodiments of the present application may be implemented as a computer program or program code executing on a programmable system comprising at least one processor, memory (or storage system including volatile and non-volatile memory and/or storage units).
It should be noted that the terms "first," "second," and the like are used merely to distinguish between descriptions and should not be construed as indicating or implying relative importance.
It should be noted that in the drawings, some structural or method features may be shown in a specific arrangement and/or order. However, it should be understood that such a particular arrangement and/or ordering may not be required. Rather, in some embodiments, these features may be arranged in a different manner and/or order than shown in the illustrative figures. Additionally, the inclusion of structural or methodological features in a particular figure is not meant to imply that such features are required in all embodiments, and in some embodiments, may not be included or may be combined with other features.
While the present application has been shown and described with respect to certain preferred embodiments thereof, it will be understood by those of ordinary skill in the art that the foregoing is a further detailed description of the present application in conjunction with the specific embodiments and is not intended to limit the practice of the present application to such descriptions. Various changes in form and detail may be made therein by those skilled in the art, including a few simple inferences or alternatives, without departing from the spirit and scope of the present application.

Claims (14)

1. A file system management method applied to an electronic device, the method comprising:
the file system checking tool creates a main thread and at least one sub thread;
the file system checking tool performs consistency checking and repairing on the file system through the main thread and the sub thread, wherein the main thread is used for determining file nodes of the file system, adding information of the file nodes into a preset linked list, and the sub thread is used for performing consistency checking and repairing on the file nodes in the linked list.
2. The method of claim 1, wherein,
the main thread is also used for carrying out consistency check and repair on directory entries, directory nodes and metadata of the file system.
3. The file system management method according to claim 2, wherein the method further comprises:
the sub-thread records comparison information in a preset data area, wherein the comparison information is information corresponding to metadata of the file system, which is obtained in the process that the sub-thread carries out consistency check and repair on the file nodes in the linked list;
And the main thread acquires the comparison information from the data area, and performs consistency check and repair on the metadata of the file system according to the metadata of the file system and the comparison information.
4. The file system management method of claim 2, wherein the main thread determining a file node of the file system comprises:
the main thread checks the directory of the file system and determines the directory entry of the file system;
and the main thread determines the node type of the node corresponding to the directory entry, wherein the node type comprises the file node.
5. The file system management method according to claim 4, wherein said node type further comprises said directory node, said method further comprising: and if the main thread determines that the node type of the node corresponding to the directory entry is the directory node, the main thread performs consistency check and repair on the directory node.
6. The file system management method according to claim 4, wherein said method further comprises: the main thread performs consistency check and repair on the determined directory entry of the file system.
7. The file system management method according to any one of claims 1 to 6, wherein said method further comprises: the file system checking tool determines a device performance capability value according to the hardware resource information of the electronic device, and determines the number of the sub-threads according to the device performance capability value.
8. The file system management method according to claim 7, wherein the hardware resource information includes the following information:
memory size;
a memory base value;
the number of CPU cores;
CPU core base value;
CPU frequency;
CPU frequency base value.
9. The file system management method according to claim 8, wherein said file system checking tool calculates said device performance capability value by the following formula:
Figure FDA0004095093560000021
wherein Z is the device performance capability value, M is the memory size, M0 is the memory base value, H is the number of CPU cores, H0 is the CPU core base value, F is the CPU frequency, F0 is the CPU frequency base value, and K1, K2 and K3 are weight coefficients.
10. The file system management method according to any one of claims 1 to 6, further comprising the file system checking tool creating the main thread and the sub-thread if any one of:
The file system checking tool checks that file system checking mark information exists in a file system image corresponding to the file system;
the file system checking tool checks that the electronic equipment is started up;
the file system checking tool checks that the electronic equipment is subjected to system upgrading.
11. The file system management method according to claim 10, wherein said method further comprises:
if the file system detects consistency problems in the running process, the file system adds the file system detection mark information into the corresponding file system image.
12. The file system management method according to claim 11, wherein said method further comprises:
and the file system checking tool performs consistency check and repair on the file system corresponding to the file system image comprising the file system checking mark information through the main thread and the sub thread.
13. An electronic device, comprising:
a memory for storing a computer program, the computer program comprising program instructions;
control means for executing program instructions to cause an electronic device to perform the file system management method according to any one of claims 1-12.
14. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program comprising program instructions that are executed by a computer to cause an electronic device to perform the file system management method according to any of claims 1-12.
CN202110244081.XA 2021-03-05 2021-03-05 File system management method and electronic equipment Active CN115033525B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110244081.XA CN115033525B (en) 2021-03-05 2021-03-05 File system management method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110244081.XA CN115033525B (en) 2021-03-05 2021-03-05 File system management method and electronic equipment

Publications (2)

Publication Number Publication Date
CN115033525A CN115033525A (en) 2022-09-09
CN115033525B true CN115033525B (en) 2023-06-09

Family

ID=83118416

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110244081.XA Active CN115033525B (en) 2021-03-05 2021-03-05 File system management method and electronic equipment

Country Status (1)

Country Link
CN (1) CN115033525B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104641365A (en) * 2012-09-19 2015-05-20 日立数据系统工程英国有限公司 System and method for managing deduplication using checkpoints in a file storage system
CN111596930A (en) * 2020-05-22 2020-08-28 深圳创新奇智科技有限公司 Root file system mirror image manufacturing method and device, storage medium and embedded device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102147755B (en) * 2011-04-14 2012-07-04 中国人民解放军国防科学技术大学 Multi-core system fault tolerance method based on memory caching technology
US9465810B2 (en) * 2011-07-20 2016-10-11 Veritas Technologies Llc Method and system for a fast full style system check using multithreaded read ahead
CN109586989B (en) * 2017-09-28 2022-09-20 阿里巴巴集团控股有限公司 State checking method, device and cluster system
CN111488255A (en) * 2020-03-27 2020-08-04 深圳壹账通智能科技有限公司 Multithreading concurrent monitoring method, device, equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104641365A (en) * 2012-09-19 2015-05-20 日立数据系统工程英国有限公司 System and method for managing deduplication using checkpoints in a file storage system
CN111596930A (en) * 2020-05-22 2020-08-28 深圳创新奇智科技有限公司 Root file system mirror image manufacturing method and device, storage medium and embedded device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Purushottam Sigdel等.Coalescing and Deduplicating Incremental Checkpoint Files for Restore-Express Multi-Level Checkpointing.《IEEE Transactions on Parallel and Distributed Systems》.2018,2713-2727. *
张悠慧,汪东升,郑纬民.Solaris系统多线程检查点设置与卷回恢复.计算机工程与应用.2000,(08),45-47. *
王雅楠 ; 陈香兰 ; 代栋 ; 孙明明 ; 周学海 ; .基于镜像的在线文件系统检查工具的研究与实现.计算机系统应用.2013,(08),184-189. *

Also Published As

Publication number Publication date
CN115033525A (en) 2022-09-09

Similar Documents

Publication Publication Date Title
CN107786794B (en) Electronic device and method for providing an image acquired by an image sensor to an application
US11647108B2 (en) Service processing method and apparatus
EP3451193B1 (en) Electronic device and file data journaling method of electronic device
CN112035298A (en) Data backup method and device, electronic equipment and storage medium
WO2023024900A1 (en) Method for secure boot checking and electronic device
CN112148337A (en) Firmware upgrading method and device
TWI521348B (en) Controling system and method for cache coherency
CN115033525B (en) File system management method and electronic equipment
CN107832191B (en) Black screen detection method, mobile terminal and computer readable storage medium
CN107861827B (en) Card screen detection method, mobile terminal and computer readable storage medium
CN107818036B (en) Black screen detection method, mobile terminal and computer readable storage medium
US20200218710A1 (en) Electronic device and data management method thereof
EP4325363A1 (en) Device for managing cache corruption, and operation method thereof
CN115495020A (en) File processing method and device, electronic equipment and readable storage medium
CN112181467B (en) Method and device for upgrading memory firmware of terminal, terminal and storage medium
US11423012B2 (en) Electronic device for prohibiting loss of data in database and method for operating the same
CN114070892A (en) Data transmission method and device
CN117312055B (en) Data backup method and related device
CN111881211B (en) Method, system and equipment for synchronizing storage data and computer storage medium
CN116661678B (en) Data dump method and electronic equipment
CN111949211B (en) Storage device and storage control method
WO2023070462A1 (en) File deduplication method and apparatus, and device
US20240134801A1 (en) Methods and system for efficient access to solid state drive
WO2023001033A1 (en) Method for image startup, method for generating image, and electronic device
EP4357928A1 (en) Methods and system for efficient access to solid state drive

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant