CN115309327A - Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium - Google Patents

Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium Download PDF

Info

Publication number
CN115309327A
CN115309327A CN202210873638.0A CN202210873638A CN115309327A CN 115309327 A CN115309327 A CN 115309327A CN 202210873638 A CN202210873638 A CN 202210873638A CN 115309327 A CN115309327 A CN 115309327A
Authority
CN
China
Prior art keywords
client
target
cloud disk
determining
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210873638.0A
Other languages
Chinese (zh)
Inventor
王栩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202210873638.0A priority Critical patent/CN115309327A/en
Publication of CN115309327A publication Critical patent/CN115309327A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0637Permissions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a method and a device for controlling reading and writing of a cloud disk, an electronic device and a storage medium, wherein the method comprises the following steps: acquiring a specified client needing to be mounted on a target cloud disk; mounting a specified client on a target cloud disk; determining target authority information with the highest priority from the first authority information of the current client and the second authority information of the designated client, and determining the target client from the designated client and the current client; and controlling the target cloud disk to only accept read-write operation from the target client. According to the method and the device, the target cloud disk can only accept the read-write operation of the target client, so that the situation that the plurality of clients simultaneously perform the read-write operation on the target cloud disk after the target cloud disk is mounted to the plurality of clients can be avoided, and the problem that the correctness can not be ensured due to the read-write operation of the plurality of clients when the cloud disk is mounted in the related art is solved; the beneficial effect of effectively guaranteeing the consistency of the data in the cloud disk is achieved.

Description

Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium
Technical Field
The present application relates to the field of cloud computing technologies, and in particular, to a method and an apparatus for controlling reading and writing of a cloud disk, an electronic device, and a storage medium.
Background
When the cloud hard disk is used, the cloud hard disk needs to be mounted firstly, the mounting operation mainly aims at obtaining basic information of the cloud hard disk, the basic information can be called as meta information of the cloud hard disk, a client side of the mounting operation generally comprises virtualized components of qemu or spdk vhost, a server side for processing the mounting operation is a meta data cluster of the block storage service, after the mounting operation is completed, the client side can read and write the cloud hard disk, and a server side for processing the reading and writing operation is a data cluster of the block storage service.
At present, when a block storage service metadata cluster processes mount operation, the number of clients is not limited, that is, different clients can mount the same cloud hard disk, where different clients are generally distributed on different hosts, and after the cloud hosts on the hosts mount the same cloud disk, the cloud disk can be simultaneously read and written, and the block storage metadata service does not distinguish whether the clients requesting the read and write requests are the same. The bottom logic of the block storage service metadata cluster can ensure data consistency under the condition of reading and writing the same client, and if different clients read and write the same cloud disk at the same time, the data consistency cannot be ensured.
Therefore, in the related art, when the cloud disk is mounted more, the problem that the correctness cannot be ensured due to the reading and writing of multiple clients exists.
Disclosure of Invention
The application provides a method and a device for controlling reading and writing of a cloud disk, an electronic device and a storage medium, which are used for at least solving the problem that the correctness can not be ensured due to the reading and writing of multiple clients when the cloud disk is mounted in multiple ways in the related art.
According to an aspect of an embodiment of the present application, there is provided a method for controlling reading and writing of a cloud disk, including:
acquiring a specified client needing to be mounted on a target cloud disk;
mounting the specified client on the target cloud disk;
determining target authority information with the highest priority from first authority information of a current client and second authority information of the specified client, and determining a target client from the specified client and the current client, wherein the current client is a client mounted on the target cloud disk at the current moment, and the target client is a client corresponding to the target authority information from the specified client and the current client;
and controlling the target cloud disk to only accept read-write operation from the target client.
Optionally, as in the foregoing method, before the target permission information with the highest priority is determined from the first permission information of the current client and the second permission information of the designated client, the method further includes:
determining a first version number as the first permission information and a first client identifier of the current client;
and determining a second client identification of the specified client.
Optionally, as in the foregoing method, the determining a target client from the designated client and the current client by determining target permission information with the highest priority from among first permission information of the current client and second permission information of the designated client includes:
under the condition that the first client identifier is different from the second client identifier and the version number corresponding to the second client identifier does not exist, updating the first version number according to a preset updating mode to obtain a second version number serving as the second permission information;
determining the designated client as the target client, and taking the second version number as the target authority information;
storing the corresponding relation between the second version number and the second client identifier;
transmitting the second version number to the designated client.
Optionally, as in the foregoing method, the determining a target client from the designated client and the current client by determining target permission information with the highest priority from among first permission information of the current client and second permission information of the designated client includes:
determining that the designated client is the same as the current client under the condition that the first client identifier is the same as the second client identifier;
and determining the current client as the target client, and returning the first version number to the current client.
Optionally, as in the foregoing method, before the determining, by determining target permission information with the highest priority from among the first permission information of the current client and the second permission information of the designated client, a target client is determined from among the designated client and the current client, the method further includes:
and acquiring a pre-generated black and white list corresponding to the target cloud disk, wherein the black list in the black and white list is used for indicating a client which prohibits the read-write operation of the target cloud disk, and the white list in the black and white list is used for indicating a client which permits the read-write operation of the target cloud disk.
Optionally, as in the foregoing method, the determining a target client from the designated client and the current client by determining target permission information with the highest priority from among first permission information of the current client and second permission information of the designated client includes:
determining a first client identification of the current client and a second client identification of the designated client;
the determining a target client from the designated 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 designated client comprises:
determining a target client identifier located in the white list from the first client identifier and the second client identifier, and determining authority information corresponding to the target client identifier as the target authority information;
and determining the client corresponding to the target client identification as the target client.
Optionally, as in the foregoing method, before obtaining a specified client that needs to be mounted on a target cloud disk, the method further includes:
acquiring a mounting request from the specified client;
determining cloud disk information in the mounting request;
when it is determined that the cloud disk indicated by the cloud disk information meets a preset available state, determining the cloud disk indicated by the cloud disk information as the target cloud disk;
the controlling the target cloud disk to only accept the read-write operation from the target client includes:
acquiring a read-write request of a pending client;
determining undetermined authority information carried in the read-write request;
under the condition that the undetermined authority information is determined to be the target authority information, determining the undetermined client to be the target client, and accepting the read-write operation of the target client to the target cloud disk;
and under the condition that the undetermined authority information is determined not to be the target authority information, refusing the read-write operation of the target client to the target cloud disk.
According to another aspect of the embodiments of the present application, there is also provided a method for controlling reading and writing of a cloud disk, including:
the acquisition module is used for acquiring a specified client which needs to be mounted on a target cloud disk;
the mounting module is used for mounting the specified client on the target cloud disk;
the determining module is used for determining a target client from the designated client and the 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 designated client, wherein the current client is a client mounted on the target cloud disk at the current moment, and the target client is a client corresponding to the target permission information from the designated client and the current client;
and the read-write control module is used for controlling the target cloud disk to only accept the read-write operation from the target client.
According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used for storing the computer program; a processor for performing the method steps in any of the above embodiments by running the computer program stored on the memory.
According to a further aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to perform the method steps of any of the above embodiments when the computer program is executed.
In the embodiment of the application, the target client is determined from the designated client and the current client according to the first permission information of the current client and the second permission information of the designated client, so that the target client capable of performing read-write operation on the target cloud disk is determined, and the target cloud disk can only receive the read-write operation from the target client by controlling the target cloud disk, so that the condition that the target cloud disk is simultaneously subjected to the read-write operation by a plurality of clients after being mounted to the plurality of clients of the target cloud disk can be avoided, and the problem that the correctness can not be ensured due to the read-write of the plurality of clients when the cloud disk is mounted in a plurality of ways in the related technology is solved; the beneficial effect of effectively guaranteeing the consistency of the data in the cloud disk is achieved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
Fig. 1 is a schematic flowchart of an alternative method for controlling reading and writing of a cloud disk according to an embodiment of the present application;
fig. 2 is a schematic flowchart of an alternative method for controlling reading and writing of a cloud disk according to another embodiment of the present application;
fig. 3 is a schematic diagram of an alternative method for controlling reading and writing of a cloud disk according to another embodiment of the present application;
fig. 4 is a block diagram of an alternative method and apparatus for controlling reading and writing of a cloud disk according to an embodiment of the present application;
fig. 5 is a block diagram of an alternative electronic device according to an embodiment of the application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an aspect of an embodiment of the present application, a method for controlling reading and writing of a cloud disk is provided. Optionally, in this embodiment, the method for controlling reading and writing of the cloud disk may be applied to a hardware environment formed by a terminal and a server. The server is connected with the terminal through a network, and can be used for providing services (such as data processing services and application services) for the terminal or a client installed on the terminal, and a database can be arranged on the server or independent of the server and used for providing data storage services for the server.
The network may include, but is not limited to, at least one of: wired networks, wireless networks. The wired network may include, but is not limited to, at least one of: wide area networks, metropolitan area networks, local area networks, which may include, but are not limited to, at least one of the following: WIFI (Wireless Fidelity), bluetooth. The terminal may not be limited to a PC, a mobile phone, a tablet computer, and the like.
The method for controlling the reading and writing of the cloud disk in the embodiment of the application can be executed by a server, a terminal, or both the server and the terminal. The method for controlling the reading and writing of the cloud disk by the terminal according to the embodiment of the present application may also be executed by a client installed on the terminal.
In most scenarios, the virtualization platform will not mount the cloud disk to different hosts at the same time. In some cases, such as virtual machine migration, there may be multiple hosts mounting the same cloud disk, and virtual machine migration refers to: at a certain moment, the cloud host of the user is on the host A, but the cloud host needs to be migrated to the host B for some reasons, the cloud disk can be mounted on the host A and the host B simultaneously in the migration process, and after the migration is completed, the cloud disk can be unloaded on the host A. For a block storage data service, the uniqueness of mounting and reading and writing cannot be guaranteed by completely depending on an upper module, a scheme is needed by a bottom layer to control multiple mounting and reading and writing of a cloud disk, the scheme cannot be simply made to be incapable of allowing multiple mounting of the cloud disk, so that failure due to the fact that a host B cannot mount the cloud disk during migration of a virtual machine occurs, mounting is completely released, and if a virtualization platform generates multiple mounting conditions due to bugs, correctness of data of the bottom layer can not be guaranteed due to reading and writing of multiple clients.
To solve the above problem, taking the method for controlling the reading and writing of the cloud disk in this embodiment as an example, where the server executes the method for controlling the reading and writing of the cloud disk, fig. 1 is a method for controlling the reading and writing of the cloud disk provided in this embodiment, and includes the following steps:
step S101, acquiring a specified client needing to be mounted on a target cloud disk;
the method for controlling the reading and writing of the cloud disk in the embodiment can be applied to a scene that a plurality of clients are mounted on the cloud disk, for example, when a virtual machine is migrated, the plurality of clients are mounted on the same cloud disk; or the virtualized platform has a bug, so that the data in the cloud disk may not be correct due to the reading and writing of multiple clients. For other types of scenarios, the above method for controlling reading and writing of the cloud disk is also applicable without contradiction.
Different clients can be mounted on the same cloud disk, so that the specified client needing to be mounted on the target cloud disk can be obtained in real time.
The target cloud disk may be the cloud disk to which the specified client indicates a need to mount.
A given client may be a client distributed on a given host, and typically, different clients are distributed on different hosts.
Optionally, the designated client may actively initiate a mount request that needs to be mounted to the target cloud disk to the server, and the server may determine, based on the mount request, that the designated client needs to be mounted, and that the cloud disk to which the designated client needs to be mounted is the target cloud disk. Further, it may be determined that the cloud disk to be mounted is the target cloud disk based on the target meta-information indicating the target cloud disk in the mounting request.
And step S102, mounting the specified client on the target cloud disk.
After the designated client is determined, the designated client can be mounted to the target cloud disk.
Step S103, determining target authority information with the highest priority level from the first authority information of the current client and the second authority information of the designated client, and determining the target client from the designated client and the current client, wherein the current client is the client mounted on the target cloud disk at the current moment, and the target client is the client corresponding to the target authority information from the designated client and the current client.
After the target cloud disk is determined, the client which is currently mounted on the target cloud disk, namely the current client, can be determined by inquiring the information of the client which is currently mounted on the target cloud disk.
For each client, the unique corresponding authority information exists, namely the current client has the unique corresponding first authority information, and the appointed client has the unique corresponding second authority information.
In order to ensure that the target cloud disk only receives the read-write operation of one client at the same time, the priorities corresponding to different authority information are different.
Furthermore, the first authority information and the second authority information can be compared, and the authority information with the highest priority in the first authority information and the second authority information is used as the target authority information.
After the target permission information is determined, a client (i.e., a designated client or a current client) corresponding to the target permission information may be used as the target client. Alternatively, it may be determined to make one-to-one correspondence between the client and the authority information by presetting an identifier (for example, IP) corresponding to each client.
For example, if the first right information (corresponding to the current client a ') is a and the second right information (corresponding to the designated client b ') is b, and the priority of b is higher than a, b is determined as the target right information and b ' is determined as the target client.
And step S104, controlling the target cloud disk to only accept read-write operation from the target client.
After the target client is determined, the server locally may store related information corresponding to the target client (for example, identification information of the target client, or target authority information corresponding to the target client), and may accept only the read-write operation of the target client by controlling the target cloud disk, so as to reject the read-write operation from other clients.
By the method in the embodiment, the target client is determined from the designated client and the current client according to the first permission information of the current client and the second permission information of the designated client, so that the target client capable of performing read-write operation on the target cloud disk is determined, and the target cloud disk can only accept the read-write operation from the target client by controlling the target cloud disk to only accept the read-write operation from the target client, so that the situation that the target cloud disk is simultaneously read-written by a plurality of clients after being mounted to the plurality of clients of the target cloud disk can be avoided, and the problem that the correctness can not be ensured due to the read-write of the plurality of clients when the cloud disk is mounted in a plurality of ways in the related technology is solved; the beneficial effect of effectively guaranteeing the consistency of the data in the cloud disk is achieved.
As an alternative embodiment, as the foregoing method, before determining the target client in the designated client and the current client by determining the target permission information with the highest priority in the first permission information of the current client and the second permission information of the designated client in step S103, the method further includes the following steps:
step S201, determining a first version number as first authority information and a first client identification of a current client;
step S202, determining a second client identifier of the designated client.
In this embodiment, the version number corresponding to the client is used as the authority information of the client.
Optionally, the first version number may be information corresponding to the current client, which is determined by a block storage metadata service (which mainly maintains metadata of the target cloud disk, and with which a mount operation initiated by the current client needs to interact) after the current client mounts to the target cloud disk. The version number may be used to indicate the sequence of mounting different clients to the same cloud disk. And, the block storage metadata service may store a mapping relationship between the client and the version number, or at least store a mapping relationship between a specified version number with the highest priority and a client corresponding to the specified version number.
Furthermore, after the block storage metadata service can maintain and obtain the first version number of the current client for the target cloud disk, the first version number can be used as the first permission information. And the block storage metadata service can inform the data service of the first version number (mainly processing the reading and writing of the cloud disk), and the data service correspondingly stores the first version number and the first client identifier, so that the later data service can receive the reading and writing operation of the current client based on the first version number and the first client identifier.
The first client identification may be a unique identification indicating the current client, e.g. the IP address of the current client.
The second client identifier of the specified client may be obtained through a mount request from the specified client.
As shown in fig. 2, the step S103 determines the target client from the designated 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 designated client, and includes the following steps:
step S301, when the first client identifier is different from the second client identifier and there is no version number corresponding to the second client identifier, updating the first version number according to a preset updating manner to obtain a second version number serving as the second permission information.
After the first client identifier and the second client identifier are obtained, the first client identifier and the second client identifier can be compared, and the first version number can be updated according to a preset updating mode under the condition that the first client identifier is different from the second client identifier and the version number corresponding to the second client identifier does not exist (namely, the designated client is indicated to be mounted to the target cloud disk for the first time), so that the second version number serving as the second permission information is obtained.
The preset updating manner may be a manner for updating the version number, for example: in the mode 1, the version number can be started from 1, and if the target cloud disk is mounted and the client mounted at this time is not the same as the client mounted at the last time, the version number is added with 1 on the basis of the last mounting of the version number; in the method 2, the first version number is updated according to the mounting time. The preset updating mode can also be implemented in other modes, which are not listed here.
After the preset updating manner and the first version number are determined, the first version number may be updated according to the preset updating manner to obtain a second version number as second authority information, and the more the version number is generated, the higher the authority is, for example, in the case that the first version number is 9 and the preset updating manner is the manner 1, the second version number is 10, and in this case, the larger the version number is, the higher the authority is.
Step S302, the designated client is determined as a target client, and the second version number is used as target authority information.
After the second version number is determined, the interface determines the designated client as a target client, and takes the second version number as target permission information.
Step S303, saving the corresponding relationship between the second version number and the second client identifier.
After the second version number, the second client identifier of the designated client and the designated client as the target client are determined, the corresponding relationship between the second version number and the second client identifier can be stored in the data service. So that the target cloud disk can be controlled to only accept the read-write operation of the specified client at the later stage.
Step S304, the second version number is transmitted to the appointed client.
In order to enable the read-write operation of the specified client to be recognized in the later period, the second version number is transmitted to the specified client, so that the later-period data service can receive the read-write operation initiated by the specified client by recognizing the second version number carried in the read-write operation initiated by the specified client.
As shown in fig. 3, as an alternative embodiment, as the foregoing method, the step S103 determines, by determining the target permission information with the highest priority from among the first permission information of the current client and the second permission information of the designated client, the target client from among the designated client and the current client, and includes the following steps:
step S401, under the condition that the first client identification is the same as the second client identification, determining that the designated client is the same as the current client;
and step S402, determining the current client as the target client, and returning the first version number to the current client.
Under the condition that the first client identification is the same as the second client identification, the specified client can be determined to be the same as the current client due to the unique correspondence between the client identification and the client.
And may proceed to determine the current client as the target client (i.e., equivalent to determining the specified client as the target client) and return the first version number to the current client.
By the method in the embodiment, only the newly mounted specified client can perform read-write operation on the target cloud disk, and the condition that data is inconsistent due to the fact that the new and old clients perform read-write operation on the target cloud disk in the later period is avoided.
As an alternative embodiment, as the foregoing method, before determining the target client in the designated client and the current client by determining the target permission information with the highest priority in the first permission information of the current client and the second permission information of the designated client in step S103, the method further includes the following steps:
step S501, a pre-generated black and white list corresponding to the target cloud disk is obtained, wherein the black list in the black and white list is used for indicating a client which forbids reading and writing operations on the target cloud disk, and the white list in the black and white list is used for indicating a client which allows reading and writing operations on the target cloud disk.
Optionally, the client can control the read-write operation of the target cloud disk by maintaining a black-and-white list.
The black-and-white list may be list information obtained by pre-maintenance, wherein the client corresponding to the client identifier recorded in the black list cannot perform read-write operation on the target cloud disk, so as to achieve the purpose of indicating the client prohibited from performing read-write operation on the target cloud disk through the black list, and the client corresponding to the client identifier recorded in the white list may perform read-write operation on the target cloud disk, so as to achieve the purpose of indicating the client permitted to perform read-write operation on the target cloud disk through the white list.
Therefore, in the present embodiment, there is only one client identifier in the white list in general.
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 designated client, before determining the target client from the designated client and the current client, the method further includes the following steps:
step S601, determining a first client identifier of the current client and a second client identifier of the designated client.
After the current client and the designated client are determined, a first client identifier of the current client can be determined based on pre-stored related 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.
Step S103, determining the target authority information with the highest priority from the first authority information of the current client and the second authority information of the designated client, and determining the target client from the designated client and the current client, wherein the method comprises the following steps:
step S602, determining a target client identifier located in the white list from the first client identifier and the second client identifier, and determining the authority information corresponding to the target client identifier as the target authority information.
After the first client identifier and the second client identifier are determined, the relationship between the first client identifier and the second client identifier and the blacklist or the white list respectively can be judged. And determining a target client identifier in the white list from the first client identifier and the second client identifier, and determining the authority information corresponding to the target client identifier as target authority information.
Step S603, determining the client corresponding to the target client identifier as the target client.
After the target client identifier is determined, that is, the client corresponding to the target client identifier is indicated to perform read-write operation on the target cloud disk, so that the client corresponding to the target client identifier can be determined as the target client.
For example, when the first client identifier is in the white list, the first client identifier is determined as the target client identifier, and the specific client corresponding to the first client identifier is determined as the target client.
By the method in the embodiment, the target client capable of performing read-write operation on the target cloud disk can be determined in a black-and-white list manner, and the situation that data is inconsistent due to the fact that a plurality of clients perform read-write operation on the target cloud disk under the condition that the target cloud disk is hung with the plurality of clients can be avoided.
As an alternative embodiment, as in the foregoing method, before acquiring, in step S101, a specified client that needs to be mounted on the target cloud disk, the method further includes the following steps:
step S701, acquiring a mounting request from a specified client;
step S702, determining cloud disk information in the mounting request;
in step S703, when it is determined that the cloud disk indicated by the cloud disk information satisfies the preset available state, the cloud disk indicated by the cloud disk information is determined as the target cloud disk.
The designated client may be an active client that initiates a mount request for requesting to mount to a target cloud disk, where the mount request may include cloud disk information of a cloud disk to which mount is required, and after receiving the mount request, the block storage metadata service may determine whether the cloud disk indicated by the cloud disk information satisfies a preset available state.
The preset available state may include: whether the cloud disk indicated by the cloud disk information exists or not and whether the state of the cloud disk indicated by the cloud disk information is normal or not.
And when determining that the cloud disk indicated by the cloud disk information meets the preset available state, the block storage metadata service determines the cloud disk indicated by the cloud disk information as a target cloud disk.
Step S104, controlling the target cloud disk to only accept the read-write operation from the target client, comprising the following steps:
step S801, acquiring a read-write request of a pending client;
step S802, determining undetermined authority information carried in the read-write request;
step S803, under the condition that the undetermined authority information is determined to be the target authority information, determining the undetermined client to be the target client, and accepting the read-write operation of the target client to the target cloud disk;
and step S804, refusing the read-write operation of the target client to the target cloud disk under the condition that the undetermined authority information is determined not to be the target authority information.
After the target client is determined, that is, the target cloud disk needs to be controlled to only accept the read-write operation of the target client, and after the read-write request of the client to be determined is obtained, the information of the authority to be determined carried in the read-write request can be determined.
The read-write request may be a request generated by the pending client for requesting to perform a read-write operation on the target cloud disk. The pending permission information may be permission information present in the read-write request.
Under the condition that the undetermined authority information is the same as target authority information stored in the data service, determining the undetermined authority information as the target authority information, determining the undetermined client as a target client, and accepting the read-write operation of the target client on the target cloud disk; and under the condition that the undetermined permission information is the same as the target permission information stored in the data service, determining that the undetermined permission information is not the target permission information, and refusing the read-write operation of the target client to the target cloud disk.
By the method in the embodiment, the read-write operation of the undetermined client to the target cloud disk can be controlled based on the target authority information, and the purpose of only allowing the target client to read-write the target cloud disk is achieved.
As described below, the present application further provides an application example to which any of the foregoing embodiments is applied:
the method comprises the steps that metadata cluster bottom layer services of the block storage service are divided into two types in advance, wherein one type is the block storage metadata service which mainly maintains metadata of the cloud disk and needs interaction with mounting operation, and the other type is the data service which mainly processes reading and writing of the cloud disk.
When a host mounts a cloud hard disk, in addition to returning normal cloud disk meta-information, the block storage metadata service also maintains a version number related to the mounting sequence for the cloud disk and returns the version number and the version number together. After the mount operation is completed, the metadata service needs to inform the data service of the version number of the cloud disk, and the data service locally stores the mapping relationship between the version number and the client. When a client initiates read-write operation after mounting, a version number needs to be carried in each read-write operation, when a data service processes a read-write request, whether the version number carried in the request is consistent with a locally stored version number needs to be checked, and if the version number is smaller than the locally stored mounting version number, the read-write operation is refused.
If another host machine also initiates mounting operation, when the block storage metadata service returns mounting information, the block storage metadata service adds a version number and broadcasts the version number to the data service, at this time, the mounting version number taken by a new host machine (a physical machine distributed with a latest mounted client) is higher than that taken by an old host machine (a physical machine distributed with a client with read-write operation permission), at this time, the read-write operation initiated on the old host machine is rejected, and the new host machine has higher read-write permission.
The method comprises the following specific steps:
1. the method comprises the steps that a mounting request is processed by a block storage metadata service, whether a cloud disk corresponding to mounting operation meets mounting conditions is checked, wherein the conditions generally mean whether the cloud disk exists or not, whether the state of the cloud disk is normal or not, if yes, a version number is generated for the cloud disk, the version number starts from 1, if the cloud disk is already mounted, and a client (namely, a designated client) mounted at the time is not the same as a client (namely, a current client) mounted at the last time, the version number is added on the basis of the last mounting version number and is broadcasted to the block storage data service, after the broadcasting is completed, the metadata service replies the mounting request to the client mounted at the time, and the response carries the version number besides normal cloud disk metadata information. If the client mounted this time is the same as the client mounted last time, that is, the same client is mounted twice repeatedly, the last mounted version number is directly used for returning. Here, whether the comparison is the same client or not may be through the IP address of the client that is directly compared. And if the mounting condition is not met, directly replying that the mounting of the client fails.
2. And the client processes the mounting result, if the mounting is successful, the version number is stored to the local, and the read-write request carries the version number when the read-write operation of the cloud disk is initiated every time later.
3. When the block storage metadata service processes cloud disk reading and writing, the locally stored version number is compared with the version number carried in the request, if the locally stored version number is inconsistent with the version number carried in the request, the reading and writing request is refused, and if the client receives the error report, the multi-mount scene is found through checking and positioning, so that data reading and writing on an old host machine are cancelled, and subsequent reading and writing are initiated through a new host machine.
By adding the version number in the mounting operation and the reading and writing operation, only one client can read and write the cloud disk at any time under the condition that the cloud disk is allowed to be mounted more, so that the consistency of data is ensured.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art will recognize that the embodiments described in this specification are preferred embodiments and that acts or modules referred to are not necessarily required for this application.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., a ROM (Read-Only Memory)/RAM (Random Access Memory), a magnetic disk, an optical disk) and includes several instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the methods according to the embodiments of the present application.
According to another aspect of the embodiment of the present application, there is also provided an apparatus for controlling reading and writing of a cloud disk, which is used for implementing the above method for controlling reading and writing of a cloud disk. Fig. 4 is a block diagram of an alternative apparatus for controlling reading and writing of a cloud disk according to an embodiment of the present application, and as shown in fig. 4, the apparatus may include:
the system comprises an acquisition module 1, a storage module and a processing module, wherein the acquisition module is used for acquiring a specified client which needs to be mounted on a target cloud disk;
the mounting module 2 is used for mounting a specified client on a target cloud disk;
the determining module 3 is used for determining a target client from the designated client and the 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 designated client, wherein the current client is a client mounted on a target cloud disk at the current moment, and the target client is a client corresponding to the target permission information from the designated client and the current client;
and the read-write control module 4 is used for controlling the target cloud disk to only accept read-write operation from the target client.
It should be noted that the obtaining module 1 in this embodiment may be configured to execute the step S101, the mounting module 2 in this embodiment may be configured to execute the step S102, the determining module 3 in this embodiment may be configured to execute the step S103, and the read/write control module 4 in this embodiment may be configured to execute the step S104.
Through the module, the target cloud disk can only accept the read-write operation of the target client, so that the situation that the plurality of clients simultaneously perform the read-write operation on the target cloud disk after the target cloud disk is mounted to the plurality of clients can be avoided, and the problem that the correctness can not be ensured due to the read-write operation of the plurality of clients when the cloud disk is mounted in the related technology is solved; the beneficial effect of effectively guaranteeing the consistency of the data in the cloud disk is achieved.
It should be noted here that the modules described above are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the above embodiments. It should be noted that the modules described above as a part of the apparatus may be run in a hardware environment for implementing the method shown in fig. 1, and may be implemented by software or hardware, where the hardware environment includes a network environment.
According to another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the above method for controlling reading and writing of a cloud disk, where the electronic device may be a server, a terminal, or a combination thereof.
According to another embodiment of the present application, there is also provided an electronic apparatus including: as shown in fig. 5, the electronic device may include: the system comprises 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 complete communication with each other through the communication bus 1504.
A memory 1503 for storing a computer program;
the processor 1501, when executing the program stored in the memory 1503, implements the following steps:
step S101, acquiring a specified client needing to be mounted on a target cloud disk;
and step S102, mounting the specified client on the target cloud disk.
Step S103, determining target authority information with the highest priority level from the first authority information of the current client and the second authority information of the designated client, and determining the target client from the designated client and the current client, wherein the current client is the client mounted on the target cloud disk at the current moment, and the target client is the client corresponding to the target authority information from the designated client and the current client.
And step S104, controlling the target cloud disk to only accept read-write operation from the target client.
Alternatively, in the present embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this is not intended to represent only one bus or type of bus. The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The processor may be a general-purpose processor, and may include but is not limited to: a CPU (Central Processing Unit), an NP (Network Processor), and the like; but also a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
The embodiment of the present application further provides a computer-readable storage medium, where the storage medium includes a stored program, and when the program runs, the method steps of the above method embodiment are executed.
Optionally, in this embodiment, the storage medium may include, but is not limited to: a U disk, a ROM, a RAM, a removable hard disk, a magnetic disk, or an optical disk.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including instructions for causing one or more computer devices (which may be personal computers, servers, network devices, or the like) to execute all or part of the steps of the method described in the embodiments of the present application.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, and may also be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (10)

1. A method for controlling reading and writing of a cloud disk is characterized by comprising the following steps:
acquiring a specified client needing to be mounted on a target cloud disk;
mounting the specified client on the target cloud disk;
determining target authority information with the highest priority level from first authority information of a current client and second authority information of the specified client, and determining a target client from the specified client and the current client, wherein the current client is a client mounted on the target cloud disk at the current moment, and the target client is a client corresponding to the target authority information from the specified client and the current client;
and controlling the target cloud disk to only accept the read-write operation from the target client.
2. The method of claim 1, wherein before the determining a target client from the designated client and the current client by determining a target permission information with a highest priority from the first permission information of the current client and the second permission information of the designated client, the method further comprises:
determining a first version number as the first permission information and a first client identifier of the current client;
and determining a second client identification of the specified client.
3. The method of claim 2, wherein the determining a target client from the designated client and the current client by determining a target permission information with a highest priority from the first permission information of the current client and the second permission information of the designated client comprises:
under the condition that the first client identifier is different from the second client identifier and the version number corresponding to the second client identifier does not exist, updating the first version number according to a preset updating mode to obtain a second version number serving as the second permission information;
determining the designated client as the target client, and taking the second version number as the target permission information;
storing the corresponding relation between the second version number and the second client identifier;
transmitting the second version number to the specified client.
4. The method as claimed in claim 2, wherein the determining a target client from the designated client and the current client by determining a target permission information with the highest priority from the first permission information of the current client and the second permission information of the designated client comprises:
determining that the designated client is the same as the current client under the condition that the first client identifier is the same as the second client identifier;
and determining the current client as the target client, and returning the first version number to the current client.
5. The method of claim 1, wherein before the determining a target client from the designated client and the current client by determining a target permission information with a highest priority from the first permission information of the current client and the second permission information of the designated client, the method further comprises:
and acquiring a pre-generated black and white list corresponding to the target cloud disk, wherein the black list in the black and white list is used for indicating a client which forbids read-write operation on the target cloud disk, and the white list in the black and white list is used for indicating a client which allows the read-write operation on the target cloud disk.
6. The method as claimed in claim 5, wherein the determining a target client from the designated client and the current client by determining a target permission information with the highest priority from the first permission information of the current client and the second permission information of the designated client comprises:
determining a first client identification of the current client and a second client identification of the designated client;
the determining a target client from the designated 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 designated client comprises:
determining a target client identifier located in the white list from the first client identifier and the second client identifier, and determining authority information corresponding to the target client identifier as the target authority information;
and determining the client corresponding to the target client identification as the target client.
7. The method according to any one of claims 1 to 6, wherein before obtaining the specified client that needs to be mounted on the target cloud disk, the method further comprises:
acquiring a mounting request from the specified client;
determining cloud disk information in the mounting request;
when it is determined that the cloud disk indicated by the cloud disk information meets a preset available state, determining the cloud disk indicated by the cloud disk information as the target cloud disk;
the controlling the target cloud disk to only accept the read-write operation from the target client includes:
acquiring a read-write request of a pending client;
determining undetermined authority information carried in the read-write request;
under the condition that the undetermined authority information is determined to be the target authority information, determining the undetermined client to be the target client, and accepting the read-write operation of the target client to the target cloud disk;
and under the condition that the undetermined authority information is determined not to be the target authority information, refusing the read-write operation of the target client to the target cloud disk.
8. A method for controlling reading and writing of a cloud disk is characterized by comprising the following steps:
the acquisition module is used for acquiring a specified client which needs to be mounted on a target cloud disk;
the mounting module is used for mounting the specified client on the target cloud disk;
the determining module is used for determining a target client from the designated client and the 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 designated client, wherein the current client is a client mounted on the target cloud disk at the current moment, and the target client is a client corresponding to the target permission information from the designated client and the current client;
and the read-write control module is used for controlling the target cloud disk to only accept the read-write operation from the target client.
9. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein said processor, said communication interface and said memory communicate with each other via said communication bus,
the memory for storing a computer program;
the processor for performing the method steps of any one of claims 1 to 7 by running the computer program stored on the memory.
10. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to carry out the method steps of any one of claims 1 to 7 when executed.
CN202210873638.0A 2022-07-21 2022-07-21 Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium Pending CN115309327A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210873638.0A CN115309327A (en) 2022-07-21 2022-07-21 Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210873638.0A CN115309327A (en) 2022-07-21 2022-07-21 Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115309327A true CN115309327A (en) 2022-11-08

Family

ID=83859182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210873638.0A Pending CN115309327A (en) 2022-07-21 2022-07-21 Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115309327A (en)

Similar Documents

Publication Publication Date Title
CN110661658B (en) Node management method and device of block chain network and computer storage medium
CN109831494B (en) User data management method and device
CN106302609B (en) Access method and device
WO2020093976A1 (en) Resource change method and device, apparatus, and storage medium
CN112162825A (en) Equipment configuration method, device, equipment and storage medium
WO2020211362A1 (en) Method and apparatus for improving availability of trunking system, and computer device
CN110825400A (en) Certificate updating method and system for application program client
EP4006725A1 (en) Virtual machine migration processing and strategy generation method, apparatus and device, and storage medium
CN113810216A (en) Cluster fault switching method and device and electronic equipment
CN109783196B (en) Virtual machine migration method and device
CN115309327A (en) Method and device for controlling reading and writing of cloud disk, electronic equipment and storage medium
CN110688130A (en) Physical machine deployment method, physical machine deployment device, readable storage medium and electronic equipment
KR20200121657A (en) Apparatus and method for providing update of vehicle
CN112632032B (en) Data migration method and device, storage medium and terminal equipment
CN112822729B (en) Edge service switching method and edge management system
CN110765426A (en) Equipment permission setting method, device, equipment and computer storage medium
CN112702735A (en) Registration information service method, equipment and computer readable storage medium
CN114185602B (en) Starting method, device and terminal of operating system
CN112350856A (en) Distributed service sign-off method and equipment
CN117560285B (en) Intelligent control internet of things OTA upgrading method, client and server
CN110286956B (en) Plug-in operation method and device and electronic equipment
CN111159786B (en) Metadata protection method and device, electronic equipment and storage medium
CN115454780A (en) Memory health degree resetting method, device and equipment
CN117032819A (en) Cluster system deployment method, device, equipment and readable storage medium
CN116339781A (en) Upgrading method and device for internal software of virtual machine, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination