Storage control method and device

By responding to writing operations in solid -state hard disks, obtaining file information and determining the matching storage blocks, solving the fragmented and large problems faced by the solid -state hard disk under random writing operation, realizing the effect of more efficient storage and extending the life of the hard disk life Essence

CN119336260AActive Publication Date: 2025-01-21LENOVO (BEIJING) LTD
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Solid-state drives face disk fragmentation and write amplification problems under a large number of random write operations, which affects their performance and lifespan.

Method used

By responding to the write operation, the file information of the target file is obtained, and based on the information, a matching target storage block is determined from the target storage area, and the storage device is controlled to write the file into the target block.

Benefits of technology

Optimized the use of storage space, reduced the delay of writing operation, reduced the wear of solid -state hard disks, prolonged its life, and improved the flexibility of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336260A_ABST
    Figure CN119336260A_ABST
Patent Text Reader

Abstract

The invention discloses a storage control method and device, and the method comprises the steps: obtaining file information of a target file in response to a write operation for the target file; determining a target storage block matched with the file information from a target storage area based on the file information, the target storage area being an area configured with storage blocks with different storage capacities, and the target storage area belonging to a target storage device or a target cache; and controlling the target storage device to execute 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 association relationship with the target storage block. The storage resources can be effectively managed according to the file attributes, and the use of the storage space can be optimized by matching the file information and the storage blocks. And moreover, the delay of the write operation can be reduced by quickly positioning and allocating the storage blocks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to a storage control method and device. Background Art

[0002] As solid-state drives (SSDs) gradually become the mainstream storage medium, they have shown significant advantages in improving data access speed and reducing access latency. However, SSDs face disk fragmentation and write amplification problems under a large number of random write operations, which seriously affect the use efficiency and performance of SSDs. In SSDs, due to the physical characteristics of NAND Flash, write operations do not directly update data at the original location, but need to be erased before writing. This process is called write amplification (WA). Write amplification not only increases the amount of written data, but also aggravates the wear of SSDs, resulting in performance degradation and shortened life. In addition, a large number of random write operations lead to uneven utilization of storage blocks, resulting in fragmentation, which further reduces storage efficiency. Summary of the invention

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

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

[0005] Determine a target storage block matching the file information from a target storage area based on the file information, the target storage area being an area configured with storage blocks of different storage capacities, and the target storage area belonging to a target storage device or a target cache;

[0006] The target storage device is controlled to execute a write operation of writing the target file into a target block, wherein the target block includes the target storage block or a storage area having a target association relationship 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 obtaining a write operation for a target file, intercepting an instruction or request triggering the write operation through a target filter driver, and obtaining file information of the target file;

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

[0010] Obtain label 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] Obtaining historical access data of the target file, and generating tag information of the target file based on the historical access data;

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

[0014] A target operation acting on the target file is obtained, and tag information of the target file is configured based on the target operation.

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

[0016] In a case where the file information indicates that the target file comes from a first application or a first electronic device, determining a target storage block that matches a file size of the target file;

[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, the step of writing the target file to the target block of the target storage device based on the storage address determined by the target storage block comprises at least one of the following:

[0019] In a case where the target storage area is located in the target storage device, writing the target file to the target storage block based on the first storage address of the target storage block;

[0020] In the case where the target storage area is located in the target cache, a second storage address of a target block corresponding to the target storage block in the target storage device is determined based on a 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, the step of determining a target storage block matching the file information from a target storage area based on the file information further includes at least one of the following:

[0022] Obtaining usage information of each storage block in the target storage area, and determining a target storage block matching the file information from the target storage area based on the file information and the usage information;

[0023] The degree of wear 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 degree of wear.

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

[0025] After the target block is written into the target file, there is also free space, and the free space is filled;

[0026] In a case where the write operation is a first write operation, the target storage area is created in the target storage device or the target cache.

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

[0028] In response to obtaining a creation operation for creating the target storage area, determining a storage space of a first capacity from the target storage area, and configuring a plurality of storage blocks of different capacity according to the first storage block as a minimum storage unit, wherein the capacity of the storage block is an integer multiple of the first storage block;

[0029] A file mapping table representing an address mapping relationship between storage blocks in a target storage area and blocks in a target storage device is generated, and the file mapping table is stored in the target storage area.

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

[0031] In response to obtaining a deletion operation for the target file, deleting the target file from the target block, and updating a status indicator of a corresponding target storage block in the target storage area;

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

[0033] The present application also provides a storage control device, including:

[0034] An acquisition module, configured to obtain file information of a target file in response to obtaining a write operation for the target file;

[0035] a determination module configured to determine a target storage block matching the file information from a target storage area based on the file information, the target storage area being an area configured with storage blocks of different storage capacities, and the target storage area belonging to a target storage device or a target cache;

[0036] An execution module is configured to control the target storage device to execute a write operation of writing the target file into a target block, wherein the target block includes the target storage block or a storage area having a target association relationship with the target storage block. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A flowchart of a storage control method according to an embodiment of the present application;

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

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

[0040] Figure 4 A schematic diagram of dividing multiple target storage blocks according to an embodiment of the present application;

[0041] Figure 5 A schematic diagram of the sequence numbers of multiple target storage blocks according to an embodiment of the present application;

[0042] Figure 6 A schematic diagram of the correspondence between the target file and the target storage block in an embodiment of the present application;

[0043] Figure 7 This is a structural block diagram of a storage control device according to an embodiment of the present application. DETAILED DESCRIPTION

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

[0045] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.

[0046] The accompanying drawings, which are incorporated in and constitute a part of the 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 characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.

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

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

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

[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 the present application.

[0052] The present application embodiment provides a storage control method, such as Figure 1 As shown, including:

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

[0054] In this embodiment, the write operation is an operation of writing to a storage device, which can be an active operation or a series of operations generated by an application. Among them, the active operation refers to a write operation directly initiated by a user or a system, such as a user consciously saving a file to a hard disk, or a system regularly backing up data.

[0055] The series of operations generated by the application refer to the write operations automatically generated by the application during operation. These operations are not directly initiated by the user, but are side effects of the application performing its functions. For example, the transaction log of the database, the progress of the game save, or the temporary file writing during the software update process.

[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 (based on historical access frequency to determine whether it is a hot file or a cold file), and file generation time.

[0057] S2. Determine a target storage block matching 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 of different storage capacities, and the target storage area belongs to a target storage device or a target cache.

[0058] In this embodiment, a suitable storage block is searched or allocated according to the file information so that there is enough space and appropriate characteristics to store the target file. The target storage block is a storage block that matches the file information of the target file. For example, the file information is the file size, and a small file is allocated a smaller storage block, while a large file requires a larger storage block.

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

[0060] In addition to considering file information, the state information of the target storage block, the degree of wear of the target block, etc. may also be considered. The state information of the target storage block includes but is not limited to whether it is idle, damaged, in use, etc. The degree of wear of the target storage block is considered to avoid writing important data into a block that is about to fail.

[0061] The target storage area is an area composed of storage blocks with different storage capacities, and these storage blocks (target storage area) can be located in a storage device or cache. Storage blocks with different storage capacities refer to the storage area being divided into physical blocks of various sizes in order to meet the storage requirements of data of different sizes.

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

[0063] Alternatively, the target storage area may be determined in the virtual mapping space of the cache, in which 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 of different storage capacities, a data space is first determined in the hard disk, and the size of the data space is about 30% of the hard disk. The size of the data space is converted into the size of the block, and the size of the data space is between the power of 2 of the block size, 2^ N <30%<2^ N +1 to obtain N=log2(Space / 4K), where the data size of each block is the storage unit size of the hard disk, 4K.

[0065] The data space is divided into multiple storage blocks according to the power of 2, and the storage blocks are divided into root nodes, parent nodes, left and right child nodes, and leaf nodes. Among them, the root node represents the entire storage space. Assuming that the entire storage space is Size, the block size represented by the root node is Size. The root node has no parent node and is the top of the tree.

[0066] When a node is split, it produces two child nodes, which are called "partners". Each parent node is split into two child nodes of equal size. The storage block size of the parent node is twice that of the child node. For example, if the parent node represents an 8MB block, after the split, the left and right child nodes each represent a 4MB block. Leaf nodes are nodes that cannot be split any further, i.e. they have no child nodes. The size of a leaf node is usually the smallest block size, such as 4KB.

[0067] For example, for a 64MB storage space, the partitioning process is as follows:

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

[0069] First split: The root node is split into two 32MB blocks, the size of the left child node is 32MB and the size of the right child node is 32MB;

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

[0071] The split continues: each time the size of the block is halved until the desired minimum block size is reached.

[0072] Leaf node: When the block size reaches 4KB, the splitting stops.

[0073] S3. Control the target storage device to execute a write operation of writing the target file into a target block, where the target block includes the target storage block or a storage area having 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 in a hard disk, the target storage block is the actual physical block in the hard disk, and the target storage block is the actual target block in the hard disk. If the target storage area is located in a cache, the target block is the block in the hard disk that maps the target storage block.

[0076] Specifically, when the target storage area belongs to the target storage device, it is necessary to define a storage address space on the target storage device as the target storage area, and configure the target storage area into storage blocks with different storage capacities, each storage block having a physical address.

[0077] When the system receives a write operation request, it obtains the file information of the requested target file in the operation 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 corresponding physical address as the write address of the target file to write 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 defined in the target cache that matches the 30% capacity mapping of the target storage device (such as a hard disk), and the target storage area is configured as storage blocks of different storage capacities, each storage block has a corresponding virtual address in the target cache, and the virtual address is mapped to the storage area corresponding to the storage block on the target storage device. The storage area is composed of a plurality of blocks, which may be blocks of the smallest storage unit in the target storage device or blocks of different capacities composed of different numbers of smallest storage units.

[0079] At this time, when the system receives a write operation request, it obtains the file information of the requested target file in the operation 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 maps its virtual address to the physical address to the file, so as to write the file data to the target block in the hard disk to which the target storage block is mapped.

[0080] The present 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, fast positioning and allocation of storage blocks can reduce the delay of write operations. The method of the present application is applicable to different storage devices and caches, which improves the flexibility of the system.

[0081] For example, when the system needs to allocate space for a file, it will request a storage block of a specific size and look for the smallest block that can satisfy the request. If a matching block is found, it is directly allocated to the requester. For example, the file size of the target file is 3MB, and the smallest power of square that can satisfy the data storage is 2^ 2=4, then the target storage block with a storage capacity of 4MB meets the requirements. The file size of the target file is 120MB, and the minimum power of two that can satisfy 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 searching for the target storage block, the target storage block is searched from top to bottom according to the level of the target storage block (divided from large to small according to the storage capacity), starting from the root node, which represents the entire storage capacity.

[0083] Check whether 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 in the left and right child nodes of the current level to determine whether there is a smaller block that can satisfy the request.

[0084] When a target storage block whose storage capacity just matches the request is found, the target storage block is marked as "used". At this time, the value of the current target storage block is set to 0, indicating that the space is already occupied.

[0085] And, when the target storage block is marked as used, it will trace back to the parent node of the allocation block. In the parent node, the size of its available space is calculated. If both the left and right child nodes of the parent node are marked as used (value 0), the size of the available space of the parent node is 0. If at least one child node is not fully used, the size of the available space of the parent node will be the maximum value of the 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 obtaining a write operation for a target file, an instruction or request triggering the write operation is intercepted by a target filter driver, and file information of the target file is obtained.

[0088] In this embodiment, when performing a write operation on a file, detailed information about the file needs to be obtained first. This process can be implemented by using a filter driver, which can intercept write requests for files and extract relevant information. The filter driver can intercept and process requests for files, such as read or write operations, at the operating system level.

[0089] The file information includes the file metadata, such as file size, file source, file type, file tag, file creation time, owner, permissions, etc. File type is classified according to file format and purpose, such as text files (.txt), image files (.jpg, .png), video files (.mp4, .avi), audio files (.mp3, .wav), etc. File creation time is the creation time of the file, which can be the time when the file was first created or the time when it was last modified.

[0090] For example, an enterprise resource planning (ERP) system, through which a user uploads a sales report. User uploads a file: The user uploads a sales report file named "Sales_Report_Q1_2024.xlsx" through the ERP system. The filter driver of the ERP system intercepts this write operation request.

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

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

[0093] The source information and / or file size information of the target file is obtained.

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

[0095] Obtain label information of the target file.

[0096] In this embodiment, the tag information is used to describe the file content or purpose, which can be automatically generated based on the file content or customized by the user. The file tag can be information used for classification or priority marking, such as "hot" files represent frequently accessed files, and "cold" files represent infrequently accessed files.

[0097] Specifically, the filter driver monitors the file system and intercepts write operation requests to the target file. Once the write operation is intercepted, the filter driver extracts the relevant information of the target file so that appropriate storage allocation can be made later. After obtaining the required 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 of the target file, and generate tag information of the target file based on the historical access data.

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

[0101] By analyzing the frequency and pattern of file access through historical access data, you can generate tags that represent file popularity, such as "frequently used" and "uncommonly used". Among them, historical access data refers to the historical access data of storage devices, such as historical access data in hard disks, which usually refers to the time records of file or data access, modification or creation. This data can be used to analyze the usage patterns, frequencies and trends of files. In addition to local hard disks, 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 will track and record every access to the file, including the time of access, the identity of the visitor (if it is accessed remotely or in the cloud), etc. For data across devices, such as using cloud services or other devices in the local area network, historical access data can be synchronized to the cloud or the target device.

[0103] By analyzing historical access data, you can determine the popularity of files, such as which files are frequently accessed and which are infrequently accessed. Based on the analysis results, you can classify files, such as marking them as "hot" or "cold", and optimize storage strategies accordingly.

[0104] Also, if the target file is a newly produced file, there is not enough information to directly assign a file tag. At this time, the following method can be used to generate tag information: Generate tag information based on a prediction model or historical data of the associated file.

[0105] Among them, the prediction model is to use machine learning models to predict the access pattern or purpose of files based on the source, type, creation time and other characteristics of the files, and generate labels accordingly. For example, if a file is created by a specific application during working hours on a weekday, the model may predict that it is a "work file."

[0106] Based on the historical data of associated files, the new file is associated with existing files in the system. For example, if they are created by the same user or belong to the same project, the historical access data of the associated files can be referred to to generate tags. For example, if a user often accesses a certain type of file at night, the new file may also be marked as "accessed at night".

[0107] The reference information of the target file is obtained, and the tag information matching the target file is determined from the target tag library based on the reference information.

[0108] In this embodiment, if the file is associated with some well-known reference information, such as a specific project, event or theme, this reference information can be used to generate a tag. The reference information includes but is not limited to the file source, file type, file name, file storage path, file generation time, etc.

[0109] Specifically, it includes determining the tag information of the file through the prediction model. At this time, the prediction model can predict the usage pattern of the file through reference information, thereby determining whether the file is a frequently accessed "hot file" or a seldom accessed "cold file", helping the system understand the popularity of the file in advance.

[0110] The label information of the file is determined by the activity of the application. If an application frequently creates or modifies certain files, these files may be frequently accessed. The system can monitor the activity of the application and mark the files related to it as "hot files".

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

[0112] A target operation acting on the target file is obtained, and tag information of the target file is configured based on the target operation.

[0113] In this embodiment, files may be tagged according to a predetermined operation or purpose, wherein the target operation includes but is not limited to backup, archive, and temporary. The tag is configured according to the operation to be performed on the file. For example, if a file is scheduled for backup, it may be tagged as a "backup file".

[0114] Specifically, identify the operations that will be performed on the file, such as backup, archive, frequently read, etc. Assign appropriate tags to the file based on the target operation, such as "hot", "cold", "backup", etc. Store the tag information as metadata of the file so that the system can use these tags to optimize storage and access policies.

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

[0116] S21. When 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, for example, whether the file is created by a specific application (first application) or from a specific device (first electronic device). These sources are considered to be in the whitelist, which means that they need to be prioritized for storage optimization and access acceleration.

[0118] The system will determine a storage block that is large enough to accommodate the file based on the file size information. This ensures that the file can be stored completely while avoiding allocating too much space and wasting storage resources.

[0119] Specifically, in order to optimize storage and access speed, especially for trusted applications and electronic devices, a whitelist can be set. When a file is created or accessed, the system will check the source of the file to determine whether it belongs to an entity in the whitelist.

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

[0121] If the file is not created or accessed by an application or device in the whitelist, the system will execute the default file processing logic, which includes basic security checks and disk space management.

[0122] S22. Writing 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 will determine the storage address of the storage block so as to write the file to the target block of the target storage device to complete the storage process. In the process of writing the file, whether the storage address needs to be mapped 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 usually written directly to a physical address of the device. In this case, the storage address usually does not need to be mapped, because the logical address of the file will be directly converted to the corresponding physical address.

[0125] If the target storage area is part of the cache, the write of the file must first occur in the cache. In this case, the storage address needs to be mapped because the logical address of the file is converted to 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, the step of writing the target file to the target block of the target storage device based on the storage address determined by the target storage block comprises at least one of the following:

[0127] In a case where 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 uses the Word application to create a financial report file named "Financial_Report.docx" and chooses to save it to the hard disk. The system allocates a 4MB storage block on the hard disk to this file, and the physical address of the storage block is / storage / ssd1 / block2048. The system directly writes the file to this physical address without address mapping.

[0130] In the case where the target storage area is located in the target cache, a second storage address of a target block corresponding to the target storage block in the target storage device is determined based on a 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, and finally the file is written to the target block of 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 hard disk physical addresses.

[0133] The address of the target storage block that matches the file in the cache is / cache / ram1 / buffer1024 in the cache. When the data in the cache needs to be written to the hard disk, the system will search for the hard disk physical address corresponding to the cache address / cache / ram1 / buffer1024. Assume that the mapping relationship indicates that / cache / ram1 / buffer1024 is mapped to / storage / ssd1 / block2048 on the hard disk. The system writes the data in the cache to the mapped hard disk physical address to complete the file storage.

[0134] As an optional embodiment, the step of determining a target storage block matching the file information from a 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 is 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, the remaining capacity, etc., to determine whether the storage block is currently free so that the new file can be written. Check whether the remaining space of the storage block is sufficient to accommodate the new file. Through the usage information, the storage block matching the file size and type is found to avoid space waste or overflow.

[0137] For example, 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 the remaining capacity of storage block A is 15MB and is not occupied; the remaining capacity of storage block B is 5MB and is occupied. The system selects storage block A to store this video file because it has enough free capacity.

[0138] Alternatively, the association relationship between the files may be considered to decide to place the two files in one storage block.

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

[0140] Therefore, if there is no association between two files, the two files will not be placed in the same storage block. For example, a user uploaded two files, one is a video file (video.mp4) with a size of 5MB, and the other is a text file (document.txt) with a size of 3MB. Although the two files were uploaded at the same time, they have no direct association in terms of content and purpose. The video file is a short video recorded by the user, and the text file is a draft of an article written by the user. The system will find suitable storage blocks for the two files separately.

[0141] The degree of wear 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 degree of wear.

[0142] In this embodiment, related files are placed in the same storage block in consideration of the relevance of file content or usage, for ease of management and access.

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

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

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

[0146] In this embodiment, after a file is written to a target block, if the block still contains unused free space, the system may perform a specific filling process to optimize the use of storage capacity without actually writing data, such as by writing zeros or other placeholder data. This can reduce file system fragmentation and optimize subsequent read and write performance.

[0147] In a case where the write operation is a first write operation, the target storage area is created in the target storage device or the target cache.

[0148] In this embodiment, before executing a write operation or the first write operation, the system will check whether a target storage area already exists. If not, the system will create a new target storage area. The target storage area includes a storage area and a cache area. The cache area contains a data management structure for managing the storage area, such as a heap buffer, to track the usage of storage blocks. If the system has already created a target storage area before executing a write operation, the system will directly load the existing target storage area.

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

[0150] S41. In response to obtaining a creation operation for creating the target storage area, a storage space of a first capacity size is determined from the target storage area, and a plurality of storage blocks of different capacity sizes are configured according to a first storage block as a minimum 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 is determined in the target storage area, which is called the first capacity size. Based on the first capacity size, the system configures a number of storage blocks of different capacity sizes to accommodate files and data of different sizes. The capacity of these storage blocks is an integer multiple of the first storage block, which can ensure the effective use and management of storage space. When data needs to be stored, the system selects a suitable storage block for allocation according to the size of the data.

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

[0153] S42: Generate a file mapping table representing the address mapping relationship between the storage blocks in the target storage area and the 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 in the cache, the file mapping table is stored in the cache. The file mapping table records the mapping relationship between the storage blocks in the cache and the blocks of the target storage device, and also includes information of each storage block, such as the starting address of each storage block, the size of each storage block, 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. If the file mapping table is stored on the target storage device, the storage space size of the file mapping table needs to be determined in the target storage area of ​​the target storage device.

[0156] Assume that 30% of the capacity of the target storage device (such as a hard disk) is the target storage area, the space size of the target storage area is 2GB, the storage unit is 4KB, the number of blocks = hard disk 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] And, the serial numbers of multiple storage blocks are recorded in the file mapping table. Among them, 0 represents the area storing the entire Size, 1 represents the storage data from 0 to Size / 2, 2 represents the storage of continuous data from Size / 2 to Size, 3, 4, 5, 6 represent the area after Size / 4, and so on, n / 2 to n data store the basic data unit, and the formula for the storage capacity of serial number N is: Size / log2(N).

[0158] Among them, the storage block with serial number 0 is the root node of the entire storage area. If the value in serial number 0 is Size, it means that the entire storage space is not used. Size is the size of the entire storage space. If the value in a certain serial number is 0, it means that the corresponding storage block has been fully used and there is no remaining space. The value in the serial number of the storage block indicates the maximum amount of data that the storage block can store. If this block is split, then this value indicates the maximum amount of space that the left and right child nodes can store.

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

[0160] In response to obtaining a deletion operation for the target file, the target file is deleted from the target block, and a status indicator of a 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 a deletion operation, find the storage blocks storing the file data, and remove the file data from these storage blocks.

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

[0163] The system obtains the information of the storage block from the metadata of the file, which usually includes the index and size of the storage block. The system checks the cell data of the leaf node to see if it has been allocated (whether the used space is 0). If it is 0, it means that the storage block has been allocated. If not, it needs to look up the parent node.

[0164] Once the 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 until the root node, checking the left and right child nodes of each node. If both left and right child nodes are free, the system merges them into a large parent node and restores the value of this node to the default space size. That is, when a storage block is released, the system checks whether its partner block is also free. If so, the two blocks are merged into a larger block, thereby reducing external fragmentation.

[0166] After deleting a file, the storage blocks originally occupied by the file will no longer be occupied, so the status flags of these storage blocks need to be updated from the "occupied" state to the "free" state.

[0167] In response to obtaining 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 will perform a read operation. The system will find the storage blocks storing the file data and read all or part of the required data from these storage blocks. The process of finding the storage blocks storing the file data when reading is the same as the process of finding when writing.

[0169] Specifically, if the data size of the target file is smaller than the storage capacity of the storage block being written, the storage block needs to be filled when writing. The filling process usually writes some specific data or patterns in the free space of the storage block to ensure that the data block is fully used to prevent data leakage or unauthorized access.

[0170] Then when the system reads data from the storage block, if the storage block has been filled, it will read part of the data. If the storage block has not been filled, it will read all the data.

[0171] For example, a 4MB file is written to a storage block with a storage capacity of 8MB. For security and integrity, the system decides to fill the remaining 4MB space. The system writes specific filling data (which may be random data or a specific filling pattern) to the remaining space of the storage block, such as using EOF filling.

[0172] When reading data, if the storage block has been filled, the system will stop reading when it encounters EOF when reading part of the data in the storage block, that is, the system will only read the first 4MB of data. If the storage block is not filled, the system will read the entire 8MB of data, because the entire storage block is valid data at this time.

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

[0174] When the system receives a write operation request for a target file, the storage control method starts to be executed.

[0175] If the write operation is the first write operation or there is no target storage area before the write operation, you need to create the target storage area. Divide the storage area into multiple storage blocks according to the storage capacity from large to small. Create a cache area to save the block information of the storage block. Generate a file mapping table to map the virtual address in the cache area to the physical address of the storage block in the storage area.

[0176] The target filter driver intercepts the instruction or request that triggers the write operation, obtains the file information of the target file, including the source information, file size information and tag information, and determines the target storage block that matches the file information from the target storage area based on the file source or file size.

[0177] The target storage device is controlled to perform a write operation to write the target file into the target storage block. If the target storage area is located in the target storage device, the target file is written into the target storage block based on the first storage address of the target storage block. If the target storage area is located in the cache, a virtual address is first determined in the target storage area, and then the physical address 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, and the file data in the target cache is written based on the physical address. If there is still free space after the target block is written into the file, fill processing is performed.

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

[0179] Exemplarily, when the target storage area is located on a 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 according to the file size. Then, according to the first storage address of the target storage block, the target file is written to the target storage block corresponding to the first storage address on the hard disk.

[0180] Exemplarily, when the target storage area is located in the cache, a write operation request is received, the cache receives the file data, and obtains the file information of the target file. According to the file information, the file mapping table is searched 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 written to the target block corresponding to the physical address.

[0181] When a write / read / delete operation is performed, the file data in the target storage block is read / deleted according to the physical address, and the file mapping table and the status identifier of the target storage block are updated.

[0182] This application applies the buddy algorithm to the hard disk, which can more effectively manage the free space in the hard disk, optimize the data management and write operations of the hard disk, reduce the overhead of write amplification and garbage collection, reduce fragmentation, and provide better space utilization. This can bring faster read and write speeds, lower latency and more stable performance, thereby improving the performance of the entire hard disk. And it is flexible to use. Whether it is random writing or sequential writing, this application can quickly determine the visual storage block, effectively manage data, reduce write amplification, and maintain high performance and stability.

[0183] The present application embodiment provides a storage control device, such as Figure 7 As shown, including:

[0184] An acquisition module, configured to obtain file information of a target file in response to obtaining a write operation for the target file;

[0185] a determination module configured to determine a target storage block matching the file information from a target storage area based on the file information, the target storage area being an area configured with storage blocks of different storage capacities, and the target storage area belonging to a target storage device or a target cache;

[0186] An execution module is configured to control the target storage device to execute a write operation of writing the target file into a target block, wherein the target block includes the target storage block or a storage area having a target association relationship with the target storage block.

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

[0188] An embodiment of the present application further provides an electronic device, comprising: a memory and a processor, wherein an executable program is stored in the memory, and the processor executes the executable program to implement the steps of any method provided in the embodiment of the present application.

[0189] The processor may 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 PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof. The general purpose processor may be a microprocessor or any conventional processor.

[0190] Since the electronic device introduced in the embodiments of the present application is an electronic device provided with a memory for implementing the method disclosed in the embodiments of the present application, based on the method introduced in the embodiments of the present application, technical personnel in this field can understand the structure and deformation of the electronic device introduced in the embodiments of the present application, so it is not repeated here.

[0191] The embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any method of the task processing method provided in the embodiment of the present application are implemented.

[0192] The storage medium in this embodiment may be included in the electronic device, or may exist independently without being installed in the electronic device. The storage medium carries one or more computer programs, and when the one or more computer programs are executed, the steps of any method of the storage control method provided in the embodiment of the present application are implemented.

[0193] It should be understood that each scheme in this embodiment has the corresponding technical effects in the above method embodiment, which will not be repeated here.

[0194] According to an embodiment of the present application, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. Optionally, the specific examples in this embodiment can refer to the examples described in any embodiment of the present application, and this embodiment is not repeated here. Obviously, it should be understood by those skilled in the art that the above-mentioned modules or steps of the present application can be implemented with a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented with a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from here, or they can be made into individual integrated circuit modules respectively, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.

[0195] The above embodiments are only exemplary embodiments of the present application and are not intended to limit the present application. The protection scope of the present application is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present application within the essence and protection scope of the present application, and such modifications or equivalent substitutions shall also be deemed to fall within the protection scope of the present application.

Claims

1. A storage control method, comprising: In response to obtaining a write operation for a target file, obtaining file information of the target file; Determine a target storage block matching the file information from a target storage area based on the file information, the target storage area being an area configured with storage blocks of different storage capacities, and the target storage area belonging to a target storage device or a target cache; The target storage device is controlled to execute a write operation of writing the target file into a target block, wherein the target block includes the target storage block or a storage area having a target association relationship with the target storage block.

2. The method according to claim 1, wherein: Obtaining 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 an instruction or request triggering the write operation through a target filter driver, and obtaining file information of the target file; Obtaining source information and / or file size information of the target file; Obtain label information of the target file.

3. The method according to claim 2, wherein: Obtaining the tag information of the target file includes at least one of the following: Obtaining historical access data of the target file, and generating tag information of the target file based on the historical access data; Obtain reference information of the target file, and determine tag information matching the target file from a target tag library based on the reference information; A target operation acting on the target file is obtained, and tag information of the target file is configured based on the target operation.

4. The method according to claim 1, wherein: Determining a target storage block matching the file information from a target storage area based on the file information includes: In a case where the file information indicates that the target file comes from a first application or a first electronic device, determining a target storage block that matches a file size of the target file; 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.

5. The method according to claim 4, 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 comprises at least one of the following: In a case where the target storage area is located in the target storage device, writing the target file to the target storage block based on the first storage address of the target storage block; In the case where the target storage area is located in the target cache, a second storage address of a target block corresponding to the target storage block in the target storage device is determined based on a 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.

6. 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: Obtaining usage information of each storage block in the target storage area, and determining a target storage block matching the file information from the target storage area based on the file information and the usage information; The degree of wear 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 degree of wear.

7. The method according to claim 4 or 5, further comprising at least one of the following: After the target block is written into the target file, there is also free space, and the free space is filled; In a case where the write operation is a first write operation, the target storage area is created in the target storage device or the target cache.

8. The method according to claim 7, wherein: Creating the target storage area includes: In response to obtaining a creation operation for creating the target storage area, determining a storage space of a first capacity from the target storage area, and configuring a plurality of storage blocks of different capacity according to the first storage block as a minimum storage unit, wherein the capacity of the storage block is an integer multiple of the first storage block; A file mapping table representing an address mapping relationship between storage blocks in a target storage area and blocks in a target storage device is generated, and the file mapping table is stored in the target storage area.

9. The method according to claim 1, further comprising at least one of the following: In response to obtaining a deletion operation for the target file, deleting the target file from the target block, and updating a status indicator of a corresponding target storage block in the target storage area; In response to obtaining a read operation for the target file, all or part of the data is read from the target block.

10. A storage control device, comprising: An acquisition module, configured to obtain file information of a target file in response to obtaining a write operation for the target file; a determination module configured to determine a target storage block matching the file information from a target storage area based on the file information, the target storage area being an area configured with storage blocks of different storage capacities, and the target storage area belonging to a target storage device or a target cache; An execution module is configured to control the target storage device to execute a write operation of writing the target file into a target block, wherein the target block includes the target storage block or a storage area having a target association 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

  • System-on-chip file data writing method and system based on erasing and writing frequency counting

    CN116450052A

  • File management device and method using block flag

    KR1020020087707A

  • Mobile storage device providing mass virtual storage space and providing method thereof

    KR1020150071898A