A kind of method of utilizing solid state hard disc to improve the snapshot performance
Technical field
The present invention relates to computer system and field of storage, specifically a kind of method of utilizing solid state hard disc to improve the snapshot performance.
Background technology
Solid state hard disc (Solid State Disk; Be called for short: SSD) formed by control module and storage unit.Storage unit non-volatile flash memory (Flash) chips that adopt perhaps adopt Synchronous Dynamic Random Access Memory (SynchronousDynamic Random Access Memory more; Be called for short: SDRAM).SSD does not have mechanical rotation device, has very high random read-write performance.But cost is very high, through being usually used in high-end field of storage.
Snapshot generally refers to a complete usable copy about the specific data set, and this copy comprises that corresponding data at certain time point (for example: the reflection time point of copy beginning).Snapshot can be copy or the duplicate of represented data.The effect of snapshot is can carry out online data to recover, and when memory device generation application and trouble or file corruption, can utilize snapshot to carry out timely data and recover, and data is reverted to the state of snapshot generation time point.The method that snapshot is realized has a variety of, such as: namely write namely and copy, cut apart mirror snapshot etc.
In linux, realize snapshot based on LVM, employing be copy on firest write (cow) mechanism, one of them important concept makes an exception exactly.Be the snapshot mapping relations, show that data were revised on the snapshot source after setting up snapshot, the data before changing have copied or have copied to another chunk on the snapshot to from some chunk of snapshot source device.In order to embody this mapping relations, need metadata to represent this mapping relations.The equipment that metadata is deposited also is exception storehouse volume.
When to snapped volume or source book read-write, at first need to search the corresponding element data, check whether this chunk shone upon, namely create after the snapshot source volume data and whether revised, the words that were it not for also need be set up new mapping relations again, create new metadata.If the deletion snapshot also needs to delete corresponding metadata etc.Each data block must be carried out metadata operation.If metadata is deposited to hard disk, will be become the performance bottleneck of snapshot to the operation of metadata.If metadata is deposited to internal memory, although can increase the performance of snapshot, in case after the power down, metadata will be lost.
Summary of the invention
The purpose of this invention is to provide a kind of method of utilizing solid state hard disc to improve the snapshot performance.
The objective of the invention is to realize in the following manner, the method is to utilize the high random read-write performance of solid state hard disc, with the exception storehouse volume of solid state hard disc as snapshot, metadata and COW data are stored in the solid state hard disc, the organizational form of metadata in the solid state hard disc, with the metadata store of snapshot at solid state hard disc foremost, the COW data are stored in the residue section, to improve snapshot to the operating performance of metadata, system comprises: snapshot module (1), exception storehouse volume module (2), and concrete steps are as follows:
(1) snapshot module
Adopt the mode of incremental snapshot, by way of exception roll up in the storehouse with solid state hard disc, solid state hard disc is divided into meta-data region and cow data field, after source book is set up snapshot, the meta-data region of initialization exception warehouse volume, the form of metadata is old chunk, new chunk, snapID range, wherein, old chunk points to the piece in the source book, new chunk points to piece corresponding to snapped volume, snapID range is the scope of snapshot ID, and each snapshot has an ID, and snapID range is used for showing which snapshot range the piece of metadata appointment is within;
When source book is write, at first search metadata, were it not for and find words, explanation is first revision snapshot source, need to suppose that the position at the data place in snapshot source is old chunk with the data copy in snapshot source to COW equipment, finishing said process needs following three steps:
1) searches position for save data at COW equipment, be designated as new chunk;
2) data with the snapshot data source are saved in new chunk place on the COW equipment;
3) with exceptional information old chunk, new chunk, snapID range are that so-called meta-data preservation is to solid state hard disc;
If find, illustrate that source book upgraded after creating snapshot, the data of source book have been saved in COW equipment and have suffered, and directly source book are carried out write operation;
When source book is carried out read operation, directly source book is carried out read operation and get final product;
When snapped volume is carried out write operation, at first search metadata, if do not find, the data that this chunk place of source book is described are not also revised, new data need to be write on the COW equipment, search position for save data at COW equipment, be designated as new chunk, again with meta-data preservation to solid state hard disc;
If find, directly the new chunk write operation that finds is got final product;
When snapped volume is carried out read operation, at first search metadata, if do not find, read the corresponding chunk of source book, if find, read the corresponding chunk of snapshot storehouse volume;
(2) exception storehouse volume module
First sector of solid state hard disc is used for the root node position of record metadata B+ tree, the degree of depth and bitmap and the root node of B+ tree as superblock;
In the front portion of solid state hard disc as meta-data index storage, metadata is with the form tissue of B+ tree, the leaf directory entry of B+ tree comprises: in the old chunk source book, in the volume of new chunk snapshot storehouse, the snapshot ID scope that this belongs to mapping, the key word Key of B+ tree is by old chunk, and snapshot ID range forms, maximum catalogue item No. in a node has regulation, to such an extent as to a node just fills a piece;
Internal node has identical data structure with leaf node, if internal node, new_chunk then represents the pointer that points to subordinate B+ tree node, if leaf node, new_chunk is exactly the data content that will search;
When searching metadata B+ tree, search when root node is opened, key comes comparison according to key word, keyword sequences in the node is carried out binary chop, just can hit until reach leaf node, internal node is equivalent to the index of leaf node, and leaf node directly points to the COW data field;
Solid state hard disc does not have the physical mechanical arm, the random read-write performance is very high, the COW data in exception storehouse volume, directly store in mode at random with solid state hard disc in, wherein the new_chunk of metadata is used for preserving the sector number that the COW data are deposited, after finding new_chunk in meta-data region, direct read/write exception storehouse volume change the chunk position;
Exception storehouse volume free space is by bitmap management, bitmap is pointed to by a Ji Shu, each internal node comprises 64 pointer, point to slave node, leaf node is bitmask, and each leaf node comprises independent position, 1 means and distributes, 0 expression is idle, and the root node position of bitmap is stored in the superblock, and the degree of depth is by instrument size and the common decision of chunk size;
If the degree of depth is 0, then root bitmap piece only comprises single position, and equipment is very little, to such an extent as to 1 piece is just enough as bitmap, if the degree of depth is 1, then root bitmap piece is one group 64 pointer, and the piece of sensing is as single bitmap, if the degree of depth is 2, then be second rank pointer, by that analogy;
When bitmap is searched, begin traversal according to bitmap piece number from root node, during traversal, obtain the index of every one deck by bitmap piece number and the degree of depth, until find leaf node.
The invention has the beneficial effects as follows: the method is to take into account the consideration of performance, utilizes solid state hard disc to improve the method for snapshot performance.The consideration that takes into account performance of mentioning is because if with common hard disc storage snapshot data, the operation meeting of snapshot data reduces the performance of snapshot greatly.Utilizing solid state hard disc to store snapshot data, is to utilize the high random read-write performance of solid state hard disc to improve the speed of snapshot data operation.Of the present invention a kind of with the method for solid state hard disc as the exception warehouse memory device of snapshot, utilize the high random read-write performance of solid state hard disc, improve snapshot to the operating performance of metadata, and the power down metadata do not lose, reached the technique effect of high-performance, high availability snapshot.
Description of drawings
Fig. 1 is the snapshot module structural drawing;
Fig. 2 is that metadata is organized structural drawing;
Fig. 3 is the bitmap organization chart.
Embodiment
Explain below with reference to Figure of description method of the present invention being done.
Concrete technical scheme is as follows:
1 〉. a kind of mode that realizes snapshot with the exception storehouse volume of solid state hard disc as snapshot, is stored in metadata and COW data in the solid state hard disc;
2 〉. the organizational form of metadata in the solid state hard disc with the metadata store of snapshot at solid state hard disc foremost, is stored in the residue section with the COW data;
(1) snapshot module
This example adopts the mode of incremental snapshot, by way of exception rolls up in the storehouse with solid state hard disc, as shown in Figure 1:
Solid state hard disc is divided into meta-data region and cow data field, after source book is set up snapshot, the meta-data region of initialization exception warehouse volume.The form of metadata is (old chunk, new chunk, snapID range), old chunk points to the piece in the source book, new chunk points to piece corresponding to snapped volume, snapID range is the scope of snapshot ID, and each snapshot has an ID, and snapID range is used for showing which snapshot range the piece of metadata appointment is within;
When source book is write, at first search metadata, were it not for and find words, explanation is first revision snapshot source, need to suppose that the position at the data place in snapshot source is old chunk with the data copy in snapshot source to COW equipment, finishing said process needs three steps;
1) searches position for save data at COW equipment, be designated as new chunk;
2) data with the snapshot data source are saved in new chunk place on the COW equipment;
3) be that so-called meta-data preservation is to solid state hard disc with exceptional information (old chunk, new chunk, snapID range);
If find, illustrate that source book upgraded after creating snapshot, the data of source book have been saved in COW equipment and have suffered.Can directly write source book;
When source book is read, directly source book is read to get final product;
When snapped volume is carried out write operation, at first search metadata, if do not find, illustrate that the data at this chunk place of source book are not also revised, new data need to be write on the COW equipment.Search position for save data at COW equipment, be designated as new chunk.Again with meta-data preservation to solid state hard disc;
If find, the direct new chunk that finds is write gets final product;
When snapped volume is carried out read operation, at first search metadata, if do not find, read the corresponding chunk of source book, if find, read the corresponding chunk of snapshot storehouse volume;
(2) exception storehouse volume module
First sector of solid state hard disc is used for the root node position of record metadata B+ tree, the degree of depth and bitmap and the root node of B+ tree as superblock.
As meta-data index storage, metadata is with the form tissue of B+ tree in the front portion of solid state hard disc.The leaf directory entry of B+ tree comprises: old chunk (in the source book), new chunk (in the volume of snapshot storehouse), the snapshot ID scope that this belongs to mapping.The key word (Key) of B+ tree is by old chunk, and snapshot ID range forms.Maximum catalogue item No. in a node has regulation, to such an extent as to a node just fills a piece.
Internal node has identical data structure with leaf node.If internal node, new_chunk then represents the pointer that points to subordinate B+ tree node.If leaf node, new_chunk is exactly the data content that will search.As shown in Figure 2.
When searching metadata B+ tree, search when root node is opened, key comes comparison according to key word, and the keyword sequences in the node is carried out binary chop, just can hit until reach leaf node, and internal node is equivalent to the index of leaf node.Leaf node directly points to the COW data field.
Solid state hard disc does not have the physical mechanical arm, the random read-write performance is very high, the COW data in exception storehouse volume, directly store in mode at random with solid state hard disc in, wherein the new_chunk of metadata is used for preserving the sector number that the COW data are deposited, after finding new_chunk in meta-data region, direct read/write exception storehouse volume change the chunk position.
Exception storehouse volume free space is by bitmap management.Bitmap is pointed to by a Ji Shu.Each internal node comprises 64 pointer, points to slave node, and leaf node is bitmask.Each leaf node comprises independent position, and 1 means and distributes, and 0 expression is idle.The root node position of bitmap is stored in the superblock, and the degree of depth is by instrument size and the common decision of chunk size.
If the degree of depth is 0, then root bitmap piece only comprises single position (equipment is very little, to such an extent as to 1 piece is just enough as bitmap).If the degree of depth is 1, then root bitmap piece is one group 64 pointer, and the piece of sensing is as single bitmap.If the degree of depth is 2, then be second rank pointer, by that analogy.By shown in Figure 3.
When bitmap is searched, begin traversal according to bitmap piece number from root node, during traversal, obtain the index of every one deck by bitmap piece number and the degree of depth, until find leaf node.
Except the described technical characterictic of instructions, be the known technology of those skilled in the art.