CN113961517A - File system management method, electronic device and storage medium - Google Patents

File system management method, electronic device and storage medium Download PDF

Info

Publication number
CN113961517A
CN113961517A CN202010707628.0A CN202010707628A CN113961517A CN 113961517 A CN113961517 A CN 113961517A CN 202010707628 A CN202010707628 A CN 202010707628A CN 113961517 A CN113961517 A CN 113961517A
Authority
CN
China
Prior art keywords
defragmentation
fragmentation
degree
mode
file system
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
CN202010707628.0A
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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN202010707628.0A priority Critical patent/CN113961517A/en
Priority to PCT/CN2021/103843 priority patent/WO2022017148A1/en
Publication of CN113961517A publication Critical patent/CN113961517A/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/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • 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
    • 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/18File system types
    • 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/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

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 relates to the technical field of computers, and particularly discloses a file system management method, electronic equipment and a storage medium. The method comprises the following steps: acquiring fragmentation state information of a file system, and determining a defragmentation mode according to the fragmentation state information; and controlling the file system to perform defragmentation operation according to the defragmentation mode, wherein the defragmentation mode corresponds to a preset defragmentation intensity. The problem of inefficiency among the prior art of arranging can be solved to this application embodiment.

Description

File system management method, electronic device and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a file system management method, an electronic device, and a storage medium.
Background
F2FS (Flash Friendly File System) is a Flash-Friendly File System, F2FS is rapidly developing and has already reached a substantially mature stage, and currently mainstream manufacturers replace the F2FS File System with a Fourth-generation extended File System (EXT 4). In the using process of the electronic equipment, operations such as saving, updating and deleting files can cause gradual fragmentation of the storage module, and the storage performance is reduced due to excessive fragmentation, so that the user experience is reduced. The F2FS file system provides a defragmentation mechanism based on a garbage collection mechanism, which is mainly used to reduce the fragmentation in the file system and prevent the problem of reduced access speed. The existing fragment finishing machine has certain blindness, low efficiency and can not achieve good effect.
Disclosure of Invention
The application provides a file system management method, electronic equipment and a storage medium, which can solve the problem of low efficiency in the prior arrangement technology.
In a first aspect, the present application provides a file system management method, including: acquiring fragmentation state information of a file system, and determining a defragmentation mode according to the fragmentation state information; and controlling the file system to perform defragmentation operation according to the defragmentation mode, wherein the defragmentation mode corresponds to a preset defragmentation intensity.
In a second aspect, the present application further provides an electronic device comprising a memory and a processor; the memory is used for storing a computer program; the processor is configured to execute the computer program and to implement the file system management method when executing the computer program.
In a third aspect, the present application further provides a computer-readable storage medium storing a computer program, which when executed by a processor causes the processor to implement the file system management method as described above.
The application discloses a file system management method, an electronic device and a storage medium, wherein the method comprises the following steps: acquiring fragmentation state information of a file system, and determining a defragmentation mode according to the fragmentation state information; and controlling the file system to perform defragmentation operation according to the defragmentation mode, wherein the defragmentation mode corresponds to a preset defragmentation intensity. The file system management provided by the embodiment of the application can determine the state of file fragments in the storage module according to the fragmentation state information through the acquired fragmentation state information of the file system, and further can determine a suitable defragmentation mode, the different defragmentation strengths corresponding to different defragmentation modes control the file system to perform defragmentation operation according to the defragmentation strength, the file fragments can be accurately and reasonably sorted, the user experience is improved while the performance of the electronic equipment is optimized, and the problem of low efficiency in the existing sorting technology can be solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic flow chart diagram of a file system management method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram of another file system management method provided by an embodiment of the present application;
fig. 3 is a block diagram schematically illustrating a structure of an electronic device according to an embodiment of the present application.
Detailed Description
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 obvious that the described embodiments are some, but not all, embodiments of the present application. 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.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be decomposed, combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It is to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
The embodiment of the application provides a file system management method, electronic equipment and a storage medium. Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a schematic flowchart of a file system management method according to an embodiment of the present disclosure, and as shown in fig. 1, the file system management method may include steps S101 to S102.
Step S101, obtaining fragmentation state information of a file system, and determining a defragmentation mode according to the fragmentation state information.
The method of the embodiment of the application can be applied to electronic equipment, the electronic equipment can be a terminal with an operating system, and the electronic equipment can be a mobile phone, a tablet computer, a computer or the like.
The file system runs in an operating system of the electronic device, and the file system is used for managing files in a storage module in the electronic device. The file in the storage module also has a corresponding address in the file system, and the address in the file system and the address in the storage module have a mapping relation.
The file system also provides an external interface, and a user can operate the file system through the external interface and further operate the files in the storage module according to the mapping relation. Illustratively, the storage address of the entity file of the file a in the storage module is "address a", the storage address of the file a in the file system is "address b", the user can find the file a at "address b" of the file system, and when the user operates on the file a, the file system can find the entity file of the file a at "address a" in the storage module according to the mapping relationship and perform corresponding operation on the entity file. For example, the storage module may be an Embedded multimedia memory Card (eMMC), and the File System may be an F2FS (Flash Friendly File System) File System.
For example, when a user uses the electronic device to store a picture on the electronic device from a network, the picture needs to be written into the storage module, and a file system of the picture is also added correspondingly. And the operations of reading, writing, deleting, saving and the like are carried out on the files in the storage module, the operations can lead the storage module to be gradually fragmented, file fragments can be generated, and if the file fragments are accumulated more, the performance of the electronic equipment can be influenced.
The file system has corresponding records for the generated file fragments, the fragmentation status information may include record information about the file fragments in the file system, and the fragmentation status in the storage module may be known according to the fragmentation status information. In an embodiment, the fragmentation status information may include a fragmentation degree parameter.
After the fragmentation state information of the file system is determined, the fragmentation state in the file system can be known according to the fragmentation state information, and different fragmentation states correspond to different defragmentation requirements. A plurality of defragmentation modes can be preset according to different defragmentation requirements, and after the defragmentation state information of the file system is acquired, the corresponding defragmentation mode can be determined according to the defragmentation state information.
In an embodiment, fragmentation status information corresponding to each defragmentation mode may be predetermined, and after the fragmentation status information of the file system is obtained, the corresponding defragmentation mode may be determined.
And S102, controlling the file system to perform defragmentation operation according to the defragmentation mode, wherein the defragmentation mode corresponds to a preset defragmentation intensity.
The file system may perform defragmentation operation, and the defragmentation operation may be an operation of defragmenting file defragmentation in the storage module. The file system prestores a function for sorting file fragments in the storage module, and defragmentation operation can be realized by triggering the sorting function.
The defragmentation intensity may be an ability of a workload of the defragmentation operation that can be completed within a preset time period, a higher defragmentation intensity indicates that more defragmentations can be completed within the preset time period, and a lower defragmentation intensity indicates that less defragmentations are completed within the preset time period. The defragmentation modes correspond to a predetermined defragmentation intensity, and the different defragmentation modes correspond to different predetermined defragmentation intensities, including a stronger defragmentation intensity and also a weaker defragmentation intensity. And controlling the file system to perform defragmentation operation according to the defragmentation mode to realize the defragmentation effect of the corresponding defragmentation strength, thereby meeting the corresponding defragmentation requirement. In an embodiment, after the corresponding defragmentation mode is automatically determined according to the defragmentation status information, the corresponding parameters may be set to perform defragmentation operations with corresponding strengths.
Illustratively, the F2FS file system includes an F2fs _ gc function, and the defragmentation operation can be realized by triggering the F2fs _ gc function. Different defragmentation modes correspond to different trigger parameters of the f2fs _ gc function, and the f2fs _ gc function is triggered according to the corresponding trigger parameters, so that the defragmentation effect of the corresponding defragmentation intensity can be realized.
In one embodiment, the defragmentation intensity may include a defragmentation frequency and a defragmentation amount. When the file system performs the defragmentation operation, at least one defragmentation operation may be performed, and each defragmentation operation may be to defragment at least one data segment (segment). The defragmentation number may comprise the number of data segments corresponding to each defragmentation operation and the defragmentation frequency may be the time interval between two adjacent defragmentation operations, e.g. may be the time interval between two triggers of the f2fs _ gc function.
The data segments (segments) are distribution basic storage units of the file system, and one data segment (segment) is composed of a plurality of storage blocks (blocks). The size of the data segment (segment) can be configured according to requirements, and for example, can be set to 2 megabits (M), that is, one data segment (segment) includes 512 memory blocks (blocks).
Different defragmentation strengths can be achieved by setting different defragmentation frequencies and/or amounts. For example, the higher the frequency of finishing, the higher the intensity of defragmentation, the higher the number of finishes, and the higher the intensity of defragmentation.
In one embodiment, the operation of determining the defragmentation mode based on the defragmentation status information may be performed by:
determining the fragmentation degree according to the fragmentation state information; and determining a corresponding defragmentation mode according to the defragmentation degree, wherein the higher the defragmentation degree is, the higher the defragmentation intensity is.
The higher the fragmentation degree is, the more the file fragments in the storage area are, and the more the file fragments are, the more the performance of the electronic device is affected. The higher fragmentation degree corresponds to the requirement of higher defragmentation strength, so that the file fragments in the storage area can be defragmented more quickly, and the performance of the electronic device can be recovered as soon as possible.
Therefore, the fragmentation degree of the file system can be determined according to the fragmentation state information, the requirements for the high and low fragmentation intensity are determined according to the fragmentation degree, and then the fragmentation mode corresponding to the fragmentation intensity can be determined.
In an embodiment, the fragmentation status information may include a fragmentation degree parameter, where the fragmentation degree parameter is a parameter for representing a fragmentation degree in the file system, and the fragmentation degree may be determined according to a numerical size of the fragmentation degree parameter. In one embodiment, a lower value of the fragmentation degree parameter indicates a higher fragmentation degree, and the fragmentation degree can be determined according to the higher or lower value of the fragmentation degree parameter. The BDF parameter in the F2FS file system is a parameter reflecting the distribution of F2FS segment data, and generally, the lower the BDF, the higher the fragmentation degree, but not an absolute linear relationship. The BDF parameter may reflect a parameter of the distribution condition of the F2FS segment data, and in general, the lower the BDF is, the higher the fragmentation degree is, and the fragmentation degree may be determined according to the BDF value.
In one embodiment, after controlling the file system to perform the defragmentation operation according to the defragmentation mode, the method further includes the following operations: and continuously monitoring the fragmentation degree, and adjusting the defragmentation mode according to the change of the fragmentation degree. Wherein, along with the execution of defragmentation operation, the fragmentation degree can change, if the fragmentation degree has reduced, can correspond the adjustment defragmentation mode. In other embodiments, the intelligent sorting described above may also be stopped when the degree of fragmentation decreases to a preset condition.
In one embodiment, the fragmentation status information may include a fragmentation degree parameter, a triggering degree, and a number of data segments, wherein the triggering degree may include a degree to which free space reclamation is triggered in the second time period, and the number of data segments includes a number of dirty data segments.
Wherein, the Slack Space Recycling (SSR) is a Logging policy (Threaded Logging) for writing the fragmented files into the file system, and the degree of triggering the Slack Space Recycling can also be used as a parameter for measuring the fragmentation status. The dirty data segment (dirty segment) is a data segment (segment) which is not contained in a part of the storage block (block) and has user data, and the number of the dirty data segments can also be used as a parameter for measuring the fragmentation state.
In one embodiment, the operation of determining the fragmentation degree according to the fragmentation status information may be implemented as follows: performing weighting operation on the fragment degree parameter, the triggering degree and the data segment quantity according to preset weight to obtain a weighting result; and determining the fragmentation degree according to the weighting result.
When the fragmentation state information comprises a plurality of parameters, the fragmentation degree can be determined by a weighting operation method. Preset weights can be respectively set for the fragment degree parameter, the triggering degree and the number of the data segments, the fragment degree parameter, the triggering degree and the number of the data segments are respectively multiplied by the corresponding preset weights, then the weighting result is calculated according to the three multiplication results, and the fragmentation degree can be determined according to the weighting result. For example, the fragmentation degree parameter may be weighted to 0.45, the triggering degree parameter may be weighted to 0.35, the number of data segments may be weighted to 0.2, and a higher weighting result after the weighting operation indicates a higher fragmentation degree. And determining the fragmentation degree according to a plurality of parameters to obtain more accurate fragmentation degree.
In one embodiment, the operation of obtaining fragmentation status information of the file system further comprises the following operations before:
monitoring fragmentation state information of a file system; and when the change of the fragmentation state information of the file system meets a first sorting condition, executing the operation of acquiring the fragmentation state information of the file system.
The fragmentation state information of the file system may be continuously monitored, or the fragmentation state information may be periodically monitored, and if it is monitored that the fragmentation state information is not changed, the operation of acquiring the fragmentation state information of the file system is not required to be performed. If the fragmentation state information is monitored to be changed to a certain extent, the file fragments in the storage module are changed, and the operation of acquiring the fragmentation state information of the file system can be executed.
The first sorting condition may be used to judge that the change of the fragmentation status information meets a condition of the sorting requirement, and for example, if the fragmentation degree parameter in the fragmentation status information changes by more than a first proportion within a preset time period, it may be determined that the first sorting condition is met. The specific first finishing condition may be determined according to an actual application requirement, and is not limited herein.
The file system management provided by the embodiment of the application can determine the state of file fragments in the storage module according to the fragmentation state information through the acquired fragmentation state information of the file system, and further can determine a suitable defragmentation mode, the different defragmentation strengths corresponding to different defragmentation modes control the file system to perform defragmentation operation according to the defragmentation strength, the file fragments can be accurately and reasonably sorted, the user experience is improved while the performance of the electronic equipment is optimized, and the problem of low efficiency in the existing sorting technology can be solved.
In one embodiment, the method further comprises the operations of: acquiring operation information of the electronic equipment; accordingly, the operation of determining the defragmentation mode according to the defragmentation status information may be performed as follows: and determining a defragmentation mode according to whether the operation information meets a preset operation condition and the fragmentation state information.
On the basis of the above embodiment, the operation information of the electronic device may be further acquired as a judgment factor.
The operation information of the electronic device may include operation parameters of the electronic device, may include operation parameters representing performance of the electronic device, and may further include operation parameters representing an interaction state of the electronic device and a user. For example, the operation information includes a power state of the electronic device, a display state of a screen, an operation on a file in the storage module, and the like.
The operation information of the electronic equipment can reflect the current operation state of the electronic equipment, and different operation states correspond to different defragmentation requirements. For example, if the electronic device is in a busy operating state, the operation of the electronic device may be considered preferentially, and a defragmentation mode with lower defragmentation strength is adopted to avoid that the normal operation of the electronic device is affected by defragmentation operation.
And determining a defragmentation mode according to the defragmentation state information and the operation information, and selecting the defragmentation mode by comprehensively considering the current operation state of the electronic device and the condition of the defragmentation state, so that a more reasonable defragmentation mode can be selected, and the user experience is further optimized.
The preset operation condition may be a condition indicating that the current operation state of the electronic device is suitable for performing the defragmentation operation, and if the operation information meets the preset operation condition, the preset operation condition indicates that the current state of the electronic device is suitable for performing the defragmentation operation. Further, the defragmentation mode may be determined according to the fragmentation status information, and the specific implementation of determining the defragmentation mode according to the fragmentation status information may refer to the related description above, which is not described herein again.
For example, when the operation information includes a power state of the electronic device, if the power state is greater than a preset power, it is determined that the preset operation condition is met. Avoid because the electric quantity of electronic equipment is low excessively, can't accomplish the defragmentation operation.
In one embodiment, the operation information includes a read-write operation, and when the electronic device does not execute the read-write operation, it is determined that the operation information meets a preset operation condition.
The read-write operation may include an operation of reading and writing a file in the storage module, for example, the electronic device needs to upload a local picture to a network, needs to read the file of the picture from the storage module, and then uploads the file to the network; if the electronic equipment needs to download the pictures from the network to the local, the pictures need to be written into the storage module.
When defragmentation operation is performed, if read-write operation is performed on the storage module, defragmentation operation is interrupted, and therefore the read-write operation of the electronic device can be used as a judgment factor. If the electronic equipment does not execute the read-write operation, the defragmentation operation can be executed; the defragmentation operation is prevented from being interrupted by the read-write operation of the electronic device.
In an embodiment, when the electronic device does not perform the read-write operation within a first time period, it is determined that the operation information meets a preset operation condition.
Whether the electronic equipment executes the read-write operation within a certain time can be monitored, if the electronic equipment does not execute the read-write operation within the certain time, the electronic equipment can be determined not to execute the read-write operation within a short time, the running information can be determined to accord with the preset running condition, and then the defragmentation operation can be carried out.
In one embodiment, the operation of acquiring the operation information of the electronic device further includes the following operations before the operation of acquiring the operation information of the electronic device:
monitoring operation information of the electronic equipment; and when the change of the operation information of the electronic equipment meets a second sorting condition, executing the operation of acquiring the operation information of the electronic equipment.
The second sorting condition may be a condition for judging that a change of the electronic device meets a sorting requirement, and if the change of the operation information of the electronic device meets the second sorting condition, the operation information of the electronic device may be further acquired, so as to determine a defragmentation mode according to the defragmentation state information and the operation information. For example, if it is monitored that the electronic device stops the read-write operation, the operation information of the electronic device may be acquired, and then it is determined whether the electronic device does not execute the read-write operation in the first time period according to the acquired operation information.
In an embodiment, as shown in fig. 2, when the operation information meets a preset operation condition, the operation of determining the defragmentation mode according to the defragmentation status information may be implemented as follows:
step S201, determining the fragmentation degree according to the fragmentation state information. When the operation information meets a preset operation condition and the fragmentation degree is greater than a first degree, executing step S202; or when the operation information meets a preset operation condition and the fragmentation degree is less than the first degree and greater than the second degree, executing step S203.
In step S202, it is determined that the first sort mode is the defragmentation mode.
Step S203, determining the second sorting mode as a defragmentation mode; wherein a defragmentation intensity of the first defragmentation mode is higher than a defragmentation intensity of the second defragmentation mode.
Therein, the present embodiment determines two sort modes: a first sorting mode and a second sorting mode, the defragmentation intensity of the first sorting mode being higher than the defragmentation intensity of the second sorting mode. After the degree of fragmentation is determined, a first sorting mode may be employed in which the intensity of defragmentation is higher if the degree of fragmentation is higher, and a second sorting mode may be employed in which the intensity of defragmentation is lower if the degree of fragmentation is lower.
In one embodiment, the defragmentation intensity includes a defragmentation frequency and a defragmentation number, and illustratively, the first defragmentation pattern may include a defragmentation frequency of 500 milliseconds, and a defragmentation number of 6 data segments; the second collation pattern may include a collation frequency of 3 seconds and a collation number of 6 data segments, or the second collation pattern includes a collation frequency of 500 milliseconds and a collation number of 1 data segment.
The first degree and the second degree may be preset degree parameters, and specific values may be set according to actual situations, which are not limited herein. If the degree of fragmentation is greater than the first degree, it indicates that the degree of fragmentation is high, a first sort mode may be employed, and if the degree of fragmentation is less than the first degree and greater than the second degree, it indicates that the degree of fragmentation is not high, a second sort mode may be employed. Wherein the first degree is greater than the second degree.
In one embodiment, fragmentation information can be continuously monitored during a defragmentation operation of a file system, and a degree of fragmentation can be determined; the defragmentation mode may be adjusted from the first defragmentation mode to the second defragmentation mode if the degree of defragmentation decreases from being greater than the first degree to being less than the first degree. Along with the defragmentation operation, the defragmentation degree can reduce gradually, when the defragmentation degree reduces not too high scope, can need not to adopt the higher first arrangement mode of defragmentation intensity, can adjust to the lower second arrangement mode of defragmentation intensity.
In addition, if the degree of defragmentation is less than the second degree, the defragmentation mode may not be determined and the file system may perform the defragmentation operation according to a default setting. For a specific embodiment of determining the fragmentation degree according to the fragmentation status information, reference may be made to the foregoing description.
In an embodiment, the operation of determining the defragmentation mode according to whether the operation information meets a preset operation condition and the fragmentation status information may be performed as follows:
and determining the fragmentation degree according to the fragmentation state information.
And when the operation information meets a first condition of a preset operation condition and the fragmentation degree is greater than the first degree, determining that the first sorting mode is the fragmentation sorting mode. Or
When the operation information meets a second condition of a preset operation condition, and the fragmentation degree is smaller than the first degree and larger than the second degree, determining that a second sorting mode is a fragmentation sorting mode; the preset operation condition comprises a first condition and a second condition, the operation information comprises read-write operation, and when the electronic equipment does not execute the read-write operation, the operation information is determined to accord with the first condition of the preset operation condition;
the operation information also comprises a screen state, and when the screen state of the electronic equipment is in a screen-off state and the electronic equipment does not execute read-write operation, the second condition that the operation information meets the preset operation condition is determined
The defragmentation intensity of the first defragmentation mode is higher than the defragmentation intensity of the second defragmentation mode.
When the fragmentation degree is greater than the first degree, that is, the fragmentation degree is relatively high, the performance of the electronic device is likely to be affected, and even if the user uses the electronic device, the user experience is very poor. Therefore, when the electronic equipment does not execute the read-write operation, the file system can be controlled to perform defragmentation operation according to the first defragmentation mode, the storage module is defragmented with higher defragmentation strength, and the performance of the electronic equipment is recovered as soon as possible.
And if the fragmentation degree is smaller than the first degree and larger than the second degree, namely the fragmentation degree is not very high, whether the screen state of the electronic equipment is in the screen-off state or not can be additionally considered as a judgment factor, if the screen state of the electronic equipment is in the screen-off state, the fact that the user does not operate the electronic equipment at the moment is indicated, and meanwhile, the electronic equipment does not perform read-write operation, so that the file system can be controlled to perform the fragmentation operation according to the second sorting mode, and the situation that the use of the user is influenced by the fragmentation operation performed when the user operates the electronic equipment can be avoided.
In one embodiment, the second sorting mode includes a first sub-mode and a second sub-mode, and the operation of determining the second sorting mode as the defragmentation mode may be implemented by:
when the fragmentation degree is smaller than the first degree and larger than the third degree, determining that the first sub-mode is a fragmentation sorting mode; when the fragmentation degree is smaller than the third degree and larger than the second degree, determining that the second sub-mode is a fragmentation sorting mode; wherein the defragmentation intensity of the first sub-mode is higher than the defragmentation intensity of the second sub-mode.
The method comprises the steps of determining a fragmentation mode according to a fragmentation intensity, wherein a plurality of conditions can be set for the condition that the fragmentation degree is not high, and the specific fragmentation mode is determined in a mode that the higher fragmentation degree corresponds to the higher fragmentation intensity in the range that the fragmentation degree is smaller than a first degree and larger than a second degree.
In this embodiment, the first sub-mode and the second sub-mode are determined, the first sub-mode with higher defragmentation intensity may be selected for the case where the degree of defragmentation is smaller than the first degree and larger than the third degree, and the first sub-mode with lower defragmentation intensity may be selected for the case where the degree of defragmentation is smaller than the third degree and larger than the second degree. Wherein the third degree is greater than the second degree and the third degree is less than the first degree.
In one embodiment, the defragmentation intensity includes a defragmentation frequency and a defragmentation number, and the first sub-pattern may include, for example, a defragmentation frequency of 3 seconds, and a defragmentation number of 6 data segments. The second sub-pattern may include a sorting frequency of 3 seconds, and a sorting number of 1 data segment.
It should be noted that, in an actual situation, three or more sub-modes may be set according to requirements, and specifically, the setting may be performed according to actual application requirements, and it is sufficient to satisfy a mode that a higher fragmentation degree corresponds to a higher defragmentation intensity.
In one embodiment, the method further comprises:
acquiring data write-in quantity of the electronic equipment; and when the data writing amount meets a preset writing threshold value, triggering an erasing command to the storage module.
The data writing amount is the total amount of writing operations executed on the storage module, the storage module of the electronic device has a certain service life, and the data writing amount can be used as a parameter for representing the service life. For example, the memory module includes a total write amount of a first write amount in total, and if the data write amount is close to the first write amount, it indicates that the memory module has reached the lifetime limit.
By setting the preset write threshold as the judgment threshold, if the data write amount meets the preset write threshold, the data write amount is gradually close to the total write amount, and the service life maintenance operation can be performed on the storage module. For example, the preset write threshold may be greater than or equal to 60% of the total write amount.
The erase (e.g., Discard command) command is used to mark the memory block in the memory module, the marked memory block is not defragmented, the erase command can reduce the data write amount increased by defragmentation, the wear of the memory module can be reduced, and the life of the memory module can be prolonged.
In an embodiment, when the data writing amount meets a preset writing threshold, the execution frequency of the erase command may be increased. By increasing the frequency of execution of erase commands, the life of the memory module can be further extended.
Referring to fig. 3, fig. 3 is a schematic block diagram of an electronic device according to an embodiment of the present disclosure. The electronic device may be a mobile phone, a tablet computer, a computer, or the like.
Referring to fig. 3, the electronic device 100 includes a processor 110 and a memory 120 connected by a system bus, wherein the memory 120 may include a nonvolatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program includes program instructions that, when executed, cause a processor to perform any of the file system management methods.
The processor is used for providing calculation and control capability and supporting the operation of the whole electronic equipment.
The internal memory provides an environment for the execution of a computer program on a non-volatile storage medium, which when executed by a processor, causes the processor to perform any of the file system management methods.
Those skilled in the art will appreciate that the architecture shown in fig. 3 is a block diagram of only a portion of the architecture associated with the subject application, and does not constitute a limitation on the electronic devices to which the subject application may be applied, and that a particular electronic device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
acquiring fragmentation state information of a file system, and determining a defragmentation mode according to the fragmentation state information;
and controlling the file system to perform defragmentation operation according to the defragmentation mode, wherein the defragmentation mode corresponds to a preset defragmentation intensity.
In one embodiment, the processor, in implementing determining a defragmentation mode based on the fragmentation status information, is configured to implement:
determining the fragmentation degree according to the fragmentation state information;
and determining a corresponding defragmentation mode according to the defragmentation degree, wherein the higher the defragmentation degree is, the higher the defragmentation intensity is.
In one embodiment, the processor is further configured to implement: acquiring operation information of the electronic equipment;
when the processor determines the defragmentation mode according to the fragmentation status information, the processor is configured to:
and determining a defragmentation mode according to whether the operation information meets a preset operation condition and the fragmentation state information.
In one embodiment, the operation information includes a read-write operation, and when the electronic device does not execute the read-write operation, it is determined that the operation information meets a preset operation condition.
In one embodiment, when determining the defragmentation mode according to whether the operation information meets a preset operation condition and the defragmentation status information, the processor is configured to:
determining the fragmentation degree according to the fragmentation state information;
when the operation information meets a preset operation condition and the fragmentation degree is greater than a first degree, determining that a first sorting mode is a fragmentation sorting mode; or
When the operation information meets a preset operation condition and the fragmentation degree is smaller than a first degree and larger than a second degree, determining that a second sorting mode is a fragmentation sorting mode;
wherein a defragmentation intensity of the first defragmentation mode is higher than a defragmentation intensity of the second defragmentation mode.
In one embodiment, when determining the defragmentation mode according to whether the operation information meets a preset operation condition and the defragmentation status information, the processor is configured to:
determining the fragmentation degree according to the fragmentation state information;
when the operation information meets a first condition of a preset operation condition and the fragmentation degree is greater than a first degree, determining that a first sorting mode is a fragmentation sorting mode; or
When the operation information meets a second condition of a preset operation condition, and the fragmentation degree is smaller than the first degree and larger than the second degree, determining that a second sorting mode is a fragmentation sorting mode;
the preset operation condition comprises a first condition and a second condition, the operation information comprises read-write operation, and when the electronic equipment does not execute the read-write operation, the operation information is determined to accord with the first condition of the preset operation condition; or the running information comprises read-write operation and a screen state, and when the screen state of the electronic equipment is in a screen-off state and the electronic equipment does not execute the read-write operation, the running information is determined to meet a second condition of a preset running condition;
the defragmentation intensity of the first defragmentation mode is higher than the defragmentation intensity of the second defragmentation mode.
In one embodiment, the second sorting mode comprises a first sub-mode and a second sub-mode, and the processor, in effecting determining that the second sorting mode is a defragmentation mode, is configured to effect:
when the fragmentation degree is smaller than the first degree and larger than the third degree, determining that the first sub-mode is a fragmentation sorting mode; or
When the fragmentation degree is smaller than the third degree and larger than the second degree, determining that the second sub-mode is a fragmentation sorting mode;
wherein the defragmentation intensity of the first sub-mode is higher than the defragmentation intensity of the second sub-mode.
In one embodiment, the fragmentation status information includes a fragmentation level parameter, a trigger level, and a number of data segments, wherein the trigger level includes a level to which free space reclamation is triggered within the second time period, and the number of data segments includes a number of dirty data segments.
In one embodiment, the processor, in effecting determining the degree of fragmentation from the fragmentation status information, is operable to effect:
performing weighting operation on the fragment degree parameter, the triggering degree and the data segment quantity according to preset weight to obtain a weighting result;
and determining the fragmentation degree according to the weighting result.
In one embodiment, the processor is further configured to implement:
acquiring data write-in quantity of the electronic equipment;
when the data writing amount meets a preset writing threshold value, triggering an erasing command to a storage module;
in one embodiment, before the obtaining fragmentation status information of the file system, the processor is further configured to:
monitoring fragmentation state information of a file system;
and when the change of the fragmentation state information of the file system meets a first sorting condition, executing the operation of acquiring the fragmentation state information of the file system.
In one embodiment, before implementing the acquiring of the operation information of the electronic device, the processor is further configured to implement:
monitoring operation information of the electronic equipment;
and when the change of the operation information of the electronic equipment meets a second sorting condition, executing the operation of acquiring the operation information of the electronic equipment.
The embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, where the computer program includes program instructions, and the processor executes the program instructions to implement any file system management method provided in the embodiment of the present application.
The computer-readable storage medium may be an internal storage unit of the electronic device according to the foregoing embodiment, for example, a hard disk or a memory of the electronic device. The computer readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, provided on the electronic device.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (14)

1. A file system management method, the method comprising:
acquiring fragmentation state information of a file system, and determining a defragmentation mode according to the fragmentation state information;
and controlling the file system to perform defragmentation operation according to the defragmentation mode, wherein the defragmentation mode corresponds to a preset defragmentation intensity.
2. The file system management method according to claim 1, wherein said determining a defragmentation mode based on the defragmentation status information comprises:
determining the fragmentation degree according to the fragmentation state information;
and determining a corresponding defragmentation mode according to the defragmentation degree, wherein the higher the defragmentation degree is, the higher the defragmentation intensity is.
3. The file system management method according to claim 1, wherein said method further comprises:
acquiring operation information of the electronic equipment;
the determining a defragmentation mode according to the fragmentation status information comprises:
and determining a defragmentation mode according to whether the operation information meets a preset operation condition and the fragmentation state information.
4. The file system management method according to claim 3, wherein the operation information includes a read-write operation, and when the electronic device does not perform the read-write operation, it is determined that the operation information meets a preset operation condition.
5. The file system management method according to claim 3, wherein said determining a defragmentation mode according to whether the operation information meets a preset operation condition and the defragmentation status information comprises:
determining the fragmentation degree according to the fragmentation state information;
when the operation information meets a preset operation condition and the fragmentation degree is greater than a first degree, determining that a first sorting mode is a fragmentation sorting mode; or
When the operation information meets a preset operation condition and the fragmentation degree is smaller than a first degree and larger than a second degree, determining that a second sorting mode is a fragmentation sorting mode;
wherein a defragmentation intensity of the first defragmentation mode is higher than a defragmentation intensity of the second defragmentation mode.
6. The file system management method according to claim 3, wherein said determining a defragmentation mode according to whether the operation information meets a preset operation condition and the defragmentation status information comprises:
determining the fragmentation degree according to the fragmentation state information;
when the operation information meets a first condition of a preset operation condition and the fragmentation degree is greater than a first degree, determining that a first sorting mode is a fragmentation sorting mode; or
When the operation information meets a second condition of a preset operation condition, and the fragmentation degree is smaller than the first degree and larger than the second degree, determining that a second sorting mode is a fragmentation sorting mode;
the operation information comprises read-write operation, and when the electronic equipment does not execute the read-write operation, the operation information is determined to meet a first condition of a preset operation condition; or the running information comprises read-write operation and a screen state, and when the screen state of the electronic equipment is in a screen-off state and the electronic equipment does not execute the read-write operation, the running information is determined to meet a second condition of a preset running condition;
the defragmentation intensity of the first defragmentation mode is higher than the defragmentation intensity of the second defragmentation mode.
7. The file system management method according to claim 5 or 6, wherein the second defragmentation mode comprises a first sub-mode and a second sub-mode, and wherein the determining that the second defragmentation mode is a defragmentation mode comprises:
when the fragmentation degree is smaller than the first degree and larger than the third degree, determining that the first sub-mode is a fragmentation sorting mode; or
When the fragmentation degree is smaller than the third degree and larger than the second degree, determining that the second sub-mode is a fragmentation sorting mode;
wherein the defragmentation intensity of the first sub-mode is higher than the defragmentation intensity of the second sub-mode.
8. The file system management method according to any one of claims 1 to 6, wherein the fragmentation status information includes a fragmentation degree parameter, a trigger degree, and a number of data segments, wherein the trigger degree includes a degree to which free space reclamation is triggered in the second time period, and the number of data segments includes a number of dirty data segments.
9. The file system management method according to claim 8, wherein determining a fragmentation degree from the fragmentation status information comprises:
performing weighting operation on the fragment degree parameter, the triggering degree and the data segment quantity according to preset weight to obtain a weighting result;
and determining the fragmentation degree according to the weighting result.
10. The file system management method according to any one of claims 1 to 6, characterized in that the method further comprises:
acquiring data write-in quantity of the electronic equipment;
and when the data writing amount meets a preset writing threshold value, triggering an erasing command to the storage module.
11. The file system management method according to any one of claims 1 to 6, wherein before the obtaining fragmentation status information of the file system, further comprising:
monitoring fragmentation state information of a file system;
and when the change of the fragmentation state information of the file system meets a first sorting condition, executing the operation of acquiring the fragmentation state information of the file system.
12. The file system management method according to any one of claims 3 to 6, wherein before acquiring the operation information of the electronic device, the method further comprises:
monitoring operation information of the electronic equipment;
and when the change of the operation information of the electronic equipment meets a second sorting condition, executing the operation of acquiring the operation information of the electronic equipment.
13. An electronic device, comprising a memory and a processor;
the memory is used for storing a computer program;
the processor for executing the computer program and implementing the file system management method according to any of claims 1 to 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, causes the processor to implement the file system management method according to any one of claims 1 to 12.
CN202010707628.0A 2020-07-21 2020-07-21 File system management method, electronic device and storage medium Pending CN113961517A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010707628.0A CN113961517A (en) 2020-07-21 2020-07-21 File system management method, electronic device and storage medium
PCT/CN2021/103843 WO2022017148A1 (en) 2020-07-21 2021-06-30 File system management method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010707628.0A CN113961517A (en) 2020-07-21 2020-07-21 File system management method, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN113961517A true CN113961517A (en) 2022-01-21

Family

ID=79459991

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010707628.0A Pending CN113961517A (en) 2020-07-21 2020-07-21 File system management method, electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN113961517A (en)
WO (1) WO2022017148A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116049021A (en) * 2022-08-29 2023-05-02 荣耀终端有限公司 Storage space management method, electronic device, and computer-readable storage medium
CN116701298A (en) * 2022-11-22 2023-09-05 荣耀终端有限公司 File system management method and electronic equipment

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9767032B2 (en) * 2012-01-12 2017-09-19 Sandisk Technologies Llc Systems and methods for cache endurance
CN104933169B (en) * 2015-06-29 2018-05-01 南开大学 Based on the preferential file system fragmentation method for sorting of hot spot file
CN107145452A (en) * 2017-05-25 2017-09-08 努比亚技术有限公司 Method, terminal device and the computer-readable recording medium of defragmentation
CN107704507B (en) * 2017-08-31 2021-05-25 三星电子(中国)研发中心 Database processing method and device
US11842046B2 (en) * 2018-06-30 2023-12-12 Huawei Technologies Co., Ltd. Storage fragment management method and terminal
CN111258972B (en) * 2020-01-10 2023-10-03 Oppo广东移动通信有限公司 Flash memory file system fragmentation evaluation method and device and electronic equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116049021A (en) * 2022-08-29 2023-05-02 荣耀终端有限公司 Storage space management method, electronic device, and computer-readable storage medium
CN116049021B (en) * 2022-08-29 2023-10-20 荣耀终端有限公司 Storage space management method, electronic device, and computer-readable storage medium
CN116701298A (en) * 2022-11-22 2023-09-05 荣耀终端有限公司 File system management method and electronic equipment
CN116701298B (en) * 2022-11-22 2024-06-07 荣耀终端有限公司 File system management method and electronic equipment

Also Published As

Publication number Publication date
WO2022017148A1 (en) 2022-01-27

Similar Documents

Publication Publication Date Title
US20220091740A1 (en) Memory devices and electronic systems having a hybrid cache including static and dynamic caches, and related methods
CN111090398B (en) Garbage recycling method, device and equipment for solid state disk and readable storage medium
US10552315B2 (en) Data processing method and apparatus, and flash device
KR101390134B1 (en) Handling dynamic and static data for a system having non-volatile memory
US8321703B2 (en) Power aware memory allocation
US9274944B2 (en) Wear leveling
US20180373428A1 (en) Methods and systems for managing data migration in solid state non-volatile memory
US20120005405A1 (en) Pre-Emptive Garbage Collection of Memory Blocks
US10289317B2 (en) Memory apparatus and methods thereof for write amplification aware wear leveling
KR20140033099A (en) Managing data placement on flash-based storage by use
CN101770428A (en) Method for operating non-volatile memory and data storage system using the same
US8161251B2 (en) Heterogeneous storage array optimization through eviction
CN108139904B (en) Write command filtering
CN113961517A (en) File system management method, electronic device and storage medium
CN112068782B (en) Memory management method, memory storage device and memory control circuit unit
CN110390985B (en) Memory management method, memory storage device and memory control circuit unit
EP4231131A1 (en) Data storage method and device
CN115509454A (en) Solid state disk data writing method and device, electronic equipment and medium
CN106021124B (en) A kind of storage method and storage system of data
CN110096215B (en) Memory management method, memory storage device and memory control circuit unit
CN118689402A (en) Data merging method and storage device
CN109144399A (en) A kind of date storage method, device and electronic equipment
KR20240142823A (en) Method for bit error rate based hybrid partitioning of NAND flash solid-state drive and apparatus thereof
CN118796119A (en) Memory management method and memory device
CN115933964A (en) Lifecycle aware persistent storage

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