CN113419870A - Volume reading and writing method and device - Google Patents
Volume reading and writing method and device Download PDFInfo
- Publication number
- CN113419870A CN113419870A CN202110682333.7A CN202110682333A CN113419870A CN 113419870 A CN113419870 A CN 113419870A CN 202110682333 A CN202110682333 A CN 202110682333A CN 113419870 A CN113419870 A CN 113419870A
- Authority
- CN
- China
- Prior art keywords
- volume
- state
- response
- read
- write
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 61
- 230000004044 response Effects 0.000 claims abstract description 106
- 230000008859 change Effects 0.000 claims description 10
- 238000004590 computer program Methods 0.000 description 15
- 230000008569 process Effects 0.000 description 8
- 230000006870 function Effects 0.000 description 6
- 230000000694 effects Effects 0.000 description 5
- 230000004048 modification Effects 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 230000001960 triggered effect Effects 0.000 description 4
- 230000001360 synchronised effect Effects 0.000 description 3
- 230000009471 action Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 230000010076 replication Effects 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 238000000844 transformation Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000007704 transition Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5061—Partitioning or combining of resources
- G06F9/5077—Logical partitioning of resources; Management or configuration of virtualized resources
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a volume reading and writing method and a device, wherein the method comprises the following steps: in response to the volume being requested to perform a read operation and the volume being in the first state, allowing the read operation to be performed on the volume and switching the volume from the first state to the second state; switching the volume from the second state to the first state in response to the read operation for the volume being performed; in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state; switching the volume from the third state to the first state in response to the write operation being performed; denying the write operation request in response to the volume being in the second state; the read operation request and the write operation request are denied in response to the volume being in the third state. The invention can avoid the data inconsistency caused by using the exclusive lock and maintain the data consistency.
Description
Technical Field
The present invention relates to the field of data reading and writing, and more particularly, to a volume reading and writing method and apparatus.
Background
In virtualization and data scenarios, more and more users choose to use distributed block storage, and the exclusive lock feature of a volume is a mechanism for protecting the consistency of volume data, and the lock needs to be held when a modification is made to the volume. The exclusive lock is a distributed lock, and is realized by defaulting to acquiring the lock when a client writes for the first time and automatically releasing the lock when a lock request of other clients is received, so that the aim of preventing a plurality of processes from accessing the same device in an uncoordinated mode is fulfilled, the exclusive lock is largely used in virtualization, and the exclusive lock can prevent virtual machines from re-clicking on the write operation of each other.
However, it is entirely possible for two or more concurrently running processes to only open a book, from which data can also be read. The client acquires the exclusive lock only when attempting to write to the volume. In this way, there may be a problem of data inconsistency for some operations and scenarios of the volume, for example, a source volume is rolled back in the process of volume copy, that is, the source volume is copied to a target volume, because only a read action is performed on the source volume, an exclusive lock does not need to be acquired, and at this time, a roll back operation is performed on the source volume, the exclusive lock is not occupied, and the exclusive lock is allowed to be acquired, which causes the data inconsistency to roll back while copying.
In order to solve the problem that data inconsistency may be caused by exclusive lock of data in the prior art, no effective solution exists at present.
Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a volume read-write method and apparatus, which can avoid data inconsistency caused by using an exclusive lock, and maintain data consistency.
Based on the above object, a first aspect of the embodiments of the present invention provides a volume read-write method, including the following steps:
in response to the volume being requested to perform a read operation and the volume being in the first state, allowing the read operation to be performed on the volume and switching the volume from the first state to the second state;
switching the volume from the second state to the first state in response to the read operation for the volume being performed;
in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state;
switching the volume from the third state to the first state in response to the write operation being performed;
the write operation request is denied in response to the volume being in the second state, and the read operation request and the write operation request are denied in response to the volume being in the third state.
In some embodiments, the method further comprises performing the steps of:
the volume initialization is marked as being in the first state in response to the volume being created.
In some embodiments, the method further comprises performing the steps of:
the read operation is permitted to be performed on the volume in response to the volume being requested to perform the read operation and the volume being in the second state.
In some embodiments, completing the read operation for the volume comprises: all read operations for the volume are performed.
In some embodiments, denying the write operation request in response to the volume being in the second state comprises: rejecting all write operation requests; denying the read operation request and the write operation request in response to the volume being in the third state includes: all read operation requests and all write operation requests are denied.
In some embodiments, the roll comprises a first roll and a second roll.
In some embodiments, copying data from a first volume to a second volume is included by performing the following steps:
reading data from the first volume and switching the first volume to the second state in response to the first volume being in the first state or the second state;
in response to the data being read and all read operations for the first volume being performed, switching the first volume to a first state;
in response to the second volume being in the first state, writing data to the second volume and switching the second volume to a third state;
the second volume is switched to the first state in response to the data having been written.
In some embodiments, further comprising: denying the data write request to the first volume in response to the first volume being in the second state; in response to the second volume being in the third state, data read requests and data write requests for the second volume are denied.
In some embodiments, read operations include operations that do not change the data within the volume; write operations include operations that change data within a volume.
A second aspect of an embodiment of the present invention provides an apparatus, including:
a processor;
a controller storing program code executable by a processor, the processor executing the following steps when executing the program code:
in response to the volume being requested to perform a read operation and the volume being in the first state, allowing the read operation to be performed on the volume and switching the volume from the first state to the second state;
switching the volume from the second state to the first state in response to the read operation for the volume being performed;
in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state;
switching the volume from the third state to the first state in response to the write operation being performed;
the write operation request is denied in response to the volume being in the second state and the read operation request and the write operation request are denied in response to the volume being in the third state.
In some embodiments, further comprising performing the steps of:
the volume initialization is marked as being in the first state in response to the volume being created.
In some embodiments, further comprising performing the steps of:
the read operation is permitted to be performed on the volume in response to the volume being requested to perform the read operation and the volume being in the second state.
In some embodiments, completing the read operation for the volume comprises: all read operations for the volume are performed.
In some embodiments, denying the write operation request in response to the volume being in the second state comprises: rejecting all write operation requests; denying the read operation request and the write operation request in response to the volume being in the third state includes: all read operation requests and all write operation requests are denied.
In some embodiments, the roll comprises a first roll and a second roll.
In some embodiments, copying data from a first volume to a second volume is included by performing the following steps:
reading data from the first volume and switching the first volume to the second state in response to the first volume being in the first state or the second state;
in response to the data being read and all read operations for the first volume being performed, switching the first volume to a first state;
in response to the second volume being in the first state, writing data to the second volume and switching the second volume to a third state;
the second volume is switched to the first state in response to the data having been written.
In some embodiments, the steps further comprise: denying the data write request to the first volume in response to the first volume being in the second state; in response to the second volume being in the third state, data read requests and data write requests for the second volume are denied.
In some embodiments, read operations include operations that do not change the data within the volume; write operations include operations that change data within a volume.
The invention has the following beneficial technical effects: according to the volume reading and writing method and device provided by the embodiment of the invention, the volume is allowed to be read and switched from the first state to the second state by responding to the fact that the volume is requested to be read and the volume is in the first state; switching the volume from the second state to the first state in response to the read operation for the volume being performed; in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state; switching the volume from the third state to the first state in response to the write operation being performed; denying the write operation request in response to the volume being in the second state; the technical scheme of refusing the read operation request and the write operation request in response to the volume being in the third state can avoid data inconsistency caused by using an exclusive lock and maintain data consistency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of a volume read/write method according to the present invention;
FIG. 2 is a volume state transition diagram of a volume read/write method according to the present invention;
FIG. 3 is a detailed flow chart of data replication of the volume read/write method provided by the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and they are not described in any more detail in the following embodiments.
In view of the foregoing, a first aspect of the embodiments of the present invention provides an embodiment of a volume read-write method for maintaining data consistency by avoiding data inconsistency caused by using an exclusive lock. Fig. 1 is a schematic flow chart of a volume read-write method provided by the present invention.
The volume read-write method, as shown in fig. 1, includes the following steps:
a step S101, in response to the volume being requested to perform a read operation and the volume being in the first state, allowing the read operation to be performed on the volume and switching the volume from the first state to the second state;
step S103, in response to the completion of the read operation on the volume, switching the volume from the second state to the first state;
step S105, in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed on the volume and switching the volume from the first state to a third state;
step S107, responding to the completion of the write operation, and switching the volume from the third state to the first state;
step S109 rejects the write operation request in response to the volume being in the second state, and rejects the read operation request and the write operation request in response to the volume being in the third state.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like. Embodiments of the computer program may achieve the same or similar effects as any of the preceding method embodiments to which it corresponds.
In some embodiments, the method further comprises performing the steps of:
the volume initialization is marked as being in the first state in response to the volume being created.
In some embodiments, the method further comprises performing the steps of:
the read operation is permitted to be performed on the volume in response to the volume being requested to perform the read operation and the volume being in the second state.
In some embodiments, completing the read operation for the volume comprises: all read operations for the volume are performed.
In some embodiments, denying the write operation request in response to the volume being in the second state comprises: rejecting all write operation requests; denying the read operation request and the write operation request in response to the volume being in the third state includes: all read operation requests and all write operation requests are denied.
The various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
In some embodiments, the roll comprises a first roll and a second roll.
In some embodiments, copying data from a first volume to a second volume is included by performing the following steps:
reading data from the first volume and switching the first volume to the second state in response to the first volume being in the first state or the second state;
in response to the data being read and all read operations for the first volume being performed, switching the first volume to a first state;
in response to the second volume being in the first state, writing data to the second volume and switching the second volume to a third state;
the second volume is switched to the first state in response to the data having been written.
In some embodiments, the data write request to the first volume is denied in response to the first volume being in the second state; in response to the second volume being in the third state, data read requests and data write requests for the second volume are denied.
In some embodiments, read operations include operations that do not change the data within the volume; write operations include operations that change data within a volume.
The computer-readable storage media (e.g., memory) described herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which can act as external cache memory. By way of example and not limitation, RAM is available in a variety of forms such as synchronous RAM (DRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
Referring to fig. 2, the present invention adds volume operations related to data classes, such as volume copy, rollback, import, export, etc., to a state machine for management, and its specific idea is: after the volume is created, the volume state is a normal state (namely, a first state), operations related to reading data are performed on the volume, such as copying a source volume, changing the state of the source volume into a read state (namely, a second state), and after the reading is finished, changing the state into the normal state; operations involving writing data to a volume, such as copying source volume data to a target volume, require setting the target volume state to the write state (i.e., the third state), and modifying the target volume state to the normal state after copying is complete.
When the concurrent volume operation is performed again, if the volume state is judged to be normal, the operation can be continuously executed no matter what operation is performed; if the volume state is judged to be a read state, the volume state needing to be set and the current state of the volume are judged to be read continuously, and the execution can be continued; if the state of the volume is judged to be write, the return fails regardless of whether the state to be set is read or write, and the volume can be continuously executed when the state of the volume is normal or read, so that the data consistency of the volume operation is ensured.
The following further illustrates an embodiment of the present invention in accordance with the embodiment shown in fig. 3. Fig. 3 shows a flow of volume replication, in which fig. 3 the source volume is a first volume and the target volume is a second volume.
If the volume copy is reading the source volume, at this time, the roll-back operation of the source volume is triggered, the state of the volume at this time is judged as read, and if the volume state needing to be set is judged as write, the direct return fails, and the roll-back is not allowed.
If the volume copy is reading the source volume, the source volume read operation is triggered, the state of the volume is judged to be read first, and the volume state required to be set is judged to be read, and the operation can be continued.
If the volume copy is writing the target volume, at this time, the source volume rollback operation is triggered, and it is first determined that the state of the source volume is normal, at this time, the source volume may continue to be rolled back.
If the volume copy is writing the target volume, at this time, the write operation of the target volume is triggered, and the state of the target volume is determined to be write first, and the write modification of the target volume is not allowed.
Note that rollback is one type of write operation, but in practice write operations herein are limited to rollback, which is just one example for the case shown in fig. 3.
Furthermore, the method disclosed according to an embodiment of the present invention may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. The computer program, when executed by the CPU, performs the above-described functions defined in the method disclosed in the embodiments of the present invention. The above-described method steps and system elements may also be implemented using a controller and a computer-readable storage medium for storing a computer program for causing the controller to implement the functions of the above-described steps or elements.
As can be seen from the foregoing embodiments, the volume read-write method provided by an embodiment of the present invention allows a read operation to be performed on a volume and switches the volume from a first state to a second state by responding to a request for the volume to perform the read operation and the volume is in the first state; switching the volume from the second state to the first state in response to the read operation for the volume being performed; in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state; switching the volume from the third state to the first state in response to the write operation being performed; denying the write operation request in response to the volume being in the second state; the technical scheme of refusing the read operation request and the write operation request in response to the volume being in the third state can avoid data inconsistency caused by using an exclusive lock and maintain data consistency.
It should be particularly noted that, the steps in the embodiments of the volume reading and writing method described above can be mutually intersected, replaced, added, or deleted, so that these reasonable permutation and combination transformations should also belong to the scope of the present invention, and should not limit the scope of the present invention to the described embodiments.
In view of the foregoing, a second aspect of the embodiments of the present invention provides an embodiment of a volume read/write apparatus for maintaining data consistency by avoiding data inconsistency caused by using an exclusive lock.
The device comprises:
a processor;
a controller storing program code executable by a processor, the processor executing the following steps when executing the program code:
in response to the volume being requested to perform a read operation and the volume being in the first state, allowing the read operation to be performed on the volume and switching the volume from the first state to the second state;
switching the volume from the second state to the first state in response to the read operation for the volume being performed;
in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state;
switching the volume from the third state to the first state in response to the write operation being performed;
the write operation request is denied in response to the volume being in the second state, and the read operation request and the write operation request are denied in response to the volume being in the third state.
The steps of a method or algorithm described in connection with the disclosure herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In the alternative, the processor and the storage medium may reside as discrete components in a user terminal.
In some embodiments, further comprising performing the steps of:
the volume initialization is marked as being in the first state in response to the volume being created.
In some embodiments, further comprising performing the steps of:
the read operation is permitted to be performed on the volume in response to the volume being requested to perform the read operation and the volume being in the second state.
In some embodiments, completing the read operation for the volume comprises: all read operations for the volume are performed.
In some embodiments, denying the write operation request in response to the volume being in the second state comprises: rejecting all write operation requests; denying the read operation request and the write operation request in response to the volume being in the third state includes: all read operation requests and all write operation requests are denied.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
In some embodiments, the roll comprises a first roll and a second roll.
In some embodiments, copying data from a first volume to a second volume comprises performing the following steps
Reading data from the first volume and switching the first volume to the second state in response to the first volume being in the first state or the second state;
in response to the data being read and all read operations for the first volume being performed, switching the first volume to a first state;
in response to the second volume being in the first state, writing data to the second volume and switching the second volume to a third state;
the second volume is switched to the first state in response to the data having been written.
In some embodiments, the steps further comprise: denying the data write request to the first volume in response to the first volume being in the second state; in response to the second volume being in the third state, data read requests and data write requests for the second volume are denied.
In some embodiments, read operations include operations that do not change the data within the volume; write operations include operations that change data within a volume.
The apparatuses and devices disclosed in the embodiments of the present invention may be various electronic terminal devices, such as a mobile phone, a Personal Digital Assistant (PDA), a tablet computer (PAD), a smart television, and the like, or may be a large terminal device, such as a server, and therefore the scope of protection disclosed in the embodiments of the present invention should not be limited to a specific type of apparatus and device. The client disclosed in the embodiment of the present invention may be applied to any one of the above electronic terminal devices in the form of electronic hardware, computer software, or a combination of both.
As can be seen from the foregoing embodiments, the volume read-write apparatus according to an embodiment of the present invention allows a read operation to be performed on a volume and switches the volume from a first state to a second state by responding to a request for the volume to perform the read operation and the volume being in the first state; switching the volume from the second state to the first state in response to the read operation for the volume being performed; in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed to the volume and switching the volume from the first state to a third state; switching the volume from the third state to the first state in response to the write operation being performed; denying the write operation request in response to the volume being in the second state; the technical scheme of refusing the read operation request and the write operation request in response to the volume being in the third state can avoid data inconsistency caused by using an exclusive lock and maintain data consistency.
It should be particularly noted that the above-mentioned embodiment of the apparatus adopts the embodiment of the volume reading and writing method to specifically describe the working process of each module, and those skilled in the art can easily think that these modules are applied to other embodiments of the volume reading and writing method. Of course, since the steps in the embodiment of the volume reading and writing method may be mutually intersected, replaced, added, and deleted, these reasonable permutation and combination transformations should also belong to the scope of the present invention, and should not limit the scope of the present invention to the embodiment.
The embodiment of the invention also can comprise corresponding computer equipment. The computer device comprises a memory, at least one processor and a computer program stored on the memory and executable on the processor, the processor performing any of the above methods when executing the program.
The memory, as a non-volatile computer-readable storage medium, may be used to store a non-volatile software program, a non-volatile computer-executable program, and modules, such as program instructions/modules corresponding to the volume reading and writing method in the embodiments of the present application. The processor executes various functional applications and data processing of the server by running the nonvolatile software program, instructions and modules stored in the memory, that is, the volume read-write method of the above method embodiment is realized.
The memory may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created from use of the volume read-write apparatus, and the like. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and such remote memory may be coupled to the local module via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The embodiment of the present invention may further include a corresponding computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions may execute the volume reading and writing method in any of the above method embodiments and implement the volume reading and writing apparatus in any of the above apparatus embodiments. Embodiments of the computer-readable storage medium may achieve the same or similar effects as any of the aforementioned method and apparatus embodiments corresponding thereto.
Embodiments of the present invention may also include a corresponding computer program product, where the computer program product includes a computer program stored on a computer-readable storage medium, where the computer program includes instructions that, when executed by a computer, cause the computer to execute the volume read-write method in any of the above method embodiments and the volume read-write apparatus implementing any of the above apparatus embodiments. Embodiments of the computer program product may achieve the same or similar effects as any of the aforementioned method and apparatus embodiments corresponding thereto.
Finally, it should be noted that, as will be understood by those skilled in the art, all or part of the processes of the methods of the above embodiments may be implemented by a computer program, which may be stored in a computer-readable storage medium, and when executed, may include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like. Embodiments of the computer program may achieve the same or similar effects as any of the preceding method embodiments to which it corresponds.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of an embodiment of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.
Claims (10)
1. A volume read-write method, comprising performing the steps of:
in response to a volume being requested to perform a read operation and the volume being in a first state, allowing the read operation to be performed on the volume and switching the volume from the first state to a second state;
switching the volume from the second state to the first state in response to the read operation for the volume being performed;
in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed on the volume and switching the volume from the first state to a third state;
switching the volume from the third state to the first state in response to the write operation being performed;
denying write requests in response to the volume being in the second state, and denying read and write requests in response to the volume being in the third state.
2. The method of claim 1, further comprising performing the steps of:
in response to the volume being created, the volume initialization is marked as being in the first state.
3. The method of claim 1, further comprising performing the steps of:
in response to the volume being requested to perform a read operation and the volume being in the second state, allowing the read operation to be performed on the volume.
4. The method of claim 1, wherein completing the read operation for the volume comprises: all read operations for the volume are performed.
5. The method of claim 1, wherein denying a write operation request in response to the volume being in the second state comprises: rejecting all write operation requests;
denying the read operation request and the write operation request in response to the volume being in the third state comprises: all read operation requests and all write operation requests are denied.
6. The method of claim 1, wherein the roll comprises a first roll and a second roll.
7. The method of claim 6, comprising copying data from the first volume to the second volume by performing the steps of:
reading data from the first volume and switching the first volume to the second state in response to the first volume being in the first state or the second state;
switching the first volume to the first state in response to the data having been read and all read operations for the first volume having been performed;
in response to the second volume being in the first state, writing data to the second volume and switching the second volume to the third state;
switching the second volume to the first state in response to the data having been written.
8. The method of claim 7, further comprising: denying a data write request to the first volume in response to the first volume being in the second state; denying data read requests and data write requests for the second volume in response to the second volume being in the third state.
9. The method of claim 1, wherein a read operation comprises an operation that does not change data within the volume; write operations include operations that change data within the volume.
10. A volume read-write apparatus, comprising:
a processor;
a controller storing program code executable by the processor, the processor executing the following steps when executing the program code:
in response to a volume being requested to perform a read operation and the volume being in a first state, allowing the read operation to be performed on the volume and switching the volume from the first state to a second state;
switching the volume from the second state to the first state in response to the read operation for the volume being performed;
in response to the volume being requested to perform a write operation and the volume being in the first state, allowing the write operation to be performed on the volume and switching the volume from the first state to a third state;
switching the volume from the third state to the first state in response to the write operation being performed;
denying write requests in response to the volume being in the second state, and denying read and write requests in response to the volume being in the third state.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110682333.7A CN113419870A (en) | 2021-06-20 | 2021-06-20 | Volume reading and writing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110682333.7A CN113419870A (en) | 2021-06-20 | 2021-06-20 | Volume reading and writing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113419870A true CN113419870A (en) | 2021-09-21 |
Family
ID=77789217
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110682333.7A Pending CN113419870A (en) | 2021-06-20 | 2021-06-20 | Volume reading and writing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113419870A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118093730A (en) * | 2024-04-29 | 2024-05-28 | 济南浪潮数据技术有限公司 | Data double-writing method, device, computer equipment and program product |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1645335A (en) * | 2003-06-18 | 2005-07-27 | 国际商业机器公司 | Method, system, and article of manufacture for consistent copying of storage volumes |
CN107832097A (en) * | 2017-09-29 | 2018-03-23 | 华为技术有限公司 | Data load method and device |
CN108572876A (en) * | 2018-03-07 | 2018-09-25 | 北京神州绿盟信息安全科技股份有限公司 | A kind of implementation method and device of Read-Write Locks |
-
2021
- 2021-06-20 CN CN202110682333.7A patent/CN113419870A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1645335A (en) * | 2003-06-18 | 2005-07-27 | 国际商业机器公司 | Method, system, and article of manufacture for consistent copying of storage volumes |
CN107832097A (en) * | 2017-09-29 | 2018-03-23 | 华为技术有限公司 | Data load method and device |
CN108572876A (en) * | 2018-03-07 | 2018-09-25 | 北京神州绿盟信息安全科技股份有限公司 | A kind of implementation method and device of Read-Write Locks |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118093730A (en) * | 2024-04-29 | 2024-05-28 | 济南浪潮数据技术有限公司 | Data double-writing method, device, computer equipment and program product |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110427342B (en) | Method, equipment and readable medium for creating mirror library | |
CN110096306B (en) | Application version switching method and device, electronic equipment and storage medium | |
CN108255542B (en) | Serial port and parallel port control method and device of virtual machine | |
CN111240595A (en) | Method, system, equipment and medium for optimizing storage cache | |
CN111352586B (en) | Directory aggregation method, device, equipment and medium for accelerating file reading and writing | |
CN113535708A (en) | Data deduplication method, system, storage medium and equipment | |
CN111581126A (en) | Method, device, equipment and medium for saving log data based on SSD | |
CN110780994A (en) | Method, equipment and medium for regulating and controlling memory | |
CN111737201B (en) | Method for closing opened file, computer equipment and storage medium | |
CN115586933A (en) | Computer startup method, system, equipment, medium and shutdown method | |
CN113419870A (en) | Volume reading and writing method and device | |
CN111309264B (en) | Method, system, device and medium for making directory quota compatible with snapshot | |
CN111708482B (en) | Method, system, device and medium for limiting bandwidth in distributed storage | |
CN111857571B (en) | Solid state disk physical block address distribution method, device, equipment and storage medium | |
CN111291007B (en) | File aggregation method, system, device and medium | |
CN108399076A (en) | A kind of firmware update and device based on UEFI | |
CN111723140A (en) | Method, device and equipment for user to access storage and readable medium | |
CN111581133A (en) | Method, system, equipment and readable medium for multi-core memory consistency | |
CN109240621B (en) | Nonvolatile internal memory management method and device | |
CN114546286B (en) | Method, system, storage medium and equipment for selecting members of homing group | |
WO2020215211A1 (en) | Site session termination method and apparatus, terminal device and medium | |
CN113626089B (en) | Data operation method, system, medium and device based on BIOS (basic input output system) | |
CN111858538B (en) | Method, device, equipment and medium for configuring BeeGFS quota by cluster | |
CN111722959B (en) | Method, system, equipment and medium for expanding storage pool | |
CN111355716B (en) | Method, system, equipment and medium for determining unique identifier of virtual machine |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210921 |