A multi-client data reading and writing method in a distributed file system

By introducing a range lock mechanism into the distributed file system, the read and write mode is dynamically determined, which solves the problem of poor performance when multiple clients read and write files at the same time, and realizes efficient processing of large IO sequential read and write scenarios.

CN116009778BActive Publication Date: 2025-04-29CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In a distributed file system, when multiple clients read and write the same file at the same time, the existing technology is difficult to make full use of client cache, resulting in poor performance in large IO sequential read and write scenarios.

Method used

A range lock mechanism is introduced. When the client opens a file, MDS allocates a range lock of the default size. According to the client's read and write mode and the mode of other clients in the system, it dynamically decides to use range lock mode or direct read and write mode.

Benefits of technology

In the multi-client large IO sequential read and write scenario, the client cache is fully utilized to improve read and write performance, and by identifying the dynamic switching mode of the IO model, the overhead of repeated switching of range locks is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116009778B_ABST
    Figure CN116009778B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data reading and writing in storage systems, and provides a multi-client data reading and writing method in a distributed file system, including: when a client in the system opens a file in a read-write mode, the MDS allocates a range lock of a default size to each client; when the client performs cache reading and writing within the range lock allocated by the MDS, the corresponding read-write mode of the client is judged; the MDS summarizes the read-write modes corresponding to all clients that read and write files in the system, and determines the read-write mode of the file according to the summary result; the client reads and writes the file according to the determined read-write mode of the file. According to the multi-client data reading and writing method in a distributed file system according to an exemplary embodiment of the present invention, different clients can make full use of the cache when reading and writing at different offsets, thereby improving the read-write performance; by identifying the multi-client IO model, it is dynamically determined to use the range lock or the direct read-write mode, making full use of the advantages of the two modes in different scenarios, and reducing the overhead of repeated switching of the range lock.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of storage system data reading and writing, and in particular to a multi-client data reading and writing method in a distributed file system. Background Art

[0002] POSIX semantics requires order preservation for concurrent reading and writing of a file. Similarly, the same requirements apply when multiple clients read and write concurrently in a distributed file system.

[0003] The Ceph file system is one of the current mainstream distributed file systems. The implementation scheme of this file system for this scenario is as follows: a single client is allowed to use the client cache for cached reading and writing, but when multiple clients are identified to read and write concurrently, the cached reading and writing capabilities of all clients are reclaimed, that is, degenerated into direct reading and writing mode, so as to ensure consistency and POSIX semantic requirements.

[0004] However, the direct read and write mode of the Ceph solution is more suitable for small IO random read and write in the scenario of simultaneous read and write by multiple clients. However, it is not very friendly to the scenario of large IO sequential read and write at different offsets of a single file, and cannot fully utilize the client cache to improve performance.

[0005] Therefore, how to provide a method that can fully utilize the client cache when multiple clients read and write the same file has become a technical problem that needs to be solved urgently. Summary of the invention

[0006] In view of this, in order to overcome the deficiencies of the prior art, the present invention provides a multi-client data reading and writing method in a distributed file system.

[0007] On the one hand, the present invention provides a multi-client data reading and writing method in a distributed file system, comprising:

[0008] Step S1: When a client in the system opens a file in read-write mode, the MDS allocates a range lock of a default size to each client;

[0009] Step S2: When the client performs cache reading and writing within the range lock allocated by the MDS, the corresponding read and write mode of the client is determined;

[0010] Step S3: MDS summarizes the read-write modes corresponding to all clients that read and write files in the system, and determines the read-write mode of the file based on the summary result;

[0011] Step S4: The client reads and writes the file according to the determined read and write mode of the file.

[0012] Furthermore, step S2 of the multi-client data reading and writing method in the distributed file system of the present invention includes: when the client performs cache reading and writing within the range lock allocated by the MDS, the offset and length of each IO are recorded, the position of each reading and writing is determined according to the recorded offset and length of the IO, the position of each reading and writing is compared with the position of the previous reading and writing, and the corresponding reading and writing mode of the client is determined according to the comparison result.

[0013] Furthermore, in step S2 of the multi-client data reading and writing method in the distributed file system of the present invention, the position of each reading and writing is compared with the position of the previous reading and writing, and the reading and writing mode corresponding to the client is determined according to the comparison result, including:

[0014] When the position of each read and write is the same as the position of the previous read and write, the read and write mode corresponding to the client is determined to be sequential read and write;

[0015] When the position of each read and write is different from the position of the previous read and write, the read and write mode corresponding to the client is determined to be random read and write.

[0016] Furthermore, in step S3 of the multi-client data reading and writing method in the distributed file system of the present invention, determining the reading and writing mode of the file according to the summary result includes:

[0017] When the read / write mode of all clients reading and writing files in the system is sequential, the file's read / write mode is determined to be range lock mode;

[0018] When the read / write mode corresponding to any client that reads and writes files in the system is random read / write, the read / write mode of the file is determined to be direct read / write mode.

[0019] Furthermore, step S4 of the multi-client data reading and writing method in the distributed file system of the present invention comprises:

[0020] If the file's read / write mode is the range lock mode, when the client reads or writes the file, the client's local range lock is matched with the allocated range lock. When the allocated range lock includes the local range lock, the file is cached for reading and writing. When the allocated range lock does not include the local range lock, a new range lock application request is sent to the MDS.

[0021] After receiving the application request sent by the client, the MDS compares the new range lock applied for in the application request with the range locks already allocated to other clients, and allocates the new range lock to the client that sent the application request for the new range lock based on the comparison result.

[0022] Furthermore, in step S4 of the multi-client data reading and writing method in the distributed file system of the present invention, the new range lock applied for in the application request is compared with the range locks already allocated to other clients, and the new range lock is allocated to the client that sends the application request for the new range lock according to the comparison result, including:

[0023] Check whether the new range lock applied in the application request has an intersection with the range locks already allocated to other clients;

[0024] When the two range locks have an intersection, it is determined that the range locks conflict, and the MDS first reclaims the range locks that have been allocated to other clients, and then allocates the new range lock to the client that sent the new range lock application request;

[0025] When there is no intersection between the two range locks, it is determined that there is no conflict between the range locks, and a new range lock is allocated to the client that sends the application request for the new range lock.

[0026] Furthermore, step S4 of the multi-client data reading and writing method in the distributed file system of the present invention includes: if the reading and writing mode of the file is the direct reading and writing mode, the MDS reclaims the range locks of all clients, and the clients perform direct reading and writing on the file.

[0027] In another aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed, the above method is performed.

[0028] Finally, the present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of the method are implemented when the processor executes the program.

[0029] The multi-client data reading and writing method in the distributed file system of the present invention has the following beneficial effects:

[0030] 1. Aiming at the scenario where multiple clients perform large IO sequential reading and writing at different offsets of a single file, the present invention introduces a range lock mechanism, so that different clients can make full use of the cache when reading and writing at different offsets, thereby improving the reading and writing performance.

[0031] 2. The present invention identifies the multi-client IO model and dynamically determines whether to use range lock or direct read and write mode, making full use of the advantages of the two modes in different scenarios and reducing the overhead of repeated switching of range locks. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1 This is a flowchart of a multi-client data reading and writing method in a distributed file system according to the first embodiment of the present invention.

[0034] Figure 2 This is a flowchart of a range lock read-write mode in a multi-client data read-write method in a distributed file system according to the third embodiment of the present invention.

[0035] Figure 3 This is a flowchart of a direct read and write mode in a multi-client data reading and writing method in a distributed file system according to the third embodiment of the present invention.

[0036] Figure 4 This is a flowchart of a method for reading and writing data among multiple clients in a distributed file system according to the fourth embodiment of the present invention.

[0037] Figure 5 This is a flowchart of a multi-client data reading and writing method in a distributed file system according to the fifth embodiment of the present invention. DETAILED DESCRIPTION

[0038] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0039] It should be noted that the following embodiments and features in the embodiments may be combined with each other in the absence of conflict; and, based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making any creative work are within the scope of protection of the present disclosure.

[0040] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0041] The terms used in the following embodiments are explained as follows:

[0042] MDS: Metadata Service, a daemon process that is mainly responsible for responding to client metadata operations.

[0043] Range lock: A read-write lock that locks a file range.

[0044] IO: Input / Output, reading and writing data to readable and writable storage media.

[0045] OSD: Object Storage Device, a daemon process that is mainly responsible for responding to client data reading and writing.

[0046] Figure 1 FIG. 1 is a flowchart of a multi-client data reading and writing method in a distributed file system according to an exemplary first embodiment of the present invention. Figure 1 As shown, the method of this embodiment includes:

[0047] Step S1: When a client in the system opens a file in read-write mode, the MDS allocates a range lock of a default size to each client;

[0048] Step S2: When the client performs cache reading and writing within the range lock allocated by the MDS, the corresponding read and write mode of the client is determined;

[0049] Step S3: MDS summarizes the read-write modes corresponding to all clients that read and write files in the system, and determines the read-write mode of the file based on the summary result;

[0050] Step S4: The client reads and writes the file according to the determined read and write mode of the file.

[0051] The second exemplary embodiment of the present invention provides a multi-client data reading and writing method in a distributed file system. Figure 1 A preferred embodiment of the method is shown.

[0052] Step S2 of the method of this embodiment includes: when the client performs cache reading and writing within the range lock allocated by the MDS, the offset and length of each IO are recorded, the position of each reading and writing is determined according to the recorded offset and length of the IO, the position of each reading and writing is compared with the position of the previous reading and writing, and the reading and writing mode corresponding to the client is judged according to the comparison result. Specifically, when the position of each reading and writing is the same as the position of the previous reading and writing, the reading and writing mode corresponding to the client is judged as sequential reading and writing; when the position of each reading and writing is different from the position of the previous reading and writing, the reading and writing mode corresponding to the client is judged as random reading and writing.

[0053] The third exemplary embodiment of the present invention provides a method for reading and writing data from multiple clients in a distributed file system. Figure 1In the preferred embodiment of the method shown in the figure, in step S3 of the method of this embodiment, the reading and writing mode of the file is determined according to the summary result, including:

[0054] like Figure 2 As shown, when the read-write mode corresponding to all clients that read and write files in the system is sequential read-write, the read-write mode of the file is determined to be the range lock mode;

[0055] like Figure 3 As shown, when the read-write mode corresponding to any client that reads and writes files in the system is random read-write, the read-write mode of the file is determined to be direct read-write mode.

[0056] Figure 4 FIG. 1 is a flowchart of a method for reading and writing data by multiple clients in a distributed file system according to an exemplary fourth embodiment of the present invention. Figure 1 The preferred embodiment of the method shown is as follows Figure 4 As shown, step S4 of the method of this embodiment includes:

[0057] If the file's read / write mode is the range lock mode, when the client reads or writes the file, the client's local range lock is matched with the allocated range lock. When the allocated range lock includes the local range lock, the file is cached for reading and writing. When the allocated range lock does not include the local range lock, a new range lock application request is sent to the MDS.

[0058] After receiving the application request sent by the client, the MDS compares the new range lock applied for in the application request with the range locks already allocated to other clients, and allocates the new range lock to the client that sent the application request for the new range lock based on the comparison result.

[0059] In practical applications, in step S4 of the method of this embodiment, the new range lock applied for in the application request is compared with the range locks already allocated to other clients, and the new range lock is allocated to the client that sends the application request for the new range lock according to the comparison result, which is implemented in the following manner:

[0060] Check whether the new range lock applied in the application request has an intersection with the range locks already allocated to other clients;

[0061] When the two range locks have an intersection, it is determined that the range locks conflict, and the MDS first reclaims the range locks that have been allocated to other clients, and then allocates the new range lock to the client that sent the new range lock application request;

[0062] When there is no intersection between the two range locks, it is determined that there is no conflict between the range locks, and a new range lock is allocated to the client that sends the application request for the new range lock.

[0063] Figure 5FIG. 1 is a flowchart of a method for reading and writing data by multiple clients in a distributed file system according to an exemplary fifth embodiment of the present invention. Figure 1 The preferred embodiment of the method shown is as follows Figure 5 As shown, step S4 of the method of this embodiment includes: if the read-write mode of the file is the direct read-write mode, the MDS reclaims the range locks of all clients, and the clients perform direct read-write on the file.

[0064] Furthermore, the present invention provides a computer-readable storage medium, characterized in that a computer program is stored thereon, and when the computer program is executed, the multi-client data reading and writing method in the distributed file system of the present invention is executed.

[0065] Finally, the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a multi-client data reading and writing method in a distributed file system when executing the program.

[0066] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A method for reading and writing data from multiple clients in a distributed file system, characterized in that: The method comprises: Step S1: When a client in the system opens a file in read-write mode, the MDS allocates a range lock of a default size to each client; Step S2: when the client performs cache reading and writing within the range lock allocated by the MDS, the corresponding read and write mode of the client is determined; Step S3: MDS summarizes the read-write modes corresponding to all clients that read and write files in the system, and determines the read-write mode of the file based on the summary result; Step S4: the client reads and writes the file according to the determined reading and writing mode of the file; In step S3, the read and write mode of the file is determined according to the summary result, including: When the read / write modes of all clients reading and writing files in the system are sequential, the file's read / write mode is determined to be range lock mode; When the read / write mode corresponding to any client that reads and writes files in the system is random read / write, the read / write mode of the file is determined to be direct read / write mode.

2. The method for reading and writing data by multiple clients in a distributed file system according to claim 1, characterized in that: Step S2 includes: when the client performs cache reading and writing within the range lock allocated by the MDS, the offset and length of each IO are recorded, the position of each reading and writing is determined according to the recorded offset and length of the IO, the position of each reading and writing is compared with the position of the previous reading and writing, and the corresponding reading and writing mode of the client is determined according to the comparison result.

3. The multi-client data reading and writing method in a distributed file system according to claim 2, characterized in that: In step S2, the position of each read and write is compared with the position of the previous read and write, and the read and write mode corresponding to the client is determined according to the comparison result, including: When the position of each read and write is the same as the position of the previous read and write, the read and write mode corresponding to the client is determined to be sequential read and write; When the position of each read and write is different from the position of the previous read and write, the read and write mode corresponding to the client is determined to be random read and write.

4. The method for reading and writing data by multiple clients in a distributed file system according to claim 1, characterized in that: Step S4 includes: If the file's read / write mode is the range lock mode, when the client reads or writes the file, the client's local range lock is matched with the allocated range lock. When the allocated range lock includes the local range lock, the file is cached for reading and writing. When the allocated range lock does not include the local range lock, a new range lock application request is sent to the MDS. After receiving the application request sent by the client, the MDS compares the new range lock applied for in the application request with the range locks already allocated to other clients, and allocates the new range lock to the client that sent the application request for the new range lock based on the comparison result.

5. The method for reading and writing data by multiple clients in a distributed file system according to claim 4, characterized in that: In step S4, the new range lock applied for in the application request is compared with the range locks already allocated to other clients, and the new range lock is allocated to the client sending the new range lock application request according to the comparison result, including: Check whether the new range lock applied in the application request has an intersection with the range locks already allocated to other clients; When the two range locks have an intersection, it is determined that the range locks conflict, and the MDS first reclaims the range locks that have been allocated to other clients, and then allocates the new range lock to the client that sent the new range lock application request; When there is no intersection between the two range locks, it is determined that there is no conflict between the range locks, and a new range lock is allocated to the client that sends the application request for the new range lock.

6. The multi-client data reading and writing method in a distributed file system according to claim 1, characterized in that: Step S4 includes: if the read-write mode of the file is the direct read-write mode, the MDS reclaims the range locks of all clients, and the clients perform direct read-write on the file.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 6 is performed.

8. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 6 when executing the program.

Citation Information

Patent Citations

  • A method and a device for realizing data consistency in a distributed file system

    CN109582658A

  • Parallel file system with method using tokens for locking modes

    US6032216A