A Cache Management Method and System for File System

Through a file system-oriented cache management method, file system meta-information optimizes cache search and management, combined with stack algorithm and collective clearing mechanism, the problems of low efficiency and space utilization of existing cache systems are solved, and more efficient cache management is achieved.

CN115794755BActive Publication Date: 2025-06-10EAST CHINA NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211576435.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-09
Publication Date
2025-06-10
Estimated Expiration
2042-12-09

AI Technical Summary

Technical Problem

Existing cache systems are inefficient in file reading and low space utilization, mainly due to the use of physical addresses as cache index key values, and the existing cache replacement strategy is not very high in space utilization during updates.

Method used

The cache management method for file systems is adopted, and the cache manager determines the specific location of the data in the cache based on the file system meta information of the requested data, and manages the cached data block collection according to the stack algorithm or collective clearing method to ensure the improvement of cache efficiency and space utilization.

Benefits of technology

By using file system meta information to optimize the cache search process, the cache efficiency is improved; through regular retrieval and clearing mechanisms, the utilization rate of cache space is improved, and the problems of low cache efficiency and space utilization are solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115794755B_ABST
    Figure CN115794755B_ABST
Patent Text Reader

Abstract

The present invention discloses a cache management method and system for a file system. The method includes: the cache manager determines the specific location of the requested data according to the file system metadata of the requested data, further determines the cache location of the requested data based on whether the specific location is valid, and sends the cache location to the user system; the cache manager performs retrieval at regular time intervals, makes determinations and judgments, and if there is a file in the file set of the cache data block set that is not in the file set being opened by the user system, the cache manager performs clearing according to the collective clearing method. The system includes a cache manager and a cache data block set, wherein the cache manager includes: a retrieval module, a module for reading specific data, a data addition module, a first, a second, and a third judgment module, and a first and a second clearing module. The present invention solves the problems of low performance and low space utilization rate of the existing cache system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer cache management, and particularly relates to an efficient cache management method and system for a file system. Background Art

[0002] Caching is one of the most fundamental and effective methods in computer science to improve system performance. Its working principle is that when the CPU wants to read a piece of data, it first looks for it in the cache. If found, it is immediately read and sent to the CPU for processing; if not found, it has to be read from other memories at a relatively slow speed and then sent to the CPU for processing. At the same time, the data block where this data is located is transferred into the cache, so that subsequent reads of the entire data block can be performed in the cache without having to call other relatively slow storage devices.

[0003] With the development of technology, more and more cache systems are applied, and caches for file reading have also emerged. The existing caching method uses the physical address of the data as the cache index key value. However, obtaining the physical address of the requested data is time-consuming, and obtaining the cache index key value is a necessary prerequisite step for determining whether the requested data is cached. Therefore, using the physical address as the cache index key value will lead to a decrease in cache efficiency.

[0004] At the same time, existing cache replacement policies such as the first-in-first-out algorithm, etc., only start to select a cache data block for clearing when the cache is full, and then add the new cache data block to the cache data block set. Although this method can also update the cache, the cache is in a full state both before and after the update, and the space utilization rate of the cache is relatively low, resulting in a waste of cache space. Summary of the Invention

[0005] In order to overcome the above deficiencies of the prior art, the object of the present invention is to provide a cache management method and system for a file system. Based on the characteristics of the file system, the present invention solves the problems of low performance and space utilization rate of the existing cache system.

[0006] The specific technical solution for achieving the object of the present invention is as follows:

[0007] A cache management method for a file system, the method comprising:

[0008] The cache manager determines the specific location of the requested data in the cache data block set according to the file system metadata of the requested data;

[0009] Judge whether the specific location of the requested data is valid in the cache data block set; if valid, obtain the cache location of the requested data; if invalid, the cache manager determines the original location of the requested data;

[0010] After the cache manager reads the specific content of the request data from the original location of the request data, it first determines the number of data blocks in the cache data block set;

[0011] It is judged whether the number of data blocks is greater than or equal to a preset maximum number of data blocks. If it is greater than or equal to, the cache manager clears the data blocks in the cache data block set according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; if it is less than, the cache manager adds the specific content of the request data, the file system meta information and the cache location to the cache data block set;

[0012] The cache manager sends the cache location of the request data to the user system;

[0013] The cache manager retrieves at regular time intervals to determine the set of files being opened in the user system and the set of files to which the cache data block set belongs;

[0014] It is judged whether the files in the set of files to which the cache data block set belongs are also in the set of files being opened in the user system. If not, the cache manager clears the data blocks in the cache data block set according to the collective clearing method.

[0015] The file system meta information of the request data includes: inode number, logical block number and connection symbol @, denoted as: inode number @ logical block number, where:

[0016] The inode number is the unique number of a file in the file system and is used to identify different files;

[0017] The logical block number is an integer starting from 0 and is used to determine which block the specific position in the file belongs to;

[0018] The connection symbol @ separates the inode number and the logical block number.

[0019] Determining the specific position of the request data in the cache data block set according to the file system meta information of the request data includes:

[0020] Based on the cache location of the request data, determining the position of the request data in the cache data block set;

[0021] Based on the original location of the request data, determining the position of the request data on the hard disk.

[0022] Judging whether the specific position of the request data is valid in the cache data block set includes:

[0023] Determine whether the specific location of the requested data exists in the cache data block set;

[0024] If it does not exist, the specific location of the requested data is invalid; if it exists, determine the file system metadata of the data block at the specific location in the cache data block set;

[0025] Determine whether the file system original information of the requested data is the same as the file system metadata of the data block at the specific location. If they are not the same, the specific location of the requested data is invalid; if they are the same, the specific location of the requested data is valid.

[0026] The stack algorithm is to determine the data block to be cleared in the cache data block set according to the least recently used algorithm, and clear the data block to be cleared from the cache data block set.

[0027] The collective clearing method is to determine all data blocks belonging to the file in the cache data block set as the data blocks to be cleared according to the files in the file set to which the cache data block set belongs but not in the file set being opened in the user system, and clear the data blocks to be cleared from the cache data block set.

[0028] A cache management system for a file system, including: a cache manager and a cache data block set, where:

[0029] The cache manager is used to manage the cache data block set, determine the number of data blocks in the cache data block set; judge whether the number of data blocks is greater than or equal to the preset maximum number of data blocks. If it is greater, clear according to the stack algorithm; add the specific content, file system metadata and cache location information of the requested data to the cache data block set; retrieve at regular time intervals to determine the file set being opened in the user system and the file set to which the cache data block set belongs; judge whether the files in the file set to which the cache data block set belongs are also in the file set being opened in the user system. If not, the cache manager clears the data blocks in the cache data block set according to the collective clearing method;

[0030] The cache data block set is used to store the data blocks not exceeding the preset maximum number of data blocks, where the specific content, file system metadata and cache location information of the requested data are stored in the data blocks.

[0031] The cache manager includes: a retrieval module, a module for reading specific data, a data addition module, a first judgment module, a second judgment module, a third judgment module, a first clearing module and a second clearing module, where:

[0032] A retrieval module, which is used to retrieve the set of cached data blocks to determine the number of data blocks in the set of cached data blocks; used to retrieve the set of cached data blocks to determine the set of files being opened in the user system; used to retrieve the user system to determine the set of files to which the set of cached data blocks belongs;

[0033] A specific data reading module, which is used to read the specific content of the requested data from the original position of the requested data;

[0034] A data adding module, which is used to add the specific content of the requested data, file system meta-information, and cache location to the set of cached data blocks;

[0035] A first judgment module, which is used to judge whether the specific position of the requested data is valid in the set of cached data blocks; if it is valid, obtain the cache location of the requested data; if it is invalid, the cache manager determines the original position of the requested data;

[0036] A second judgment module, which is used to judge whether the number of data blocks is greater than or equal to a preset maximum number of data blocks. If it is greater than or equal to, the cache manager clears the data blocks in the set of cached data blocks according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; if it is less than, the cache manager adds the specific content of the requested data, file system meta-information, and cache location to the set of cached data blocks;

[0037] A third judgment module, which is used to judge whether the files in the set of files to which the set of cached data blocks belongs are also in the set of files being opened in the user system. If not, the cache manager clears the data blocks in the set of cached data blocks according to the collective clearing method;

[0038] A first clearing module, which is used to clear the data blocks in the set of cached data blocks according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; used to update the number of data blocks in the set of cached data blocks after clearing;

[0039] A second clearing module, which clears the data blocks in the set of cached data blocks according to the collective clearing method; used to update the number of data blocks in the set of cached data blocks after clearing.

[0040] Based on the above technical solution, for the cache management method and system for a file system provided by the present invention, the cache manager determines the specific location of the requested data in the cache data block set according to the file system meta-information of the requested data, and then determines whether the specific location is valid; if it is valid, the cache location of the requested data is obtained; if it is invalid, the cache manager determines the original location of the requested data, reads the specific content of the requested data, and then determines whether the number of data blocks in the cache block set is greater than or equal to the preset maximum number of data blocks. If it is greater than or equal to, the cache manager performs clearing according to the stack algorithm until the number of data blocks in the cache block set is less than the preset maximum number of data blocks; if it is less than, the cache manager adds the specific content of the requested data, the file system meta-information, and the cache location to the cache data block set; because it is determined whether the requested data is in the cache data block set according to the file system meta-information of the requested data, and the time overhead for the cache manager to obtain the file system meta-information of the requested data is very low, the present invention can effectively improve the cache efficiency while facing the file system.

[0041] Based on the above technical solution, for the cache management method and system for a file system provided by the present invention, the cache manager performs a retrieval at regular time intervals. First, it determines the set of files that are being opened in the user system and the set of files in the cache data block set, and then determines whether the files in the set of files in the cache data block set are also in the set of files that are being opened in the user system. If not, the cache manager clears the data blocks in the cache data block set according to the collective clearing method. Through such regular retrieval, judgment, and clearing, the cache manager can clear the file data in the cache data block set that is no longer used by the user system, release a certain amount of cache space, and improve the space utilization rate of the cache.

[0042] In summary, for the cache management method and system for a file system provided by the present invention, on the basis of facing the file system, it can improve the cache efficiency and the space utilization rate of the cache at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a flowchart of the cache management method for a file system provided by the present invention;

[0044] Figure 2 It is a flowchart of clearing the data blocks in the cache data block set according to the collective clearing method in the cache management method for a file system provided by the present invention;

[0045] Figure 3 It is a schematic structural diagram of the cache management system for a file system provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0046] The following will further clearly and completely describe in detail the technical solutions in the present invention in conjunction with the accompanying drawings in the present invention.

[0047] Figure 1 It is a flowchart of a cache management method for a file system provided by the present invention, which realizes effective management of data blocks in a cache data block set. Refer to Figure 1 , starting from step 101, and then:

[0048] In step 102, the cache manager determines its specific location in the cache data block set according to the file system meta-information of the requested data.

[0049] In step 103, the cache manager determines whether the specific location of the requested data is valid in the cache data block set. If it is valid, step 104 is executed; if it is not valid, step 105 is executed. In step 104, the cache manager obtains the cache location of the requested data and enters step 111.

[0050] In step 105, the cache manager determines the original location of the requested data and reads the specific content of the requested data from the original location.

[0051] In step 106, the cache manager determines the number of data blocks in the cache data block set.

[0052] In step 107, the cache manager determines whether the number of data blocks is greater than or equal to a preset maximum number of data blocks. If it is greater than or equal to, step 109 is executed; if it is less than, step 108 is executed.

[0053] In step 108, the cache manager adds the specific content of the requested data, the file system meta-information, and the cache location to the cache data block set and enters step 111.

[0054] In step 109, the cache manager clears the data blocks in the cache data block set according to the stack algorithm.

[0055] In step 110, the cache manager updates the number of data blocks in the cache data block set and enters step 107.

[0056] In step 111, the cache manager sends the cache location of the requested data to the user system and enters step 112 to end.

[0057] Figure 2 It is a flowchart of clearing data blocks in a cache data block set according to a collective clearing method in a cache management method for a file system provided by the present invention, which realizes effective management of data blocks in the cache data block set. Refer to Figure 2 , starting from step 201, and then:

[0058] In step 202, the cache manager retrieves at a predetermined time interval to determine the set of files being opened in the user system and the set of files to which the cache data block set belongs.

[0059] In step 203, the cache manager determines whether the files in the set of files to which the cache data block set belongs are also in the set of files being opened in the user system. If there are files not in the set of files being opened in the user system, step 204 is executed; otherwise, it proceeds to step 206 to end.

[0060] In step 204, the cache manager clears the data blocks in the cache data block set according to the collective clearing method.

[0061] In step 205, the cache manager updates the number of data blocks in the cache data block set and proceeds to step 206 to end.

[0062] Figure 3 It is a schematic structural diagram of the cache management system for the file system provided by the present invention. Refer to Figure 3 This cache management system for the file system may include: a cache manager 31 and a cache data block set 32, where:

[0063] The cache manager 31 is used to manage the cache data block set 32;

[0064] The cache data block set 32 is used to store data blocks not exceeding the preset maximum number of data blocks;

[0065] Figure 3 It shows a schematic structural diagram of the cache manager 31 in the cache management system for the file system provided by the present invention. Refer to Figure 3 This cache manager 31 may include: a retrieval module 311, a read specific data module 312, an add data module 313, a first judgment module 314, a second judgment module 315, a third judgment module 316, a first clearing module 317, and a second clearing module 318, where:

[0066] The retrieval module 311 is used to retrieve the cache data block set 32 to determine the number of data blocks in the cache data block set 32; is used to retrieve the cache data block set 32 to determine the set of files being opened in the user system; is used to retrieve the user system to determine the set of files to which the cache data block set 32 belongs;

[0067] The read specific data module 312 is used to read the specific content of the requested data from the original position of the requested data;

[0068] An adding data module 313 is used to add the specific content of the requested data, the file system meta-information, and the cache location to the cache data block set 32;

[0069] A first judgment module 314 is used to judge whether the specific location of the requested data is valid in the cache data block set 32; if it is valid, the cache location of the requested data is obtained; if it is not valid, the cache manager 31 determines the original location of the requested data;

[0070] A second judgment module 315 is used to judge whether the number of data blocks is greater than or equal to a preset maximum number of data blocks. If it is greater than or equal to, the cache manager 31 calls a first clearing module 317 to clear the data blocks in the cache data block set 32 according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; if it is less than, the cache manager 31 adds the specific content of the requested data, the file system meta-information, and the cache location to the cache data block set 32;

[0071] A third judgment module 316 is used to judge whether the file in the file set to which the cache data block set 32 belongs is also in the file set being opened in the user system. If it is not, the cache manager 31 calls a second clearing module 318 to clear the data blocks in the cache data block set 32 according to the collective clearing method.

[0072] The first clearing module 317 is used to clear the data blocks in the cache data block set 32 according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; and is used to update the number of data blocks in the cache data block set after clearing;

[0073] The second clearing module 318 clears the data blocks in the cache data block set 32 according to the collective clearing method; and is used to update the number of data blocks in the cache data block set after clearing.

[0074] Figure 3 Shows a schematic structural diagram of the cache data block set 32 in the cache management system for a file system provided by the present invention. Refer to Figure 3 and this cache data block set 32 may include several data blocks 321, where:

[0075] The data block 321 is used to store the specific content of the requested data block, the file system meta-information, and the cache location.

Claims

1. A cache management method for a file system, characterized in that, it includes: The cache manager determines the specific location of the requested data in the cache data block set according to the file system metadata of the requested data; Judge whether the specific location of the requested data is valid in the cache data block set; if it is valid, obtain the cache location of the requested data; if it is not valid, the cache manager determines the original location of the requested data; After the cache manager reads the specific content of the requested data from the original location of the requested data, it first determines the number of data blocks in the cache data block set; Judge whether the number of data blocks is greater than or equal to the preset maximum number of data blocks. If it is greater than or equal to, the cache manager clears the data blocks in the cache data block set according to the stack algorithm, and the cache manager updates the number of data blocks in the cache data block set until the number of data blocks is less than the preset maximum number of data blocks; if it is less than, the cache manager adds the specific content, file system metadata and cache location of the requested data to the cache data block set; The cache manager sends the cache location of the requested data to the user system; The cache manager retrieves at regular time intervals to determine the set of files being opened in the user system and the set of files to which the cache data block set belongs; Judge whether the files in the set of files to which the cache data block set belongs are also in the set of files being opened in the user system. If not, the cache manager clears the data blocks in the cache data block set according to the collective clearing method, and the cache manager updates the number of data blocks in the cache data block set; where: The judgment of whether the specific location of the requested data is valid in the cache data block set includes: Judge whether the specific location of the requested data exists in the cache data block set; If it does not exist, the specific location of the requested data is invalid; if it exists, determine the file system metadata of the data block at the specific location in the cache data block set; Judge whether the original file system information of the requested data is the same as the file system metadata of the data block at the specific location. If they are not the same, the specific location of the requested data is invalid; if they are the same, the specific location of the requested data is valid.

2. The cache management method for a file system according to claim 1, characterized in that, The file system metadata of the requested data includes: inode number, logical block number and connection symbol @, denoted as: inode number @ logical block number, where: The inode number is the unique number of a file in the file system, used to identify different files; The logical block number is an integer starting from 0, used to determine which block the specific location in the file belongs to; The connection symbol @ separates the inode number and the logical block number.

3. The cache management method for a file system according to claim 1, characterized in that, Determining the specific location of the requested data in the cache data block set according to the file system meta information of the requested data includes: Based on the cache location of the requested data, determining the location of the requested data in the cache data block set; Based on the original location of the requested data, determining the location of the requested data on the hard disk.

4. A cache management method for a file system according to claim 1, characterized in that The stack algorithm is to determine the data block to be cleared in the cache data block set according to the least recently used algorithm, and clear the data block to be cleared from the cache data block set.

5. A cache management method for a file system according to claim 1, characterized in that The collective clearing method is to determine all the data blocks belonging to the file in the cache data block set as the data blocks to be cleared according to the files in the file set to which the cache data block set belongs but not in the file set being opened in the user system, and clear the data blocks to be cleared from the cache data block set.

6. A system for implementing the cache management method for a file system according to any one of claims 1-5, characterized in that it includes: A cache manager and a cache data block set, where: The cache manager is used to manage the cache data block set, determine the number of data blocks in the cache data block set; judge whether the number of data blocks is greater than or equal to a preset maximum number of data blocks, and if so, perform clearing according to the stack algorithm; add the specific content, file system meta information and cache location information of the requested data to the cache data block set; perform retrieval at regular time intervals to determine the file set being opened in the user system and the file set to which the cache data block set belongs; Judge whether the files in the file set to which the cache data block set belongs are also in the file set being opened in the user system, and if not, the cache manager clears the data blocks in the cache data block set according to the collective clearing method; The cache data block set is used to store the data blocks not exceeding the preset maximum number of data blocks, and the specific content of the requested data, file system meta information and cache location information are stored in the data blocks.

7. The system according to claim 6, characterized in that The cache manager includes: a retrieval module, a module for reading specific data, a data adding module, a first judgment module, a second judgment module, a third judgment module, a first clearing module and a second clearing module, where: The retrieval module is used to retrieve the cache data block set to determine the number of data blocks in the cache data block set; used to retrieve the cache data block set to determine the file set being opened in the user system; used to retrieve the user system to determine the file set to which the cache data block set belongs; The module for reading specific data is used to read the specific content of the requested data from the original location of the requested data; An adding data module, configured to add the specific content of the request data, file system meta information, and cache location to the cache data block set; A first judgment module, configured to judge whether the specific location of the request data is valid in the cache data block set; if it is valid, obtain the cache location of the request data; if it is invalid, the cache manager determines the original location of the request data; A second judgment module, configured to judge whether the number of data blocks is greater than or equal to a preset maximum number of data blocks; if it is greater than or equal to, the cache manager clears the data blocks in the cache data block set according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; if it is less than, the cache manager adds the specific content of the request data, file system meta information, and cache location to the cache data block set; A third judgment module, configured to judge whether the files in the file set to which the cache data block set belongs are also in the file set being opened in the user system; if not, the cache manager clears the data blocks in the cache data block set according to the collective clearing method; A first clearing module, configured to clear the data blocks in the cache data block set according to the stack algorithm until the number of data blocks is less than the preset maximum number of data blocks; and configured to update the number of data blocks in the cache data block set after clearing; A second clearing module, configured to clear the data blocks in the cache data block set according to the collective clearing method; and configured to update the number of data blocks in the cache data block set after clearing.

Citation Information

Patent Citations

  • Cache Management System for Enhancing the Accessibility of Small Files in Distributed File System

    KR1020160067289A

  • Lazy virtual filesystem instantiation and caching

    US20200125650A1