File arrangement method and device, terminal equipment and computer readable storage medium
By detecting and sorting fragmented files in the log structure file system, the fragmentation problem caused by the off-site update mechanism of LFS file system is solved, and the sequential read and write performance of the file system is improved.
Patent Information
- Application Number
- CN202411060432.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-12-13
AI Technical Summary
The log structure file system (LFS) type file system has significantly reduced the file fragmentation problem caused by the off-site update mechanism, resulting in a significant reduction in the sequential reading and sequential writing performance of the file system.
Provide a file sorting method, which realizes continuous storage of files by determining whether the target file is a fragmented file and sorting it into a target storage location with empty and continuous storage addresses in the storage space. The method includes detecting the number of times, size, type, and time intervals of a file, determining whether the file is a fragmented file, and migrating the file to a continuous storage location when there is enough storage space.
It effectively avoids the degradation of file system performance by file fragmentation, improves the performance of sequential reading and sequential writing, and ensures that files change from fragmented state to continuous state.
Smart Images

Figure CN119127822A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a file organization method, device, terminal equipment and computer-readable storage medium. Background Art
[0002] The log-structured file system (Log-structure FileSystem) has derived a variety of file systems, collectively referred to as log-structured (LFS) file systems, such as F2FS and NILFS. The main features of this type of file system are the off-site update mechanism and the checkpoint mechanism. Regardless of whether the underlying storage device is a mechanical hard disk or a Flash storage device, the off-site (address) update mechanism can significantly improve the random write performance. This type of file system is widely used in mobile smart devices. However, the side effect of the off-site update mechanism is that compared with other in-place update file systems, the LFS file system will have very serious fragmentation caused by file overwriting or update. The fragmentation here includes two aspects: fragmentation within the file (internal fragmentation) and fragmentation of the remaining space of the file system (external fragmentation). These two types of fragmentation will significantly reduce the performance of sequential reading and sequential writing of the file system. Therefore, a solution to this problem is needed. Summary of the invention
[0003] The present application provides a file organization method, which can organize fragmented files.
[0004] In a first aspect, the present application provides a file arrangement method, the method comprising:
[0005] Determine whether the target file is a fragmented file;
[0006] If the target file is a fragmented file, determining a target storage location that is free and has a continuous storage address in the target storage space;
[0007] The target files are sorted into the target storage location.
[0008] In some embodiments of the present application, determining whether the target file is a fragmented file includes:
[0009] Determine the file write count, file size, file type, and write time interval of the target file;
[0010] Whether the target file is a fragmented file is determined according to the number of file writes, and / or the file size, and / or the file type, and / or the write time interval.
[0011] In some embodiments of the present application, determining whether the target file is a fragmented file according to the number of file writes, and / or the file size, and / or the file type, and / or the write time interval includes:
[0012] Determine whether the file type of the target file is the target file type;
[0013] If the target file is of the target file type, determining whether the file size of the target file is greater than the target file size;
[0014] If the file size of the target file is larger than the target file size, determining whether the number of file writes of the target file is larger than a target write number threshold;
[0015] If the number of file writes to the target file is greater than the target write number threshold, determining whether the write time interval between each write of the target file is less than the target time;
[0016] If the writing time interval between each writing of the target file is less than the target time, it is determined whether the target file is a fragmented file.
[0017] In some embodiments of the present application, determining a target storage location that is free in the target storage space and has a continuous storage address includes:
[0018] Determining remaining storage space of the target storage space;
[0019] If the remaining storage space is less than or equal to the target space threshold, the target file is sorted according to the default sorting strategy;
[0020] If the remaining storage space is greater than the target space threshold, a target storage location that is free and has a continuous storage address in the target storage space is determined.
[0021] In some embodiments of the present application, if the remaining storage space is greater than the target space threshold, determining a target storage location that is free in the target storage space and has a continuous storage address includes:
[0022] Determining whether there is reserved storage space in the remaining storage space;
[0023] If the reserved storage space exists, determining a storage location in the reserved storage space that is free and has a continuous storage address as the target storage location;
[0024] If the reserved storage space does not exist, a storage location with a vacant storage address and a continuous storage address in the remaining storage space is applied as the target storage location.
[0025] In some embodiments of the present application, determining a target storage location that is free in the target storage space and has a continuous storage address includes:
[0026] Determining a first number of storage locations required for the target file;
[0027] Determine storage locations with continuous storage addresses corresponding to a second number of storage locations that is vacant in the target storage space and is greater than the first number of storage locations as target storage locations.
[0028] In some embodiments of the present application, the step of arranging the target files to the target storage location includes:
[0029] Determine the initial storage location of the target file;
[0030] Determining address mapping information between the initial storage location and the target storage location;
[0031] The target file is sorted to the target storage location according to the address mapping information.
[0032] In a second aspect, the present application further provides a file arrangement device, the device comprising:
[0033] A determination module, used to determine whether a target file is a fragmented file;
[0034] The determination module is further used to determine a target storage location that is free and has a continuous storage address in the target storage space if the target file is a fragmented file;
[0035] The arranging module is used to arrange the target files to the target storage location.
[0036] In a third aspect, the present application also provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in any one of the file organization methods described.
[0037] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps in any one of the file organization methods described.
[0038] The file arrangement method provided by the present application can first determine whether the target file is a fragmented file. If the target file is a fragmented file, a target storage location that is free and has a continuous storage address in the corresponding target storage space is determined, and the target file is arranged to the target storage location. This solution can arrange fragmented files to a continuous storage location, so that the file is converted from a fragmented storage state to a continuous storage state, avoiding the fragmented storage that will significantly reduce the performance of the file system's sequential read and sequential write, and improving the performance of the file's sequential read and sequential write. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0040] Figure 1 is a schematic diagram of a scenario of a file arrangement system provided in an embodiment of the present application;
[0041] Figure 2 This is a flowchart of an embodiment of the file arrangement method in the embodiment of the present application;
[0042] Figure 3 This is a schematic diagram illustrating an embodiment of the file arrangement method in the embodiment of the present application;
[0043] Figure 4 This is a schematic diagram illustrating an embodiment of the file arrangement method in the embodiment of the present application;
[0044] Figure 5 This is a schematic diagram illustrating an embodiment of the file arrangement method in the embodiment of the present application;
[0045] Figure 6 It is a functional module schematic diagram of a file arrangement device in an embodiment of the present application;
[0046] Figure 7 It is a schematic diagram of the structure of the terminal device in the embodiment of the present application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0048] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0049] In this application, the word "exemplary" is used to mean "used as an example, illustration or description". Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. At the same time, it is to be understood that in the specific implementation of this application, when user information, user data and other related data are involved, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data shall comply with relevant laws, regulations and standards of relevant countries and regions.
[0050] In order to enable any person skilled in the art to implement and use the present application, the following description is provided. In the following description, details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art will recognize that the present application can be implemented without using these specific details. In other examples, known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the present application.
[0051] The present application provides a file organization method, apparatus, device and storage medium, which are described in detail below.
[0052] See also Figure 1 , Figure 1 Schematic diagram of a scenario of a file arrangement system provided in an embodiment of the present application. The file arrangement system may include a terminal device 100 and a storage device 200. The storage device 200 may transmit data to the terminal device 100. Figure 1 The terminal device 100 in the storage device 200 can obtain the files stored in the storage device 200 to execute the file organization method in the present application.
[0053] In the embodiment of the present application, the terminal device 100 includes but is not limited to a desktop computer, a portable computer, a network server, a PDA (Personal Digital Assistant), a tablet computer, a wireless terminal device, an embedded device, etc.
[0054] In the embodiments of the present application, the terminal device 100 and the storage device 200 can communicate with each other through any communication method, including but not limited to mobile communications based on the 3rd Generation Partnership Project (3GPP), Long Term Evolution (LTE), Worldwide Interoperability for Microwave Access (WiMAX), or computer network communications based on the TCP / IP Protocol Suite (TCP / IP), User Datagram Protocol (UDP), etc. It should be noted that the storage device 200 can also be built into the terminal device 100, and the specific embodiments of the present application are not limited thereto.
[0055] It should be noted that Figure 1 The scenario diagram of the file organization system shown is merely an example. The file organization system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the file organization system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is equally applicable to similar technical problems.
[0056] like Figure 2 As shown, Figure 2 This is a flowchart of an embodiment of a file organization method in an embodiment of the present application. The file organization method may include the following steps 201 to 203:
[0057] 201. Determine whether the target file is a fragmented file.
[0058] First, according to the background technology, if a file is stored in a non-continuous storage address in a storage device, it is a fragmented file. Figure 3 As shown, Figure 3 Each cell in can be regarded as a storage address. If file A corresponds to A1, A2, A3, A4, and file B corresponds to B1, B2, B3, B4, then according to Figure 3It can be obtained that both file A and file B are stored in non-continuous storage addresses. Therefore, in the embodiment of the present application, if it is determined whether a file is a fragmented file, the storage address of a file can be detected to detect whether these storage addresses are continuous. If these storage addresses are not continuous, it can be determined that the file is a fragmented file. It should be noted that the target file in the present application can be a file of any file type, such as exe, jpg, doc, etc., which is not limited in the embodiment of the present application. When these fragmented files are running, the system needs to find the fragmented files from each storage address, so that the system will take a long time to start the file.
[0059] When a file is first stored in the target storage space, the file is in a continuous storage state. However, whenever a file is rewritten, the rewritten information will be deleted, and new file information will be generated and stored in a new storage location. Including file updates, modifications, etc., will cause new data to be stored in other storage locations, which are usually not continuous with the original storage location. For example, Figure 4 As shown in the figure, file A corresponds to A1, A2, A3, A4, and file B corresponds to B1, B2, B3, B4. If the system updates A4 and A2 in file A and B3 and B2 in file B, the newly generated A4, A2 and B3, B2 will be stored in other locations. Figure 5 As shown, the newly generated A4, A2 and B3, B2 are stored in other storage locations.
[0060] 202. If the target file is a fragmented file, determine a target storage location that is free in the target storage space and has a continuous storage address.
[0061] According to the above steps, it can be determined whether the target file is a fragmented file. When it is determined that the target file is a fragmented file, an unoccupied and continuous storage address can be determined in the target storage space as the new target storage location of the target file. Among them, the method of determining the target storage address may include detecting the free storage addresses in the target storage space, and respectively detecting whether the addresses of these free storage addresses are continuous, and filtering out the continuous free storage addresses. Among them, the target storage space can be a storage space corresponding to a storage device of a local device, or it can be a storage space corresponding to an external storage device connected to the local device, and the specific embodiments of the present application are not limited.
[0062] 203. Organize the target files to the target storage location.
[0063] Once the target storage location is determined, the target file can be migrated to the target storage location.
[0064] The file arrangement method provided by the present application can first determine whether the target file is a fragmented file. If the target file is a fragmented file, a target storage location that is free and has a continuous storage address in the corresponding target storage space is determined, and the target file is arranged to the target storage location. This solution can arrange fragmented files to a continuous storage location, so that the file is converted from a fragmented storage state to a continuous storage state, avoiding the fragmented storage that will significantly reduce the performance of the file system's sequential read and sequential write, and improving the performance of the file's sequential read and sequential write.
[0065] In order to better implement the embodiment of the present application, in one embodiment of the present application, determining whether the target file is a fragmented file includes:
[0066] Determine the number of file writes, file size, file type, and write time interval of the target file; and determine whether the target file is a fragmented file based on the number of file writes, and / or file size, and / or file type, and / or write time interval.
[0067] The above embodiment provides a solution for determining whether a target file is a fragmented file by detecting the storage address of the target file. However, if the amount of data stored in the target storage space is large and the target storage space is a large-capacity storage space, the efficiency of this method is low. Therefore, in order to improve the efficiency of determining whether a target file is a fragmented file, it can be determined based on some attribute information of the target file.
[0068] Specifically, if a file is written frequently, the file will be in the above Figure 5 state in. Therefore, the degree of fragmentation of a file can be determined according to the number of times the file is written. For example: the more times the file is written, the higher the degree of fragmentation. In addition, the larger the file is, the more likely it is that the file will be stored in segments. Alternatively, if the file type of the file is a specific type, such as txt, doc, etc., which are file types that can be used as logs, this file type will be updated in real time as the program runs, and this type of file also inputs files that are updated at a high frequency, so this type of file is also usually a fragmented file. At the same time, the time interval between each suction of the target file can also be detected. The shorter the time interval, the higher the writing frequency of the file can be, and it can also be regarded as a fragmented file. Therefore, any of the above methods or any combination of methods can be used as a criterion for determining whether the target file is a fragmented file, and the specific embodiments of the present application are not limited.
[0069] In order to better implement the embodiment of the present application, in an embodiment of the present application, determining whether the target file is a fragmented file according to the number of file writes, and / or the file size, and / or the file type, and / or the write time interval includes:
[0070] Determine whether the file type of the target file is the target file type; if the target file is the target file type, determine whether the file size of the target file is greater than the target file size; if the file size of the target file is greater than the target file size, determine whether the number of file writes of the target file is greater than the target write number threshold; if the number of file writes of the target file is greater than the target write number threshold, determine whether the write time interval between each write of the target file is less than the target time; if the write time interval between each write of the target file is less than the target time, determine whether the target file is a fragmented file.
[0071] The above embodiment provides a method of using any one or more of the number of file write times, file size, file type, and write time interval as a criterion for determining whether a file is a fragmented file. However, the present application embodiment also provides a method of using all of the above methods as a criterion for determining whether a file is a fragmented file.
[0072] Specifically, as shown above, the file type of the target file can be determined first, then the file size of the target file can be determined, then the number of file writes of the target file can be determined, and finally the write time interval of the target file can be determined. If all of the above determination conditions are met, it can be determined that the target file is a fragmented file, otherwise it is not a fragmented file.
[0073] In addition, in the embodiment of the present application, a first fragmentation score may be determined according to the file type, for example, assuming that the file type of the target file belongs to the target file type, the first fragmentation score is increased by 1. Then, according to the number of write times, the second fragmentation score is determined, which can be obtained according to a linear function of a preset number of writes and the second fragmentation score or a lookup table. Then, according to the file size, the third fragmentation score is determined, which can be obtained according to a linear function of a preset file size and the third fragmentation score or a lookup table. Next, according to the write time interval, the fourth fragmentation score may be determined, which can also be obtained according to a linear function of a preset write time interval and the fourth fragmentation score or a lookup table. Finally, the first fragmentation score, the second fragmentation score, the third fragmentation score and the fourth fragmentation score are added together to obtain the target fragmentation score. When the target fragmentation score is greater than or equal to the score threshold, it can be determined as a fragmented file. If the target fragmentation score is less than the score threshold, it can be determined as a non-fragmented file.
[0074] In order to better implement the embodiments of the present application, in one embodiment of the present application, determining a target storage location that is free in the target storage space and has a continuous storage address includes:
[0075] Determine the remaining storage space of the target storage space; if the remaining storage space is less than or equal to the target space threshold, organize the target files according to the default organization strategy; if the remaining storage space is greater than the target space threshold, determine the target storage locations in the target storage space that are free and have continuous storage addresses.
[0076] The above embodiment provides a solution for file organization. The embodiment of the present application also provides a solution for file organization.
[0077] Specifically, when determining the target storage location of the target file, the remaining storage space of the target storage space may be determined first. If the remaining storage space is smaller than the file size of the target file, the target file cannot be re-migrated to the remaining storage space.
[0078] Therefore, when determining the target storage location, you can first determine whether the remaining storage space in the target storage space is greater than the target space threshold. If the remaining storage space in the target storage space is less than or equal to the target space threshold, it can be determined that the remaining storage space cannot meet the file organization requirements under the current situation. At this time, the target files are organized according to the default organization strategy.
[0079] For example: sorting part of the target file's contents instead of sorting the entire target file. Figure 5 For example, if A1, A2, A3, and A4 cannot be sorted at the same time, A2 and A4 can be stored continuously to achieve the effect of partial sorting. At this time, if the size of the remaining storage space in the target storage space is greater than the target space threshold, the target storage address can be determined according to the method of the above embodiment, which will not be repeated here. Among them, the target space threshold can be set according to the actual situation, and the embodiment of the present application does not limit it.
[0080] In order to better implement the embodiments of the present application, in one embodiment of the present application, if the remaining storage space is greater than the target space threshold, determining a target storage location that is free in the target storage space and has a continuous storage address includes:
[0081] Determine whether there is reserved storage space in the remaining storage space; if there is reserved storage space, determine that the storage location in the reserved storage space that is free and has a continuous storage address is the target storage location; if there is no reserved storage space, apply for a storage location in the remaining storage space that is free and has a continuous storage address as the target storage location.
[0082] In the embodiment of the present application, a reserved storage space can be set in the remaining storage space, and the reserved storage space is used to store the organized files. If it exists, the target storage address can be determined in the reserved storage space, otherwise the target storage location can be applied in the remaining storage space. The method of determining the target storage location is the same as the above-mentioned embodiment, and will not be repeated here.
[0083] In order to better implement the embodiments of the present application, in one embodiment of the present application, determining a target storage location that is free in the target storage space and has a continuous storage address includes:
[0084] Determine the number of first storage locations required for the target file; determine the storage locations with continuous storage addresses corresponding to the number of second storage locations that are free in the target storage space and greater than the number of first storage locations as the target storage locations.
[0085] When determining the target storage location, the number of storage locations consumed by the target file before sorting can be used as the required number of first storage locations. Then, in the target storage space, determine the storage addresses of the second storage locations that are free and continuous and at the same time greater than the number of first storage locations as the target storage locations. The specific reason is that additional storage space can be appropriately reserved so that when the target file is changed again in the future, the additional storage space can be used to store the change information of the target file, so as to achieve the effect of not having to sort again. For example: assuming that the initial size of the target file is M, when the file has been modified or updated many times and the current size of the target file is S, the current size can be used as the first storage location number. At this time, when determining the target storage location, N, that is, the storage location corresponding to the second storage location number, can be used as the target storage location.
[0086] In order to better implement the embodiment of the present application, in one embodiment of the present application, organizing the target files to the target storage location includes:
[0087] Determine the initial storage location of the target file; determine the address mapping information between the initial storage location and the target storage location; and organize the target file to the target storage location according to the address mapping information.
[0088] The embodiment of the present application also provides a sorting method. Specifically, during the sorting process, a mapping relationship can be established between the initial storage location of the target file before sorting and the target storage location, and sorting can be performed according to the mapping relationship. Since the storage location of the target file changes, when the target file is subsequently run for the first time after sorting, the migration of the file may cause a longer startup time. After sorting according to the mapping relationship, the mapping information can be retained, so that the startup time of the first run after sorting is the same as the previous startup time, thereby ensuring the startup efficiency of the file.
[0089] In addition, the establishment of address mapping information may include, assuming that A1 of file A is previously stored at address 1, and A1 after being sorted is stored at address 10, then an index mark may be established according to address 1 and address 10. This index mark may be understood as address mapping information. Of course, other ways of establishing address mapping information may also be included, which are not limited in the specific embodiments of the present application.
[0090] In summary, the embodiment of the present application provides a solution for file organization. However, it should also be noted that the present application also includes a general organization module, which is used to organize non-fragmented files. For example: according to the above-mentioned judgment method, when it is determined that the target file is a non-fragmented file, if the user manually performs file organization, the target file is organized through the organization module. At the same time, regardless of whether the target file is a fragmented file or a non-fragmented file, after the target file is organized, the storage address before the target file can be released and used to store data of other files.
[0091] In order to better implement the file organization method in the embodiment of the present application, in addition to the file organization method, the embodiment of the present application also provides a file organization device, such as Figure 6 As shown, the device 300 includes:
[0092] A determination module 301 is used to determine whether a target file is a fragmented file;
[0093] The determination module 301 is further used to determine a target storage location that is free and has a continuous storage address in the target storage space if the target file is a fragmented file;
[0094] The sorting module 302 is used to sort the target files into the target storage location.
[0095] The file arrangement device provided by the present application can first determine whether the target file is a fragmented file through the determination module 301. If the target file is a fragmented file, the target storage position with free storage address and continuous storage address in the corresponding target storage space is determined by the determination module 301, and the target file is arranged to the target storage position through the arrangement module 302. This solution can arrange the fragmented files to the continuous storage position, so that the file is converted from the fragmented storage state to the continuous storage state, avoiding the fragmented storage which will significantly reduce the performance of the file system sequential reading and sequential writing, and improving the performance of the file sequential reading and sequential writing.
[0096] In some embodiments of the present application, the determination module 301 is specifically used to:
[0097] Determine the number of file writes, file size, file type, and write time interval of the target file;
[0098] Whether the target file is a fragmented file is determined according to the number of file writes, and / or the file size, and / or the file type, and / or the write time interval.
[0099] In some embodiments of the present application, the determination module 301 is specifically used to:
[0100] Determine whether the file type of the target file is the target file type;
[0101] If the target file is of the target file type, determining whether the file size of the target file is greater than the target file size;
[0102] If the file size of the target file is larger than the target file size, determining whether the number of file writes of the target file is larger than the target write number threshold;
[0103] If the number of file writes to the target file is greater than the target write number threshold, determining whether the write time interval between each write of the target file is less than the target time;
[0104] If the writing time interval between each writing of the target file is less than the target time, it is determined whether the target file is a fragmented file.
[0105] In some embodiments of the present application, the determination module 301 is specifically used to:
[0106] Determine the remaining storage space of the target storage space;
[0107] If the remaining storage space is less than or equal to the target space threshold, the target files are organized according to the default organization strategy;
[0108] If the remaining storage space is greater than the target space threshold, a target storage location that is free and has a continuous storage address in the target storage space is determined.
[0109] In some embodiments of the present application, the determination module 301 is specifically used to:
[0110] Determine whether there is reserved storage space in the remaining storage space;
[0111] If there is a reserved storage space, determining a storage location in the reserved storage space that is free and has a continuous storage address as the target storage location;
[0112] If there is no reserved storage space, a storage location with a vacant storage address and a continuous storage address in the remaining storage space is applied as the target storage location.
[0113] In some embodiments of the present application, the determination module 301 is specifically used to:
[0114] determining a first number of storage locations required for the target file;
[0115] Determine the storage locations with continuous storage addresses corresponding to a second storage location number that is vacant in the target storage space and is greater than the first storage location number as the target storage locations.
[0116] In some embodiments of the present application, the sorting module 302 is specifically used to:
[0117] Determine the initial storage location of the target file;
[0118] Determining address mapping information between an initial storage location and a target storage location;
[0119] According to the address mapping information, the target files are sorted to the target storage location.
[0120] The present application also provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps of any file organization method in the present application. The terminal device integrates any file organization method provided in the present application. Figure 7 As shown, it shows a schematic diagram of the structure of the terminal device involved in the embodiment of the present application, specifically:
[0121] The terminal device may include one or more processing core processors 401, one or more computer-readable storage media memories 402, a power supply 403, an input unit 404 and other components. Those skilled in the art will appreciate that Figure 7 The terminal device structure shown in the figure does not constitute a limitation on the terminal device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0122] The processor 401 is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the entire terminal device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 executes various functions of the terminal device and processes data, thereby monitoring the terminal device as a whole. Optionally, the processor 401 may include one or more processing cores; the processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface and the application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0123] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0124] The terminal device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption management and other functions through the power management system. The power supply 403 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0125] The terminal device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0126] Although not shown, the terminal device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the terminal device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, such as:
[0127] Determine whether the target file is a fragmented file;
[0128] If the target file is a fragmented file, determine a target storage location that is free and has a continuous storage address in the target storage space;
[0129] Organize the target files to the target storage location.
[0130] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0131] To this end, an embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any file arrangement method provided in the embodiment of the present application. For example, the computer program is loaded by a processor to execute the following steps:
[0132] Determine whether the target file is a fragmented file;
[0133] If the target file is a fragmented file, determine a target storage location that is free and has a continuous storage address in the target storage space;
[0134] Organize the target files to the target storage location.
[0135] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.
[0136] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.
[0137] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0138] The above is a detailed introduction to a file organization method and device provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A file arrangement method, characterized in that: The method comprises: Determine whether the target file is a fragmented file; If the target file is a fragmented file, determining a target storage location that is free and has a continuous storage address in the target storage space; The target files are sorted into the target storage location.
2. The file arrangement method according to claim 1, characterized in that: The step of determining whether the target file is a fragmented file includes: Determine the file write count, file size, file type, and write time interval of the target file; Whether the target file is a fragmented file is determined according to the number of file writes, and / or the file size, and / or the file type, and / or the write time interval.
3. The file arrangement method according to claim 2, characterized in that: The determining whether the target file is a fragmented file according to the number of file write times, and / or the file size, and / or the file type, and / or the write time interval includes: Determine whether the file type of the target file is the target file type; If the target file is of the target file type, determining whether the file size of the target file is greater than the target file size; If the file size of the target file is larger than the target file size, determining whether the number of file writes of the target file is larger than a target write number threshold; If the number of file writes to the target file is greater than the target write number threshold, determining whether the write time interval between each write of the target file is less than the target time; If the writing time interval between each writing of the target file is less than the target time, it is determined whether the target file is a fragmented file.
4. The file arrangement method according to claim 1, characterized in that: The step of determining a target storage location that is free in the target storage space and has a continuous storage address includes: Determining remaining storage space of the target storage space; If the remaining storage space is less than or equal to the target space threshold, the target file is sorted according to the default sorting strategy; If the remaining storage space is greater than the target space threshold, a target storage location that is free and has a continuous storage address in the target storage space is determined.
5. The file arrangement method according to claim 4, characterized in that: If the remaining storage space is greater than the target space threshold, determining a target storage location that is free in the target storage space and has a continuous storage address includes: Determining whether there is reserved storage space in the remaining storage space; If the reserved storage space exists, determining a storage location in the reserved storage space that is free and has a continuous storage address as the target storage location; If the reserved storage space does not exist, a storage location with a vacant storage address and a continuous storage address in the remaining storage space is applied as the target storage location.
6. The file arrangement method according to claim 5, characterized in that: If the reserved storage space exists, determining a storage location in the reserved storage space that is free and has a continuous storage address as the target storage location includes: Determining a first number of storage locations required for the target file; Determine storage locations with continuous storage addresses corresponding to a second number of storage locations that is vacant in the target storage space and is greater than the first number of storage locations as target storage locations.
7. The file arrangement method according to claim 1, characterized in that: The step of arranging the target files to the target storage location includes: Determine the initial storage location of the target file; Determining address mapping information between the initial storage location and the target storage location; The target file is sorted to the target storage location according to the address mapping information.
8. A file arrangement device, characterized in that: The device comprises: A determination module, used to determine whether a target file is a fragmented file; The determination module is further used to determine a target storage location that is free and has a continuous storage address in the target storage space if the target file is a fragmented file; The arranging module is used to arrange the target files to the target storage location.
9. A terminal device, characterized in that: The terminal device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps in the file organization method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in the file organization method according to any one of claims 1 to 7.
Citation Information
Cited By
Data defragmentation method and device and readable storage medium
CN121166029A
