[go: up one dir, main page]

CN103853497A - Disk mirror image block adjusting method, disk mirror image building method and relevant device - Google Patents

Disk mirror image block adjusting method, disk mirror image building method and relevant device Download PDF

Info

Publication number
CN103853497A
CN103853497A CN201210504938.8A CN201210504938A CN103853497A CN 103853497 A CN103853497 A CN 103853497A CN 201210504938 A CN201210504938 A CN 201210504938A CN 103853497 A CN103853497 A CN 103853497A
Authority
CN
China
Prior art keywords
disk image
block size
disk
capacity
instruction
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
CN201210504938.8A
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201210504938.8A priority Critical patent/CN103853497A/en
Publication of CN103853497A publication Critical patent/CN103853497A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

本发明实施例公开了磁盘镜像的块调整方法和磁盘镜像创建方法及相关设备。其中。一种磁盘镜像的块调整方法,包括:接收对第一磁盘镜像块大小的调整指令;创建第二磁盘镜像,其中,第二磁盘镜像的块大小为调整指令所指示的块大小;向第二磁盘镜像拷贝第一磁盘镜像中存储的数据,本发明技术方案有利于提高磁盘镜像的数据读写性能和存储空间利用率。

The embodiment of the invention discloses a disk image block adjustment method, a disk image creation method and related equipment. in. A block adjustment method of a disk image, comprising: receiving an adjustment instruction to a block size of a first disk image; creating a second disk image, wherein the block size of the second disk image is the block size indicated by the adjustment instruction; The disk image copies the data stored in the first disk image, and the technical solution of the present invention is beneficial to improving the data read-write performance and storage space utilization rate of the disk image.

Description

磁盘镜像的块调整方法和磁盘镜像创建方法及相关设备Disk image block adjustment method, disk image creation method and related equipment

技术领域technical field

本发明涉及计算机技术领域,具体涉及磁盘镜像的块调整方法和磁盘镜像创建方法及相关设备。The invention relates to the technical field of computers, in particular to a disk image block adjustment method, a disk image creation method and related equipment.

背景技术Background technique

虚拟化技术是一种将底层硬件设备与上层操作系统、应用程序分离的去耦合技术,参见图1,引入虚拟机监控器(VMM,Virtual Machine Monitor)层直接管理底层硬件资源,创建与硬件无关的虚拟机(VM,Virtual Machine)供上层操作系统和应用程序使用。Virtualization technology is a decoupling technology that separates underlying hardware devices from upper-layer operating systems and applications. See Figure 1. The virtual machine monitor (VMM, Virtual Machine Monitor) layer is introduced to directly manage underlying hardware resources, creating hardware-independent The virtual machine (VM, Virtual Machine) is used by the upper operating system and applications.

通过虚拟机软件可以在一台物理计算机上模拟出一台或者多台虚拟的计算机,即VM,而这些VM就像真正的计算机那样进行工作,VM上可以安装操作系统和应用程序,VM还可访问网络资源。对于在VM中运行的应用程序而言,VM就像是在真正的计算机中进行工作。虚拟化技术作为当前流行的云计算(Cloud Computing)平台的底层重要支撑技术之一,可以极大的提高物理设备的资源使用效率。与传统的物理计算机相比,VM具有更好的隔离性和封装性,One or more virtual computers, namely VMs, can be simulated on a physical computer through virtual machine software, and these VMs work like real computers. Operating systems and applications can be installed on VMs, and VMs can also Access network resources. To the applications running in the VM, the VM is like working on a real computer. Virtualization technology, as one of the underlying important supporting technologies of the popular cloud computing (Cloud Computing) platform, can greatly improve the resource utilization efficiency of physical devices. Compared with traditional physical computers, VM has better isolation and encapsulation,

磁盘镜像(disk image)是存放着代表一个存储介质或设备的全部内容和结构的单独文件,针对源存储介质进行扇区到扇区的拷贝,并能够完美地复制设备的结构和内容。虚拟化软件通过相应的磁盘驱动程序将对应的磁盘镜像映射为虚拟机的磁盘,VM运行过程中所有对VM内部文件的读写都可被驱动最终转换为对磁盘镜像的读写。磁盘镜像中除包含存储介质或设备的全部数据外,还包含元数据(Metadata),其中,Metadata被定义为数据的1个或多个方面的信息提供,描述数据的数据(data about data),如数据的创建时间、创建者和数据含义等等,用于自身数据管理,实现驱动程序对磁盘镜像的快速数据读取、更高级的存储特性实现。在虚拟化平台下结合驱动程序使用磁盘镜像,可以实现瘦分配、快照等高级特性。在磁盘镜像中存储区域以块的形式划分,每个块可对应若干个扇区。A disk image (disk image) is a separate file that stores all the content and structure of a storage medium or device. It performs sector-to-sector copying of the source storage medium and can perfectly replicate the structure and content of the device. The virtualization software maps the corresponding disk image to the disk of the virtual machine through the corresponding disk driver. During the running of the VM, all reads and writes to the internal files of the VM can be converted into reads and writes to the disk image by the driver. In addition to all the data of the storage medium or device, the disk image also contains metadata (Metadata), where Metadata is defined as the information provision of one or more aspects of the data, and the data describing the data (data about data), Such as data creation time, creator and data meaning, etc., are used for its own data management, to realize the fast data reading of the disk image by the driver, and the realization of more advanced storage features. Using disk mirroring in conjunction with drivers under the virtualization platform can implement advanced features such as thin allocation and snapshots. The storage area in the disk image is divided in the form of blocks, and each block can correspond to several sectors.

现有主流的磁盘镜像技术对于块大小都是统一固定的。本发明的发明人在研究和实践过程中发现,磁盘镜像采用统一固定的块大小,在有些场景下会影响到磁盘镜像的数据读写性能,在有些场景还会影响存储空间的利用率。The existing mainstream disk mirroring technology has a unified fixed block size. In the process of research and practice, the inventors of the present invention found that the disk mirroring adopts a uniform and fixed block size, which will affect the data read and write performance of the disk mirroring in some scenarios, and also affect the utilization rate of storage space in some scenarios.

发明内容Contents of the invention

本发明实施例提供磁盘镜像的块调整方法和磁盘镜像创建方法及相关设备,以期提高磁盘镜像的数据读写性能和存储空间利用率。Embodiments of the present invention provide a method for adjusting blocks of a disk image, a method for creating a disk image, and related equipment, in order to improve the data read and write performance and storage space utilization of the disk image.

本发明第一方面提供一种磁盘镜像的块调整方法,包括:The first aspect of the present invention provides a block adjustment method for disk mirroring, including:

接收对第一磁盘镜像块大小的调整指令;receiving an adjustment instruction to the size of the first disk image block;

创建第二磁盘镜像,其中,所述第二磁盘镜像的块大小为所述调整指令所指示的块大小;Create a second disk image, wherein the block size of the second disk image is the block size indicated by the adjustment instruction;

向所述第二磁盘镜像拷贝所述第一磁盘镜像中存储的数据。Copying the data stored in the first disk image to the second disk image.

结合第一方面,在第一种可能的实施方式中,With reference to the first aspect, in a first possible implementation manner,

所述接收对第一磁盘镜像块大小的调整指令之前还包括:Before receiving the instruction for adjusting the size of the first disk image block, it also includes:

接收磁盘镜像创建指令;创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系;receiving a disk image creation instruction; creating a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the capacity satisfy preset correspondence;

或者,or,

接收磁盘镜像创建指令;创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示块大小。Receive a disk image creation instruction; create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the disk image creation instruction The indicated block size.

结合第一方面或第一方面的第一种可能的实施方式,在第二种可能的实施方式中,若所述第一磁盘镜像的容量等于S字节,则所述第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,所述n和m为正整数。With reference to the first aspect or the first possible implementation manner of the first aspect, in the second possible implementation manner, if the capacity of the first disk image is equal to S bytes, the blocks of the first disk image The size is equal to 2 m bytes, where 2 n-1 <S≤2 n , 9≤m≤n-17, where n and m are positive integers.

结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式,在第三种可能的实施方式中,所述接收对第一磁盘镜像块大小的调整指令之后还包括:在所述第一磁盘镜像关闭之前,若接收到指示向所述第一磁盘镜像写入第一数据的写操作指令,且还未向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据,则向所述第一磁盘镜像和所述第二磁盘镜像分别写入所述第一数据。With reference to the first aspect or the first possible implementation manner of the first aspect or the second possible implementation manner of the first aspect, in a third possible implementation manner, the receiving After the adjustment instruction, it also includes: before the first disk image is closed, if a write operation instruction indicating to write the first data to the first disk image is received, and the first data has not been copied to the second disk image If the data stored in the first disk image is used, the first data is respectively written to the first disk image and the second disk image.

结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种可能的实施方式或第一方面的第三种可能的实施方式,在第四种可能的实施方式中,在第一虚拟机关机时,其中,所述第一虚拟机为使用所述第一磁盘镜像的虚拟机,若已经向所述第二磁盘镜像拷贝完了所述第一磁盘镜像中存储的数据,则关闭所述第二磁盘镜像;若还未向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据,则可在向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据之后,关闭所述第二磁盘镜像。In combination with the first aspect or the first possible implementation manner of the first aspect or the second possible implementation manner of the first aspect or the third possible implementation manner of the first aspect, in the fourth possible implementation manner , when the first virtual machine is shut down, wherein the first virtual machine is a virtual machine using the first disk image, if the data stored in the first disk image has been copied to the second disk image , then close the second disk image; if the data stored in the first disk image has not been copied to the second disk image, the first disk can be copied to the second disk image After mirroring the stored data, turn off the second disk mirror.

本发明第二方面提供一种磁盘镜像创建方法,包括:A second aspect of the present invention provides a method for creating a disk image, including:

接收磁盘镜像创建指令;Receive a disk image creation instruction;

创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系。Create a first disk image, where the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the capacity satisfy a preset corresponding relationship.

结合第二方面,在第一种可能的实施方式中,With reference to the second aspect, in a first possible implementation manner,

若所述第一磁盘镜像的容量等于S字节,则所述第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,所述n和m为正整数。If the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2 n-1 <S≤2 n , 9≤m≤n-17, Wherein, said n and m are positive integers.

本发明第三方面提供一种磁盘镜像创建方法,包括:A third aspect of the present invention provides a method for creating a disk image, including:

接收磁盘镜像创建指令;Receive a disk image creation instruction;

创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示的块大小。Create a first disk image, where the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the block size indicated by the disk image creation instruction.

本发明第四方面提供一种磁盘镜像的块调整装置,可包括:A fourth aspect of the present invention provides a block adjustment device for disk mirroring, which may include:

接收单元,接收对第一磁盘镜像块大小的调整指令;The receiving unit receives an instruction for adjusting the size of the first disk image block;

创建单元,创建第二磁盘镜像,其中,所述第二磁盘镜像的块大小为所述调整指令所指示的块大小;The creating unit is configured to create a second disk image, where the block size of the second disk image is the block size indicated by the adjustment instruction;

数据转移单元,用于向所述第二磁盘镜像拷贝所述第一磁盘镜像中存储的数据。A data transfer unit, configured to copy the data stored in the first disk image to the second disk image.

结合第四方面,在第一种可能的实施方式中,With reference to the fourth aspect, in a first possible implementation manner,

所述接收单元还用于,接收对第一磁盘镜像块大小的调整指令之前接收磁盘镜像创建指令;所述创建单元还用于,创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系。The receiving unit is also used to receive a disk image creation instruction before receiving an instruction to adjust the block size of the first disk image; the creation unit is also used to create a first disk image, wherein the capacity of the first disk image For the capacity indicated by the disk image creation instruction, the block size of the first disk image and the capacity satisfy a preset corresponding relationship.

或者,or,

所述接收单元还用于,接收对第一磁盘镜像块大小的调整指令之前接收磁盘镜像创建指令;所述创建单元还用于,创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示块大小。The receiving unit is also used to receive a disk image creation instruction before receiving an instruction to adjust the block size of the first disk image; the creation unit is also used to create a first disk image, wherein the capacity of the first disk image The capacity indicated by the disk image creation instruction, the block size of the first disk image is the block size indicated by the disk image creation instruction.

结合第四方面或第四方面的第一种可能的实施方式,在第二种可能的实施方式中,所述装置还包括:With reference to the fourth aspect or the first possible implementation manner of the fourth aspect, in a second possible implementation manner, the device further includes:

数据读写单元,用于在所述接收单元接收对第一磁盘镜像块大小的调整指令之后,且在所述第一磁盘镜像关闭之前,若接收到指示向所述第一磁盘镜像写入第一数据的写操作指令,且还未向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据,则向所述第一磁盘镜像和所述第二磁盘镜像分别写入所述第一数据。The data reading and writing unit is configured to, after the receiving unit receives an instruction to adjust the size of the first disk image block and before the first disk image is closed, if an instruction is received to write the first disk image to the first disk image A data write operation command, and the data stored in the first disk image has not been copied to the second disk image, then write the first disk image and the second disk image respectively to the first data.

本发明第五方面提供一种磁盘镜像创建装置,可包括:A fifth aspect of the present invention provides a device for creating a disk image, which may include:

接收单元,用于接收磁盘镜像创建指令;a receiving unit, configured to receive a disk image creation instruction;

创建单元,用于创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系。The creation unit is configured to create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the capacity meet a predetermined requirement. The corresponding relationship is set.

结合第五方面,在第一种可能的实施方式中,With reference to the fifth aspect, in a first possible implementation manner,

若所述第一磁盘镜像的容量等于S字节,则所述第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,所述n和m为正整数。If the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2 n-1 <S≤2 n , 9≤m≤n-17, Wherein, said n and m are positive integers.

本发明第六方面提供一种磁盘镜像创建装置,可包括:A sixth aspect of the present invention provides a device for creating a disk image, which may include:

接收单元,用于接收磁盘镜像创建指令;a receiving unit, configured to receive a disk image creation instruction;

创建单元,用于创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示的块大小。The creation unit is configured to create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the disk image creation instruction. The indicated block size.

由上可见,本发明实施例的磁盘镜像的块调整方案中,在接收对第一磁盘镜像块大小的调整指令之后,根据调整指令所指示的块大小来创建第二磁盘镜像;向创建的第二磁盘镜像拷贝第一磁盘镜像中存储的数据。由于是根据块大小调整指令按需来调整磁盘镜像块大小,这一机制使得磁盘镜像的块大小更为灵活,有利于更好的匹配具体场景需要,进而有利于提高磁盘镜像的数据读写性能和存储空间利用率。As can be seen from the above, in the block adjustment scheme of the disk image in the embodiment of the present invention, after receiving the adjustment instruction to the block size of the first disk image, the second disk image is created according to the block size indicated by the adjustment instruction; The second disk image copies the data stored in the first disk image. Because the block size of the disk image is adjusted according to the needs of the block size adjustment command, this mechanism makes the block size of the disk image more flexible, which is conducive to better matching the needs of specific scenarios, and thus helps to improve the data read and write performance of the disk image and storage space utilization.

另一方面,在本实施例提供的一种磁盘镜像创建方案中,在接收磁盘镜像创建指令之后,根据接收磁盘镜像创建指令所指示的容量来创建第一磁盘镜像,且第一磁盘镜像的块大小与其容量之间满足预设的对应关系。由于是根据指示容量,按照容量对应的块大小创建相应容量和块大小的磁盘镜像,这一磁盘镜像创建机制使得创建磁盘镜像的块大小更为灵活,这一有利于更好的匹配具体场景需要,进而有利于提高磁盘镜像的数据读写性能和存储空间利用率。On the other hand, in a disk image creation solution provided by this embodiment, after receiving the disk image creation instruction, the first disk image is created according to the capacity indicated by the received disk image creation instruction, and the blocks of the first disk image There is a preset correspondence between the size and its capacity. Because the disk image with the corresponding capacity and block size is created according to the indicated capacity and the block size corresponding to the capacity, this disk image creation mechanism makes the block size of the created disk image more flexible, which is conducive to better matching the needs of specific scenarios , which in turn helps to improve the data read and write performance and storage space utilization of the disk image.

又一方面,在本实施例提供的另一种磁盘镜像创建方案中,在接收磁盘镜像创建指令之后,根据接收磁盘镜像创建指令所指示的容量和块大小,来创建第一磁盘镜像。由于是根据指示的容量和块大小,按照需创建磁盘镜像,这一磁盘镜像创建机制使得创建磁盘镜像的块大小更为灵活,这一有利于更好的匹配具体场景需要,进而有利于提高磁盘镜像的数据读写性能和存储空间利用率。In yet another aspect, in another disk image creation solution provided by this embodiment, after receiving the disk image creation instruction, the first disk image is created according to the capacity and block size indicated by the received disk image creation instruction. Because the disk image is created as needed based on the indicated capacity and block size, this disk image creation mechanism makes the block size of the disk image more flexible. Mirror data read and write performance and storage space utilization.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.

图1是本发明实施例提供的一种磁盘镜像的块调整方法的流程示意图;FIG. 1 is a schematic flowchart of a method for adjusting blocks of a disk image provided by an embodiment of the present invention;

图2是本发明实施例提供的一种磁盘镜像创建方法的流程示意图;FIG. 2 is a schematic flowchart of a method for creating a disk image provided by an embodiment of the present invention;

图3是本发明实施例提供的另一种磁盘镜像创建方法的流程示意图;FIG. 3 is a schematic flowchart of another method for creating a disk image provided by an embodiment of the present invention;

图4是本发明实施例提供的另一种磁盘镜像的块调整方法的流程示意图;FIG. 4 is a schematic flow chart of another disk image block adjustment method provided by an embodiment of the present invention;

图5-a是本发明实施例提供的一种磁盘镜像的块调整装置的示意图;Fig. 5-a is a schematic diagram of a disk image block adjustment device provided by an embodiment of the present invention;

图5-b是本发明实施例提供的另一种磁盘镜像的块调整装置的示意图;Fig. 5-b is a schematic diagram of another disk image block adjustment device provided by an embodiment of the present invention;

图5-c是本发明实施例提供的另一种磁盘镜像的块调整装置的示意图;Fig. 5-c is a schematic diagram of another disk image block adjustment device provided by an embodiment of the present invention;

图6是本发明实施例提供的一种计算机的示意图;Fig. 6 is a schematic diagram of a computer provided by an embodiment of the present invention;

图7是本发明实施例提供的一种磁盘镜像创建装置的示意图;FIG. 7 is a schematic diagram of a device for creating a disk image provided by an embodiment of the present invention;

图8是本发明实施例提供的另一种计算机的示意图;Fig. 8 is a schematic diagram of another computer provided by an embodiment of the present invention;

图9是本发明实施例提供的另一种磁盘镜像创建装置的示意图;FIG. 9 is a schematic diagram of another device for creating a disk image provided by an embodiment of the present invention;

图10是本发明实施例提供的另一种计算机的示意图。Fig. 10 is a schematic diagram of another computer provided by an embodiment of the present invention.

具体实施方式Detailed ways

本发明实施例提供一种磁盘镜像的块调整方法和磁盘镜像创建方法及相关设备,以期提高磁盘镜像的数据读写性能和存储空间利用率。Embodiments of the present invention provide a method for adjusting blocks of a disk image, a method for creating a disk image, and related equipment, in order to improve the data read and write performance and storage space utilization of the disk image.

为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only It is an embodiment of a part of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.

以下分别进行详细说明。Each will be described in detail below.

本发明说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例例如能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法或系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if any) in the description and claims of the present invention and the above drawings are used to distinguish similar objects and not necessarily to describe A particular order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of practice in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method or system, product or device comprising a sequence of steps or elements is not necessarily limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.

本发明磁盘镜像的块调整方法的一实施例,其中,一种磁盘镜像的块调整方法可包括:接收对第一磁盘镜像块大小的调整指令;创建第二磁盘镜像,其中,第二磁盘镜像的块大小为该调整指令所指示的块大小;向第二磁盘镜像拷贝第一磁盘镜像中存储的数据。In an embodiment of the disk image block adjustment method of the present invention, a disk image block adjustment method may include: receiving an adjustment instruction for the block size of the first disk image; creating a second disk image, wherein the second disk image The block size is the block size indicated by the adjustment command; copying the data stored in the first disk image to the second disk image.

参见图1,图1为本发明实施例提供的一种磁盘镜像的块调整方法的流程示意图。如图1所示,本发明实施例提供的一种磁盘镜像的块调整方法可包括以下内容:Referring to FIG. 1 , FIG. 1 is a schematic flowchart of a block adjustment method for a disk image provided by an embodiment of the present invention. As shown in Figure 1, a block adjustment method of a disk image provided by an embodiment of the present invention may include the following:

101、接收对第一磁盘镜像块大小的调整指令;101. Receive an instruction to adjust the size of the first disk image block;

在本发明的一些实施例中,接收到的对第一磁盘镜像块大小的调整指令可包含块大小指示,其中,该块大小指示可用于指示出需调整到的目标块大小(例如2MB字节、4MB、8MB或其它块大小)。其中,上述对第一磁盘镜像块大小的调整指令,可由第一磁盘镜像的磁盘镜像驱动发出或者可由使用第一磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或用户发出。进一步的,对第一磁盘镜像块大小的调整指令中还可包含第一磁盘镜像的标识,当然也可通过其它方式来确定是要对第一磁盘镜像的块大小进行调整,例如,若上述第一磁盘镜像块大小的调整指令由使用第一磁盘镜像的第一VM发出,则可默认为是要对第一磁盘镜像的块大小进行调整。或若第一磁盘镜像块大小的调整指令包含有使用第一磁盘镜像的第一VM的标识,则可根据第一VM的标识确定是要对第一磁盘镜像的块大小进行调整,其它方式可以此类推。In some embodiments of the present invention, the received adjustment command for the block size of the first disk image may include a block size indication, wherein the block size indication may be used to indicate the target block size to be adjusted (for example, 2 MB bytes , 4MB, 8MB or other block sizes). Wherein, the above-mentioned adjustment instruction for the block size of the first disk image may be issued by the disk image driver of the first disk image, or may be issued by a VM using the first disk image (for ease of reference, it may be referred to as the first VM), or may be issued by other Issued by an object or user. Further, the instruction for adjusting the block size of the first disk image may also include the identifier of the first disk image. Of course, other methods may also be used to determine whether to adjust the block size of the first disk image. For example, if the above-mentioned An instruction to adjust the block size of a disk image is issued by the first VM using the first disk image, and it may be assumed by default that the block size of the first disk image is to be adjusted. Or if the adjustment instruction of the block size of the first disk image includes the identification of the first VM using the first disk image, then it can be determined according to the identification of the first VM that the block size of the first disk image should be adjusted, and other methods can be And so on.

在本发明的一些实施例中,在接收对第一磁盘镜像块大小的调整指令之前还可包括:接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与上述容量之间满足预设的对应关系。In some embodiments of the present invention, before receiving the instruction to adjust the block size of the first disk image, it may also include: receiving a disk image creation instruction; creating the first disk image, wherein the capacity of the first disk image is the disk image created The capacity indicated by the instruction, the block size of the first disk image and the above capacity satisfy a preset corresponding relationship.

举例来说,若第一磁盘镜像的容量等于S字节,则第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,n和m为正整数。当然,第一磁盘镜像的块大小与其容量之间亦可满足预设的其它对应关系,此处不再一一举例,主要目的是创建出的第一磁盘镜像的块大小与容量之间相匹配。For example, if the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2n -1 < S≤2n , 9≤m≤n-17, Among them, n and m are positive integers. Of course, the block size of the first disk image and its capacity can also meet other preset correspondences, and examples are not given here. The main purpose is to match the block size and capacity of the created first disk image. .

例如,若第一磁盘镜像的容量小于或等于256GB,则第一磁盘镜像的块大小可等于2MB;若第一磁盘镜像的容量介于256GB与512GB之间,则第一磁盘镜像的块大小可等于4MB;若第一磁盘镜像的容量介于512GB与1TB之间,则第一磁盘镜像的块大小可等于8MB;若第一磁盘镜像的容量等于介于1TB与2TB之间,则第一磁盘镜像的块大小可等于16MB;若第一磁盘镜像的容量等于介于2TB与4TB之间,则第一磁盘镜像的块大小可等于32MB,以此类推,当然不限于举例的对应关系。For example, if the capacity of the first disk image is less than or equal to 256GB, the block size of the first disk image can be equal to 2MB; if the capacity of the first disk image is between 256GB and 512GB, the block size of the first disk image can be equal to 4MB; if the capacity of the first disk image is between 512GB and 1TB, the block size of the first disk image can be equal to 8MB; if the capacity of the first disk image is between 1TB and 2TB, the first disk The block size of the image can be equal to 16MB; if the capacity of the first disk image is between 2TB and 4TB, the block size of the first disk image can be equal to 32MB, and so on, of course not limited to the example correspondence.

在本发明另一些实施例中,在接收对第一磁盘镜像块大小的调整指令之前还可包括:接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小为磁盘镜像创建指令所指示的块大小。In some other embodiments of the present invention, before receiving the instruction to adjust the block size of the first disk image, it may further include: receiving a disk image creation instruction; creating the first disk image, wherein the capacity of the first disk image is the disk image created The capacity indicated by the instruction, the block size of the first disk image is the block size indicated by the disk image creation instruction.

在本发明的一些实施例中,在接收到磁盘镜像创建指令之后,还可先判断该磁盘镜像创建指令所指示的块大小是否等于2的x次方,若不是,则可返回磁盘镜像创建失败指令,以指示无法按需创建磁盘镜像,若是则执行创建第一磁盘镜像的步骤。In some embodiments of the present invention, after receiving the disk image creation instruction, it is also possible to first judge whether the block size indicated by the disk image creation instruction is equal to 2 to the power of x, if not, return the disk image creation failure command to indicate that the disk image cannot be created on demand, and if so, execute the steps of creating the first disk image.

在本发明的一些实施例中,在接收到磁盘镜像创建指令之后,还可先判断该第一磁盘镜像块大小的调整指令所指示的块大小(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是则执行创建第一磁盘镜像的步骤,其中,此场景下创建的第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,并且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小,来执行创建第一磁盘镜像的步骤,此场景下创建的第一磁盘镜像的块大小为2x-1或2x字节。其中,上述x为自然数,x大于或等于9为宜。In some embodiments of the present invention, after receiving the disk image creation instruction, the block size indicated by the first disk image block size adjustment instruction can also be judged first (for ease of description, the indicated block size is used for B to represent ) is equal to 2 to the x power, and if so, execute the step of creating the first disk image, wherein the block size of the first disk image created in this scenario is the block size B bytes indicated by the above disk image creation instruction; if No, and 2x -1 <B< 2x , then for example, 2x -1 bytes or 2xbytes can be used as the block size indicated by the adjustment instruction to perform the step of creating the first disk image, in this scenario The block size of the created first disk image is 2 x-1 or 2 x bytes. Wherein, the above-mentioned x is a natural number, preferably x is greater than or equal to 9.

102、创建第二磁盘镜像;102. Create a second disk image;

其中,第二磁盘镜像的块大小为上述调整指令所指示的块大小。Wherein, the block size of the second disk image is the block size indicated by the adjustment command.

在本发明的一些实施例中,创建的第二磁盘镜像的容量可大于或等于第一磁盘镜像的容量。In some embodiments of the present invention, the capacity of the created second disk image may be greater than or equal to the capacity of the first disk image.

在本发明的一些实施例中,在接收对第一磁盘镜像块大小的调整指令之后,还可先判断该第一磁盘镜像块大小的调整指令所指示的块大小是否等于2的x次方,其中,x为自然数,x大于或等于9为宜;若不是,则可返回第一磁盘镜像块大小调整失败指令以指示无法按需调整块大小,若是,则执行创建第二磁盘镜像的步骤。In some embodiments of the present invention, after receiving the instruction for adjusting the block size of the first disk image block, it may be first determined whether the block size indicated by the block size adjustment instruction for the first disk image block is equal to 2 to the power of x, Wherein, x is a natural number, and x is preferably greater than or equal to 9; if not, the block size adjustment failure instruction of the first disk image can be returned to indicate that the block size cannot be adjusted as required, and if so, the step of creating the second disk image is executed.

在本发明的另一些实施例中,在接收对第一磁盘镜像块大小的调整指令之后,可先判断该第一磁盘镜像块大小的调整指令所指示的块大小B(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是,则执行创建第二磁盘镜像的步骤,其中,此场景下创建的第二磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小来执行创建第二磁盘镜像的步骤,其中,此场景下创建的第二磁盘镜像的块大小为2x-1或2x字节。其中,上述x为自然数,x大于或等于9为宜。In some other embodiments of the present invention, after receiving the instruction to adjust the block size of the first disk image block, the block size B indicated by the block size adjustment instruction of the first disk image block can be judged first (for ease of description, the indicated The block size is used to indicate whether B) is equal to 2 to the power of x, and if so, execute the step of creating the second disk image, where the block size of the second disk image created in this scenario is indicated by the above disk image creation command Block size B bytes; if not, and 2x-1 <B< 2x , then for example, 2x -1 bytes or 2x bytes can be used as the block size indicated by the adjustment command to perform creation of the second disk image Steps, wherein the block size of the second disk image created in this scenario is 2 x-1 or 2 x bytes. Wherein, the above-mentioned x is a natural number, preferably x is greater than or equal to 9.

103、向第二磁盘镜像拷贝第一磁盘镜像中存储的数据。103. Copy the data stored in the first disk image to the second disk image.

在本发明一些实施例中,可按照扇区到扇区的拷贝方式,向第二磁盘镜像拷贝第一磁盘镜像中存储的数据。进一步的,在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,可将使用第一磁盘镜像的第一VM使用的磁盘镜像变换为第二磁盘镜像,并可关闭第一磁盘镜像。In some embodiments of the present invention, the data stored in the first disk image may be copied to the second disk image in a sector-to-sector copy manner. Further, after copying the data stored in the first disk image to the second disk image, the disk image used by the first VM using the first disk image can be converted to the second disk image, and the first disk image can be closed .

在本发明一些实施例中,接收对第一磁盘镜像块大小的调整指令之后还可包括:在第一磁盘镜像关闭之前,若接收到指示向第一磁盘镜像写入第一数据的写操作指令,且还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据(此时第一磁盘镜像还处于块大小调整状态),则可向第一磁盘镜像和第二磁盘镜像分别写入第一数据。例如,在接收对第一磁盘镜像块大小的调整指令之后,可向镜像配置文件中写入的第一磁盘镜像的标识和块大小调整状态指示等,以标识当前第一磁盘镜像处于块大小调整状态,后续可根据镜像配置文件中写入的第一磁盘镜像的标识和块大小调整状态指示,确定第一磁盘镜像还处于块大小调整状态,当然,也可通过其它方式来标识第一磁盘镜像是否处于块大小调整状态。进一步的,当向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,可向镜像配置文件中写入对应第一磁盘镜像的数据拷贝完成标识,以标识第一磁盘镜像块大小调整结束。后续可根据镜像配置文件中写入的对应第一磁盘镜像的数据拷贝完成标识,确定第一磁盘镜像的块大小调整已经结束。In some embodiments of the present invention, after receiving the instruction to adjust the block size of the first disk image, it may further include: before the first disk image is closed, if a write operation instruction indicating to write the first data to the first disk image is received , and the data stored in the first disk image has not been copied to the second disk image (the first disk image is still in the block size adjustment state), then the first disk image and the second disk image can be respectively written to the first a data. For example, after receiving an instruction to adjust the block size of the first disk image, the identifier of the first disk image and an indication of the block size adjustment state may be written in the image configuration file to identify that the first disk image is currently in block size adjustment state, and then you can determine that the first disk image is still in the block size adjustment state according to the identifier of the first disk image written in the image configuration file and the block size adjustment status indication. Of course, other methods can also be used to identify the first disk image Is in block resizing state. Further, after the data stored in the first disk image is copied to the second disk image, the data copy completion flag corresponding to the first disk image can be written into the image configuration file to mark the end of the first disk image block size adjustment . Subsequently, it may be determined that the block size adjustment of the first disk image has been completed according to the data copy completion flag corresponding to the first disk image written in the image configuration file.

在本发明一些实施例中,在第一VM关机时,若已经向第二磁盘镜像拷贝完了第一磁盘镜像中存储的数据,则可关闭第二磁盘镜像;若还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据,则可在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,关闭第二磁盘镜像。其中,第一VM为使用第一磁盘镜像的VM。举例来说,若在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,向镜像配置文件中写入对应第一磁盘镜像的数据拷贝完成标识,则在第一VM关机时,可读取镜像配置文件,若读取的镜像配置文件中写入了对应第一磁盘镜像的数据拷贝完成标识,则确定已经向第二磁盘镜像拷贝完了第一磁盘镜像中存储的数据(即第一磁盘镜像块大小调整已经结束),若读取的镜像配置文件未写入对应第一磁盘镜像的数据拷贝完成标识,则确定还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据(即第一磁盘镜像块大小调整未结束)。当然,也可通过其它方式来标识第一磁盘镜像块大小调整状态是否已经结束。In some embodiments of the present invention, when the first VM is shut down, if the data stored in the first disk image has been copied to the second disk image, the second disk image can be closed; After the data stored in the first disk image is finished, the second disk image can be closed after the data stored in the first disk image has been copied to the second disk image. Wherein, the first VM is a VM using the first disk image. For example, if after the data stored in the first disk image is copied to the second disk image, the data copy completion flag corresponding to the first disk image is written into the image configuration file, then when the first VM is shut down, the Read the mirror configuration file, if the data copy completion flag corresponding to the first disk mirror is written in the read mirror configuration file, then it is determined that the data stored in the first disk mirror has been copied to the second disk mirror (that is, the first disk image block size adjustment has been completed), if the image configuration file read does not write the data copy completion flag corresponding to the first disk image, then it is determined that the data stored in the first disk image has not been copied to the second disk image ( That is, the first disk image block resizing is not completed). Of course, other ways may also be used to identify whether the first disk image block size adjustment state has ended.

可以看出,本实施例磁盘镜像的块调整方案中,在接收对第一磁盘镜像块大小的调整指令之后,根据调整指令所指示的块大小来创建第二磁盘镜像;向创建的第二磁盘镜像拷贝第一磁盘镜像中存储的数据。由于是根据块大小调整指令按需来调整磁盘镜像块大小,这一机制使得磁盘镜像的块大小更为灵活,有利于更好的匹配具体场景需要,进而有利于提高磁盘镜像的数据读写性能和存储空间利用率。It can be seen that, in the block adjustment scheme of the disk image in this embodiment, after receiving the adjustment instruction to the block size of the first disk image, the second disk image is created according to the block size indicated by the adjustment instruction; Mirroring copies the data stored in the first disk image. Because the block size of the disk image is adjusted according to the needs of the block size adjustment command, this mechanism makes the block size of the disk image more flexible, which is conducive to better matching the needs of specific scenarios, and thus helps to improve the data read and write performance of the disk image and storage space utilization.

本发明磁盘镜像创建方法的一实施例,其中,一种磁盘镜像创建方法可包括:接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与该容量之间满足预设的对应关系。In an embodiment of the method for creating a disk image according to the present invention, a method for creating a disk image may include: receiving a disk image creation instruction; creating a first disk image, wherein the capacity of the first disk image is indicated by the above disk image creation instruction The capacity of the first disk image satisfies a preset corresponding relationship between the block size of the first disk image and the capacity.

参见图2,图2为本发明实施例提供的一种磁盘镜像创建方法的流程示意图。如图2所示,本发明实施例提供的一种磁盘镜像创建方法可包括以下内容:Referring to FIG. 2 , FIG. 2 is a schematic flowchart of a method for creating a disk image provided by an embodiment of the present invention. As shown in Figure 2, a method for creating a disk image provided by an embodiment of the present invention may include the following:

201、接收磁盘镜像创建指令。201. Receive a disk image creation instruction.

在本发明的一些实施例中,接收到的磁盘镜像创建指令可包含磁盘镜像容量指示,其中,上述磁盘镜像容量指示于指示出请求磁盘镜像的目标容量。其中,上述磁盘镜像创建指令,例如可由磁盘镜像驱动发出或者可由需使用磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或者用户发出。In some embodiments of the present invention, the received disk image creation command may include a disk image capacity indication, wherein the disk image capacity indication indicates a target capacity of the requested disk image. Wherein, the above-mentioned disk image creation instruction may be issued by, for example, a disk image driver, or may be issued by a VM that needs to use the disk image (for ease of reference, may be referred to as the first VM), or may be issued by other objects or users.

202、创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与上述容量之间满足预设的对应关系。202. Create a first disk image, where the capacity of the first disk image is the capacity indicated by the above-mentioned disk image creation instruction, and the block size of the first disk image and the above-mentioned capacity satisfy a preset corresponding relationship.

在本发明的一些实施例中,第一磁盘镜像的块大小与容量之间满足预设的对应关系可如下:若第一磁盘镜像的容量等于S字节,则第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中n和m为正整数。当然,第一磁盘镜像的块大小与其容量之间亦可满足预设的其它对应关系,此处不再一一举例,主要目的是创建出的第一磁盘镜像的块大小与容量之间相匹配。In some embodiments of the present invention, the preset corresponding relationship between the block size and capacity of the first disk image can be as follows: if the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, where 2 n-1 <S≤2 n , 9≤m≤n-17, where n and m are positive integers. Of course, the block size of the first disk image and its capacity can also meet other preset correspondences, and examples are not given here. The main purpose is to match the block size and capacity of the created first disk image. .

例如,若第一磁盘镜像的容量小于或等于256GB,则第一磁盘镜像的块大小可等于2MB;若第一磁盘镜像的容量介于256GB与512GB之间,则第一磁盘镜像的块大小可等于4MB;若第一磁盘镜像的容量介于512GB与1TB之间,则第一磁盘镜像的块大小可等于8MB;若第一磁盘镜像的容量等于介于1TB与2TB之间,则第一磁盘镜像的块大小可等于16MB;若第一磁盘镜像的容量等于介于2TB与4TB之间,则第一磁盘镜像的块大小可等于32MB,以此类推,当然不限于举例的对应关系。For example, if the capacity of the first disk image is less than or equal to 256GB, the block size of the first disk image can be equal to 2MB; if the capacity of the first disk image is between 256GB and 512GB, the block size of the first disk image can be equal to 4MB; if the capacity of the first disk image is between 512GB and 1TB, the block size of the first disk image can be equal to 8MB; if the capacity of the first disk image is between 1TB and 2TB, the first disk The block size of the image can be equal to 16MB; if the capacity of the first disk image is between 2TB and 4TB, the block size of the first disk image can be equal to 32MB, and so on, of course not limited to the example correspondence.

可以看出,本实施例磁盘镜像创建方案中,在接收磁盘镜像创建指令之后,根据接收磁盘镜像创建指令所指示的容量来创建第一磁盘镜像,且第一磁盘镜像的块大小与其容量之间满足预设的对应关系。由于是根据指示容量,按照容量对应的块大小创建相应容量和块大小的磁盘镜像,这一磁盘镜像创建机制使得创建磁盘镜像的块大小更为灵活,这一有利于更好的匹配具体场景需要,进而有利于提高磁盘镜像的数据读写性能和存储空间利用率。It can be seen that in the disk image creation scheme of this embodiment, after receiving the disk image creation instruction, the first disk image is created according to the capacity indicated by the received disk image creation instruction, and the block size of the first disk image and its capacity are between Satisfy the preset corresponding relationship. Because the disk image with the corresponding capacity and block size is created according to the indicated capacity and the block size corresponding to the capacity, this disk image creation mechanism makes the block size of the created disk image more flexible, which is conducive to better matching the needs of specific scenarios , which in turn helps to improve the data read and write performance and storage space utilization of the disk image.

本发明磁盘镜像创建方法的另一实施例,其中,另一种磁盘镜像创建方法可包括:接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小。In another embodiment of the method for creating a disk image of the present invention, another method for creating a disk image may include: receiving a disk image creation instruction; creating a first disk image, wherein the capacity of the first disk image is equal to the above-mentioned disk image creation instruction For the capacity indicated, the block size of the first disk image is the block size indicated by the above disk image creation command.

参见图3,图3为本发明实施例提供的另一种磁盘镜像创建方法的流程示意图。如图3所示,本发明实施例提供的另一种磁盘镜像创建方法可包括以下内容:Referring to FIG. 3 , FIG. 3 is a schematic flowchart of another method for creating a disk image provided by an embodiment of the present invention. As shown in Figure 3, another method for creating a disk image provided by an embodiment of the present invention may include the following:

301、接收磁盘镜像创建指令。301. Receive a disk image creation instruction.

在本发明的一些实施例中,接收到的磁盘镜像创建指令可包含磁盘镜像容量指示和块大小指示,其中,该磁盘镜像容量指示于指示出请求磁盘镜像的目标容量;其中,上述块大小指示可用于指示出需调整到的目标块大小。其中,上述磁盘镜像创建指令,例如可由磁盘镜像驱动发出或可由需使用将创建出的磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或者用户发出。In some embodiments of the present invention, the received disk image creation instruction may include a disk image capacity indication and a block size indication, wherein the disk image capacity indication indicates the target capacity of the requested disk image; wherein the block size indication Can be used to indicate the target block size to adjust to. Wherein, the above-mentioned disk image creation instruction may be issued by, for example, a disk image driver, or may be issued by a VM (for ease of reference, referred to as the first VM) that needs to use the disk image to be created, or may be issued by other objects or users.

302、创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小上述磁盘镜像创建指令所指示的块大小。302. Create a first disk image, where the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the block size indicated by the disk image creation instruction.

在本发明的一些实施例中,在接收到磁盘镜像创建指令之后,还可先判断该磁盘镜像创建指令所指示的块大小是否等于2的x次方,若不是,则可返回磁盘镜像创建失败指令,以指示无法按需创建磁盘镜像,若是则执行创建第一磁盘镜像的步骤。In some embodiments of the present invention, after receiving the disk image creation instruction, it is also possible to first judge whether the block size indicated by the disk image creation instruction is equal to 2 to the power of x, if not, return the disk image creation failure command to indicate that the disk image cannot be created on demand, and if so, execute the steps of creating the first disk image.

在本发明另一些实施例中,在接收到磁盘镜像创建指令之后,还可先判断该第一磁盘镜像块大小的调整指令所指示的块大小(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是,则执行创建第一磁盘镜像的步骤,其中,此场景下创建的第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,并且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小,来执行创建第一磁盘镜像的步骤,此场景下创建的第一磁盘镜像的块大小为2x-1或2x字节。其中,上述x为自然数,x大于或等于9为宜。In other embodiments of the present invention, after receiving the disk image creation instruction, the block size indicated by the block size adjustment instruction of the first disk image can also be judged first (for ease of description, the indicated block size is used for B to represent ) is equal to 2 to the power of x, and if so, execute the step of creating the first disk image, wherein the block size of the first disk image created in this scenario is the block size B bytes indicated by the above disk image creation instruction; If not, and 2 x-1 <B<2 x , then for example, 2 x-1 bytes or 2 x bytes may be used as the block size indicated by the adjustment instruction to perform the step of creating the first disk image. In this scenario The block size of the first disk image created below is 2 x-1 or 2 x bytes. Wherein, the above-mentioned x is a natural number, preferably x is greater than or equal to 9.

可以看出,本实施例磁盘镜像创建方案中,在接收磁盘镜像创建指令之后,根据接收磁盘镜像创建指令所指示的容量和块大小,来创建第一磁盘镜像。由于是根据指示的容量和块大小,按照需创建磁盘镜像,这一磁盘镜像创建机制使得创建磁盘镜像的块大小更为灵活,这一有利于更好的匹配具体场景需要,进而有利于提高磁盘镜像的数据读写性能和存储空间利用率。It can be seen that in the disk image creation scheme of this embodiment, after receiving the disk image creation instruction, the first disk image is created according to the capacity and block size indicated by the received disk image creation instruction. Because the disk image is created as needed based on the indicated capacity and block size, this disk image creation mechanism makes the block size of the disk image more flexible. Mirror data read and write performance and storage space utilization.

为便于更好的理解和实施本发明实施例的上述方案,下面举例一些应用场景进行介绍。In order to facilitate a better understanding and implementation of the above solutions of the embodiments of the present invention, some application scenarios are given as examples below for introduction.

参见图4,图4为本发明实施例提供的另一种磁盘镜像的块调整方法的流程示意图。如图4所示,本发明实施例提供的另一种磁盘镜像的块调整方法可包括以下内容:Referring to FIG. 4 , FIG. 4 is a schematic flowchart of another method for adjusting blocks of a disk image provided by an embodiment of the present invention. As shown in FIG. 4, another block adjustment method for a disk image provided by an embodiment of the present invention may include the following:

401、磁盘镜像驱动接收对磁盘镜像A块大小的调整指令;401. The disk image driver receives an instruction to adjust the size of block A of the disk image;

其中,假设磁盘镜像A当前有正在运行中的第一VM使用。Wherein, it is assumed that the disk image A is currently used by the running first VM.

在本发明的一些实施例中,接收到的对磁盘镜像A块大小的调整指令可包含块大小指示,其中,上述块大小指示可用于指示出需调整到的目标块大小(例如2MB字节、4MB、8MB或其它块大小)。In some embodiments of the present invention, the received instruction to adjust the block size of the disk image A may include a block size indication, wherein the above block size indication may be used to indicate the target block size to be adjusted (for example, 2MB bytes, 4MB, 8MB or other block size).

402、磁盘镜像驱动判断目标块大小是否等于2的x次方个字节;402. The disk mirroring driver judges whether the size of the target block is equal to 2 to the power of x bytes;

其中,x为自然数,x大于或等于9为宜;Wherein, x is a natural number, preferably x is greater than or equal to 9;

若是,执行步骤403;If yes, execute step 403;

若否,执行步骤404。If not, go to step 404 .

403、磁盘镜像驱动提示无法按需调整磁盘镜像A的块大小。403. The disk image driver prompts that the block size of disk image A cannot be adjusted as required.

404、磁盘镜像驱动在镜像配置文件中写入磁盘镜像A的路径、名称和块调整状态指示。404. The disk image driver writes the path, name and block adjustment state indication of disk image A in the image configuration file.

405、创建磁盘镜像B;405. Create a disk image B;

其中,磁盘镜像B的块大小为上述调整指令所指示的块大小,磁盘镜像B的容量大于或等于磁盘镜像A的容量。Wherein, the block size of the disk image B is the block size indicated by the adjustment command, and the capacity of the disk image B is greater than or equal to the capacity of the disk image A.

406、磁盘镜像驱动启动数据拷贝线程,进行磁盘镜像A到磁盘镜像B的扇区拷贝。406. The disk image driver starts a data copy thread to copy sectors from disk image A to disk image B.

特别的,当发现磁盘镜像B的对应扇区已经为使用状态,则可跳过向磁盘镜像B的该扇区拷贝数据(因为磁盘镜像B的该扇区中的数据可能是最新的数据),而继续其它扇区的数据拷贝。In particular, when it is found that the corresponding sector of disk image B is already in use, copying data to this sector of disk image B can be skipped (because the data in this sector of disk image B may be the latest data), And continue to copy the data of other sectors.

407、在磁盘镜像A到磁盘镜像B的扇区拷贝完成后,磁盘镜像驱动将第一VM使用的磁盘镜像变换为磁盘镜像B。磁盘镜像驱动在镜像配置文件中写入对应磁盘镜像A的数据拷贝完成标识,以标识磁盘镜像A的块大小调整结束。磁盘镜像驱动还可关闭磁盘镜像A。407. After sector copying from disk image A to disk image B is completed, the disk image driver converts the disk image used by the first VM into disk image B. The disk mirroring driver writes the data copy completion flag corresponding to the disk mirroring A in the mirroring configuration file, to mark that the block size adjustment of the disk mirroring A is finished. The disk mirroring driver can also close the disk mirroring A.

在本发明一些实施例中,在磁盘镜像A关闭之前,磁盘镜像驱动若接收到指示向磁盘镜像A写入第一数据的写操作指令,且还未向磁盘镜像B拷贝完磁盘镜像A中存储的数据(此时磁盘镜像A还处于块大小调整状态),则可向磁盘镜像A和磁盘镜像B分别写入第一数据。In some embodiments of the present invention, before the disk mirroring A is closed, if the disk mirroring driver receives a write operation command indicating to write the first data to the disk mirroring A, and has not copied the disk mirroring B to the disk mirroring B and stored in the disk mirroring A (at this time, disk image A is still in the block size adjustment state), then the first data can be written to disk image A and disk image B respectively.

在本发明一些实施例中,在第一VM关机时,若已经向磁盘镜像B拷贝完了磁盘镜像A中存储的数据(例如镜像配置文件中写入了对应磁盘镜像A的数据拷贝完成标识),则可关闭磁盘镜像B;若还未向磁盘镜像B像拷贝完磁盘镜像A中存储的数据(例如,镜像配置文件中写入了写入磁盘镜像A的路径、名称和块调整状态指示,但未写入对应磁盘镜像A的数据拷贝完成标识),则可在向磁盘镜像B拷贝完磁盘镜像A中存储的数据之后,再关闭磁盘镜像B。In some embodiments of the present invention, when the first VM is shut down, if the data stored in disk image A has been copied to disk image B (for example, the data copy completion flag corresponding to disk image A is written in the image configuration file), Then disk mirroring B can be closed; if the data stored in disk mirroring A has not been copied to disk mirroring B (for example, the path, name and block adjustment status indication of writing disk mirroring A are written in the mirroring configuration file, but If the data copy completion flag corresponding to disk image A is not written), you can close disk image B after copying the data stored in disk image A to disk image B.

对于第一VM处于待机或准备关机状态,这种状态下第一VM通常不会向磁盘镜像中写入数据,若此时进行磁盘镜像的块大小调整,则可无需进行镜像配置文件的维护。For the first VM is in a state of standby or ready to shut down, in this state the first VM usually does not write data into the disk image, if the block size of the disk image is adjusted at this time, the maintenance of the image configuration file may not be necessary.

可以理解,上述应用场景仅为举例,在实际应用中,根据应用场景的不同方案可能会进行适应性的调整。It can be understood that the above application scenarios are only examples, and in actual applications, adaptive adjustments may be made according to different schemes of the application scenarios.

为便于更好的实施本发明实施例的上述方案,下面还提供用于实施上述方案的相关装置。In order to facilitate better implementation of the above solutions in the embodiments of the present invention, related devices for implementing the above solutions are also provided below.

参见图5-a,图5-a为本发明实施例提供的一种磁盘镜像的块调整装置500的示意图,磁盘镜像的块调整装置500可包括:接收单元510、创建单元520和数据转移单元530。Referring to Fig. 5-a, Fig. 5-a is a schematic diagram of a disk image block adjustment device 500 provided by an embodiment of the present invention. The disk image block adjustment device 500 may include: a receiving unit 510, a creation unit 520 and a data transfer unit 530.

其中,接收单元510,接收对第一磁盘镜像块大小的调整指令。Wherein, the receiving unit 510 receives an instruction to adjust the size of the first disk image block.

在本发明的一些实施例中,接收单元510接收到的对第一磁盘镜像块大小的调整指令可包含块大小指示,其中,该块大小指示可用于指示出需调整到的目标块大小(例如2MB字节、4MB、8MB或其它块大小)。其中,上述对第一磁盘镜像块大小的调整指令,可由第一磁盘镜像的磁盘镜像驱动发出或者可由使用第一磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或用户发出。进一步的,对第一磁盘镜像块大小的调整指令中还可包含第一磁盘镜像的标识,当然也可通过其它方式来确定是要对第一磁盘镜像的块大小进行调整,例如,若上述第一磁盘镜像块大小的调整指令由使用第一磁盘镜像的第一VM发出,则可默认为是要对第一磁盘镜像的块大小进行调整。或若第一磁盘镜像块大小的调整指令包含有使用第一磁盘镜像的第一VM的标识,则可根据第一VM的标识确定是要对第一磁盘镜像的块大小进行调整,其它方式可以此类推。In some embodiments of the present invention, the instruction for adjusting the block size of the first disk image received by the receiving unit 510 may include a block size indication, where the block size indication may be used to indicate the target block size to be adjusted (for example 2MB bytes, 4MB, 8MB or other block sizes). Wherein, the above-mentioned adjustment instruction for the block size of the first disk image may be issued by the disk image driver of the first disk image, or may be issued by a VM using the first disk image (for ease of reference, it may be referred to as the first VM), or may be issued by other Issued by an object or user. Further, the instruction for adjusting the block size of the first disk image may also include the identifier of the first disk image. Of course, other methods may also be used to determine whether to adjust the block size of the first disk image. For example, if the above-mentioned An instruction to adjust the block size of a disk image is issued by the first VM using the first disk image, and it may be assumed by default that the block size of the first disk image is to be adjusted. Or if the adjustment instruction of the block size of the first disk image includes the identification of the first VM using the first disk image, then it can be determined according to the identification of the first VM that the block size of the first disk image should be adjusted, and other methods can be And so on.

创建单元520,创建第二磁盘镜像,其中,第二磁盘镜像的块大小为上述调整指令所指示的块大小。The creating unit 520 creates a second disk image, wherein the block size of the second disk image is the block size indicated by the adjustment instruction.

数据转移单元530,用于向第二磁盘镜像拷贝第一磁盘镜像中存储的数据。The data transfer unit 530 is configured to copy the data stored in the first disk image to the second disk image.

在本发明的一些实施例中,接收单元510还可用于,接收对第一磁盘镜像块大小的调整指令之前接收磁盘镜像创建指令;创建单元520还可用于,创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与上述容量之间满足预设的对应关系。In some embodiments of the present invention, the receiving unit 510 may also be configured to receive a disk image creation instruction before receiving an instruction to adjust the block size of the first disk image; the creation unit 520 may also be configured to create the first disk image, wherein the first The capacity of a disk image is the capacity indicated by the above-mentioned disk image creation instruction, and the block size of the first disk image satisfies a preset corresponding relationship with the above-mentioned capacity.

举例来说,若第一磁盘镜像的容量等于S字节,则第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,n和m为正整数。当然,第一磁盘镜像的块大小与其容量之间,亦可满足预设的其它对应关系,此处不再一一举例,主要目的是创建出的第一磁盘镜像的块大小与容量之间相匹配。For example, if the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2n -1 < S≤2n , 9≤m≤n-17, Among them, n and m are positive integers. Of course, the block size of the first disk image and its capacity can also satisfy other preset corresponding relationships, and examples are not given here. The main purpose is to create a correspondence between the block size and capacity of the first disk image. match.

在本发明的另一些实施例中,接收单元510还可用于,接收对第一磁盘镜像块大小的调整指令之前接收磁盘镜像创建指令;创建单元520还用于,创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示块大小。In some other embodiments of the present invention, the receiving unit 510 is further configured to receive the disk image creation instruction before receiving the instruction for adjusting the block size of the first disk image; the creation unit 520 is also configured to create the first disk image, wherein, The capacity of the first disk image is the capacity indicated by the above disk image creation instruction, and the block size of the first disk image is the block size indicated by the above disk image creation instruction.

在本发明一些实施例中,接收单元510接收到磁盘镜像创建指令后,创建单元520可先判断该磁盘镜像创建指令所指示的块大小是否等于2的x次方,若不是,则可返回磁盘镜像创建失败指令,以指示无法按需创建磁盘镜像,若是则创建第一磁盘镜像。In some embodiments of the present invention, after the receiving unit 510 receives the disk image creation instruction, the creation unit 520 can first judge whether the block size indicated by the disk image creation instruction is equal to 2 to the power of x, and if not, return the disk The image creation failure instruction indicates that the disk image cannot be created on demand, and if so, create the first disk image.

在本发明另的一些实施例中,接收单元510在接收到磁盘镜像创建指令之后,创建单元520还可先判断该第一磁盘镜像块大小的调整指令所指示的块大小(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是,则创建第一磁盘镜像,其中,此场景下创建的第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,并且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小,来创建第一磁盘镜像,此场景下创建的第一磁盘镜像的块大小为2x-1或2x字节。其中,上述x为自然数,x大于或等于9为宜。In some other embodiments of the present invention, after the receiving unit 510 receives the disk image creation instruction, the creation unit 520 may first determine the block size indicated by the block size adjustment instruction of the first disk image (for ease of description, indicate The block size of B is used to indicate whether it is equal to 2 to the power of x, and if so, create the first disk image, where the block size of the first disk image created in this scenario is the block size indicated by the above disk image creation command B bytes; if not, and 2 x-1 <B<2 x , then for example, 2 x-1 bytes or 2 x bytes can be used as the block size indicated by the adjustment instruction to create the first disk image, this The block size of the first disk image created in the scenario is 2 x-1 or 2 x bytes. Wherein, the above-mentioned x is a natural number, preferably x is greater than or equal to 9.

参见图5-b,在本发明的另一些实施例中,磁盘镜像的块调整装置500还可包括:数据读写单元540,用于在接收单元510接收对第一磁盘镜像块大小的调整指令之后,且在第一磁盘镜像关闭之前,若接收到指示向第一磁盘镜像写入第一数据的写操作指令,且还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据,则向第一磁盘镜像和第二磁盘镜像分别写入第一数据。Referring to FIG. 5-b, in some other embodiments of the present invention, the disk image block adjustment device 500 may further include: a data reading and writing unit 540, which is used to receive an adjustment instruction for the first disk image block size at the receiving unit 510 Afterwards, and before the first disk image is closed, if a write operation command indicating to write the first data to the first disk image is received, and the data stored in the first disk image has not been copied to the second disk image, then Writing first data to the first disk image and the second disk image respectively.

参见图5-c,在本发明的另一些实施例中,磁盘镜像的块调整装置500还可包括:管理单元550,用于在第一虚拟机关机时,其中,第一虚拟机为使用第一磁盘镜像的虚拟机,若已经向第二磁盘镜像拷贝完了第一磁盘镜像中存储的数据,则关闭第二磁盘镜像;若还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据,则可在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,关闭第二磁盘镜像。Referring to FIG. 5-c, in some other embodiments of the present invention, the block adjustment device 500 for disk mirroring may further include: a management unit 550, configured to shut down the first virtual machine, wherein the first virtual machine uses the second For a virtual machine with a disk image, if the data stored in the first disk image has been copied to the second disk image, the second disk image is turned off; if the data stored in the first disk image has not been copied to the second disk image , after the data stored in the first disk image is copied to the second disk image, the second disk image can be closed.

举例来说,在接收对第一磁盘镜像块大小的调整指令之后,管理单元550可向镜像配置文件中写入的第一磁盘镜像的标识和块大小调整状态指示等,以标识当前第一磁盘镜像处于块大小调整状态,后续可根据镜像配置文件中写入的第一磁盘镜像的标识和块大小调整状态指示,确定第一磁盘镜像还处于块大小调整状态,当然,也可通过其它方式来标识第一磁盘镜像是否处于块大小调整状态。进一步的,数据转移单元530当向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,管理单元550可向镜像配置文件中写入对应第一磁盘镜像的数据拷贝完成标识,以标识第一磁盘镜像块大小调整结束。后续可根据镜像配置文件中写入的对应第一磁盘镜像的数据拷贝完成标识,确定第一磁盘镜像的块大小调整已经结束。For example, after receiving an instruction to adjust the block size of the first disk image, the management unit 550 may write the identifier of the first disk image and an indication of the block size adjustment state in the image configuration file to identify the current first disk image The image is in the block size adjustment state, and you can determine that the first disk image is still in the block size adjustment state according to the identifier and block size adjustment state of the first disk image written in the image configuration file. Of course, other methods can also be used to Identifies whether the first disk image is in block resizing state. Further, after the data transfer unit 530 copies the data stored in the first disk image to the second disk image, the management unit 550 can write the data copy completion flag corresponding to the first disk image into the image configuration file to identify the second disk image. A disk image block resizing is complete. Subsequently, it may be determined that the block size adjustment of the first disk image has been completed according to the data copy completion flag corresponding to the first disk image written in the image configuration file.

若在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,管理单元550向镜像配置文件中写入对应第一磁盘镜像的数据拷贝完成标识,则在第一VM关机时,管理单元550可读取镜像配置文件,若读取的镜像配置文件中写入了对应第一磁盘镜像的数据拷贝完成标识,则确定已经向第二磁盘镜像拷贝完了第一磁盘镜像中存储的数据(即第一磁盘镜像块大小调整已经结束),若读取的镜像配置文件未写入对应第一磁盘镜像的数据拷贝完成标识,则确定还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据(即第一磁盘镜像块大小调整未结束)。当然,管理单元550也可通过其它方式来标识第一磁盘镜像块大小调整状态是否已经结束。If after copying the data stored in the first disk image to the second disk image, the management unit 550 writes the data copy completion flag corresponding to the first disk image to the image configuration file, then when the first VM is shut down, the management unit 550 can read the image configuration file, if the data copy completion mark corresponding to the first disk image is written in the read image configuration file, then it is determined that the data stored in the first disk image has been copied to the second disk image (i.e. The block size adjustment of the first disk image has been completed), if the image configuration file read does not write the data copy completion flag corresponding to the first disk image, it is determined that the data stored in the first disk image has not been copied to the second disk image data (i.e. first disk image block resizing not completed). Of course, the management unit 550 may also use other methods to identify whether the first disk image block size adjustment state has ended.

可以理解的是,本实施例的磁盘镜像的块调整装置500的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of the functional modules of the block adjustment device 500 for disk mirroring in this embodiment can be specifically implemented according to the method in the above-mentioned method embodiment, and the specific implementation process can refer to the relevant description of the above-mentioned method embodiment, here No longer.

参见图6,图6为本发明实施例提供的一种计算机600的示意图,计算机600可包括输入装置610、输出装置620、存储器630和处理器640(计算机中的处理器640的数量可以1个或多个,图6中以1个处理器为例)。在本发明的一些实施例中,输入装置610、输出装置620、存储器630和处理器640可通过总线或其它方式连接,其中,图6中以通过总线连接为例。Referring to FIG. 6, FIG. 6 is a schematic diagram of a computer 600 provided by an embodiment of the present invention. The computer 600 may include an input device 610, an output device 620, a memory 630, and a processor 640 (the number of processors 640 in the computer may be one or more, one processor is taken as an example in Figure 6). In some embodiments of the present invention, the input device 610 , the output device 620 , the memory 630 and the processor 640 may be connected through a bus or in other ways, wherein connection through a bus is taken as an example in FIG. 6 .

其中,处理器640执行如下步骤:Wherein, the processor 640 performs the following steps:

接收对第一磁盘镜像块大小的调整指令;创建第二磁盘镜像,其中,第二磁盘镜像的块大小为上述调整指令所指示的块大小;向第二磁盘镜像拷贝第一磁盘镜像中存储的数据。Receive an adjustment instruction to the block size of the first disk image; create a second disk image, wherein the block size of the second disk image is the block size indicated by the above adjustment instruction; copy the data stored in the first disk image to the second disk image data.

在本发明的一些实施例中,处理器640接收到的对第一磁盘镜像块大小的调整指令可包含块大小指示,其中,该块大小指示可用于指示出需调整到的目标块大小(例如2MB字节、4MB、8MB或其它块大小)。其中,上述对第一磁盘镜像块大小的调整指令,可由第一磁盘镜像的磁盘镜像驱动发出或者可由使用第一磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或用户发出。进一步的,对第一磁盘镜像块大小的调整指令中还可包含第一磁盘镜像的标识,当然也可通过其它方式来确定是要对第一磁盘镜像的块大小进行调整,例如,若上述第一磁盘镜像块大小的调整指令由使用第一磁盘镜像的第一VM发出,则可默认为是要对第一磁盘镜像的块大小进行调整。或者若第一磁盘镜像块大小的调整指令包含有使用第一磁盘镜像的第一VM的标识,则处理器640可根据第一VM的标识确定是要对第一磁盘镜像的块大小进行调整,其它方式可以此类推。In some embodiments of the present invention, the instruction for adjusting the block size of the first disk image received by the processor 640 may include a block size indication, where the block size indication may be used to indicate the target block size to be adjusted (for example 2MB bytes, 4MB, 8MB or other block sizes). Wherein, the above-mentioned adjustment instruction for the block size of the first disk image may be issued by the disk image driver of the first disk image, or may be issued by a VM using the first disk image (for ease of reference, it may be referred to as the first VM), or may be issued by other Issued by an object or user. Further, the instruction for adjusting the block size of the first disk image may also include the identifier of the first disk image. Of course, other methods may also be used to determine whether to adjust the block size of the first disk image. For example, if the above-mentioned An instruction to adjust the block size of a disk image is issued by the first VM using the first disk image, and it may be assumed by default that the block size of the first disk image is to be adjusted. Or if the adjustment instruction of the block size of the first disk image includes the identifier of the first VM using the first disk image, the processor 640 can determine according to the identifier of the first VM whether to adjust the block size of the first disk image, Other ways can be deduced by analogy.

在本发明的一些实施例中,在接收对第一磁盘镜像块大小的调整指令之前处理器640还可执行如下步骤:In some embodiments of the present invention, before receiving the instruction to adjust the size of the first disk image block, the processor 640 may also perform the following steps:

接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与上述容量之间满足预设的对应关系。Receiving a disk image creation instruction; creating a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the above-mentioned capacity satisfy a preset corresponding relationship.

举例来说,若第一磁盘镜像的容量等于S字节,则第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,n和m为正整数。当然,第一磁盘镜像的块大小与其容量之间亦可满足预设的其它对应关系,此处不再一一举例,主要目的是创建出的第一磁盘镜像的块大小与容量之间相匹配。For example, if the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2n -1 < S≤2n , 9≤m≤n-17, Among them, n and m are positive integers. Of course, the block size of the first disk image and its capacity can also meet other preset correspondences, and examples are not given here. The main purpose is to match the block size and capacity of the created first disk image. .

在本发明另一些实施例中,在接收对第一磁盘镜像块大小的调整指令之前处理器640还可执行如下步骤:In other embodiments of the present invention, the processor 640 may further perform the following steps before receiving the instruction for adjusting the size of the first disk image block:

接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小为磁盘镜像创建指令所指示的块大小。Receive a disk image creation instruction; create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the block size indicated by the disk image creation instruction.

在本发明的一些实施例中,在接收到磁盘镜像创建指令之后,处理器640可先判断该磁盘镜像创建指令所指示的块大小是否等于2的x次方,若不是,则可返回磁盘镜像创建失败指令,以指示无法按需创建磁盘镜像,若是则执行创建第一磁盘镜像的步骤。In some embodiments of the present invention, after receiving the disk image creation instruction, the processor 640 can first judge whether the block size indicated by the disk image creation instruction is equal to 2 to the power of x, if not, it can return to the disk image A failure instruction is created to indicate that the disk image cannot be created on demand, and if so, the step of creating the first disk image is executed.

在本发明的一些实施例中,在接收到磁盘镜像创建指令之后,处理器640可先判断该第一磁盘镜像块大小的调整指令所指示的块大小(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是,则执行创建第一磁盘镜像的步骤,其中,此场景下创建的第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,并且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小,来执行创建第一磁盘镜像的步骤,此场景下创建的第一磁盘镜像的块大小为2x-1或2x字节。其中,上述x为自然数,x大于或等于9为宜。In some embodiments of the present invention, after receiving the disk image creation instruction, the processor 640 may first determine the block size indicated by the first disk image block size adjustment instruction (for ease of description, the indicated block size is used for B indicates whether) is equal to 2 to the power of x, and if so, execute the step of creating the first disk image, where the block size of the first disk image created in this scenario is the block size B indicated by the above disk image creation command section; if not, and 2 x-1 <B<2 x , then for example, 2 x-1 bytes or 2 x bytes can be used as the block size indicated by the adjustment instruction to perform the step of creating the first disk image, The block size of the first disk image created in this scenario is 2 x-1 or 2 x bytes. Wherein, the above-mentioned x is a natural number, preferably x is greater than or equal to 9.

在本发明一些实施例中,处理器640可按照扇区到扇区的拷贝方式,向第二磁盘镜像拷贝第一磁盘镜像中存储的数据。进一步的,在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,可将使用第一磁盘镜像的第一VM使用的磁盘镜像变换为第二磁盘镜像,并可关闭第一磁盘镜像。In some embodiments of the present invention, the processor 640 may copy the data stored in the first disk image to the second disk image in a sector-to-sector copy manner. Further, after copying the data stored in the first disk image to the second disk image, the disk image used by the first VM using the first disk image can be converted to the second disk image, and the first disk image can be closed .

在本发明一些实施例中,处理器640接收对第一磁盘镜像块大小的调整指令之后还可包括:在第一磁盘镜像关闭之前,若接收到指示向第一磁盘镜像写入第一数据的写操作指令,且还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据(此时第一磁盘镜像还处于块大小调整状态),则可向第一磁盘镜像和第二磁盘镜像分别写入第一数据。例如,在接收对第一磁盘镜像块大小的调整指令之后,处理器640可向镜像配置文件中写入的第一磁盘镜像的标识和块大小调整状态指示等,以标识当前第一磁盘镜像处于块大小调整状态,后续处理器640可根据镜像配置文件中写入的第一磁盘镜像的标识和块大小调整状态指示,确定第一磁盘镜像还处于块大小调整状态,当然,也可通过其它方式来标识第一磁盘镜像是否处于块大小调整状态。进一步的,当向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,处理器640可向镜像配置文件中写入对应第一磁盘镜像的数据拷贝完成标识,以标识第一磁盘镜像块大小调整结束。后续处理器640可根据镜像配置文件中写入的对应第一磁盘镜像的数据拷贝完成标识,确定第一磁盘镜像的块大小调整已经结束。In some embodiments of the present invention, after receiving the instruction to adjust the block size of the first disk image, the processor 640 may further include: before closing the first disk image, if receiving an instruction to write the first data to the first disk image Write operation command, and the data stored in the first disk image has not been copied to the second disk image (at this time, the first disk image is still in the block size adjustment state), then the first disk image and the second disk image can be respectively Write first data. For example, after receiving an instruction to adjust the block size of the first disk image, the processor 640 may write the identifier of the first disk image and an indication of the block size adjustment state in the image configuration file to identify that the current first disk image is in block size adjustment state, the follow-up processor 640 can determine that the first disk image is still in the block size adjustment state according to the identification of the first disk image written in the image configuration file and the block size adjustment state indication, of course, other methods can also be used to identify whether the first disk image is in block resizing state. Further, after copying the data stored in the first disk image to the second disk image, the processor 640 can write the data copy completion flag corresponding to the first disk image to the image configuration file to identify the first disk image block Resizing is complete. The subsequent processor 640 may determine that the block size adjustment of the first disk image has been completed according to the data copy completion flag corresponding to the first disk image written in the image configuration file.

在本发明一些实施例中,在第一VM关机时,若已经向第二磁盘镜像拷贝完了第一磁盘镜像中存储的数据,则处理器640可关闭第二磁盘镜像;若还未向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据,则处理器640可在向第二磁盘镜像拷贝完第一磁盘镜像中存储的数据之后,关闭第二磁盘镜像。其中第一VM为使用第一磁盘镜像的VM。In some embodiments of the present invention, when the first VM is shut down, if the data stored in the first disk image has been copied to the second disk image, the processor 640 can close the second disk image; After the disk image has copied the data stored in the first disk image, the processor 640 may close the second disk image after copying the data stored in the first disk image to the second disk image. Wherein the first VM is a VM using the first disk image.

可以理解的是,本实施例的计算机600的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of the functional modules of the computer 600 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

请参见图7,图7为本发明实施例提供的一种磁盘镜像创建装置700的结构示意图,磁盘镜像创建装置700可包括:Please refer to FIG. 7. FIG. 7 is a schematic structural diagram of a disk image creation device 700 provided by an embodiment of the present invention. The disk image creation device 700 may include:

接收单元710和创建单元720。A receiving unit 710 and a creating unit 720 .

其中,接收单元710,用于接收磁盘镜像创建指令。Wherein, the receiving unit 710 is configured to receive a disk image creation instruction.

在本发明的一些实施例中,接收单元710接收到的磁盘镜像创建指令可包含磁盘镜像容量指示,其中,上述磁盘镜像容量指示于指示出请求磁盘镜像的目标容量。其中,上述磁盘镜像创建指令,例如可由磁盘镜像驱动发出或者可由需使用磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或者用户发出。In some embodiments of the present invention, the disk image creation instruction received by the receiving unit 710 may include a disk image capacity indication, wherein the disk image capacity indication indicates the target capacity of the requested disk image. Wherein, the above-mentioned disk image creation instruction may be issued by, for example, a disk image driver, or may be issued by a VM that needs to use the disk image (for ease of reference, may be referred to as the first VM), or may be issued by other objects or users.

创建单元720,用于创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与上述容量之间满足预设的对应关系。The creation unit 720 is configured to create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the above disk image creation instruction, and the block size of the first disk image and the above capacity satisfy a preset corresponding relationship.

在本发明的一些实施例中,第一磁盘镜像的块大小与容量之间满足预设的对应关系可如下:若第一磁盘镜像的容量等于S字节,则第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中n和m为正整数。当然,第一磁盘镜像的块大小与其容量之间亦可满足预设的其它对应关系,此处不再一一举例,主要目的是创建出的第一磁盘镜像的块大小与容量之间相匹配。In some embodiments of the present invention, the preset corresponding relationship between the block size and capacity of the first disk image can be as follows: if the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, where 2 n-1 <S≤2 n , 9≤m≤n-17, where n and m are positive integers. Of course, the block size of the first disk image and its capacity can also meet other preset correspondences, and examples are not given here. The main purpose is to match the block size and capacity of the created first disk image. .

可以理解的是,本实施例的磁盘镜像创建装置700的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of each functional module of the disk image creation apparatus 700 of this embodiment can be specifically implemented according to the method in the above-mentioned method embodiment, and the specific implementation process can refer to the relevant description of the above-mentioned method embodiment, and will not be repeated here. repeat.

参见图8,图8为本发明实施例提供的一种计算机800的示意图,计算机800可包括输入装置810、输出装置820、存储器830和处理器840(计算机中的处理器840的数量可以1个或多个,图8中以1个处理器为例)。在本发明的一些实施例中,输入装置810、输出装置820、存储器830和处理器840可通过总线或其它方式连接,其中,图8中以通过总线连接为例。Referring to FIG. 8, FIG. 8 is a schematic diagram of a computer 800 provided by an embodiment of the present invention. The computer 800 may include an input device 810, an output device 820, a memory 830, and a processor 840 (the number of processors 840 in the computer may be one or more, one processor is taken as an example in Figure 8). In some embodiments of the present invention, the input device 810 , the output device 820 , the memory 830 and the processor 840 may be connected via a bus or in other ways, wherein connection via a bus is taken as an example in FIG. 8 .

其中,处理器840执行如下步骤:Wherein, the processor 840 performs the following steps:

接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小与上述容量之间满足预设的对应关系。Receive a disk image creation instruction; create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the above disk image creation instruction, and the block size of the first disk image and the above capacity satisfy a preset corresponding relationship.

在本发明的一些实施例中,处理器840接收到的磁盘镜像创建指令可包含磁盘镜像容量指示,其中,上述磁盘镜像容量指示于指示出请求磁盘镜像的目标容量。其中,上述磁盘镜像创建指令,例如可由磁盘镜像驱动发出或者可由需使用磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或者用户发出。In some embodiments of the present invention, the disk image creation command received by the processor 840 may include a disk image capacity indication, wherein the disk image capacity indication indicates the target capacity of the requested disk image. Wherein, the above-mentioned disk image creation instruction may be issued by, for example, a disk image driver, or may be issued by a VM that needs to use the disk image (for ease of reference, may be referred to as the first VM), or may be issued by other objects or users.

在本发明的一些实施例中,第一磁盘镜像的块大小与容量之间满足预设的对应关系可如下:若第一磁盘镜像的容量等于S字节,则第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中n和m为正整数。当然,第一磁盘镜像的块大小与其容量之间,亦可满足预设的其它对应关系,此处不再一一举例,主要目的是创建出的第一磁盘镜像的块大小与容量之间相匹配。In some embodiments of the present invention, the preset corresponding relationship between the block size and capacity of the first disk image can be as follows: if the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, where 2 n-1 <S≤2 n , 9≤m≤n-17, where n and m are positive integers. Of course, the block size of the first disk image and its capacity can also satisfy other preset corresponding relationships, and examples are not given here. The main purpose is to create a correspondence between the block size and capacity of the first disk image. match.

可以理解的是,本实施例的计算机800的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of the functional modules of the computer 800 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

请参见图9,图9为本发明实施例提供的另一种磁盘镜像创建装置900的示意图,磁盘镜像创建装置900可包括:接收单元910和创建单元920。Please refer to FIG. 9 . FIG. 9 is a schematic diagram of another disk image creation device 900 according to an embodiment of the present invention. The disk image creation device 900 may include: a receiving unit 910 and a creation unit 920 .

其中,接收单元910,用于接收磁盘镜像创建指令。Wherein, the receiving unit 910 is configured to receive a disk image creation instruction.

在本发明的一些实施例中,接收单元910接收到的磁盘镜像创建指令可包含磁盘镜像容量指示和块大小指示,其中,该磁盘镜像容量指示于指示出请求磁盘镜像的目标容量;其中,上述块大小指示可用于指示出需调整到的目标块大小。其中,上述磁盘镜像创建指令,例如可由磁盘镜像驱动发出或可由需使用将创建出的磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或者用户发出。In some embodiments of the present invention, the disk image creation instruction received by the receiving unit 910 may include a disk image capacity indication and a block size indication, wherein the disk image capacity indication indicates the target capacity of the requested disk image; wherein, the above A block size indication can be used to indicate the target block size to adjust to. Wherein, the above-mentioned disk image creation instruction may be issued by, for example, a disk image driver, or may be issued by a VM (for ease of reference, referred to as the first VM) that needs to use the disk image to be created, or may be issued by other objects or users.

创建单元920,用于创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小。The creation unit 920 is configured to create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the block size indicated by the disk image creation instruction.

在本发明的一些实施例中,在接收单元910接收到磁盘镜像创建指令之后,创建单元920还可先判断该磁盘镜像创建指令所指示的块大小是否等于2的x次方,若不是,则可返回磁盘镜像创建失败指令(以指示无法按需创建磁盘镜像),若是则创建第一磁盘镜像。In some embodiments of the present invention, after the receiving unit 910 receives the disk image creation instruction, the creation unit 920 can also first judge whether the block size indicated by the disk image creation instruction is equal to 2 to the power of x, if not, then A disk image creation failure instruction may be returned (indicating that the disk image cannot be created on demand), and if so, the first disk image is created.

在本发明的另一些实施例中,在接收单元910接收到磁盘镜像创建指令之后,创建单元920可判断该第一磁盘镜像块大小的调整指令所指示的块大小(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是,则创建第一磁盘镜像,其中,此场景下创建的第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,并且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小,来创建第一磁盘镜像,此场景下创建的第一磁盘镜像的块大小为2x-1或2x字节。其中,上述x为自然数,x大于或等于9为宜。In other embodiments of the present invention, after the receiving unit 910 receives the disk image creation instruction, the creation unit 920 may determine the block size indicated by the first disk image block size adjustment instruction (for ease of description, the indicated block The size is used to indicate whether B) is equal to 2 to the power of x, and if so, create the first disk image, where the block size of the first disk image created in this scenario is the block size B indicated by the above disk image creation command section; if not, and 2 x-1 <B<2 x , then for example, 2 x-1 bytes or 2 x bytes can be used as the block size indicated by the adjustment command to create the first disk image, in this scenario The block size of the created first disk image is 2 x-1 or 2 x bytes. Wherein, the above-mentioned x is a natural number, preferably x is greater than or equal to 9.

可以理解的是,本实施例的磁盘镜像创建装置900的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of the functional modules of the disk image creation apparatus 900 in this embodiment can be specifically implemented according to the method in the above-mentioned method embodiment, and the specific implementation process can refer to the relevant description of the above-mentioned method embodiment, and will not be repeated here. repeat.

参见图10,图10为本发明实施例提供的一种计算机1000的示意图,计算机1000可包括输入装置1010、输出装置1020、存储器1030和处理器1040(计算机中的处理器1040的数量可以1个或多个,图10中以1个处理器为例)。在本发明的一些实施例中,输入装置1010、输出装置1020、存储器1030和处理器1040可通过总线或其它方式连接,其中,图10中以通过总线连接为例。Referring to FIG. 10, FIG. 10 is a schematic diagram of a computer 1000 provided by an embodiment of the present invention. The computer 1000 may include an input device 1010, an output device 1020, a memory 1030, and a processor 1040 (the number of processors 1040 in the computer may be one or more, one processor is taken as an example in Figure 10). In some embodiments of the present invention, the input device 1010 , the output device 1020 , the memory 1030 and the processor 1040 may be connected via a bus or in other ways, wherein connection via a bus is taken as an example in FIG. 10 .

其中,处理器1040执行如下步骤:Wherein, the processor 1040 performs the following steps:

接收磁盘镜像创建指令;创建第一磁盘镜像,其中,第一磁盘镜像的容量为上述磁盘镜像创建指令所指示的容量,第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小。Receive a disk image creation instruction; create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the above disk image creation instruction, and the block size of the first disk image is the block size indicated by the above disk image creation instruction.

在本发明的一些实施例中,处理器1040接收到的磁盘镜像创建指令可包含磁盘镜像容量指示和块大小指示,其中,该磁盘镜像容量指示于指示出请求磁盘镜像的目标容量;其中,上述块大小指示可用于指示出需调整到的目标块大小。其中,上述磁盘镜像创建指令,例如可由磁盘镜像驱动发出或可由需使用将创建出的磁盘镜像的VM(为便于引述,可称之为第一VM)发出或者可由其它对象或者用户发出。In some embodiments of the present invention, the disk image creation instruction received by the processor 1040 may include a disk image capacity indication and a block size indication, wherein the disk image capacity indication indicates the target capacity of the requested disk image; wherein, the above A block size indication can be used to indicate the target block size to adjust to. Wherein, the above-mentioned disk image creation instruction may be issued by, for example, a disk image driver, or may be issued by a VM (for ease of reference, referred to as the first VM) that needs to use the disk image to be created, or may be issued by other objects or users.

在本发明的一些实施例中,在接收到磁盘镜像创建指令之后,处理器1040还可先判断该磁盘镜像创建指令所指示的块大小是否等于2的x次方,若不是则可返回磁盘镜像创建失败指令,以指示无法按需创建磁盘镜像,若是则执行创建第一磁盘镜像的步骤。In some embodiments of the present invention, after receiving the disk image creation instruction, the processor 1040 can also first judge whether the block size indicated by the disk image creation instruction is equal to 2 to the power of x, and if not, return to the disk image A failure instruction is created to indicate that the disk image cannot be created on demand, and if so, the step of creating the first disk image is executed.

在本发明另一些实施例中,在接收到磁盘镜像创建指令之后,处理器1040还可先判断该第一磁盘镜像块大小的调整指令所指示的块大小(为便于描述,指示的块大小用于B表示)是否等于2的x次方,若是,则执行创建第一磁盘镜像的步骤,其中,此场景下创建的第一磁盘镜像的块大小为上述磁盘镜像创建指令所指示的块大小B字节;若否,并且2x-1<B<2x,则例如可以2x-1字节或2x字节作为该调整指令所指示的块大小,来执行创建第一磁盘镜像的步骤,此场景下创建的第一磁盘镜像的块大小为2x-1或2x字节。其中,x为自然数,x大于或等于9为宜。In other embodiments of the present invention, after receiving the disk image creation instruction, the processor 1040 may first determine the block size indicated by the first disk image block size adjustment instruction (for ease of description, the indicated block size is represented by Indicated by B) is equal to 2 to the power of x, if so, execute the step of creating the first disk image, wherein the block size of the first disk image created in this scenario is the block size B indicated by the above disk image creation command byte; if not, and 2 x-1 <B<2 x , then for example, 2 x-1 bytes or 2 x bytes can be used as the block size indicated by the adjustment instruction to perform the step of creating the first disk image , the block size of the first disk image created in this scenario is 2 x-1 or 2 x bytes. Wherein, x is a natural number, preferably x is greater than or equal to 9.

可以理解的是,本实施例的计算机1000的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of the functional modules of the computer 1000 in this embodiment can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the relevant descriptions of the above method embodiments, and will not be repeated here.

本发明实施例还提供一种计算机存储介质,其中,该计算机存储介质可存储有程序,该程序执行时包括上述方法实施例中记载的磁盘镜像的块调整方法或磁盘镜像创建方法的部分或全部步骤。An embodiment of the present invention also provides a computer storage medium, wherein the computer storage medium can store a program, and when the program is executed, it includes part or all of the disk image block adjustment method or the disk image creation method described in the above method embodiment step.

需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。It should be noted that for the foregoing method embodiments, for the sake of simple description, they are expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. Because of the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the foregoing embodiments, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the above units is only a logical function division. In actual implementation, there may be other division methods, for example, multiple units or components can be combined or integrated. to another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical or other forms.

上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

上述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例上述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。If the above integrated units are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions for enabling a computer device (which may be a personal computer, server or network device, etc.) to execute all or part of the steps of the above-mentioned methods in various embodiments of the present invention. The aforementioned storage media include: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes. .

以上上述,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。The above, the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still be applied to the foregoing embodiments. The technical solutions described in the embodiments are modified, or some of the technical features are replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (14)

1.一种磁盘镜像的块调整方法,其特征在于,包括:1. A block adjustment method of disk mirroring, characterized in that, comprising: 接收对第一磁盘镜像块大小的调整指令;receiving an adjustment instruction to the size of the first disk image block; 创建第二磁盘镜像,其中,所述第二磁盘镜像的块大小为所述调整指令所指示的块大小;Create a second disk image, wherein the block size of the second disk image is the block size indicated by the adjustment instruction; 向所述第二磁盘镜像拷贝所述第一磁盘镜像中存储的数据。Copying the data stored in the first disk image to the second disk image. 2.根据权利要求1所述的方法,其特征在于,2. The method of claim 1, wherein, 所述接收对第一磁盘镜像块大小的调整指令之前还包括:Before receiving the instruction for adjusting the size of the first disk image block, it also includes: 接收磁盘镜像创建指令;创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系;receiving a disk image creation instruction; creating a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the capacity satisfy preset correspondence; 或者,or, 接收磁盘镜像创建指令;创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示块大小。Receive a disk image creation instruction; create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the disk image creation instruction The indicated block size. 3.根据权利要求2所述的方法,其特征在于,3. The method of claim 2, wherein, 若所述第一磁盘镜像的容量等于S字节,则所述第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,所述n和m为正整数。If the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2 n-1 <S≤2 n , 9≤m≤n-17, Wherein, said n and m are positive integers. 4.根据权利要求1至3任一项所述的方法,其特征在于,4. The method according to any one of claims 1 to 3, characterized in that, 所述接收对第一磁盘镜像块大小的调整指令之后还包括:After receiving the adjustment instruction to the size of the first disk image block, it also includes: 在所述第一磁盘镜像关闭之前,若接收到指示向所述第一磁盘镜像写入第一数据的写操作指令,且还未向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据,则向所述第一磁盘镜像和所述第二磁盘镜像分别写入所述第一数据。Before the first disk image is closed, if a write operation command indicating to write the first data to the first disk image is received, and the first disk image has not been copied to the second disk image If the stored data is stored, write the first data to the first disk image and the second disk image respectively. 5.根据权利要求1至4任一项所述的方法,其特征在于,5. The method according to any one of claims 1 to 4, characterized in that, 在第一虚拟机关机时,其中,所述第一虚拟机为使用所述第一磁盘镜像的虚拟机,若已经向所述第二磁盘镜像拷贝完了所述第一磁盘镜像中存储的数据,则关闭所述第二磁盘镜像;若还未向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据,则可在向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据之后,关闭所述第二磁盘镜像。When the first virtual machine is shut down, wherein the first virtual machine is a virtual machine using the first disk image, if the data stored in the first disk image has been copied to the second disk image, Then close the second disk image; if the data stored in the first disk image has not been copied to the second disk image, the first disk image can be copied to the second disk image After storing the data in, turn off the second disk mirror. 6.一种磁盘镜像创建方法,其特征在于,包括:6. A method for creating a disk image, comprising: 接收磁盘镜像创建指令;Receive a disk image creation instruction; 创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系。Create a first disk image, where the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the capacity satisfy a preset corresponding relationship. 7.根据权利要求6所述的方法,其特征在于,7. The method of claim 6, wherein, 若所述第一磁盘镜像的容量等于S字节,则所述第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,所述n和m为正整数。If the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2 n-1 <S≤2 n , 9≤m≤n-17, Wherein, said n and m are positive integers. 8.一种磁盘镜像创建方法,其特征在于,包括:8. A method for creating a disk image, comprising: 接收磁盘镜像创建指令;Receive a disk image creation instruction; 创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示的块大小。Create a first disk image, where the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the block size indicated by the disk image creation instruction. 9.一种磁盘镜像的块调整装置,其特征在于,包括:9. A block adjustment device for disk mirroring, characterized in that it comprises: 接收单元,接收对第一磁盘镜像块大小的调整指令;The receiving unit receives an instruction for adjusting the size of the first disk image block; 创建单元,创建第二磁盘镜像,其中,所述第二磁盘镜像的块大小为所述调整指令所指示的块大小;The creating unit is configured to create a second disk image, where the block size of the second disk image is the block size indicated by the adjustment instruction; 数据转移单元,用于向所述第二磁盘镜像拷贝所述第一磁盘镜像中存储的数据。A data transfer unit, configured to copy the data stored in the first disk image to the second disk image. 10.根据权利要求9所述的装置,其特征在于,10. The apparatus of claim 9, wherein: 所述接收单元还用于,接收对第一磁盘镜像块大小的调整指令之前接收磁盘镜像创建指令;所述创建单元还用于,创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系。The receiving unit is also used to receive a disk image creation instruction before receiving an instruction to adjust the block size of the first disk image; the creation unit is also used to create a first disk image, wherein the capacity of the first disk image For the capacity indicated by the disk image creation instruction, the block size of the first disk image and the capacity satisfy a preset corresponding relationship. 或者,or, 所述接收单元还用于,接收对第一磁盘镜像块大小的调整指令之前接收磁盘镜像创建指令;所述创建单元还用于,创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示块大小。The receiving unit is also used to receive a disk image creation instruction before receiving an instruction to adjust the block size of the first disk image; the creation unit is also used to create a first disk image, wherein the capacity of the first disk image The capacity indicated by the disk image creation instruction, the block size of the first disk image is the block size indicated by the disk image creation instruction. 11.根据权利要求9或10所述的装置,其特征在于,11. Apparatus according to claim 9 or 10, characterized in that, 所述装置还包括:The device also includes: 数据读写单元,用于在所述接收单元接收对第一磁盘镜像块大小的调整指令之后,且在所述第一磁盘镜像关闭之前,若接收到指示向所述第一磁盘镜像写入第一数据的写操作指令,且还未向所述第二磁盘镜像拷贝完所述第一磁盘镜像中存储的数据,则向所述第一磁盘镜像和所述第二磁盘镜像分别写入所述第一数据。The data reading and writing unit is configured to, after the receiving unit receives an instruction to adjust the size of the first disk image block and before the first disk image is closed, if an instruction is received to write the first disk image to the first disk image A data write operation command, and the data stored in the first disk image has not been copied to the second disk image, then write the first disk image and the second disk image respectively to the first data. 12.一种磁盘镜像创建装置,其特征在于,包括:12. A device for creating a disk image, comprising: 接收单元,用于接收磁盘镜像创建指令;a receiving unit, configured to receive a disk image creation instruction; 创建单元,用于创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小与所述容量之间满足预设的对应关系。The creation unit is configured to create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image and the capacity meet a predetermined requirement. The corresponding relationship is set. 13.根据权利要求12所述的装置,其特征在于,13. The device of claim 12, wherein: 若所述第一磁盘镜像的容量等于S字节,则所述第一磁盘镜像的块大小等于2m字节,其中,2n-1<S≤2n,9≤m≤n-17,其中,所述n和m为正整数。If the capacity of the first disk image is equal to S bytes, then the block size of the first disk image is equal to 2 m bytes, wherein, 2 n-1 <S≤2 n , 9≤m≤n-17, Wherein, said n and m are positive integers. 14.一种磁盘镜像创建装置,其特征在于,包括:14. A device for creating a disk image, comprising: 接收单元,用于接收磁盘镜像创建指令;a receiving unit, configured to receive a disk image creation instruction; 创建单元,用于创建第一磁盘镜像,其中,所述第一磁盘镜像的容量为所述磁盘镜像创建指令所指示的容量,所述第一磁盘镜像的块大小为所述磁盘镜像创建指令所指示的块大小。The creation unit is configured to create a first disk image, wherein the capacity of the first disk image is the capacity indicated by the disk image creation instruction, and the block size of the first disk image is the disk image creation instruction. The indicated block size.
CN201210504938.8A 2012-11-30 2012-11-30 Disk mirror image block adjusting method, disk mirror image building method and relevant device Pending CN103853497A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210504938.8A CN103853497A (en) 2012-11-30 2012-11-30 Disk mirror image block adjusting method, disk mirror image building method and relevant device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210504938.8A CN103853497A (en) 2012-11-30 2012-11-30 Disk mirror image block adjusting method, disk mirror image building method and relevant device

Publications (1)

Publication Number Publication Date
CN103853497A true CN103853497A (en) 2014-06-11

Family

ID=50861214

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210504938.8A Pending CN103853497A (en) 2012-11-30 2012-11-30 Disk mirror image block adjusting method, disk mirror image building method and relevant device

Country Status (1)

Country Link
CN (1) CN103853497A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030191911A1 (en) * 2002-04-03 2003-10-09 Powerquest Corporation Using disassociated images for computer and storage resource management
CN1688981A (en) * 2002-08-09 2005-10-26 网络装置公司 Storage virtualization by layering virtual disk objects on a file system
CN101446976A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 File storage method in distributed file system
CN101556802A (en) * 2009-05-25 2009-10-14 杭州华三通信技术有限公司 RAID array transposing method and device thereof
CN102662727A (en) * 2012-04-05 2012-09-12 北京天地云箱科技有限公司 Virtual machine creating method and virtual machine creating device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030191911A1 (en) * 2002-04-03 2003-10-09 Powerquest Corporation Using disassociated images for computer and storage resource management
CN1688981A (en) * 2002-08-09 2005-10-26 网络装置公司 Storage virtualization by layering virtual disk objects on a file system
CN101446976A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 File storage method in distributed file system
CN101556802A (en) * 2009-05-25 2009-10-14 杭州华三通信技术有限公司 RAID array transposing method and device thereof
CN102662727A (en) * 2012-04-05 2012-09-12 北京天地云箱科技有限公司 Virtual machine creating method and virtual machine creating device

Similar Documents

Publication Publication Date Title
TWI492061B (en) Selective enablement of operating modes or features via host transfer rate detection
CN103034566B (en) Method and device for restoring virtual machine
US20210278998A1 (en) Architecture and design of a storage device controller for hyperscale infrastructure
CN103412822B (en) Operation Nonvolatile memory and the method and relevant apparatus of data manipulation
US20180081548A1 (en) Storage device efficiency during data replication
US20140095555A1 (en) File management device and method for storage system
US9792075B1 (en) Systems and methods for synthesizing virtual hard drives
CN102681912B (en) Improving network efficiency for continuous remote copy
CN105227672B (en) The method and system that data are stored and accessed
CN104520802B (en) Data sending method, data receiving method and storage device
CN105808163A (en) Method and server for accessing shingled magnetic recording SMR hard disk
US12141118B2 (en) Optimizing storage system performance using data characteristics
US11977785B2 (en) Non-volatile memory device-assisted live migration of virtual machine data
CN106445421A (en) Storage system data migration method and system
WO2013029434A1 (en) Method and device for writing data into production volume
CN116540952B (en) Disk access methods and devices, storage media, electronic equipment
US8468007B1 (en) Emulating a peripheral mass storage device with a portable device
CN103488431A (en) Data-writing method and storage device
CN108604162A (en) Optimize the access to creation data
WO2024230250A1 (en) Method for managing storage resources, electronic device, and computer readable storage medium
CN111324414B (en) NVM storage media emulator
CN107193693A (en) A kind of online data storage optimization method based on storage system
CN105607869A (en) Method for quickly formatting and using virtual machine disk
CN112000289A (en) Data management method for full flash storage server system and related components
CN115826874A (en) Method, device and assembly for realizing virtual RAID card

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into 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: 20140611