File processing method and apparatus, and device and storage medium

By obtaining the configuration parameters of file fragments in the log-structured file system, determining their order and writing them to consecutive locations, the problem of internal file fragmentation caused by off-site updates is solved and system performance is improved.

WO2024212879A1PCT designated stage expired Publication Date: 2024-10-17SHENZHEN TCL NEW-TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/086301
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-14
Filing Date
2024-04-07
Publication Date
2024-10-17

AI Technical Summary

Technical Problem

The internal file fragmentation problem caused by the off-site update mechanism of the existing log-structured file system cannot be effectively alleviated by the existing garbage collection mechanism, affecting the performance of sequential reading and writing.

Method used

By obtaining the configuration parameters of the file fragments, the order of the file fragments is determined, and written to consecutive locations in the target reserved area to ensure the continuity of the file fragments and alleviate internal file fragmentation.

Benefits of technology

It effectively alleviates the internal fragmentation problem of the file system, improves the performance of sequential reading and writing, and reduces IO overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024086301_17102024_PF_FP_ABST
    Figure CN2024086301_17102024_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the present invention are a file processing method and apparatus, and a device and a storage medium. The method comprises: determining a segment sequence of file segments by means of configuration parameters of the file segments; and determining target positions of the file segments in a target reservation region according to the segment sequence of the file segments. In this way, it is ensured that the file segments, which are written into the target reservation region, are continuous, such that the problem of internal fragmentation of a file is mitigated.
Need to check novelty before this filing date? Find Prior Art

Description

File processing method, device, equipment and storage medium

[0001] This application claims priority to Chinese patent application filed on April 14, 2023, with application number 202310410411.7 and application name “File processing method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present invention relates to the technical field of computer information storage, and in particular to a file processing method, device, equipment and storage medium. Background Art

[0003] The Log-Structure File System (LFS) has spawned a variety of file systems, collectively referred to as LFS-type file systems, such as F2FS and NILFS. The key features of these file systems are their off-site update and checkpoint mechanisms. Regardless of whether the underlying storage device is a mechanical hard drive or a Flash memory device, the off-site update mechanism can significantly improve random write performance. Therefore, these file systems are widely used in mobile smart devices.

[0004] The side effect of the out-of-place update mechanism is that compared with other in-place update file systems, the file fragmentation caused by file updates in LFS-type file systems will significantly reduce the performance of sequential reads and writes of the structured file system. Technical issues

[0005] Existing methods mainly alleviate the fragmentation problem of structured file systems through a garbage collection (GC) mechanism. However, this mechanism can only alleviate the external fragmentation of files in the file system, but cannot alleviate the internal fragmentation problem of files. Technical Solutions

[0006] Embodiments of the present invention provide a file processing method, apparatus, device, and storage medium to alleviate the problem of internal file fragmentation in a structured file system.

[0007] In one aspect, an embodiment of the present invention provides a file processing method, the method comprising:

[0008] Obtaining configuration parameters of each file segment in a to-be-processed file, and determining a target reserved area of ​​the to-be-processed file;

[0009] Determining a fragment order of each of the file fragments according to configuration parameters of each of the file fragments;

[0010] Determine the target position of each file fragment in the target reserved area according to the fragment sequence of each file fragment; and write each file fragment into the target position corresponding to each file fragment in the target reserved area.

[0011] In another aspect, an embodiment of the present invention provides a file processing device, comprising:

[0012] An acquisition module, configured to acquire configuration parameters of each file segment in a file to be processed and determine a target reserved area of ​​the file to be processed;

[0013] a fragment sorting module, configured to determine the fragment order of each file fragment according to the configuration parameters of each file fragment; a fragment-sensitive file address mapping module, configured to determine the target position of each file fragment in the target reserved area according to the fragment order of each file fragment;

[0014] The internal anti-fragmentation recycling module is configured to write each of the file fragments to a corresponding target location in the target reserved area. Another aspect of the present invention provides a file processing device comprising a memory and a processor; the memory stores an application program, and the processor is configured to execute the application program in the memory to perform the operations in the above method.

[0015] On the other hand, an embodiment of the present invention provides a storage medium, wherein the storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor to execute the steps in the above method. Beneficial effects

[0016] An embodiment of the present invention provides a file processing method, apparatus, device and storage medium, which relate to the field of computer information storage technology. The method obtains configuration parameters of each file fragment in a to-be-processed file and determines a target reserved area for the to-be-processed file. The fragment order of each file fragment is determined according to the configuration parameters of each file fragment. The target position of each file fragment in the target reserved area is determined according to the fragment order of each file fragment, and each file fragment is written to its corresponding target position in the target reserved area. The embodiment of the present invention determines the fragment order of each file fragment through the configuration parameters of the file fragment, and determines the target position of each file fragment in the target reserved area according to the fragment order of each file fragment. In this way, it is ensured that each file fragment written in the target reserved area is continuous, thereby alleviating the problem of internal fragmentation of the file. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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.

[0018] FIG1 is a schematic diagram of a remote update mechanism of the prior art;

[0019] FIG2 is a schematic diagram of an existing garbage collection mechanism of the prior art;

[0020] FIG3 is a schematic diagram of an embodiment of a file processing method provided by the present invention;

[0021] FIG4 is a schematic diagram of another embodiment of the file processing method provided by the present invention;

[0022] FIG5 is a schematic diagram of an embodiment of a method for determining internal fragmented data provided by the present invention;

[0023] 6 is a schematic diagram of an embodiment of a method for determining a target reserved area of ​​a file to be processed provided by the present invention;

[0024] 7 is a schematic diagram of an embodiment of a method for determining a target position of a file segment in a target reserved area provided by the present invention;

[0025] FIG8 is a schematic diagram of file internal fragmentation processing provided by the present invention;

[0026] FIG9 is a schematic diagram of another embodiment of a file processing method provided by the present invention;

[0027] FIG10 is a schematic diagram of another embodiment of a file processing method provided by the present invention;

[0028] 11 is a schematic diagram of another embodiment of the file processing method provided by the present invention;

[0029] 12 is a schematic diagram of an embodiment of a method for updating a list to be sorted provided by the present invention;

[0030] 13 is a schematic diagram of a file writing structure file system provided by the present invention;

[0031] FIG14 is a schematic diagram of an embodiment of a file processing device provided by the present invention;

[0032] FIG15 is a schematic diagram of an embodiment of a file processing device provided by the present invention. Modes for Carrying Out the Invention

[0033] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work shall fall within the scope of protection of the present invention.

[0034] As described in the background technology, under the off-site update mechanism, when file fragments in files stored in the structured file system are deleted, overwritten, or parameters are updated, it will cause discontinuity of file fragments in the file and discontinuity of free storage areas in the structured file system, resulting in internal file fragmentation and external file fragmentation. Among them, internal file fragmentation is manifested as discontinuity of file fragments in the file, and external file fragmentation is manifested as discontinuity of free storage areas in the structured file system, that is, fragmentation of the remaining space of the structured file system.

[0035] For example, as shown in FIG1 , FIG1 is a schematic diagram of an off-site update mechanism in the prior art. The file structure system shown in FIG1 includes 16 storage areas. As shown in FIG1 (a), in the initial state, file A includes four file fragments A1, A2, A4 and A4, and file A occupies 4 storage areas continuously in the file structure system. File B includes four file fragments B1, B2, B3 and B4, and file B is continuous in the file structure system and occupies 4 storage areas. The storage areas of the remaining space of the structure file system are continuous. When the file fragments A2, B3, A2 and B2 are updated off-site in sequence, , write the updated file fragment A2 into the free storage area 08, write the updated file fragment B3 into the free storage area 09, write the updated file fragment A2 into the free storage area 10, and write the updated file fragment B2 into the free storage area 11. At the same time, the stored file fragments in the storage areas 01, 03, 05 and 06 are erased. As shown in Figure 1 (b), the file fragments of file A and file B are discontinuous, resulting in internal file fragmentation, and the number of storage areas in the remaining space of the structural file system remains unchanged, but the storage areas in the remaining space of the structural file system are discontinuous, resulting in external file fragmentation. And the number of storage areas of the remaining space of the structural file system remains unchanged, but the storage areas of the remaining space of the structural file system are discontinuous, resulting in external file fragmentation. When file A and file B need to be read sequentially, the file fragments of file A and file B are discontinuous, which will increase the number of IO and overhead. At the same time, the storage addresses of the file fragments of file A and file B are out of order, which reduces the performance of sequential addressing storage devices. When the written file C includes 8 file fragments, the file fragment C1 of file C is written into the remaining storage area 12, the file fragment C2 is written into the remaining storage area 13, and the file fragment C3 is written into the remaining storage area 14. The remaining storage area 14 is entered, and the file fragment C4 is written into the remaining storage area 15. When writing the file fragment C5, since there is no free storage area after the storage area 15, it is necessary to traverse the storage area of ​​the structure file system, determine the blank storage area 01 from the storage area of ​​the entire structure file system, write the file fragment C5 into the storage area 01, and write the file fragments C6, C7 and C8 in sequence according to the writing method of the file fragment C5. This increases the number of IO when adding files to write, and as shown in Figure 1 (c), the file fragments of the written C file are discontinuous, resulting in internal file fragmentation.

[0036] In order to alleviate the fragmentation problem of the structured file system, the prior art has designed a garbage collection mechanism. However, the existing garbage collection mechanism can only alleviate the fragmentation of the remaining space of the structured file system, but cannot alleviate the internal fragmentation of the files. For example, as shown in Figure 2, Figure 2 is a schematic diagram of the existing garbage collection mechanism. As shown in Figure (a) in Figure 2, in the existing garbage collection mechanism, the structured system file is divided into four storage segments sec1, sec2, sec3 and sec4, each storage segment includes 4 storage areas, and file A and file B have external file fragmentation and internal file fragmentation; as shown in Figures (b) and (c) in Figure 2, the existing garbage collection mechanism traverses each storage segment and writes the data of the used storage area in each storage segment to the continuous storage segment of the free storage area, so that the storage area of ​​the remaining space in the structured system file is continuous; as shown in Figure (d) in Figure 2, the file fragments of file A and file B in the structured file system after being sorted by the garbage collection mechanism are still discontinuous, which shows that the existing garbage collection mechanism does not alleviate the internal file fragmentation. When file A and file B need to be read sequentially, due to the internal file fragmentation of file A and file B, the IO number and overhead will increase, causing the performance of sequential addressing storage devices to decline.

[0037] Based on this, in order to alleviate the problem of internal file fragmentation, an embodiment of the present invention provides a file processing method, device, equipment and storage medium, which determines the fragment order of each file fragment through the configuration parameters of the file fragment, and determines the target position of each file fragment in the target reserved area according to the fragment order of each file fragment. In this way, it can be ensured that the file fragments written into the target reserved area are continuous, thereby alleviating the problem of internal file fragmentation.

[0038] The implementation details of the technical solution of the embodiment of the present invention are described in detail below:

[0039] As shown in Figure 3, Figure 3 is a schematic diagram of an embodiment of a file processing method provided by an embodiment of the present invention. The method can be executed by an electronic device with data storage and data processing capabilities, such as a server, a smartphone, a tablet computer, a personal computer, etc., without specific limitation herein.

[0040] 3 , the method includes at least steps 301 to 304 , which are described in detail as follows:

[0041] Step 301: Obtain the configuration parameters for each file segment in the pending file and determine the target reserved area for the pending file. In the present invention, the pending file can be a file to be written received by the structured file system. For example, when a file write request is received, a file write operation is triggered, the pending file is obtained, and the file segments of the pending file are traversed to obtain the configuration parameters for each file segment. The pending file includes, but is not limited to, files being written for the first time, file segments or files to be updated, or already written files in the structured file system. The present invention does not limit the type of file to be processed.

[0042] Optionally, in some implementations, when the file writing operation is the first writing of the file, the file to be written is set as the file to be processed, each file segment of the file to be processed is traversed, and the configuration parameters of each file segment are determined.

[0043] Optionally, in other embodiments, when the file write operation is a file fragment update, the file fragment to be updated is obtained, and based on the file identifier of the file fragment to be updated, a written file in the structured file system that is consistent with the file identifier is determined. The file fragment to be updated and the set of file fragments in the written file that is consistent with the file identifier are set as the file to be processed. Each file fragment in the file to be processed is traversed to determine the configuration parameters of each file fragment. A file fragment update represents a data update of at least one file fragment in a file already written in the structured file system. Data updates include, but are not limited to, overwriting file fragments and updating data in file fragments.

[0044] Optionally, in other embodiments, when the file write operation is a file update, the file to be updated is obtained, the file to be updated is set as a pending file, each file segment in the pending file is traversed, and configuration parameters of each file segment are determined. The file update represents overwriting at least one already written file in the structured file system.

[0045] Optionally, in some other embodiments of the present invention, the file to be processed may also be a written file in the structured file system. For example, when a defragmentation request is received, a file defragmentation operation is triggered, a target written file is selected from the structured file system, the selected target written file is set as the file to be processed, and the file fragments of the file to be processed are traversed to obtain the configuration parameters of each file fragment. The target written file may be any written file in the structured file system, or the target written file may be selected from the written files in the structured file system according to preset conditions. The preset conditions include but are not limited to file size, file type, number of file updates, etc.

[0046] In the present invention, the configuration parameters are used to characterize the order of each file fragment in the to-be-processed file, including but not limited to the fragment code, creation time, update time, etc. of each file fragment in the to-be-processed file.

[0047] In the present invention, the target reserved area is a continuous storage area in the structured file system that is allocated for the purpose of storing only the pending files. This area includes, but is not limited to, a persistent storage area and a temporary storage area. The persistent storage area indicates that the target reserved area is used only for storing the pending files, and that free reserved storage areas within the target reserved area are not reclaimed; the temporary storage area indicates that the target reserved area is used only for storing the pending files, and that free reserved storage areas within the target reserved area are reclaimed.

[0048] Reclaiming the free reserved storage area in the target reserved area refers to reclaiming the free reserved storage area in the target reserved area as a free storage area when the remaining space in the structured file system is insufficient, thereby increasing the remaining space in the structured file system. The free storage area in the structured file system refers to the storage space composed of the free storage areas in the structured file system; the free storage area refers to a regular storage area in the structured file system that has no data written to it and does not belong to the reserved area.

[0049] Optionally, in some embodiments of the present invention, the file identifier of the file to be processed can be obtained, and the reserved area in the structured file system that matches the file identifier can be determined as the target reserved area for the file to be processed. The file identifier can be one or more of letters, numbers, and special characters, and the file identifier can be used to characterize the file type of the file to be processed, wherein the file types include but are not limited to video files, text files, audio files, and image files. Exemplarily, the continuous free storage area in the file structure system can be divided into multiple reserved areas, and the preset file type of each reserved area can be determined. When determining the file identifier of the file to be processed, the mapping relationship between the preset file identifier and the file type is queried to obtain the file type of the file to be processed. According to the preset file type corresponding to each reserved area, the reserved area whose preset file type matches the file type of the file to be processed is determined as the target reserved area for the file to be processed.

[0050] Optionally, in other embodiments of the present invention, a continuous free storage area in the storage area of ​​the structured file system can be determined as the target reserved area for the file to be processed through an isolation mechanism. For example, the continuous free storage area in the structured file system can be divided into at least two storage areas: a first storage area and a second storage area. The storage area in the first storage area is set as a regular storage area, and the second storage area is set as the target reserved area for the file to be processed. The isolation mechanism means that when data in the target reserved storage area in the target reserved area is written, updated, or erased, the data in the regular storage area in the first storage area is not affected.

[0051] Step 302: Determine the fragment order of each file fragment according to the configuration parameters of each file fragment.

[0052] The fragment order of the file fragment refers to sorting the file fragments according to the configuration parameters of the file fragments to obtain a file fragment sequence, and the sequence number of the file fragment in the file fragment sequence.

[0053] In some implementations, the file segments may be sorted in descending order of the configuration parameters; or the file segments may be sorted in descending order of the configuration parameters.

[0054] Step 303: Determine the target position of each file segment in the target reserved area according to the segment sequence of each file segment.

[0055] The target location may be the starting address of a free reserved storage area in the target reserved area, or may be the address range of a free reserved storage area in the target reserved area, wherein the address refers to the physical address where the data is stored in the structured file system.

[0056] Optionally, in some implementations, the target position associated with each fragment sequence can be obtained by querying pre-stored data on the relationship between fragment sequences and positions based on the fragment sequence of the file fragments. The target position associated with each fragment sequence is then determined as the target position of the file fragment corresponding to the fragment sequence in the target reserved area. The data on the relationship between fragment sequences and positions includes multiple fragment sequences and the position corresponding to each fragment sequence.

[0057] Optionally, in some other embodiments, a continuous free reserved storage area in the target reserved area can be determined, the fragment order of each file fragment can be traversed, and starting from the first free reserved storage area in the continuous free reserved storage area, the address range or the starting address of the first free reserved storage area can be set as the target position of the file fragment corresponding to the first fragment order in the target reserved area, and the address range or the starting address of the next adjacent free reserved storage area of the first free reserved storage area can be set as the target position of the file fragment corresponding to the second fragment order in the target reserved area until the traversal of the fragment order of each file fragment is completed.

[0058] Among them, the first free reserved storage area can be the free reserved storage area with the lowest address range or starting address in the continuous free reserved storage area.

[0059] Step 304: Write each file fragment into its corresponding target position in the target reserved area.

[0060] In the present invention, after determining the target positions of each file fragment in the target reserved area, each file fragment is written into its corresponding target position in the target reserved area.

[0061] Optionally, in some embodiments, when the file to be processed is a file to be written, according to the fragment order of each file fragment, each file fragment of the file to be processed is sequentially written into the target position corresponding to the file fragment in the target reserved area. For example, when the file to be processed includes four file fragments A1, A2, A3, and A4, and the respective fragment orders corresponding to A1, A2, A3, and A4 are A1 < A2 < A3 < A4, A1, A2, A3, and A4 are sequentially written into the target positions corresponding to A1, A2, A3, and A4 in the target reserved area.

[0062] Optionally, in some embodiments, when the file to be processed is a file that has been written, according to the fragment order of each file fragment, each file fragment corresponding to each fragment order is sequentially copied, and the copied file fragment corresponding to the fragment order is written into the target position of the file fragment corresponding to the fragment order in the target reserved area.

[0063] The file processing method provided by the embodiments of the present invention determines the fragment order of each file fragment through the configuration parameters of the file fragments, and determines the target positions of each file fragment in the target reserved area according to the fragment order of each file fragment. In this way, it can be ensured that the file fragments written into the target reserved area are continuous, thereby alleviating the problem of internal fragmentation of the file.

[0064] Based on the embodiment of FIG3, in order to improve system performance, the fragmentation degree of the files to be processed can be processed first, and the fragmentation process is performed only when the fragmentation degree requirement is met. As shown in FIG4, another embodiment of the file processing method provided by the present application is shown in FIG4. Another embodiment of the file processing method provided by the present application includes at least steps 401 to 406:

[0065] Step 401: Determine internal fragmented data of the file to be processed.

[0066] In this embodiment, the files to be processed that have been written into the structured file system may be files written into the structured file system within the past period of time, wherein the past period of time may be the past day, the past three days, or the past week. In this embodiment, the files to be processed that have been written into the structured file system may also be written files that have been written into the structured file system within the past period of time and that comply with preset rules, wherein the preset rules may be one or more of file labels, file sizes, and file types. For example, when the preset rule is a file label, a written file with a file label that has not undergone internal fragmentation processing may be set as a file to be processed, or a written file with a file label that is a fragmented file may be set as a file to be processed. In this embodiment, the internal fragmentation data is used to characterize the degree of internal fragmentation of the file to be processed, which includes but is not limited to the degree of disorder of the file fragments in the file to be processed and the degree of emptiness of the file fragments.

[0067] In some embodiments of the present invention, the internal fragmentation data of the to-be-processed file can be determined based on the storage addresses of the file segments of the to-be-processed file. Specifically, as shown in FIG5 , the present invention provides a method for determining the internal fragmentation data, which specifically includes the contents of steps 4011 to 4014:

[0068] Step 4011: Obtain the storage address of the file segment of the file to be processed.

[0069] The storage address may be the starting address of the physical address of the file segment in the structured file system, or may be the address range of the physical address of the file segment in the structured file system. In some embodiments, the storage address of the file segment of the to-be-processed file may be directly read from the structured file system; in other embodiments, the logical address of the file segment of the to-be-processed file may be read from the structured file system, and logical storage address mapping information of the to-be-processed file may be obtained. The storage address of the file segment of the to-be-processed file may be obtained based on the logical storage address mapping information of the to-be-processed file. The logical storage address mapping information includes a mapping relationship between logical addresses and storage addresses.

[0070] Optionally, in some embodiments, considering that the internal fragmentation level of the files to be processed that are written to the structured file system for the first time is low, for the files to be processed that are written to the structured file system, and when the file writing operation is the first time the file is written, the files to be processed can be directly written to the remaining space in the structured file system, or the target reserved area of ​​the files to be processed can be determined, and according to the configuration parameters of the file fragments in the files to be written, the file fragments in the files to be processed can be written sequentially into the free reserved storage area in the target reserved area.

[0071] Optionally, in some embodiments, considering that the to-be-processed file is not written to the structured file system for the first time, that is, when the file write operation is a file segment update, internal fragmentation of the file segment of the to-be-processed file may occur due to factors such as the update of the file segment of the to-be-processed file and discontinuous remaining space in the structured file system. Therefore, the storage address of the file segment of the to-be-processed file in the structured file system is obtained, and steps 4012 to 4014 are executed to determine the internal fragmentation data of the to-be-processed file.

[0072] Step 4012: Determine the discrete data of the file to be processed according to the storage address of each file segment.

[0073] The discrete data is used to quantify the disorder degree of the file segments of the file to be processed.

[0074] In some embodiments, the logical address range of the file to be processed can be determined based on the logical address of the file to be processed, and the discrete data of the file to be processed can be obtained based on the logical address range of the file to be processed and the storage addresses of each file fragment. The discrete data can be the number of file fragments whose storage addresses are out of order. For example, when the logical address range of file A is LAB10 to LAB13, and its corresponding storage addresses are PPN10, PPN12, PPN11, and PPN13, and the logical address range of file B is LAB14 to LAB17, and its corresponding storage addresses are PPN14 to PPN17, then the storage addresses of the file fragments with logical addresses LAB11 and LAB12 in file A are out of order, and the discrete data of the file to be processed is determined to be 2; the discrete data of the file to be processed in file B is 0.

[0075] In other embodiments, the discrete data of the file to be processed can be obtained by counting the number of file segments with out-of-order storage addresses in the file to be processed based on the configuration parameters of each file segment and the storage address of each file segment. Specifically, the discrete data determination method includes at least steps 40121 to 40123:

[0076] Step 40121: Determine the fragment order of each file fragment according to the configuration parameters of each file fragment in the file to be processed.

[0077] Step 40122: Determine the storage order of each file fragment according to the storage address of each file fragment in the file to be processed.

[0078] Step 40123: Determine the discrete data of the file to be processed based on the difference information between the storage order of each file fragment and the fragment order.

[0079] Optionally, in some embodiments, the difference information may be the sequence difference or similarity between the storage order and the fragment order of each file fragment. Exemplarily, taking the example of the difference information being the sequence difference between the storage order and the fragment order of each file fragment, for each file fragment, the sequence difference between the storage order and the fragment order of the file fragment may be determined. If the sequence difference is not equal to 0, it is determined that the storage order of the file fragment is inconsistent with the fragment order of the file fragment; if the sequence difference is equal to 0, it is determined that the storage order of the file fragment is consistent with the fragment order of the file fragment; the number of file fragments in the to-be-processed file whose storage order is inconsistent with the fragment order of the file fragment is counted to obtain discrete data of the to-be-processed file. For example, taking the configuration parameter as fragment coding, and the fragment codes corresponding to file fragments A1, A2, A3 and A4 of file A are 001, 002, 003 and 004 respectively, then the fragment orders corresponding to file fragments A1, A2, A3 and A4 of file A are 1, 2, 3 and 4 respectively. When the storage orders corresponding to file fragments A1, A2, A3 and A4 of file A are 4, 3, 2 and 1 respectively, that is, the storage order of each file fragment in file A is inconsistent with the fragment order of the file fragment, then the discrete data 4 of the file to be processed is determined; when the storage orders corresponding to file fragments A1, A2, A3 and A4 of file A are 1, 2, 3 and 4 respectively, that is, the storage order of each file fragment in file A is consistent with the fragment order of the file fragment, then the discrete data 0 of the file to be processed is determined.

[0080] Step 4013: Determine the hole data of the file to be processed based on the status difference information between each file segment and its adjacent file segments.

[0081] The state difference information represents the difference between the state information of each file fragment and the state information of the adjacent file fragments of the file fragment. The hole data quantifies the hole degree of the file to be processed, wherein the hole degree is used to determine whether all file fragments in the file to be processed are stored in a continuous storage area. When the hole degree is not 0, it is determined that all file fragments of the file to be processed are not stored in a continuous storage area. When the hole degree is 0, it is determined that all file fragments of the file to be processed are stored in a continuous storage area. The state information includes the file identifier of the file fragment file and the storage state of the file fragment, wherein the storage state includes stored and idle.

[0082] In step 4013, the status information of each file segment can be compared with the status information of the adjacent file segments of the file segment to determine the status difference information between each file segment and the adjacent file segments of the file segment. The hole data of the file to be processed can be determined based on the status difference information. Specifically, the method for determining the hole data of the file to be processed includes at least steps 40131 to 40133:

[0083] Step 40131: For each file segment, compare the status information of the file segment with the status information of the adjacent file segments of the file segment.

[0084] Step 40132: Determine the number of adjacent file segments that are inconsistent with the status information of the file segment as local hole data of the file segment.

[0085] Step 40133: Obtain the hole data of the file to be processed based on the local hole data of each file segment.

[0086] The adjacent file segment may be a previous file segment adjacent to the file segment, or a subsequent file segment adjacent to the file segment.

[0087] Exemplarily, taking the example of the adjacent file segment being the previous file segment adjacent to the file segment, we can start from the first file segment of the file to be processed, compare the file segment with the status information of the file segment and the status information of the adjacent file segment of the file segment; if the status information of the file segment is consistent with the status information of the adjacent file segment of the file segment, determine that the local hole data of the file segment is 0, and determine the local hole data of the next file segment of the file segment; if the status information of the file segment is inconsistent with the status information of the adjacent file segment of the file segment, set the next adjacent file segment of the adjacent file segment as a new adjacent file, and compare the status information of the file segment to the new adjacent file. If the status information of the file fragment is consistent with the status information of the new adjacent file, the local hole data of the file fragment is determined to be 1, and the local hole data of the file fragment next to the file fragment is determined; if the status information of the file fragment is inconsistent with the status information of the new adjacent file, the status information of the file fragment is continued to be compared with the status information of the next adjacent file fragment of the new adjacent file, and this is repeated until the status information of the new adjacent file is consistent with the status information of the file fragment to be processed, and the number of adjacent file fragments that are inconsistent with the status information of the file fragment is counted to obtain the local hole data, and the local hole data of the file fragment next to the file fragment is determined.

[0088] Optionally, in some implementations, local hole data of each file segment may be aggregated to obtain hole data of the file to be processed.

[0089] Optionally, in other embodiments, local void data of each file segment may be counted to obtain statistical features of the local void data, and the statistical features may be set as the void data of the file to be processed. The statistical features include, but are not limited to, the mean, maximum, and range of the local void data.

[0090] Step 4014: Determine and obtain internal fragmented data of the file to be processed based on the discrete data and the void data of the file to be processed.

[0091] Optionally, in some implementations, discrete data and void data of the file to be processed may be aggregated to obtain internal fragmented data of the file to be processed.

[0092] Optionally, in other implementations, the arithmetic mean or weighted mean of the discrete data and the hole data of the file to be processed may be determined as the internal fragmented data of the file to be processed.

[0093] Optionally, in other embodiments, the weights corresponding to the discrete data and the hole data of the file to be processed can be obtained, and the weighted sum of the discrete data and the hole data of the file to be processed can be obtained based on the discrete data and the hole data of the file to be processed and the weights corresponding to the discrete data and the hole data of the file to be processed. The weighted sum of the discrete data and the hole data of the file to be processed is determined as the internal fragmented data of the file to be processed.

[0094] Step 402: If the internal fragmentation data of the file to be processed is greater than or equal to the preset internal fragmentation threshold, the configuration parameters of each file segment in the file to be processed are obtained, and a target reserved area of ​​the file to be processed is determined.

[0095] In this embodiment, after obtaining the internal fragmentation data of the file to be processed, the internal fragmentation data of the file to be processed can be compared with a preset internal fragmentation threshold. If the internal fragmentation data of the file to be processed is greater than or equal to the preset internal fragmentation threshold, it means that the degree of internal fragmentation of the file to be processed is high. Then, the configuration parameters of each file fragment in the file to be processed are obtained, and the target reserved area of ​​the file to be processed is determined.

[0096] In this embodiment, the target reserved area of ​​the file to be processed can be determined based on the file size, cumulative number of writes, and creation time of the file to be processed. Specifically, as shown in FIG6 , the present invention also provides a method for determining the target reserved area of ​​the file to be processed, including steps 4021 to 4023:

[0097] Step 4021: Determine the modification frequency of the file to be processed within the interval time according to the interval time between the creation time of the file to be processed and the current time and the cumulative number of write times of the file to be processed.

[0098] In some implementations, the modification frequency of the to-be-processed file within the interval duration can be obtained by accumulating the number of writes / interval duration.

[0099] Step 4022: Determine the number of reserved storage areas for the file to be processed based on the modification frequency and the file size of the file to be processed.

[0100] Optionally, in some embodiments, the product of the modification frequency value and the file size of the file to be processed can be used to obtain the storage space size required for the file to be processed, and the storage space size of each preset reserved storage area can be obtained. The number of reserved storage areas for the file to be processed can be obtained by dividing the storage space size by the storage space size of each reserved storage area.

[0101] Optionally, in other embodiments, the preset storage space size of each reserved storage area can be obtained, and the initial number of reserved storage areas for the files to be processed can be obtained by dividing the file size of the files to be processed by the storage space size of each reserved storage area. The number of reserved storage areas can be obtained by (initial number + (initial data volume * value of modification frequency).

[0102] Optionally, in other embodiments, the relationship data between the pre-stored modification frequency and the quantity coefficient can be queried according to the modification frequency to obtain the target quantity coefficient corresponding to the preset modification frequency range in which the modification frequency is located, and the storage space size required for the file to be processed is obtained by multiplying the target quantity coefficient by the file size of the file to be processed, and the storage space size of each preset reserved storage area is obtained. The number of reserved storage areas for the file to be processed is obtained by dividing the storage space size by the storage space size of each reserved storage area; or the storage space size of each preset reserved storage area is obtained. The initial number of reserved storage areas for the file to be processed is obtained by dividing the file size of the file to be processed by the storage space size of each reserved storage area, and the number of reserved storage areas is obtained by (initial number + (initial data volume * target quantity coefficient). In this case, the relationship data between the modification frequency and the quantity coefficient includes multiple preset modification frequency ranges and the quantity coefficient corresponding to each preset modification frequency range.

[0103] Alternatively, in other embodiments, the modification frequency and the file size of the to-be-processed file may be input into a preset prediction model to obtain the number of reserved storage areas for the to-be-processed file. The prediction model may be a mathematical model, such as a linear equation model, an exponential equation model, or the like.

[0104] Step 4023: Determine the target reserved area for the file to be processed according to the number of reserved storage areas for the file to be processed.

[0105] The number of target reserved areas in the target reserved area is greater than or equal to the number of reserved storage areas for the file to be processed.

[0106] Optionally, in some implementations, the same number of continuous free storage areas can be determined from the remaining space of the structured file system based on the number of reserved storage areas for the files to be processed, and the same number of continuous free storage areas can be set as target reserved areas for the files to be processed.

[0107] Optionally, in other embodiments, it can be determined based on the file identifier of the file to be processed whether there is an existing target reserved area associated with the file to be processed; if there is no existing target reserved area associated with the file to be processed, the storage space size of each preset reserved storage area is obtained, and the initial number of reserved storage areas for the file to be processed is obtained by dividing the file size of the file to be processed by the storage space size of each reserved storage area, and the final number of reserved storage areas for the file to be processed is obtained by adding the number of reserved storage areas for the file to be processed to the initial number, and the continuous free storage areas with the same number as the final number in the remaining space of the structural file system are set as the target reserved areas for the file to be processed.

[0108] Optionally, in other embodiments, if there is an existing target reserved area associated with the file to be processed, the number of free reserved storage areas of the existing target reserved area is compared with the number of reserved storage areas of the file to be processed; if the number of free reserved storage areas of the existing target reserved area is greater than or equal to the number of reserved storage areas of the file to be processed, the existing target reserved area associated with the file to be processed is set as the target reserved area of ​​the file to be processed; if the number of free reserved storage areas of the existing target reserved area is less than or equal to the number of reserved storage areas of the file to be processed, the existing target reserved area is updated to obtain the target reserved area of ​​the file to be processed.

[0109] Wherein, updating the existing target reserved area may be to increase the number of free reserved storage areas of the existing target reserved area. In some embodiments, a target number of free storage areas that are continuous with the existing target reserved area from the remaining space of the structured file system may be set as free reserved storage areas to increase the number of free reserved storage areas of the existing target reserved area; in other embodiments, data in used reserved storage areas in the existing target reserved area may be merged or erased to increase the number of free reserved storage areas of the existing target reserved area. Wherein, the target number may be determined based on the difference between the number of free reserved storage areas of the existing target reserved area and the number of reserved storage areas of the files to be processed, for example, the absolute value of the difference is set as the target number, and the sum of the absolute value of the difference and a preset parameter is set as the target number, wherein the preset parameter is a positive integer greater than 1.

[0110] In other embodiments, when the internal fragmentation data of the file to be processed is greater than or equal to a preset internal fragmentation threshold, it can be determined based on the file identifier of the file to be processed whether there is an existing target reserved area associated with the file to be processed; if there is no existing target reserved area associated with the file to be processed, the target reserved area of ​​the file to be processed is determined according to the above steps 4021 to 4023; if there is an existing target reserved area associated with the file to be processed, the target reserved area of ​​the file to be processed is determined based on the number of free reserved storage areas of the existing target reserved area, the file size of the file to be processed, the cumulative number of writes and the creation time.

[0111] Optionally, in some embodiments, when there is an existing target reserved area associated with the file to be processed, the number of free reserved storage areas in the existing target reserved area can be compared with a preset number threshold; if the number of free reserved storage areas in the existing target reserved area is greater than the preset number threshold, the existing target reserved area associated with the file to be processed is set as the target reserved area for the file to be processed; if the number of free reserved storage areas in the existing target reserved area is less than or equal to the preset number threshold, the number of reserved storage areas for the file to be processed is determined according to steps 4021 to 4023 above, and the existing target reserved area is updated according to the number of reserved storage areas for the file to be processed and step 4023 to obtain the target reserved area for the file to be processed. Step 403: Determine the fragment order of each file fragment based on the configuration parameters of each file fragment.

[0112] This embodiment can be understood by referring to the content of step 302 in FIG. 3 , which will not be described in detail here.

[0113] Optionally, in some embodiments of the present invention, after determining the target reserved area of ​​the file to be processed, the file fragments can be sorted in ascending order according to the configuration parameters of each file fragment to obtain the fragment order of each file fragment.

[0114] In other embodiments of the present invention, considering that in the off-site update mechanism, when a certain file fragment in the structured file fragment is updated, the unupdated file fragment will not be erased immediately, but the garbage collection mechanism will be triggered periodically to perform garbage collection on the file fragments that need to be erased in the structured file system. Therefore, there may be at least two file fragments in the structured file system with the same configuration information but different write times. If the fragment order of each file fragment is determined only based on the configuration parameters of each file fragment, the fragment order may be inaccurate. Based on this, in order to improve the accuracy of the fragment order of the file fragments, the fragment order of each file fragment can be determined based on the configuration parameters and write time of each file fragment in the file to be processed. Exemplarily, taking the example of the configuration information including the fragment encoding of the file fragment, the method for determining the fragment order of the file fragment includes at least steps 4031 to 4033:

[0115] Step 4031: Determine whether there is a first file segment with the same segment code among the file segments.

[0116] Step 4032: If there are first file segments with the same segment code, determine the time difference between the writing time of each first file segment and the current time.

[0117] Step 4033: Sort the first file segment and the second file segment with the smallest time difference according to the segment codes to obtain a segment order.

[0118] The second file segment is a file segment other than the first file segment among all the file segments.

[0119] In some implementations, if there are no first file fragments with the same fragment code, the file fragments are sorted in ascending order according to the fragment codes of the file fragments to obtain the fragment order of the file fragments.

[0120] In other embodiments of the present invention, in order to improve the accuracy of the fragment order of file fragments, it can be determined whether each file fragment in the to-be-processed file has a to-be-erased mark. If no to-be-erased mark exists in each file fragment in the to-be-processed file, then the file fragments are sorted in ascending order of numerical values ​​according to the configuration parameters of each file fragment in the to-be-processed file to obtain the fragment order of each file fragment; if there is a to-be-erased mark in the file fragment in the to-be-processed file, the file fragment with the to-be-erased mark is eliminated, and the remaining file fragments are sorted in ascending order of numerical values ​​according to the configuration parameters of each remaining file fragment in the to-be-processed file to obtain the fragment order.

[0121] Step 404: Determine the target position of each file segment in the target reserved area according to the segment sequence of each file segment.

[0122] In this embodiment, after determining the fragment sequence, the target position of each file fragment in the target reserved area can be determined according to the fragment sequence of each file fragment using the method of step 303. The repeated content is not described here.

[0123] In other embodiments of the present invention, after determining the fragment order, a target free reserved storage area in the target reserved area corresponding to the fragment order of each file fragment can be determined based on the storage address of the free reserved storage area in the target reserved area and the fragment order of each file fragment. The storage address of the target free reserved storage area corresponding to the fragment order of each file fragment is set as the target position of the file fragment in the target reserved area. Specifically, as shown in Figure 7, the present invention provides a method for determining the target position of a file fragment in the target reserved area, including the contents of steps 4041 to 4043:

[0124] Step 4041: Obtain the storage address of each target reserved storage area in the target reserved area.

[0125] The target reserved storage area refers to an idle reserved storage area in the target reserved area.

[0126] Step 4042: Determine the storage order of each target reserved storage area according to the storage address of each reserved storage area.

[0127] In some implementations, the target reserved storage areas may be sorted in ascending order based on the storage addresses of the target reserved storage areas, and the storage order of the target reserved storage areas may be determined based on the sorted target reserved storage areas. In step 4043, for each file segment, the storage address of the target reserved storage area having the same storage order as the segment order of the file segment is determined as the target location of the file segment in the target reserved area.

[0128] In some embodiments of the present invention, after determining the target location of each file segment in the target reserved area, the file segments are written to their corresponding target locations in the target reserved area based on the target location of each file segment in the target reserved area. Step 405: Write each file segment to its corresponding target location in the target reserved area.

[0129] This embodiment can be understood by referring to step 304 in FIG. 3 , and repeated details are not repeated here.

[0130] In this embodiment, when the file to be processed is a file to be written into the structured file system, each file segment is written into the target position of the file segment in the target reserved area according to the target position of each file segment in the target reserved area.

[0131] Optionally, in other embodiments, when the file to be processed is a file that has been written in the structured file system, the storage address of the file fragment of the file to be processed is obtained, and each file fragment is synchronized to the target position of the file fragment in the target reserved area based on the storage address of each file fragment and the target position of each file fragment in the target reserved area.

[0132] Optionally, in some embodiments, based on the target position of each file fragment in the target reserved area, a mapping can be established between the logical address of each file fragment and the target position of the file fragment in the target reserved area, the storage address of each file fragment can be updated, and each file fragment can be written to its corresponding target position in the target reserved area.

[0133] Optionally, in other embodiments, the storage address of each file fragment can be obtained based on the target position of each file fragment in the target reserved area, the offset position of each file fragment can be determined based on the storage address of each file fragment and the target position of the file fragment in the target reserved area, and according to the offset position of each file fragment, each file fragment can be copied to obtain a copied file fragment of each file fragment, and the copied file fragment of each file fragment can be written to the target position of the file fragment in the target reserved area according to the offset position of the file fragment.

[0134] In other embodiments of the present invention, considering that rewriting all file fragments in the to-be-processed file will result in a large amount of data and increase the workload, and when the to-be-processed file is a file that has already been written in the structured file system, the storage addresses of some file fragments in the to-be-processed file are the same as the target positions of the file fragments in the target reserved area. If these file fragments are also rewritten, the write operation will be invalid and the workload will increase. Therefore, in order to reduce the amount of data written to the target reserved area by the file fragments, an embodiment of the present invention determines the offset position of each file fragment based on the storage address of each file fragment and the target position of the file fragment in the target reserved area, selects the target file fragment to be moved based on the offset position, and writes the target file fragment to the target position of the target file fragment in the target reserved area. Specifically, the method for writing file fragments to the target reserved area includes steps 4051 to 4053:

[0135] Step 4051, obtain the storage address of each file segment.

[0136] Step 4052: Determine the offset position of each file segment based on the storage address of each file segment and the target position in the target reserved area.

[0137] The offset position represents the position difference between the storage address of each file segment and the target position of the file segment in the target reserved area.

[0138] Step 4053: Write the target file segment whose offset position is greater than the preset offset position into the target position corresponding to the target file segment in the target reserved area.

[0139] Optionally, in some embodiments, for each file segment, the offset position of the file segment is compared with a preset offset position; if the offset position of the file segment is less than or equal to the preset offset position, it indicates that the storage address of the file segment is the same as the target position of the file segment in the target reserved area, and the file segment does not need to be processed, then it is determined whether the offset position of the next file segment to be processed is greater than the preset offset position; if the offset position of the file segment is greater than the preset offset position, it indicates that the storage address of the file segment is different from the target position of the file segment in the target reserved area, and the file segment needs to be processed, then the file segment is set as the target file segment; each target file segment is synchronized to the target position of the target file segment in the target reserved area, so as to write the target file segment to the target position corresponding to the target file segment in the target reserved area.

[0140] Exemplarily, as shown in FIG8 , FIG8 is a schematic diagram of the internal file fragmentation processing of an embodiment of the present invention, for file segments A1, A2, A3 and A4 of file A, wherein, as shown in FIG8 (a), file segments A2, A3 and A4 are stored in the existing target reserved area of ​​file A, and the storage addresses of file segments A2, A3 and A4 are disordered, and file segment A1 is stored in the regular storage area in the structured file system, that is, the internal fragmentation degree of file A is relatively large, then the target reserved area of ​​file A to be determined according to the above steps 4021 to 4023, and the target positions of file segments A1, A2, A3 and A4 in the target reserved area are determined according to the above steps 4041 to 4043, and file segments A1, A2, A3 and A4 are synchronized to file segment A1 in sequence according to the above steps 4051 to 4053. , A2, A3 and A4 are respectively at the target position of the target reserved area, as shown in (b) of Figure 8, the file fragment A1 in the storage area 00 is synchronized to the target position Y00 in the target reserved area, the file fragment A2 at the position Y05 in the target reserved area is synchronized to the target position Y01 in the target reserved area, the file fragment A3 at the position Y06 in the target reserved area is synchronized to the target position Y02 in the target reserved area, and the file fragment A2 at the position Y04 in the target reserved area is synchronized to the target position Y03 in the target reserved area; at the same time, the file fragments of the storage area 00, the target reserved area Y05, the target reserved area Y06 and the target reserved area Y04 are respectively erased, so that the file fragments A1, A2, A3 and A4 are continuously stored in the target reserved area in the fragment order, as shown in (c) of Figure 8.

[0141] Optionally, in some embodiments of the present invention, after writing each target file segment in the pending file to its target location in the target reserved area, the target file segments not at the target location in the pending file can be erased to increase the remaining space in the structured file system. Alternatively, a to-be-erased flag can be set for the target file segments not at the target location in the pending file, so that the next time the garbage collection mechanism is triggered, the target file segments carrying the to-be-erased flag will be erased. Optionally, in some embodiments of the present invention, after writing each file segment to its corresponding target location in the target reserved area, if it is detected that a file segment in the pending file needs to be updated, the update can be performed using an in-place update mechanism. For example, when file segment A1 in the pending file needs to be updated, the received to-be-updated file segment A1 can be newly written to the target location M1 in the target reserved area where file segment A1 is located, overwriting file segment A1 at target location M1. Optionally, in some embodiments of the present invention, after writing each file segment to its corresponding target location in the target reserved area, if it is detected that a file segment in the pending file needs to be updated, the update can be performed using a remote update mechanism. For example, when the file segment A1 in the file to be processed needs to be updated, the received file segment A1 to be updated can be newly written into the first free reserved storage area in the free reserved storage area in the target reserved area, and the file segment A1 stored at the target position M1 in the target reserved area can be erased, and steps 404 and 405 are executed to write the file segment A1 to be updated into the target position M1.

[0142] Step 406, after step 401, if the internal fragmentation data of the to-be-processed file is less than the preset internal fragmentation threshold, the to-be-processed file to be written into the structured file system is written into the structured file system, or the to-be-processed file already written into the structured file system is not processed.

[0143] Writing the file to be processed into the structured file system may be writing the file to be processed into the remaining space in the structured file system, or may be writing the file to be processed into an idle reserved storage area in the target reserved area in the structured file system. It is understandable that when the internal fragmentation of the file to be processed is low, writing the file to be processed into the target reserved area in the structured file system does not mean writing each file fragment of the file to be processed into its corresponding target location in the target reserved area.

[0144] In an embodiment of the present invention, whether to perform internal fragmentation processing on a file to be processed is determined through the internal fragmentation data of the file. When internal fragmentation processing is required for the file to be processed, a target reserved area is determined based on the file size, creation time and cumulative number of writes, and each file fragment is written into the target reserved area based on the offset position of each file fragment in the file to be processed, so that each file fragment of the file to be processed is arranged in a continuous order in the target reserved area, thereby reducing the internal fragmentation of the file and alleviating the problem of internal file fragmentation.

[0145] Based on the embodiment shown in FIG3 , in order to improve system performance and reduce IO consumption when reading files that need to be read sequentially, before obtaining the configuration parameters of each file segment in the to-be-processed file, the file type can be determined based on the file attribute information of the to-be-processed file. When the file type is a preset target type, the target reserved area of ​​the to-be-processed file can be determined. As shown in FIG9 , FIG9 is a schematic diagram of another embodiment of the file processing method provided by the present application. The another embodiment of the file processing method provided by the present application shown in FIG9 can include the following steps:

[0146] Step 901: Determine the file attribute information of the file to be processed.

[0147] The file attribute information includes, but is not limited to, file size, internal fragmentation data, number of file writes, file read size, and file read parameters. The file read parameters include the number of times the file to be processed is read according to the target read method. The target read method includes sequential read.

[0148] In some implementations, internal fragmented data of the to-be-processed file may be determined according to steps 4011 to 4014 above, which will not be described in detail herein.

[0149] Step 902: Determine the file type of the file to be processed based on the file attribute information.

[0150] File types include, but are not limited to, fragile files, fragmentation-sensitive files, non-fragmentation-sensitive files, and normal files. A normal file is a file that is neither fragile nor fragmentation-sensitive. A fragile file is a file with discontinuous storage addresses, and a fragmentation-sensitive file is a file that requires sequential reading.

[0151] In some embodiments, in fragile file identification, whether the file type of the to-be-processed file is a fragile file can be determined based on the file size, internal fragmentation data, and the number of times the file is written. Specifically, the fragile file identification method includes steps 9021A to 9022A:

[0152] Step 9021A: compare the file size with a first preset file size threshold, compare the internal fragmentation data with a preset first fragmentation threshold, and compare the file write count with a preset file write count threshold.

[0153] In some embodiments, the file size, internal fragmentation data, and file write count of the file to be processed can be compared with their respective corresponding thresholds respectively. For example, the file size can be compared with a first preset file size threshold, the internal fragmentation data can be compared with a preset first fragmentation threshold, and the file write count can be compared with a preset file write count threshold in parallel.

[0154] In other embodiments, the file size, file write count, and internal fragmentation data of the file to be processed may be compared with their respective corresponding thresholds in sequence. For example, the file size of the file to be processed is compared with a first preset file size threshold. If the file size of the file to be processed is less than the first preset file size threshold, the file type of the file to be processed is determined to be a non-fragile file. If the file size of the file to be processed is greater than or equal to the first preset file size threshold, the file write count is compared with a preset file write count threshold. If the file write count is less than the preset file write count threshold, the file type of the file to be processed is determined to be a non-fragile file. If the file write count is greater than or equal to the preset file write count threshold, the internal fragmentation data is compared with a preset first fragmentation threshold. If the internal fragmentation data is less than the preset first fragmentation threshold, the file type of the file to be processed is determined to be a non-fragile file. If the internal fragmentation data is greater than or equal to the preset first fragmentation threshold, the file type of the file to be processed is determined to be a fragile file.

[0155] Step 9022A: If the file size is greater than or equal to the preset file size threshold, the internal fragmentation data is greater than or equal to the preset first fragmentation threshold, and the number of file writes is greater than or equal to the preset file write number threshold, then the file type of the file to be processed is determined to be a fragile file.

[0156] In this embodiment, if the file to be processed meets one or more of the following conditions, the file type of the file to be processed is determined to be a non-fragile file: the file size is less than a preset file size threshold, the internal fragmentation data is less than a preset first fragmentation threshold, and the number of file writes is less than a preset file write number threshold.

[0157] In other embodiments, it is possible to query whether the file to be processed carries a fragile file mark. If the file to be processed carries a fragile file mark, the file type is determined to be a fragile file; if the file to be processed does not carry a fragile file mark, the fragile file determination method shown in steps 9021A to 9022A above is executed to determine the file type of the file to be processed. In some embodiments, in fragmented file identification, whether the file type is a fragmentation-sensitive file is determined based on the file size, internal fragmentation data, file read size, and file read parameters. Specifically, the fragmentation-sensitive file determination method includes steps 9021B to 9022B:

[0158] Step 9021B, compare the file size with the second preset file size threshold, compare the file read size with the preset file read size threshold, compare the internal fragmentation data with the preset second fragmentation threshold, and compare the file read parameters with the preset read parameters.

[0159] Step 9022B: If the file size is greater than or equal to the second preset file size threshold, the file read size is greater than or equal to the preset file read size threshold, the internal fragmentation data is greater than or equal to the preset second fragmentation threshold, and the file read parameter is greater than or equal to the preset read parameter, then the file type of the file to be processed is determined to be a fragile and sensitive file.

[0160] In this embodiment, if the file to be processed meets one or more of the following conditions, the file type of the file to be processed is determined to be a non-fragmentation sensitive file: the file size is less than the second preset file size threshold, the file read size is less than the preset file read size threshold, the internal fragmentation data is less than the preset second fragmentation threshold, and the file read parameter is less than the preset read parameter.

[0161] In some embodiments, it is possible to query whether the file to be processed carries a fragmentation-sensitive file mark. If the file to be processed carries the fragmentation-sensitive file mark, the file type is determined to be a fragmentation-sensitive file; if the file to be processed does not carry the fragmentation-sensitive file mark, the fragmentation-sensitive file determination method shown in steps 9021B to 9022B above is executed to determine the file type of the file to be processed.

[0162] It should be noted that the embodiments of the present invention do not limit the specific values ​​of the preset first file size threshold, the preset first fragmentation threshold, the preset file write count threshold, the preset second file size threshold, the preset second fragmentation threshold, the preset reading parameters, and the preset file read size threshold, and can be set according to the specific application scenario.

[0163] In some embodiments, for a file to be processed, steps 9021A to 9022A and steps 9021B to 9022B may be executed in parallel to determine the file type of the file to be processed. Steps 9021A to 9022A and steps 9021B to 9022B may be executed in a preset execution order to determine the file type of the file to be processed. For example, the fragile file identification results of steps 9021A to 9022A may be first executed, and then the fragmentation-sensitive file identification results of steps 9021B to 9022B may be executed to obtain the fragmentation-sensitive file identification results. The file type of the file to be processed may be determined based on the fragile file identification results and the fragmentation-sensitive file identification results. Alternatively, steps 9021B to 9022B may be executed first to obtain the fragmentation-sensitive file identification results, and then steps 9021A to 9022A may be executed to obtain the fragile file identification results. The file type of the file to be processed may be determined based on the fragile file identification results and the fragmentation-sensitive file identification results. The fragile file identification result indicates whether the file to be processed is a fragile file, and the fragmentation-sensitive file identification result indicates whether the file to be processed is a fragmentation-sensitive file.

[0164] Step 903: If the file type is a preset target type, then the configuration parameters of each file segment in the to-be-processed file are obtained, and a target reserved area of ​​the to-be-processed file is determined.

[0165] The target type includes at least one of a fragile file and a fragment-sensitive file.

[0166] In some implementations, if the file type is a preset target type, reference may be made to steps 4021 to 4023 in FIG. 6 for understanding, which will not be described in detail here.

[0167] Step 904: Determine the fragment order of each file fragment according to the configuration parameters of each file fragment.

[0168] This embodiment can be understood by referring to the content of step 403 in FIG. 4 , which will not be described in detail here.

[0169] Step 905: Determine the target position of each file segment in the target reserved area according to the segment sequence of each file segment.

[0170] This embodiment can be understood by referring to the content of step 404 in FIG. 4 , and will not be described in detail here.

[0171] Step 906: Write each file segment into its corresponding target location in the target reserved area.

[0172] This embodiment can be understood by referring to step 405 in FIG. 4 , and repeated details are not repeated here.

[0173] Step 907: After step 902, if the file type is not the target type, the pending file to be written into the structured file system is written into the structured file system, or the pending file already written into the structured file system is not processed.

[0174] In some implementations, when the file to be processed is a file that has been written into the structured file system, if the file type of the file to be processed is not a preset target type, internal fragmentation processing is not performed on the file to be processed.

[0175] In other embodiments, when the file to be processed is a file to be written to a structured file system, if the file type of the file to be processed is not a preset target type, the file to be processed is written to the remaining space in the structured file system through an off-site update mechanism, or the file to be processed is written to the target reserved area of ​​the file to be processed through an off-site update mechanism, or the file to be processed is written to the remaining space in the structured file system through an in-place update mechanism, or the file to be processed is written to the target reserved area of ​​the file to be processed through an in-place update mechanism.

[0176] In an embodiment of the present invention, the file type of the file to be processed is determined based on file attribute information. When the file type of the file to be processed is a preset target type, the target reserved area of ​​the file to be processed is determined to perform internal fragmentation processing. In this way, internal fragmentation processing can be performed on the file to be processed whose internal fragmentation data is less than the preset internal fragmentation threshold but requires sequential reading, thereby reducing the IO consumption of such files when reading the files, thereby improving the performance of the storage device.

[0177] Based on the embodiment shown in FIG3, in order to further improve system performance and reduce the workload of the structured file system, the file type of the to-be-processed file can be first determined according to the above-mentioned method for determining fragile files and the method for determining fragment-sensitive files. When the file type of the to-be-processed file is a preset target type, whether to perform internal fragmentation processing is determined based on the internal fragmentation data of the processed file. In this way, through two rounds of screening based on file type and internal fragmentation data, the number of to-be-processed files that require internal fragmentation processing is reduced, thereby reducing the workload of the structured file system. As shown in FIG10, FIG10 is another embodiment of the file processing method provided by the present application, which may include the following steps:

[0178] Step 1001: Determine the file attribute information of the file to be processed.

[0179] File attribute information includes, but is not limited to, file size, internal fragmentation data, file write count, file read size, and file read parameters. The file read parameters include the number of times the file to be processed is read according to a target read method. The target read method includes sequential read.

[0180] In some implementations, internal fragmented data of the to-be-processed file may be determined according to steps 4011 to 4014 above, which will not be described in detail herein.

[0181] Step 1002: Determine the file type of the file to be processed based on the file attribute information.

[0182] File types include, but are not limited to, fragile files, fragmentation-sensitive files, non-fragmentation-sensitive files, and normal files. A normal file is a file that is neither fragile nor fragmentation-sensitive. A fragile file is a file with discontinuous storage addresses, and a fragmentation-sensitive file is a file that requires sequential reading.

[0183] In this embodiment, the file type of the to-be-processed file may be determined by referring to step 902 in FIG. 9 , which will not be described in detail here.

[0184] Step 1003: If the file type is a preset target type and the internal fragmentation data of the file to be processed is greater than or equal to the preset internal fragmentation threshold, the configuration parameters of each file segment in the file to be processed are obtained, and the target reserved area of ​​the file to be processed is determined.

[0185] In some embodiments, if the file type is a preset target type, the internal fragmentation data in the file attribute information of the file to be processed is compared with the preset internal fragmentation threshold. If the internal fragmentation data of the file to be processed is greater than or equal to the preset internal fragmentation threshold, the configuration parameters of each file fragment in the file to be processed are obtained and the target reserved area of ​​the file to be processed is determined.

[0186] In some implementations, if the file type is a preset target type and the internal fragmentation data of the file to be processed is greater than or equal to a preset internal fragmentation threshold, refer to steps 4021 to 4023 in FIG. 6 for understanding, which will not be described in detail here.

[0187] Step 1004: Determine the fragment order of each file fragment according to the configuration parameters of each file fragment.

[0188] This embodiment can be understood by referring to step 403 in FIG. 4 , and repeated details are not repeated here.

[0189] Step 1005: Determine the target position of each file segment in the target reserved area according to the segment sequence of each file segment.

[0190] This embodiment can be understood by referring to step 404 in FIG. 4 , and repeated details are not repeated here.

[0191] Step 1006: Write each file segment into its corresponding target location in the target reserved area.

[0192] This embodiment can be understood by referring to step 405 in FIG. 4 , and repeated details are not repeated here.

[0193] Step 1007, after step 1002, if the internal fragmentation data of the file to be processed is less than the preset internal fragmentation threshold, and / or the file type is not the target type, the file to be processed to be written into the structured file system is written into the structured file system, or the file to be processed that has been written into the structured file system is not processed.

[0194] In some embodiments, when the file to be processed is a file that has been written in the structured file system, if the internal fragmentation data of the file to be processed is less than a preset third fragmentation threshold, or the file type of the file to be processed is not a preset target type, internal fragmentation processing is not performed on the file to be processed.

[0195] In other embodiments, when the file to be processed is a file to be written to a structured file system, if the internal fragmentation data of the file to be processed is less than a preset internal fragmentation threshold, or the file type of the file to be processed is not a preset target type, the file to be processed is written to the remaining space in the structured file system through an off-site update mechanism, or the file to be processed is written to the target reserved area of ​​the file to be processed through an off-site update mechanism, or the file to be processed is written to the remaining space in the structured file system through an in-place update mechanism, or the file to be processed is written to the target reserved area of ​​the file to be processed through an in-place update mechanism.

[0196] In an embodiment of the present invention, whether to perform internal fragmentation processing on a file to be processed is determined based on the file type of the file to be processed and the internal fragmentation data. In this way, internal fragmentation processing may not be performed on a file to be processed that is only a fragile file type but does not require sequential reading, thereby reducing the workload of the structural file system and improving system stability.

[0197] Based on the embodiment shown in Figure 3, in order to improve system performance and improve the processing efficiency of the structured file system during the fragmentation processing, and at the same time reduce the workload of the structured file system, the files to be processed can be obtained from a pre-established list to be sorted, and whether to perform internal fragmentation sorting can be determined based on the internal fragmentation data of the files to be processed. In this way, it is only necessary to determine whether to perform fragmentation processing based on the internal fragmentation data of the files to be processed in the list to be sorted, thereby improving the processing efficiency of the structured file system during the fragmentation processing, and screening can be performed based on the two conditions of the list to be sorted and the internal fragmentation data of the files to be processed, thereby reducing the number of files to be processed and achieving the effect of reducing the workload of the structured file system.

[0198] As shown in FIG11 , FIG11 is a schematic diagram of another embodiment of the file processing method provided by the present application. The another embodiment of the file processing method provided by the present application shown in FIG11 may include the following steps:

[0199] Step 1101 , traverse a pre-stored list to be sorted, set a file currently traversed in the pre-stored list to be sorted as a file to be processed, and determine internal fragmented data of the file to be processed.

[0200] In some embodiments, the files stored in the to-be-organized list are files carrying a fragmentation-sensitive file flag and / or a fragile file flag, wherein the fragmentation-sensitive file flag is used to indicate that the file type is a fragmentation-sensitive file, and the fragile file flag is used to indicate that the file type is a fragile file.

[0201] Optionally, when receiving a file write request, the structured file system obtains the file attribute information of the file to be written corresponding to the file write request, determines the file type based on the file attribute information of the file to be written, and when the file type is a fragment-sensitive file and / or a fragile file, marks the file to be written and updates the to-be-organized list. Specifically, as shown in Figure 12, Figure 12 is a schematic diagram of an embodiment of a method for updating a to-be-organized list provided in an embodiment of the present application, and the illustrated method for updating a to-be-organized list includes steps 1201 to 1205:

[0202] Step 1201: In response to a file write request, obtain file attribute information of the file to be written corresponding to the file write request. The file attribute information includes, but is not limited to, file size, internal fragmentation data, number of file writes, file read size, and file read parameters. The file read parameters include the number of times the file to be written is read according to a target read mode. The target read mode includes sequential read.

[0203] In some implementations, the internal fragmented data to be written into the file may be determined according to steps 4011 to 4014 above, which will not be described in detail here.

[0204] Step 1202: Determine the file type of the file to be written based on the file attribute information of the file to be written.

[0205] File types include, but are not limited to, fragile files, fragmentation-sensitive files, non-fragmentation-sensitive files, and normal files. A normal file is a file that is neither fragile nor fragmentation-sensitive. A fragile file is a file with discontinuous storage addresses, and a fragmentation-sensitive file is a file that requires sequential reading.

[0206] In this embodiment, the file type of the file to be written can be determined by referring to step 902 in FIG. 9 , which will not be described in detail here.

[0207] Step 1203: If the file type of the file to be written is the preset target type, the file to be written is marked.

[0208] In some implementations, if the file type of the file to be written is a fragile file, the file to be written is marked as a fragile file; if the file type of the file to be written is a fragmentation-sensitive file, the file to be written is marked as a fragmentation-sensitive file.

[0209] Step 1204: write the marked file to be written into the target reserved area of ​​the structured file system, and add the file identifier of the marked file to be written into the pre-stored list to be sorted.

[0210] In some embodiments, when writing the marked file to be written into the target reserved area of ​​the structured file system, the target reserved area for the file to be written can be determined based on the file size, cumulative number of writes, and creation time of the file to be written, referring to the contents of steps 4021 to 4023 in Figure 6, and the file to be written into the target reserved area. No further details will be given here.

[0211] In some embodiments, when writing the marked file to be written into the target reserved area of ​​the structured file system, it is determined whether there is an existing target reserved area associated with the file to be written in the structured file system. If there is no existing target reserved area associated with the file to be written, refer to the contents of steps 4021 to 4023 in Figure 6 to determine the target reserved area for the file to be written, which will not be repeated here. If there is an existing target reserved area associated with the file to be written, it is determined whether the file to be written carries a fragile file mark. If the file to be written does not carry a fragile file mark, the file to be written is written to the remaining space of the structured file system.

[0212] For example, as shown in FIG13 , FIG13 is a schematic diagram of a file writing structure file system provided by an embodiment of the present invention. As shown in FIG13 (a), when updating the file segment A2 of file A, since the file segments A1, A2, A3 and A4 storage areas of file A in the regular storage area are not continuous and the file segments are out of order, file A is marked as a fragile file; when updating the file segment A2 of file A, since there is no associated existing target area for file A, the target reserved area to be written to the file is determined according to the contents of steps 4021 to 4023 in FIG6 , as shown in FIG13 (b), the updated file segment A2 is written to the target reserved area Y00, and the file segment A2 in the storage area 01 is erased; as shown in FIG12 (c), When the file segments A3, A4, and A2 of file A are updated in sequence, the updated file segment A3 is written into the target reserved area Y01, the updated file segment A4 is written into the target reserved area Y02, and the file segment A2 that is updated again is written into the target reserved area Y03; and the file segment A3 in the storage area 10, the file segment A4 in the storage area 08, and the file segment A2 in the target reserved area Y00 are erased, as shown in Figure (d) of Figure 13; as shown in Figure (e) of Figure 13, when the file segments A4, A2, and A3 of file A are updated again in sequence, the file segment A4 that is updated again is written into the target reserved area Y04, the file segment A2 that is updated again is written into the target reserved area Y05, and the file segment A3 that is updated again is written into the target reserved area Y06. As shown in Figure 13, the file processing method provided by the present invention, after allocating the target reserved area to file A, the update behavior of the file fragments in the subsequent file A will not affect the outside of the target reserved area, thereby alleviating the problem of residual space fragmentation caused by file updates in the structured file system, that is, alleviating the problem of external file fragmentation caused by file updates in the structured file system.

[0213] Step 1205: After step 1202, if the file type of the file to be written is not the preset target type, the file to be written is written into the structured file system.

[0214] In this embodiment, for a file to be written that carries a fragile file mark and / or a fragmentation-sensitive file mark, a continuous target reserved area is allocated to the file to be written, and the file to be written is written into the target reserved area, which can effectively alleviate the problem of external file fragmentation caused by updating and writing the file to be written.

[0215] In some implementations, the contents of step 406 in FIG. 4 may be referred to for writing the file to be written into the structured file system, which will not be described in detail here.

[0216] Step 1102 : If the internal fragmentation data of the file to be processed is greater than or equal to a preset internal fragmentation threshold, the configuration parameters of each file segment in the file to be processed are obtained, and a target reserved area of ​​the file to be processed is determined.

[0217] In some implementations, if the internal fragmentation data of the file to be processed is greater than or equal to a preset internal fragmentation threshold, refer to steps 4021 to 4023 in FIG. 6 for understanding, which will not be described in detail here.

[0218] Step 1103: Determine the fragment order of each file fragment according to the configuration parameters of each file fragment.

[0219] This embodiment can be understood by referring to step 403 in FIG. 4 , and repeated details are not repeated here.

[0220] Step 1104 : Determine the target position of each file segment in the target reserved area according to the segment sequence of each file segment.

[0221] This embodiment can be understood by referring to step 404 in FIG. 4 , and repeated details are not repeated here.

[0222] Step 1105: Write each file segment into its corresponding target location in the target reserved area.

[0223] This embodiment can be understood by referring to step 405 in FIG. 4 , and repeated details are not repeated here.

[0224] Step 1106: After step 1101, if the internal fragmentation data of the to-be-processed file is less than a preset internal fragmentation threshold, the file identifier of the to-be-processed file is removed from the pre-stored to-be-processed list, and the next file in the pre-stored to-be-processed list is traversed. This embodiment of the present invention only requires determining whether to perform fragmentation processing based on the internal fragmentation data of the to-be-processed file in the to-be-processed list, thereby improving the processing efficiency of the structured file system during the fragmentation processing process. Furthermore, based on the two conditions of the to-be-processed list and the internal fragmentation data of the to-be-processed file, the number of to-be-processed files is reduced, thereby reducing the workload of the structured file system.

[0225] To better implement the file processing method provided in the embodiment of the present invention, based on the embodiment of the file processing method, the embodiment of the present invention provides a file processing device. Specifically, as shown in FIG14 , FIG14 is a schematic structural diagram of the file processing device provided in the embodiment of the present invention. The file processing device shown includes:

[0226] The acquisition module 1401 is used to acquire the configuration parameters of each file segment in the file to be processed and determine the target reserved area of ​​the file to be processed;

[0227] The fragment sorting module 1402 is used to determine the fragment order of each file fragment according to the configuration parameters of each file fragment;

[0228] The fragment-sensitive file address mapping module 1403 is used to determine the target location of each file fragment in the target reserved area according to the fragment sequence of each file fragment;

[0229] The internal anti-fragmentation recovery module 1404 is configured to write each file fragment into its corresponding target location in the target reserved area.

[0230] In some embodiments, the configuration parameters include fragment codes of the file fragments; a fragment sorting module 1402 is used to determine whether there is a first file fragment with the same fragment code in each file fragment; if there is a first file fragment with the same fragment code, then determine the time difference between the write time of each first file fragment and the current time; according to the fragment code, the first file fragment and the second file fragment with the smallest time difference are sorted to obtain a fragment order; the second file fragment is the file fragment in each file fragment except the first file fragment.

[0231] In some embodiments, the fragment-sensitive file address mapping module 1403 is used to obtain the storage addresses of each target reserved storage area in the target reserved area; determine the storage order of each target reserved storage area based on the storage addresses of each target reserved storage area; for each file fragment, determine the storage address of the target reserved storage area whose storage order is the same as the fragment order of the file fragment as the target position of the file fragment in the target reserved area.

[0232] In some embodiments, the internal anti-fragmentation recovery module 1404 is configured to obtain the storage address of each file fragment; determine the offset position of each file fragment based on the storage address of each file fragment and the target position in the target reserved area; the offset position represents the position difference between the storage address of each file fragment and the target position of the file fragment in the target reserved area; and for a target file fragment whose offset position is greater than a preset offset position, write the target file fragment to the target position of the target file fragment in the target reserved area.

[0233] In some implementations, the acquisition module 1401 is configured to determine a target reserved area for the file to be processed based on the file size, cumulative number of writes, and creation time of the file to be processed.

[0234] In some embodiments, the acquisition module 1401 is used to determine the modification frequency of the file to be processed within the interval time based on the interval time between the creation time of the file to be processed and the current time, and the cumulative number of writes to the file to be processed; determine the number of reserved storage areas for the file to be processed based on the modification frequency and the file size of the file to be processed; determine the target reserved area for the file to be processed based on the number of reserved storage areas for the file to be processed, and the number of target reserved storage areas in the target reserved area is greater than or equal to the number of reserved storage areas for the file to be processed.

[0235] In some embodiments, the file processing apparatus further comprises:

[0236] The first judgment module 1405 is used to determine the internal fragmentation data of the file to be processed; if the internal fragmentation data of the file to be processed is greater than or equal to the preset internal fragmentation threshold, the configuration parameters of each file segment in the file to be processed are obtained and the target reserved area of ​​the file to be processed is determined.

[0237] In some embodiments, the first judgment module 1405 is used to obtain the storage address of the file fragments of the file to be processed; determine the discrete data of the file to be processed based on the storage address of each file fragment; determine the void data of the file to be processed based on the status difference information between each file fragment and the adjacent file fragments of the file fragment; and determine the internal fragmented data of the file to be processed based on the discrete data and void data of the file to be processed.

[0238] In some embodiments, the first judgment module 1405 is used to compare, for each file fragment, the status information of the file fragment with the status information of the adjacent file fragments of the file fragment; determine the number of adjacent file fragments that are inconsistent with the status information of the file fragment as the local hole data of the file fragment; and obtain the hole degree of the file to be processed based on the local hole degree of each file fragment.

[0239] In some embodiments, the first judgment module 1405 is used to determine the fragment order of each file fragment based on the configuration parameters of each file fragment in the file to be processed; determine the storage order of each file fragment based on the storage address of each file fragment in the file to be processed; and determine the discrete data of the file to be processed based on the difference information between the storage order of each file fragment and the fragment order.

[0240] In some embodiments, the file processing apparatus further includes:

[0241] The second judgment module 1406 is used to determine the file attribute information of the file to be processed; determine the file type of the file to be processed based on the file attribute information; if the file type is the target type, execute to obtain the configuration parameters of each file fragment in the file to be processed, and determine the target reserved area of ​​the file to be processed; the target type includes at least one of a fragile file and a fragment-sensitive file.

[0242] In some implementations, the file attribute information includes file size, internal fragmentation data, and file write counts. The second determination module 1406 includes:

[0243] The fragile file determination unit is configured to compare the file size with a preset first file size threshold, compare the internal fragmentation data with a preset first fragmentation threshold, and compare the number of file writes with a preset file write count threshold; if the file size is greater than or equal to the preset first file size threshold, the internal fragmentation data is greater than or equal to the preset first fragmentation threshold, and the number of file writes is greater than or equal to the preset file write count threshold, then determine that the file type of the to-be-processed file is a fragile file. In some embodiments, the file attribute information includes the file read size, file read parameters, file size, and internal fragmentation data; the second determination module 1406 includes:

[0244] A fragmentation-sensitive file judgment unit is used to compare the file size with a preset second file size threshold, compare the file read size with the preset file read size threshold, compare the internal fragmentation data with the preset second fragmentation threshold, and compare the file read parameters with the preset read parameters; the file read parameters include the number of times the file to be processed is read according to the target reading method; if the file size is greater than or equal to the second preset file size threshold, the file read size is greater than or equal to the preset file read size threshold, the internal fragmentation data is greater than or equal to the preset second fragmentation threshold, and the file read parameters are greater than or equal to the preset read parameters, then the file type of the file to be processed is determined to be a fragile and sensitive file.

[0245] In some embodiments, the file processing apparatus further includes:

[0246] The third judgment module 1407 is used to determine the file attribute information of the file to be processed; the file attribute information includes the file size and internal fragmentation data; based on the file attribute information, the file type of the file to be processed is determined; the target type includes at least one of a fragile file and a fragmentation-sensitive file; if the file type is the target type and the internal fragmentation data of the file to be processed is greater than or equal to the preset internal fragmentation threshold, then the configuration parameters of each file fragment in the file to be processed are obtained, and the target reserved area of ​​the file to be processed is determined.

[0247] The file processing device provided by an embodiment of the present invention determines the fragment order of each file fragment through the configuration parameters of the file fragment, and determines the target position of each file fragment in the target reserved area based on the fragment order of each file fragment. In this way, it can ensure that the file fragments written into the target reserved area are continuous, thereby alleviating the problem of internal file fragmentation.

[0248] An embodiment of the present invention further provides a file processing device, as shown in FIG15 , which shows a schematic structural diagram of the file processing device involved in an embodiment of the present invention. Specifically:

[0249] The file processing device may include one or more processing cores of a processor 1501, one or more computer-readable storage media 1502, a power supply 1503, an input unit 1504, and other components. Those skilled in the art will appreciate that the file processing device structure shown in FIG15 does not limit the file processing device, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.

[0250] Processor 1501 is the control center of the file processing device. It connects the various components of the entire file processing device using various interfaces and circuits. By running or executing software programs and / or modules stored in memory 1502 and accessing data stored in memory 1502, it performs various functions of the file processing device and processes data, thereby providing overall monitoring of the file processing device. Optionally, processor 1501 may include one or more processing cores; preferably, processor 1501 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 1501.

[0251] The memory 1502 can be used to store software programs and modules. The processor 1501 executes various functional applications and data processing by running the software programs and modules stored in the memory 1502. The memory 1502 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 based on the use of the file processing device, etc. In addition, the memory 1502 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 device. Accordingly, the memory 1502 may also include a memory controller to provide the processor 1501 with access to the memory 1502.

[0252] The file processing device also includes a power supply 1503 for supplying power to various components. Preferably, the power supply 1503 can be logically connected to the processor 1501 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 1503 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.

[0253] The file processing device may further include an input unit 1504, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0254] Although not shown, the file processing device may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 1501 in the file processing device will load the executable files corresponding to one or more application processes into the memory 1502 according to the following instructions, and the processor 1501 will run the application stored in the memory 1502 to implement various functions as follows:

[0255] Obtain configuration parameters of each file segment in the file to be processed and determine the target reserved area of ​​the file to be processed;

[0256] Determining the fragment order of each file fragment according to the configuration parameters of each file fragment;

[0257] Determining a target position of each file fragment in a target reserved area according to a fragment sequence of each file fragment;

[0258] Write each file segment to its corresponding target location in the target reserved area.

[0259] Example 8 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 accomplished 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.

[0260] To this end, an embodiment of the present invention provides a storage medium storing a plurality of instructions that can be loaded by a processor to execute the steps of any of the file processing methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps:

[0261] Obtain configuration parameters of each file segment in the file to be processed and determine the target reserved area of ​​the file to be processed;

[0262] Determining the fragment order of each file fragment according to the configuration parameters of each file fragment;

[0263] Determining a target position of each file fragment in a target reserved area according to a fragment sequence of each file fragment;

[0264] Write each file segment to its corresponding target location in the target reserved area.

[0265] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0266] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0267] Since the instructions stored in the storage medium can execute the steps in any file processing method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any file processing method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0268] The above is a detailed introduction to a file processing method, device, equipment and storage medium provided by an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A file processing method, in, The method comprises: Obtaining configuration parameters of each file segment in the to-be-processed file, and determining a target reserved area of ​​the to-be-processed file; Determining a fragment order of each of the file fragments according to a configuration parameter of each of the file fragments; Determining a target position of each of the file fragments in the target reserved area according to a fragment sequence of each of the file fragments; Each of the file segments is written into a corresponding target location in the target reserved area.

2. The file processing method according to claim 1, in, The configuration parameters include the fragment codes of the file fragments; and determining the fragment order of each of the file fragments according to the configuration parameters of each of the file fragments includes: Determine whether there is a first file segment with the same segment code among the file segments; If there are first file segments with the same segment code, determining the time difference between the writing time of each first file segment and the current time; According to the fragment coding, the first file fragment and the second file fragment with the smallest time difference are sorted to obtain the fragment order; the second file fragment is the file fragment of each of the file fragments except the first file fragment.

3. The file processing method according to claim 1, in, The determining, according to the fragment sequence of each file fragment, the target position of each file fragment in the target reserved area comprises: Obtaining storage addresses of each target reserved storage area of ​​the target reserved area; Determine the target reserved storage area according to the storage address of each target reserved storage area The storage order of For each of the file segments, a storage address of a target reserved storage area having a storage order that is the same as the segment order of the file segment is determined as a target position of the file segment in the target reserved area.

4. The file processing method according to claim 1, in, The method of determining, according to the fragment sequence of each of the file fragments, that each of the file fragments is after the target position of the target reserved area comprises: Obtaining the storage address of each of the file fragments; The offset position of each file fragment is determined according to the storage address of each file fragment and the target position in the target reserved area; the offset position represents the position difference between the storage address of each file fragment and the target position of the file fragment in the target reserved area; for a target file fragment whose offset position is greater than a preset offset position, the target file fragment is written to the target position of the target file fragment in the target reserved area.

5. The file processing method according to claim 1, in, Determining the target reserved area of ​​the to-be-processed file comprises: A target reserved area for the file to be processed is determined according to the file size, the cumulative number of write times, and the creation time of the file to be processed.

6. The file processing method according to claim 5, in, Determining the target reserved area of ​​the file to be processed according to the file size, the cumulative number of write times and the creation time of the file to be processed includes: According to the interval between the creation time of the to-be-processed file and the current time, and the cumulative number of writes of the to-be-processed file, it is determined that the number of to-be-processed files within the interval is The frequency of modification of the document; Determining the number of reserved storage areas for the file to be processed according to the modification frequency and the file size of the file to be processed; According to the number of reserved storage areas for the to-be-processed files, a target reserved area for the to-be-processed files is determined, wherein the number of target reserved storage areas in the target reserved area is greater than or equal to the number of reserved storage areas for the to-be-processed files.

7. The file processing method according to any one of claims 1 to 6, in, Before obtaining the configuration parameters of each file segment in the to-be-processed file and determining the target reserved area of ​​the to-be-processed file, the method includes: Determining internal fragmentation data of the file to be processed; If the internal fragmentation data of the to-be-processed file is greater than or equal to a preset internal fragmentation threshold, the configuration parameters of each file segment in the to-be-processed file are obtained, and a target reserved area of ​​the to-be-processed file is determined.

8. The file processing method according to claim 7, in, Determining the internal fragmentation data of the to-be-processed file includes: Obtaining the storage address of the file fragment of the to-be-processed file; Determine the discrete data of the to-be-processed file according to the storage address of each of the file fragments; determine the hole data of the to-be-processed file according to the state difference information between each of the file fragments and the adjacent file fragments of the file fragment; According to the discrete data and the hole data of the file to be processed, internal fragmented data of the file to be processed is determined.

9. The file processing method according to claim 8, in, The determining, according to the status difference information between each file segment and the adjacent data blocks of the file segment, the hole data of the to-be-processed file comprises: For each of the file segments, comparing the status information of the file segment with the status information of adjacent file segments of the file segment; Determine the number of adjacent file fragments that are inconsistent with the state information of the file fragment as local hole data of the file fragment; The hole degree of the file to be processed is obtained according to the local hole degree of each of the file segments.

10. The file processing method according to claim 8, in, Determining the discrete data of the to-be-processed file according to the storage address of each of the file fragments includes: Determining the fragment order of each file fragment according to the configuration parameters of each file fragment in the to-be-processed file; Determining the storage order of each file fragment according to the storage address of each file fragment in the to-be-processed file; According to the difference information between the storage order of each of the file fragments and the fragment order, the discrete data of the file to be processed is determined.

11. The file processing method according to any one of claims 1 to 6, in, Before obtaining the configuration parameters of each file segment in the to-be-processed file and determining the target reserved area of ​​the to-be-processed file, the method includes: Determining file attribute information of the file to be processed; Determining the file type of the file to be processed according to the file attribute information; If the file type is the target type, execute to obtain each file piece in the file to be processed The configuration parameters of the segment are determined, and the target reserved area of ​​the file to be processed is determined; the target type includes at least one of a fragile file and a fragment-sensitive file.

12. The file processing method according to claim 11, in, The file attribute information includes file size, internal fragmentation data, and file write times; Determining the file type of the to-be-processed file according to the file attribute information includes: Comparing the file size with a preset first file size threshold, comparing the internal fragmentation data with a preset first fragmentation threshold, and comparing the file write count with a preset file write count threshold; If the file size is greater than or equal to the preset first file size threshold, the internal fragmentation data is greater than or equal to the preset first fragmentation threshold, and the number of file writes is greater than or equal to the preset file write number threshold, the file type of the file to be processed is determined to be a fragile file.

13. The file processing method according to claim 11, in, The file attribute information includes file read size, file read parameters, file size, and internal fragmentation data; Determining the file type of the to-be-processed file according to the file attribute information includes: Comparing the file size with a preset second file size threshold, comparing the file read size with a preset file read size threshold, comparing the internal fragmentation data with a preset second fragmentation threshold, and comparing the file read parameter with a preset read parameter; the file read parameter includes the number of times the to-be-processed file is read according to the target read mode; If the file size is greater than or equal to the second preset file size threshold, the file read size is greater than or equal to the preset file read size threshold, and the internal fragmented data If the value is greater than or equal to the preset second fragmentation threshold and the file reading parameter is greater than or equal to the preset reading parameter, it is determined that the file type of the file to be processed is a fragile and sensitive file.

14. The file processing method according to any one of claims 1 to 6, in, Before obtaining the configuration parameters of each file segment in the to-be-processed file and determining the target reserved area of ​​the to-be-processed file, the method includes: Determine the file attribute information of the to-be-processed file; the file attribute information includes file size and internal fragmentation data; Determining the file type of the file to be processed according to the file attribute information; If the file type is the target type, and the internal fragmentation data of the file to be processed is greater than or equal to a preset internal fragmentation threshold, then the configuration parameters of each file fragment in the file to be processed are obtained, and the target reserved area of ​​the file to be processed is determined; the target type includes at least one of a fragile file and a fragmentation-sensitive file.

15. The file processing method according to claim 1, in, The step of obtaining the configuration parameters of each file segment in the file to be processed includes: When a file write request is received, a file write operation is triggered; Obtain a file to be processed, traverse the file segments of the file to be processed, and obtain configuration parameters of each file segment.

16. The file processing method according to claim 15, in, The step of obtaining the file to be processed, traversing the file segments of the file to be processed, and obtaining the configuration parameters of each file segment includes: When the file writing operation is the first writing of the file, the file to be written is set to be processed file, traversing each file segment of the to-be-processed file and determining configuration parameters of each file segment; When the file writing operation is a file fragment update, the file fragment to be updated is obtained, and according to the file identifier of the file fragment to be updated, a written file consistent with the file identifier in the structured file system is determined, the file fragment to be updated and a set of file fragments in the written file consistent with the file identifier are set as files to be processed, each file fragment in the files to be processed is traversed, and configuration parameters of each file fragment are determined; When the file writing operation is a file update, the file to be updated is obtained, the file to be updated is set as a file to be processed, each file segment in the file to be processed is traversed, and the configuration parameters of each file segment are determined.

17. The file processing method according to claim 1, in, The step of determining the target reserved area of ​​the to-be-processed file comprises: Obtaining the file identifier of the file to be processed; A reserved area in the structured file system that matches the file identifier is determined as a target reserved area for the file to be processed.

18. A file processing device, in, The device comprises: An acquisition module, used for acquiring configuration parameters of each file segment in a to-be-processed file, and determining a target reserved area of ​​the to-be-processed file; A fragment sorting module, used to determine the fragment order of each of the file fragments according to the configuration parameters of each of the file fragments; A fragment-sensitive file address mapping module, used to determine the target position of each file fragment in the target reserved area according to the fragment sequence of each file fragment; The internal anti-fragment recovery module is used to write each of the file fragments into a corresponding target position in the target reserved area.

19. A file processing device, in, The device includes a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to perform the operations in any one of the methods described in claims 1 to 17.

20. A storage medium, in, The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method according to any one of claims 1 to 17.

Citation Information

Patent Citations

  • Method for reducing fragments of log structure file system and flash memory storage system

    CN111984604A

  • Intelligent disk defragmentation method and device and electronic equipment

    CN114238161A

  • File fragment adjusting method and electronic equipment

    CN114490442A

  • File arrangement method, intelligent terminal and computer readable storage medium

    CN115840736A

  • File processing method and device, equipment and storage medium

    CN117407368A