File arrangement method, electronic device, storage medium and chip system

By dynamically adjusting the FBO execution threshold based on the current state of the storage device, the problem of poor FBO processing performance under a fixed threshold is solved, enabling timely recovery of file reading speed and extension of storage device lifespan.

CN122309468APending Publication Date: 2026-06-30HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-12-31
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In existing technologies, file-level defragmentation (FBO) technology has shortcomings in improving processing performance. In particular, when the storage device is in different states, fixed-threshold FBO processing cannot effectively improve file reading speed and may lead to unnecessary defragmentation, increasing the lifespan of the storage device.

Method used

Electronic devices dynamically adjust the triggering conditions for FBO processing by determining an FBO execution threshold that matches the current state of the storage device. This takes into account factors such as the current operating temperature of the storage device, background I/O pressure, and the level of dirtiness, allowing for flexible triggering of FBO processing and reducing unnecessary defragmentation.

Benefits of technology

It improves the efficiency of FBO processing, restores file reading speed in a timely manner, reduces data transfer operations on storage devices, and extends the lifespan of storage devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309468A_ABST
    Figure CN122309468A_ABST
Patent Text Reader

Abstract

This application relates to the field of storage technology, and more particularly to a file organization method, electronic device, storage medium, and chip system. The method includes: an electronic device selecting a target file; then, the electronic device determining an FBO (File Order Optimization) threshold that matches the current state of the storage device. The current state of the storage device includes one or more factors affecting file read speed, such as the current operating temperature of the storage device, the current background I / O pressure of the storage device, and the current dirty level of the storage device. Next, the electronic device sets an FBO threshold that matches the current state of the storage device. Finally, the electronic device triggers the storage device to perform FBO processing on the target file based on the FBO threshold that matches the current state of the storage device. This method can improve the effectiveness of FBO processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage technology, and in particular to a file organization method, electronic device, storage medium, and chip system. Background Technology

[0002] File-based optimization (FBO) is a file-level defragmentation technique, with specifications provided by the Joint Electron Device Engineering Council (JEDEC). In this technique, FBO is performed on a file if its fragmentation rate exceeds a set FBO execution threshold (hereinafter referred to as the FBO execution threshold).

[0003] At present, how to improve the processing efficiency of FBO is a problem that needs to be solved. Summary of the Invention

[0004] This application provides a file organization method, an electronic device, a storage medium, and a chip system. In this method, the electronic device can determine an FBO threshold that matches the current state of the storage devices deployed on the electronic device.

[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0006] Firstly, a file organization method is provided, applicable to electronic devices including storage devices such as mobile phones and tablets. The method includes: the electronic device selecting a target file; then, the electronic device determining an FBO (File-Based Order) execution threshold that matches the current state of the storage device. The current state of the storage device characterizes factors that, besides the file's own fragmentation rate, can affect the file read speed stored in the storage device. For example, the current state of the storage device includes one or more factors such as the current operating temperature of the storage device, the current background I / O pressure of the storage device, and the current dirt level of the storage device. Next, the electronic device sets an FBO execution threshold that matches the current state of the storage device. Then, the electronic device triggers the storage device to perform FBO processing on the target file based on the FBO execution threshold that matches the current state of the storage device.

[0007] The current dirtiness level of a storage device indicates how frequently it performs BKOPS (Background Kops). The more frequently the device performs BKOPS, the higher its current dirtiness level. The current background I / O pressure of a storage device represents the number of background processes (threads). A higher number of background processes (threads) results in greater background I / O pressure (more threads lead to more frequent resource contention and context switching, increasing memory resource constraints and thus longer I / O times), and slower file read speeds. The current operating temperature of a storage device can, to some extent, measure its response speed. For example, the current operating temperature is typically positively correlated with the operating temperature of the electronic device. The operating temperature of an electronic device affects the processor's frequency; higher operating temperatures cause the processor's frequency to decrease, thus reducing the processor's read speed of files stored on the storage device.

[0008] In the above method, the electronic device sets an FBO threshold that matches the current operating state of the storage device. Compared with the electronic device triggering FBO processing of the target file through a fixed threshold, the electronic device can trigger FBO processing of the target file more flexibly, which can improve the FBO effect.

[0009] For example, in scenarios with poor storage device conditions, the target file read speed is more likely to fall below the file read speed decline threshold due to various factors, and the target file expects to recover its read speed in a timely manner. In scenarios with poor storage device conditions, when a fixed FBO execution threshold is used, the fixed FBO execution threshold is 5. However, in scenarios with poor storage device conditions, when the target file read speed is at a PBA fragmentation rate level of 4, the target file read speed has already fallen below the file read speed decline threshold. Since the target file's PBA fragmentation rate level (4) is less than the fixed FBO execution threshold (5), the electronic device will not trigger the storage device to perform FBO processing on the target file. This will result in the target file's read speed not being recovered in a timely manner.

[0010] Similarly, in scenarios with poor storage device conditions, the target file's PBA fragmentation level is 4. When employing a technical solution that matches the FBO threshold to the current state of the storage device, the FBA execution threshold can be dynamically (appropriately) adjusted by the electronic device to 4 (or lower). Thus, since the target file's PBA fragmentation level will be equal to (or less than) the FBO threshold matching the current state of the UFS device, the electronic device will trigger the storage device to perform FBO processing on the target file. Therefore, by performing FBO processing on the target file, the read and write speeds of the target file can be improved, meaning file read speeds are promptly restored.

[0011] For example, in scenarios where storage devices are in good condition, the target file read speed is less likely to fall below the file read speed degradation threshold. In this case, the target device aims to reduce the number of files for which FBO (Fragmentation-Based Optimization) is performed to minimize wear and tear on the storage device. In scenarios where storage devices are in good condition, when the target file read speed is at a PBA (Particle Balance Optimization) fragmentation level of 7, the target file read speed will fall below the file read speed degradation threshold. When using a fixed FBO execution threshold, if the fixed FBO execution threshold is (somewhat inappropriately) set to a low value, such as 3, from the perspective of the target file itself, it is easier for its fragmentation rate to deteriorate to 3 than to 7. From the perspective of the number of files, the number of target files with a PBA fragmentation level greater than or equal to 3 will be greater (usually much greater) than the number of target files with a PBA fragmentation level greater than or equal to 7. In scenarios where storage devices are in good condition, when the target file's PBA fragmentation level is 5, because the target file's PBA fragmentation level is higher than the fixed FBO execution threshold, the electronic device will trigger the storage device to perform FBO processing on the target file. In other words, a fixed FBO execution threshold may lead to more (unnecessary) file defragmentation, increase data movement operations within storage devices, and exacerbate the wear and tear on storage device lifespan.

[0012] Similarly, in scenarios where the storage device is in good condition, the target file's PBA fragmentation level is 5. When employing a technical solution that matches the current state of the storage device with the FBO execution threshold, the FBO execution threshold can be dynamically (appropriately) adjusted by the electronic device to a higher value, such as 6 (or higher). When the target file's PBA fragmentation level is below the FBO execution threshold, the electronic device will not trigger the storage device to perform FBO processing on the target file. Instead, the electronic device will trigger FBO processing on files with a PBA fragmentation level higher than the FBO execution threshold. This mitigates the occurrence of the electronic device triggering defragmentation on the target file when its fragmentation level is low (with limited impact on current read speed), thus avoiding unnecessary defragmentation. The electronic device will only trigger the storage device to perform FBO processing on the target file when the target file's PBA fragmentation level reaches (equal to or higher than) the dynamic FBO execution threshold.

[0013] It is evident that by employing a technical solution that matches the current state of the storage device, electronic devices can, on the one hand, lower the FBO execution threshold in scenarios where the storage device is in poor condition, allowing more files to be defragmented and enabling timely recovery of file reading speed. On the other hand, in scenarios where the storage device is in good condition, electronic devices can raise the FBO execution threshold, defragmenting only files with a high degree of fragmentation degradation (PBA fragmentation rate level), reducing unnecessary defragmentation (reducing the number of files processed by FBO). This ensures that the necessary file reading speed is restored while conserving valuable CPU computing resources, reducing data movement operations within the storage device, and minimizing wear and tear on the storage device's lifespan.

[0014] In one possible design of the first aspect, the electronic device determines an FBO execution threshold that matches the current state of the storage device, including: the electronic device acquiring the fragmentation rate of the target file. Then, the electronic device acquires the read speed of the target file. Next, the electronic device uses a first optimization algorithm on the fragmentation rate and read speed based on a first model to obtain the current state of the storage device. The first model fits the relationship between the file read speed, the file fragmentation rate, and the current state of the storage device. Then, the electronic device uses a second optimization algorithm on the current state of the storage device and a preset read speed decrease threshold based on the first model to obtain an FBO execution threshold that matches the current state of the storage device. Here, the aforementioned read speed decrease threshold can also be referred to as the file read speed decrease threshold.

[0015] In this design, the electronic device can quickly and accurately obtain the FBO execution threshold that matches the current state of the storage device through the first model.

[0016] In another possible design of the first aspect, the target file includes n files, where n is a positive integer; the fragmentation rate of the target file obtained by the electronic device includes: the fragmentation rate of k files among the n files; k is a positive integer and k is less than n. The reading speed of the target file obtained by the electronic device includes: the reading speed of the k files. Then, the electronic device uses a first optimization algorithm on the fragmentation rate and reading speed based on the first model to obtain the current state of the storage device, including: the electronic device uses the first optimization algorithm on the fragmentation rate of the k files and the fragmentation rate of the k files respectively to obtain the current state of the storage device corresponding to the k files. Next, the electronic device takes the average of the current states of the storage devices corresponding to the k files as the current state of the storage device.

[0017] In this design, the current state of the storage device can be obtained through a portion of the target file, which can save resources of the electronic device.

[0018] In another possible design of the first aspect, the method further includes: if the coefficient of variation of the current state of the storage devices corresponding to the k files exceeds a preset coefficient of variation threshold, then the FBO execution threshold is not set for the target file. The coefficient of variation threshold can be 0.1, 0.2, etc.

[0019] Understandably, the coefficient of variation measures the dispersion of data (i.e., the current state of the storage devices corresponding to k files). When the coefficient of variation exceeds a preset storage device threshold, it may indicate that the current state of the storage devices obtained by the electronic device is inaccurate. In this case, the electronic device can choose not to set the FBO execution threshold. This avoids interference caused by inaccurate current states of the UFS devices.

[0020] In another possible design of the first aspect, the inputs to the first model are the file fragmentation rate and the current state of the storage device, and the output of the first model is the file read speed. The electronic device uses a first optimization algorithm on the fragmentation rate and read speed based on the first model to obtain the current state of the storage device, including: the electronic device inputs the fragmentation rate of the target file and a first attempt value into the first model; the electronic device obtains a first attempt result corresponding to the first attempt value output by the first model. Then, the electronic device uses the first optimization algorithm to iterate the first attempt value to obtain a first target value. The first target value corresponds to a first target result, and the difference between the first target result and the read speed of the target file is minimized. Next, the electronic device uses the first target value as the current state of the storage device.

[0021] In another possible design of the first aspect, the electronic device uses a second optimization algorithm based on the first model to obtain an FBO execution threshold that matches the current state of the storage device, taking into account the current state of the storage device and a preset read speed decrease threshold. This includes: the electronic device inputting the current state of the storage device and a second attempt value into the first model, and obtaining the second attempt result output by the first model. Then, the electronic device uses the second optimization algorithm to iterate the second attempt value to obtain a second target value. The second target value corresponds to a second target result, and the difference between the second target result and the preset decrease threshold is minimized. Next, the electronic device uses the second target value as the FBO execution threshold that matches the current state of the storage device.

[0022] In another possible design of the first aspect, the electronic device uses the second target value as the FBO execution threshold that matches the current state of the storage device, including: when the second target value corresponds to multiple second target results, the electronic device takes the smallest second target value as the FBO execution threshold that matches the current state of the storage device.

[0023] In another possible design of the first aspect, the aforementioned second optimization algorithm includes any one of the following: gradient descent, conjugate gradient method, BFGS algorithm, and Nelder-Mead simplex method.

[0024] In another possible design of the first aspect, the above-mentioned triggering of the storage device to perform FBO processing on the target file based on the FBO execution threshold matched with the current state of the storage device includes: performing FBO processing on the target file when the overall fragmentation rate of the target file is greater than or equal to the FBO execution threshold matched with the current state of the storage device.

[0025] In another possible design of the first aspect, the target file includes a first LBA segment, the fragmentation rate of which is greater than or equal to an FBO execution threshold matching the current state of the storage device. The aforementioned triggering of FBO processing on the target file by the storage device based on the FBO execution threshold matching the current state of the storage device includes: performing FBO processing on the first LBA segment.

[0026] In another possible design of the first aspect, the target file includes a first LBA segment, the fragmentation rate of which is greater than or equal to an FBO execution threshold matching the current state of the storage device. Triggering the storage device to perform FBO processing on the target file based on the FBO execution threshold matching the current state of the storage device includes: performing FBO processing on the first LBA segment if the size of the first LBA segment is greater than or equal to a preset ratio with the size of the target file. The preset ratio can be 30%, 45%, etc.

[0027] In another possible design of the first aspect, the target file mentioned above is a file whose usage frequency exceeds a preset frequency threshold. The frequency threshold could be 5 times / day, or 20 times / week, etc.

[0028] In another possible design of the first aspect, the electronic device sets an FBO execution threshold that matches the current state of the storage device, including: the electronic device sets the FBO execution threshold attribute of the storage device to an encoding corresponding to the FBO execution threshold that matches the current state of the storage device.

[0029] In a second aspect, an electronic device is provided, the electronic device including a memory and one or more processors, the memory being coupled to the processors; wherein the memory stores computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method provided by the first aspect and any possible design of the first aspect.

[0030] Thirdly, a computer-readable storage medium is provided, including computer instructions that, when executed on an electronic device, cause the electronic device to perform the methods provided by the first aspect and any possible design of the first aspect.

[0031] Fourthly, a computer program product containing instructions is provided, which, when run on an electronic device, enables the electronic device to perform the methods provided by the first aspect and any possible design of the first aspect.

[0032] Fifthly, a chip system is provided for use in an electronic device, the chip system including one or more processors for invoking computer instructions to cause the electronic device to perform the methods provided by the first aspect and any possible design of the first aspect.

[0033] The technical effects of any of the design methods in aspects two through five can be found in the technical effects of different design methods in aspect one, and will not be repeated here. Attached Figure Description

[0034] Figures 1A-1D A schematic diagram of PBA fragments provided for an embodiment of this application;

[0035] Figure 2 This is a schematic diagram of FBO processing provided for an embodiment of this application;

[0036] Figure 3 A schematic diagram illustrating the process of obtaining fragmentation rate as provided in an embodiment of this application;

[0037] Figure 4 This application provides a schematic flowchart illustrating the process of an electronic device triggering a target file to perform FBO processing.

[0038] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0039] Figure 6 A schematic diagram of the architecture of an electronic device provided in an embodiment of this application;

[0040] Figure 7 A schematic diagram illustrating the process of a document organization method provided in this application embodiment;

[0041] Figure 8 This is a schematic diagram of the neural network structure provided in an embodiment of this application;

[0042] Figure 9 A schematic diagram illustrating the relationship between the first model provided for embodiments of this application and the fitting of the relationship between reading speed, device dirtiness, and file fragmentation rate;

[0043] Figure 10 A flowchart illustrating a document organization method provided in an embodiment of this application;

[0044] Figure 11 A flowchart illustrating a two-step solution method provided in this application embodiment;

[0045] Figure 12 A schematic flowchart illustrating the process of determining an FBO execution threshold that matches the current state of a UFS device, provided for an embodiment of this application;

[0046] Figure 13 A schematic diagram of another process for determining an FBO execution threshold that matches the current state of a UFS device, provided for an embodiment of this application;

[0047] Figure 14 A flowchart illustrating another document organization method provided in this application embodiment;

[0048] Figure 15 A flowchart illustrating the document processing method provided in this application embodiment;

[0049] Figure 16 A schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0050] Figure 17 This is a schematic diagram of a chip system provided in an embodiment of this application. Detailed Implementation

[0051] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of this application, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can represent A or B. "And / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone, where A and B can be singular or plural. Furthermore, in the description of the embodiments of this application, unless otherwise stated, "multiple" refers to two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. Furthermore, to facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.

[0052] In this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being better or more advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner to facilitate understanding.

[0053] The technical solutions disclosed in this application involve the collection, storage, use, processing, transmission, provision, and disclosure of users' personal information, all of which comply with relevant laws and regulations and do not violate public order and good morals.

[0054] The following provides an exemplary explanation of some technical terms involved in the embodiments of this application.

[0055] Regarding Universal Flash Storage (UFS): UFS is regulated by JEDEC. In the following description of the embodiments of this application, storage devices that conform to (support) UFS-related standards will be simply referred to as UFS devices. It should be noted that the technical solutions provided in the embodiments of this application do not impose any limitations on the versions of UFS-related standards. For example, a UFS device may support the UFS 4.0 standard; or, a UFS device may support other versions of the standard that will be introduced in future technological evolutions.

[0056] Regarding logical block addresses (LBAs) and physical block addresses (PBAs): File storage in electronic devices can be divided into two layers: the file system layer and the storage device layer. In the file system layer, files are stored using logical block addresses (LBAs), while in the storage device layer, files are stored using physical block addresses (PBAs). Both logical block addresses and physical block addresses are stored in units of pages (e.g., 4KB). Files in the file system are stored as a segment or multiple LBAs, each in a page; files in the storage device are stored as a segment or multiple PBAs, each in a page. There is a correspondence between LBAs and PBAs. This mapping is recorded in the logical-to-physics (L2P) table within the storage device.

[0057] Storage device operations can be divided into foreground operations that directly affect the user experience and background operations that are performed in the system background and are not directly perceived by the user.

[0058] Foreground operations (FGOPS) refer to the actions / operations that occur during data transfer between main memory and the host. These directly involve data reading and writing and have a direct impact on user response time. Users can clearly perceive the execution of these operations, such as loading applications and saving files.

[0059] Foreground operations include: Read operations: reading data from UFS storage to the host. Write operations: writing data from the host to UFS storage; write operations are typically performed on a page-by-page basis. Erase operations (block erase): clearing old data from UFS storage before writing new data; erase operations are performed on a block-by-block basis.

[0060] Device background operations (BKOPS) refer to a series of operations automatically performed in the background of a storage device (e.g., when the storage device is idle). These operations aim to maintain and optimize the performance and lifespan of the storage device. Background operations typically do not directly participate in current data transfers and are transparent to the user.

[0061] Background operations include, but are not limited to, garbage collection (GC): For example, in NAND flash memory, when data is updated, older copies of data become useless, and the space occupied by this useless data needs to be cleaned up to make room for new data to be written. Garbage collection is part of this process; it involves finding these useless data blocks and erasing them to free up space.

[0062] Wear-leveling: Used to extend the lifespan of storage devices. Because flash memory cells have a limited number of write cycles, frequent writes to the same physical location accelerate wear at that location, thus shortening the overall lifespan of the storage device. Wear-leveling solves this problem by evenly distributing write operations across the entire storage medium. The principle is to redistribute the location of data on the physical storage medium. When data is updated, the new data typically does not directly overwrite the old data in the original location. Instead, the new data is written to a different, less worn physical location, while the old data in the original location is marked as invalid. Due to this data redistribution mechanism of wear-leveling, files stored on storage devices (such as flash memory devices) may not occupy contiguous physical block addresses (PBAs). Even if files are logically contiguous, their physical storage may be scattered across different locations on the storage medium.

[0063] Bad block management / block reassignment: This involves detecting and marking corrupted storage blocks to ensure that data is not written to them. When a block is deemed unreliable due to physical damage or other reasons, the storage device's firmware marks it as bad and removes it from use. The data is then reallocated or moved to a healthy block. This process sometimes involves updating the block address mapping table to ensure that the logical addresses of the data point to the new physical locations.

[0064] Data flushing: To ensure data integrity, unwritten data (data in the cache) is periodically or under specific conditions written to non-volatile storage. This process helps prevent data loss. For example, UFS 4.0's write booster flush.

[0065] ECC (Error Correction Code) verification is an error detection and correction technology used to detect and correct data errors that may occur during storage. Each time data is read, the ECC algorithm checks the data integrity and attempts to correct any errors found.

[0066] Dirty pages: These can be understood as pages containing old data that has been overwritten by new data in other locations. Therefore, the data in these pages needs to be erased or rewritten.

[0067] Dirty blocks: These can be understood as blocks containing data that is no longer needed. They need to be erased before new data can be written to them. UFS devices manage data in blocks, and each block typically contains multiple pages. When data is written to a UFS device, the write operation allocates space in one or more blocks to store the data. Some pages in these blocks may have new data written to them (otherwise), while other pages may still contain old data. This means that some pages in the block have become "dirty" because they contain old data that needs to be updated or deleted. The UFS device performs an erase operation to clear the entire storage segment and mark it as free, after which the UFS device can rewrite new data.

[0068] It should be noted that in some flash memory models (such as NAND flash memory), data is erased block by block. Data is first written to clean blocks, also known as free blocks. Dirty blocks, after being garbage collected, are allowed to be written with data again.

[0069] For example, block A is a dirty block. After block A is garbage collected, it becomes a clean block, and data can then be written to it again. For instance, NAND flash memory erasure needs to be performed on a block-by-block basis; a single bit cannot be changed back from "0" to "1". Therefore, the entire block is erased first, and then new data is written to that block. This process is called block erasure.

[0070] Block erasure can be a foreground or background operation. When the available space is full (the available blocks are full), old data needs to be cleared before new data can be written. This means the garbage collector (GC) needs to erase invalid data from the blocks and move valid data to free up available blocks. In this case, block erasure is performed in the foreground as part of the write process. Alternatively, in some cases, UFS devices can also perform block erasure in the background to prepare free blocks for future writes. In this case, block erasure is performed in the background as a preprocessing or optimization technique, and is a background operation.

[0071] Physical address (PBA) fragmentation can be understood as the existence of discontinuous or free spaces between physical block addresses within a storage device layer. PBA fragmentation can result from discontinuous allocation of data blocks caused by file creation, deletion, and modification operations, or from discontinuous distribution of physical pages due to erase and write operations on the storage device. For example, when data is deleted or updated, older data blocks in the device are marked as dirty and subsequently become free blocks again through garbage collection (GC), while new data (not necessarily from the same file) is written to available free blocks. Over time, this process leads to a decrease in the physical associativity of data on the storage medium, resulting in logically adjacent data (contiguous LBAs) being distributed at discontinuous locations on the PBA.

[0072] For example, because some data in a file has been modified, data deletion and reallocation operations occur in the data blocks at the storage device layer. Due to the characteristics of NAND flash memory, data stored on the storage device cannot be updated in its original storage location; new data blocks are needed to store the updated data, which may result in PBA fragmentation.

[0073] For example, see Figure 1A The data for file A is stored on file pages with LBA numbers 1-6 on the host-side file system, and its PBA numbers on the storage device are 1-6. Next, the data stored on PBA number 5 (corresponding to LBA number 5) is modified. The storage device needs to use a new physical page (potentially a new physical page within a new physical block) to record the modified data (for simplicity, we'll still use PBA 5). Then, the data stored on LBA number 2 is modified, so the storage device needs to use a new physical page to record the modified data. Then, the data stored on LBA number 4 is deleted, so the physical page recording the data corresponding to LBA number 4 is marked as invalid. Similarly, if the physical pages containing data on LBA numbers 2 and 5 are modified, the storage device needs to use new physical pages (potentially new physical pages within a new physical block) to record the modified data. From... Figure 1A As can be seen, when a portion of the file is modified, the storage device becomes physically discontinuous, resulting in PBA fragmentation.

[0074] As another example, writing to a file when there is insufficient contiguous storage space on the storage device can also generate PBA fragmentation.

[0075] For example, see Figure 1BThe data of file B is stored in data blocks numbered 7-11 of PBA. Due to insufficient storage space in the storage device, the storage device may not have a contiguous physical address of sufficient length. The storage device may put the LBA data of the same file into multiple PBA segments with a length less than the LBA length. Figure 1B In the diagram, black-filled physical pages indicate that the physical page is unavailable. For example, if file B is 25 pages long and there are no consecutive physical addresses longer than 25 pages on the storage device, the storage device might place file B into multiple PBA segments shorter than 25 pages. For instance, the storage device might place file B into physical pages with PBA numbers 1-5 (5 pages long), into physical pages with PBA numbers 6-15 (10 pages long), or into physical pages with PBA numbers 16-25 (10 pages long).

[0076] For example, multiple processes alternately writing data to storage devices may also generate PBA fragmentation.

[0077] For example, see Figure 1C When a process writes file C to a storage device, other processes may also write data to the storage device, which could lead to PBA fragmentation. Figure 1C In the image, black-filled physical pages represent data written to the storage device by other processes.

[0078] Understandably, files can experience PBA fragmentation due to the combined effects of the factors mentioned above. For example, multiple processes alternately writing data to the storage device, and partial modification of file data, can also lead to PBA fragmentation. See, for example... Figure 1D The data in file D is stored on pages with LBA numbers 1-6. Next, the data stored on LBA numbers 2 and 3 is modified, so the physical pages recording the data corresponding to LBA numbers 2 and 3 are marked as invalid. The storage device then needs to use new physical pages (potentially new physical pages within a new physical block) to record the modified data. Since other processes are also writing data to the storage device simultaneously, such as... Figure 1D The black-filled physical pages are shown. This causes the original LBA numbers 2 and 3 to be discontinuous when written to the new physical page. This results in PBA fragmentation between the PBAs corresponding to unmodified LBAs and the PBAs corresponding to modified LBAs, as well as between the PBAs corresponding to later modified LBAs.

[0079] It should be understood that the above Figure 1A , Figure 1B , Figure 1C and Figure 1DThis is merely an example; in actual use, electronic devices can generate PBA fragmentation through many other processes. These include asynchronous update strategies of flash-friendly file systems (F2FS), frequent write / deletion by various apps / files, alternating writes by different processes, the inability of the storage system to find contiguous, complete free physical addresses (at the end of the capacity) when the remaining storage space is insufficient, and wear-leveling strategies within the device. It should be noted that this application does not impose any limitations on the PBA fragmentation generation process.

[0080] PBA fragmentation can reduce the efficiency of both data read and write operations. For example, when file data blocks are scattered across discontinuous locations on the storage device, read and write operations need to address and access different physical pages, increasing addressing time and thus reducing the overall performance of the storage device. Furthermore, for reads, the discontinuous distribution of PBAs prevents optimal concurrency from being utilized when reading data from the slave device, leading to degraded read performance. For each new data write, data migration (e.g., garbage collection) may be triggered, resulting in degraded write performance.

[0081] PBA fragmentation rate describes the degree of fragmentation in a file's physical address space. A high PBA fragmentation rate significantly increases I / O latency. For example, a high PBA fragmentation rate can cause electronic devices to lag.

[0082] FBO (File Based Optimization) technology, specified by JEDEC, is a file-level defragmentation technology supported by storage devices. This technology achieves physical address defragmentation by rearranging the Physical Address Block (PBA). Defragmentation using FBO technology can reduce the fragmentation rate of files on UFS devices, thereby improving / restoring file read speeds. Currently, FBO technology is included in the UFS 4.0 standard. For further information on FBO technology, please refer to the official JEDEC technical document: "Universal Flash Storage (UFS) File Based Optimizations (FBO) Extension".

[0083] For example, see Figure 2 The data in file D is stored in data blocks numbered 1-5 in LBA. These data blocks are discontinuous in the PBA, meaning the PBA is highly fragmented. After performing an FBO on file D, the logical relationship of file D in the PBA becomes continuous, and the fragmentation level of the PBA decreases.

[0084] As can be seen, FBO restores file reading speed in a timely manner by defragmenting (defragmenting contiguous) the physical address of the target file.

[0085] Currently, in the JEDEC standard specifications, the degree of PBA fragmentation of a file is represented by a PBA fragmentation rate level (hereinafter referred to as fragmentation rate). For example, 11 levels from 0 to 10 are used to represent the degree of fragmentation of the file; the fragmentation rate of a file is directly proportional to the degree of fragmentation of the file. For example, the higher the fragmentation rate of a file, the higher the degree of fragmentation of the file, and vice versa.

[0086] In some technical solutions, the host can be accessed through the following methods: Figure 3 The illustrated process obtains the fragmentation rate. Here, "host" can be understood as an electronic device that controls storage devices (e.g., mobile phones, tablets, etc.). "Device" can be understood as a storage device, such as a UFS device.

[0087] For example, see Figure 3 First, the host sends a query command to the device to determine if the device supports FBO. The host performs this step by reading the FBO descriptor on the device to determine if the device supports FBO functionality. Second, the host selects the target file to be optimized, queries the target file's logical address in the file system (one or more LBA segments), encapsulates the target file's logical address according to the FBO protocol, and sends a command to the device. The host performs this step by writing data of a specific format (FBOWirteBuffer) to the device buffer to inform the device. Third, the host sends an analysis command (setting the bFBOControl attribute to 0x1), and the device analyzes whether there is fragmentation in the PBA corresponding to the target file's logical address in the file system. Fourth, the host continuously queries the device's FBO execution status. Fifth, when the device-level analysis is complete (e.g., the bFBOProgressState status is set to 0x2h), the host obtains the fragmentation level of the target file. The host performs this step by reading data from the device buffer (FBOReadBuffer).

[0088] In some technical solutions, the host can be accessed through the following methods: Figure 4 The process triggering device shown performs FBO processing on the target file. See also Figure 4First, the host determines the optimization level, i.e., the host sets the FBO execution threshold (bFBOExecuteThreshold). Second, the host issues an optimization command (setting the bFBOControl property to 0x2); the device performs FBO processing on the PBA corresponding to the LBA written in the device buffer (FBOWirteBuffer) based on the FBO execution threshold (bFBOExecuteThreshold). Afterwards, the host checks the optimization progress. The host performs this step by obtaining the bFBOProgressState property. This "FBO processing" can also be referred to as "FBO optimization." Figure 4 The process allows the host to perform FBO processing on the target file based on the threshold trigger device of the FBO.

[0089] As mentioned above Figure 4 As shown, the FBO execution threshold is an attribute that needs to be set by the host before the device performs FBO processing. The FBO execution threshold specifies which FBO level in the range the device should perform FBO optimization operations from.

[0090] The device performs FBO (Fragment Optimization) if the fragmentation rate of the target file is greater than or equal to the FBO execution threshold. For example, if the FBO execution threshold is set to 5, it means that the device performs FBO processing (i.e., defragmentation) if the fragmentation rate of the target file is greater than or equal to 5. If the fragmentation rate of the target file is less than 5, the device will not perform FBO processing even if the host issues an FBO optimization command.

[0091] At present, how to improve the processing efficiency of FBO is a problem that needs to be solved.

[0092] In view of this, embodiments of this application provide a technical solution in which an electronic device can dynamically set the FBO execution threshold based on the current state of the storage device. This can improve the effectiveness of FBO. The current state of the storage device is used to characterize factors other than fragmentation rate that can affect the read speed of the storage device. Further description of the current state of the storage device is provided below; it will not be repeated here.

[0093] The aforementioned electronic devices can also be referred to as terminals, including terminal equipment, user equipment (UE), mobile station (MS), and mobile terminal (MT). These electronic devices can be mobile phones, tablets, wearable devices, smart screens, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), and other electronic devices with storage devices.

[0094] Next, the structure of the electronic device provided in the embodiments of this application will be described.

[0095] Figure 5 A schematic diagram of the structure of the electronic device 100 is shown.

[0096] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, etc.

[0097] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0098] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0099] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.

[0100] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0101] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0102] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.

[0103] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0104] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0105] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory.

[0106] For example, internal memory 121 includes at least a UFS device. Internal memory 121 may also include disk storage devices, flash memory devices, etc.

[0107] The processor 110 can connect to the UFS device via the UFS interface.

[0108] The technical solutions provided in this application embodiment are applicable to those having the above-mentioned characteristics. Figure 5 The structure of the electronic device is shown.

[0109] Next, we will introduce the architecture of electronic devices.

[0110] The software system architecture of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android™ system as an example to illustrate the architecture of electronic device 100.

[0111] Figure 6 An architectural diagram of an electronic device 100 according to an embodiment of this application is shown.

[0112] A layered architecture can be divided into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the layered architecture can be divided into four layers, from top to bottom: application layer, framework layer, native layer, and kernel layer. For example, the Android™ system of an electronic device can be deployed on top of the device's application processing.

[0113] The application layer can include a series of application packages.

[0114] like Figure 6 As shown, the application package may include system UI applications, launcher applications, etc. The system UI applications are used to manage the display of the system-level user interface, such as managing the status bar display, managing the display of wired charging animations (interface), managing the display of wireless charging animations, etc.; the launcher applications are used to display the desktop, manage desktop icons, display wallpapers, etc.

[0115] The framework layer (FWK) provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer includes some predefined functions.

[0116] like Figure 6 As shown, the application framework layer can include system services, etc.

[0117] A system server is a process that provides many subsystem services. Each subsystem service runs as a thread, waiting for requests from applications, processing the requests, and then returning the results to the applications. These subsystem services include, for example, the Window Manager Service (WMS), Notification Manager Service (NMS), Activity Manager Service (AMS), Input Manager Service (IMS), and Power Manager Service (PMS).

[0118] WMS (Windows Management System) can be used for window management, window animation management, surface management, and as a relay station for input systems. NMS (Natural Management System) allows applications to display notification information in the status bar, which can be used to convey informative messages and can disappear automatically after a short pause without user interaction. AMS (Application Management System) can be used for the startup, switching, and scheduling of system components (e.g., activities, services, content providers, and broadcast receivers), as well as the management and scheduling of application processes. IMS (Integrated Management System) can be used to manage system input, such as touchscreen input, keypad input, and sensor input. PSM (Power Management System) is used to manage the power of electronic devices, such as turning the screen on and off.

[0119] System services may also include a storage manager service (SMS). SMS is used to manage storage devices installed in electronic devices. For example, SMS can enable the periodic cleanup of storage devices.

[0120] The native layer runs storage management processes, such as the init process and the vold (volumedaemon) daemon. It should be understood that in some implementations, the storage management process can create child threads that inherit the SELinux context of the storage management process. The storage management process can be used to manage storage devices (such as USB, SD cards, and flash memory) of electronic devices. In other examples, the storage management process can also be some other process capable of managing storage devices.

[0121] The native layer can also be referred to as system libraries and the Android Runtime layer.

[0122] The kernel layer is the layer between hardware and software. At a minimum, the kernel layer contains storage device drivers, such as a UFS driver. Storage device drivers enable communication between the application processor (AP) and storage devices, sending instructions to the storage devices, receiving information from the storage devices, and so on.

[0123] The technical solutions provided in this application embodiment are applicable to those having the above-mentioned characteristics. Figure 6 The electronic device with the architecture shown.

[0124] Below, taking the FBO scenario as an example, combined with Figure 6 The architecture shown further illustrates the technical solutions provided in the embodiments of this application.

[0125] For example, in some technical solutions, during the power-on phase of an electronic device, the device can call a specific interface exposed by the storage device driver (e.g., a sysfs node) or a function interface provided by the driver based on kernel-specific system calls (e.g., the ioctl system call) to set the FBO execution threshold. Then, during the running phase of the electronic device (e.g., when the device is charging and the screen is off), the device's storage management service can call the storage management process (or other processes) to obtain the fragmentation rate of the file reported by the UFS device through the UFS driver. If the fragmentation rate of the file exceeds the aforementioned FBO execution threshold, the storage management service instructs the file to undergo FBO processing.

[0126] In this approach, the electronic device determines whether to perform FBO processing on a file based on a fixed FBO execution threshold; furthermore, for multiple different files, the electronic device applies the same FBO execution threshold to all of them. By applying the same FBO execution threshold to multiple files, this approach makes the process of triggering FBO processing by the electronic device relatively simple and efficient.

[0127] The power-on phase of an electronic device can be understood as the time period from when the electronic device is powered on to when its initialization process is completed. The operation phase of an electronic device can be understood as the time period from when the electronic device completes its initialization to when it begins executing its shutdown process. It should be understood that the initialization and power-on phases may be divided differently for different electronic devices. Specifically, the design can be tailored to the actual situation, and the embodiments in this application are not limited in this regard.

[0128] Understandably, this process is only an example; in actual use, there may be other processes to perform FBO processing on the target file. Please see the further description below for details.

[0129] The following description uses a mobile phone as an example, which has a UFS device, to further illustrate the technical solution provided in this application. It should be noted that in the following description of the technical solution of this application, the mobile phone can also be referred to as a host, and the UFS device can also be referred to as a device.

[0130] Example 1

[0131] In the technical solution provided in Example 1, the mobile phone sets a fixed FBO execution threshold during the boot-up phase. Then, the mobile phone obtains the fragmentation rate of the target file. If the fragmentation rate of the target file exceeds the aforementioned FBO execution threshold, the host triggers FBO processing on the target file.

[0132] For example, see Figure 7 The document organization method provided in this application includes steps S700-S705.

[0133] S700. The host obtains the FBO capability of the UFS device.

[0134] As one possible implementation, the host can read the FBO descriptor (e.g., FBO_Descriptor) of the UFS device to determine the FBO capability of the UFS device, that is, whether the UFS device supports FBO processing.

[0135] S701. Host settings for FBO execution threshold.

[0136] As one possible implementation, if step S700 determines that the UFS device supports FBO processing, the host sets the FBO execution threshold of the UFS device to a first value. This first value can be pre-configured, for example, pre-configured by the host manufacturer.

[0137] For example, the host manufacturer can configure the first value based on one or more of the following factors.

[0138] Factor 1: Read speed is related to file fragmentation rate. For example, when a file's fragmentation rate exceeds a certain threshold (e.g., 50%), the expected file speed will significantly decrease (exceeding the speed reduction threshold). This speed reduction threshold can be a pre-set threshold on the host side based on business requirements. At this point, FBO (File Buyout) is executed in the hope of restoring file read performance. For another example, when a file's fragmentation rate exceeds 50%, the read speed will significantly decrease due to the file's fragmentation (e.g., the decrease will exceed 50%). Executing FBO at this time will restore the read speed to some extent, usually restoring it to (close to) the read speed when the storage device is in good condition and the file itself is fragment-free. A good storage device condition can be understood as each physical block in the storage device being clean, and the storage device having no dirty blocks. Alternatively, a good storage device condition can be understood as most of the physical blocks in the storage device being clean, and the storage device having almost no dirty blocks.

[0139] The aforementioned decrease in read speed can be measured when the storage device is in good condition and the file itself has no physical address fragmentation (this can be denoted as A), and when the file's PBA fragmentation level is at a specific value (e.g., a fragmentation level of 4 indicates a fragmentation rate of 40%), the file read speed can be tested (this can be denoted as B). The decrease in read speed = (AB) / A.

[0140] For example, if the storage device is in good condition and the file itself has no physical fragmentation, the file read speed is 4000 MB / s; if the device condition remains unchanged and the file's PBA fragmentation level is 6, the file read speed is 2000 MB / s. Therefore, the decrease in read speed is (4000-2000) / 4000 = 50%.

[0141] Factor 2: Considering device lifespan protection, an excessively low execution threshold will frequently trigger data migration (for example, with an FBO execution threshold of 0, based on a file fragmentation rate of 1%, a UFS device can perform FBO processing on the target file). The data in the target file requiring defragmentation typically changes frequently (the file undergoes frequent write and delete operations). Considering the return on investment (for example, when the file's own fragmentation rate is only 10%, the read benefit after FBO processing is only 5%, at which point the benefit of performing FBO is not significant (e.g., it may be difficult to offset normal fluctuations in read speed).

[0142] Factor 3: File fragmentation only has a significant impact on file reading speed when the file fragmentation rate exceeds a certain level. In other words, when the file fragmentation rate reaches a certain level, performing FBO on the target file will yield considerable FBO benefits.

[0143] For example, a hosting provider can configure a first value based on a threshold of file read speed reduction that the hosting provider can tolerate (hereinafter referred to as the drop threshold), which corresponds to the file fragmentation rate. For instance, if the drop threshold is 70% and the corresponding fragmentation rate is 6, then the first value is configured to 6.

[0144] For example, the FBO execution threshold can be an integer in the range [0, 10], meaning the first value is an integer in the range [0, 10]. For instance, if the first value is 4, the host can set the bFBOExecuteThreshold property to 0x04.

[0145] Below, please refer to Table 1 for an example of the correspondence between the bFBOExecuteThreshold attribute value and the FBO execution threshold.

[0146] Table 1

[0147]

[0148]

[0149] It should be understood that the correspondence between the bFBOExecuteThreshold attribute values ​​and the FBO execution threshold shown in Table 1 above is merely an example. This application does not impose any limitations on this.

[0150] In some implementations, steps S700-S701 described above can be performed during the power-on phase of the mobile phone (i.e., the host). That is, in this implementation, the mobile phone does not set the FBO execution threshold during operation; the FBO execution threshold remains fixed.

[0151] S702. The host selects the target file.

[0152] As one possible implementation, the host can select a file whose size is greater than a second value as the target file. This second value can be 100MB, 200MB, 1GB, etc. It should be understood that the file size is directly proportional to the number of data blocks used by the file. That is, the larger the file, the more data blocks it occupies; therefore, the higher the benefit gained from performing FBO processing on that file. Thus, the host can select a relatively large file to perform FBO processing, thereby increasing the FBO benefit.

[0153] As another possible implementation, the host can select a file with a usage frequency higher than a first frequency as the target file. This third value could be 5 times / day, 20 times / week, etc. It should be understood that high usage frequency indicates frequent use of the target file by the user. Therefore, the file read speed of the target file has a greater impact on the user experience. Thus, by selecting a file with a usage frequency higher than the first frequency as the target file, the read speed of the target file will be improved after it is processed by the FBO, thereby enhancing the user experience.

[0154] As another possible implementation, the host can also select the target file according to actual business needs.

[0155] The benefits of File-Based Load (FBO) can be understood as the change in file fragmentation rate after FBO processing compared to before FBO processing. Alternatively, it can be understood as the change in the host's file read speed after FBO processing compared to before FBO processing. The lower the fragmentation rate after FBO processing compared to before, the higher the FBO benefit, and vice versa. Similarly, the faster the host's file read speed after FBO processing compared to before FBO processing, the higher the FBO benefit, and vice versa.

[0156] As one possible implementation, the host can encapsulate the LBA of the target file and write it to an FBOWriteBuffer. The FBOWriteBuffer can be understood as a volatile buffer that is write-only to the host. The host uses this buffer to provide device information about the LBA range needed to perform FBO analysis or optimization. This buffer can be 4KB in size.

[0157] For example, the target file includes LBA segment 1, LBA segment 2, and LBA segment 3. The host can package LBA segment 1, LBA segment 2, and LBA segment 3 and write them to the FBOWirteBuffer.

[0158] S703. The host issues a fragmentation rate analysis command.

[0159] As one possible implementation, the host can set the bFBOControl property to 0x1 to send fragmentation rate analysis commands.

[0160] S704. Host obtains fragmentation rate analysis results.

[0161] As one possible implementation, the host can obtain the fragmentation rate analysis results of the target file by reading the FBOReadBuffer. The FBOReadBuffer can be located in the buffer of the UFS device. For example, the value range of the fragmentation rate analysis results can be an integer belonging to [0, 10].

[0162] FBOReadBuffer can be understood as a volatile buffer that is read-only by the host. The host uses this buffer to receive analytical information about the data in FBOReadBuffer from the device. This buffer can also be 4KB in size.

[0163] For example, the target file includes LBA segment 1, LBA segment 2, and LBA segment 3. After the host encapsulates LBA segment 1, LBA segment 2, and LBA segment 3 according to the FBO-related protocol provided by JDEDEC, it writes them into the FBOReadBuffer. After the device completes the analysis of LBA segment 1, LBA segment 2, and LBA segment 3, the host can read the individual fragmentation rate levels of LBA segment 1, LBA segment 2, and LBA segment 3 from the FBOReadBuffer. Furthermore, according to the FBO-related protocol provided by JDEDEC, the host can also read the fragmentation rate level of LBA segment 1, LBA segment 2, and LBA segment 3 of the target file as a whole (also referred to as the overall fragmentation rate of the target file) from the FBOReadBuffer.

[0164] S705. The host issues an FBO processing command.

[0165] If the fragmentation rate analysis result of the target file is greater than or equal to the aforementioned FBO execution threshold, the host sets the bFBOControl attribute to 0x2. By setting the bFBOControl attribute to 0x2, the host instructs the device to perform FBO processing on the target file (e.g., the LBA written by the host in the FBOWirteBuffer).

[0166] It should be noted that the above description of steps S700-S705 is mainly for the host (e.g., a mobile phone). For steps performed on devices (e.g., UFS devices), please refer to related technologies. This application embodiment does not impose any limitations on the steps performed on devices (e.g., UFS devices).

[0167] In this implementation, setting an FBO execution threshold once during the boot process can reduce the interaction between the host and the UFS device, making the interaction between the mobile phone and the UFS device simpler.

[0168] Example 2,

[0169] In the technical solution provided in Embodiment 2, the mobile phone deploys a first model. This first model can be a pre-trained model file based on multi-factor fitting. In other embodiments, the first model may also be referred to as a fitting model, a neural network, etc., and this application embodiment is not limited in this regard. Next, the mobile phone uses the first model to determine the current state of the UFS device. The current state of the UFS device includes various factors that can affect file reading speed. For example, the current state of the UFS device may include one or more of the following factors that can affect file reading speed: the current operating temperature of the UFS device, the current background IO pressure of the UFS device, and the current dirty level of the UFS device. Then, the mobile phone uses the first model to determine an FBO threshold that matches the current state of the UFS device. Then, the mobile phone sets the aforementioned FBO execution threshold that matches the current state of the UFS device to the UFS device. Then, if the fragmentation rate of the target file is greater than or equal to the FBO execution threshold that matches the current state of the UFS device, the mobile phone triggers the UFS device to perform FBO processing on the target file.

[0170] In this approach, the phone sets an FBO threshold that matches the current operating state of the UFS device. This contrasts with a technique that triggers FBO processing of the target file using a fixed threshold. The fixed threshold technique doesn't consider the impact of the storage device's current state on the target file's read speed, which could lead to delayed recovery of the file read speed. Furthermore, because the fixed threshold technique doesn't account for the UFS device's current state, it might increase data transfer operations within the UFS device, accelerating device lifespan loss.

[0171] For example, in scenarios where the UFS device is in poor condition, the target file read speed is more likely to fall below the file read speed reduction threshold due to various factors, and the target file expects to recover its read speed in a timely manner. In scenarios where the UFS device is in poor condition, when a fixed FBO execution threshold is used, the fixed FBO execution threshold is 5. However, in scenarios where the UFS device is in poor condition, when the target file read speed is at a fragmentation rate of 4, the target file read speed is already below the file read speed reduction threshold. Since the fragmentation rate (4) of the target file is less than the fixed FBO execution threshold (5), the phone will not trigger the UFS device to perform FBO processing on the target file. This will result in the target file read speed not being recovered in a timely manner.

[0172] For example, in scenarios where the UFS device is in good condition, the target file read speed is less likely to fall below the file read speed degradation threshold. In this case, the target aims to reduce the number of files for which FBO (Fragmentation-Based Optimization) is performed to minimize the wear and tear on the UFS device's lifespan. In scenarios where the UFS device is in good condition, when the target file read speed is at a PBA (Particle Size Association) fragmentation level of 7, the read speed will fall below the file read speed degradation threshold. When using a fixed FBO execution threshold, if the fixed FBO execution threshold is (somewhat inappropriately) set to a low value, such as 3, from the perspective of the target file itself, it is easier for its fragmentation rate to deteriorate to 3 than to 7. From the perspective of the number of files, the number of target files with a PBA fragmentation level greater than or equal to 3 will be greater (usually much greater) than the number of target files with a PBA fragmentation level greater than or equal to 7. In scenarios where the UFS device is in good condition, when the target file's PBA fragmentation level is 5, because the target file's PBA fragmentation level is higher than the fixed FBO execution threshold, the phone will trigger the UFS device to perform FBO processing on the target file. For a fixed FBO execution threshold, more (unnecessary) files may need to be defragmented, increasing data transfer operations within the UFS device and exacerbating the wear and tear on the UFS device's lifespan.

[0173] However, in the technical solution provided in Example 2, the mobile phone not only considers the impact of fragmentation rate on file read speed, but also takes into account one or more of the following factors: the current operating temperature of the UFS device, the current background I / O pressure of the UFS device, and the current dirty level of the UFS device, all of which affect file read speed. Therefore, in scenarios where the UFS device is in poor condition, target files that cannot be promptly processed using a fixed threshold approach can be processed by the UFS device using FBO (File-Based Loading). This improves the read and write speed of files processed by FBO, enhancing the FBO effect. Alternatively, in scenarios where the device is in good condition, data transfer operations within the UFS device can be reduced, minimizing wear and tear on the device's lifespan.

[0174] For example, in scenarios where the UFS device is in poor condition, the fragmentation rate of the target file is 4. When a technical solution is adopted that matches the FBO threshold to the current state of the UFS device, the FBA execution threshold can be dynamically (appropriately) adjusted by the mobile phone to 4 (or lower). In this way, since the fragmentation rate of the target file will be equal to (or less than) the FBO threshold matching the current state of the UFS device, the mobile phone will trigger the UFS device to perform FBO processing on the target file. Therefore, by performing FBO processing on the target file, the read and write speed of the target file can be improved, meaning that the file read speed is restored in a timely manner.

[0175] For example, in a scenario where the UFS device is in good condition and the fragmentation rate of the target file is 5, when using a technical solution that matches the current state of the UFS device with the FBO execution threshold, the FBO execution threshold can be dynamically (appropriately) adjusted by the phone to a higher value, such as 6 (or higher). When the fragmentation rate of the target file is below the FBO execution threshold, the phone will not trigger the UFS device to perform FBO processing on the target file. Instead, the phone will trigger the UFS device to perform FBO processing on files with a PBA fragmentation rate higher than the FBO execution threshold. This mitigates the situation where the phone triggers defragmentation on the target file when its fragmentation rate is low (with limited impact on current read speed), thus avoiding unnecessary defragmentation. The phone will only trigger the UFS device to perform FBO processing on the target file when its fragmentation rate reaches (equal to or higher than) the dynamic FBO execution threshold.

[0176] It is evident that by employing a technical solution that matches the current state of the UFS device, the mobile phone can, on the one hand, lower the FBO execution threshold in scenarios where the UFS device is in poor condition, allowing more files to be defragmented and enabling timely recovery of file read speed. On the other hand, in scenarios where the UFS device is in good condition, the mobile phone can raise the FBO execution threshold, defragmenting only files with a high degree of fragmentation, reducing unnecessary defragmentation (reducing the number of files processed by FBO). This ensures that the necessary file read speeds are restored while conserving valuable CPU computing resources, reducing data movement operations within the UFS device, and minimizing wear and tear on the UFS device's lifespan.

[0177] Before introducing the file organization method provided in Example 2, the training process of the first model provided in Example 2 will be introduced first.

[0178] The training device can use the training set to train the initial first model. After the training termination condition is met (e.g., the loss function converges, or, if the loss function does not converge, the preset number of training iterations is reached), the training process of the initial first model is completed, and the first model is obtained. Here, loss function convergence can be understood as the value of the loss function being less than the preset error rate.

[0179] The training device can be a terminal, or other computing devices such as servers or cloud devices. For example, the training device can be a graphics processing unit (GPU), a neural network processing unit (NPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program in this application.

[0180] Neural networks can be composed of neurons, and neurons can refer to neurons that are denoted by x. s The arithmetic unit takes an intercept of 1 as input. The output of this arithmetic unit satisfies the following expression 1.

[0181]

[0182] Where s = 1, 2, ..., n, n is a natural number greater than 1, W s For x sThe weights are denoted by b, where b is the neuron's bias. f is the neuron's activation function, used to introduce non-linear characteristics into the neural network, converting the input signal into the output signal. The output signal of this activation function can be used as the input to the next layer; the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple individual neurons, meaning the output of one neuron can be the input of another. The input of each neuron can be connected to the local receptive field of the previous layer to extract features from that local receptive field, which can be a region composed of several neurons. The weights represent the strength of the connection between different neurons. The weights determine the influence of the input on the output. A weight close to 0 means that changing the input does not change the output. A negative weight means that increasing the input decreases the output.

[0183] like Figure 8 The diagram shown is a schematic representation of a neural network structure provided in an embodiment of this application. The neural network 800 includes N processing layers, where N is an integer greater than or equal to 3. The first layer of the neural network 100 is an input layer 110, responsible for receiving input signals. The last layer of the neural network 100 is an output layer 130, responsible for outputting the processing results of the neural network. The layers excluding the first and last layers are intermediate layers 140, which together form a hidden layer 120. Each intermediate layer 140 in the hidden layer 120 can both receive input signals and output signals. The hidden layer 120 is responsible for processing the input signals. Each layer represents a logical level of signal processing; through multiple layers, data signals can undergo multi-level logical processing. Hidden layers can also be called implicit layers. For example, when the hidden layer is set to 2, the number of neural network processing layers is 4. The number of hidden layers can be set according to actual usage needs, and this embodiment of the application does not limit this.

[0184] In some feasible embodiments, the input signal of the first model provided in this application can be a variety of factors that can affect file reading speed, such as file fragmentation rate, UFS device dirtiness, background I / O pressure, and UFS device operating temperature. The technical solution provided in this application does not limit the factor affecting file reading speed to a single factor (file fragmentation rate); the factor affecting file reading speed can be selected according to actual needs and the actual capabilities of the host. Furthermore, the output signal of the neural network can also be the file reading speed. It is understood that the input signal of the neural network also includes various other computer-processable engineering signals, which will not be listed here.

[0185] As one possible implementation, the first model described above can be any of the following: Back Propagation (BP) neural network, Convolutional Neural Network (CNN), or Recurrent Neural Network (RNN). These models share the same or similar fundamental principles. The BP upgrade network will be used as an example in the following description.

[0186] A backpropagation (BP) neural network can be understood as a neural network in which the backpropagation algorithm is used to adjust the weights between each neuron during training. Specifically, forward propagation of the input signal to the output generates an error loss. This error loss information is then used to update the initial parameters of the neural network, thereby bringing the error loss to convergence. The backpropagation algorithm is a backpropagation process dominated by the error loss, aiming to obtain the optimal parameters of the neural network, such as the weight matrix.

[0187] In some examples, the first model provided in this application embodiment can use the sigmoid function as the activation function. The sigmoid function can be:

[0188] In some examples, the error function of the first model provided in the embodiments of this application is the following expression 2.

[0189]

[0190] in, The training set includes the labels of the training data, y j This is the initial training result output by the first model.

[0191] During the training process, when a training device can use a training set to train an initial first model, the learning rate is a parameter that controls the magnitude of weight updates. In the training of a neural network, the direction of weight updates is determined by calculating the gradient of the loss function relative to each weight. The learning rate determines how large a step should be taken in that direction. Additionally, during training, the number of iterations, also known as training epochs, refers to the number of times the entire training dataset is traversed. Each iteration involves feeding the entire training set in batches into the network for forward and backward propagation to update the model's weights. Too few iterations may result in the model not having enough time to learn the data features, leading to underfitting.

[0192] For example, during the training process where the training device can use the training set to train the initial first model, the learning rate can be set to 0.03, 0.05, and 0.06, etc., the number of iterations can be 2500, 3000, 5000, and 8000, etc., and the error rate can be 0.5%, 0.1%, and 0.3%, etc. It should be understood that the above descriptions of learning rate, number of iterations, and error rate are merely examples; in actual use, there can be many more designs, depending on the specific application requirements.

[0193] The training set used in the training process consists of a feature and a label for each training data point. The features of the training data are factors that may affect read speed, such as x1 (file fragmentation rate level), x2 (storage device dirtiness), x3 (storage device background I / O pressure), and x4 (storage device operating temperature). The label for the training data can be the file read speed.

[0194] The construction of the training set can be performed by a data acquisition device. This data acquisition device can be the same as the training device described above, or it can be another type of device.

[0195] For collecting data on file fragmentation rate levels: For example, data acquisition devices can use FIO tools (e.g., by randomly overwriting the target file) to generate different levels of physical address fragmentation rate for the target file. The total number of possible file fragmentation rate levels can be represented as N. x1 For example, the fragmentation rate level can be set to 11 levels (levels 0-10), N x1 =11. File fragmentation rate level can measure the degree of file fragmentation. For further information on file fragmentation rate level, please refer to the technical document provided by JEDEC: "Universal Flash Storage (UFS) File Based Optimizations (FBO) Extension".

[0196] For data acquisition targeting storage device dirt levels: For example, a data acquisition device can use a specific storage device aging tool (e.g., a full disk fragmentation tool) to fragment the remaining space on the entire disk. The storage device dirt level is simulated based on the degree of aging (granularity of coverage and percentage of coverage), and the total number of possible storage device dirt level values ​​is represented by N. x2 For example, the dirty level of a storage device can be set to 11 levels (0-10), N x2=11. Storage device dirtiness measures the percentage of dirty blocks on a storage device. The higher the percentage of dirty blocks, the higher the storage device's dirtiness, and vice versa. It should be understood that storage devices are configured with strategies such as garbage collection (GC) and wear leveling. Therefore, when the percentage of dirty blocks on a storage device is higher, the more BKOPS (e.g., GC) will be performed. Thus, storage device dirtiness can also measure the frequency with which the storage device performs BKOPS.

[0197] For background I / O pressure on storage devices: For example, data acquisition devices can create threads for read / write operations to simulate background application load, the total number of which is denoted as N. x3 For example, the background I / O pressure of the storage device can be set to 17 levels (0-16), N x3 =17. It should be understood that in some cases, to improve the user experience, the phone can perform FBO (Frame-Based Operation) processing even when the screen is off while charging. This is understandable, as the phone will run background processes but not foreground processes when the screen is off while charging. In other cases, the phone can perform FBO processing in any scenario, allowing it to calculate foreground I / O pressure in addition to background I / O pressure.

[0198] To control the operating temperature of storage devices, data acquisition equipment can use a temperature-controlled chamber to regulate the ambient temperature. Temperature ranges are defined in increments of several degrees Celsius, from the lowest to the highest temperature. The total number of possible operating temperature values ​​for the storage device is represented by N. x4 For example, the operating temperature range of the storage device is set to 10°C to 50°C. Within this range, there are 9 temperature increments of 5°C, N. x4 =9.

[0199] It should be noted that in actual use, data acquisition devices can collect factors beyond those mentioned above (such as the dirty level of storage devices, background I / O pressure of storage devices, operating temperature, etc.). These factors may or may not be used. For example, operating temperature can affect the CPU frequency of a mobile phone, thereby affecting file reading speed. This factor can be replaced by directly collecting a specific CPU frequency.

[0200] The x2 setting measures the frequency of BKOPS on the storage device, while x3 measures the load of background applications. Since the host cannot directly control or measure the frequency of BKOPS on the storage device, the data acquisition device can simulate this by using device aging processes / tools to degrade the storage device to a specific degree. For example, after closing background threads, the data acquisition device can use aging tools to perform file write and delete operations to fragment the remaining disk space. Then, the data acquisition device can start background threads. Once started, background threads can perform data updates, file read / write operations, etc., thus varying the frequency of BKOPS on the storage device.

[0201] It should be noted that the embodiments of this application do not limit the specific aging tools or aging methods used in the data acquisition equipment, as long as they can reflect the degree of fragmentation of the entire storage device.

[0202] It should be understood that, considering that the units of the features of the above training data may be different, and the numerical range of the features may be different, in order to prevent gradient vanishing in subsequent training, in some examples, the training device can normalize the features of the training data and map them to [0,1].

[0203] Normalization can be performed using the following expression 3.

[0204]

[0205] Xnorm is the normalized data. X is the original data. Xmin and Xmax are the minimum and maximum values ​​in the original data (features of the training data), respectively.

[0206] In some examples, the data acquisition device can collect one or more of the data from x1, x2, x3, and x4 mentioned above to construct a training set. For example, the data acquisition device can collect x1 and x2 to construct a training set. Or, the data acquisition device can collect x1, x2, x3, and x4 to construct a training set.

[0207] The training set is constructed by collecting x1, x2, x3, and x4 data using the data acquisition device. After one round of data acquisition, the training set has at least N data points. x1 *N x2 *N x3 *N x4 =11*11*17*9=18513 training data points. It should be understood that the data acquisition device can also collect K rounds of data, with one round containing 18513 training data points, and K rounds containing K*18513 training data points, where K is a positive integer.

[0208] With the data acquisition device collecting one round of training data, the training set is shown in Table 2 below.

[0209] Table 2

[0210]

[0211] If the data acquisition device only collects the two features x1 and x2 mentioned above to construct the training set, and the data acquisition device collects data in one round, the training set will have at least N features. x1 *N x2 =11*11=121 training data points. It should be understood that the data acquisition device can also collect K rounds of data, with 121 training data points per round, and K rounds having K*121 training data points, where K is a positive integer.

[0212] With K rounds of data collection, the training set is shown in Table 3 below.

[0213] Table 3

[0214]

[0215]

[0216] In the case where the data acquisition device collects the above four features x1, x2, x3 and x4 to construct the training set, logically / mathematically / algorithmally / model can use x1 as a variable of one dimension, and logically, mathematically, algorithmically or modelally can use x2, x3 and x4 as variables of another dimension in the form of tuples.

[0217] It should be noted that the number of training set features collected by the data acquisition device is not limited to the four features mentioned above. The number of features to be collected can be increased or decreased according to actual needs and capabilities, and this application embodiment does not impose any restrictions on this. Regardless of the number of features, the model construction process is not affected.

[0218] The training device can use the training set shown in Table 2 or Table 3 to train the initial first model. If the first model meets the training termination condition, the first model is obtained.

[0219] For example, the first model obtained using the training set shown in Table 1 above fits the reading speed, device dirtiness, and file fragmentation rate, and the schematic diagram of the fitting relationship between these three factors is shown below. Figure 9 As shown. Given the fitting relationship, and having obtained any two of the above three factors, the third can be obtained through the mathematical inverse solution method using the fitting relationship between them.

[0220] For example, see Figure 10The document organization method provided in this application embodiment may include steps S900-S903.

[0221] S900. Select the target file on your phone.

[0222] For a further description of this step, please refer to step S702 above, which will not be repeated here.

[0223] S901. The mobile phone determines the FBO execution threshold that matches the current state of the UFS device.

[0224] As one possible implementation, the mobile phone can obtain a fitted relationship between the file fragmentation rate (represented by X1), other factors affecting file reading speed besides fragmentation rate (e.g., the current state of the UFS device, represented by X2), and file reading speed (represented by Y) through a first model trained by the offline training device. For example, Y = f(X1, X2).

[0225] Subsequently, the first model, which has been trained offline, is deployed in the mobile phone algorithm program. In the subsequent FBO process, before the mobile phone sets the FBO execution threshold, the mobile phone, based on the deployed first model, further solves the target execution threshold according to the two-step inverse problem solving method provided in the embodiments of this application (that is, the mobile phone obtains the FBO execution threshold that matches the current state of the UFS device).

[0226] For example, see Figure 11 The first step of the two-step inverse problem solving method is: given X1 and Y, solve X2 according to the model inverse problem. For example, after the mobile phone obtains the fragmentation rate (e.g., X1) and reading speed (e.g., Y) of the target file, the mobile phone obtains X2 based on the fitting relationship presented by the first model.

[0227] The second step of the two-step inverse problem solution method is as follows: Given X2 and Y' (the lower limit of the acceptable decrease in target file read speed, i.e., the file read speed decrease threshold), X1' is obtained by solving the inverse problem of the model, which is the FBO execution threshold that matches the current state of the UFS device. For example, the mobile phone can obtain Y' based on the preset speed decrease threshold and the target file read speed when the UFS device is in good condition. Then, the mobile phone obtains X1' based on the fitting relationship presented by the first model. For further explanation of the preset speed decrease threshold and the target file read speed when the device is in good condition, please refer to the previous explanation of Factor 1, which will not be repeated here.

[0228] For a further description of the first step in the two-step inverse problem-solving method, please refer to step S1002 below. For a further description of the second step in the two-step inverse problem-solving method, please refer to step S1003 below. These details will not be elaborated here.

[0229] For a further description of this step, please see below. Figure 12 , Figure 13 The corresponding introduction will not be detailed here.

[0230] S902. The mobile phone sets an FBO execution threshold for the UFS device that matches the current state of the UFS device.

[0231] S903. The mobile phone triggers the UFS device to perform FBO processing on the target file based on the FBO execution threshold that matches the current state of the UFS device.

[0232] For example, if the overall fragmentation rate of the target file is greater than or equal to the FBO execution threshold that matches the current state of the UFS device, the UFS device performs FBO processing on the target file.

[0233] For example, the target includes a first LBA segment, the fragmentation rate of which is greater than or equal to an FBO execution threshold matching the current state of the storage device. The UFS device performs FBO processing on the first LBA segment. When the first LBA segment includes multiple segments, the mobile phone can instruct the UFS device to perform FBO processing on each segment of the first LBA segment separately. Alternatively, the mobile phone can instruct the UFS device to perform FBO processing on all segments of the first LBA segment uniformly.

[0234] For example, the target file includes a first LBA segment, and the fragmentation rate of the first LBA segment is greater than or equal to an FBO execution threshold that matches the current state of the storage device. If the size of the first LBA segment is greater than or equal to the size of the target file in a preset ratio, the UFS device performs FBO processing on the first LBA segment. This preset ratio can be 30%, 45%, etc.

[0235] For a further description of steps S902 and S903, please refer to the preceding text. Figure 3 , Figure 4 The corresponding introduction will not be elaborated here.

[0236] For example, see Figure 12 In some embodiments of this application, the document organization method can determine the FBO execution threshold that matches the current state of the UFS device through steps S1000-S1003.

[0237] S1000: Mobile phone obtains the reading speed of the target file.

[0238] The target file can be one or more complete files. Alternatively, the target file can be understood as one or more LBA segments of a file. For further details on how to select the target file, please refer to the relevant description in step S702 above, which will not be repeated here.

[0239] S1001. The mobile phone obtains the fragmentation rate of the target file.

[0240] For further details on step S1001, please refer to the above. Figure 3 The corresponding descriptions will not be repeated here.

[0241] It is understood that in some embodiments, step S1000 may be executed after step S1001, or the mobile phone may execute steps S1001 and S1000 in parallel, and the embodiments of this application do not limit this.

[0242] S1002. The mobile phone uses an optimization algorithm based on the first model to obtain the current state of the UFS device by optimizing the reading speed and fragmentation rate of the target file.

[0243] In one possible implementation, the mobile phone can input the target file reading speed and a first attempt value into a first model, and the first model outputs a first attempt result corresponding to the first attempt value. The mobile phone takes minimizing the difference between the first attempt result and the target file reading speed as the optimization objective, and uses an optimization algorithm to iterate the first attempt value to obtain a first objective optimization solution. The first optimization solution corresponds to the first optimization result with the minimum difference between the target file reading speed and the first optimization result. Then, the mobile phone uses the first objective optimization solution as the current state of the UFS device. The optimization algorithm can be gradient descent, conjugate gradient method, BFGS algorithm, Nelder-Mead simplex method, etc. This application embodiment is not limited in this respect.

[0244] In cases where the mobile phone obtains multiple first objective optimization solutions by iterating the first attempt value using the optimization algorithm, the mobile phone can take the first objective optimization solution with the smallest value as the current state of the UFS device.

[0245] S1003. Based on the first model, the mobile phone uses an optimization algorithm to obtain an FBO execution threshold that matches the current state of the UFS device and the preset file read speed reduction threshold.

[0246] In one possible implementation, the mobile phone can input the second attempt value and the current state of the UFS device into the first model, and the first model inputs the second attempt result corresponding to the second attempt value. The mobile phone takes minimizing the difference between the preset descent threshold and the second attempt result as the optimization objective, and uses an optimization algorithm to iterate the second attempt value to obtain the second objective optimization solution. The second objective optimization solution has the smallest difference from the preset descent threshold. Then, the mobile phone rounds the second objective optimization solution and uses it as the FBO execution threshold that matches the current state of the UFS device. The optimization algorithm used in step S1003 can be the same as the optimization algorithm used in step S1002 above; they can be the same or different, and this application embodiment does not impose any restrictions on this.

[0247] In the case where the mobile phone obtains multiple second objective optimization solutions by iterating the second attempt value using the optimization algorithm, the mobile phone can take the second objective optimization solution that meets the constraint conditions of the second objective optimization solution and has the smallest value, and round it down as the current state of the UFS device. The constraint condition of the second objective optimization solution is: the second objective optimization solution ∈ [0,10].

[0248] Based on steps S1000-S1003, the mobile phone sets an FBO threshold that matches the current operating state of the storage device. Compared to the mobile phone triggering FBO processing of the target file through a fixed threshold, this allows the mobile phone to trigger FBO processing of the target file more flexibly, thereby improving the FBO effect.

[0249] For example, in scenarios where the UFS device is in poor condition, the target file read speed is more likely to fall below the file read speed reduction threshold due to various factors, and the target file expects to recover its read speed in a timely manner. In scenarios where the UFS device is in poor condition, when a fixed FBO execution threshold is used, the fixed FBO execution threshold is 5. However, in scenarios where the UFS device is in poor condition, when the target file read speed is at a fragmentation rate of 4, the target file read speed is already below the file read speed reduction threshold. Since the fragmentation rate (4) of the target file is less than the fixed FBO execution threshold (5), the phone will not trigger the UFS device to perform FBO processing on the target file. This will result in the target file read speed not being recovered in a timely manner.

[0250] Similarly, in scenarios where the UFS device is in poor condition, the fragmentation rate of the target file is 4. When a technical solution is adopted that matches the FBO threshold to the current state of the UFS device, the FBA execution threshold can be dynamically (appropriately) adjusted by the phone to 4 (or lower). In this way, since the fragmentation rate of the target file will be equal to (or less than) the FBO threshold matching the current state of the UFS device, the phone will trigger the UFS device to perform FBO processing on the target file. Therefore, by performing FBO processing on the target file, the read and write speed of the target file can be improved, meaning that the file read speed is restored in a timely manner.

[0251] For example, in scenarios where storage devices are in good condition, the target file read speed is less likely to fall below the file read speed degradation threshold. In this case, the target device aims to reduce the number of files for which FBO (Fragmentation-Based Optimization) is performed to minimize wear and tear on the storage device. In scenarios where storage devices are in good condition, when the target file read speed is at a PBA (Particle Balance Optimization) fragmentation level of 7, the target file read speed will fall below the file read speed degradation threshold. When using a fixed FBO execution threshold, if the fixed FBO execution threshold is (somewhat inappropriately) set to a low value, such as 3, from the perspective of the target file itself, it is easier for its fragmentation rate to deteriorate to 3 than to 7. From the perspective of the number of files, the number of target files with a PBA fragmentation level greater than or equal to 3 will be greater (usually much greater) than the number of target files with a PBA fragmentation level greater than or equal to 7. In scenarios where storage devices are in good condition, when the target file's PBA fragmentation level is 5, because the target file's PBA fragmentation level is higher than the fixed FBO execution threshold, the electronic device will trigger the storage device to perform FBO processing on the target file. In other words, a fixed FBO execution threshold may lead to more (unnecessary) file defragmentation, increase data movement operations within storage devices, and exacerbate the wear and tear on storage device lifespan.

[0252] Similarly, in a scenario where the UFS device is in good condition, the fragmentation rate of the target file is 5. When using a technical solution that matches the current state of the UFS device with the FBO execution threshold, the FBO execution threshold can be dynamically (appropriately) adjusted by the phone to a higher value, such as 6 (or higher). If the fragmentation rate of the target file is below the FBO execution threshold, the phone will not trigger the UFS device to perform FBO processing on the target file. The phone will trigger the UFS device to perform FBO processing on files with a PBA fragmentation rate higher than the FBO execution threshold. This mitigates the situation where the phone triggers defragmentation on the target file when its fragmentation rate is low (with limited impact on current read speed), thus avoiding unnecessary defragmentation. The phone will only trigger the UFS device to perform FBO processing on the target file when its fragmentation rate reaches (equal to or higher than) the dynamic FBO execution threshold.

[0253] It is evident that by employing a technical solution that matches the current state of the UFS device, the mobile phone can, on the one hand, lower the FBO execution threshold in scenarios where the UFS device is in poor condition, allowing more files to be defragmented and thus restoring file read speed in a timely manner; on the other hand, it can raise the FBO execution threshold in scenarios where the UFS device is in good condition, defragmenting only files with a high degree of fragmentation degradation, reducing unnecessary defragmentation (reducing the number of files processed by FBO). This ensures that the necessary file read speeds are restored while conserving valuable CPU computing resources, reducing data transfer operations within the UFS device, and minimizing wear and tear on the UFS device's lifespan.

[0254] It should be understood that, in practical use, the technical effects of using an FBO execution threshold that matches the current state of the UFS device are not limited to the examples described above. Similarly, the technical effects of using an FBO execution threshold that matches the current state of the UFS device do not impose any limitations on the technical solutions provided in the embodiments of this application.

[0255] For example, see Figure 13 In some embodiments of this application, the document organization method can determine the FBO execution threshold that matches the current state of the UFS device through the following steps S1100-S1104.

[0256] S1100. The mobile phone obtains the reading speed of K files included in the target file.

[0257] Where K is a positive integer. When the target file comprises multiple files, retrieving all of them would be time-consuming. Therefore, some technical solutions allow the mobile phone to retrieve only a portion of the target files (e.g., K files). This saves valuable computing and time resources.

[0258] As one possible implementation, the mobile phone can obtain the reading speed of K files by performing read operations on K files. For example, the phone can record the timestamp of starting to read a certain file among the K files, and the timestamp of completing the reading of that file. The phone subtracts these two timestamps to obtain the reading speed of that file.

[0259] Furthermore, in this implementation, the mobile phone can read a portion of the data from each of the K files, thus further reducing the reading time required for file reading. For example, the mobile phone can read 10MB of data from each of the K files, or it can read 10% of the data from each of the K files. This application embodiment does not limit the size of the partial data.

[0260] S1101. The mobile phone obtains the fragmentation rate of the above K files.

[0261] For further details on step S1101, please refer to the above. Figure 3 The corresponding descriptions will not be repeated here.

[0262] S1102. Based on the first model, the mobile phone uses optimization algorithms to optimize the reading speed and fragmentation rate of K files respectively, and obtains the current state of the UFS device corresponding to each file.

[0263] S1103. The mobile phone uses the average value of the current state of the UFS device corresponding to each file as the current state of the UFS device.

[0264] For example, when K is 3, the K files include a first file, a second file, and a third file. The phone uses an optimization algorithm based on the first model to optimize the read speed and fragmentation rate of the first file, obtaining the current state of the UFS device corresponding to the first file. The phone uses the same algorithm to optimize the read speed and fragmentation rate of the second file, obtaining the current state of the UFS device corresponding to the second file. The phone uses the same algorithm to optimize the read speed and fragmentation rate of the third file, obtaining the current state of the UFS device corresponding to the third file. The phone can use the average of the current states of the UFS devices corresponding to the first, second, and third files as the current state of the UFS device.

[0265] As one possible implementation, after step S1103, the mobile phone can further calculate the coefficient of variation of the current state of the UFS devices corresponding to the K files. If the coefficient of variation exceeds a preset threshold (e.g., 0.1, 0.2, etc.), the mobile phone does not set the FBO execution threshold for the target file. That is, the mobile phone does not execute the subsequent step S1104, and the mobile phone does not set the FBO execution threshold for the target file.

[0266] It should be understood that the coefficient of variation measures the dispersion of data (i.e., the current state of the UFS devices corresponding to K files). When the K files are stored on the same UFS device, the dispersion of the current state of the UFS devices corresponding to these K files should be low. If the coefficient of variation exceeds a preset value, it may indicate that the current state of the UFS devices obtained by the phone is inaccurate. In this case, the phone can refrain from setting an FBO (Fulfilled Item Optimization) threshold. This avoids interference caused by inaccurate current states of the UFS devices.

[0267] For example, with K = 3, the fragmentation rate of the first file is 49%, the fragmentation rate of the second file is 15%, and the fragmentation rate of the third file is 30%. The read speed of the first file is 300MB / s, the read speed of the second file is 1400MB / s, and the read speed of the third file is 800MB / s. Based on the first model, the current state of the UFS device corresponding to the three files obtained by the mobile phone is: the current state of the UFS device corresponding to the first file is a, the current state of the UFS device corresponding to the second file is b, and the current state of the UFS device corresponding to the third file is c. If the coefficients of variation of a, b, and c are less than 0.1, the current state of the UFS device is the average of a, b, and c.

[0268] After step S1103, the mobile phone executes step S1104.

[0269] S1104. The mobile phone uses an optimization algorithm based on the first model to obtain an FBO execution threshold that matches the current state of the UFS device and the preset decline threshold.

[0270] For further details on steps S1103 and S1104, please refer to the previous descriptions of steps S1002 and S1003, which will not be repeated here.

[0271] contrast Figure 12 and Figure 13 The technical solution is visible. Figure 13 The corresponding technical solution uses K files to determine the current state of the UFS device. Compared to Figure 12 The corresponding technical solution, Figure 13 The corresponding technical solution can more accurately determine the current state of the UFS device. Because the mobile phone can more accurately determine the current state of the UFS device, it can then set an FBO execution threshold that better matches the current state of the UFS device.

[0272] In other implementations, the mobile phone can also obtain the read speed of one or more target file LBA segments (e.g., K segments), and the fragmentation rate of one or more target file LBA segments (e.g., K segments). Then, the mobile phone determines the current state of the UFS device using the one or more target file LBA segments (e.g., K segments). It should be understood that this implementation is different from the one described above. Figure 13 The corresponding technical solutions are similar and will not be elaborated upon.

[0273] The file organization method provided in this application embodiment will be further described below in conjunction with the architecture of a mobile phone.

[0274] For example, see Figure 14The document organization method provided in this application embodiment may include steps S1200-S1205. It should be understood that the above... Figure 14 The software modules shown are merely examples. In actual use, mobile phones can also perform the above steps S1200-S1205 through other similar software modules. This application embodiment does not limit this.

[0275] S1200. If the mobile phone meets the file organization conditions, the SMS instructs the initiation of the process to perform FBO processing on the UFS device.

[0276] It should be understood that performing FBO (Fulfilled Item Buy) processing on a phone's UFS device while the user is using the phone may degrade the user experience. Therefore, when the user does not use the phone frequently, SMS can instruct the initiation of the FBO process on the UFS device. This can improve the user experience.

[0277] For example, a phone might meet the criteria for file organization if: the screen has been off for more than 20 minutes and the battery level is above 50%; or, the current time falls within a period of low phone usage frequency. For instance, these periods of low usage frequency can be determined through analysis of user habits. Alternatively, these periods can be preset, such as 0:00-4:00.

[0278] As one possible implementation, SMS can invoke the first interface to instruct the initiation of a process to perform FBO processing on the UFS device. The first interface, as mentioned above, can be the RunIdleMaint interface.

[0279] As one possible implementation, SMS can receive the aforementioned screen-off broadcast by subscribing to broadcast receivers.

[0280] S1201. In response to the SMS instruction to initiate the process of performing FBO processing on the UFS device, the first process determines the target file.

[0281] The aforementioned first process can be a process on the mobile phone used for storage management, such as a storage management process. Alternatively, the aforementioned first process can also be other local layer processes, such as a child process of the init process, etc. The specific design can be made according to actual usage needs, and this application embodiment does not limit this.

[0282] The first process of determining the target file may include: the first process using files whose size exceeds a second value as the target file; or, the first process using LBA segments whose length exceeds a third value from files whose size exceeds the second value as the target file. It should be understood that performing FBO on a relatively small file will reduce FBO benefits. Similarly, a file may include multiple LBA segments, where the length of each LBA segment corresponds to its size. Performing FBO on smaller LBA segments will also reduce FBO benefits. Therefore, in some implementations, performing FBO on longer LBA segments can improve FBO benefits.

[0283] In other implementations, the first process may also determine the target file based on the file's usage frequency. For example, the first process may select a file with a usage frequency higher than a first frequency as the target file.

[0284] In other implementations, the target file can also be determined by the upper-layer business entity. The upper-layer business entity can be an SMS located at the framework layer, or an application related to mobile phone storage management located at the mobile application layer. That is, in this implementation, the first process may not need to determine the target file; instead, the first process obtains the target file determined by the upper-layer business entity.

[0285] S1202. The first process determines the FBO execution threshold that matches the current state of the UFS device.

[0286] For example, the first process can determine the FBO execution threshold matching the current state of the UFS device through the above steps S1000-S1003. Alternatively, the storage management process can also determine the FBO execution threshold matching the current state of the UFS device through the above steps S1100-S1104.

[0287] As one possible implementation, after the first process determines an FBO execution threshold that matches the current state of the UFS device, the first process can instruct the storage management driver to set the FBO execution threshold by calling a specific interface exposed by the storage device driver (e.g., a sysfs node) or a function interface provided by the driver based on a kernel-specific system call (e.g., the ioctl system call).

[0288] S1203. The storage management driver sets an FBO execution threshold for the UFS device that matches the current state of the UFS device.

[0289] For example, if the FBO execution threshold determined in step S1202 above that matches the current state of the UFS device is 3, the storage management driver sets the bFBOExecuteThreshold attribute of the UFS device to 0x03.

[0290] S1204. The storage management driver obtains the fragmentation rate of the target file.

[0291] For further details on step S1204, please refer to the previous description of step S704, which will not be repeated here.

[0292] S1205. If the fragmentation rate of the target file is greater than or equal to the FBO execution threshold that matches the current state of the UFS device, the storage management driver triggers the UFS device to perform FBO processing on the target file.

[0293] For further details on step S1205, please refer to the description of step S705 above, which will not be repeated here.

[0294] For example, see Figure 15 Another document organization method provided in this application embodiment may include steps S1500-S1507.

[0295] S1500. If the mobile phone meets the file organization conditions, the SMS instructs the initiation of the process to perform FBO processing on the UFS device.

[0296] For a further description of this step, please refer to the description of step S1200 above, which will not be repeated here.

[0297] S1501. The first process loads the first model.

[0298] The first model can be a pre-trained model file based on multi-factor fitting.

[0299] S1502. The first process checks whether the UFS device supports FBO processing.

[0300] As one possible implementation, the first process can read the FBO descriptor (e.g., FBO_Descriptor) of the UFS device to determine the FBO capability of the UFS device, that is, whether the UFS device supports FBO processing.

[0301] S1503. The first process obtains the reading speed of the K files included in the target file.

[0302] For a further description of this step, please refer to step S1100 above, which will not be repeated here.

[0303] S1504. The first process obtains the fragmentation rate of K files.

[0304] For a further description of this step, please refer to step S1101 above, which will not be repeated here.

[0305] S1505. The first process uses a two-step inverse problem-solving method based on the first model to obtain the FBO execution threshold that matches the current state of the UFS device.

[0306] For a further description of this step, please refer to steps S1102-S1104 above, which will not be repeated here.

[0307] S1506. The storage management driver sets the above-mentioned FBO execution threshold for the UFS device.

[0308] As one possible implementation, the storage management driver can first issue optimization commands to K files, instructing the UFS device to perform FBO processing on the K files based on an FBO execution threshold that matches the current state of the UFS device. Then, after the UFS device performs FBO processing on the K files, it can issue optimization commands to the files outside the K files in the target file, instructing the UFS device to perform FBO processing on the files outside the K files in the target file based on an FBO execution threshold that matches the current state of the UFS device.

[0309] As another possible implementation, storage management startup can also directly issue optimization commands to the target file, instructing the UFS device to perform FBO processing on the target file based on an FBO execution threshold that matches the current state of the UFS device.

[0310] S1507. The storage management driver is waiting for the UFS device to complete the FBO execution.

[0311] It should be noted that the personal information used in the technical solution of this application is limited to information for which individual consent has been obtained, including but not limited to notifying and reminding users to read the relevant user agreement (notification) and sign the agreement (authorization) which includes authorization of relevant user information before users use the function.

[0312] Based on the algorithmic steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementations should not be considered beyond the scope of this application.

[0313] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0314] This application also provides an electronic device, such as... Figure 16 As shown, the electronic device may include one or more processors 2101, memory 2102 and communication interfaces 2103.

[0315] The memory 2102, communication interface 2103, and processor 2101 are coupled together. For example, the memory 2102, communication interface 2103, and processor 2101 can be coupled together via bus 2104.

[0316] The communication interface 2103 is used for data transmission with other devices. The memory 2102 stores computer program code. The computer program code includes computer instructions, which, when executed by the processor 2101, cause the electronic device to perform the relevant method steps in the above-described method embodiments of this application.

[0317] The processor 2101 can be a processor or controller, such as a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in connection with this disclosure. The processor can also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0318] Bus 2104 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Bus 2104 can be categorized into address bus, data bus, control bus, etc. For ease of representation, Figure 16 The symbol is represented by only one line, but this does not mean that there is only one bus or one type of bus.

[0319] This application also provides a chip system, such as... Figure 17 As shown, the chip system 2200 includes at least one processor 2201 and at least one interface circuit 2202. The processor 2201 and the interface circuit 2202 are interconnected via lines. For example, the interface circuit 2202 can be used to receive signals from other devices (e.g., the memory of an electronic device). As another example, the interface circuit 2202 can be used to send signals to other devices (e.g., the processor 2201). Exemplarily, the interface circuit 2202 can read instructions stored in the memory and send those instructions to the processor 2201. When the instructions are executed by the processor 2201, the electronic device can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, and this application embodiment does not specifically limit this.

[0320] This application also provides a computer-readable storage medium storing computer program code. When the processor executes the computer program code, the electronic device executes the relevant method steps in the above method embodiments.

[0321] This application also provides a computer program product that, when run on a computer, causes the computer to execute the relevant method steps described in the above method embodiments.

[0322] The electronic devices, computer-readable storage media, or computer program products provided in this application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0323] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0324] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0325] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0326] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0327] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, in essence, or the part that contributes, or all or part of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0328] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for organizing documents, characterized in that, The method is applied to an electronic device, the electronic device including a storage device; the method includes: Select the target file; Determine an FBO execution threshold that matches the current state of the storage device; the current state of the storage device includes one or more of the following: the current operating temperature of the storage device, the current background I / O pressure of the storage device, and the current dirty level of the storage device. Set the FBO execution threshold that matches the current state of the storage device to the storage device; The storage device is triggered to perform FBO processing on the target file based on the FBO execution threshold that matches the current state of the storage device.

2. The method according to claim 1, characterized in that, Determining the FBO execution threshold that matches the current state of the storage device includes: Obtain the fragmentation rate of the target file; Obtain the reading speed of the target file; The first model is used to apply a first optimization algorithm to the fragmentation rate and the read speed to obtain the current state of the storage device; the first model fits the relationship between the file read speed, the file fragmentation rate and the current state of the storage device. Based on the first model, a second optimization algorithm is used to obtain an FBO execution threshold that matches the current state of the storage device and a preset read speed decrease threshold.

3. The method according to claim 2, characterized in that, The target file comprises n files, where n is a positive integer; the fragmentation rate of the target file is obtained by: Obtain the fragmentation rate of k files among the n files; where k is a positive integer and k is less than n; The reading speed of the target file includes: Obtain the reading speed of the k files; The step of using a first optimization algorithm based on the first model to obtain the current state of the storage device, including: Based on the first model, the first optimization algorithm is applied to the fragmentation rate of k files and the fragmentation rate of k files respectively to obtain the current state of the storage device corresponding to the k files; The average value of the current states of the storage devices corresponding to the k files is taken as the current state of the storage device.

4. The method according to claim 3, characterized in that, The method further includes: if the coefficient of variation of the current state of the storage device corresponding to the k files exceeds a preset coefficient of variation threshold, then the FBO execution threshold is not set for the target file.

5. The method according to claim 2, characterized in that, The input to the first model is the file fragmentation rate and the current state of the storage device, and the output of the first model is the file reading speed; The step of using a first optimization algorithm based on the first model to obtain the current state of the storage device, based on the fragmentation rate and the read speed, includes: The fragmentation rate of the target file and the first attempt value are input into the first model, and the first model outputs the first attempt result corresponding to the first attempt value. The first target value is obtained by iterating the first attempt value using the first optimization algorithm; the first target value corresponds to the first target result, and the difference between the first target result and the reading speed of the target file is minimized; The first target value is taken as the current state of the storage device.

6. The method according to claim 5, characterized in that, The second optimization algorithm, based on the first model and a preset read speed decrease threshold, is used to obtain an FBO execution threshold that matches the current state of the storage device, including: Input the current state of the storage device and the second attempt value into the first model, and obtain the second attempt result output by the first model; The second target value is obtained by iterating the second attempt value using the second optimization algorithm; the second target value corresponds to the second target result, and the difference between the second target result and the preset descent threshold is minimized; The second target value is used as the FBO execution threshold that matches the current state of the storage device.

7. The method according to claim 5 or 6, characterized in that, Using the second target value as the FBO execution threshold that matches the current state of the storage device includes: When the second target value corresponds to multiple second target results, the smallest second target value is rounded down and used as the FBO execution threshold that matches the current state of the storage device.

8. The method according to any one of claims 2-7, characterized in that, The second optimization algorithm includes any one of the following: gradient descent, conjugate gradient method, BFGS algorithm, and Nelder-Mead simplex method.

9. The method according to any one of claims 1-8, characterized in that, The target files include files whose usage frequency is higher than a preset frequency threshold.

10. The method according to any one of claims 1-9, characterized in that, The step of triggering the storage device to perform FBO processing on the target file based on the FBO execution threshold matching the current state of the storage device includes: If the overall fragmentation rate of the target file is greater than or equal to the FBO execution threshold that matches the current state of the storage device, then FBO processing is performed on the target file. Alternatively, perform FBO processing on the first LBA segment; Alternatively, if the ratio of the size of the first LBA segment to the size of the target file is greater than or equal to a preset ratio, the first LBA segment is subjected to FBO processing. The first LBA segment is an LBA segment included in the target file, and whose fragmentation rate is greater than or equal to the FBO execution threshold that matches the current state of the storage device.

11. The method according to any one of claims 1-10, characterized in that, Setting the FBO execution threshold that matches the current state of the storage device includes: Set the FBO execution threshold attribute of the storage device to the encoding corresponding to the FBO execution threshold that matches the current state of the storage device.

12. The method according to any one of claims 1-11, characterized in that, The first model includes any one of the following: BP neural network, CNN neural network, and RNN neural network.

13. An electronic device, characterized in that, The electronic device includes a processor and a memory; the processor is coupled to the memory; the memory is used to store computer program code; the computer program code includes computer instructions, which, when executed by the processor, cause the electronic device to perform the method as described in any one of claims 1-12.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-12.

15. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the processors being configured to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1-12.