A storage control method and device

By acquiring file information and matching target storage blocks, the write amplification and fragmentation issues of solid-state drives under random write operations are resolved, storage space utilization is optimized, and the performance and lifespan of storage devices are improved.

CN119336260BActive Publication Date: 2025-11-21LENOVO (BEIJING) LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411391000.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-11-21
Estimated Expiration
2044-09-30

AI Technical Summary

Technical Problem

Solid-state drives (SSDs) face write amplification and fragmentation issues under heavy random write operations, leading to performance degradation and shortened lifespan.

Method used

By obtaining the file information of the target file, the matching target storage block is determined from the target storage area based on the file information, and the target storage device is controlled to perform a write operation to write the file to the target block. The target block includes the target storage block or a storage area associated with it.

Benefits of technology

It optimizes storage space utilization, reduces write operation latency, and improves system flexibility and storage device performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336260B_ABST
    Figure CN119336260B_ABST
Patent Text Reader

Abstract

The application discloses a storage control method and device. The method comprises the following steps: obtaining file information of a target file in response to obtaining a write operation of the target file; determining a target storage block matched with the file information from a target storage area based on the file information, wherein the target storage area is an area configured with storage blocks with different storage capacities, and the target storage area belongs to a target storage device or a target cache; and controlling the target storage device to perform a write operation of writing the target file into a target block, wherein the target block comprises the target storage block or a storage area having a target correlation relationship with the target storage block. The application can effectively manage storage resources according to file attributes, and can optimize the use of storage space by matching file information and storage blocks. In addition, quick positioning and allocation of storage blocks can reduce the delay of write operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to a storage control method and apparatus. Background Technology

[0002] As solid-state drives (SSDs) gradually become the mainstream storage medium, they have demonstrated significant advantages in improving data access speed and reducing access latency. However, under heavy random write operations, SSDs face disk fragmentation and write amplification issues, which severely impact their performance. In SSDs, due to the physical characteristics of NAND flash memory, write operations do not directly update data in the original location; instead, data must be erased before being written—a process known as write amplification (WA). Write amplification not only increases the amount of data written but also accelerates wear and tear on the SSD, leading to performance degradation and a shortened lifespan. Furthermore, a large number of random write operations result in uneven utilization of storage blocks, causing fragmentation and further reducing storage efficiency. Summary of the Invention

[0003] This application provides a storage control method, including:

[0004] In response to receiving a write operation for the target file, the file information of the target file is obtained;

[0005] Based on the file information, a target storage block matching the file information is determined from the target storage area. The target storage area is an area configured with storage blocks of different storage capacities. The target storage area belongs to the target storage device or the target cache.

[0006] Control the target storage device to perform a write operation to write the target file to a target block, wherein the target block includes the target storage block or a storage area that has a target association with the target storage block.

[0007] As an optional embodiment, obtaining the file information of the target file includes at least one of the following:

[0008] In response to receiving a write operation for a target file, the system intercepts the instruction or request that triggers the write operation through a target filter driver and obtains the file information of the target file.

[0009] Obtain the source information and / or file size information of the target file;

[0010] Obtain the tag information of the target file.

[0011] As an optional embodiment, obtaining the tag information of the target file includes at least one of the following:

[0012] Obtain historical access data for the target file, and generate tag information for the target file based on the historical access data;

[0013] Obtain reference information for the target file, and determine matching tag information from the target tag library based on the reference information;

[0014] Obtain the target operation applied to the target file, and configure the tag information of the target file based on the target operation.

[0015] As an optional embodiment, determining a target storage block matching the file information from the target storage area based on the file information includes:

[0016] If the file information indicates that the target file comes from a first application or a first electronic device, a target storage block that matches the file size of the target file is determined.

[0017] The target file is written to the target block of the target storage device based on the storage address determined by the target storage block.

[0018] As an optional embodiment, writing the target file to the target block of the target storage device based on the storage address determined by the target storage block includes at least one of the following:

[0019] If the target storage area is located in the target storage device, the target file is written to the target storage block based on the first storage address of the target storage block;

[0020] When the target storage area is located in the target cache, the second storage address of the target block corresponding to the target storage block in the target storage device is determined based on the mapping relationship between the target storage area and the target storage device, so as to write the target file to the target block based on the second storage address.

[0021] As an optional embodiment, determining the target storage block matching the file information from the target storage area based on the file information further includes at least one of the following:

[0022] Obtain usage information for each storage block in the target storage area, and determine the target storage block that matches the file information from the target storage area based on the file information and the usage information;

[0023] The wear level of each storage block in the target storage area is obtained, and a target storage block matching the file information is determined from the target storage area based on the file information and the wear level.

[0024] As an optional embodiment, it also includes at least one of the following:

[0025] After the target block is written to the target file, there is also free space, which is filled.

[0026] In the case that the write operation is the first write operation, the target storage region is created in the target storage device or target cache.

[0027] As an optional embodiment, creating the target storage region includes:

[0028] In response to receiving a creation operation to create the target storage region, a storage space of a first capacity size is determined from the target storage region, and several storage blocks of different capacity sizes are configured according to a first storage block as the smallest storage unit, wherein the capacity of the storage block is an integer multiple of the first storage block;

[0029] Generate a file mapping table that represents the address mapping relationship between storage blocks in the target storage area and blocks in the target storage device, and store the file mapping table in the target storage area.

[0030] As an optional embodiment, it also includes at least one of the following:

[0031] In response to receiving a deletion operation for the target file, the target file is deleted from the target block, and the status identifier of the corresponding target storage block in the target storage area is updated;

[0032] In response to receiving a read operation for the target file, all or part of the data is read from the target block.

[0033] This application embodiment also provides a storage control device, including:

[0034] The acquisition module is configured to acquire file information of the target file in response to a write operation on the target file.

[0035] The determination module is configured to determine a target storage block that matches the file information from the target storage area based on the file information. The target storage area is an area configured with storage blocks of different storage capacities, and the target storage area belongs to a target storage device or a target cache.

[0036] An execution module is configured to control the target storage device to perform a write operation to write the target file to a target block, wherein the target block includes the target storage block or a storage area that has a target association with the target storage block. Attached Figure Description

[0037] Figure 1 This is a flowchart of a storage control method according to an embodiment of this application;

[0038] Figure 2 This is a flowchart of step S2 of the storage control method in an embodiment of this application;

[0039] Figure 3 This is a flowchart of step S0 of the storage control method according to an embodiment of this application;

[0040] Figure 4 This is a schematic diagram illustrating the partitioning of multiple target storage blocks according to an embodiment of this application;

[0041] Figure 5 This is a schematic diagram showing the sequence numbers of multiple target storage blocks in an embodiment of this application;

[0042] Figure 6 This is a schematic diagram illustrating the correspondence between target files and target storage blocks in an embodiment of this application;

[0043] Figure 7 This is a structural block diagram of a storage control device according to an embodiment of this application. Detailed Implementation

[0044] Various embodiments and features of this application are described herein with reference to the accompanying drawings.

[0045] It should be understood that various modifications can be made to the embodiments described herein. Therefore, the above description should not be considered as limiting, but merely as an example of embodiments. Other modifications within the scope and spirit of this application will be apparent to those skilled in the art.

[0046] The accompanying drawings, which are included in and form part of this specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.

[0047] These and other features of this application will become apparent from the following description of preferred forms of embodiments given as non-limiting examples, with reference to the accompanying drawings.

[0048] It should also be understood that although this application has been described with reference to some specific examples, those skilled in the art can certainly implement many other equivalent forms of this application.

[0049] The above and other aspects, features and advantages of this application will become more apparent when taken in conjunction with the accompanying drawings and in view of the following detailed description.

[0050] Specific embodiments of this application are described thereafter with reference to the accompanying drawings; however, it should be understood that the claimed embodiments are merely examples of this application, which can be implemented in various ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that could obscure the application. Therefore, the specific structural and functional details claimed herein are not intended to be limiting, but merely serve as the basis and representative basis for the claims to teach those skilled in the art to use this application in a variety of substantially any suitable detailed structures.

[0051] This specification may use the phrases “in one embodiment,” “in another embodiment,” “in yet another embodiment,” or “in other embodiments,” all of which may refer to one or more of the same or different embodiments according to this application.

[0052] This application provides a storage control method, such as... Figure 1 As shown, it includes:

[0053] S1. In response to obtaining a write operation for the target file, obtain the file information of the target file.

[0054] In this embodiment, a write operation is an operation to write data to a storage device. It can be an active operation or a series of operations generated by an application. An active operation refers to a write operation directly initiated by the user or the system, such as when a user intentionally saves a file to the hard drive, or when the system periodically backs up data.

[0055] Application-inducing operations refer to write operations that are automatically generated during application runtime. These operations are not directly initiated by the user, but rather are side effects of the application performing its functions. Examples include database transaction logs, game progress saving, or temporary file writes during software updates.

[0056] When a write operation request for a target file is received, the file information of the target file is first obtained. The file information includes metadata such as file size, file source, file type, file name, file owner, permissions, file tags (determined whether it is a hot or cold file based on historical access frequency), and file creation time.

[0057] S2. Based on the file information, determine the target storage block that matches the file information from the target storage area. The target storage area is an area configured with storage blocks of different storage capacities. The target storage area belongs to the target storage device or the target cache.

[0058] In this embodiment, a suitable storage block is located or allocated based on the file information to ensure sufficient space and appropriate characteristics for storing the target file. The target storage block is a storage area that matches the file information of the target file. For example, the file information is the file size; smaller files are allocated smaller storage blocks, while larger files require larger storage blocks.

[0059] Alternatively, the file information can be file tags, and the storage blocks can be divided into multiple levels. Frequently accessed files (hot files) are stored in smaller storage blocks with lower wear levels, while infrequently accessed files (cold files) are stored in larger storage blocks with higher wear levels.

[0060] In addition to considering file information, the status information and wear level of the target storage block can also be taken into account. The status information of the target storage block includes, but is not limited to, whether it is free, damaged, or currently in use. Considering the wear level of the target storage block helps avoid writing important data to blocks that are about to expire.

[0061] A target storage region is an area composed of storage blocks with different storage capacities. These storage blocks (the target storage region) can reside in a storage device or cache. Storage blocks of different capacities refer to the fact that the storage region is divided into physical blocks of various sizes to accommodate storage needs for data of different sizes.

[0062] The target storage area can be physical or virtual, depending on storage requirements and system architecture. For example, the target storage area can be determined directly within the physical storage area of ​​the hard drive. Each storage block has a physical address, and in this case, a physical address on the hard drive is assigned to the file.

[0063] Alternatively, the target storage area can be determined within the cached virtual mapping space. In this case, a virtual address is allocated to the file, and then the virtual address is mapped to a physical address.

[0064] For example, when configuring storage blocks with different storage capacities, a data space is first determined on the hard disk, the size of which is approximately 30% of the hard disk's capacity. The size of this data space is then converted to the block size, which is between a power of two of the block size, 2^ N <30%<2^ N +1 to find N = log2(Space / 4K), where the data size of each block is 4K, which is the storage unit size of the hard drive.

[0065] The data space is divided into multiple storage blocks according to powers of 2, and each storage block is divided into a root node, parent node, left and right child nodes, and leaf nodes. The root node represents the entire storage space. Assuming the entire storage space is 'Size', then the block size represented by the root node is 'Size'. The root node has no parent node; it is the top of the tree.

[0066] When a node is split, it creates two child nodes, called "partners." Each parent node splits into two child nodes of equal size. The parent node's block size is twice that of its child nodes. For example, if the parent node represents an 8MB block, after splitting, the left and right child nodes each represent a 4MB block. Leaf nodes are nodes that cannot be split further; that is, they have no child nodes. The size of a leaf node is typically the smallest block size, such as 4KB.

[0067] For example, a 64MB storage space can be partitioned as follows:

[0068] Root node: Represents the entire 64MB storage space; the size of the root node is 64MB (2^64MB). 26 byte);

[0069] First split: The root node splits into two 32MB blocks, with the left child node being 32MB and the right child node being 32MB.

[0070] Second split: Each 32MB block is split into two 16MB blocks, with the left child of the left child node being 16MB, the right child of the left child node being 16MB, the left child of the right child node being 16MB, and the right child of the right child node being 16MB.

[0071] Continue splitting: halve the size of each block until the minimum required block size is reached.

[0072] Leaf nodes: Stop splitting when the block size reaches 4KB.

[0073] S3. Control the target storage device to perform a write operation to write the target file to a target block, wherein the target block includes the target storage block or a storage area that has a target association relationship with the target storage block.

[0074] In this embodiment, after the target storage block is determined, the target storage device is controlled to perform a write operation to write the target file into the target block. The target block includes the target storage block itself or a storage area associated with the target storage block.

[0075] For example, if the target storage area is located on a hard disk, then the target storage block is the actual physical block on the hard disk, and the target storage block is the actual target block on the hard disk. If the target storage area is located in a cache, then the target block is the block on the hard disk that maps to the target storage block.

[0076] Specifically, when the target storage area belongs to the target storage device, a segment of storage address space needs to be allocated on the target storage device as the target storage area, and the target storage area needs to be configured into storage blocks of different storage capacities, with each storage block having a physical address.

[0077] When the system receives a write operation request, it retrieves the file information of the target file from the request. Based on the file information, the system searches for a suitable target storage block in the available target storage area. If a suitable target storage block is found, the system determines its actual physical address as the write address for the target file, and writes the file data into the allocated target block.

[0078] Alternatively, when the target storage area belongs to the target cache, a target storage area is designated within the target cache that maps to 30% of the capacity of the target storage device (e.g., a hard drive). This target storage area is then configured as storage blocks of different capacities. Each storage block has a corresponding virtual address in the target cache, and this virtual address is mapped to the corresponding storage area on the target storage device. This storage area consists of several blocks, which can be blocks of the smallest storage unit in the target storage device or blocks of different capacities composed of different numbers of the smallest storage units.

[0079] When the system receives a write operation request, it retrieves the file information of the target file from the request. Based on the file information, the system searches for a suitable target storage block in the available target storage area. If a suitable target storage block is found, the system assigns its virtual address to the corresponding physical address to the file, thus writing the file data to the target block on the hard drive to which the target storage block is mapped.

[0080] This application enables efficient management of storage resources based on file attributes. By matching file information with storage blocks, storage space utilization can be optimized. Furthermore, rapid location and allocation of storage blocks reduces write operation latency. The method described in this application is applicable to different storage devices and caches, improving system flexibility.

[0081] For example, when the system needs to allocate space for a file, it requests a storage block of a specific size and searches for the smallest block that can satisfy the request. If a matching block is found, it is directly allocated to the requester. For instance, if the target file is 3MB in size, the smallest power of two that can satisfy the data storage requirement is 2^3MB. 2=4, therefore a target storage block with a capacity of 4MB meets the requirements. The target file size is 120MB, which satisfies the requirement that the smallest power of square for data storage is 2^ 7 =128, then the target storage block with a storage capacity of 128MB meets the requirements.

[0082] In the process of locating the target storage block, the search proceeds from top to bottom according to the target storage block's level (divided by storage capacity from largest to smallest). It starts from the root node, which represents the entire storage capacity.

[0083] Check if the storage capacity of the current node is greater than the requested data size (i.e., file size). If the storage capacity of the current node is greater than the requested data size, continue searching among the left and right child nodes of the current level to determine if there is a smaller block that can satisfy the request.

[0084] When a target storage block with a storage capacity that exactly matches the request is found, this target storage block is marked as "used". At this point, the value of the current target storage block is set to 0, indicating that this space has been occupied.

[0085] Furthermore, once the target storage block is marked as used, the process traces back to the parent node of the allocated block. Within the parent node, its available space is calculated. If both the left and right child nodes of the parent node are marked as used (value 0), the parent node's available space is 0. If at least one child node is not fully used, the parent node's available space will be the maximum value among its left and right child nodes.

[0086] As an optional embodiment, obtaining the file information of the target file includes at least one of the following:

[0087] In response to receiving a write operation for a target file, the instruction or request that triggers the write operation is intercepted by the target filter driver, and the file information of the target file is obtained.

[0088] In this embodiment, before performing a write operation on a file, it is necessary to obtain detailed information about the file. This process can be achieved using a filter driver, which can intercept write requests to the file and extract relevant information. Specifically, the filter driver can intercept and process file requests, such as read or write operations, at the operating system level.

[0089] The file information includes metadata such as file size, file origin, file type, file tags, file creation time, owner, and permissions. File type is categorized based on file format and purpose, such as text files (.txt), image files (.jpg, .png), video files (.mp4, .avi), and audio files (.mp3, .wav). File creation time is the time the file was created, which can be the time of its first creation or the time of its last modification.

[0090] For example, in an Enterprise Resource Planning (ERP) system, a user uploads a sales report. The user uploads a sales report file named "Sales_Report_Q1_2024.xlsx" through the ERP system. The ERP system's filter driver intercepts this write operation request.

[0091] The filter driver retrieves the file's size (2MB), source information (user Alice's computer), and tag information (financial report). The filter driver logs this information in the system log and updates the file's metadata.

[0092] After the filter driver completes information retrieval, it allows file write operations to continue. The system stores the file in the appropriate physical or virtual storage block based on the file size and tag information.

[0093] Obtain the source information and / or file size information of the target file.

[0094] In this embodiment, source information refers to the location or origin of the target file, which can be a specific application, device (such as a scanner or mobile phone), network location, or other storage medium. File size refers to the storage space occupied by the target file, usually expressed in units such as bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB).

[0095] Obtain the tag information of the target file.

[0096] In this embodiment, the tag information, used to describe the content or purpose of a file, can be automatically generated based on the file content or user-defined. The file tags can be information used for classification or priority marking, such as "hot" files indicating frequently accessed files and "cold" files indicating infrequently accessed files.

[0097] Specifically, the filter driver monitors the file system and intercepts write operation requests to target files. Once a write operation is intercepted, the filter driver extracts relevant information about the target file to perform appropriate storage allocation later. After obtaining the necessary information, the filter driver allows the write operation to continue.

[0098] As an optional embodiment, obtaining the tag information of the target file includes at least one of the following:

[0099] Obtain historical access data for the target file, and generate tag information for the target file based on the historical access data.

[0100] In this embodiment, tag information is a type of metadata used to describe the characteristics and attributes of a file to facilitate file management and retrieval. Tag information can be generated based on different standards.

[0101] By analyzing historical access data to determine the frequency and patterns of file access, tags indicating file popularity, such as "frequently used" and "infrequently used," can be generated. Historical access data refers to the historical access data of storage devices, such as hard drives, and typically refers to records of when files or data were accessed, modified, or created. This data can be used to analyze file usage patterns, frequency, and trends. In addition to local hard drives, historical access data can also be stored in the cloud or synchronized to other devices for cross-device access and analysis.

[0102] Specifically, the system tracks and records every access to a file, including the access time and the visitor's identity (if it's remote or cloud-based). For cross-device data, such as data accessed via cloud services or other devices on a local area network, historical access data can be synchronized to the cloud or the target device.

[0103] By analyzing historical access data, we can determine the popularity of files, such as which files are frequently accessed and which are infrequently accessed. Based on the analysis results, files can be categorized, for example, marked as "hot" or "cold," and storage strategies can be optimized accordingly.

[0104] Furthermore, if the target file is a newly generated file, there may not be enough information to directly assign a label to it. In this case, the following methods can be used to generate label information: generate label information based on a predictive model or historical data from associated files.

[0105] Among them, the predictive model uses machine learning models to predict the access patterns or uses of files based on features such as the file's source, type, and creation time, and generates tags accordingly. For example, if a file is created by a specific application during working hours on a weekday, the model might predict that it is a "working file".

[0106] Historical data based on associated files utilizes the association between new files and existing files in the system, such as whether they were created by the same user or belong to the same project. Tags can be generated by referencing the historical access data of associated files. For example, if a user frequently accesses a certain type of file at night, then a new file might also be tagged as "accessed at night."

[0107] Obtain reference information for the target file, and determine matching tag information from the target tag library based on the reference information.

[0108] In this embodiment, if a file is associated with certain well-known reference information, such as a specific project, event, or topic, this reference information can be used to generate tags. The reference information includes, but is not limited to, file source, file type, file name, file storage path, and file creation time.

[0109] Specifically, this includes determining the file's tag information through a predictive model. At this point, the predictive model can predict the file's usage pattern using reference information, thereby determining whether the file is a frequently accessed "hot file" or a less frequently accessed "cold file," helping the system to understand the file's popularity in advance.

[0110] File tagging information is determined by the activity level of the application. If an application frequently creates or modifies certain files, these files are likely to be accessed frequently. The system can monitor application activity and mark related files as "hot files".

[0111] File tagging information is determined by analyzing historical communication data between devices. In a distributed system, this communication data reflects the frequency of file sharing and access. If a file is frequently transferred between multiple devices, it will be marked as a "hot file".

[0112] Obtain the target operation applied to the target file, and configure the tag information of the target file based on the target operation.

[0113] In this embodiment, files may be tagged according to predetermined operations or purposes, including but not limited to backup, archiving, and temporary use. Tags are configured based on the operations to be performed on the file. For example, if a file is intended for backup, it might be tagged as a "backup file".

[0114] Specifically, identify the operations to be performed on the file, such as backup, archiving, or frequent reads. Assign appropriate tags to the file based on the target operation, such as "hot," "cold," or "backup." Store the tag information as file metadata so that the system can use these tags to optimize storage and access strategies.

[0115] As an optional embodiment, wherein, as Figure 2 As shown, determining a target storage block matching the file information from the target storage area based on the file information includes:

[0116] S21. If the file information indicates that the target file comes from a first application or a first electronic device, determine a target storage block that matches the file size of the target file.

[0117] In this embodiment, the system checks the source of the file, such as whether the file was created by a specific application (first application) or from a specific device (first electronic device). These sources are considered to be on a whitelist, meaning they need to be prioritized for storage optimization and access acceleration.

[0118] The system will determine a sufficiently large storage block to accommodate the file based on its size. This ensures that the file is stored intact while avoiding the waste of storage resources caused by allocating excessive space.

[0119] Specifically, to optimize storage and access speed, especially for trusted applications and electronic devices, a whitelist can be set up. When a file is created or accessed, the system checks the file's origin to determine if it belongs to an entity on the whitelist.

[0120] If a file is created or accessed by an application on the whitelist, the system will determine whether it is an application that can be accelerated based on the path of the executing process. If the path of the executing process matches a path on the whitelist, the system will continue to execute preset optimization rules, such as prioritizing cache allocation and increasing I / O priority.

[0121] If a file is not created or accessed by a whitelisted application or device, the system will execute the default file handling logic. The default file handling logic includes basic security checks and disk space management.

[0122] S22. Write the target file to the target block of the target storage device based on the storage address determined by the target storage block.

[0123] In this embodiment, after finding a suitable storage block, the system determines the storage address of that block so that the file can be written to the target block of the target storage device, completing the storage process. Whether the storage address needs to undergo mapping transformation during the file writing process depends on whether the target storage area is located on a physical storage device or in a cache.

[0124] If the target storage area is part of a physical storage device, the file is typically written directly to a physical address on the device. In this case, the storage address usually does not require mapping, because the file's logical address is directly translated to its corresponding physical address.

[0125] If the target storage area is part of a cache, file writes first occur in the cache. In this case, storage address mapping is required because the file's logical address is translated into a virtual address in the cache. When the data in the cache is finally written to the physical storage device, an additional mapping step is performed to map the virtual address to the physical address.

[0126] As an optional embodiment, writing the target file to the target block of the target storage device based on the storage address determined by the target storage block includes at least one of the following:

[0127] When the target storage area is located in the target storage device, the target file is written to the target storage block based on the first storage address of the target storage block.

[0128] In this embodiment, if the target storage area is on the target storage device, the file can be directly written to the physical address of the target storage block allocated to the file. In this case, address mapping is not required.

[0129] For example, a user creates a financial report file named "Financial_Report.docx" using the Word application and chooses to save it to the hard drive. The system allocates a 4MB storage block on the hard drive for this file, with the physical address of the storage block being / storage / ssd1 / block2048. The system writes the file directly to this physical address without requiring address mapping.

[0130] When the target storage area is located in the target cache, the second storage address of the target block corresponding to the target storage block in the target storage device is determined based on the mapping relationship between the target storage area and the target storage device, so as to write the target file to the target block based on the second storage address.

[0131] In this embodiment, if the target storage area is located in the cache, the file is first written to the cache, and then the virtual address of the cache is mapped to the corresponding physical address on the physical storage device according to the mapping relationship between the cache and the physical storage device. Finally, the file is written to the target block at the corresponding physical address in the physical storage device.

[0132] For example, the system creates a mapping space in the cache to track the mapping relationship between cache addresses and physical addresses on the hard disk.

[0133] The target storage block address matched in the cache is / cache / ram1 / buffer1024. When data in the cache needs to be written to the hard disk, the system looks up the physical hard disk address corresponding to the cache address / cache / ram1 / buffer1024. Assuming the mapping indicates that / cache / ram1 / buffer1024 maps to / storage / ssd1 / block2048 on the hard disk, the system writes the data in the cache to the mapped physical hard disk address, completing the file storage.

[0134] As an optional embodiment, determining the target storage block matching the file information from the target storage area based on the file information further includes at least one of the following:

[0135] The usage information of each storage block in the target storage area is obtained, and the target storage block matching the file information is determined from the target storage area based on the file information and the usage information.

[0136] In this embodiment, the usage information refers to the current usage status information. The system checks the usage information of each storage block in the target storage area, such as whether it is occupied and its remaining capacity, to determine whether the storage block is currently free so that a new file can be written. It also checks whether the remaining space in the storage block is sufficient to accommodate the new file. By using this information, a storage block matching the file size and type is found to avoid wasted space or overflow.

[0137] For example, if a user uploads a 10MB video file, the system first checks the usage information of each storage block in the target storage area. The system finds that storage block A has 15MB of remaining capacity and is not occupied; storage block B has 5MB of remaining capacity and is already occupied. The system selects storage block A to store the video file because it has sufficient free capacity.

[0138] Alternatively, consider the relationships between files to decide whether to place two files in the same storage block.

[0139] For example, a user uploads a group of related image files, totaling 8MB. Considering the correlation between these files, the system decides to store them in the same storage block for easier management and access. The system finds a storage block C with sufficient remaining capacity that is not currently occupied, and stores the image files as a group in storage block C.

[0140] Therefore, if two files are not related, they will not be placed in the same storage block. For example, a user uploads two files: a video file (video.mp4) of 5MB and a text file (document.txt) of 3MB. Although these two files are uploaded at the same time, they are not directly related in content or purpose. The video file is a short video recorded by the user, while the text file is a draft of an article written by the user. The system will find suitable storage blocks for each of these files separately.

[0141] The wear level of each storage block in the target storage area is obtained, and a target storage block matching the file information is determined from the target storage area based on the file information and the wear level.

[0142] In this embodiment, considering the correlation between file content or purpose, related files are placed in the same storage block for easier management and access.

[0143] For example, for a frequently accessed hot file, the system wants to store it on a storage block with low wear to improve read speed and reliability. The system checks the wear level of each storage block in the target storage area and finds that storage block D has low wear and sufficient free capacity. The system decides to store this hot file on storage block D.

[0144] As an optional embodiment, it also includes at least one of the following:

[0145] After the target block is written to the target file, there is also free space, which is filled.

[0146] In this embodiment, after a file is written to the target block, if the block still contains unused free space, the system may perform specific padding to optimize storage capacity usage, but without actually writing data, for example, by writing zeros or other placeholder data. This reduces file system fragmentation and optimizes subsequent read / write performance.

[0147] In the case that the write operation is the first write operation, the target storage region is created in the target storage device or target cache.

[0148] In this embodiment, before performing a write operation or the first write operation, the system checks whether a target storage region already exists. If it does not exist, the system creates a new target storage region. The target storage region includes a storage region and a cache region. The cache region contains data management structures, such as a heap buffer, used to manage the storage region and track storage block usage. If the system has already created a target storage region before performing a write operation, it will directly load the existing target storage region.

[0149] As an optional embodiment, wherein, as Figures 3-6 As shown, creating the target storage area includes:

[0150] S41. In response to obtaining a creation operation to create the target storage region, determine a storage space of a first capacity size from the target storage region, and configure several storage blocks of different capacity sizes according to the first storage block as the smallest storage unit, wherein the capacity of the storage block is an integer multiple of the first storage block.

[0151] In this embodiment, a standard storage block size, referred to as the first capacity size, is determined within the target storage area. Based on the first capacity size, the system configures several storage blocks of different sizes to accommodate files and data of varying sizes. The capacity of these storage blocks is an integer multiple of the first storage block size, thus ensuring efficient utilization and management of storage space. When data needs to be stored, the system selects and allocates an appropriate storage block based on the size of the data.

[0152] For example, 30% of the capacity of the target storage device (such as a hard drive) is the target storage area, and the space size of the target storage area is 1TB. 1GB is used as the smallest storage unit, and the target storage area can be divided into blocks of the following sizes: 1TB blocks, 512GB blocks, 256GB blocks... 1GB blocks. Each level of block is a power of 2 in size, ensuring that the size of the blocks at each level is uniform.

[0153] S42. Generate a file mapping table that represents the address mapping relationship between storage blocks in the target storage area and blocks in the target storage device, and store the file mapping table in the target storage area.

[0154] In this embodiment, when the target storage area is located within the cache, the file mapping table is stored within the cache. The file mapping table records the mapping relationship between storage blocks in the cache and blocks on the target storage device, and also includes information about each storage block, such as the starting address of each storage block, the size of each storage block, and the status of each storage block (free, allocated), etc.

[0155] If the target storage area is located on the target storage device, the file mapping table is stored on the target storage device. When the file mapping table is stored on the target storage device, the storage space size of the file mapping table needs to be determined within the target storage area of ​​the target storage device.

[0156] Assuming that 30% of the target storage device (such as a hard drive) is the target storage area, the target storage area has a space size of 2GB, the storage unit is 4KB, the number of blocks = hard drive space size / storage unit = 2GB / 4KB = 512KB, the block size is the length of the storage space, the block size is 4 bytes, and the storage space required for the file mapping table = number of blocks * block size = 512K * 4 = 2MB.

[0157] In addition, the file mapping table records the sequence numbers of multiple storage blocks. Among them, 0 represents the area storing the entire Size, 1 represents the area storing data from space 0 to Size / 2, 2 represents the area storing continuous data from Size / 2 to Size, 3, 4, 5, 6 represent the area after Size / 4, and so on. The data from n / 2 to n stores basic data units. The formula for the storage capacity of the sequence number N is: Size / log2(N).

[0158] In this system, the storage block with sequence number 0 is the root node of the entire storage area. If the value in sequence number 0 is Size, it means that the entire storage space is unused; Size is the size of the entire storage space. If the value in a sequence number is 0, it means that the corresponding storage block is fully used, with no remaining space. The value in the block's sequence number indicates the maximum amount of data that the block can store. If the block is divided, this value indicates the maximum amount of space that the left and right child nodes can store.

[0159] As an optional embodiment, it also includes at least one of the following:

[0160] In response to receiving a deletion operation for the target file, the target file is deleted from the target block, and the status identifier of the corresponding target storage block in the target storage area is updated.

[0161] In this embodiment, when the system receives an instruction to delete a file, it will perform the deletion operation. The system will locate the storage blocks where the file data is stored and remove the file data from these storage blocks.

[0162] The process of locating the storage block where the file is stored is as follows:

[0163] The system retrieves storage block information from the file's metadata, which typically includes the block's index and size. The system then checks the cell data of the leaf nodes to see if they have been allocated (whether the used space is 0). If it is 0, the storage block has been allocated; otherwise, it needs to search upwards to find its parent node.

[0164] Once a corresponding storage block is found, the system restores the value of the data unit to the default space size that the current storage block can support, that is, marks the storage block as unallocated.

[0165] Next, the system traverses the parent nodes up to the root node, checking the left and right child nodes of each node. If both child nodes are free, the system merges them into a larger parent node and restores the current node's value to the default space size. That is, when a storage block is released, the system checks if its buddy block is also free. If so, the two blocks are merged into a larger block, thus reducing external fragmentation.

[0166] After a file is deleted, the storage blocks that were originally occupied by that file will no longer be occupied. Therefore, it is necessary to update the status flags of these storage blocks from "occupied" to "free".

[0167] In response to receiving a read operation for the target file, all or part of the data is read from the target block.

[0168] In this embodiment, when the system receives an instruction to read a file, it performs a read operation. The system locates the storage blocks containing the file data and reads all or part of the required data from these storage blocks. The process of locating the storage blocks containing the file data during reading is the same as the process of locating them during writing.

[0169] Specifically, if the size of the target file is smaller than the storage capacity of the block being written to, padding is required during the write process. Padding typically involves writing specific data or patterns into the free space of the storage block to ensure that the data block is fully utilized and to prevent data leakage or unauthorized access.

[0170] When the system reads data from a storage block, if the storage block has been padded, then only part of the data is read. If the storage block has not been padded, then all the data is read.

[0171] For example, if a 4MB file is written to an 8MB storage block, the system decides to pad the remaining 4MB of space for safety and integrity. The system writes specific padding data (which could be random data or a specific padding pattern) to the remaining space of the storage block, such as using EOF padding.

[0172] When reading data, if the storage block has been padded, the system will stop reading when it encounters EOF (End of Message), meaning the system will only read the first 4MB of data. If the storage block has not been padded, the system will read the entire 8MB of data, because the entire storage block is valid at this point.

[0173] In summary, the working process of the storage control method is as follows:

[0174] When the system receives a write operation request for the target file, it begins to execute the storage control method.

[0175] If the write operation is the first write operation or if no target storage area is found before the write operation, the target storage area needs to be created. Divide the storage area into multiple storage blocks according to storage capacity, from largest to smallest. Create a cache area to store the block information of the storage blocks. Generate a file mapping table to map the virtual addresses in the cache area to the physical addresses of the storage blocks in the storage area.

[0176] The target filter driver intercepts instructions or requests that trigger write operations, obtaining file information for the target file, including source information, file size information, and tag information. Based on the file source or file size, it determines the target storage block that matches the file information from the target storage area.

[0177] The system controls the target storage device to perform a write operation, writing the target file to the target storage block. Specifically, if the target storage area is located on the target storage device, the target file is written to the target storage block based on its first storage address. If the target storage area is located in a cache, a virtual address is first determined within the target storage area. Then, based on the mapping relationship between the target storage area and the target storage device, the physical address corresponding to the target storage block in the target storage device is determined, and the file data from the target cache is written based on this physical address. If there is still free space after the file is written to the target block, it is filled.

[0178] After writing to the file, update the status flag of the target storage block to reflect the usage of the storage block.

[0179] For example, when the target storage area is located on the hard disk, a write operation request is received, the file size and file source of the target file are obtained, and when the file source is an application or electronic device on the whitelist, a matching target storage block is determined based on the file size. Then, based on the first storage address of the target storage block, the target file is written to the target storage block on the hard disk corresponding to the first storage address.

[0180] For example, when the target storage area is located in the cache, a write operation request is received, the cache receives file data, and obtains the file information of the target file. Based on the file information, a file mapping table is consulted to determine the virtual address in the cache and the physical address on the hard disk corresponding to the virtual address. The file data is then written to the target block corresponding to the physical address.

[0181] Specifically, when performing write / read / delete operations, the file data within the target storage block is read / deleted based on the physical address. Additionally, the file mapping table and the status flag of the target storage block are updated.

[0182] This application utilizes the buddy algorithm in hard drives, enabling more efficient management of free space, optimizing data management and write operations, reducing write amplification and garbage collection overhead, minimizing fragmentation, and providing better space utilization. This results in faster read / write speeds, lower latency, and more stable performance, thereby improving overall hard drive performance. Furthermore, it offers greater flexibility; whether performing random or sequential writes, this application can quickly identify visual storage blocks, effectively manage data, reduce write amplification, and maintain high performance and stability.

[0183] This application provides a storage control device, such as... Figure 7 As shown, it includes:

[0184] The acquisition module is configured to acquire file information of the target file in response to a write operation on the target file.

[0185] The determination module is configured to determine a target storage block that matches the file information from the target storage area based on the file information. The target storage area is an area configured with storage blocks of different storage capacities, and the target storage area belongs to a target storage device or a target cache.

[0186] An execution module is configured to control the target storage device to perform a write operation to write the target file to a target block, wherein the target block includes the target storage block or a storage area that has a target association with the target storage block.

[0187] It should be noted that the principle of the storage control device provided in this application embodiment to solve the technical problem is similar to that of the storage control method provided in this application embodiment. Therefore, the implementation of the storage control device provided in this application embodiment can refer to the implementation of the storage control method provided in this application embodiment, and repeated details will not be repeated.

[0188] This application also provides an electronic device, including: a memory and a processor, wherein the memory stores an executable program, and the processor executes the executable program to implement the steps of any of the methods provided in this application.

[0189] The aforementioned processor can be a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD can be a complex programmable logic device (FPGA), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0190] Since the electronic device described in this application embodiment is an electronic device equipped with a memory for implementing the methods disclosed in this application embodiment, those skilled in the art can understand the structure and variations of the electronic device described in this application embodiment based on the methods described in this application embodiment, and therefore will not be repeated here.

[0191] This application also provides a computer-readable storage medium storing a computer program thereon, which, when run by a processor, implements the steps of any of the task processing methods provided in this application.

[0192] The storage medium in this embodiment may be included in an electronic device; or it may exist independently and not assembled into an electronic device. The storage medium carries one or more computer programs, which, when executed, implement the steps of any of the storage control methods provided in the embodiments of this application.

[0193] It should be understood that the various solutions in this embodiment have the same technical effects as those in the above method embodiments, and will not be repeated here.

[0194] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. Optionally, specific examples in this embodiment can refer to the examples described in any embodiment of this application, which will not be repeated here. Obviously, those skilled in the art should understand that the various modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular hardware and software combination.

[0195] The above embodiments are merely exemplary embodiments of this application and are not intended to limit this application. The scope of protection of this application is defined by the claims. Those skilled in the art can make various modifications or equivalent substitutions to this application within its substance and scope of protection, and such modifications or equivalent substitutions should also be considered to fall within the scope of protection of this application.

Claims

1. A storage control method, comprising: In response to obtaining a write operation for a target file, file information of the target file is obtained, wherein obtaining the file information of the target file includes at least one of the following: in response to obtaining a write operation for a target file, intercepting the instruction or request that triggers the write operation through a target filter driver and obtaining the file information of the target file; obtaining the source information and / or file size information of the target file; or obtaining the tag information of the target file; Based on the file information, a target storage block matching the file information is determined from the target storage area. The target storage area is an area configured with storage blocks of different storage capacities. The target storage area belongs to the target storage device or the target cache. The target storage device is controlled to perform a write operation to write the target file to a target block, wherein the target block includes the target storage block or a storage area that has a mapping relationship with the target storage block.

2. The method according to claim 1, wherein, Obtaining the tag information of the target file includes at least one of the following: Obtain historical access data for the target file, and generate tag information for the target file based on the historical access data; Obtain reference information for the target file, and determine matching tag information from the target tag library based on the reference information; Obtain the target operation applied to the target file, and configure the tag information of the target file based on the target operation.

3. The method according to claim 1, wherein, Determining a target storage block matching the file information from the target storage area based on the file information includes: If the file information indicates that the target file comes from a first application or a first electronic device, a target storage block that matches the file size of the target file is determined. The target file is written to the target block of the target storage device based on the storage address determined by the target storage block.

4. The method according to claim 3, wherein, Writing the target file to the target block of the target storage device based on the storage address determined by the target storage block includes at least one of the following: If the target storage area is located in the target storage device, the target file is written to the target storage block based on the first storage address of the target storage block; When the target storage area is located in the target cache, the second storage address of the target block corresponding to the target storage block in the target storage device is determined based on the mapping relationship between the target storage area and the target storage device, so as to write the target file to the target block based on the second storage address.

5. The method according to claim 1, wherein, Determining a target storage block matching the file information from the target storage area based on the file information further includes at least one of the following: Obtain usage information for each storage block in the target storage area, and determine the target storage block that matches the file information from the target storage area based on the file information and the usage information; The wear level of each storage block in the target storage area is obtained, and a target storage block matching the file information is determined from the target storage area based on the file information and the wear level.

6. The method according to claim 3 or 4, further comprising at least one of the following: After the target block is written to the target file, there is also free space, which is filled. In the case that the write operation is the first write operation, the target storage region is created in the target storage device or target cache.

7. The method according to claim 6, wherein, Creating the target storage region includes: In response to receiving a creation operation to create the target storage region, a storage space of a first capacity size is determined from the target storage region, and several storage blocks of different capacity sizes are configured according to a first storage block as the smallest storage unit, wherein the capacity of the storage block is an integer multiple of the first storage block; Generate a file mapping table that represents the address mapping relationship between storage blocks in the target storage area and blocks in the target storage device, and store the file mapping table in the target storage area.

8. The method of claim 1, further comprising at least one of the following: In response to receiving a deletion operation for the target file, the target file is deleted from the target block, and the status identifier of the corresponding target storage block in the target storage area is updated; In response to receiving a read operation for the target file, all or part of the data is read from the target block.

9. A storage control device, comprising: The acquisition module is configured to acquire file information of the target file in response to a write operation on the target file. The determination module is configured to determine a target storage block that matches the file information from the target storage area based on the file information. The target storage area is an area configured with storage blocks of different storage capacities, and the target storage area belongs to a target storage device or a target cache. An execution module is configured to control the target storage device to perform a write operation to write the target file to a target block, wherein the target block includes the target storage block or a storage area that has a mapping relationship with the target storage block.

Citation Information

Patent Citations

  • Method and device for distributing cache quota for client on basis of files

    CN106776043A

  • Log file storage method, mobile terminal, and computer-readable storage medium

    CN109002547A