CN110750495A - File management method, file management device, storage medium and terminal - Google Patents

File management method, file management device, storage medium and terminal Download PDF

Info

Publication number
CN110750495A
CN110750495A CN201910971833.5A CN201910971833A CN110750495A CN 110750495 A CN110750495 A CN 110750495A CN 201910971833 A CN201910971833 A CN 201910971833A CN 110750495 A CN110750495 A CN 110750495A
Authority
CN
China
Prior art keywords
file system
area
thread
logic
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.)
Pending
Application number
CN201910971833.5A
Other languages
Chinese (zh)
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.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent Technology 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 Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN201910971833.5A priority Critical patent/CN110750495A/en
Publication of CN110750495A publication Critical patent/CN110750495A/en
Pending legal-status Critical Current

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
    • 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/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a file management method, a file management device, a storage medium and a terminal, and relates to the technical field of data processing. In the embodiment of the application, a recovery thread aiming at a file system is established, and the recovery thread and a log thread corresponding to the file system are asynchronous threads; then scanning the file system through a recovery thread to obtain a logic address corresponding to an invalid logic area in the file system; and finally, determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region, and deleting the file in the region to be recovered. Because the established recovery thread and the log thread corresponding to the file system are asynchronous threads, the recovery thread is no longer associated with the log thread, the execution of the recovery thread is not influenced by the log thread, and the fluency of system calling and upper-layer application is improved.

Description

File management method, file management device, storage medium and terminal
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a file management method, an apparatus, a storage medium, and a terminal.
Background
With the development of science and technology, various terminals become an indispensable part of people's lives, and since there are operations of reading, writing, and deleting a stored file during the use of the terminal, file management becomes one of the key points of research of those skilled in the art.
In the related art, when a file is deleted in a memory with a NAND medium as a core, a log thread is operated to log a transaction, and a recovery instruction is issued after the log recording is completed to instruct to recover a recoverable area in the memory so as to clear an occupied storage area in the memory. However, in the related art, when the log thread issues more recycle instructions in a short time, the system call and the upper layer application may be stuck.
Disclosure of Invention
The application provides a file management method, a file management device, a storage medium and a terminal, which can solve the technical problems that system calling and upper-layer application blocking may be caused when a log thread issues more recovery instructions in a short time in the related art.
In a first aspect, the present application provides a file management method, comprising
Establishing a recovery thread aiming at a file system, wherein the recovery thread and a log thread corresponding to the file system are asynchronous threads;
scanning the file system through the recovery thread to acquire a logic address corresponding to an invalid logic area in the file system;
and determining an area to be recovered in a memory according to the logic address corresponding to the invalid logic area, and deleting the file in the area to be recovered.
Optionally, before the creating a recycle thread for the file system, the method further includes:
receiving a file deleting instruction input aiming at the memory, and acquiring a logic area corresponding to the file deleting instruction in the file system;
and marking a logic area corresponding to the file deleting instruction in the file system as the invalid logic area.
Optionally, the scanning, by the recycle thread, the file system includes:
sequentially scanning the logic area in the file system for multiple rounds through the recovery thread;
acquiring a logic area which is scanned by the recovery thread in the file system and marked as the invalid logic area;
and the maximum number of the invalid logic areas scanned by the recovery thread in each round is a preset number.
Optionally, the method further comprises:
when the number of the invalid logic areas scanned by the recovery thread in each round is equal to the preset number, setting the sleep time of the recovery thread as a first time;
when the recovery thread is interrupted, setting the sleep time of the recovery thread as a second time;
when the number of the invalid logic areas scanned by the recovery thread in each round is smaller than the preset number, setting the sleep time of the recovery thread as a third time;
wherein the first time is less than the second time, which is less than the third time.
Optionally, the method further comprises:
acquiring the proportion of unoccupied logic areas in the file system;
if the proportion is larger than a preset proportion, setting the recovery thread to only scan an invalid logic area larger than a preset data volume in the file system;
and if the proportion is smaller than or equal to a preset proportion, setting the recovery thread to scan all invalid logic areas in the file system, and setting the sleep time of the recovery thread as the first time.
Optionally, the method further comprises:
establishing a mapping relation between a logic area in the file system and a physical area in the memory; wherein the logical area of the file system corresponds to a logical address, and the logical address corresponding to the logical area indicates a physical address of the physical area in the memory.
Optionally, the determining, according to the logic address corresponding to the invalid logic area, an area to be recovered in a memory includes:
acquiring a first logic address matched with a logic address corresponding to the invalid logic area;
determining a first physical address corresponding to the first logical address based on the mapping relation;
and taking the first physical address as a physical address of the area to be recovered, and determining the area to be recovered in the memory according to the physical address.
In a second aspect, an embodiment of the present application provides a file management apparatus, including:
the asynchronous thread establishing module is used for establishing a recovery thread aiming at a file system, and the recovery thread and a log thread corresponding to the file system are asynchronous threads;
a logical address obtaining module, configured to scan the file system through the recovery thread, and obtain a logical address corresponding to an invalid logical area in the file system;
and the deleting module is used for determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region and deleting the file in the region to be recovered.
In a third aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the steps of the above-mentioned method.
In a fourth aspect, embodiments of the present application provide a terminal, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the steps of the method described above.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
in the embodiment of the application, a recovery thread aiming at a file system is established, and the recovery thread and a log thread corresponding to the file system are asynchronous threads; then scanning the file system through a recovery thread to obtain a logic address corresponding to an invalid logic area in the file system; and finally, determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region, and deleting the file in the region to be recovered. Because the established recovery thread and the log thread corresponding to the file system are asynchronous threads, the recovery thread is no longer associated with the log thread, the execution of the recovery thread is not influenced by the log thread, and the fluency of system calling and upper-layer application is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic structural diagram of a file system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a file management method according to an embodiment of the present application;
FIG. 3 is a diagram illustrating a bitmap of a data block of a file system according to an embodiment of the present disclosure;
FIG. 4 is a flowchart illustrating a file management method according to another embodiment of the present application;
FIG. 5 is a schematic diagram illustrating a file delete command according to another embodiment of the present application;
FIG. 6 is a flowchart illustrating a file management method according to another embodiment of the present application;
FIG. 7 is a performance curve of a memory according to another embodiment of the present application;
FIG. 8 is a schematic structural diagram of a file management apparatus according to an embodiment of the present application;
FIG. 9 is a schematic structural diagram of a file management apparatus according to another embodiment of the present application;
fig. 10 is a schematic structural diagram of a terminal according to an embodiment of the present application.
Detailed Description
In order to make the features and advantages of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application, as detailed in the appended claims.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a file system according to an embodiment of the present disclosure.
It is understood that the file management method provided in the embodiment of the present application may be applied to various file systems, for example, the file management method may be applied to a Fourth-generation extended file system (ext 4), and the Memory in the embodiment of the present application may be a Memory with a NAND flash Memory as a core, and the Memory may be an Embedded multimedia Card (eMMC), a UNIX file system (UNIX file system, ufs), a Serial Advanced Technology Attachment (SATA), or a Non-voice format Memory (NVMe) type Memory.
The memory may be a hardware device, the memory stores files (data), the file system may be software or a program, the entity files stored in the memory are presented in the form of data block bitmaps in the file system, and the file system may control the memory to write, read or delete the files stored in the memory. In the above memory, when a file in the memory is deleted, the file system may first notify the memory that the physical storage area corresponding to the deleted file is invalid and can be recovered, and after determining the physical storage area corresponding to the deleted file, the memory may delete the file in the physical storage area, that is, complete the recovery of the physical storage area, so that the physical storage area may store another file again.
In the related art, when ext4 is applied to the above memory, since a log thread exists in ext4, when ext4 controls to delete a file in the memory, the log thread is executed first to log the file system and related operations in the system operation, which is convenient for subsequent system debugging and maintenance. The log thread is associated with the thread in ext4, which is used to notify that the physical storage area corresponding to the deleted file in the memory is invalid and can be recycled, so that the file system executes the log thread every time the deletion operation is executed, and executes the thread which notifies the memory that the physical storage area corresponding to the deleted file in the memory is invalid and can be recycled after the log thread is finished.
If a file is stored in the memory and is distributed among a plurality of data blocks, that is, if the file is severely fragmented, then the file system will execute a large number of log threads in a short time when deleting the file, and then execute a large number of threads in a short time to notify that the physical storage area corresponding to the deleted file in the memory is invalid and can be recycled, and at this time, the system call and the upper-layer application are likely to be blocked due to the large number of threads running. If the thread which informs that the physical storage area corresponding to the deleted file in the memory is invalid and can be recycled in the file system is closed, the memory can recycle the storage area in the memory only when the memory has no available storage area, so that the memory is in a high-load state all the time, and the performance of the memory can be maintained at a lower level and cannot be recovered after falling. In view of the above related technical problems, an embodiment of the present application provides a file management method.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a file management method according to an embodiment of the present disclosure.
As shown in fig. 2, the method steps include:
s202, establishing a recovery thread aiming at the file system, wherein the recovery thread and a log thread corresponding to the file system are asynchronous threads.
Optionally, when the file in the memory needs to be recovered, when the terminal is turned on, or when the terminal leaves the factory, a recovery thread for the file system may be established, where the recovery thread is used to notify one or more areas in the memory that the area is an invalid storage area, and recover the invalid storage area.
Referring to fig. 3, fig. 3 is a schematic diagram of a data block bitmap of a file system according to an embodiment of the present application. As shown in fig. 3, the file system may operate on the file of the memory according to a data block bitmap, where the data block bitmap may be composed of a plurality of data block groups, each of the data block groups may also include a plurality of data blocks, that is, the data block bitmap in the file system may include a plurality of regions. Since the file system is a kind of software, the data block bitmap in the file system is a kind of virtual concept, and thus a plurality of areas included in the data block bitmap may be referred to as logical areas, and have no physical and actual concept. In order to associate the file system with the memory, the data block bitmaps in the file system and the physical storage areas in the memory can be in one-to-one correspondence, so that the corresponding information reading and data operation on the physical storage areas in the memory can be realized by reading and data operation on the information of the data block bitmaps in the file system. It can be understood that the data block bitmap may also be replaced by a general directory and a sub-directory to store the data block group and the data block of the file system, and since the file system is a virtual concept and may have multiple existing representations, the specific representation in the file system is not limited in the embodiments of the present application.
Optionally, when the recycle thread notifies an area in the memory that the area is an invalid storage area, the invalid storage area may be an area corresponding to a file deletion instruction input by a user in the upper application for the memory, and the area may be one or more data blocks or data block groups in a block bitmap specific to the file system. In order to log operations in an upper application or a file system, a preset log thread may be executed to log. The established recovery threads are two different threads relative to the log thread and cannot be executed simultaneously, namely the recovery threads and the log thread are asynchronous threads, so that the recovery threads cannot be associated when the log thread performs log recording, even if the file is seriously fragmented, the file system can execute the log thread for many times in a short time when deleting the file, and because the log threads and the recovery threads are not associated, the recovery threads cannot be executed for many times in a short time, namely the log threads cannot influence the execution of the recovery threads, and the smoothness of system calling and upper-layer application is improved.
Optionally, another service environment may be created in a service environment different from the log thread, and a recovery thread is established in the created service environment, so that the recovery thread is completely independent of the log thread, and fluency of system call and upper-layer application is further improved.
S204, scanning the file system through the recovery thread, and acquiring a logic address corresponding to the invalid logic area in the file system.
Optionally, a user may input a file deletion instruction for the memory in the upper layer application, the file system determines and marks one or more logical areas in the block bitmap in the file system as invalid logical areas according to the file deletion instruction, that is, the invalid logical areas correspond to the physical storage areas in the memory as invalid areas, and may recycle the physical areas in the memory and delete files in the physical areas, so that the memory needs to be notified of the condition that the logical areas in the file system have been marked as invalid logical areas, and the memory can recycle the physical areas and delete files. When a logical area in the file system is marked as an invalid logical area, the logical area is not storing files at the file system level and can be restored and utilized.
Optionally, the established recovery thread may be controlled to scan the file system, specifically, the recovery thread may sequentially scan block bitmaps in the file system, and the sleep time, the interrupt time, or the scan trigger logic of the recovery thread may also be set according to the file storage condition of the file system and the number of invalid logic areas scanned in each round, so as to improve the scanning efficiency of the recovery thread and the processing efficiency of the system.
When the recovery thread scans that invalid logic areas exist in a block bitmap in a file system, the logical address corresponding to each invalid logic area can be obtained, so that the physical storage area corresponding to the logical address in the memory can be obtained according to the logical address subsequently.
S206, determining the area to be recovered in the memory according to the logic address corresponding to the invalid logic area, and deleting the file in the area to be recovered.
Optionally, the data block group or the data block in the block bitmap in the file system represents a logical area in the file system, and a physical storage area for storing a file exists in the memory, so that a relationship may be established between the logical area of the block bitmap in the file system and the physical area in the memory, so as to determine, according to the relationship and the address of the scanned invalid logical area, a physical storage area corresponding to the invalid logical area in the memory, where the physical area is an area to be recovered in the memory, that is, the area to be recovered is determined according to the address of the invalid logical area, and delete the file in the area to be recovered, thereby completing the recovery of the physical storage area in the memory.
In the embodiment of the application, a recovery thread aiming at a file system is established, and the recovery thread and a log thread corresponding to the file system are asynchronous threads; then scanning the file system through a recovery thread to obtain a logic address corresponding to an invalid logic area in the file system; and finally, determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region, and deleting the file in the region to be recovered. Because the established recovery thread and the log thread corresponding to the file system are asynchronous threads, the recovery thread is no longer associated with the log thread, the execution of the recovery thread is not influenced by the log thread, and the fluency of system calling and upper-layer application is improved.
Referring to fig. 4, fig. 4 is a schematic flowchart illustrating a file management method according to another embodiment of the present application.
As shown in fig. 4, the method steps include:
s402, receiving a file deleting instruction input aiming at the memory, and acquiring a logic area corresponding to the file deleting instruction in the file system.
Optionally, a user can implement operations such as writing, reading, and deleting a file stored in the memory through an upper application set in the terminal, the upper application may be various application programs for obtaining file management permissions, and the user can implement a virtual deletion operation on the file in the application layer by operating options in the application program, where the virtual deletion operation is used for clicking or selecting the file to perform a deletion operation after the file in the memory is displayed in the application program, and is equivalent to that the user inputs a file deletion instruction for the memory.
Referring to fig. 5, fig. 5 is a schematic diagram illustrating a file deletion instruction according to another embodiment of the present application. As shown in fig. 5, fig. 5 is a display interface of a terminal, where the display interface is an operation interface of an album application, and a user may click a picture to select a delete option for the picture, so as to delete the picture stored in a memory, that is, generate a file delete instruction for the memory.
Optionally, the processor in the terminal receives the file deletion instruction, and at this time, the processor does not delete the file in the memory directly according to the file deletion instruction, but sends the file deletion instruction to the file system, and the file system may determine, according to the file deletion instruction, a logical area corresponding to the file deletion instruction in a block bitmap in the file system.
S404, marking the logic area corresponding to the file deleting instruction in the file system as an invalid logic area.
Alternatively, when the file system determines the logical area corresponding to the file deletion instruction, the file system may mark the logical area in the block bitmap as an invalid logical area, when the logical area in the block bitmap is marked as an invalid logical area, the logical area is invalid and is not available until the logical area is not recycled, and when the logical area in the block bitmap is marked as an invalid logical area, the invalid logical area in the block bitmap in the file system is also invalid in the corresponding physical storage area in the memory, the physical storage area is recyclable, and the file in the physical area may be deleted, so that after the physical storage area is recycled, other files may be stored.
S406, establishing a recovery thread aiming at the file system, wherein the recovery thread and the log thread corresponding to the file system are asynchronous threads.
For the detailed description of the step S406, please refer to the detailed description of the step S202 in the above embodiment, which is not repeated herein.
And S408, sequentially scanning the logic areas in the file system for multiple rounds through the recovery thread.
Optionally, the established recycle thread may be controlled to scan the file system, and specifically, the recycle thread may sequentially perform multiple rounds of scanning on logical areas in the block bitmap in the file system. When the file system is scanned, only a logic area with a preset storage size can be scanned in each round according to a block bitmap in the file system, for example, a recovery thread can only scan one data block group in the block bitmap in the file system in each round, and because the block bitmap comprises a plurality of data block groups, when the recovery thread scans the file system, multiple rounds of scanning can be performed, and then one complete scanning of the whole file system can be completed. The method has the advantages that on one hand, more invalid logic areas can be prevented from being scanned in a short time, data congestion is avoided, and the stability of the system is improved; on the other hand, invalid logic areas in each data block group of the block bitmap in the file system can be scanned relatively evenly, repeated scanning of only one data block group in the block bitmap is avoided, repeated recovery of a physical storage area in the memory is avoided, and the service life of the memory is prolonged.
S410, acquiring the logic area which is scanned by the recovery thread in the file system and marked as the invalid logic area.
Optionally, after the file system determines the logical area corresponding to the file deletion instruction, the file system may mark the logical area in the block bitmap as an invalid logical area, so that the marked invalid logical area in the block bitmap in the file system may be scanned by the recycle thread. In order to further improve the stability of the system, the maximum number of the invalid logic regions scanned by the recovery thread in each round may be set to be a preset number, for example, the preset number may be 8, so that the number of the invalid logic regions scanned by the recovery thread in each round is recorded, and when the number of the invalid logic regions scanned by the round reaches the preset number of 8, the scanning of the round is stopped. The method has the advantages that the maximum value of the invalid logic areas scanned by each round of the recovery thread is set, so that the situation that when the fragmentation of the file is serious, more invalid logic areas are not scanned in a short time can be avoided, the sudden increase of the workload of the memory in a short time can not be caused, the execution efficiency of other memories on other files is not influenced, and the use efficiency of the memory is favorably improved.
Optionally, after each round of scanning of the recovery thread is completed, sleep time before the next round of scanning is started can be set, and the purpose of setting the sleep time is to provide enough time for the memory to recover the physical storage area and improve the utilization rate of the performance of the memory; on the other hand, the utilization rate of the processor can be improved, and the condition that the processor is under high load or low load for a long time is avoided.
Optionally, when the number of invalid logic regions scanned by the recovery thread in each round is equal to the preset number, it is stated that more logic regions in the file system are marked as invalid logic regions, the invalid logic regions need to be processed in time, and it is also necessary to notify the memory to recover the physical regions in time, so that the storage space in the memory is released conveniently, then the sleep time of the recovery thread may be set as the first time, for example, the first time may be set to 50 milliseconds.
Alternatively, the eviction thread may be interrupted or interrupted by other data input, output, or interrupt, when the eviction thread is interrupted, which indicates that the processor needs to process more important data or tasks, the scan of the eviction thread may be suspended, the sleep time may be entered, and the sleep time of the eviction thread may be set to the second time, for example, the second time may be set to 500 milliseconds.
Optionally, when the number of invalid logical areas scanned by the recycling thread in each round is less than the preset number, at this time, it is described that the logical area with less block bitmaps in the file system is marked as an invalid logical area, then more idle logical areas also exist in the file system, and more idle physical areas also exist in the memory, at this time, a longer sleep time of the recycling thread may be set, and then the sleep time of the recycling thread may be set to a third time, for example, the third time may be set to 60 seconds.
It can be understood that the sleep time under different conditions of the thread recovery can be set according to actual conditions, and the sleep time can satisfy that the first time is less than the second time, and the second time is less than the third time, so as to improve the utilization rate of the processor and the memory.
Optionally, the scan option and the sleep time of the recycling thread may also be set according to the specific occupation condition of the block bitmap in the file system. Specifically, the proportion of the unoccupied logical areas in the file system may be obtained, and since the occupied logical areas are included in the file system, files are stored in the memory corresponding to the occupied logical areas, and the unoccupied logical areas are also included in the file system, and files are not stored in the memory corresponding to the unoccupied logical areas. Therefore, if the proportion of the unoccupied logical areas in the file system is greater than the preset proportion, for example, the preset proportion may be twenty percent, it is indicated that more free storage space still exists in the memory, and the invalid logical areas in the file system may be more continuous data block groups with a larger data amount or discontinuous data blocks with a smaller data amount, at this time, the recovery thread may be set to scan only the invalid logical areas greater than the preset data amount in the file system, so that the invalid logical areas obtained by the recovery thread are all continuous and large invalid logical areas, on one hand, the scanning efficiency of the recovery thread may be improved, on the other hand, the memory may also be convenient to recover the physical storage areas, so that the memory may quickly climb to a near-clean state performance after the performance falls.
Optionally, if the ratio is smaller than or equal to the preset ratio, it is indicated that the free storage space in the memory is small, and at this time, it is required that all the invalid logic areas in the file system trigger scanning of the recycling thread, and the recycling thread may be set to scan all the invalid logic areas in the file system, and set the sleep time of the recycling thread to be the first time. Because all invalid logic areas in the file system trigger the scanning of the recovery thread, and the sleep time of the first time is short, after the recovery thread executes one round of scanning, the other round of scanning can be quickly carried out, so that the storage area in the memory can be quickly recovered, and more storage space is released.
S412, acquiring a logic address corresponding to the invalid logic area in the file system.
And S414, determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region, and deleting the file in the region to be recovered.
For the detailed description of the steps S412 and S414, please refer to the detailed description of the steps S204 and S206 in the above embodiments, which is not repeated herein.
In the embodiment of the application, a recovery thread can be set to sequentially perform multiple scanning rounds on a logic area in a block bitmap in a file system, and after each scanning round of the recovery thread is completed, sleep time before the next scanning round is started can be set; on the other hand, the utilization rate of the processor can be improved, and the condition that the processor is under high load or low load for a long time is avoided.
Referring to fig. 6, fig. 6 is a flowchart illustrating a file management method according to another embodiment of the present application.
As shown in fig. 6, the method steps include:
s602, establishing a mapping relation between a logic area in the file system and a physical area in the memory.
Optionally, a logical address corresponds to a logical area of the file system, a physical area in the memory also has a physical address, and the logical address of the logical area in the file system and the physical address of the physical area in the memory are in one-to-one correspondence and a mapping relationship is established, so that the logical address corresponding to the logical area indicates the physical address of the physical area in the memory.
S604, establishing a recovery thread aiming at the file system, wherein the recovery thread and a log thread corresponding to the file system are asynchronous threads.
S606, scanning the file system through the recovery thread, and acquiring a logic address corresponding to the invalid logic area in the file system.
For the detailed description of the steps S604 and S606, please refer to the detailed description of the steps S202 and S204 in the above embodiments, which is not repeated herein.
S608, acquiring a first logic address matched with the logic address corresponding to the invalid logic area.
S610, determining a first physical address corresponding to the first logical address based on the mapping relation.
And S612, taking the first physical address as a physical address of the area to be recovered, and determining the area to be recovered in the memory according to the physical address.
Because the logical address of the logical area in the file system and the physical address of the physical area in the memory are in one-to-one correspondence and have a mapping relationship, the area to be recovered in the memory can be determined according to the mapping relationship and the logical address corresponding to the invalid logical area.
And S614, deleting the files in the area to be recovered.
In the embodiment of the application, the logical addresses of the logical areas in the file system are in one-to-one correspondence with the physical addresses of the physical areas in the memory, and a mapping relation is established, so that the logical addresses corresponding to the logical areas indicate the physical addresses of the physical areas in the memory, and the speed and the efficiency of determining the areas to be recovered in the memory according to the logical addresses corresponding to the invalid logical areas are improved.
Referring to fig. 7, fig. 7 is a performance curve of a memory according to another embodiment of the present application.
In the embodiment of the application, a recovery thread aiming at a file system is established, and the recovery thread and a log thread corresponding to the file system are asynchronous threads; then scanning the file system through a recovery thread to obtain a logic address corresponding to an invalid logic area in the file system; and finally, determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region, and deleting the file in the region to be recovered.
Because the established recovery thread and the log thread corresponding to the file system are asynchronous threads, the recovery thread is no longer associated with the log thread, the execution of the recovery thread is not influenced by the log thread, and the fluency of system calling and upper-layer application is improved. As shown in fig. 7, compared with the related art, in the embodiment of the present application, on the premise of considering that the performance of devices of various manufacturers is not dropped, the problems of blocking and/or screen fixing caused in the fragmentation scene of the file system are solved, the stability of the system is improved, and the performance of the memory is improved when the performance of the memory is dropped and the climbing is restored to a state close to the cleanness.
Referring to fig. 8, fig. 8 is a schematic structural diagram of a file management device according to an embodiment of the present application.
As shown in fig. 8, the file management apparatus 800 includes:
the asynchronous thread establishing module 810 is configured to establish a recovery thread for the file system, where the recovery thread and the log thread corresponding to the file system are asynchronous threads.
The logical address obtaining module 820 is configured to scan the file system through the recycling thread, and obtain a logical address corresponding to an invalid logical area in the file system.
And a deleting module 830, configured to determine, according to the logical address corresponding to the invalid logical area, an area to be recovered in the memory, and delete the file in the area to be recovered.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a file management device according to another embodiment of the present application.
As shown in fig. 9, the file management apparatus 900 includes:
the instruction receiving module 910 is configured to receive a file deletion instruction input for the memory, and acquire a logic area corresponding to the file deletion instruction in the file system.
The marking module 920 is configured to mark a logic area corresponding to a file deletion instruction in the file system as an invalid logic area.
The asynchronous thread establishing module 930 is configured to establish a recovery thread for the file system, where the recovery thread and the log thread corresponding to the file system are asynchronous threads.
And a scanning module 940, configured to perform multiple scanning rounds on the logical areas in the file system sequentially through the recycling thread.
The region acquiring module 950 is configured to acquire a logical region scanned by the recycle thread in the file system and marked as an invalid logical region. The maximum number of invalid logic areas scanned by each round of the recovery thread is a preset number.
When the number of invalid logic areas scanned by each round of the recovery thread is equal to the preset number, setting the sleep time of the recovery thread as a first time; when the recovery thread is interrupted, setting the sleep time of the recovery thread as a second time; when the number of invalid logic areas scanned by each round of the recovery thread is smaller than the preset number, setting the sleep time of the recovery thread as a third time; wherein the first time is less than the second time, and the second time is less than the third time.
Optionally, acquiring the proportion of an unoccupied logic region in the file system; if the proportion is larger than the preset proportion, setting a recovery thread to only scan an invalid logic area larger than the preset data volume in the file system; and if the proportion is smaller than or equal to the preset proportion, setting the recovery thread to scan all invalid logic areas in the file system, and setting the sleep time of the recovery thread as the first time.
A mapping module 960, configured to establish a mapping relationship between a logical area in the file system and a physical area in the memory; the logical area of the file system corresponds to a logical address, and the logical address corresponding to the logical area indicates a physical address of the physical area in the memory.
The first logical address obtaining module 970 is configured to obtain a first logical address matching the logical address corresponding to the invalid logical area.
A first physical address obtaining module 980 is configured to determine, based on the mapping relationship, a first physical address corresponding to the first logical address.
The area determining module 990 is configured to use the first physical address as a physical address of the area to be recycled, and determine the area to be recycled in the memory according to the physical address.
A deleting module 9100 for deleting the files in the to-be-recovered area
In an embodiment of the present application, a file management apparatus includes: the asynchronous thread establishing module is used for establishing a recovery thread aiming at the file system, and the recovery thread and a log thread corresponding to the file system are asynchronous threads; the logic address acquisition module is used for scanning the file system through the recovery thread and acquiring a logic address corresponding to an invalid logic area in the file system; and the deleting module is used for determining the area to be recovered in the memory according to the logic address corresponding to the invalid logic area and deleting the file in the area to be recovered. Because the established recovery thread and the log thread corresponding to the file system are asynchronous threads, the recovery thread is no longer associated with the log thread, the execution of the recovery thread is not influenced by the log thread, and the fluency of system calling and upper-layer application is improved.
Embodiments of the present application also provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the steps of the method according to any of the above embodiments.
Referring to fig. 10, fig. 10 is a schematic structural diagram of a terminal according to an embodiment of the present application. As shown in fig. 10, terminal 1000 can include: at least one processor 1001, at least one network interface 1004, a user interface 1003, memory 1005, at least one communication bus 1002.
Wherein a communication bus 1002 is used to enable connective communication between these components.
The user interface 1003 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 1001 may include one or more processing cores, among other things. Processor 1001 interfaces various parts throughout terminal 1000 using various interfaces and lines, and performs various functions of terminal 1000 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in memory 1005, and calling data stored in memory 1005. Alternatively, the processor 1001 may be implemented in at least one hardware form of Digital Signal Processing (DSP), Field-Programmable gate Array (FPGA), and Programmable Logic Array (PLA). The processor 1001 may integrate one or a combination of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 1001, but may be implemented by a single chip.
The Memory 1005 may include a Random Access Memory (RAM) or a Read-only Memory (ROM). Optionally, the memory 1005 includes a non-transitory computer-readable medium. The memory 1005 may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory 1005 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. As shown in fig. 10, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a file management instruction.
In the terminal 1000 shown in fig. 10, the user interface 1003 is mainly used as an interface for providing input for a user, and acquiring data input by the user; and the processor 1001 may be configured to call the file management instruction stored in the memory 1005, and specifically perform the following operations:
establishing a recovery thread aiming at the file system, wherein the recovery thread and a log thread corresponding to the file system are asynchronous threads;
scanning a file system through a recovery thread to obtain a logic address corresponding to an invalid logic area in the file system;
and determining an area to be recovered in the memory according to the logic address corresponding to the invalid logic area, and deleting the file in the area to be recovered.
Optionally, before executing the set-up recycle thread for the file system, the processor 1001 is further configured to:
receiving a file deleting instruction input aiming at a memory, and acquiring a logic area corresponding to the file deleting instruction in a file system;
and marking the logic area corresponding to the file deleting instruction in the file system as an invalid logic area.
Optionally, when the processor 1001 performs scanning the file system through the recycle thread, the following operations are further specifically performed:
sequentially scanning the logic area in the file system for multiple rounds through a recovery thread;
acquiring a logic area which is scanned by a recovery thread in a file system and marked as an invalid logic area;
the maximum number of invalid logic areas scanned by each round of the recovery thread is a preset number.
Optionally, the processor 1001 is further configured to execute, when the number of invalid logic regions scanned by the recovery thread in each round is equal to a preset number, setting the sleep time of the recovery thread as a first time; when the recovery thread is interrupted, setting the sleep time of the recovery thread as a second time; when the number of invalid logic areas scanned by each round of the recovery thread is smaller than the preset number, setting the sleep time of the recovery thread as a third time; wherein the first time is less than the second time, and the second time is less than the third time.
Optionally, the processor 1001 is further configured to execute, obtain a proportion of an unoccupied logical area in the file system; if the proportion is larger than the preset proportion, setting a recovery thread to only scan an invalid logic area larger than the preset data volume in the file system; and if the proportion is smaller than or equal to the preset proportion, setting the recovery thread to scan all invalid logic areas in the file system, and setting the sleep time of the recovery thread as the first time.
Optionally, the processor 1001 is further configured to perform mapping between a logical area in the file system and a physical area in the memory; the logical area of the file system corresponds to a logical address, and the logical address corresponding to the logical area indicates a physical address of the physical area in the memory.
Optionally, when the processor 1001 determines, according to the logic address corresponding to the invalid logic area, the area to be recovered in the memory, the following steps are further specifically performed:
acquiring a first logic address matched with a logic address corresponding to the invalid logic area;
determining a first physical address corresponding to the first logical address based on the mapping relation;
and taking the first physical address as a physical address of the area to be recovered, and determining the area to be recovered in the memory according to the physical address.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of modules is merely a division of logical functions, and an actual implementation may have another division, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
Modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art will also appreciate that the acts and modules illustrated in the description are not necessarily required in all implementations of the application.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In view of the above description of the file management method, apparatus, storage medium and terminal provided in the embodiments of the present application, those skilled in the art will recognize that there are variations in the embodiments and applications of the method and apparatus provided in the embodiments of the present application.

Claims (10)

1. A file management method, characterized in that the method comprises
Establishing a recovery thread aiming at a file system, wherein the recovery thread and a log thread corresponding to the file system are asynchronous threads;
scanning the file system through the recovery thread to acquire a logic address corresponding to an invalid logic area in the file system;
and determining an area to be recovered in a memory according to the logic address corresponding to the invalid logic area, and deleting the file in the area to be recovered.
2. The method of claim 1, wherein before establishing the recycle thread for the file system, further comprising:
receiving a file deleting instruction input aiming at the memory, and acquiring a logic area corresponding to the file deleting instruction in the file system;
and marking a logic area corresponding to the file deleting instruction in the file system as the invalid logic area.
3. The method of claim 2, wherein scanning the file system via the recycle thread comprises:
sequentially scanning the logic area in the file system for multiple rounds through the recovery thread;
acquiring a logic area which is scanned by the recovery thread in the file system and marked as the invalid logic area;
and the maximum number of the invalid logic areas scanned by the recovery thread in each round is a preset number.
4. The method of claim 3, further comprising:
when the number of the invalid logic areas scanned by the recovery thread in each round is equal to the preset number, setting the sleep time of the recovery thread as a first time;
when the recovery thread is interrupted, setting the sleep time of the recovery thread as a second time;
when the number of the invalid logic areas scanned by the recovery thread in each round is smaller than the preset number, setting the sleep time of the recovery thread as a third time;
wherein the first time is less than the second time, which is less than the third time.
5. The method of claim 4, further comprising:
acquiring the proportion of unoccupied logic areas in the file system;
if the proportion is larger than a preset proportion, setting the recovery thread to only scan an invalid logic area larger than a preset data volume in the file system;
and if the proportion is smaller than or equal to a preset proportion, setting the recovery thread to scan all invalid logic areas in the file system, and setting the sleep time of the recovery thread as the first time.
6. The method of claim 1, further comprising:
establishing a mapping relation between a logic area in the file system and a physical area in the memory; wherein the logical area of the file system corresponds to a logical address, and the logical address corresponding to the logical area indicates a physical address of the physical area in the memory.
7. The method according to claim 6, wherein the determining the area to be recycled in the memory according to the logical address corresponding to the invalid logical area comprises:
acquiring a first logic address matched with a logic address corresponding to the invalid logic area;
determining a first physical address corresponding to the first logical address based on the mapping relation;
and taking the first physical address as a physical address of the area to be recovered, and determining the area to be recovered in the memory according to the physical address.
8. A file management apparatus, characterized in that the apparatus comprises:
the asynchronous thread establishing module is used for establishing a recovery thread aiming at a file system, and the recovery thread and a log thread corresponding to the file system are asynchronous threads;
a logical address obtaining module, configured to scan the file system through the recovery thread, and obtain a logical address corresponding to an invalid logical area in the file system;
and the deleting module is used for determining a region to be recovered in the memory according to the logic address corresponding to the invalid logic region and deleting the file in the region to be recovered.
9. A computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the steps of the method according to any of claims 1 to 7.
10. A terminal comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor when executing the program implementing the steps of the method according to any of claims 1 to 7.
CN201910971833.5A 2019-10-14 2019-10-14 File management method, file management device, storage medium and terminal Pending CN110750495A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910971833.5A CN110750495A (en) 2019-10-14 2019-10-14 File management method, file management device, storage medium and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910971833.5A CN110750495A (en) 2019-10-14 2019-10-14 File management method, file management device, storage medium and terminal

Publications (1)

Publication Number Publication Date
CN110750495A true CN110750495A (en) 2020-02-04

Family

ID=69278232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910971833.5A Pending CN110750495A (en) 2019-10-14 2019-10-14 File management method, file management device, storage medium and terminal

Country Status (1)

Country Link
CN (1) CN110750495A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111597147A (en) * 2020-04-30 2020-08-28 星辰天合(北京)数据科技有限公司 Space recovery method, device, storage medium and processor

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101501623A (en) * 2006-05-03 2009-08-05 数据机器人技术公司 Filesystem-aware block storage system, apparatus, and method
CN103019971A (en) * 2012-11-25 2013-04-03 向志华 Method of quickly responding to trim command, SSD (Solid State Disk) controller and system
CN104615652A (en) * 2014-12-29 2015-05-13 曙光云计算技术有限公司 Organization method for auxiliary records
CN105868122A (en) * 2016-03-28 2016-08-17 深圳市硅格半导体股份有限公司 Data processing method and device for quick flashing storage equipment
CN109739775A (en) * 2018-11-20 2019-05-10 北京航空航天大学 The flash translation layer (FTL) composting recovery method locked based on the multistage

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101501623A (en) * 2006-05-03 2009-08-05 数据机器人技术公司 Filesystem-aware block storage system, apparatus, and method
CN103019971A (en) * 2012-11-25 2013-04-03 向志华 Method of quickly responding to trim command, SSD (Solid State Disk) controller and system
CN104615652A (en) * 2014-12-29 2015-05-13 曙光云计算技术有限公司 Organization method for auxiliary records
CN105868122A (en) * 2016-03-28 2016-08-17 深圳市硅格半导体股份有限公司 Data processing method and device for quick flashing storage equipment
CN109739775A (en) * 2018-11-20 2019-05-10 北京航空航天大学 The flash translation layer (FTL) composting recovery method locked based on the multistage

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111597147A (en) * 2020-04-30 2020-08-28 星辰天合(北京)数据科技有限公司 Space recovery method, device, storage medium and processor
CN111597147B (en) * 2020-04-30 2021-12-17 星辰天合(北京)数据科技有限公司 Space recovery method, device, storage medium and processor

Similar Documents

Publication Publication Date Title
WO2021072716A1 (en) Memory management method and apparatus, electronic device and computer-readable medium
EP3404538B1 (en) Data processing method, and data processing apparatus
CN110895492B (en) Device control method, device, storage medium and electronic device
CN107071284A (en) A kind of photographic method and terminal
CN106156346A (en) The automatic classification method of icon and device
US20210232275A1 (en) Method for Displaying View and Terminal Device
CN115951839A (en) Data writing method and device for partition name space solid state disk and electronic equipment
CN105512033A (en) Automated testing method and device of mobile terminal and mobile terminal
CN113837939A (en) Image processing method and device
CN103677893B (en) Method for reducing size of image file of starting up and arithmetic device
CN110750495A (en) File management method, file management device, storage medium and terminal
CN114968839A (en) Hard disk garbage recycling method, device and equipment and computer readable storage medium
CN1251541C (en) Method for shortening booting time of digital equipment having flash memory
CN106776908A (en) Data clearing method, device and terminal
CN112306368B (en) Method and device for expanding user data partition by EMMC (enhanced multi-media card)
CN112486966A (en) Expired data cleaning method and device and electronic equipment
CN108804258B (en) Data recovery method and device, mobile terminal and storage medium
CN109522174B (en) Method, device, terminal and storage medium for controlling adb enabling
CN111158595A (en) Enterprise-level heterogeneous storage resource scheduling method and system
CN115454617A (en) Processor performance adjusting method and device, electronic equipment and storage medium
CN115543859A (en) Wear leveling optimization method, device, equipment and medium for multi-partition SSD
CN113849195A (en) Application program loading method and device, storage medium and terminal
CN114020208A (en) Data garbage recovery method and device, computer equipment and storage medium
CN111562983A (en) Memory optimization method and device, electronic equipment and storage medium
CN108762985B (en) Data recovery method and related product

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200204