Method and device for controlling cloud disk read-write, electronic equipment and storage medium

By determining the priority and version number mechanism of the cloud disk client's permission information, the cloud disk is controlled to only accept read and write operations from the client with the highest priority, which solves the data inconsistency problem when the cloud disk is mounted multiple times and achieves data consistency guarantee.

CN115309327BActive Publication Date: 2025-11-04BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210873638.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-21
Publication Date
2025-11-04
Estimated Expiration
2042-07-21

AI Technical Summary

Technical Problem

When multiple cloud disks are mounted, existing technologies cannot guarantee the correctness of read and write operations on multiple clients, leading to data inconsistency issues.

Method used

By obtaining the permission information of the specified client and the current client, the highest priority target permission information is determined, and the target cloud disk is controlled to only accept read and write operations from the target client. Mechanisms such as version numbers and blacklists and whitelists are used to ensure data consistency.

Benefits of technology

This effectively avoids situations where multiple clients read and write to the cloud disk simultaneously, ensuring data consistency and resolving read/write correctness issues when multiple cloud disks are mounted.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115309327B_ABST
    Figure CN115309327B_ABST
Patent Text Reader

Abstract

The application provides a method and device for controlling cloud disk read-write, electronic equipment and a storage medium, wherein the method comprises: obtaining a specified client which needs to be mounted on a target cloud disk; mounting the specified client on the target cloud disk; determining a target client from the specified client and a current client by determining target permission information with the highest priority from first permission information of the current client and second permission information of the specified client; and controlling the target cloud disk to only accept read-write operations from the target client. Through the application, the target cloud disk can only accept read-write operations from the target client, thereby avoiding the situation that multiple clients simultaneously perform read-write operations on the target cloud disk after being mounted on the target cloud disk, and further solving the problem in the related art that when a cloud disk is mounted multiple times, read-write operations of multiple clients cannot guarantee correctness; and the application achieves the beneficial effect of effectively guaranteeing consistency of data in the cloud disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and in particular to a method and apparatus for controlling cloud disk read and write, electronic equipment and storage medium. Background Technology

[0002] When using a cloud disk, it needs to be mounted first. The main purpose of the mounting operation is to obtain the basic information of the cloud disk, which can be called the metadata of the cloud disk. The client for the mounting operation is usually a virtualization component such as QEMU or SPDK Vhost. The server that handles the mounting operation is the metadata cluster of the block storage service. After the mounting operation is completed, the client can read and write to the cloud disk. The server that handles the read and write operations is the data cluster of the block storage service.

[0003] Currently, the block storage service metadata cluster does not limit the number of clients when handling mount operations. This means different clients can mount the same cloud disk. These clients are generally distributed across different host machines. Once these cloud hosts mount the same cloud disk, they can simultaneously read and write to it. The block storage metadata service does not distinguish whether the clients making read / write requests are the same. While the underlying logic of the block storage service metadata cluster can guarantee data consistency when reading and writing from the same client, it cannot guarantee data consistency if different clients simultaneously read and write to the same cloud disk.

[0004] This shows that when multiple cloud disks are mounted, the correctness of read and write operations by multiple clients cannot be guaranteed. Summary of the Invention

[0005] This application provides a method, apparatus, electronic device, and storage medium for controlling cloud disk read and write operations, in order to at least solve the problem in the related art that when multiple cloud disks are mounted, the correctness of read and write operations by multiple clients cannot be guaranteed.

[0006] According to one aspect of the embodiments of this application, a method for controlling cloud disk read and write is provided, including:

[0007] Obtain the specified client that needs to be mounted on the target cloud disk;

[0008] Mount the specified client onto the target cloud disk;

[0009] The target client is determined by identifying the highest priority target permission information between the first permission information of the current client and the second permission information of the specified client, and then by identifying the target client between the specified client and the current client. The current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information between the specified client and the current client.

[0010] The target cloud disk is controlled to only accept read and write operations from the target client.

[0011] Optionally, as described above, before determining the target client from the specified client and the current client by identifying the highest priority target permission information from the first permission information of the current client and the second permission information of the specified client, the method further includes:

[0012] Determine the first version number, which serves as the first permission information, and the first client identifier of the current client;

[0013] Determine the second client identifier of the specified client.

[0014] Optionally, as described above, determining the target client from the specified client and the current client by determining the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client includes:

[0015] If the first client identifier is different from the second client identifier and there is no version number corresponding to the second client identifier, the first version number is updated according to a preset update method to obtain the second version number as the second permission information;

[0016] The specified client is identified as the target client, and the second version number is used as the target permission information;

[0017] Save the correspondence between the second version number and the second client identifier;

[0018] The second version number is transmitted to the designated client.

[0019] Optionally, as described above, determining the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client includes:

[0020] If the first client identifier and the second client identifier are the same, it is determined that the specified client is the same as the current client;

[0021] The current client is identified as the target client, and the first version number is returned to the current client.

[0022] Optionally, as described above, before determining the target client from the specified client and the current client by identifying the highest priority target permission information from the first permission information of the current client and the second permission information of the specified client, the method further includes:

[0023] Obtain a pre-generated blacklist and whitelist corresponding to the target cloud disk, wherein the blacklist in the blacklist and whitelist is used to indicate clients that are prohibited from performing read and write operations on the target cloud disk, and the whitelist in the blacklist and whitelist is used to indicate clients that are allowed to perform read and write operations on the target cloud disk.

[0024] Optionally, as described above, determining the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client includes:

[0025] Determine the first client identifier of the current client and the second client identifier of the specified client;

[0026] The step of determining the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client includes:

[0027] Among the first client identifier and the second client identifier, the target client identifier located in the whitelist is determined, and the permission information corresponding to the target client identifier is determined as the target permission information;

[0028] The client corresponding to the target client identifier is identified as the target client.

[0029] Optionally, as described above, before obtaining the specified client that needs to be mounted on the target cloud disk, the method further includes:

[0030] Obtain the mount request from the specified client;

[0031] Determine the cloud disk information in the mount request;

[0032] When it is determined that the cloud disk indicated by the cloud disk information meets the preset usability status, the cloud disk indicated by the cloud disk information is determined as the target cloud disk;

[0033] The control of the target cloud disk to only accept read and write operations from the target client includes:

[0034] Obtain read and write requests from pending clients;

[0035] Determine the pending permission information carried in the read / write request;

[0036] If the pending permission information is determined to be the target permission information, the pending client is determined to be the target client, and the read and write operations of the target client on the target cloud disk are accepted.

[0037] If it is determined that the pending permission information is not the target permission information, the target client's read and write operations on the target cloud disk are denied.

[0038] According to another aspect of the embodiments of this application, a method for controlling cloud disk read and write is also provided, including:

[0039] The acquisition module is used to acquire the specified client that needs to be mounted on the target cloud disk;

[0040] A mounting module is used to mount the specified client onto the target cloud disk.

[0041] The determination module is used to determine the target client by identifying the highest priority target permission information among the first permission information of the current client and the second permission information of the specified client, wherein the current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information among the specified client and the current client;

[0042] The read / write control module is used to control the target cloud disk to only accept read / write operations from the target client.

[0043] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used to store a computer program; and the processor is used to execute the method steps of any of the above embodiments by running the computer program stored in the memory.

[0044] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the method steps of any of the above embodiments when running.

[0045] In this embodiment, the target client is determined from the specified client and the current client based on the first permission information of the current client and the second permission information of the specified client. This identifies the target client that can perform read and write operations on the target cloud disk. Furthermore, by controlling the target cloud disk to only accept read and write operations from the target client, the target cloud disk can be made to accept only read and write operations from the target client. This avoids the situation where multiple clients simultaneously perform read and write operations on the target cloud disk after it has been mounted to multiple clients. This solves the problem in related technologies where the correctness of read and write operations by multiple clients cannot be guaranteed when the cloud disk is mounted to multiple clients. This achieves the beneficial effect of effectively ensuring the consistency of data in the cloud disk. Attached Figure Description

[0046] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart illustrating an optional method for controlling cloud disk read / write according to an embodiment of this application;

[0049] Figure 2 This is a flowchart illustrating an optional method for controlling cloud disk read / write according to another embodiment of this application;

[0050] Figure 3 This is a schematic diagram of an optional method for controlling cloud disk read / write according to another embodiment of this application;

[0051] Figure 4 This is a structural block diagram of an optional method or apparatus for controlling cloud disk read / write according to an embodiment of this application;

[0052] Figure 5 This is a structural block diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0053] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0054] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0055] According to one aspect of the embodiments of this application, a method for controlling cloud disk read and write is provided. Optionally, in this embodiment, the above-described method for controlling cloud disk read and write can be applied to a hardware environment consisting of a terminal and a server. The server is connected to the terminal via a network and can be used to provide services (such as data processing services, application services, etc.) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services to the server.

[0056] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal is not limited to PC, mobile phone, tablet computer, etc.

[0057] The method for controlling cloud disk read / write in this application embodiment can be executed by a server, a terminal, or both. Specifically, the method for controlling cloud disk read / write in this application embodiment can also be executed by a client installed on the terminal.

[0058] In most scenarios, virtualization platforms do not mount cloud disks to different host machines simultaneously. However, in some cases, such as during virtual machine migration, multiple host machines may mount the same cloud disk. Virtual machine migration refers to a situation where a user's cloud host is currently on host A, but for some reason needs to be migrated to host B. During the migration process, the cloud disk will be mounted on both host A and host B. After the migration is complete, the cloud disk will be unmounted from host A. As a block storage data service, it's not feasible to rely solely on upper-layer modules to guarantee the uniqueness of mounting and read / write operations. The underlying layer needs a solution to control multiple mountings and read / write operations of cloud disks. This solution cannot simply be designed to prevent multiple mountings of cloud disks, as this would cause virtual machine migration to fail because host B cannot mount the cloud disk. However, completely allowing mounting could lead to multiple mountings due to bugs in the virtualization platform, potentially compromising the integrity of the underlying data due to read / write operations by multiple clients.

[0059] To address the aforementioned issues, this embodiment uses a method for controlling cloud disk read / write operations, executed by a server, as an example. Figure 1 A method for controlling cloud disk read / write provided in this application embodiment includes the following steps:

[0060] Step S101: Obtain the specified client that needs to be mounted on the target cloud disk;

[0061] The method for controlling cloud disk read / write in this embodiment can be applied to scenarios where multiple clients are mounted on the cloud disk. For example, when a virtual machine is migrated, multiple clients may be mounted on the same cloud disk; or when the virtualization platform has bugs that could compromise the integrity of data in the cloud disk due to multiple clients reading and writing data. For other types of scenarios, the above method for controlling cloud disk read / write is also applicable, provided there are no contradictions.

[0062] Since different clients can be mounted to the same cloud disk, the specific clients that need to be mounted on the target cloud disk can be obtained in real time.

[0063] The target cloud disk can be the cloud disk that the specified client indicates to be mounted.

[0064] The specified client can be a client distributed on a specified host machine, and in general, different clients are distributed on different host machines.

[0065] Optionally, a specified client may proactively initiate a mount request to the server to mount to the target cloud disk. The server can then determine, based on this mount request, that the specified client is the one requiring mounting, and that the cloud disk to which the specified client wishes to mount is the target cloud disk. Furthermore, the target cloud disk to be mounted can be determined based on the target metadata in the mount request that indicates the target cloud disk.

[0066] Step S102: Mount the specified client to the target cloud disk.

[0067] Once the specified client is identified, it can be mounted to the target cloud drive.

[0068] Step S103: Determine the target permission information with the highest priority from the first permission information of the current client and the second permission information of the specified client, and determine the target client from the specified client and the current client. The current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information from the specified client and the current client.

[0069] Once the target cloud disk is identified, the information of the clients currently mounted on the target cloud disk can be queried to determine the current client.

[0070] For each client, there is a unique set of permission information. That is, the current client has a unique first permission information, and the specified client has a unique second permission information.

[0071] To ensure that the target cloud disk only accepts read and write operations from one client at a time, the priorities corresponding to different permission information are different.

[0072] Furthermore, by comparing the first permission information and the second permission information, the permission information with the highest priority among the first permission information and the second permission information can be used as the target permission information.

[0073] Once the target permission information is determined, the client corresponding to that permission information (i.e., the specified client or the current client) can be used as the target client. Optionally, an identifier (e.g., IP address) can be pre-defined for each client to ensure a one-to-one correspondence between clients and permission information.

[0074] For example, if the first permission information (corresponding to the current client is a') is a and the second permission information (corresponding to the specified client is b') is b, and b has a higher priority than a, then b is determined as the target permission information and b' is determined as the target client.

[0075] Step S104: Control the target cloud disk to only accept read and write operations from the target client.

[0076] Once the target client is identified, the server can store relevant information about the target client locally (e.g., the target client's identification information or the target client's permission information). By controlling the target cloud disk to only accept read and write operations from the target client, it is easy to reject read and write operations from other clients.

[0077] The method in this embodiment determines the target client by using the first permission information of the current client and the second permission information of the specified client. This identifies the target client that can perform read and write operations on the target cloud disk. By controlling the target cloud disk to only accept read and write operations from the target client, it avoids the situation where multiple clients simultaneously perform read and write operations on the target cloud disk after it is mounted to the target cloud disk. This solves the problem in related technologies where the correctness of read and write operations by multiple clients cannot be guaranteed when the cloud disk is mounted to multiple clients. It achieves the beneficial effect of effectively ensuring the consistency of data in the cloud disk.

[0078] As an optional embodiment, as described above, before determining the target client from the specified client and the current client in step S103 by determining the target permission information with the highest priority from the first permission information of the current client and the second permission information of the specified client, the method further includes the following steps:

[0079] Step S201: Determine the first version number, which serves as the first permission information, and the first client identifier of the current client;

[0080] Step S202: Determine the second client identifier of the specified client.

[0081] In this embodiment, the version number corresponding to the client is used as the client's permission information.

[0082] Optionally, the first version number can be determined by the block storage metadata service (which primarily maintains the metadata of the target cloud disk and interacts with it during the mounting operation initiated by the current client) after the current client mounts the target cloud disk, and is the information corresponding to the current client. The version number can be used to indicate the order in which different clients mount to the same cloud disk. Furthermore, the block storage metadata service can store the mapping relationship between clients and version numbers, or at least store the mapping relationship between the highest-priority specified version number and the client corresponding to that version number.

[0083] Furthermore, once the block storage metadata service maintains and obtains the first version number of the current client for the target cloud disk, this first version number can be used as the first permission information. The block storage metadata service can then inform the data service (primarily handling cloud disk read / write operations) of the first version number, and the data service will store the first version number and the first client identifier accordingly, so that the data service can later accept read / write operations from the current client based on the first version number and the first client identifier.

[0084] The first client identifier can be a unique identifier that indicates the current client, such as the current client's IP address.

[0085] The second client identifier of a specified client can be obtained through a mount request from a specified client.

[0086] like Figure 2 As shown, step S103 determines the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client, including the following steps:

[0087] Step S301: If the first client identifier is different from the second client identifier and there is no version number corresponding to the second client identifier, update the first version number according to the preset update method to obtain the second version number as the second permission information.

[0088] After obtaining the first client identifier and the second client identifier, the first client identifier and the second client identifier can be compared. If the first client identifier and the second client identifier are different, and there is no version number corresponding to the second client identifier (i.e., indicating that the specified client is being mounted to the target cloud disk for the first time), the first version number can be updated according to the preset update method to obtain the second version number as the second permission information.

[0089] The preset update method can be used to update the version number. For example: Method 1, the version number can start from 1. If the target cloud disk has already been mounted, and the client mounted this time is not the same as the client mounted last time, then the version number is incremented by 1 based on the previous mounting version number; Method 2, updates the first version number based on the mounting time. Other methods can also be used to implement this preset update method, which will not be listed here.

[0090] After determining the preset update method and the first version number, the first version number can be updated according to the preset update method to obtain the second version number as the second permission information. Furthermore, the newer the version number, the higher the permission. For example, if the first version number is 9 and the preset update method is method 1, the second version number is 10. In this case, the larger the version number, the higher the permission.

[0091] Step S302: The specified client is identified as the target client, and the second version number is used as the target permission information.

[0092] After determining the second version number, the interface will identify the specified client as the target client and use the second version number as the target permission information.

[0093] Step S303: Save the correspondence between the second version number and the second client identifier.

[0094] After determining the second version number, the second client identifier of the specified client, and that the specified client is the target client, the mapping between the second version number and the second client identifier can be saved in the data service. This allows for later control over the target cloud disk to only accept read and write operations from the specified client.

[0095] Step S304: Transmit the second version number to the designated client.

[0096] In order to enable the read and write operations of a specified client to be identified later, a second version number is transmitted to the specified client so that the data service can accept the read and write operations initiated by the specified client by identifying the second version number carried in the read and write operations initiated by the specified client.

[0097] like Figure 3 As shown, as an optional embodiment, in the aforementioned method, step S103 determines the target client from the specified client and the current client by determining the target permission information with the highest priority from the first permission information of the current client and the second permission information of the specified client, including the following steps:

[0098] Step S401: If the first client identifier and the second client identifier are the same, determine that the specified client is the same as the current client;

[0099] Step S402: Identify the current client as the target client and return the first version number to the current client.

[0100] If the first client identifier and the second client identifier are the same, since there is a unique correspondence between client identifiers and clients, it can be determined that the specified client is the same as the current client.

[0101] This allows us to further identify the current client as the target client (i.e., equivalent to identifying the specified client as the target client) and return the first version number to the current client.

[0102] The method in this embodiment allows only the newly mounted specified client to perform read and write operations on the target cloud disk, avoiding data inconsistency caused by both new and old clients performing read and write operations on the target cloud disk later.

[0103] As an optional embodiment, as described above, before determining the target client from the specified client and the current client by determining the highest priority target permission information from the first permission information of the current client and the second permission information of the specified client in step S103, the method further includes the following steps:

[0104] Step S501: Obtain a pre-generated blacklist and whitelist corresponding to the target cloud disk. The blacklist in the blacklist and whitelist is used to indicate clients that are prohibited from reading and writing to the target cloud disk, and the whitelist in the blacklist and whitelist is used to indicate clients that are allowed to read and write to the target cloud disk.

[0105] Optionally, by maintaining blacklists and whitelists, the client can control read and write operations on the target cloud disk.

[0106] The blacklist and whitelist can be pre-maintained lists. The blacklist records client identifiers that prevent clients from reading or writing to the target cloud disk, thus indicating which clients are prohibited from reading or writing to the target cloud disk. The whitelist records client identifiers that allow clients to read or write to the target cloud disk, thus indicating which clients are permitted to read or write to the target cloud disk.

[0107] Therefore, in this embodiment, there is generally only one client identifier in the whitelist.

[0108] Before determining the target client from the specified client and the current client by identifying the highest priority target permission information from the first permission information of the current client and the second permission information of the specified client in step S103, the method further includes the following steps:

[0109] Step S601: Determine the first client identifier of the current client and the second client identifier of the specified client.

[0110] After identifying the current client and the specified client, the first client identifier of the current client can be determined based on the pre-stored relevant information of the current client; the second client identifier of the specified client carried in the mount request can be determined based on the mount request from the specified client.

[0111] Step S103 involves determining the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client, including the following steps:

[0112] Step S602: Determine the target client identifier in the whitelist from the first client identifier and the second client identifier, and determine the permission information corresponding to the target client identifier as the target permission information.

[0113] After identifying the first client identifier and the second client identifier, their relationship with the blacklist or whitelist can be determined. Furthermore, the target client identifier located in the whitelist is identified from the first and second client identifiers, and the permission information corresponding to that target client identifier is determined as the target permission information.

[0114] Step S603: Identify the client corresponding to the target client identifier as the target client.

[0115] Once the target client identifier is determined, the client corresponding to the target client identifier is instructed to perform read and write operations on the target cloud disk. Therefore, the client corresponding to the target client identifier can be identified as the target client.

[0116] For example, if the first client identifier is in the whitelist, then the first client identifier is determined as the target client identifier, and the specified client corresponding to the first client identifier is determined as the target client.

[0117] The method in this embodiment can identify target clients that can perform read and write operations on the target cloud disk by using blacklists and whitelists. It can also avoid data inconsistency caused by multiple clients performing read and write operations on the target cloud disk when multiple clients are mounted on it.

[0118] As an optional embodiment, as described above, before obtaining the specified client to be mounted on the target cloud disk in step S101, the method further includes the following steps:

[0119] Step S701: Obtain a mount request from the specified client;

[0120] Step S702: Determine the cloud disk information in the mount request;

[0121] Step S703: When it is determined that the cloud disk indicated by the cloud disk information meets the preset usable state, the cloud disk indicated by the cloud disk information is determined as the target cloud disk.

[0122] The specified client can actively initiate a mount request to request mounting to the target cloud disk. The mount request can include cloud disk information of the cloud disk to which it needs to be mounted. After receiving the mount request, the block storage metadata service can determine whether the cloud disk indicated by the cloud disk information meets the preset usability status.

[0123] The preset availability status can include: whether the cloud disk indicated by the cloud disk information exists, and whether the status of the cloud disk indicated by the cloud disk information is normal.

[0124] When the block storage metadata service determines that the cloud disk indicated by the cloud disk information meets the preset usability status, it will identify the cloud disk indicated by the cloud disk information as the target cloud disk.

[0125] Step S104, controlling the target cloud disk to only accept read and write operations from the target client, includes the following steps:

[0126] Step S801: Obtain read / write requests from pending clients;

[0127] Step S802: Determine the pending permission information carried in the read / write request;

[0128] Step S803: If the pending permission information is determined to be the target permission information, the pending client is determined to be the target client, and read and write operations on the target cloud disk by the target client are accepted.

[0129] Step S804: If it is determined that the pending permission information is not the target permission information, the target client's read and write operations on the target cloud disk are rejected.

[0130] After identifying the target client, it is necessary to control the target cloud disk to only accept read and write operations from the target client. After obtaining the read and write requests from the pending client, the pending permission information carried in the read and write request can be determined first.

[0131] A read / write request can be a request generated by a client to perform read / write operations on a target cloud disk. Pending permission information can be permission information present in the read / write request.

[0132] If the pending permission information is the same as the target permission information stored in the data service, then the pending permission information is determined to be the target permission information, the pending client is determined to be the target client, and the target client's read and write operations on the target cloud disk are accepted; if the pending permission information is the same as the target permission information stored in the data service, then the pending permission information is determined not to be the target permission information, and the target client's read and write operations on the target cloud disk are rejected.

[0133] The method in this embodiment can control the read and write operations of the target cloud disk by the client to be identified based on the target permission information, and achieve the goal of only allowing the target client to perform read and write operations on the target cloud disk.

[0134] As described below, this application also provides an application example that applies any of the foregoing embodiments:

[0135] The underlying services of the block storage service metadata cluster are divided into two categories in advance: one is the block storage metadata service, which mainly maintains the metadata information of the cloud disk and requires interaction with it for mounting operations; the other is the data service, which mainly handles the reading and writing of the cloud disk.

[0136] When mounting a cloud disk on a host machine, in addition to returning the normal cloud disk metadata information, the block storage metadata service also maintains a version number related to the mounting order for the cloud disk and returns it along with the disk. After the mounting operation is completed, the metadata service needs to inform the data service of the cloud disk's version number. The data service locally stores the mapping relationship between the version number and the client. When the client initiates read or write operations after mounting, each read or write operation needs to include the version number. When processing read or write requests, the data service needs to check whether the version number carried in the request matches the locally stored version number. If it is smaller than the locally stored mounting version number, the read or write operation is rejected.

[0137] If another host machine also initiates a mount operation, the block storage metadata service will increment the version number when returning the mount information and broadcast it to the data service. At this time, the new host machine (the physical machine with the latest mounted client) will have a higher mount version number than the old host machine (the physical machine with the client having read and write permissions). In this case, read and write operations initiated on the old host machine will be rejected, and the new host machine will have higher read and write permissions.

[0138] Specifically:

[0139] 1. The block storage metadata service processes mount requests, checking whether the cloud disk corresponding to the mount operation meets the mount conditions. These conditions generally refer to whether the cloud disk exists and whether its status is normal. If the conditions are met, a version number is generated for the cloud disk, starting from 1. If the cloud disk has already been mounted, and the client mounting this time (i.e., the specified client) is not the same as the client mounting last time (i.e., the current client), the version number is incremented by one based on the previous mount version number, and this version number is broadcast to the block storage data service. After the broadcast, the metadata service replies to the client mounting this time with the mount request. This reply includes normal cloud disk metadata information as well as the version number. If the client mounting this time is the same as the client mounting last time (i.e., the same client mounting twice), the version number from the previous mount is returned directly. This comparison of whether it is the same client can be done by directly comparing the client's IP address. If the mount conditions are not met, the client is directly replied with a mount failure message.

[0140] 2. The client processes the mounting result. If the mounting is successful, the version number is saved locally, and this version number is included in every subsequent read / write operation on the cloud disk.

[0141] 3. When the block storage metadata service processes cloud disk read and write operations, it compares the version number stored locally with the version number carried in the request. If they are inconsistent, the read and write request is rejected. If the client receives this error, it can check and locate the multi-mount scenario, thereby canceling data read and write on the old host machine, and subsequent read and write operations will be initiated through the new host machine.

[0142] By adding version numbers to mount and read / write operations, the system ensures that only one client can read and write to the cloud disk at any given time, even when multiple cloud disks are allowed to be mounted, thus guaranteeing data consistency.

[0143] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0144] 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. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0145] According to another aspect of the embodiments of this application, an apparatus for controlling cloud disk read and write for implementing the above-described method of controlling cloud disk read and write is also provided. Figure 4 This is a structural block diagram of an optional device for controlling cloud disk read / write according to an embodiment of this application, such as... Figure 4 As shown, the device may include:

[0146] Module 1 is used to obtain the specified client that needs to be mounted on the target cloud disk;

[0147] Mount module 2 is used to mount a specified client to the target cloud disk;

[0148] Module 3 is used to determine the highest priority target permission information from the first permission information of the current client and the second permission information of the specified client, and to determine the target client from the specified client and the current client. The current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information from the specified client and the current client.

[0149] Read / write control module 4 is used to control the target cloud disk to only accept read / write operations from the target client.

[0150] It should be noted that the acquisition module 1 in this embodiment can be used to perform the above step S101, the mounting module 2 in this embodiment can be used to perform the above step S102, the determination module 3 in this embodiment can be used to perform the above step S103, and the read / write control module 4 in this embodiment can be used to perform the above step S104.

[0151] The above modules enable the target cloud disk to accept read and write operations only from the target client, thereby avoiding the situation where multiple clients simultaneously perform read and write operations on the target cloud disk after it has been mounted to the target cloud disk. This solves the problem in related technologies where the correctness of data cannot be guaranteed when multiple cloud disks are mounted due to read and write operations by multiple clients; thus achieving the beneficial effect of effectively ensuring the consistency of data in the cloud disk.

[0152] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can operate in ways such as... Figure 1 The method shown can be implemented in either software or hardware within a hardware environment, where the hardware environment includes a network environment.

[0153] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described method for controlling cloud disk read and write is also provided. The electronic device may be a server, a terminal, or a combination thereof.

[0154] According to another embodiment of this application, an electronic device is also provided, comprising: Figure 5 As shown, the electronic device may include: a processor 1501, a communication interface 1502, a memory 1503, and a communication bus 1504, wherein the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504.

[0155] Memory 1503 is used to store computer programs;

[0156] When processor 1501 executes the program stored in memory 1503, it performs the following steps:

[0157] Step S101: Obtain the specified client that needs to be mounted on the target cloud disk;

[0158] Step S102: Mount the specified client onto the target cloud disk.

[0159] Step S103: Determine the target permission information with the highest priority from the first permission information of the current client and the second permission information of the specified client, and determine the target client from the specified client and the current client. The current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information from the specified client and the current client.

[0160] Step S104: Control the target cloud disk to only accept read and write operations from the target client.

[0161] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.

[0162] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0163] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0164] This application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the method steps of the above method embodiments when it runs.

[0165] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.

[0166] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0167] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0168] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

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

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

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

[0172] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for controlling cloud disk read / write operations, characterized in that, include: Obtain the specified client that needs to be mounted on the target cloud disk; Mount the specified client onto the target cloud disk; Obtain a pre-generated blacklist and whitelist corresponding to the target cloud disk, wherein the blacklist in the blacklist and whitelist is used to indicate clients that are prohibited from performing read and write operations on the target cloud disk, and the whitelist in the blacklist and whitelist is used to indicate clients that are allowed to perform read and write operations on the target cloud disk; Determine the first client identifier of the current client and the second client identifier of the specified client; The target client is determined from the specified client and the current client by identifying the highest priority target permission information between the first permission information of the current client and the second permission information of the specified client. This includes: identifying the target client identifier in the whitelist from the first client identifier and the second client identifier, determining the permission information corresponding to the target client identifier as the target permission information, and determining the client corresponding to the target client identifier as the target client. The current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information between the specified client and the current client. The target cloud disk is controlled to only accept read and write operations from the target client.

2. The method according to claim 1, characterized in that, Before determining the target client from the specified client and the current client by identifying the highest priority target permission information from the first permission information of the current client and the second permission information of the specified client, the method further includes: Determine the first version number, which serves as the first permission information, and the first client identifier of the current client; Determine the second client identifier of the specified client.

3. The method according to claim 2, characterized in that, The step of determining the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client includes: If the first client identifier is different from the second client identifier and there is no version number corresponding to the second client identifier, the first version number is updated according to a preset update method to obtain the second version number as the second permission information; The specified client is identified as the target client, and the second version number is used as the target permission information; Save the correspondence between the second version number and the second client identifier; The second version number is transmitted to the designated client.

4. The method according to claim 2, characterized in that, The step of determining the target client from the specified client and the current client by identifying the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client includes: If the first client identifier and the second client identifier are the same, it is determined that the specified client is the same as the current client; The current client is identified as the target client, and the first version number is returned to the current client.

5. The method according to any one of claims 1 to 4, characterized in that, Before obtaining the specified client that needs to be mounted on the target cloud disk, the method further includes: Obtain the mount request from the specified client; Determine the cloud disk information in the mount request; When it is determined that the cloud disk indicated by the cloud disk information meets the preset usability status, the cloud disk indicated by the cloud disk information is determined as the target cloud disk; The control of the target cloud disk to only accept read and write operations from the target client includes: Obtain read and write requests from pending clients; Determine the pending permission information carried in the read / write request; If the pending permission information is determined to be the target permission information, the pending client is determined to be the target client, and the read and write operations of the target client on the target cloud disk are accepted. If it is determined that the pending permission information is not the target permission information, the target client's read and write operations on the target cloud disk are denied.

6. A method for controlling cloud disk read / write, characterized in that, include: The acquisition module is used to acquire the specified client that needs to be mounted on the target cloud disk; A mounting module is used to mount the specified client onto the target cloud disk. It also includes a module for obtaining a pre-generated blacklist and whitelist corresponding to the target cloud disk, wherein the blacklist in the blacklist and whitelist is used to indicate clients that are prohibited from performing read and write operations on the target cloud disk, and the whitelist in the blacklist and whitelist is used to indicate clients that are allowed to perform read and write operations on the target cloud disk; and determining the first client identifier of the current client and the second client identifier of the specified client; The determination module is used to determine the target client among the specified client and the current client by determining the target permission information with the highest priority among the first permission information of the current client and the second permission information of the specified client. This includes: determining the target client identifier located in the whitelist among the first client identifier and the second client identifier, determining the permission information corresponding to the target client identifier as the target permission information, and determining the client corresponding to the target client identifier as the target client. The current client is the client currently mounted on the target cloud disk, and the target client is the client corresponding to the target permission information among the specified client and the current client. The read / write control module is used to control the target cloud disk to only accept read / write operations from the target client.

7. An electronic device comprising a processor, a communication interface, a memory, and a communication bus, wherein, The processor, the communication interface, and the memory communicate with each other via the communication bus, characterized in that... The memory is used to store computer programs; The processor is configured to perform the method steps of any one of claims 1 to 5 by running the computer program stored in the memory.

8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the steps of the method described in any one of claims 1 to 5 when it is run.

Citation Information

Patent Citations

  • Data transmission method and device

    CN112600878A