Data processing method of cluster file system and electronic device
By distributing data processing requests across multiple nodes and utilizing thread pools in the clustered file system, the problem of slow response speed in the clustered file system is solved, enabling faster data storage and deletion operations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2025-09-29
- Publication Date
- 2026-05-29
AI Technical Summary
The slow response time of the cluster file system when storing or deleting data is mainly due to communication delays caused by frequent competition for resources such as global locks between nodes.
By managing multiple storage spaces in the cluster file system through multiple nodes, data processing requests are distributed to each node for independent processing, and a thread is determined from the node's thread pool for processing based on the type and identifier of the data processing request.
It reduces communication latency between nodes, improves the response speed of the cluster file system, reduces lock contention and communication resource consumption, and solves the problems of queuing and high communication latency in data processing requests.
Smart Images

Figure CN120892394B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to data processing methods and electronic devices for clustered file systems. Background Technology
[0002] In recent years, users have had a need to manage large-scale storage space in data processing scenarios, and the scale of the storage space they manage far exceeds the capacity of the local file system.
[0003] Currently, users can use clustered file systems for data processing to meet the needs of large-scale storage space management. However, during use, the response speed of the clustered file system is slow when users perform operations such as storing files, adding content to stored files, deleting files, or deleting parts of files. Summary of the Invention
[0004] This application provides a data processing method and electronic device for a clustered file system, in order to at least solve the problem of slow response speed of clustered file systems in related technologies.
[0005] This application provides a data processing method for a clustered file system, including:
[0006] The system receives data processing requests, which are then processed by the first node among multiple nodes in the cluster file system. These multiple nodes are used to manage multiple storage spaces within the cluster file system.
[0007] Determine the first identifier and the type of data processing request in the data processing request. The first identifier is the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space.
[0008] Based on the type of data processing request and the first identifier, a first thread is determined from the multiple thread pools of the first node. The first thread is used to store data in the storage space or delete data in the storage space.
[0009] The data processing request is processed according to the first thread.
[0010] This application also provides a data processing apparatus for a clustered file system, comprising: a receiving module, a first determining module, a second determining module, and a processing module, wherein...
[0011] The receiving module is used to receive data processing requests. The data processing requests are processed by the first node among multiple nodes in the cluster file system. Multiple nodes are used to manage multiple storage spaces in the cluster file system.
[0012] The first determining module is used to determine the first identifier and the type of data processing request in the data processing request. The first identifier is the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space.
[0013] The second determining module is used to determine the first thread from multiple thread pools of the first node based on the type of data processing request and the first identifier. The first thread is used to store data in the storage space or delete data in the storage space.
[0014] The processing module is used to process data processing requests based on the first thread.
[0015] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the data processing method of any of the above-described clustered file system.
[0016] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described cluster file system data processing methods.
[0017] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described cluster file system data processing methods.
[0018] This application enables the management of multiple storage spaces within a cluster file system through multiple nodes, allowing data processing requests to be distributed across each node for independent processing. This reduces communication latency caused by frequent contention for resources such as global locks between nodes. Therefore, it solves the problem of slow response speed of cluster file systems when users store or delete data in related technologies, achieving the technical effect of improving the response speed of cluster file systems. Attached Figure Description
[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 A flowchart illustrating the data processing method of the cluster file system provided in this application embodiment;
[0021] Figure 2 A flowchart illustrating a method for processing data processing requests provided in an embodiment of this application;
[0022] Figure 3 A schematic diagram illustrating a method for managing a first area as provided in an embodiment of this application;
[0023] Figure 4 A flowchart illustrating the determination of a first thread is provided for an embodiment of this application;
[0024] Figure 5 A schematic diagram illustrating a method for managing storage space in a clustered file system, provided in an embodiment of this application;
[0025] Figure 6 This is a schematic diagram of the data processing method for a cluster file system provided in an embodiment of this application;
[0026] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, other embodiments obtained by those of ordinary skill in the art without creative effort are all within the protection scope of this application.
[0028] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0029] Definitions:
[0030] Clustered file system: A clustered file system is used to consolidate the storage resources of multiple electronic devices and manage the consolidated large-scale storage space. A clustered file system allows multiple electronic devices (nodes) to share the same storage resource.
[0031] Data blocks: Data blocks divide the large-scale storage space managed by cluster nodes in the cluster file system into multiple independent subspaces. Each data block is only used to allocate or release space addresses within its own scope. A data block is a fixed-size contiguous disk block formed after dividing the large-scale storage space.
[0032] Data block set: The data block set is used to manage data blocks. The data block set is a resource cluster composed of multiple independent data blocks.
[0033] Allocation Tree: The allocation tree is used to record the free space addresses in the data block. The allocation tree is a tree structure stored in the memory of the data block in the cluster file system. For example, the structure of the allocation tree can be a B+ tree structure, etc. The free space address can be 1 bit (corresponding to the smallest allocatable address unit) or multiple bits (corresponding to an address segment composed of multiple consecutive smallest allocatable units).
[0034] Bitmap: The bitmap is used to record the usage status of each address space in the data block. The structure of the bitmap is a binary bit sequence structure. Each binary bit corresponds to the smallest allocatable address unit in the data block. The usage status of each address unit can be represented by a preset binary value. For example, the binary value corresponding to the address unit is 1, indicating that the address unit is in an idle state; the binary value corresponding to the address unit is 0, indicating that the address unit has been occupied.
[0035] Allocation Log: The allocation log is used to record information related to the allocation of space addresses to data, including the range of allocated space addresses (e.g., the offset and length of the data within the data block), the timestamp corresponding to the allocation of the space address to the data, and the identifier of the thread (first thread) used to allocate the space address.
[0036] Release Log: The release log is used to record information related to the release of space addresses, including the range of space addresses released and the timestamp corresponding to the released space addresses.
[0037] In recent years, users have had a need to manage large-scale storage space in data processing scenarios. For example, the business data accumulated by enterprises on a daily basis (such as order records, customer information, etc.) needs to be backed up for a long time. As time goes by, the volume of business data can reach the level of terabytes (TB) or petabytes (PB). The scale of storage space managed by users far exceeds the capacity of the local file system.
[0038] Currently, users can use clustered file systems for data processing to meet the needs of large-scale storage space management. However, during use, the response speed of the clustered file system is slow when users perform operations such as storing files, adding content to stored files, deleting files, or deleting parts of files.
[0039] To address the aforementioned issues, in this embodiment, a data processing request is received, and the data processing request is processed by a first node among multiple nodes in a cluster file system. These multiple nodes manage multiple storage spaces within the cluster file system. A first identifier and a type of data processing request are determined in the data processing request. The first identifier is either the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space. Based on the type of the data processing request and the first identifier, a first thread is determined from multiple thread pools on the first node. The first thread is used to store data in the storage space or delete data in the storage space. The data processing request is then processed according to the first thread.
[0040] In the above method, by managing multiple storage spaces in the cluster file system through multiple nodes, data processing requests can be distributed to each node for independent processing. This can reduce communication latency caused by frequent contention for resources such as global locks between nodes, thereby speeding up the response speed of the cluster file system.
[0041] Furthermore, by determining the first thread for processing data processing requests based on the type of the data processing request and the first identifier, data processing requests for the same file can be handled by the same thread. This can improve the utilization rate of file metadata caching and reduce the probability that subsequent requests will need to reload metadata due to file metadata being cached separately by different threads, thereby speeding up the response speed of the cluster file system.
[0042] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0043] Figure 1 A flowchart illustrating the data processing method of the cluster file system provided in this application embodiment is shown below. Figure 1 As shown, embodiments of this application provide a data processing method for a clustered file system. The method is described in detail below:
[0044] S101. Receive a data processing request. The data processing request is processed by the first node among multiple nodes in the cluster file system. Multiple nodes are used to manage multiple storage spaces in the cluster file system.
[0045] The execution entity in this application embodiment can be an electronic device or a data processing device for a clustered file system installed in an electronic device. The data processing device for the clustered file system can be implemented in software or in a combination of software and hardware.
[0046] In one possible implementation, the data processing request could be, for example, storing a file, adding new content to a file, deleting a file, or deleting part of a file.
[0047] In one possible implementation, there is a correspondence between data processing requests and nodes. In this embodiment, the data processing request is a request sent by the client to the first node. Therefore, when the first node receives the data processing request, the first node processes the data processing request.
[0048] The clients include, but are not limited to: private clients, libraries (library, lib), etc.
[0049] In one possible implementation, multiple nodes can manage multiple different storage spaces in the cluster file system. For example, node A manages storage space A in the cluster file system, and node B manages storage space B in the cluster file system. When node A receives a data processing request (a request to store a file), node A stores the file in storage space A. When node B receives a data processing request (a request to delete a file), node B determines the address of the file in storage space B and deletes the file.
[0050] S102. Determine the first identifier and the type of data processing request in the data processing request. The first identifier is the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space.
[0051] In one possible implementation, the first identifier can be the identifier of the file to be stored, the identifier of the file to be deleted, the identifier of the file corresponding to the data to be stored in the storage space, or the identifier of the file corresponding to the data to be deleted in the storage space. The file format includes, but is not limited to: comma-separated values (CSV) format, JavaScript object notation (JSON) format, text file (TXT) format, and log file (LOG) format.
[0052] For example, if the data processing request is to store file A, then the first identifier in the data processing request is the identifier of file A; if the data processing request is to store the content of the second and third lines in file A (the content of the second and third lines in file A is the content added by the user), then the first identifier in the data processing request is the identifier of file A.
[0053] In one possible implementation, the first identifier can be an integer, and the first identifier can support mathematical modular division operations. For example, the first identifier can be 101.
[0054] In one possible implementation, the type of data processing request may include storing data (including storing files) and deleting data (including deleting files).
[0055] S103. Based on the type of data processing request and the first identifier, determine the first thread from the multiple thread pools of the first node. The first thread is used to store data in the storage space or delete data in the storage space.
[0056] In one possible implementation, a thread pool can be used to manage multiple threads.
[0057] In one possible implementation, based on the type of data processing request and the first identifier, the first thread is determined from multiple thread pools of the first node. This allows data of the same file to be stored or deleted by the same thread, which can improve the utilization rate of file metadata caching. Furthermore, it can reduce the probability that subsequent requests need to reload metadata due to file metadata being cached separately by different threads, thereby speeding up the response speed of the cluster file system.
[0058] S104. Process the data processing request according to the first thread.
[0059] In one possible implementation, if the data processing request is to delete a file or delete part of the content in a file, the first thread can release the space address occupied by the file or the space address occupied by part of the content in the file in the storage space.
[0060] In one possible implementation, if the data processing request is to store a file or new content in a file, the first thread can determine a free address in the storage space and write the file to be stored or the new content to be stored in the file into the determined free address.
[0061] In this embodiment, a data processing request is received, and the data processing request is processed by a first node among multiple nodes of a cluster file system. The multiple nodes are used to manage multiple storage spaces in the cluster file system. A first identifier and a type of data processing request are determined in the data processing request. The first identifier is the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space. Based on the type of data processing request and the first identifier, a first thread is determined from multiple thread pools of the first node. The first thread is used to store data in the storage space or delete data in the storage space. The data processing request is processed according to the first thread.
[0062] In the above method, by managing multiple storage spaces in the cluster file system through multiple nodes, data processing requests can be distributed to each node for independent processing. This reduces communication latency caused by frequent contention for resources such as global locks between nodes, thereby speeding up the response speed of the cluster file system. Furthermore, by reducing lock contention, the consumption of communication resources is also reduced. In addition, the above method can also solve the problem of data processing requests queuing and high communication latency caused by processing data processing requests through a single node in related technologies.
[0063] Based on any of the above embodiments, the following, in conjunction with Figure 2 The method for processing data processing requests based on the first thread ( Figure 1 The embodiment of S104 will be described in detail.
[0064] Figure 2 This application provides a flowchart illustrating a method for processing data processing requests. Please refer to the detailed flowchart for more information. Figure 2 The method may include:
[0065] S201. When the first thread is used to store data in the storage space, the information to be stored corresponding to the data processing request and the first data block corresponding to the first thread are determined, and the information to be stored is processed according to the first thread and the first data block. The first data block is located in the first data block set.
[0066] In one possible implementation, the information to be stored may include, but is not limited to, files and portions of the contents of those files.
[0067] In one possible implementation, the threads used to store data in the storage space correspond to the data blocks in the first data block set; that is, each thread used to store data in the storage space corresponds to a data block in the first data block set, and then according to... Figure 1 As mentioned in the embodiment, data processing requests for the same file (storing the file and adding new content to the stored file, etc.) are processed by the same thread. It can be seen that storing the same file or adding new content to the same file are all allocated space addresses by the same data block. This can improve the continuity of the file in the storage space, reduce disk addressing when reading the file or reading part of the content in the file, and thus improve the pre-read hit rate.
[0068] In some embodiments, the specific implementation of processing the information to be stored according to the first thread and the first data block is as follows:
[0069] Determine the storage address information corresponding to the first data block. The storage address information is used to indicate the free storage address in the first data block. Store the information to be stored based on the first thread, the first data block, and the storage address information.
[0070] In one possible implementation, the storage address information corresponding to the first data block includes the allocation tree corresponding to the first data block and a bitmap in the first data block used to identify the usage status of each space address.
[0071] In one possible implementation, determining the storage address information corresponding to the first data block may include: firstly, locating the free space address range by performing hierarchical indexing on the allocation tree corresponding to the first data block; further, to ensure that each address within the determined space address range is truly in a free state, checking whether the binary sequence corresponding to the space address range in the bitmap is entirely a preset value; if it is entirely a preset value, it indicates that each address within the space address range is in a free state. The size of the free space address range is greater than or equal to the size of the information to be stored, and the free space address range is contiguous.
[0072] In some embodiments, the specific implementation of storing the information to be stored based on the first thread, the first data block, and storage address information is as follows:
[0073] When the storage address information indicates that there is a free storage address in the first data block, the information to be stored is stored in the free storage address of the first data block according to the first thread; when the storage address information indicates that there is no free storage address in the first data block, a third data block with a free storage address is determined in the second data block set, and the first data block in the first data block set is replaced with the third data block, and the information to be stored is stored in the free storage address of the third data block according to the first thread.
[0074] In one possible implementation, data blocks are managed in groups, with the first and third data blocks being data blocks in different groups.
[0075] In one possible implementation, each data block in the second data block set also has its corresponding allocation tree. By locating the allocation tree corresponding to each data block in the second data block set through hierarchical indexing, it can be determined whether there are free storage addresses in the data blocks.
[0076] In one possible implementation, each data block in the second data block set also has its corresponding allocation tree and bitmap. Therefore, the free storage address in the third data block can be determined according to the method described in the above embodiments, which will not be elaborated here.
[0077] S202. When the first thread is used to delete data in the storage space, the second data block containing the information to be deleted corresponding to the data processing request is determined, and the information to be deleted is processed in the second data block according to the first thread.
[0078] In some embodiments, the specific implementation of determining the second data block containing the information to be deleted corresponding to the data processing request is as follows:
[0079] Determine the lengths of multiple data blocks in the storage space, as well as the starting address of the information to be deleted in the storage space; based on the lengths and starting addresses of the multiple data blocks, determine the second data block containing the information to be deleted.
[0080] In one possible implementation, the length of each data block can be the same, and the length of each data block can be preset to a fixed value, for example, 1 gigabyte (GB).
[0081] In one possible implementation, the metadata corresponding to a file can be bound to the file's identifier. The metadata corresponding to a file can be managed by a metadata service (MDS). When the information to be deleted is part of the content of a file, the metadata corresponding to the file can include the starting address of the information to be deleted in the storage space. The first node can first obtain the metadata of the file to which the information to be deleted belongs from the MDS by using the identifier of the file to which the information to be deleted belongs, and then determine the starting address of the information to be deleted in the storage space from the metadata corresponding to the file.
[0082] In one possible implementation, when the information to be deleted is a file, the starting address of the information to be deleted in the storage space can be determined based on the starting address of the file in the storage space. Specifically, the starting address of the file in the storage space can be determined as the starting address of the information to be deleted in the storage space.
[0083] In one possible implementation, the starting address of the information to be deleted in the storage space and the lengths of multiple data blocks can be unified to the same unit of measurement. Then, the quotient of the starting address of the information to be deleted in the storage space and the lengths of the multiple data blocks can be determined. This quotient is the data block number of the second data block containing the information to be deleted in the storage space. For example, if the length of the data block is 1GB (1024MB) and the starting address of the information to be deleted in the storage space is 1074MB, then the data block number of the second data block containing the information to be deleted in the storage space is determined to be 1 (1074 / 1024), indicating that the information to be deleted is in the second data block in the storage space (data block numbers start from 0).
[0084] In some embodiments, the specific implementation of processing the information to be deleted in the second data block according to the first thread is as follows:
[0085] Obtain the timestamp corresponding to the data processing request, and determine the target time based on the timestamp and the preset waiting time; at the target time, delete the information to be deleted in the second data block.
[0086] In one possible implementation, the preset waiting time is, for example, 100 milliseconds (ms), and the target time is the time obtained by adding the timestamp to the waiting time.
[0087] In some embodiments, the specific implementation of processing the information to be deleted in the second data block according to the first thread is further as follows:
[0088] Obtain other data processing requests for data deletion. The timestamps of these other data processing requests indicate times before the target time, and the information to be deleted corresponding to these other data processing requests is located in the second data block. At the target time, delete the information to be deleted corresponding to these other data processing requests in the second data block.
[0089] In one possible implementation, when processing information to be deleted, the corresponding information for that processing can be recorded in the release log.
[0090] In this embodiment of the application, by deleting the information to be deleted corresponding to the data processing request in the second data block at the target time, and at the same time deleting the information to be deleted corresponding to other data processing requests in the second data block, the number of release logs can be reduced and the disk space usage can be reduced.
[0091] In some embodiments, the first node includes a first data block set, a second data block set, a third data block set, and a fourth data block set. The number of data blocks in the first data block set is fixed, while the number of data blocks in the second data block set, the third data block set, and the fourth data block set is not fixed.
[0092] Specifically, when the free storage space in the first data block set and the second data block set is less than or equal to the first threshold, it is determined whether there is a fourth data block in the third data block set, and the fourth data block has free storage space; if there is a fourth data block in the third data block set, the fourth data block is added to the second data block set; if there is no fourth data block in the third data block set, the fourth data block is obtained from the fourth data block set, and the fourth data block in the fourth data block set is added to the second data block set.
[0093] By using multiple data blocks in the first data block set, concurrent data processing requests can be handled, reducing memory footprint.
[0094] In one possible implementation, the number of data blocks in the first data block set is determined by the CPU and memory resources of the cluster file system. The number of data blocks in the first data block set can indicate the number of concurrent space address allocations. All data blocks in the first data block set exist in an allocation tree. After all free space addresses in the allocation tree have been allocated, the data block can be moved to the third data block set.
[0095] In one possible implementation, all data blocks in the second data block set have an allocation tree. When a data block in the first data block set is moved to the third data block set, a data block in the second data block set can be moved to the first data block set. For example, the data block with the smallest free space address in the second data block set can be moved to the first data block set. This allows the storage address of the data block with the smallest space address to be used up as soon as possible, thereby prompting the data block to be quickly migrated to the third data block set after the space is exhausted. This avoids data blocks with low free space remaining in the first data block set for a long time occupying memory resources. At the same time, it can reduce the space fragmentation of data blocks in the first data block set, making it easier for subsequent data processing requests for the same file to obtain contiguous physical space, further reducing disk I / O latency.
[0096] In one possible implementation, none of the data blocks in the third data block set have an allocation tree.
[0097] In one possible implementation, none of the data blocks in the fourth data block set have an allocation tree, and all space addresses in the data blocks in the fourth data block set are in a free state.
[0098] In one possible implementation, the first threshold can be preset, for example, to 10GB.
[0099] In one possible implementation, multiple fourth data blocks can be determined from the third data block set. These multiple fourth data blocks are a preset number of data blocks with the largest amount of free storage space in the third data block set. The multiple fourth data blocks are then added to the second data block set. Next, it is determined whether the free storage space in the first and second data block sets is greater than or equal to a second threshold. If the free storage space in the first and second data block sets is less than the second threshold, then the data blocks in the fourth data block set can be added to the second data block set.
[0100] The preset quantity and the second threshold can both be preset. For example, the preset quantity is 3, and the first threshold is 15GB.
[0101] In one possible implementation, if the fourth data block does not exist in the third data block set, the fourth data block is retrieved from the fourth data block set and added to the second data block set. Then, it is determined whether the free storage space in the first and second data block sets is greater than or equal to a second threshold. If the free storage space in the first and second data block sets is less than the second threshold, other data blocks in the fourth data block set can be added to the second data block set.
[0102] In this embodiment of the application, when the free storage space in the first data block set and the second data block set is less than or equal to the first threshold, a fourth data block with free storage space is obtained from the third data block set and / or the fourth data block set. This enables the first thread in the first node to obtain an allocable space address in real time without waiting for data block migration, thereby solving the problem of request queuing delay caused by insufficient processing capacity of the single master node in the prior art.
[0103] Based on the above embodiments, the data block includes a header file, a first bitmap, a second bitmap, a first region, and a second region. The header file includes the version number of the data block, the address of the valid bitmap, the starting sequence number of the valid allocation log, and the starting sequence number of the valid release log.
[0104] The first and second regions are physically contiguous address ranges within the storage space and logically used as circular log areas. The first region stores allocation logs, and the second region stores release logs. Both regions need to record their current append write address, the starting log address of the bitmap to be updated, and the ending log address of the bitmap to be updated. The current append write address is less than or equal to the starting log address of the bitmap to be updated. The sequence number of the starting log address of the bitmap to be updated corresponding to the allocation log is the starting sequence number of the valid allocation log, and the sequence number of the starting log address of the bitmap to be updated corresponding to the release log is the starting sequence number of the valid release log.
[0105] In one possible implementation, the first bitmap and the second bitmap are copies of each other. When the address of the valid bitmap is the starting address of the first bitmap, and all addresses in the first region store data corresponding to the allocation log, the second bitmap can be updated by replaying the allocation log. After the second bitmap is updated, the address of the valid bitmap is determined as the starting address of the second bitmap. The next time, when all addresses in the first region store data corresponding to the allocation log, the first bitmap can be updated by replaying the allocation log. After the first bitmap is updated, the address of the valid bitmap is determined as the starting address of the first bitmap, and so on. This will not be elaborated further here.
[0106] In this way, a complete and usable bitmap is always present in the cluster file system. If a failure occurs when updating the bitmap, the other bitmap will still maintain the accurate state before the failure and can be directly used as the basis for subsequent space allocation and release, providing double fault tolerance guarantee for the space state of data blocks.
[0107] In one possible implementation, when updating data in the header file of a data block, mutual exclusion locking is required. That is, after one thread has finished updating a value in the header file, another thread can acquire the lock to update another value in the header file. This can avoid the problem of header file information being disordered when multiple threads update concurrently.
[0108] Based on the above embodiments, when adding a fourth data block from the third data block set to the second data block set, the allocation tree corresponding to the fourth data block can be constructed by replaying the allocation log and release log, and then the fourth data block can be moved to the second data block set.
[0109] Next, combined Figure 3 The management methods for the first region will be explained in detail. Figure 3 This is a schematic diagram of a first area management method provided in an embodiment of this application.
[0110] Reference Figure 3 The first area where the allocation log is stored records: the current append write address curPos, the starting log address validPos of the bitmap to be updated, and the ending log address endPos of the bitmap to be updated.
[0111] In one possible implementation, when the data processing request received by the first node is to store a file, the first node can store the file to a determined free space address, and at the same time, store the relevant information about the space address being allocated to the file in the current append write address curPos of the first region. Then, the current append write address is updated to the sum of curPos and the length of the relevant information (according to the direction of log writing).
[0112] In one possible implementation, when each address in the first region stores data corresponding to the allocation log, the bitmap value can be obtained based on the data between the start log address validPos and the end log address endPos of the bitmap to be updated, and the first or second bitmap can be updated based on the obtained bitmap value.
[0113] In one possible implementation, after the update is complete, the starting log address validPos of the bitmap to be updated is the sum of the ending log address endPos of the bitmap to be updated at the time of the update and 1. The ending log address endPos of the bitmap to be updated remains unchanged for the time being. When the difference between the current append write address at the current time and the current append write address at the time of the bitmap update exceeds a preset third threshold, the ending log address of the bitmap to be updated can be updated to the current append write address at the current time. The third threshold is less than the size of the allocation log; for example, if the size of the allocation log is 32MB, the third threshold is 10MB.
[0114] In this embodiment of the application, self-management can be achieved through bitmaps and logs. By dividing the first region and the second region, the logs corresponding to the allocation address and the logs corresponding to the release address are separated, which can avoid mutual interference between different business processes.
[0115] In this embodiment of the application, by updating the bitmap only when each address in the first region or the second region stores the data corresponding to the log, the serial processing delay caused by waiting for the address allocation operation or the address release operation to be completed before updating the bitmap can be reduced. This allows information processing and allocation (or release of logs) to be processed in parallel, which can improve the response speed of the cluster file system in high-concurrency file storage or deletion scenarios.
[0116] In this embodiment, after the bitmap is updated, the starting log address validPos of the bitmap to be updated is the sum of the ending log address endPos of the bitmap to be updated at the time of updating the bitmap and 1. This can skip the expired logs that have been compressed into the bitmap and avoid overwriting the valid logs when new logs are written later.
[0117] Based on any of the above embodiments, the following, in conjunction with Figure 4 The detailed description specifies that, based on the type of data processing request and the first identifier, the first thread is determined from multiple thread pools of the first node. Figure 1 The method in S103 of the embodiment.
[0118] Figure 4 This application provides a flowchart illustrating the determination of a first thread in an embodiment of the present application. Please refer to the detailed flowchart for further details. Figure 4 The method may include:
[0119] S401. When the data processing request type is data storage type, determine the first thread pool among multiple thread pools, determine the number of first threads in the first thread pool, and determine the first thread to store data in the storage space based on the number of first threads and the first identifier. The first thread pool is the thread pool used for storage.
[0120] In one possible implementation, the multiple thread pools include: a first thread pool, a second thread pool, and a third thread pool, wherein the threads in the first thread pool are used to store information and allocate space address for the information, the threads in the second thread pool are used to delete information and release the space address occupied by the information, and the threads in the second thread pool are used to determine a fourth data block from a third data block set.
[0121] In one possible implementation, each thread in the first thread pool corresponds to a sequence number.
[0122] In one possible implementation, the first thread for storing data in the storage space can be determined by the remainder between the first identifier and the number of the first threads, where the remainder is the sequence number of the first thread. The number of the first threads can be preset to the number of data blocks in the first data block set.
[0123] Furthermore, after determining the first thread, the input / output (I / O) queue depth of the first thread can be determined. If the I / O queue depth is full, the final first thread is determined from the other threads in the first thread pool. If the I / O queue depth of each thread in the first thread pool is full, it indicates that the pressure on the cluster file system has reached its limit, and it is necessary to wait for the I / O queue of the thread to be released before responding to the data processing request.
[0124] For example, if the I / O queue depth of the initially determined first thread is full, then the thread whose sequence number is the sum of the sequence number corresponding to the first thread and 1 is determined as the final first thread.
[0125] In this way, when the first thread I / O queue is full, there is no need to wait for the thread queue to be released (avoiding long-term blocking of requests) or to globally traverse the thread pool to find an idle thread (reducing traversal overhead). The next candidate thread can be quickly located by simple logic (sequence number + 1). This process does not require complex processing logic and can determine the available thread in a short time, so that data processing requests can quickly enter the processing queue, effectively reducing the delay from receiving the request to processing.
[0126] S402. When the data processing request type is data deletion type, determine the second thread pool from multiple thread pools, determine the number of second threads in the second thread pool, and determine the first thread for deleting data in the storage space based on the number of second threads and the first identifier. The second thread pool is the thread pool used for deletion.
[0127] In one possible implementation, each thread in the second thread pool also corresponds to a sequence number.
[0128] In one possible implementation, the first thread used to delete data in the storage space can be determined by the remainder between the first identifier and the number of the second thread, where the remainder is the sequence number of the first thread.
[0129] In this embodiment of the application, a first thread for processing data processing requests is determined according to a first identifier, so that data processing requests for the same file are processed by the same thread. This can improve the utilization rate of file metadata caching and reduce the probability that subsequent requests need to reload metadata due to file metadata being cached separately by different threads, thereby speeding up the response speed of the cluster file system.
[0130] Based on any of the above embodiments, the following, in conjunction with Figure 5 This section details the methods by which each node in a cluster file system manages its storage space.
[0131] Figure 5 This is a schematic diagram illustrating a method for managing storage space among nodes in a clustered file system, as provided in an embodiment of this application. It should be noted that... Figure 5 This explanation uses a clustered file system with two nodes as an example. Figure 5 The cluster file system includes node B and node C.
[0132] Both Node B and Node C include a storage space management module. Furthermore, the storage space management modules of Node B and Node C do not affect each other. The storage space management module is used to manage disk space (including allocating space addresses and releasing space addresses). The storage space management module includes: multiple thread pools, a first data block set, a second data block set, a third data block set, and a fourth data block set.
[0133] The storage space managed by node B is Figure 5 The white portion of the disk space represents the storage space managed by node C. Figure 5 The gray area in the disk space means that the storage space managed by node B and the storage space managed by node C do not affect each other.
[0134] When node B receives data processing request A from client A, node B can... Figure 5 The white portion of the disk space determines the free space address for storing data, thus allocating free space address for the data to be stored. Alternatively, node B can... Figure 5 Delete data from the white portion of the disk space, thereby freeing up the space occupied by the data to be deleted.
[0135] When node C receives a data processing request B from client B, node C can... Figure 5The gray area in the disk space determines the free space address to store data, thus allocating free space address for the data to be stored. Alternatively, node C can... Figure 5 Delete data from the grayed-out portion of the disk space, thereby freeing up the space occupied by the data to be deleted.
[0136] In this embodiment, data processing request A sent by client A is processed by node B, and an address is allocated or released in the disk space managed by node B. Data processing request B sent by client B is processed by node C, and an address is allocated or released in the disk space managed by node C. In other words, the data processing request is distributed to each node for independent processing. This can reduce communication latency caused by frequent contention for resources such as global locks between nodes, thereby speeding up the response speed of the cluster file system. Furthermore, since lock contention is reduced, the occupation of communication resources is also reduced. In addition, the above method can also solve the problem of high communication latency caused by data processing requests queuing and waiting due to a single node processing data processing requests in related technologies.
[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0138] Figure 6 This is a schematic diagram illustrating the structure of a data processing method for a cluster file system provided in an embodiment of this application. Figure 6 As shown, embodiments of this application also provide a data processing apparatus 600 for a clustered file system, including: a receiving module 601, a first determining module 602, a second determining module 603, and a processing module 604, wherein...
[0139] The receiving module 601 is used to receive data processing requests. The data processing requests are processed by the first node among multiple nodes in the cluster file system. The multiple nodes are used to manage multiple storage spaces in the cluster file system.
[0140] The first determining module 602 is used to determine the first identifier and the type of data processing request in the data processing request. The first identifier is the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space.
[0141] The second determining module 603 is used to determine the first thread from the multiple thread pools of the first node according to the type of data processing request and the first identifier. The first thread is used to store data in the storage space or delete data in the storage space.
[0142] Processing module 604 is used to process the data processing request according to the first thread.
[0143] The data processing device of the cluster file system provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0144] In one possible implementation, the processing module 604 is specifically used for:
[0145] When the first thread stores data in the storage space, it determines the information to be stored corresponding to the data processing request and the first data block corresponding to the first thread, and processes the information to be stored according to the first thread and the first data block. The first data block is located in the first data block set.
[0146] When the first thread is used to delete data in the storage space, it determines the second data block where the information to be deleted corresponding to the data processing request is located, and processes the information to be deleted in the second data block according to the first thread.
[0147] In one possible implementation, the processing module 604 is specifically used for:
[0148] Determine the storage address information corresponding to the first data block. The storage address information is used to indicate the free storage address in the first data block.
[0149] Based on the first thread, the first data block, and the storage address information, the information to be stored is stored.
[0150] In one possible implementation, the processing module 604 is specifically used for:
[0151] When the storage address information indicates that there is a free storage address in the first data block, the information to be stored is stored in the free storage address of the first data block according to the first thread;
[0152] When the storage address information indicates that there is no free storage address in the first data block, a third data block with a free storage address is determined in the second data block set, and the first data block in the first data block set is replaced with the third data block. According to the first thread, the information to be stored is stored in the free storage address of the third data block.
[0153] In one possible implementation, the processing module 604 is specifically used for:
[0154] Determine the lengths of multiple data blocks in the storage space, as well as the starting address of the information to be deleted in the storage space;
[0155] Based on the length and starting address of multiple data blocks, determine the second data block containing the information to be deleted.
[0156] In one possible implementation, the first node includes a first data block set, a second data block set, a third data block set, and a fourth data block set. The number of data blocks in the first data block set is fixed, while the number of data blocks in the second, third, and fourth data block sets is not fixed.
[0157] Specifically, when the free storage space in the first data block set and the second data block set is less than or equal to the first threshold, it is determined whether there is a fourth data block in the third data block set, and the fourth data block has free storage space.
[0158] If a fourth data block exists in the third data block set, add the fourth data block to the second data block set;
[0159] If the fourth data block does not exist in the third data block set, retrieve the fourth data block from the fourth data block set and add the fourth data block from the fourth data block set to the second data block set.
[0160] In one possible implementation, the processing module 604 is specifically used for:
[0161] Obtain the timestamp corresponding to the data processing request, and determine the target time based on the timestamp and the preset waiting time;
[0162] At the target time, delete the information to be deleted from the second data block.
[0163] In one possible implementation, the processing module 604 is specifically used for:
[0164] Obtain other data processing requests for data deletion. The timestamps of the other data processing requests indicate times before the target time. The information to be deleted corresponding to the other data processing requests is located in the second data block.
[0165] At the target time, delete the information to be deleted corresponding to other data processing requests in the second data block.
[0166] In one possible implementation, the second determining module 603 is specifically used for:
[0167] When the data processing request type is data storage type, the first thread pool is determined from multiple thread pools, and the number of first threads in the first thread pool is determined. Based on the number of first threads and the first identifier, the first thread used to store data in the storage space is determined, and the first thread pool is the thread pool used for storage.
[0168] When the data processing request type is data deletion, a second thread pool is determined from multiple thread pools, and the number of second threads in the second thread pool is determined. Based on the number of second threads and the first identifier, a first thread is determined to delete the data in the storage space, and the second thread pool is the thread pool used for deletion.
[0169] The data processing device of the cluster file system provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0170] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 7 As shown, the electronic device 700 provided in this embodiment includes at least one processor 701 and a memory 702. Optionally, the electronic device 700 further includes a communication component 703. The processor 701, memory 702, and communication component 703 are connected via a bus.
[0171] In a specific implementation, at least one processor 701 executes computer execution instructions stored in memory 702, causing at least one processor 701 to execute the above-described data processing method embodiment of the cluster file system.
[0172] The specific implementation process of processor 701 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0173] In the above embodiments, it should be understood that the processor can be a CPU, or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules within the processor.
[0174] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0175] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0176] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described cluster file system data processing method embodiments when running.
[0177] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0178] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data processing method embodiments of a cluster file system.
[0179] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described cluster file system data processing method embodiments.
[0180] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0181] The data processing method and electronic device of the cluster file system provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A data processing method for a clustered file system, characterized in that, The cluster file system includes multiple nodes, each of which independently manages a storage space within the cluster file system. The method includes: The first node among the plurality of nodes performs the following steps: Receive a data processing request, wherein the data processing request has a corresponding relationship with the first node; Determine the first identifier in the data processing request and the type of the data processing request, wherein the first identifier is the identifier of the file to be processed or the identifier of the file corresponding to the data to be processed in the storage space; Based on the type of the data processing request and the first identifier, a first thread is determined from the multiple thread pools of the first node. The first identifier is used to ensure that multiple data processing requests for the same file are processed by the same first thread. The first thread is used to store data in the storage space or delete data in the storage space. The data processing request is processed according to the first thread; The step of processing the data processing request according to the first thread includes: When the first thread is used to store data in the storage space, the information to be stored corresponding to the data processing request and the first data block corresponding to the first thread are determined, and the information to be stored is processed according to the first thread and the first data block. The first data block is located in the first data block set, and each thread used to store data in the storage space corresponds to a data block in the first data block set. When the first thread is used to delete data in the storage space, the second data block containing the information to be deleted corresponding to the data processing request is determined, and the information to be deleted is processed in the second data block according to the first thread.
2. The method according to claim 1, characterized in that, The process of processing the information to be stored based on the first thread and the first data block includes: Determine the storage address information corresponding to the first data block, wherein the storage address information is used to indicate the free storage address in the first data block; The information to be stored is stored based on the first thread, the first data block, and the storage address information.
3. The method according to claim 2, characterized in that, The step of storing the information to be stored based on the first thread, the first data block, and the storage address information includes: When the storage address information indicates that there is a free storage address in the first data block, the information to be stored is stored in the free storage address of the first data block according to the first thread; When the storage address information indicates that there is no free storage address in the first data block, a third data block with a free storage address is determined in the second data block set, and the first data block in the first data block set is replaced with the third data block. According to the first thread, the information to be stored is stored in the free storage address of the third data block.
4. The method according to claim 1, characterized in that, The step of determining the second data block containing the information to be deleted corresponding to the data processing request includes: Determine the lengths of multiple data blocks in the storage space, and the starting address of the information to be deleted in the storage space; Based on the length of the plurality of data blocks and the starting address, the second data block containing the information to be deleted is determined among the plurality of data blocks.
5. The method according to claim 3, characterized in that, The first node includes a first data block set, a second data block set, a third data block set, and a fourth data block set. The number of data blocks in the first data block set is fixed, while the number of data blocks in the second data block set, the third data block set, and the fourth data block set is not fixed. Wherein, when the free storage space in the first data block set and the second data block set is less than or equal to a first threshold, it is determined whether there is a fourth data block in the third data block set, and the fourth data block has free storage space; If the fourth data block exists in the third data block set, the fourth data block is added to the second data block set. If the fourth data block does not exist in the third data block set, the fourth data block is obtained from the fourth data block set and added to the second data block set.
6. The method according to claim 1, characterized in that, The step of processing the information to be deleted in the second data block according to the first thread includes: Obtain the timestamp corresponding to the data processing request, and determine the target time based on the timestamp and the preset waiting time; At the target time, the information to be deleted is deleted from the second data block.
7. The method according to claim 6, characterized in that, The method further includes: Obtain other data processing requests for data deletion, wherein the timestamps corresponding to the other data processing requests indicate times prior to the target time, and the information to be deleted corresponding to the other data processing requests is located in the second data block; At the target time, delete the information to be deleted corresponding to other data processing requests in the second data block.
8. The method according to any one of claims 1-7, characterized in that, The step of determining the first thread from multiple thread pools of the first node based on the type of the data processing request and the first identifier includes: When the data processing request is of type data storage type, a first thread pool is determined from the plurality of thread pools, and the number of first threads in the first thread pool is determined. Based on the number of first threads and the first identifier, a first thread for storing data in the storage space is determined, and the first thread pool is a thread pool for storage. When the data processing request is of type data deletion, a second thread pool is determined from the plurality of thread pools, and the number of second threads in the second thread pool is determined. Based on the number of second threads and the first identifier, a first thread for deleting data in the storage space is determined, and the second thread pool is the thread pool for deletion.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data processing method of the cluster file system as described in any one of claims 1 to 8 when executing the computer program.