Cache scheduling method and system for a file storage system

CN122654086APending Publication Date: 2026-08-28HUNAN TONGYOU FEIJI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610836741.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-10
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0005]本申请提供一种文件存储系统的缓存调度方法及系统,旨在解决现有技术在文件存储系统的小数据块并行写入缓存调度中,缓存数据写入延迟较高、不同写入对象之间延迟稳定性较差以及低延迟与高带宽难以兼顾的问题

Benefits of technology

[0064]Based on further analysis and research of existing technical problems, this application recognizes that existing technologies suffer from high cache data write latency, poor latency stability between different write objects, and difficulty in balancing low latency and high bandwidth in small data block parallel write cache scheduling of file storage systems. By receiving the data to be written from the write object and determining its data location information and object identifier, the application first assigns the data to be written to the corresponding target cache block based on the data location information and the preset cache block size, and then writes it to that target cache block, thus giving small-granularity write data a definite cache carrying location. Furthermore, based on the cache block identifier, the application allocates the target cache block to the corresponding target parallel flushing unit, allowing different cache blocks to be flushed in a distributed manner, thereby improving the parallelism of writing cache data to the backend storage system. Simultaneously, based on the object identifier... This invention associates target cache blocks with target scheduling queues in a target parallel flushing unit. The target parallel flushing unit schedules multiple queues according to a preset polling order. Flushing is triggered when the cache block's data volume reaches a preset data volume condition or the dirty data's dwell time reaches a preset time condition, preventing dirty data from remaining in the cache for extended periods while waiting for aggregation. Furthermore, after flushing a cache block in any scheduling queue, the target parallel flushing unit switches to the next queue, preventing a single write object or a single scheduling queue from occupying flushing resources for an extended period, ensuring a more balanced flushing opportunity for cache blocks of different write objects. Finally, cache blocks that have been flushed and meet preset reclamation conditions are reclaimed, allowing cache resources to be reused for subsequent data writes. Therefore, this application can reduce the waiting time for writing cached data to the backend storage system in small data block parallel write scenarios, improve latency stability between different write objects, and maintain high write bandwidth through parallel flushing under low latency requirements, thus solving the problems of high cached data write latency, poor latency stability between different write objects, and the difficulty in balancing low latency and high bandwidth.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122654086A_ABST
    Figure CN122654086A_ABST
Patent Text Reader

Abstract

The application discloses a cache scheduling method and system of a file storage system, and relates to the technical field of file storage. The method comprises the following steps: receiving to-be-written data of a write object, determining data position information and object identification; determining a cache block identification based on a preset cache block size and the data position information, locating or allocating a target cache block and writing the to-be-written data; determining a target parallel writing unit based on the cache block identification, determining a target scheduling queue based on the object identification and associating the target cache block; polling multiple scheduling queues through the target parallel writing unit, writing to a back-end storage system when the cache block meets a data amount condition or a dirty data residence time condition, and switching to a next scheduling queue after writing one cache block; and recycling the cache block that has completed writing and meets a recycling condition. Thus, the cache writing delay of small data block parallel writing can be reduced, the delay stability of different write objects can be improved, and the write bandwidth is taken into account.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of file storage technology, and in particular to a cache scheduling method and system for a file storage system. Background Technology

[0002] With the widespread adoption of distributed storage, network file systems, and high-performance file services, file storage systems need to handle a large number of read and write access requests from clients simultaneously. In scenarios such as data acquisition, log writing, business transaction recording, and parallel file writing, clients may continuously generate small-granularity data write requests. To reduce the access pressure on backend storage devices and improve overall write efficiency, file storage systems typically set up a cache area in memory to temporarily store data to be written to the backend storage system, and use an appropriate cache scheduling mechanism to write the cached data to the backend storage system.

[0003] In related technologies, file storage systems typically reduce the number of writes to the backend storage system to improve overall write bandwidth by using methods such as cache aggregation, batch writing, or periodic flushing. These methods achieve good throughput performance in scenarios with large data volumes or low write timeliness requirements. However, in scenarios where small data blocks are continuously written and the written data needs to be read or acknowledged promptly, the waiting time of cached data in memory can easily increase, leading to significant latency between data being written to the cache and becoming visible to the backend. Furthermore, when multiple files or multiple write objects are written in parallel, the amount of cached data, write frequency, and flushing timing may differ for different write objects. This can easily cause some cached data to fail to be written to the backend storage system in a timely manner, resulting in large fluctuations in data write latency between different files or different write objects. In addition, simply shortening the cache dwell time may reduce the degree of data aggregation, impacting the write bandwidth of the backend storage system.

[0004] Therefore, in the parallel write cache scheduling of small data blocks in file storage systems, the high latency of cached data writes, the poor latency stability between different write objects, and the difficulty in balancing low latency and high bandwidth have become urgent problems to be solved. Summary of the Invention

[0005] This application provides a cache scheduling method and system for a file storage system, aiming to solve the problems of high cache data write latency, poor latency stability between different write objects, and difficulty in balancing low latency and high bandwidth in the existing technology for parallel write cache scheduling of small data blocks in file storage systems.

[0006] A first aspect includes a cache scheduling method for a file storage system, the method comprising:

[0007] Receive the data to be written to the object, and determine the data location information corresponding to the data to be written and the object identifier of the object to be written;

[0008] Based on the preset cache block size and the data location information, the cache block identifier corresponding to the data to be written is determined, and the corresponding target cache block is located or allocated based on the cache block identifier, and the data to be written is written to the target cache block;

[0009] Based on the cache block identifier, a target parallel flush unit for processing the target cache block is determined from multiple parallel flush units;

[0010] Based on the object identifier, a target scheduling queue is determined from multiple scheduling queues corresponding to the target parallel flushing unit, and the target cache block is associated with the target scheduling queue.

[0011] The target parallel flushing unit schedules the multiple scheduling queues according to a preset polling order. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data amount condition, or the residence time of dirty data in the cache block to be flushed reaching a preset time condition. After performing flushing on one cache block to be flushed in any scheduling queue, the target parallel flushing unit switches to the next scheduling queue for scheduling.

[0012] Reclaim cache blocks that have been flushed and meet the preset reclamation conditions so that the reclaimed cache blocks can be used for caching subsequent data writes.

[0013] Optionally, in the above scheme, determining the cache block identifier corresponding to the data to be written based on the preset cache block size and the data location information, and locating or allocating the corresponding target cache block based on the cache block identifier, includes:

[0014] Based on the data location information and the preset cache block size, block partitioning calculation is performed to obtain the cache block identifier corresponding to the data to be written;

[0015] Based on the cache block identifier, query the allocated cache block record to obtain the cache block location result;

[0016] If the cache block location result indicates the existence of an allocated cache block, the allocated cache block is identified as the target cache block;

[0017] If the cache block location result indicates that no allocated cache block exists, a cache block is allocated from the set of free cache resources, and the allocated cache block is associated with the cache block identifier to obtain the target cache block.

[0018] Optionally, in the above scheme, determining the target parallel flush unit for processing the target cache block from multiple parallel flush units based on the cache block identifier includes:

[0019] Obtain the number of units corresponding to the plurality of parallel write units;

[0020] Based on the cache block identifier and the number of units, a mapping calculation is performed to obtain the flush unit identifier;

[0021] Based on the brushing unit identifier, the target parallel brushing unit is determined from the plurality of parallel brushing units;

[0022] The target cache block is associated with the target parallel flushing unit so that the target cache block is flushed by the target parallel flushing unit.

[0023] Optionally, in the above scheme, determining the target scheduling queue from multiple scheduling queues corresponding to the target parallel writing unit based on the object identifier includes:

[0024] Obtain the queue identifiers of multiple scheduling queues corresponding to the target parallel writing unit;

[0025] The object identifier is mapped to obtain object mapping information;

[0026] Based on the object mapping information and the queue identifiers of the multiple scheduling queues, determine the target queue identifier corresponding to the written object;

[0027] The scheduling queue corresponding to the target queue identifier is determined as the target scheduling queue.

[0028] Optionally, in the above scheme, allocating cache blocks from the set of free cache resources includes:

[0029] Get the number of objects currently being written and the total amount of allocable cache resources;

[0030] Based on the current number of write objects and the total amount of allocable cache resources, determine the object cache quota corresponding to each write object;

[0031] Obtain the amount of cache resources already occupied by the written object, and based on the amount of cache resources already occupied and the object cache quota, obtain the quota determination result;

[0032] If the quota determination result indicates that the write object meets the cache allocation conditions and there is a free cache block in the free cache resource set, the target cache block is allocated from the free cache resource set.

[0033] If the quota determination result indicates that the write object does not meet the cache allocation conditions, or if there is no free cache block in the free cache resource set, a waiting allocation record is generated and the waiting allocation record is added to the waiting queue.

[0034] Optionally, in the above scheme, if any scheduling queue contains a cache block to be flushed that meets the preset flushing conditions, then flushing the data in the cache block to be flushed to the backend storage system includes:

[0035] Obtain the amount of data written and the time of dirty data generation for any candidate cache block in the scheduling queue;

[0036] Based on the amount of data already written and the preset data amount threshold, the data amount determination result is obtained;

[0037] Based on the dirty data generation time and the preset dwell time threshold, the dwell time determination result is obtained;

[0038] If the data volume determination result indicates that the data volume of the candidate cache block reaches the preset data volume condition, or if the dwell time determination result indicates that the dirty data dwell time in the candidate cache block reaches the preset time condition, the candidate cache block is determined as the cache block to be flushed.

[0039] The data in the cache block to be written is written to the backend storage system, and a write completion status corresponding to the cache block to be written is generated.

[0040] Optionally, in the above scheme, writing the data in the cache block to be written to the backend storage system includes:

[0041] Obtain the current scheduling pointer corresponding to the target parallel flushing unit;

[0042] Based on the current scheduling pointer, determine the current scheduling queue from the plurality of scheduling queues;

[0043] A cache block to be flushed is determined from the current scheduling queue that meets the preset flushing conditions, and flushing processing is performed on the cache block to be flushed to obtain the scheduling result.

[0044] The current scheduling pointer is updated based on the current scheduling result to obtain the next scheduling pointer;

[0045] Based on the next scheduling pointer, switch to the next scheduling queue to schedule the next scheduling queue.

[0046] Optionally, in the above scheme, the step of reclaiming cache blocks that have been flushed and meet preset reclamation conditions includes:

[0047] Get the flush completion status and cache resource status information of the candidate reclaimed cache blocks that have been flushed;

[0048] Based on the amount of free cache resources and the total amount of cache resources represented by the cache resource status information, the allowable retention time corresponding to the candidate reclaimed cache block is determined;

[0049] Based on the flush completion status and the allowed retention time, the recycling determination result corresponding to the candidate recycled cache block is obtained;

[0050] If the recycling determination result indicates that the candidate recycled cache block meets the preset recycling conditions, the candidate recycled cache block is removed from the corresponding scheduling queue and added to the idle cache resource set.

[0051] Optionally, in the above scheme, after removing the candidate reclaimed cache block from the corresponding scheduling queue and adding it to the set of idle cache resources, the method further includes:

[0052] Update the status of the idle cache resources corresponding to the set of idle cache resources to obtain the updated status of the idle cache resources.

[0053] Based on the updated status of the idle cache resources, query the waiting queue to obtain the write tasks to be woken up.

[0054] Based on the write object and cache allocation conditions corresponding to the write task to be woken up, a wake-up command is generated;

[0055] The wake-up command triggers the write task to be woken up to re-execute the cache block allocation process.

[0056] Secondly, a cache scheduling system for a file storage system, the system comprising:

[0057] The data receiving module is used to receive the data to be written to the object, and to determine the data location information corresponding to the data to be written and the object identifier of the object to be written.

[0058] The cache block processing module is used to determine the cache block identifier corresponding to the data to be written based on the preset cache block size and the data location information, and to locate or allocate the corresponding target cache block based on the cache block identifier, and to write the data to be written into the target cache block.

[0059] The parallel flushing determination module is used to determine the target parallel flushing unit for processing the target cache block from multiple parallel flushing units based on the cache block identifier;

[0060] The scheduling queue determination module is used to determine the target scheduling queue from multiple scheduling queues corresponding to the target parallel flushing unit based on the object identifier, and associate the target cache block with the target scheduling queue.

[0061] The polling flushing module is used to schedule the multiple scheduling queues according to a preset polling order by the target parallel flushing unit. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions in any scheduling queue, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data amount condition, or the residence time of dirty data in the cache block to be flushed reaching a preset time condition. After the target parallel flushing unit performs flushing on one cache block to be flushed in any scheduling queue, it switches to the next scheduling queue for scheduling.

[0062] The cache block reclamation module is used to reclaim cache blocks that have been flushed and meet preset reclamation conditions, so that the reclaimed cache blocks can be used for caching subsequent data writes.

[0063] Compared with the prior art, this application has at least the following beneficial effects:

[0064] Based on further analysis and research of existing technical problems, this application recognizes that existing technologies suffer from high cache data write latency, poor latency stability between different write objects, and difficulty in balancing low latency and high bandwidth in small data block parallel write cache scheduling of file storage systems. By receiving the data to be written from the write object and determining its data location information and object identifier, the application first assigns the data to be written to the corresponding target cache block based on the data location information and the preset cache block size, and then writes it to that target cache block, thus giving small-granularity write data a definite cache carrying location. Furthermore, based on the cache block identifier, the application allocates the target cache block to the corresponding target parallel flushing unit, allowing different cache blocks to be flushed in a distributed manner, thereby improving the parallelism of writing cache data to the backend storage system. Simultaneously, based on the object identifier... This invention associates target cache blocks with target scheduling queues in a target parallel flushing unit. The target parallel flushing unit schedules multiple queues according to a preset polling order. Flushing is triggered when the cache block's data volume reaches a preset data volume condition or the dirty data's dwell time reaches a preset time condition, preventing dirty data from remaining in the cache for extended periods while waiting for aggregation. Furthermore, after flushing a cache block in any scheduling queue, the target parallel flushing unit switches to the next queue, preventing a single write object or a single scheduling queue from occupying flushing resources for an extended period, ensuring a more balanced flushing opportunity for cache blocks of different write objects. Finally, cache blocks that have been flushed and meet preset reclamation conditions are reclaimed, allowing cache resources to be reused for subsequent data writes. Therefore, this application can reduce the waiting time for writing cached data to the backend storage system in small data block parallel write scenarios, improve latency stability between different write objects, and maintain high write bandwidth through parallel flushing under low latency requirements, thus solving the problems of high cached data write latency, poor latency stability between different write objects, and the difficulty in balancing low latency and high bandwidth. Attached Figure Description

[0065] Figure 1 A flowchart illustrating a cache scheduling method for a file storage system provided in one embodiment of this application;

[0066] Figure 2 This is a schematic diagram of a cache block allocation algorithm provided in one embodiment of this application;

[0067] Figure 3 This is a schematic diagram of a worker thread scheduling algorithm provided in one embodiment of this application;

[0068] Figure 4 This is a block diagram of the module architecture of a cache scheduling system for a file storage system provided in one embodiment of this application. Detailed Implementation

[0069] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0070] In one embodiment, such as Figure 1 As shown, a cache scheduling method for a file storage system is provided, including the following steps:

[0071] Receive the data to be written to the object, and determine the data location information corresponding to the data to be written and the object identifier of the object to be written;

[0072] Based on the preset cache block size and the data location information, the cache block identifier corresponding to the data to be written is determined, and the corresponding target cache block is located or allocated based on the cache block identifier, and the data to be written is written to the target cache block;

[0073] Based on the cache block identifier, a target parallel flush unit for processing the target cache block is determined from multiple parallel flush units;

[0074] Based on the object identifier, a target scheduling queue is determined from multiple scheduling queues corresponding to the target parallel flushing unit, and the target cache block is associated with the target scheduling queue.

[0075] The target parallel flushing unit schedules the multiple scheduling queues according to a preset polling order. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data amount condition, or the residence time of dirty data in the cache block to be flushed reaching a preset time condition. After performing flushing on one cache block to be flushed in any scheduling queue, the target parallel flushing unit switches to the next scheduling queue for scheduling.

[0076] Reclaim cache blocks that have been flushed and meet the preset reclamation conditions so that the reclaimed cache blocks can be used for caching subsequent data writes.

[0077] In one possible embodiment, a cache scheduling method for a file storage system is provided. This method can be applied to a file storage system. The file storage system may include a front-end write interface, a memory cache management unit, a cache scheduler, and a back-end storage system. The memory cache management unit can maintain cache resources consisting of multiple cache blocks, which are used to temporarily store data to be written to write objects. The cache scheduler is used to flush cache blocks that meet the flushing conditions to the back-end storage system. The write object can be a file, file fragment, object file, or other data write object with continuous data location information. The back-end storage system can be a disk array, a solid-state storage array, a distributed storage node, or other persistent storage device.

[0078] In one possible embodiment, the method includes the following steps:

[0079] S101. Receive the data to be written to the object, and determine the data location information and object identifier of the object to be written.

[0080] The data to be written can be a block of data written by the client to the file storage system. In scenarios involving continuous writing of small data blocks, the amount of data to be written can be less than a preset amount, such as less than 8KB. Data location information can be used to characterize the writing position of the data to be written within the writing object, and may include, for example, a file address offset, an offset within the object, or a logical address offset. The object identifier is used to distinguish different writing objects, and may include, for example, a file name, a file inode number, an object number, a handle identifier, or a combination thereof. By determining the data location information and the object identifier, a basis can be provided for subsequent determination of the cache block identifier and the scheduling queue, respectively.

[0081] S102. Based on the preset cache block size and data location information, determine the cache block identifier corresponding to the data to be written, locate or allocate the corresponding target cache block based on the cache block identifier, and write the data to be written to the target cache block.

[0082] The preset cache block size can be pre-set based on the write performance characteristics of the backend storage system, ensuring that the cache blocks form a data granularity suitable for the backend storage system's processing when flushed to the backend. The cache block identifier identifies the cache block to which the data to be written belongs. In the specific implementation, the cache block to which the data to be written belongs can be determined based on the correspondence between data location information and the preset cache block size. If the cache block has already been allocated, it can be directly located as the target cache block; if the cache block has not yet been allocated, a cache block can be allocated from available free cache resources as the target cache block.

[0083] S103. Based on the cache block identifier, determine the target parallel flush unit for processing the target cache block from multiple parallel flush units.

[0084] The parallel flushing unit can be a worker thread, worker process, asynchronous flushing task, flushing executor, or other execution unit capable of performing cache block flushing processes in parallel. By determining the target parallel flushing unit based on the cache block identifier, different cache blocks can be distributed to different parallel flushing units for processing, thereby avoiding all cache blocks being flushed serially by a single flushing unit.

[0085] S104. Based on the object identifier, determine the target scheduling queue from the multiple scheduling queues corresponding to the target parallel flushing unit, and associate the target cache block with the target scheduling queue.

[0086] The target parallel flushing unit can maintain multiple scheduling queues, each organizing cache blocks corresponding to a type of write object or a group of write objects. The target scheduling queue is determined by the object identifier, allowing cache blocks corresponding to different write objects to be distributed across different scheduling queues, providing a data structure foundation for subsequent round-robin scheduling between different queues. Associating a target cache block with a target scheduling queue can include adding the target cache block to the target scheduling queue, or updating the target cache block's status information, dirty data identifier, write time information, or data volume information when the target cache block is already in the target scheduling queue.

[0087] S105. The target parallel flushing unit schedules multiple scheduling queues according to a preset polling order. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions in any scheduling queue, the data in the cache block to be flushed is flushed to the backend storage system.

[0088] The preset polling order can be based on queue identifier order, circular queue order, scheduling pointer order, or other pre-defined queue traversal order. Preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data volume condition, or the residence time of dirty data in the cache block reaching a preset time condition. The preset data volume condition can include the cache block being full or the amount of valid data in the cache block reaching a set threshold; the preset time condition can include the residence time of dirty data since being written to the target cache block reaching an allowed residence time. By setting both data volume and time conditions simultaneously, larger-granularity flushing can be performed promptly when the cache block is full, or flushing can be performed promptly when the cache block is not full but the waiting time is too long, preventing dirty data from remaining in the cache for extended periods.

[0089] S106. After the target parallel flushing unit performs flushing on a cache block to be flushed in any scheduling queue, it switches to the next scheduling queue for scheduling.

[0090] In other words, the target parallel flushing unit does not flush multiple cache blocks consecutively in the current scheduling queue. Instead, after completing the flushing of one cache block, it switches to the next scheduling queue according to a preset polling order. This avoids a single write object or scheduling queue from occupying the target parallel flushing unit for an extended period due to a large number of cache blocks, allowing cache blocks corresponding to other write objects to also have flushing opportunities, thereby improving scheduling fairness and latency stability among multiple write objects.

[0091] S107. Reclaim cache blocks that have been flushed and meet the preset reclamation conditions so that the reclaimed cache blocks can be used for caching subsequent data writes.

[0092] Cache blocks that have been flushed can be removed from the corresponding scheduling queue and reused as allocable cache resources after meeting preset reclamation conditions. The preset reclamation conditions may be related to factors such as the flushing completion status of the cache block, the retention time of the cache block after flushing, the current amount of free cache resources, and the total amount of cache resources.

[0093] In the above embodiments, the data to be written is first mapped to the corresponding cache block according to the data location information, then allocated to the corresponding parallel flushing unit according to the cache block identifier, and further associated with the corresponding scheduling queue according to the object identifier of the writing object. This allows the cache blocks to be processed in a distributed manner among the parallel flushing units, while forming a pollable and schedulable data organization method at the dimension of the writing object. During the scheduling process, flushing is performed when the cache block reaches the data volume condition or time condition. After flushing one cache block in one scheduling queue, the system switches to the next scheduling queue. This reduces the time that dirty data stays in the cache, reduces the visible latency after writing small data blocks, and avoids a single writing object occupying flushing resources for a long time, thus improving the latency stability between multiple writing objects. After the cache block that has been flushed is reclaimed, it can continue to be used for caching subsequent written data, which is beneficial for maintaining the cyclical use of cache resources and backend flushing bandwidth under low latency constraints.

[0094] In this embodiment, determining the cache block identifier corresponding to the data to be written based on the preset cache block size and the data location information, and locating or allocating the corresponding target cache block based on the cache block identifier, includes:

[0095] Based on the data location information and the preset cache block size, block partitioning calculation is performed to obtain the cache block identifier corresponding to the data to be written;

[0096] Based on the cache block identifier, query the allocated cache block record to obtain the cache block location result;

[0097] If the cache block location result indicates the existence of an allocated cache block, the allocated cache block is identified as the target cache block;

[0098] If the cache block location result indicates that no allocated cache block exists, a cache block is allocated from the set of free cache resources, and the allocated cache block is associated with the cache block identifier to obtain the target cache block.

[0099] In this embodiment, determining the target parallel flush unit for processing the target cache block from multiple parallel flush units based on the cache block identifier includes:

[0100] Obtain the number of units corresponding to the plurality of parallel write units;

[0101] Based on the cache block identifier and the number of units, a mapping calculation is performed to obtain the flush unit identifier;

[0102] Based on the brushing unit identifier, the target parallel brushing unit is determined from the plurality of parallel brushing units;

[0103] The target cache block is associated with the target parallel flushing unit so that the target cache block is flushed by the target parallel flushing unit.

[0104] In this embodiment, determining the target scheduling queue from multiple scheduling queues corresponding to the target parallel writing unit based on the object identifier includes:

[0105] Obtain the queue identifiers of multiple scheduling queues corresponding to the target parallel writing unit;

[0106] The object identifier is mapped to obtain object mapping information;

[0107] Based on the object mapping information and the queue identifiers of the multiple scheduling queues, determine the target queue identifier corresponding to the written object;

[0108] The scheduling queue corresponding to the target queue identifier is determined as the target scheduling queue.

[0109] In this embodiment, allocating cache blocks from the set of free cache resources includes:

[0110] Get the number of objects currently being written and the total amount of allocable cache resources;

[0111] Based on the current number of write objects and the total amount of allocable cache resources, determine the object cache quota corresponding to each write object;

[0112] Obtain the amount of cache resources already occupied by the written object, and based on the amount of cache resources already occupied and the object cache quota, obtain the quota determination result;

[0113] If the quota determination result indicates that the write object meets the cache allocation conditions and there is a free cache block in the free cache resource set, the target cache block is allocated from the free cache resource set.

[0114] If the quota determination result indicates that the write object does not meet the cache allocation conditions, or if there is no free cache block in the free cache resource set, a waiting allocation record is generated and the waiting allocation record is added to the waiting queue.

[0115] In this embodiment, if any scheduling queue contains a cache block to be flushed that meets the preset flushing conditions, then flushing the data in the cache block to the backend storage system includes:

[0116] Obtain the amount of data written and the time of dirty data generation for any candidate cache block in the scheduling queue;

[0117] Based on the amount of data already written and the preset data amount threshold, the data amount determination result is obtained;

[0118] Based on the dirty data generation time and the preset dwell time threshold, the dwell time determination result is obtained;

[0119] If the data volume determination result indicates that the data volume of the candidate cache block reaches the preset data volume condition, or if the dwell time determination result indicates that the dirty data dwell time in the candidate cache block reaches the preset time condition, the candidate cache block is determined as the cache block to be flushed.

[0120] The data in the cache block to be written is written to the backend storage system, and a write completion status corresponding to the cache block to be written is generated.

[0121] In this embodiment, writing the data in the cache block to be written to the backend storage system includes:

[0122] Obtain the current scheduling pointer corresponding to the target parallel flushing unit;

[0123] Based on the current scheduling pointer, determine the current scheduling queue from the plurality of scheduling queues;

[0124] A cache block to be flushed is determined from the current scheduling queue that meets the preset flushing conditions, and flushing processing is performed on the cache block to be flushed to obtain the scheduling result.

[0125] The current scheduling pointer is updated based on the current scheduling result to obtain the next scheduling pointer;

[0126] Based on the next scheduling pointer, switch to the next scheduling queue to schedule the next scheduling queue.

[0127] In this embodiment, the step of reclaiming cache blocks that have been flushed and meet preset reclamation conditions includes:

[0128] Get the flush completion status and cache resource status information of the candidate reclaimed cache blocks that have been flushed;

[0129] Based on the amount of free cache resources and the total amount of cache resources represented by the cache resource status information, the allowable retention time corresponding to the candidate reclaimed cache block is determined;

[0130] Based on the flush completion status and the allowed retention time, the recycling determination result corresponding to the candidate recycled cache block is obtained;

[0131] If the recycling determination result indicates that the candidate recycled cache block meets the preset recycling conditions, the candidate recycled cache block is removed from the corresponding scheduling queue and added to the idle cache resource set.

[0132] In this embodiment, after removing the candidate reclaimed cache block from the corresponding scheduling queue and adding it to the free cache resource set, the method further includes:

[0133] Update the status of the idle cache resources corresponding to the set of idle cache resources to obtain the updated status of the idle cache resources.

[0134] Based on the updated status of the idle cache resources, query the waiting queue to obtain the write tasks to be woken up.

[0135] Based on the write object and cache allocation conditions corresponding to the write task to be woken up, a wake-up command is generated;

[0136] The wake-up command triggers the write task to be woken up to re-execute the cache block allocation process.

[0137] In one embodiment, a fair and low-latency cache scheduling strategy is provided. In this embodiment, the cache is a data block allocated in memory for temporarily storing file data. The cache scheduling strategy selects an appropriate cache block and flushes it to the backend storage system.

[0138] A batch of files is written sequentially in parallel on a client side, with each write consisting of data blocks smaller than 8KB. The latency 't' for all file data blocks must be controlled within milliseconds. At time t1, the data block is sent to the cache, and the cache scheduling strategy selects to flush the cache to the backend storage system. The data block is successfully read from another client at time t2, with a latency t = t2 - t1. The latency of all data blocks is recorded, and the number of data blocks meeting the latency requirement is counted. The latency compliance rate must be higher than 99%. High bandwidth must also be guaranteed while ensuring low latency.

[0139] In the field of file storage, writing small data blocks can achieve high IOPS and low latency, but with very low bandwidth. Writing large data blocks can achieve high bandwidth, but with very high latency.

[0140] To achieve high bandwidth for small data blocks, a caching mechanism is needed to aggregate small data blocks into larger ones. To ensure low latency, high bandwidth, and a guaranteed latency compliance rate, a new caching scheduling strategy is also required.

[0141] The solution in this embodiment is as follows:

[0142] Files are divided according to cache block size, which depends on the backend storage system and must maximize bandwidth.

[0143] To reduce latency for individual files, file data remains in the cache block for a limited time, depending on the maximum allowed latency. If the cache is full within that time period, the data is immediately flushed.

[0144] To ensure high bandwidth, when flushing the cache of a single file, serial flushing is not allowed; parallel cache flushing is required. Since sequential writes are common in this application, consecutive cache blocks of the same file are distributed across different threads for flushing.

[0145] To ensure low latency for all file writes, it is necessary to further hash cache blocks from different files into different linked lists. During scheduling, all linked lists should be rotated, with each linked list being scheduled only once in one rotation.

[0146] The capacity of the cache pool depends on the maximum number of concurrent file writes, the maximum cache dwell time, and the maximum flush bandwidth.

[0147] To avoid increased latency due to waiting for free cache blocks, the maximum cache that can be allocated to each file is limited, and this value is dynamically adjusted based on the number of files currently being written.

[0148] Allocated cache blocks need to be continuously reclaimed to ensure that latency is not affected by a lack of free cache blocks at any time.

[0149] The key components and processes in this embodiment include:

[0150] A cache pool is a set of cache blocks pre-allocated from memory, and the size of each cache block is fixed.

[0151] If the maximum number of concurrent file writes is set to m, the maximum cache dwell time is t seconds, and the maximum cache flush bandwidth is bMB / s, then the total cache pool size = m * t * b MB. The cache pool maintains a linked list of free cache blocks.

[0152] The cache scheduler consists of a pool of worker threads. Each worker thread maintains a linked list of allocated cache blocks, the number of which equals the maximum number of concurrent file writes. The worker threads execute a scheduling algorithm to flush cache blocks to the backend storage system and reclaim flushed cache blocks into the cache pool's free list. The worker thread pool contains n worker threads. More worker threads result in better concurrency and higher bandwidth.

[0153] Allocation algorithm for allocated cache blocks: After a cache block is allocated, it is assigned a unique ID. The ID is determined by the offset of the written file data. ID = offset / cache block size.

[0154] Calculate the working thread of the cache block, where thread ID = cache block ID mod n.

[0155] Locate the allocated cache block linked list maintained by the corresponding worker thread, where the linked list ID is hash(filename, file inode number).

[0156] Traverse the linked list of allocated cache blocks and locate the cache block based on the cache block ID.

[0157] The cache block allocation algorithm, and its flowchart are as follows: Figure 2 As shown, the cache block is located according to the allocated cache block location algorithm. If the location is successful, the cache block is returned directly.

[0158] If location fails, the free cache block list is checked. If the list is empty, or if the list is not empty but the cache allocated to the file has exceeded the quota, the file enters the waiting queue and will be re-allocated upon being woken up. File cache quota = total cache / current number of files being written.

[0159] Remove the allocated cache block from the free cache block list and add it to the allocated cache block list.

[0160] Worker thread scheduling algorithm, algorithm flowchart as follows Figure 3 As shown, the linked list of allocated cache blocks maintained by this worker thread is traversed sequentially.

[0161] Locate the dirty cache block in this linked list. If the dirty cache block is full, immediately initiate the flushing process and move this cache block to the end of the linked list. If the dirty cache block is not full, but its dwell time exceeds the maximum allowed time, flush this cache block. The maximum dwell time for dirty data = total allowed latency * 20%.

[0162] The cache blocks are flushed to the backend storage system according to the principle of fairness. After each cache block in the linked list is flushed, it is moved to the next linked list to ensure that all file caches are flushed fairly.

[0163] Traverse all cache blocks in this linked list. If a cache block has been flushed and its allowed dwell time has exceeded, remove it and add it to the free cache block linked list of the cache pool. The calculation formula is: Dwell time = t * number of free cache blocks / total number of cache blocks in the buffer pool, where t is the maximum dwell time. The dwell time depends on the current number of free cache blocks and the total number of cache blocks. The more free cache blocks there are, the closer the dwell time is to the maximum dwell time.

[0164] After reclaiming a cache block, the waiting queue needs to be woken up to ensure that other write processes can be allocated a free cache block immediately.

[0165] This embodiment does not aggregate as much data as possible. Dirty data is refreshed in milliseconds to ensure low latency. While ensuring low latency, concurrent flushing is used to maintain high bandwidth and all write file cache blocks are fairly scheduled to maintain low latency stability.

[0166] In one embodiment, such as Figure 4 As shown, a cache scheduling system for a file storage system is provided, including the following modules:

[0167] The data receiving module is used to receive the data to be written to the object, and to determine the data location information corresponding to the data to be written and the object identifier of the object to be written.

[0168] The cache block processing module is used to determine the cache block identifier corresponding to the data to be written based on the preset cache block size and the data location information, and to locate or allocate the corresponding target cache block based on the cache block identifier, and to write the data to be written into the target cache block.

[0169] The parallel flushing determination module is used to determine the target parallel flushing unit for processing the target cache block from multiple parallel flushing units based on the cache block identifier;

[0170] The scheduling queue determination module is used to determine the target scheduling queue from multiple scheduling queues corresponding to the target parallel flushing unit based on the object identifier, and associate the target cache block with the target scheduling queue.

[0171] The polling flushing module is used to schedule the multiple scheduling queues according to a preset polling order by the target parallel flushing unit. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions in any scheduling queue, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data amount condition, or the residence time of dirty data in the cache block to be flushed reaching a preset time condition. After the target parallel flushing unit performs flushing on one cache block to be flushed in any scheduling queue, it switches to the next scheduling queue for scheduling.

[0172] The cache block reclamation module is used to reclaim cache blocks that have been flushed and meet preset reclamation conditions, so that the reclaimed cache blocks can be used for caching subsequent data writes.

[0173] The specific implementation details of each module can be found in the above description of the cache scheduling method for file storage systems, and will not be repeated here.

[0174] In one possible embodiment, a cache scheduling system for a file storage system is provided. This cache scheduling system can be deployed in a file storage server, a distributed storage node, a network file system node, or other electronic devices with file write caching capabilities. The cache scheduling system may include a data receiving module, a cache block processing module, a parallel flushing determination module, a scheduling queue determination module, a round-robin flushing module, and a cache block reclamation module.

[0175] The data receiving module receives the data to be written to the write object and determines the data location information corresponding to the data to be written and the object identifier of the write object. The data location information may include the address offset of the data to be written within the write object, and the object identifier may include the filename and file inode number. The data receiving module can parse the data to be written, the data location information, and the object identifier from the client's write request and send them to the cache block processing module.

[0176] The cache block processing module determines the cache block identifier corresponding to the data to be written based on the preset cache block size and data location information. It then locates or allocates the corresponding target cache block based on the cache block identifier and writes the data to be written to the target cache block. The cache block processing module can maintain a cache resource set, a free cache resource set, and a record of allocated cache blocks. For existing cache blocks, the module can directly locate the target cache block; for non-existent cache blocks, the module can allocate the target cache block from the free cache resource set and associate the target cache block with the cache block identifier.

[0177] The parallel flush determination module is used to identify the target parallel flush unit from multiple parallel flush units to process the target cache block, based on the cache block identifier. These multiple parallel flush units can form a set of worker threads or a set of asynchronous flush tasks. The parallel flush determination module can determine the target parallel flush unit according to the mapping relationship between the cache block identifier and the number of parallel flush units, enabling different cache blocks to be distributed across multiple parallel flush units for processing.

[0178] The scheduling queue determination module is used to determine the target scheduling queue from multiple scheduling queues corresponding to the target parallel flushing unit based on the object identifier, and associate the target cache block with the target scheduling queue. The scheduling queue determination module can perform mapping processing on the object identifier to determine the corresponding target scheduling queue. After the target cache block is associated with the target scheduling queue, the polling flushing module can schedule the cache block according to the queue dimension.

[0179] The polling flushing module schedules multiple scheduling queues according to a preset polling order through the target parallel flushing unit. When polling to any scheduling queue, if a cache block to be flushed exists in any queue that meets preset flushing conditions, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data volume condition, or the residence time of dirty data in the cache block to be flushed reaching a preset time condition. The polling flushing module also switches to the next scheduling queue after the target parallel flushing unit has flushed a cache block to be flushed in any scheduling queue, to achieve fair flushing between different scheduling queues.

[0180] The cache block reclamation module is used to reclaim cache blocks that have been flushed and meet preset reclamation conditions, so that the reclaimed cache blocks can be used for caching subsequent data writes. The cache block reclamation module can determine whether a cache block meets the preset reclamation conditions based on the flush completion status, the amount of free cache resources, and the total amount of cache resources. If the conditions are met, the cache block is removed from the corresponding scheduling queue and added to the free cache resource set. Furthermore, the cache block reclamation module can also update the free cache resource status after reclamation and trigger the write tasks in the waiting queue to re-execute the cache block allocation process.

[0181] Through the above embodiments, the cache scheduling system can complete the parsing of written data by the data receiving module, complete the location or allocation of cache blocks by the cache block processing module, complete the scheduling organization of parallel dimension and write object dimension by the parallel flushing determination module and the scheduling queue determination module respectively, realize the flushing triggered by full or timeout by the polling flushing module and the single block polling switch between queues by the polling flushing module, and realize the dynamic reclamation and subsequent reuse of flushed cache blocks by the cache block recycling module. The modules work together to reduce the latency of writing cached data to the backend storage system in the scenario of parallel writing of small data blocks, improve the latency stability between different write objects, and maintain a high flushing concurrency and backend write bandwidth under low latency constraints.

[0182] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

Claims

1. A cache scheduling method for a file storage system, characterized in that, The method includes: Receive the data to be written to the object, and determine the data location information corresponding to the data to be written and the object identifier of the object to be written; Based on the preset cache block size and the data location information, the cache block identifier corresponding to the data to be written is determined, and the corresponding target cache block is located or allocated based on the cache block identifier, and the data to be written is written to the target cache block; Based on the cache block identifier, a target parallel flush unit for processing the target cache block is determined from multiple parallel flush units; Based on the object identifier, a target scheduling queue is determined from multiple scheduling queues corresponding to the target parallel flushing unit, and the target cache block is associated with the target scheduling queue. The target parallel flushing unit schedules the multiple scheduling queues according to a preset polling order. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions in any scheduling queue, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data amount condition, or the dirty data in the cache block to be flushed staying for a preset time condition. Wherein, after the target parallel flushing unit performs flushing on a cache block to be flushed in any of the scheduling queues, it switches to the next scheduling queue for scheduling. Reclaim cache blocks that have been flushed and meet the preset reclamation conditions so that the reclaimed cache blocks can be used for caching subsequent data writes.

2. The method according to claim 1, characterized in that, The step of determining the cache block identifier corresponding to the data to be written based on the preset cache block size and the data location information, and locating or allocating the corresponding target cache block based on the cache block identifier, includes: Based on the data location information and the preset cache block size, block partitioning calculation is performed to obtain the cache block identifier corresponding to the data to be written; Based on the cache block identifier, query the allocated cache block record to obtain the cache block location result; If the cache block location result indicates the existence of an allocated cache block, the allocated cache block is identified as the target cache block; If the cache block location result indicates that no allocated cache block exists, a cache block is allocated from the set of free cache resources, and the allocated cache block is associated with the cache block identifier to obtain the target cache block.

3. The method according to claim 2, characterized in that, The step of determining the target parallel flush unit for processing the target cache block from multiple parallel flush units based on the cache block identifier includes: Obtain the number of units corresponding to the plurality of parallel write units; Based on the cache block identifier and the number of units, a mapping calculation is performed to obtain the flush unit identifier; Based on the brushing unit identifier, the target parallel brushing unit is determined from the plurality of parallel brushing units; The target cache block is associated with the target parallel flushing unit so that the target cache block is flushed by the target parallel flushing unit.

4. The method according to claim 1, characterized in that, The step of determining the target scheduling queue from multiple scheduling queues corresponding to the target parallel brush unit based on the object identifier includes: Obtain the queue identifiers of multiple scheduling queues corresponding to the target parallel writing unit; The object identifier is mapped to obtain object mapping information; Based on the object mapping information and the queue identifiers of the multiple scheduling queues, determine the target queue identifier corresponding to the written object; The scheduling queue corresponding to the target queue identifier is determined as the target scheduling queue.

5. The method according to claim 2, characterized in that, The allocation of cache blocks from the set of free cache resources includes: Get the number of objects currently being written and the total amount of allocable cache resources; Based on the current number of write objects and the total amount of allocable cache resources, determine the object cache quota corresponding to each write object; Obtain the amount of cache resources already occupied by the written object, and based on the amount of cache resources already occupied and the object cache quota, obtain the quota determination result; If the quota determination result indicates that the write object meets the cache allocation conditions and there is a free cache block in the free cache resource set, the target cache block is allocated from the free cache resource set. If the quota determination result indicates that the write object does not meet the cache allocation conditions, or if there is no free cache block in the free cache resource set, a waiting allocation record is generated and the waiting allocation record is added to the waiting queue.

6. The method according to claim 1, characterized in that, If any of the scheduling queues contains a cache block that meets the preset flushing conditions, then the data in the cache block to be flushed is flushed to the backend storage system, including: Obtain the amount of data written and the time of dirty data generation for any candidate cache block in the scheduling queue; Based on the amount of data already written and the preset data amount threshold, the data amount determination result is obtained; Based on the dirty data generation time and the preset dwell time threshold, the dwell time determination result is obtained; If the data volume determination result indicates that the data volume of the candidate cache block reaches the preset data volume condition, or if the dwell time determination result indicates that the dirty data dwell time in the candidate cache block reaches the preset time condition, the candidate cache block is determined as the cache block to be flushed. The data in the cache block to be written is written to the backend storage system, and a write completion status corresponding to the cache block to be written is generated.

7. The method according to claim 6, characterized in that, The step of writing the data in the cache block to be written to the backend storage system includes: Obtain the current scheduling pointer corresponding to the target parallel flushing unit; Based on the current scheduling pointer, determine the current scheduling queue from the plurality of scheduling queues; A cache block to be flushed is determined from the current scheduling queue that meets the preset flushing conditions, and flushing processing is performed on the cache block to be flushed to obtain the scheduling result. The current scheduling pointer is updated based on the current scheduling result to obtain the next scheduling pointer; Based on the next scheduling pointer, switch to the next scheduling queue to schedule the next scheduling queue.

8. The method according to claim 1, characterized in that, The process of reclaiming cache blocks that have been flushed and meet preset reclamation conditions includes: Get the flush completion status and cache resource status information of the candidate reclaimed cache blocks that have been flushed; Based on the amount of free cache resources and the total amount of cache resources represented by the cache resource status information, the allowable retention time corresponding to the candidate reclaimed cache block is determined; Based on the flush completion status and the allowed retention time, the recycling determination result corresponding to the candidate recycled cache block is obtained; If the recycling determination result indicates that the candidate recycled cache block meets the preset recycling conditions, the candidate recycled cache block is removed from the corresponding scheduling queue and added to the idle cache resource set.

9. The method according to claim 8, characterized in that, After removing the candidate reclaimed cache block from the corresponding scheduling queue and adding it to the set of idle cache resources, the method further includes: Update the status of the idle cache resources corresponding to the set of idle cache resources to obtain the updated status of the idle cache resources. Based on the updated status of the idle cache resources, query the waiting queue to obtain the write tasks to be woken up. Based on the write object and cache allocation conditions corresponding to the write task to be woken up, a wake-up command is generated; The wake-up command triggers the write task to be woken up to re-execute the cache block allocation process.

10. A cache scheduling system for a file storage system, characterized in that, The system includes: The data receiving module is used to receive the data to be written to the object, and to determine the data location information corresponding to the data to be written and the object identifier of the object to be written. The cache block processing module is used to determine the cache block identifier corresponding to the data to be written based on the preset cache block size and the data location information, and to locate or allocate the corresponding target cache block based on the cache block identifier, and to write the data to be written into the target cache block. The parallel flushing determination module is used to determine the target parallel flushing unit for processing the target cache block from multiple parallel flushing units based on the cache block identifier; The scheduling queue determination module is used to determine the target scheduling queue from multiple scheduling queues corresponding to the target parallel flushing unit based on the object identifier, and associate the target cache block with the target scheduling queue. The polling flushing module is used to schedule the multiple scheduling queues according to a preset polling order by the target parallel flushing unit. When polling to any scheduling queue, if there is a cache block to be flushed that meets the preset flushing conditions in any scheduling queue, the data in the cache block to be flushed is flushed to the backend storage system. The preset flushing conditions include the amount of data in the cache block to be flushed reaching a preset data amount condition, or the residence time of dirty data in the cache block to be flushed reaching a preset time condition. After the target parallel flushing unit performs flushing on one cache block to be flushed in any scheduling queue, it switches to the next scheduling queue for scheduling. The cache block reclamation module is used to reclaim cache blocks that have been flushed and meet preset reclamation conditions, so that the reclaimed cache blocks can be used for caching subsequent data writes.