Cache storage method and related device

By obtaining the file identifier in the cache and determining its block in the file identifier area, the update information is stored in the metadata update area, and the actual writing is only performed when the conditions are met. This solves the problem of metadata update competition pressure and improves cache query performance.

CN116185949BActive Publication Date: 2025-12-30SANGFOR TECH INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211717784.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2025-12-30
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

In existing technologies, the way metadata is written affects cache query performance, and there is competition pressure when metadata is updated.

Method used

A caching storage method is adopted. The current file identifier is obtained and the data is stored in the data area. The corresponding first block is determined in the file identifier area. The file identifier update information is stored in the metadata update area and is only written to the file identifier area when preset conditions are met, thereby reducing the competitive pressure of metadata updates.

Benefits of technology

This effectively reduces the contention pressure during metadata updates and improves cache query performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116185949B_ABST
    Figure CN116185949B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a cache storage method and related equipment, which are used for reducing the metadata update competition pressure caused by a large amount of cache storage. The method comprises the following steps: storing current data of a current file change in a data area, and determining a first block corresponding to the current file in a file identification area based on a current storage state of the file identification area, the first block being used for recording a current file identification; storing file identification update information in a metadata update area, wherein the file identification update information comprises an identification of the first block and the current file identification; and if the metadata update area satisfies a preset metadata update condition, writing the current file identification into the first block according to the identification of the first block. The cache comprises a metadata area and a data area, the metadata area comprises a file identification area and a metadata update area, and the current file identification of a current file is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer storage, and more particularly to cache storage methods and related devices. Background Technology

[0002] Cache is a type of high-speed memory that is faster than regular random access memory. Unlike main memory, which uses dynamic random access memory (DRAM), cache typically uses more expensive but faster static random access memory (SRAM). Cache configuration is one of the key factors for achieving high performance in all modern computer systems.

[0003] The cache consists of a metadata area and a data area. The data area stores data, while the metadata area describes the data stored in the data area. If there is a large amount of data that needs to be stored, a large amount of metadata will be generated that needs to be stored in the metadata area. In existing technical solutions, the metadata is written directly to the corresponding write location after determining the metadata that needs to be written and its corresponding write location.

[0004] When faced with a large amount of metadata to be updated, the continuous writing of large amounts of metadata will affect the query performance of the cache, thus bringing competitive pressure when updating metadata. Summary of the Invention

[0005] This application provides a caching storage method and related devices to reduce the contention pressure generated during metadata updates.

[0006] A first aspect of this application provides a cache storage method, wherein the cache includes a metadata area and a data area, the metadata area includes a file identification area and a metadata update area, and the method includes:

[0007] Get the current file identifier of the current file;

[0008] The current data of the current file change is stored in the data area, and the first block corresponding to the current file in the file identifier area is determined based on the current storage status of the file identifier area. The first block is used to record the current file identifier.

[0009] File identifier update information is stored in the metadata update area, wherein the file identifier update information includes the identifier of the first block and the current file identifier;

[0010] If the metadata update area meets the preset metadata update conditions, then the current file identifier is written into the first block according to the identifier of the first block.

[0011] In one specific implementation, the metadata area further includes a file fragmentation area and a file block area, and the method further includes:

[0012] If there is no file identifier in the file identifier area that matches the current file identifier, then at least one second block corresponding to the current file in the file segmentation area and at least one third block corresponding to the current file in the file segmentation area are determined.

[0013] At least one file segment update information and at least one file block update information are stored in the metadata update area; each file segment update information includes the identifier of the second block and the association relationship between the second block and the current file; each file block update information includes the identifier of the third block, the association relationship between the third block and the second block corresponding to the third block, the data corresponding to the third block in the data area, and the offset relative to the data corresponding to the second block corresponding to the third block in the data area;

[0014] If the metadata update area meets the preset metadata update conditions, then according to the second block identifier, the association relationship between the second block and the current file is written into the second block, and according to the third block identifier, the association relationship between the third block and the second block corresponding to the third block is written into the third block.

[0015] In one specific implementation, the update information for each file block further includes: a dirty data identifier for identifying whether the first part of the data in the current file corresponding to the third block is dirty data, a heat identifier for identifying the frequency of use of the first part of the data in the current file corresponding to the third block, and the association relationship between the third block and the fourth block in the data area.

[0016] In one specific implementation, each metadata update information further includes an update order, and the metadata update information includes the file identifier update information, the file fragment update information, and the file identifier update information. The method further includes:

[0017] If the cache meets the preset exception recovery conditions, then the metadata is updated sequentially according to the update order of each metadata update information in the metadata update area.

[0018] In one specific implementation, the method further includes:

[0019] If the file identifier area contains a file identifier that matches the current file identifier, then from each of the second blocks corresponding to the current file identifier, the second block with remaining storage space in the fourth block corresponding to the data area is determined to be the second block corresponding to the current data.

[0020] From the second block, among the fourth blocks corresponding to the data area, determine the target fourth block and / or the free fourth block with remaining storage space, and store the current data in the target fourth block and / or the free fourth block.

[0021] In one specific implementation, the size of each third block of the data area is any value between 8k and 64k.

[0022] In one specific implementation, the metadata update conditions include: the current free space of the metadata update area is less than or equal to a preset free space threshold, or the time length between the last update time of the metadata update area and the current time meets a preset update time threshold.

[0023] A second aspect of this application provides a cache, including:

[0024] The acquisition unit is used to acquire the current file identifier of the current file;

[0025] The determining unit is configured to store the current data of the current file change in the data area, and determine the first block corresponding to the current file in the file identifier area based on the current storage status of the file identifier area, wherein the first block is used to record the current file identifier;

[0026] A storage unit is used to store file identifier update information in the metadata update area, wherein the file identifier update information includes the identifier of the first block and the current file identifier;

[0027] The writing unit is used to write the current file identifier into the first block according to the identifier of the first block if the metadata update area meets the preset metadata update conditions.

[0028] In one specific implementation, the metadata area further includes a file fragment area and a file block area. The determining unit is further configured to determine at least one second block corresponding to the current file in the file fragment area and at least one third block corresponding to the current file in the file block area if there is no file identifier in the file identifier area that matches the current file identifier.

[0029] The storage unit is further configured to store at least one file fragment update information and at least one file block update information in the metadata update area; each file fragment update information includes the identifier of the second block and the association relationship between the second block and the current file; each file block update information includes the identifier of the third block, the association relationship between the third block and the second block corresponding to the third block, the data corresponding to the third block in the data area, and the offset relative to the data corresponding to the second block corresponding to the third block in the data area;

[0030] The writing unit is further configured to, if the metadata update area meets the preset metadata update conditions, write the association relationship between the second block and the current file into the second block according to the second block identifier, and write the association relationship between the third block and the second block corresponding to the third block into the third block according to the identifier of the third block.

[0031] In one specific implementation, the update information for each file block further includes: a dirty data identifier for identifying whether the first part of the data in the current file corresponding to the third block is dirty data, a heat identifier for identifying the frequency of use of the first part of the data in the current file corresponding to the third block, and the association relationship between the third block and the fourth block in the data area.

[0032] In one specific implementation, each metadata update information also includes an update order. The metadata update information includes the file identifier update information, the file fragment update information, and the file identifier update information. The writing unit is also used to update the metadata sequentially according to the update order of each metadata update information in the metadata update area if the cache meets the preset exception recovery conditions.

[0033] In one specific implementation, the determining unit is further configured to, if there is a file identifier in the file identifier area that is consistent with the current file identifier, determine from each of the second blocks corresponding to the current file identifier the second block in the fourth block corresponding to the data area that has remaining storage space as the second block corresponding to the current data;

[0034] The determining unit is further configured to determine, from the second block among the fourth blocks corresponding to the data area, a target fourth block and / or a free fourth block with remaining storage space, and store the current data in the target fourth block and / or the free fourth block.

[0035] In one specific implementation, the size of each third block of the data area is any value between 8k and 64k.

[0036] In one specific implementation, the metadata update conditions include: the current free space of the metadata update area is less than or equal to a preset free space threshold, or the time length between the last update time of the metadata update area and the current time meets a preset update time threshold.

[0037] A third aspect of this application provides a cache, including:

[0038] Central processing unit, memory, and input / output interfaces;

[0039] The memory is either a short-term storage memory or a persistent storage memory;

[0040] The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method described in the first aspect.

[0041] A fourth aspect of this application provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the method described in the first aspect.

[0042] A fifth aspect of this application provides a computer storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in the first aspect.

[0043] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: After obtaining the current file identifier of the current file, the current data can be directly stored in the data area. Then, after determining the first block corresponding to the current file in the file identifier area, the identifier of the first block and the current file identifier are directly saved in the metadata update area as file identifier update information. Finally, only when the metadata update meets the preset metadata update conditions is the current file identifier written to the first block of the file identifier area according to the identifier of the first block. Considering the competition pressure when writing a large amount of metadata, the metadata update is only actually performed when the preset metadata update conditions are met in the metadata update area, that is, the current file identifier is written to the corresponding first block according to the identifier of the first block to complete the metadata update (i.e., file identifier update), which greatly reduces the competition pressure during metadata update. Attached Figure Description

[0044] Figure 1 This is a schematic flowchart of a cache storage method disclosed in an embodiment of this application;

[0045] Figure 2 This is a structural example diagram of the cache disclosed in an embodiment of this application;

[0046] Figure 3This is another schematic diagram of the cache storage method disclosed in the embodiments of this application;

[0047] Figure 4 This is a structural example diagram of the metadata update area disclosed in an embodiment of this application;

[0048] Figure 5 This is a structural example diagram of a file offset index disclosed in an embodiment of this application;

[0049] Figure 6 This is a schematic diagram of the cache structure disclosed in an embodiment of this application;

[0050] Figure 7 This is another schematic diagram of the cache structure disclosed in the embodiments of this application. Detailed Implementation

[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0052] To better illustrate the technical solutions of the embodiments of this application, some technical concepts that appear in the following text will be explained first.

[0053] Cache, in its original sense, refers to a high-speed memory that is faster than regular random access memory (RAM). Unlike main memory, it does not use DRAM technology, but rather the more expensive but faster SRAM technology. The configuration of cache is one of the important factors for all modern computer systems to achieve high performance.

[0054] Hybrid storage is a compromise storage solution. Specifically, it involves storing critical data on high-performance flash media while storing other data on lower-cost tiered storage. Hybrid storage allows organizations to manage data within a unified storage system while still striking a balance between performance and cost.

[0055] Software systems need to use layers to isolate different concerns in order to cope with changes in different needs and to manage these changes independently. For example, a hybrid storage system composed of storage media with different performance can be managed in layers according to the method of separating hot and cold data in the storage system.

[0056] Logical block address (LBA) is a common mechanism used on PC data storage devices to represent the location of data; the most common device using this mechanism is the hard drive. An LBA can refer to the address of a specific data block or the data block pointed to by a given address. Simply put, an LBA is analogous to a house number or address.

[0057] The physical block address (PBA) is analogous to the latitude and longitude used in GPS positioning, relative to the LBA. For example, the latitude and longitude of a house address could be: East longitude: 113°16′40.0621″, North latitude: 23°07′37.6129″.

[0058] This application provides a caching storage method and related devices to reduce contention pressure during metadata updates.

[0059] Please see Figure 1 This application provides a cache storage method, including the following steps:

[0060] 101. Get the current file identifier of the current file.

[0061] To better illustrate the technical solution of the embodiments of this application, each cache that needs to be written to the disk is taken as the current data of the corresponding current file change in the embodiments of this application, and the cache storage process of the embodiments of this application is executed on this current data to complete the storage.

[0062] It's understandable that each cache corresponds to a specific file in the system; that is, each cache represents modified data for a particular file. Therefore, each cache has a corresponding current file identifier. For example, if cache A represents the current modified data for the system file "user," then the current file identifier for cache A is the file identifier for the system file "user."

[0063] In practical applications, any preset digest algorithm can be used to generate the file identifier for the system file "user" to ensure the uniqueness of the file identifier.

[0064] 102. Store the current data of the current file changes in the data area, and determine the first block corresponding to the current file in the file identifier area based on the current storage status of the file identifier area. The first block is used to record the current file identifier.

[0065] After determining the file identifier of the current file, it is possible to determine which file the current data changes belong to. Based on the current storage status of the file identifier area, the first block corresponding to the current file in the file identifier area can be determined. The first block is used to record the current file identifier.

[0066] Specifically, the first block is which of the multiple free blocks in the file identifier area, which can be determined based on the current usage of the file identifier area and the preset storage method (such as breadth-first storage and / or compact storage).

[0067] It should be noted that after storing the current data of the current file change in the corresponding area of ​​the data area, it is considered that the current data of the change has been initially stored. However, the actual storage is not considered complete until the corresponding metadata is stored in the corresponding metadata area (for example, storing the file identifier in the corresponding file identifier area).

[0068] 103. Store the file identifier update information in the metadata update area, where the file identifier update information includes the identifier of the first block and the current file identifier.

[0069] After determining the first block for storing the current file identifier, instead of writing the current file identifier into the first block, the identifier of the first block and the current file identifier can be stored as file identifier update information in the metadata update area to avoid the metadata competition pressure caused by real-time updates.

[0070] 104. If the metadata update area meets the preset metadata update conditions, then write the current file identifier into the first block according to the identifier of the first block.

[0071] The preset metadata update conditions include, but are not limited to: the current free space in the metadata update area is less than or equal to a preset free space threshold, or the time elapsed between the last update and the current time in the metadata update area meets a preset update time threshold. In other words, a metadata update write is performed when the free space in the metadata update area is insufficient and / or when the metadata update area has not processed any update information for an extended period.

[0072] Specifically, processing update information involves writing the corresponding metadata from the update information into the corresponding block. For example, the current file identifier from the file update information is written into the first block corresponding to the identifier of the first block in the file update information.

[0073] In this embodiment, after obtaining the current file identifier, the current data can be directly stored in the data area. Then, after determining the first block corresponding to the current file in the file identifier area, the identifier of the first block and the current file identifier are directly saved as file identifier update information in the metadata update area. Finally, only when the metadata update meets the preset metadata update conditions is the current file identifier written to the first block of the file identifier area according to the identifier of the first block. Considering the competition pressure during a large amount of metadata writing, the metadata update is only actually performed when the preset metadata update conditions are met in the metadata update area. That is, the current file identifier is written to the corresponding first block according to the identifier of the first block to complete the metadata update (i.e., file identifier update), which greatly reduces the competition pressure during metadata updates.

[0074] Furthermore, to achieve multi-level metadata management, the metadata area in this embodiment may also include a file fragment area and a file block area. A block in the file fragment area and a block in the file block area respectively record metadata information of the file's data at different granularities. For example, if the system file "user" is 4GB in size, a corresponding block in the file fragment area can be used to describe the entire 4GB of data information of the system file "user" (such as the PBA of this 4GB), and a corresponding block in the file block area can be used to describe a 4KB piece of data information (such as the LBA of this 4GB) within the entire 4GB of the system file "user". The metadata information of specific file segment areas and file block areas can be updated in the following way: If there is no file identifier in the file identifier area that matches the current file identifier, then at least one second block corresponding to the current file in the file segment area and at least one third block corresponding to the current file in the file block area are determined; at least one file segment update information and at least one file block update information are stored in the metadata update area; each file segment update information includes the identifier of the second block and the association relationship between the second block and the current file; each file block update information includes the identifier of the third block, the association relationship between the third block and the second block corresponding to the third block, the data corresponding to the third block in the data area, and the offset relative to the data corresponding to the second block corresponding to the third block in the data area; if the metadata update area meets the preset metadata update conditions, then according to the second block identifier, the association relationship between the second block and the current file is written into the second block, and according to the third block identifier, the association relationship between the third block and the second block corresponding to the third block is written into the third block.

[0075] Specifically, if no file identifier matching the current file identifier exists in the file identifier area, it indicates that the cache corresponding to the current file is being stored for the first time, meaning the current file is being recorded in the cache for the first time. Consequently, neither the file fragment area nor the file block area contains any metadata records for the current file. Therefore, according to the preset fragment update rules, the information corresponding to the current data changes in the current file that needs to be recorded in the file fragment area should be recorded in the second block. Similarly, the third block corresponding to the file block area is determined according to the preset block update rules. Consistent with the metadata update in the file identifier area, the file block update information and file fragment update information are also updated when the metadata update conditions in the metadata update area are met. Each second block can describe data ranging from 4GB, and each third block can describe data ranging from 8KB to 64KB.

[0076] Understandably, the metadata update area stores multiple update messages. If the metadata update area meets the metadata update conditions, it will automatically process each update message in the order it was added to the metadata update area, without needing to process all pending update messages at once. Furthermore, in the event of a disk failure, an abnormal recovery of the metadata update area will be triggered (i.e., the abnormal recovery conditions are met). In this case, the metadata update should be performed sequentially according to the order in which each update message was added to the metadata update area (i.e., the corresponding update order).

[0077] Furthermore, based on the aforementioned file segmentation and file block design, the update information for each file block more specifically includes: a dirty data identifier to indicate whether the first part of the data in the current file corresponding to the third block is dirty data; a popularity identifier to indicate the frequency of use of the first part of the data in the current file corresponding to the third block; and the association relationship between the third block and the fourth block in the data area.

[0078] In other implementations, if the current file is not being stored on disk for the first time—meaning a file identifier matching the current file exists in the file identifier area—then it's possible to determine from the multiple second blocks corresponding to the current file's segmentation area that there are remaining second blocks describing the data range. These remaining second blocks are used to record the metadata of the current data. The current data is then recorded in the corresponding fourth block in the data area where there is free space; that is, a fourth block that has not yet stored any content, or a fourth block where the used space is less than half of the maximum space. No specific limitations are imposed here.

[0079] The following describes the cache storage method of embodiments of this application in some specific scenarios.

[0080] First, an SSD is used as a tiered caching device, according to... Figure 2The hierarchical metadata structure shown is formatted, and metadata and data management are performed as shown in the table below.

[0081]

[0082]

[0083] Specifically, the metadata design in this application embodiment can be understood in the context of a file system. A file system includes metadata (superblock, inode, entry, directory entry, index, etc.) and data (business data content). Analogous to a file system, this invention adds brick (backend storage corresponding to the cache device). When cached data is stored on disk, it must be accurate and indexable, which includes the backend physical disk (brick) to which the current data belongs, the current file (inode, or file identifier) ​​to which it belongs, the shard to which it belongs, the location of the cache device (extent) where the current data is located, and the location where the cached data is stored (data, data area).

[0084] Please refer to Figure 3 During a tiered cache write operation, the following steps are executed. For example, a file named "Problem List.doc" is created. This file will be assigned a backend storage location (brick) and a unique identifier (inode) for the file, such as brick- / dev / sdx, with the file identifier being inode-uuidx (equivalent to sangfor.txt). Next, the file ID (inode-uuidx) associated with the backend device (brick- / dev / sdx) is created, and this inode data is stored in the cache device (index inode-uuidx). After the inode is created, a shard region needs to be created to store the inode->shard index, which contains the file's slice information. Assuming the file is 8GB, two shard indexes (shard granularity of 4GB) will be generated, namely shard-001 and shard-002. This index information is written to the SSD cache device. Finally, allocate an extent area to store data index information (offset = 0, len = 4KB), and write the data to the corresponding data area. It's important to note that, depending on the specific needs, updating each cache entry may not necessarily require updating the metadata for each metadata area (file identifier area, file fragment area, and / or file block area).

[0085] Specifically, each 4KB extent metadata area stores 512 extent entries, storing the mapping between LBA and PBA. Each third block of the file block area can include the following:

[0086] 1. lba: PBA->LBA mapping, identifies the logical offset of the business file fragment (4GB) of the record in this block. If aligned with the minimum block granularity of 8KB, then LBA only needs to use 19 bits.

[0087] 2. shard: Stores extent->shard mappings, identifying which shard the extent belongs to. Because the maximum number of files that can be supported is 262,144, 19 bits are needed.

[0088] 3. dirty: Indicates whether the cache block data is dirty, i.e. whether the data should be flushed back to the backend storage device (this metadata design takes into account that the cache can be used as a read and write cache).

[0089] 4. Bitmap: Based on the block granularity, data is stored again at a finer granularity (4KB) to improve space utilization. If we assume a maximum block granularity of 64KB, then 64KB / 4KB = 16 bits are needed.

[0090] 5. hot: popularity, indicating the popularity of this block, providing a basis for the replacement algorithm to eliminate it;

[0091] 6. reserved: Reserved space, 1 bit.

[0092] In summary, a total of 8 bytes are sufficient to identify the logical offset of the business file to the index of the cached data location, namely the mapping from LBA to PBA and from PBA to LBA.

[0093] The Inode area, extent area, and shard area are stored in a compact manner, and all three areas must have transactional guarantees. Therefore, the Journal area is specifically used for log-type storage of the above areas.

[0094] For details, please refer to Figure 4The entire Journal area is divided into a super block area (super) and a Journal data area (including meta and data). The meta area is one sector in size (4KB) and contains all metadata information for a single transaction or batch (the block number updated in this update [hierarchical metadata is numbered sequentially by 4KB], and the unique identifier of the current request). The data area stores the updated data content sequentially. First, the Journal space uses a circular queue for management. The head pointer increments when data is inserted, and the tail pointer increments during write-back (WAL compaction). Data within the range [tail, head] is the data to be replayed, and [tail, head] is written to disk with each I / O operation. Additionally, when the process crashes and restarts, it scans all metadata blocks for the largest "seq_id" as the final valid ID, and replays the valid logs within [tail, head]. Specifically, asynchronous replay occurs during business processes, with replay timing based on thresholds such as Journal area capacity (25% of total capacity) and a timed interval (30 minutes).

[0095] The following example illustrates how a business operation triggers an inode update event (triggered by an increase in file size). Data is written through the journal module, which fills in the header [tail, head] index (the address of the journal region) and the written data (4KB inode update write), totaling 8KB of data. The write ID is then added and written to disk in one go. If a power outage or disk unplugging occurs at this time, upon recovery, the metadata needs to be reloaded from the cache device. First, the journal region needs to be loaded. If the power outage occurred after a successful write, reading valid journal data (validity defined by the largest seq_id) restores the state after the successful write. If the write failed, the state before the power outage is restored. After the journal is successfully loaded, the data in the journal region needs to be written to the corresponding inode region; this action is called replay, at which point the entire metadata is restored to its original state.

[0096] A cached data index contains the backend storage (brick), the file (inode), the shard, and the SSD location (extent). Each cached data is a set of (ssd_id, brick_id, inode_id, shard_id, extent_id).

[0097] In practical applications, the process of finding a cached data is as follows: First, the SSD device ID is found through the configuration file to locate the SSD memory structure to which the data belongs (multiple SSD cache devices may exist on the same host). Next, the brick structure is searched in the SSD index table (the search marker is brickid, a unique identifier of the backend storage; the index table here can be a hash table). Then, the inode structure (the file to which the cached data belongs; the index table here can also be a hash table) is searched in the brick index table. Next, the shard structure is searched in the inode index (each file can be divided into multiple shards; the index table is a hash table). Finally, in the shard index structure, the cached data can be read by indexing the extent metadata through the logical offset of the business request. The extent metadata stores the physical disk storage location of the data (the index table can be a red-black tree). The file offset index can be referenced... Figure 5 The relationship between shard, extent, and inode file indexes is determined by the index from LBA to PBA.

[0098] Please see Figure 6 This application provides a cache, which includes a metadata area and a data area. The metadata area includes a file identifier area and a metadata update area. The cache also includes:

[0099] Acquisition unit 601 is used to acquire the current file identifier of the current file;

[0100] The determining unit 602 is used to store the current data of the current file change in the data area, and determine the first block corresponding to the current file in the file identifier area based on the current storage status of the file identifier area. The first block is used to record the current file identifier.

[0101] Storage unit 603 is used to store file identifier update information in the metadata update area, wherein the file identifier update information includes the identifier of the first block and the current file identifier;

[0102] The writing unit 604 is used to write the current file identifier into the first block according to the identifier of the first block if the metadata update area meets the preset metadata update conditions.

[0103] In one specific implementation, the metadata area also includes a file fragment area and a file block area. The determining unit 602 is further configured to determine at least one second block corresponding to the current file in the file fragment area and at least one third block corresponding to the current file in the file block area if there is no file identifier in the file identifier area that matches the current file identifier.

[0104] Storage unit 603 is further configured to store at least one file segment update information and at least one file block update information in the metadata update area; each file segment update information includes the identifier of the second block and the association relationship between the second block and the current file; each file block update information includes the identifier of the third block, the association relationship between the third block and the second block corresponding to the third block, the data corresponding to the third block in the data area, and the offset relative to the data corresponding to the second block corresponding to the third block in the data area;

[0105] The writing unit 604 is further configured to, if the metadata update area meets the preset metadata update conditions, write the association relationship between the second block and the current file into the second block according to the second block identifier, and write the association relationship between the third block and the second block corresponding to the third block into the third block according to the third block identifier.

[0106] In one specific implementation, the update information for each file block also includes: a dirty data identifier for identifying whether the first part of the data in the current file corresponding to the third block is dirty data, a heat identifier for identifying the frequency of use of the first part of the data in the current file corresponding to the third block, and the association relationship between the third block and the fourth block in the data area.

[0107] In one specific implementation, each metadata update information also includes an update order. The metadata update information includes file identifier update information, file fragment update information, and file identifier update information. The writing unit 604 is also used to update the metadata sequentially according to the update order of each metadata update information in the metadata update area if the cache meets the preset exception recovery conditions.

[0108] In one specific implementation, the determining unit 602 is further configured to, if there is a file identifier in the file identifier area that is consistent with the current file identifier, determine from each of the second blocks corresponding to the current file identifier the second block in the fourth block corresponding to the data area that has remaining storage space as the second block corresponding to the current data.

[0109] The determining unit 602 is further configured to determine, from each of the fourth blocks corresponding to the second block in the data area, a target fourth block and / or a free fourth block with remaining storage space, and store the current data in the target fourth block and / or the free fourth block.

[0110] In one specific implementation, the size of each third block of the data area is any value between 8k and 64k.

[0111] In one specific implementation, the metadata update conditions include: the current free space of the metadata update area is less than or equal to a preset free space threshold, or the time length between the last update time of the metadata update area and the current time meets a preset update time threshold.

[0112] Figure 7 This is a schematic diagram of a cache structure provided in an embodiment of this application. The cache 700 may include one or more central processing units (CPUs) 701 and a memory 705, in which one or more applications or data are stored.

[0113] The memory 705 can be volatile or persistent storage. The program stored in the memory 705 can include one or more modules, each module including a series of instruction operations in the cache. Furthermore, the central processing unit 701 can be configured to communicate with the memory 705 and execute the series of instruction operations in the memory 705 on the cache 700.

[0114] The cache 700 may also include one or more power supplies 702, one or more wired or wireless network interfaces 703, one or more input / output interfaces 704, and / or one or more operating systems, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0115] The central processing unit 701 can perform the aforementioned... Figures 1 to 6 The operations performed by the cache in the illustrated embodiment will not be described in detail here.

[0116] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

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

[0118] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

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

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

[0121] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the cache storage method described above.

Claims

1. A cache storage method characterized by, The cache comprises a metadata area and a data area, the metadata area comprises a file identification area and a metadata update area, and the method comprises: obtaining a current file identification of a current file; storing current data of the current file in the data area, and determining a first block corresponding to the current file in the file identification area based on a current storage state of the file identification area, the first block being used for recording the current file identification; storing file identification update information in the metadata update area, wherein the file identification update information comprises an identification of the first block and the current file identification; if the metadata update area satisfies a preset metadata update condition, writing the current file identification into the first block according to the identification of the first block.

2. The method of claim 1, wherein, The metadata area further comprises a file fragment area and a file block area, and the method further comprises: if the file identification area does not exist a file identification consistent with the current file identification, determining at least one second block corresponding to the current file in the file fragment area and at least one third block corresponding to the current file in the file block area; storing at least one file fragment update information and at least one file block update information in the metadata update area; each file fragment update information comprises an identification of the second block and an association relationship between the second block and the current file; and each file block update information comprises an identification of the third block, an association relationship between the third block and a second block corresponding to the third block, and an offset of data corresponding to the third block in the data area relative to data corresponding to the second block in the data area; if the metadata update area satisfies a preset metadata update condition, writing the association relationship between the second block and the current file into the second block according to the identification of the second block, and writing the third block and the association relationship between the third block and the second block corresponding to the third block into the third block according to the identification of the third block.

3. The method of claim 2, wherein, Each file block update information further comprises a dirty data identification for identifying whether a first part of data corresponding to the third block in the current file is dirty data, a hotness identification for identifying a frequency of use of the first part of data corresponding to the third block in the current file, and an association relationship between the third block and a fourth block in the data area.

4. The method according to claim 1 or 3, characterized in that, Each metadata update information further comprises an update sequence, the metadata update information comprises the file identification update information, the file fragment update information and the file block update information, and the method further comprises: if the cache satisfies a preset abnormal recovery condition, sequentially performing metadata update according to the update sequence of each metadata update information in the metadata update area.

5. The method of claim 1, wherein, The method further comprises: if the file identification area exists a file identification consistent with the current file identification, determining, from each second block corresponding to the current file identification, a second block having a remaining storage space in a fourth block corresponding to the data area as a second block corresponding to the current data. determining, from each fourth sub-block corresponding to the data area of the second sub-block, a target fourth sub-block with remaining storage space and / or a free fourth sub-block, and storing the current data in the target fourth sub-block and / or the free fourth sub-block.

6. The method of any one of claims 2-3, wherein, Each third sub-block of the data area has a size of any value in a range from 8k to 64k.

7. The method of claim 1, wherein, The metadata update condition includes that a current free space of the metadata update area is less than or equal to a preset free space threshold, or a time length from a last update time of the metadata update area to a current time satisfies a preset update time threshold.

8. A cache, characterized by, The cache includes a metadata area and a data area, the metadata area includes a file identification area and a metadata update area, and the cache further includes: an obtaining unit configured to obtain a current file identification of a current file; a determining unit configured to store current data changed by the current file in the data area, and determine, based on a current storage condition of the file identification area, a first sub-block corresponding to the file identification area for recording the current file identification, the first sub-block being used for recording the current file identification; a storing unit configured to store file identification update information in the metadata update area, the file identification update information including an identification of the first sub-block and the current file identification; a writing unit configured to, if the metadata update area satisfies a preset metadata update condition, write the current file identification into the first sub-block according to the identification of the first sub-block.

9. A cache, characterized by, comprise: a central processing unit, a memory, and an input / output interface; the memory is a volatile storage memory or a persistent storage memory; the central processing unit is configured to communicate with the memory and execute instruction operations in the memory to perform the method in any one of claims 1 to 7.

10. A computer storage medium, characterized in that, The computer storage medium stores instructions, and the instructions, when executed on a computer, cause the computer to perform the method in any one of claims 1 to 7. The computer storage medium stores instructions, and the instructions, when executed on a computer, cause the computer to perform the method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Metadata updating method and device, equipment and medium

    CN111488128A

  • Method, apparatus and computer program product for managing metadata of storage objects

    CN111857556A