CN109388524A - The addressing method and computer readable storage medium of virtual disk format - Google Patents
The addressing method and computer readable storage medium of virtual disk format Download PDFInfo
- Publication number
- CN109388524A CN109388524A CN201811172062.5A CN201811172062A CN109388524A CN 109388524 A CN109388524 A CN 109388524A CN 201811172062 A CN201811172062 A CN 201811172062A CN 109388524 A CN109388524 A CN 109388524A
- Authority
- CN
- China
- Prior art keywords
- copy
- data
- block
- qcow2
- file
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1479—Generic software techniques for error detection or fault masking
- G06F11/1482—Generic software techniques for error detection or fault masking by means of middleware or OS functionality
- G06F11/1484—Generic software techniques for error detection or fault masking by means of middleware or OS functionality involving virtual machines
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
Abstract
The invention discloses the addressing methods and computer readable storage medium of a kind of virtual disk format.The described method includes: reading the L1 table and/or L2 table in the qcow2 file when receiving the addressing request of qcow2 file;After the data for detecting L1 table or L2 table are damaged, the table being damaged pre-stored copy in the qcow2 file is obtained;Read the data of the copy;According to the copy data, the addressing request is responded.
Description
Technical field
The present invention relates to field of information processing, the addressing method of espespecially a kind of virtual disk format and computer-readable storage
Medium.
Background technique
Qcow2 disc format is a kind of disk image format that qemu simulator is supported, one piece is indicated in a manner of file
The virtual disk of fixed size.It is unrelated with the rear end storage medium used due to using file, it can be easily stored in
On various backend file system/block devices.Compared with common raw format, qcow2 format has following advantage:
1, natural to support to simplify to purchase, even if backend file system does not support sparse file;
2, copy-on-write is supported;
3, snapshot is supported;
4, disk chain is supported, multiple qcow2 file superpositions indicate the virtual disk of a logic;
5, compression and encryption are supported.
Therefore, qcow2 is used very extensive in virtualization and field of cloud calculation, and a qcow2 file has several sizes
Identical piece (cluster) composition, the disk block that virtual machine internal is seen are mapped on each of qcow2 pieces one by one.
Fig. 1 is the schematic diagram of qcow2 file layout in the prior art.When giving a disk offset address, Ke Yitong
Its position in qcow2 can be positioned by crossing L1- > L2- shown in FIG. 1 > cluster offset.
Fig. 2 is the schematic diagram of the addressing logic of qcow2 file in the prior art, passes through addressing side shown in above-mentioned schematic diagram
Method, at least there are the following problems in the prior art for inventor's discovery:
When L1 table table and/or L2 table once destroying, will result in addressing operation can not be continued to execute, and often make
The problem of can not restoring at entire disk.
Summary of the invention
In order to solve the above-mentioned technical problems, the present invention provides a kind of addressing methods of virtual disk format and computer can
Storage medium is read, can be improved the success rate of addressing.
In order to reach the object of the invention, the present invention provides a kind of addressing methods of virtual disk format, which is characterized in that
Include:
When receiving the addressing request of qcow2 file, the L1 table and/or L2 table in the qcow2 file are read;
After the data for detecting L1 table or L2 table are damaged, the table being damaged is obtained in the qcow2
Pre-stored copy in file;
Read the data of the copy;
According to the copy data, the addressing request is responded.
Wherein, the table that the method also has a characteristic that the acquisition is damaged is pre- in the qcow2 file
Before the copy first stored, the method also includes:
Data block i needed for obtaining the data of storage L1 table, wherein i is the integer more than or equal to 1;
From MnA BOB(beginning of block) stores the data of L1 table in continuous i data block, as the copy of L1 table,
Wherein M is the prime number more than or equal to 11, and wherein n is the integer more than or equal to 1;
Record the storage location of the copy of the L1 table.
Wherein, the method also has a characteristic that the value of the M is 17.
Wherein, the method also has a characteristic that the storage location of the copy for recording the L1 table, comprising:
The information of the storage location of the copy of the L1 table is increased in qcow2 file header.
Wherein, the method also has a characteristic that described from MnA BOB(beginning of block) is deposited in continuous i data block
After the data for storing up L1 table, the method also includes:
Whether when detecting that qcow2 file is expanded, searching has number to accord in the block newly increased in dilation procedure
Close the object block of the integral number power of M;
The object block for meeting the integral number power of M if there is numbering, then from the target BOB(beginning of block), in continuous i data
In block, the data of L1 table are stored;
Record the storage location of the copy of the L1 table newly increased.
Wherein, the method also has a characteristic that described from MnA BOB(beginning of block) is deposited in continuous i data block
After the data for storing up L1 table, the method also includes:
Detecting that the data updated in the L1 table, which are synchronized to block number, is when updating the data in the L1 table
MnAll pieces, wherein [1, k] n ∈;Wherein:
K=round_up (logMbMax);
Wherein, bMax is the numerical value of qcow2 file largest block number, and round_up expression rounds up.
Wherein, the table that the method also has a characteristic that the acquisition is damaged is pre- in the qcow2 file
Before the copy first stored, the method also includes:
According to pre-set number selection strategy, copy of two blocks as L2 table is selected;
Record the storage location of the copy of the L2 table.
Wherein, the method also has a characteristic that described according to pre-set number selection strategy, selects two blocks
Copy as L2 table includes:
The data of storage L2 table in the available free block that number is even number, main piece as the L2 table copy;
Select number for the data of storage L2 table in the available free block of (a+b/2) mod b, as the L2 table pair
This slave block, wherein a is main piece of number of L2 table copy, and b is the maximum value of 2 integral number power no more than bMax,
Middle bMax is the largest block number of qcow2 file.
Wherein, the method also has a characteristic that described according to pre-set number selection strategy, selects two blocks
As the copy of L2 table, the method also includes:
If in the qcow2 file number be even number block in there is no idle block, in the text of the qcow2 file
Part tail increases new block, and when the number of new block is even number, the data of L2 table are stored in the block newly increased.
Wherein, the method also has a characteristic that the storage location of the copy for recording the L1 table, comprising:
The information of the storage location of the copy of the L2 table is increased in L1 table.
Wherein, the method also has a characteristic that described according to pre-set number selection strategy, selects two blocks
After copy as L2 table, the method also includes:
When detecting that qcow2 file is expanded, whether two blocks selected according to the number selection strategy are judged
It is changed according to the total block data of qcow2 file;
If there is a change, then corresponding piece of copy of number of all L2 tables, the block newly determined are recalculated;
Data in L2 table are moved to the block of the new determination from former storage location, and update the pair of the L2 table
This storage location.
Wherein, the method also has a characteristic that the data by L2 table move to institute from former storage location
After stating newly determining block, the method also includes:
The use state for marking the block of the former storage location is the free time.
Wherein, the method also has a characteristic that described according to pre-set number selection strategy, selects two blocks
After copy as L2 table, the method also includes:
When detecting the data in the update L2 table, the data updated in the L2 table are synchronized to described two
In a block.
Wherein, the method also has a characteristic that the data for reading the copy include:
When the copy of the table being damaged is multiple, according to pre-set copy reading order, to copy
Carry out the detection of data integrity;
When the data for detecting copy are complete, the data for reading the copy are executed, otherwise, next copy are selected to carry out
The detection of data integrity, until detecting data complete copy.
In order to reach the object of the invention, the present invention also provides a kind of computer readable storage mediums, store computer
Program, the computer program are executed by processor to realize following operation, comprising:
When receiving the addressing request of qcow2 file, the L1 table and/or L2 table in the qcow2 file are read;
After the data for detecting L1 table or L2 table are damaged, the table being damaged is obtained in the qcow2
Pre-stored copy in file;
Read the data of the copy;
According to the copy data, the addressing request is responded.
Wherein, the computer readable storage medium also has a characteristic that the table being damaged that obtains in institute
It states in qcow2 file before pre-stored copy, the computer program is also executed by processor to realize following operation, packet
It includes:
Data block i needed for obtaining the data of storage L1 table, wherein i is the integer more than or equal to 1;
From the Mn BOB(beginning of block), in continuous i data block, the data of L1 table are stored, as the copy of L1 table,
Wherein M is the prime number more than or equal to 11, and wherein n is the integer more than or equal to 1;
Record the storage location of the copy of the L1 table.
Wherein, the computer readable storage medium also has a characteristic that the value of the M is 17.
Wherein, the computer readable storage medium also has a characteristic that the copy for recording the L1 table
Storage location, comprising:
The information of the storage location of the copy of the L1 table is increased in qcow2 file header.
Wherein, the computer readable storage medium also has a characteristic that described from the Mn BOB(beginning of block), continuous
In i data block, after the data for storing L1 table, the meter computer program is also executed by processor to realize following behaviour
Make, comprising:
Whether when detecting that qcow2 file is expanded, searching has number to accord in the block newly increased in dilation procedure
Close the object block of the integral number power of M;
The object block for meeting the integral number power of M if there is numbering, then from the target BOB(beginning of block), in continuous i data
In block, the data of L1 table are stored;
Record the storage location of the copy of the L1 table newly increased.
Wherein, the computer readable storage medium also has a characteristic that described from the Mn BOB(beginning of block), continuous
In i data block, after the data for storing L1 table, the computer program is also executed by processor as follows with realization also execution
Operation, comprising:
Detecting that the data updated in the L1 table, which are synchronized to block number, is when updating the data in the L1 table
MnAll pieces, wherein [1, k] n ∈;Wherein:
K=round_up (logMbMax);
Wherein, bMax is the numerical value of qcow2 file largest block number, and round_up expression rounds up.
Wherein, the computer readable storage medium also has a characteristic that the table being damaged that obtains in institute
It states in qcow2 file before pre-stored copy, the computer readable storage medium also performs the following operations, comprising:
According to pre-set number selection strategy, copy of two blocks as L2 table is selected;
Record the storage location of the copy of the L2 table.
Wherein, the computer readable storage medium also has a characteristic that described according to the selection of pre-set number
Strategy, selecting two blocks as the copy of L2 table includes:
The data of storage L2 table in the available free block that number is even number, main piece as the L2 table copy;
Select number for the data of storage L2 table in the available free block of (a+b/2) mod b, as the L2 table pair
This slave block, wherein a is main piece of number of L2 table copy, and b is the maximum value of 2 integral number power no more than bMax,
Middle bMax is the largest block number of qcow2 file.
Wherein, the computer readable storage medium also has a characteristic that described according to the selection of pre-set number
Strategy, selects copy of two blocks as L2 table, and the computer program is also executed by processor to realize following operation, packet
It includes:
If in the qcow2 file number be even number block in there is no idle block, in the text of the qcow2 file
Part tail increases new block, and when the number of new block is even number, the data of L2 table are stored in the block newly increased.
Wherein, the computer readable storage medium also has a characteristic that the copy for recording the L1 table
Storage location, comprising:
The information of the storage location of the copy of the L2 table is increased in L1 table.
It is described to select plan according to pre-set number in computer readable storage medium embodiment provided by the invention
Slightly, after selecting copy of two blocks as L2 table, the computer program is also executed by processor to realize following operation,
Include:
When detecting that qcow2 file is expanded, whether two blocks selected according to the number selection strategy are judged
It is changed according to the total block data of qcow2 file;
If there is a change, then corresponding piece of copy of number of all L2 tables, the block newly determined are recalculated;
Data in L2 table are moved to the block of the new determination from former storage location, and update the pair of the L2 table
This storage location.
Wherein, the computer readable storage medium also has a characteristic that the data by L2 table are deposited from original
After storage space sets the block for moving to the new determination, the computer program is also executed by processor to realize following operation, packet
It includes:
The use state for marking the block of the former storage location is the free time.
It is described to select plan according to pre-set number in computer readable storage medium embodiment provided by the invention
Slightly, after selecting copy of two blocks as L2 table, the computer program is also executed by processor to realize following operation,
Include:
When detecting the data in the update L2 table, the data updated in the L2 table are synchronized to described two
In a block.
Wherein, the computer readable storage medium also has a characteristic that the data for reading the copy include:
When the copy of the table being damaged is multiple, according to pre-set copy reading order, to copy
Carry out the detection of data integrity;
When the data for detecting copy are complete, the data for reading the copy are executed, otherwise, next copy are selected to carry out
The detection of data integrity, until detecting data complete copy.
Embodiment provided by the invention is read in the qcow2 file when receiving the addressing request of qcow2 file
L1 table and/or L2 table obtain the table being damaged in institute if the data of L1 table or L2 table are damaged
Pre-stored copy in qcow2 file is stated, by reading the data of copy, responds the addressing request, realization passes through data
Copy repair Datagram purpose, promote qcow2 format recovery capability, and then promote the number of entire virtualization system
According to safety.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
It obtains it is clear that understand through the implementation of the invention.The objectives and other advantages of the invention can be by specification, right
Specifically noted structure is achieved and obtained in claim and attached drawing.
Detailed description of the invention
Attached drawing is used to provide to further understand technical solution of the present invention, and constitutes part of specification, with this
The embodiment of application technical solution for explaining the present invention together, does not constitute the limitation to technical solution of the present invention.
Fig. 1 is the schematic diagram of qcow2 file layout in the prior art;
Fig. 2 is the schematic diagram of the addressing logic of qcow2 file in the prior art;
Fig. 3 is the flow chart of the addressing method of virtual disk format provided by the invention.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with attached drawing to the present invention
Embodiment be described in detail.It should be noted that in the absence of conflict, in the embodiment and embodiment in the application
Feature can mutual any combination.
Step shown in the flowchart of the accompanying drawings can be in a computer system such as a set of computer executable instructions
It executes.Also, although logical order is shown in flow charts, and it in some cases, can be to be different from herein suitable
Sequence executes shown or described step.
Fig. 3 is the flow chart of the addressing method of virtual disk format provided by the invention.Method shown in Fig. 3 includes:
Step 301, when receiving the addressing request of qcow2 file, read L1 table in the qcow2 file and/
Or L2 table;
Step 302, after the data for detecting L1 table or L2 table are damaged, obtain the table being damaged in institute
State pre-stored copy in qcow2 file;
Step 303, the data for reading the copy;
Step 304, according to the copy data, respond the addressing request.
Embodiment of the method provided by the invention reads the qcow2 text when receiving the addressing request of qcow2 file
L1 table and/or L2 table in part obtain the table being damaged if the data of L1 table or L2 table are damaged
The pre-stored copy in the qcow2 file responds the addressing request, realization passes through by reading the data of copy
The copy of data carries out repairing Datagram purpose, promotes qcow2 format recovery capability, and then promote entire virtualization system
Information Security.
Embodiment of the method provided by the invention is described further below:
It is standardized according to qcow2, for the virtual disk (such as 1TB) of fixed size, the maximum number of L1/L2 table is
It can decide.The magnetic disk of virtual machine of every 1TB, the size and number of L1 table and L2 table are referring specifically to table 1, specifically such as
Under:
Cluster-size (=L2-table-size) | Max.L2size per TB | Max.L1size per TB |
64KB | 128MB(2048tables) | 16KB(1table) |
128KB | 64MB(512tables) | 8KB |
256KB | 32MB(128tables) | 4KB |
512KB | 16MB(32tables) | 2KB |
1MB | 8MB(8tables) | 1KB |
2MB | 4MB(2tables) | 512B |
Table 1
Qcow2 disk is addressed, the importance of L1 is greater than the importance of L2, and L1 damage means that entire disk can not be sought
Location, and the damage of L2 table means that part disk can not address.
In order to promote qcow2 format recovery capability, the present invention devises the copy storage mode of L1/L2, once qcow2 is literary
Part L1/L2 is impaired, can be repaired by data copy, and then promotes the Information Security of entire virtualization system.Specifically
Implementation process is as follows:
The selection of 1.L1 block
According to the general using rule of agreement, first three block (0~2) of Qcow2 file has specific use, L1 table default
From the 3rd BOB(beginning of block), for given disk size, required L1 table size be it is determining, referring to table 1.
Since L1 table is of crucial importance for qcow2, it is preferred that store multiple copies of L1.
In an embodiment of the method provided by the invention, the table being damaged that obtains is in the qcow2 file
In before pre-stored copy, the method also includes:
Data block i needed for obtaining the data of storage L1 table, wherein i is the integer more than or equal to 1;
From MnA BOB(beginning of block) stores the data of L1 table in continuous i data block, as the copy of L1 table,
Wherein M is the prime number more than or equal to 11, and wherein n is the integer more than or equal to 1;
Record the storage location of the copy of the L1 table.
Specifically, when carrying out copy production, needing to select M if the data of L1 table need 2 blocks to carryn
A and Mn+ 1 block carries the data of L1 table.
Wherein, the prime number more than or equal to 11 why is selected, mainly in view of agreement regulation in the format of qcow2 file
It has all been configured in advance from the 0th piece to the 10th piece, can choose undefined block to carry out the production of copy, and selected
The reason of prime number selected, is mainly considered in file expansion, will not influence other data to the increase of copy and accounts for block
With the conflict that reduction memory space occupies.
Certainly, in summary both sides considers, it is preferred that the value of the M is 17.
For example, the present invention illustrates the reservation mode of copy block so that L1 table occupies a complete block as an example, wherein
Multiple continuous L1 table block modes are identical.Since L1 table is of crucial importance for qcow2, it is preferred that store the more of L1 table
A copy, taking block number is 17nCopy of the block of (n=1,2,3,4 ...) dedicated for storage L1 table, i.e. the 17th piece, the 289th
Block ... must be the block of L1 table.For example, having L1 table at this time for the qcow2 file of block size 1MB, disk size 1TB
4 copies of lattice, are located on the 17th, the 289th, the 4913rd and the 83521st piece.
For the existing addressing process of compatible protocol, Datagram recovery capability is promoted, it is described to record the L1 table
Copy storage location, comprising:
The information of the storage location of the copy of the L1 table is increased in qcow2 file header.
Certainly, in practical applications, note can also be realized by way of safeguarding the list of copy of a L1 table
The purpose of record, but compared to storage location information is directly stored the mode to file header, storage to file header can be better
Compatible existing addressing process, reduces the cost of the maintenance of information.
Specifically, being at least created to the 289th piece when creating qcow2 file, the 17th piece of label is main L1 block, and 289 pieces are
From block, guarantee that L1 table there are at least two copies in creation;Wherein, main L1 block is always from 17 BOB(beginning of block)s, and is recorded in
Inside qcow2header.
Wherein, if the data of L1 table are carried by least two pieces, in the production of copy, from
17nA data block is the starting block of copy, passes through the 17thnA next consecutive data block of data block come continue carry L1 table
Data.
During file management, the quantity of the copy of L1 table and the content of storage can change, and carry out below
Illustrate respectively:
(1) quantity of the copy of L1 table changes:
Described from MnA BOB(beginning of block), in continuous i data block, after the data for storing L1 table, the side
Method further include:
Whether when detecting that qcow2 file is expanded, searching has number to accord in the block newly increased in dilation procedure
Close the object block of the integral number power of M;
The object block for meeting the integral number power of M if there is numbering, then from the target BOB(beginning of block), in continuous i data
In block, the data of L1 table are stored;
Record the storage location of the copy of the L1 table newly increased.
Specifically, adding following below scheme when expanding qcow2 file:
It purchases in view of qcow2 is simplified, increases as data increase, when expanding qcow2 file, if the block of expansion
Number be 17 integral number power, then the data of L1 table are synchronized to the block, while doing conventional use using next piece, otherwise directly
Conventional use is done using the block.
In file expansion, increase new copy in time, it is ensured that the normal use of addressability reduces addressing information
Not available probability of happening.
(2) data of L1 table change:
Described from MnA BOB(beginning of block), in continuous i data block, after the data for storing L1 table, the side
Method further include:
Detecting that the data updated in the L1 table, which are synchronized to block number, is when updating the data in the L1 table
MnAll pieces, wherein [1, k] n ∈;Wherein:
K=round_up (logMbMax);
Wherein, bMax is the numerical value of qcow2 file largest block number, and round_up expression rounds up.
Specifically, increasing following process when updating the L1 table of qcow2:
If a. qcow2 file largest block number is bMax, the value of k is determined, wherein k=round_up (log17bMax);
B. for n ∈ [1, k], it is 17 that L1 data, which are synchronized to block number,nAll pieces.
By the synchronized update to copy data, guarantee the consistency of data, the correctness of data is effectively ensured, guarantees to seek
The normal use of location ability.
The selection of 2.L2 principal and subordinate's block
According to table 1, the number of L2 block determines that after block size and disk size determine.For example, block
Size is 512KB, disk size 1TB, then at most needs 32 block storage L2 tables, that is, there are 32 different L2
Table.
The table 1 seen above, the data of L1 table are one in a qcow2 file, and the quantity of L2 table is extremely
It is two few, comprehensively consider data volume, the number of L2 table and the utilization rate of memory space of the storage of L2 table, is different from L1 table
Lattice not limited number copy number, the copy number that L2 table is arranged in the present invention is 2.
Specifically, described obtain the table being damaged in the qcow2 file before pre-stored copy, it is described
Method further include:
According to pre-set number selection strategy, copy of two blocks as L2 table is selected;
Record the storage location of the copy of the L2 table.
Wherein, the number selection strategy can be configured according to actual needs, propose following management in the present invention
Strategy, specific as follows:
Wherein, described according to pre-set number selection strategy, selecting two blocks as the copy of L2 table includes:
The data of storage L2 table in the available free block that number is even number, main piece as the L2 table copy;
Select number for the data of storage L2 table in the available free block of (a+b/2) mod b, as the L2 table pair
This slave block, wherein a is main piece of number of L2 table copy, and b is the maximum value of 2 integral number power no more than bMax,
Middle bMax is the largest block number of qcow2 file.
Further, if in the qcow2 file number be even number block in there is no idle block, described
The end-of-file of qcow2 file increases new block, and when the number of new block is even number, L2 table is stored in the block newly increased
The data of lattice.
Specifically, main piece of position of L2 table selects current block number for the available free block of even number, if there is no then
It is additional in end-of-file, therefore such free block can be always found, guarantee main piece of production of L2 table.
Behind main piece of position of the copy for determining L2 table, if the main block number where the copy of a certain L2 table is a, qcow2
The current largest block number of file is bMax, and taking b is the 2 integral number power maximum value no more than bMax, then its copy is fixed from block number
Justice is (a+b/2) mod b, such as a=10, bMax=945, at this time b=512, then the slave block of the copy of the L2 table is located at the
266 pieces.
According to the copy of L2 table from the acquisition modes of block it is found that can change from block with becoming larger for bMax, this
When need the slave block of L2 moving to new position.It can be to avoid more migration occurs from block by using b value.
In conjunction with the selection mode of L1 block, it can be found that the locations of copies of L1 table and the locations of copies of L2 table will not occur
Collision.
For the existing addressing process of compatible protocol, Datagram recovery capability is promoted, it is described to record the L2 table
Copy storage location, comprising:
The information of the storage location of the copy of the L2 table is increased in L1 table.
Certainly, in practical applications, note can also be realized by way of safeguarding the list of copy of a L2 table
The purpose of record, but compared to storage location information is directly stored the mode to file header, storage to file header can be better
Compatible existing addressing process, reduces the cost of the maintenance of information.
It is described according to pre-set number selection strategy, after selecting copy of two blocks as L2 table, the side
Method further include:
When detecting that qcow2 file is expanded, whether two blocks selected according to the number selection strategy are judged
It is changed according to the total block data of qcow2 file;
If there is a change, then corresponding piece of copy of number of all L2 tables, the block newly determined are recalculated;
Data in L2 table are moved to the block of the new determination from former storage location, and update the pair of the L2 table
This storage location.
Specifically, constantly in expansion qcow2 file, whether the b value for calculating expansion front and back changes;
If b value changes, the copy of L2 table is obtained, such as by obtaining in L1 table, then calculate all
The position of the slave block of the copy of L2 table;According to the position redefined, Data Migration is completed, realizes the storage location symbol of copy
Pre-set number selection rule is closed, guarantees the accuracy of data storage location.
Optionally, the data by L2 table are described after the block that former storage location moves to the new determination
Method further include:
The use state for marking the block of the former storage location is the free time.
Specifically, for the use state of block in accurate maintenance documentation L2 table number will be stored from block as copy originally
According to block, data complete migration after, labeled as free time, so as to it is subsequent carry out other use, realize to the accurate of storage resource
Management.
In order to guarantee the consistency of copy data content Yu L2 list data, preferably safeguard addressability, it is described according to
Pre-set number selection strategy, after selecting copy of two blocks as L2 table, the method also includes:
When detecting the data in the update L2 table, the data updated in the L2 table are synchronized to described two
In a block.
By the synchronized update to copy data, guarantee the consistency of data, the correctness of data is effectively ensured, guarantees to seek
The normal use of location ability.
The data of 3.L1/L2 table are restored
The data for reading the copy include:
When the copy of the table being damaged is multiple, according to pre-set copy reading order, to copy
Carry out the detection of data integrity;
When the data for detecting copy are complete, the data for reading the copy are executed, otherwise, next copy are selected to carry out
The detection of data integrity, until detecting data complete copy.
Specifically, being defined according to the slave block position of aforementioned L1/L2, it may be convenient to find copy data, use copy
The main block number evidence of data cover.
In conclusion the invention proposes a kind of formats of improved qcow2 file, by storing more parts hereof
L1/L2table copy can be restored to promote the recovery capability of qcow2 after a certain L1/L2 generation problem by copy
Its data improves the recovery capability of qcow2 file format by data redundancy.As a comparison, once traditional qcow2 format L1
List item is damaged, then causes large area data in magnetic disk to lose, be difficult to restore.For this purpose, the present invention proposes the data block pair of L1/L2
This selection strategy promotes the availability of these critical datas of L1/L2 by using a series of copy datas, promotes qcow2 format
Recovery capability after critical data damage occurs in the presence of a harsh environment for the reliability of critical data, greatly promotion qcow2, maximum
Realize to degree that critical data is restored.
The present invention provides a kind of computer readable storage medium, store computer program, the computer program by
Device is managed to execute to realize following operation, comprising:
When receiving the addressing request of qcow2 file, the L1 table and/or L2 table in the qcow2 file are read;
After the data for detecting L1 table or L2 table are damaged, the table being damaged is obtained in the qcow2
Pre-stored copy in file;
Read the data of the copy;
According to the copy data, the addressing request is responded.
In computer readable storage medium embodiment provided by the invention, the table being damaged that obtains is described
In qcow2 file before pre-stored copy, the computer program is also executed by processor to realize following operation, packet
It includes:
Data block i needed for obtaining the data of storage L1 table, wherein i is the integer more than or equal to 1;
From MnA BOB(beginning of block) stores the data of L1 table in continuous i data block, as the copy of L1 table,
Wherein M is the prime number more than or equal to 11, and wherein n is the integer more than or equal to 1;
Record the storage location of the copy of the L1 table.
In computer readable storage medium embodiment provided by the invention, the value of the M is 17.
In computer readable storage medium embodiment provided by the invention, the copy for recording the L1 table is deposited
Storage space is set, comprising:
The information of the storage location of the copy of the L1 table is increased in qcow2 file header.
It is described from M in computer readable storage medium embodiment provided by the inventionnA BOB(beginning of block), in continuous i
In a data block, after the data for storing L1 table, the computer program is also executed by processor to realize following operation, packet
It includes:
Whether when detecting that qcow2 file is expanded, searching has number to accord in the block newly increased in dilation procedure
Close the object block of the integral number power of M;
The object block for meeting the integral number power of M if there is numbering, then from the target BOB(beginning of block), in continuous i data
In block, the data of L1 table are stored;
Record the storage location of the copy of the L1 table newly increased.
It is described from M in computer readable storage medium embodiment provided by the inventionnA BOB(beginning of block), in continuous i
In a data block, after the data for storing L1 table, the computer program is also executed by processor to realize following operation, packet
It includes:
Detecting that the data updated in the L1 table, which are synchronized to block number, is when updating the data in the L1 table
MnAll pieces, wherein [1, k] n ∈;Wherein:
K=round_up (logMbMax);
Wherein, bMax is the numerical value of qcow2 file largest block number, and round_up expression rounds up.
In computer readable storage medium embodiment provided by the invention, the table being damaged that obtains is described
In qcow2 file before pre-stored copy, the computer program is also executed by processor to realize following operation, packet
It includes:
According to pre-set number selection strategy, copy of two blocks as L2 table is selected;
Record the storage location of the copy of the L2 table.
It is described to select plan according to pre-set number in computer readable storage medium embodiment provided by the invention
Slightly, selecting two blocks as the copy of L2 table includes:
The data of storage L2 table in the available free block that number is even number, main piece as the L2 table copy;
Select number for the data of storage L2 table in the available free block of (a+b/2) mod b, as the L2 table pair
This slave block, wherein a is main piece of number of L2 table copy, and b is the maximum value of 2 integral number power no more than bMax,
Middle bMax is the largest block number of qcow2 file.
It is described to select plan according to pre-set number in computer readable storage medium embodiment provided by the invention
Slightly, copy of two blocks as L2 table is selected, the computer program is also executed by processor to realize following operation, packet
It includes:
If in the qcow2 file number be even number block in there is no idle block, in the text of the qcow2 file
Part tail increases new block, and when the number of new block is even number, the data of L2 table are stored in the block newly increased.
In computer readable storage medium embodiment provided by the invention, the copy for recording the L1 table is deposited
Storage space is set, comprising:
The information of the storage location of the copy of the L2 table is increased in L1 table.
It is described to select plan according to pre-set number in computer readable storage medium embodiment provided by the invention
Slightly, after selecting copy of two blocks as L2 table, the computer program is also executed by processor to realize following operation,
Include:
When detecting that qcow2 file is expanded, whether two blocks selected according to the number selection strategy are judged
It is changed according to the total block data of qcow2 file;
If there is a change, then corresponding piece of copy of number of all L2 tables, the block newly determined are recalculated;
Data in L2 table are moved to the block of the new determination from former storage location, and update the pair of the L2 table
This storage location.
In computer readable storage medium embodiment provided by the invention, the data by L2 table are stored from original
After position moves to the block of the new determination, the computer program is also executed by processor to realize following operation, comprising:
The use state for marking the block of the former storage location is the free time.
It is described to select plan according to pre-set number in computer readable storage medium embodiment provided by the invention
Slightly, after selecting copy of two blocks as L2 table, the computer program is also executed by processor to realize following operation,
Include:
When detecting the data in the update L2 table, the data updated in the L2 table are synchronized to described two
In a block.
In computer readable storage medium embodiment provided by the invention, the data for reading the copy include:
When the copy of the table being damaged is multiple, according to pre-set copy reading order, to copy
Carry out the detection of data integrity;
When the data for detecting copy are complete, the data for reading the copy are executed, otherwise, next copy are selected to carry out
The detection of data integrity, until detecting data complete copy.
Computer readable storage medium embodiment provided by the invention is read when receiving the addressing request of qcow2 file
L1 table and/or L2 table in the qcow2 file is taken to obtain if the data of L1 table or L2 table are damaged
The table being damaged pre-stored copy in the qcow2 file responds the addressing by reading the data of copy
Request is realized and carries out repairing Datagram purpose by the copy of data, promotes qcow2 format recovery capability, and then promoted
The Information Security of entire virtualization system.
Those of ordinary skill in the art will appreciate that computer journey can be used in all or part of the steps of above-described embodiment
Sequence process realizes that the computer program can be stored in a computer readable storage medium, the computer program exists
(such as system, unit, device) executes on corresponding hardware platform, when being executed, include the steps that embodiment of the method it
One or combinations thereof.
Optionally, integrated circuit can be used also to realize in all or part of the steps of above-described embodiment, these steps can
To be fabricated to integrated circuit modules one by one respectively, or make multiple modules or steps in them to single integrated electricity
Road module is realized.In this way, the present invention is not limited to any specific hardware and softwares to combine.
Each device/functional module/functional unit in above-described embodiment, which can be adopted, is realized with general computing device realization, it
Can be concentrated on a single computing device, can also be distributed over a network of multiple computing devices.
Each device/functional module/functional unit in above-described embodiment realized in the form of software function module and as
Independent product when selling or using, can store in a computer readable storage medium.Computer mentioned above
Read/write memory medium can be read-only memory, disk or CD etc..
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be subject to protection scope described in claim.
Claims (15)
1. a kind of addressing method of virtual disk format characterized by comprising
When receiving the addressing request of qcow2 file, the L1 table and/or L2 table in the qcow2 file are read;
After the data for detecting L1 table or L2 table are damaged, the table being damaged is obtained in the qcow2 file
In pre-stored copy;
Read the data of the copy;
According to the copy data, the addressing request is responded.
2. the method according to claim 1, wherein the table being damaged that obtains is in the qcow2 text
In part before pre-stored copy, the method also includes:
Data block i needed for obtaining the data of storage L1 table, wherein i is the integer more than or equal to 1;
From MnA BOB(beginning of block) stores the data of L1 table in continuous i data block, as the copy of L1 table, wherein M
For the prime number more than or equal to 11, wherein n is the integer more than or equal to 1;
Record the storage location of the copy of the L1 table.
3. according to the method described in claim 2, it is characterized in that, the value of the M is 17.
4. according to the method in claim 2 or 3, which is characterized in that the storage position of the copy for recording the L1 table
It sets, comprising:
The information of the storage location of the copy of the L1 table is increased in qcow2 file header.
5. according to the method in claim 2 or 3, which is characterized in that described from MnA BOB(beginning of block), in continuous i data
In block, after the data for storing L1 table, the method also includes:
Whether when detecting that qcow2 file is expanded, searching in the block newly increased in dilation procedure has number to meet M's
The object block of integral number power;
The object block for meeting the integral number power of M if there is numbering, then from the target BOB(beginning of block), in continuous i data block,
Store the data of L1 table;
Record the storage location of the copy of the L1 table newly increased.
6. according to the method in claim 2 or 3, which is characterized in that described from MnA BOB(beginning of block), in continuous i data
In block, after the data for storing L1 table, the method also includes:
Detecting that it is M that the data updated in the L1 table, which are synchronized to block number, when updating the data in the L1 tablen's
All pieces, wherein [1, k] n ∈;Wherein:
K=round_up (logMbMax);
Wherein, bMax is the numerical value of qcow2 file largest block number, and round_up expression rounds up.
7. the method according to claim 1, wherein the table being damaged that obtains is in the qcow2 text
In part before pre-stored copy, the method also includes:
According to pre-set number selection strategy, copy of two blocks as L2 table is selected;
Record the storage location of the copy of the L2 table.
8. the method according to the description of claim 7 is characterized in that described according to pre-set number selection strategy, selection
Two blocks include: as the copy of L2 table
The data of storage L2 table in the available free block that number is even number, main piece as the L2 table copy;
Select number for the data of storage L2 table in the available free block of (a+b/2) mod b, as the L2 table copy
From block, wherein a is main piece of number of L2 table copy, and b is the maximum value of 2 integral number power no more than bMax, wherein
BMax is the largest block number of qcow2 file.
9. according to the method described in claim 8, it is characterized in that, described according to pre-set number selection strategy, selection
Copy of two blocks as L2 table, the method also includes:
If in the qcow2 file number be even number block in there is no idle block, in the end-of-file of the qcow2 file
Increase new block, when the number of new block is even number, the data of L2 table are stored in the block newly increased.
10. according to any method of claim 7 to 9, which is characterized in that the copy for recording the L1 table is deposited
Storage space is set, comprising:
The information of the storage location of the copy of the L2 table is increased in L1 table.
11. according to any method of claim 7 to 9, which is characterized in that described to select plan according to pre-set number
Slightly, after selecting copy of two blocks as L2 table, the method also includes:
When detecting that qcow2 file is expanded, judge according to the number selection strategy select two blocks whether basis
The total block data of qcow2 file changes;
If there is a change, then corresponding piece of copy of number of all L2 tables, the block newly determined are recalculated;
Data in L2 table are moved to the block of the new determination from former storage location, and update the copy of the L2 table
Storage location.
12. according to the method for claim 11, which is characterized in that the data by L2 table are moved from former storage location
It moves on to after the block of the new determination, the method also includes:
The use state for marking the block of the former storage location is the free time.
13. according to any method of claim 7 to 9, which is characterized in that described to select plan according to pre-set number
Slightly, after selecting copy of two blocks as L2 table, the method also includes:
When detecting the data in the update L2 table, the data updated in the L2 table are synchronized to described two pieces
In.
14. the method according to claim 1, wherein the data for reading the copy include:
When the copy of the table being damaged is multiple, according to pre-set copy reading order, copy is carried out
The detection of data integrity;
When the data for detecting copy are complete, the data for reading the copy are executed, otherwise, next copy are selected to carry out data
The detection of integrality, until detecting data complete copy.
15. a kind of computer readable storage medium, store computer program, which is characterized in that the computer program by
Device is managed to execute to realize the method as described in claim 1 to 14 is any.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811172062.5A CN109388524B (en) | 2018-10-09 | 2018-10-09 | Virtual disk format addressing method and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811172062.5A CN109388524B (en) | 2018-10-09 | 2018-10-09 | Virtual disk format addressing method and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109388524A true CN109388524A (en) | 2019-02-26 |
CN109388524B CN109388524B (en) | 2021-10-01 |
Family
ID=65426742
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811172062.5A Active CN109388524B (en) | 2018-10-09 | 2018-10-09 | Virtual disk format addressing method and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109388524B (en) |
Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1612112A (en) * | 2003-10-30 | 2005-05-04 | 微软公司 | Shadow page tables for address translation control |
US8112396B2 (en) * | 2006-06-07 | 2012-02-07 | Emc Corporation | Backup and recovery of integrated linked databases |
US8386733B1 (en) * | 2008-02-15 | 2013-02-26 | Symantec Corporation | Method and apparatus for performing file-level restoration from a block-based backup file stored on a sequential storage device |
CN102999433A (en) * | 2012-11-21 | 2013-03-27 | 北京航空航天大学 | Redundant data deletion method and system of virtual disks |
CN103699459A (en) * | 2013-12-31 | 2014-04-02 | 汉柏科技有限公司 | Method and system for incremental backup of virtual machine data based on Qcow2 snapshots |
CN103907099A (en) * | 2011-11-02 | 2014-07-02 | 华为技术有限公司 | Uncached static short address translation table in cache coherent computer system |
US20150127612A1 (en) * | 2013-10-30 | 2015-05-07 | Muralidhara R. Balcha | Method and apparatus of managing application workloads on backup and recovery system |
US9135118B2 (en) * | 2011-03-07 | 2015-09-15 | Aptare, Inc. | System to catalog and search point-in-time instances of a file system |
CN105224478A (en) * | 2015-09-25 | 2016-01-06 | 联想(北京)有限公司 | A kind of formation of mapping table, renewal and restoration methods and electronic equipment |
CN106033454A (en) * | 2015-03-17 | 2016-10-19 | 联想(北京)有限公司 | Methods for formatting and processing virtual file system, and devices for formatting and processing virtual file system |
CN106598496A (en) * | 2016-12-08 | 2017-04-26 | 蓝信工场(北京)科技有限公司 | Method and device for constructing virtual magnetic disk and processing data |
CN106959927A (en) * | 2016-01-08 | 2017-07-18 | 阿里巴巴集团控股有限公司 | The method and device of the positional information of logical partition in acquisition virtual machine |
CN107544871A (en) * | 2017-07-21 | 2018-01-05 | 新华三云计算技术有限公司 | A kind of disk backup method of virtue machine and device |
CN107544870A (en) * | 2017-06-14 | 2018-01-05 | 新华三云计算技术有限公司 | A kind of disk backup method of virtue machine and device |
-
2018
- 2018-10-09 CN CN201811172062.5A patent/CN109388524B/en active Active
Patent Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1612112A (en) * | 2003-10-30 | 2005-05-04 | 微软公司 | Shadow page tables for address translation control |
US8112396B2 (en) * | 2006-06-07 | 2012-02-07 | Emc Corporation | Backup and recovery of integrated linked databases |
US8386733B1 (en) * | 2008-02-15 | 2013-02-26 | Symantec Corporation | Method and apparatus for performing file-level restoration from a block-based backup file stored on a sequential storage device |
US9135118B2 (en) * | 2011-03-07 | 2015-09-15 | Aptare, Inc. | System to catalog and search point-in-time instances of a file system |
CN103907099A (en) * | 2011-11-02 | 2014-07-02 | 华为技术有限公司 | Uncached static short address translation table in cache coherent computer system |
CN102999433A (en) * | 2012-11-21 | 2013-03-27 | 北京航空航天大学 | Redundant data deletion method and system of virtual disks |
US20150127612A1 (en) * | 2013-10-30 | 2015-05-07 | Muralidhara R. Balcha | Method and apparatus of managing application workloads on backup and recovery system |
CN103699459A (en) * | 2013-12-31 | 2014-04-02 | 汉柏科技有限公司 | Method and system for incremental backup of virtual machine data based on Qcow2 snapshots |
CN106033454A (en) * | 2015-03-17 | 2016-10-19 | 联想(北京)有限公司 | Methods for formatting and processing virtual file system, and devices for formatting and processing virtual file system |
CN105224478A (en) * | 2015-09-25 | 2016-01-06 | 联想(北京)有限公司 | A kind of formation of mapping table, renewal and restoration methods and electronic equipment |
CN106959927A (en) * | 2016-01-08 | 2017-07-18 | 阿里巴巴集团控股有限公司 | The method and device of the positional information of logical partition in acquisition virtual machine |
CN106598496A (en) * | 2016-12-08 | 2017-04-26 | 蓝信工场(北京)科技有限公司 | Method and device for constructing virtual magnetic disk and processing data |
CN107544870A (en) * | 2017-06-14 | 2018-01-05 | 新华三云计算技术有限公司 | A kind of disk backup method of virtue machine and device |
CN107544871A (en) * | 2017-07-21 | 2018-01-05 | 新华三云计算技术有限公司 | A kind of disk backup method of virtue machine and device |
Non-Patent Citations (1)
Title |
---|
许艳军,姜进磊,王博,杨广文: "几种虚拟机镜像格式及其性能测评", 《计算机应用》 * |
Also Published As
Publication number | Publication date |
---|---|
CN109388524B (en) | 2021-10-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6778795B2 (en) | Methods, devices and systems for storing data | |
CN103970585B (en) | Create the method and device of virtual machine | |
CN102467408B (en) | Method and device for accessing data of virtual machine | |
CN105718548B (en) | Based on the system and method in de-duplication storage system for expansible reference management | |
EP3617867B1 (en) | Fragment management method and fragment management apparatus | |
CN102629258B (en) | Repeating data deleting method and device | |
CN103699585B (en) | Methods, devices and systems for file metadata storage and file recovery | |
CN102063943B (en) | Nand flash memory parameter automatic detecting system | |
CN101777017B (en) | Rapid recovery method of continuous data protection system | |
CN104461390A (en) | Method and device for writing data into imbricate magnetic recording SMR hard disk | |
CN103797470A (en) | Storage system | |
CN113296696A (en) | Data access method, computing device and storage medium | |
CN105787037B (en) | A kind of delet method and device of repeated data | |
CN104133775A (en) | Method and apparatus for managing memory | |
CN102282544A (en) | Storage system | |
CN103914522A (en) | Data block merging method applied to deleting duplicated data in cloud storage | |
CN105159800A (en) | Data recovery method, data backup method, data recovery equipment, data backup equipment, data recovery system and data backup system | |
CN104360914A (en) | Incremental snapshot method and device | |
CN103049224A (en) | Method, device and system for importing data into physical tape | |
CN106445643A (en) | Method and device for cloning and updating virtual machine | |
CN104050057B (en) | Historical sensed data duplicate removal fragment eliminating method and system | |
CN109933564A (en) | File system management method, device, terminal, the medium of quick rollback are realized based on chained list and N-ary tree construction | |
CN103530206A (en) | Data recovery method and device | |
CN103440204B (en) | A kind of method of updating file system and memory device | |
CN103631682A (en) | Data backup implement method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |