Summary of the invention
In view of this, the embodiment of the invention provides a kind of restoration methods and device of tape metadata, and is dangerous in order to the metadata store that solves tape in the prior art, the problem that causes tape normally to use.
The restoration methods of a kind of tape metadata that the embodiment of the invention provides, carry out the following step to each file in the tape:
Confirm the position of the file header of current file, wherein:
When said current file is first file of said tape; Format information according to said first file of storing in the said tape; Said format information is used to identify which tape piece that said first file is positioned at said tape; Move the tape piece of respective amount, with the file header position of the position after moving as said first file;
When first file of the non-said tape of said current file; The attribute information of a said last file that writes down in the metadata information according to the last file of the said current file that reads; The quantity of the tape piece of confirming to move to said current file by a said last file movement; Move the tape piece of respective amount, with the file header position of the position that moves to as said current file, the file header position of wherein said current file is the end-of-file position of a said last file;
According to the file header position of the said current file of confirming, read the metadata information of the said current file of said file header location storage, and preserve the metadata information of the said current file that reads.
The recovery device of a kind of tape metadata that the embodiment of the invention provides is carried out metadata to each file of storing in the tape and is recovered, and said device comprises:
Determination module is used for confirming the file header position of current file; Said determination module comprises that first confirms unit and second definite unit, wherein:
First confirms the unit; When being used for confirming that said current file is first file of said tape; Format information according to said first file of storing in the said tape; Said format information is used to identify which tape piece that said first file is positioned at said tape, moves the tape piece of respective amount, with the file header position of the position after moving as said first file;
Second confirms the unit; When being used for confirming first file of the non-said tape of said current file; The attribute information of a said last file that writes down in the metadata information according to the last file of the said current file that reads; The quantity of the tape piece of confirming to move to said current file by a said last file movement; Move the tape piece of respective amount, with the file header position of the position that moves to as said current file, the file header position of wherein said current file is the end-of-file position of a said last file;
Recover module, be used for file header position, read the metadata information of the said current file of said file header location storage, and preserve the metadata information of the said current file that reads according to the said current file of confirming.
The embodiment of the invention provides a kind of restoration methods and device of tape metadata; This method comprises: the position of confirming the file header of current file; File header position according to the said file of confirming; Read the metadata information of the said file of said file header location storage, and preserve the metadata information of the said file that reads.Owing in embodiments of the present invention the metadata information of each file is kept at the file header position of file; Metadata through a reading and saving files position realizes the recovery to this tape metadata; As long as tape does not damage; Just can adopt the method for recovering the tape metadata to recover the metadata of preserving in the tape, thus the security that has improved metadata store.
Embodiment
The embodiment of the invention is in order effectively to improve the security of tape metadata information storage; A kind of restoration methods of tape metadata is provided, and this method is carried out the following step to each file in the tape; Confirm the position of the file header of current file; According to the file header position of the said file of confirming, read the metadata information of the said file of said file header location storage, and preserve the metadata information of the said file that reads.Owing in embodiments of the present invention the metadata information of each file is kept at the file header position of file; Metadata through a reading and saving files position realizes the recovery to this tape metadata; As long as tape does not damage; Just can adopt the method for recovering the tape metadata to recover the metadata of preserving in the tape, thus the security that has improved metadata store.
Below in conjunction with Figure of description, the embodiment of the invention is elaborated.
The rejuvenation of the tape metadata that Fig. 1 provides for the embodiment of the invention, this process comprises:
S101: the position of confirming the file header of current file.
Wherein confirm the comprising for the position of file header of current file: when said current file is first file of said tape; Format information according to said first file of storage in the said tape; Said format information is used to identify which tape piece that said first file is positioned at said tape, and the position after the tape piece of mobile respective amount will move is as the file header position of said first file;
When first file of the non-said tape of said file; The attribute information of a said last file that writes down in the metadata information according to the last file of the said current file that reads; The quantity of the tape piece of confirming to move to said current file by a said last file movement; Move the tape piece of respective amount, with the file header position of the position that moves to as said current file, the file header position of wherein said current file is the end-of-file position of a said last file.
When said current file is first file of said tape; Said method also comprised before the position of the file header of confirming current file: read leader tape head information in the said tape; Obtain the attribute information of said tape; The attribute information of wherein said tape comprises the identification information of tape, and the capacity information of each tape piece in this tape.
S102: according to the file header position of the said file of confirming, read the metadata information of the said file of said file header location storage, and preserve the metadata information of the said file that reads.
Said method also comprises:
Judge whether said current file is the tape tail of said tape, when definite said current file was the tape tail of said tape, the rejuvenation of said tape metadata finished;
When confirming the tape tail of the non-said tape of said current file; According to the said current file that reads metadata information in the attribute information of the said current file that writes down; Confirm to move to the quantity of the tape piece that the file header of the next file of said current file need move by said current file; According to the quantity of the said tape piece of confirming, move to the file header position of the next file of said current file.
Since in embodiments of the present invention in tape with the metadata information of preserving this document in the file header of each file, therefore can be when the metadata of this tape be lost, through reading the file header of each file in this tape; Obtain the metadata information of this tape; Therefore, as long as this tape does not damage, or all do not damage; Can obtain in this tape the metadata information of preserving in the file of broken parts not, the metadata of this tape is recovered.
The form of leader tape head and file is fixed in tape, and first tape piece record is leader tape head information in the general tape, and this leader tape head information contains the tape identification information, i.e. tape label information, the capacity information of tape piece etc.First file of storage also has certain format information in the tape, and this format information is used to identify which tape piece that first file is positioned at tape, and generally the 3rd tape piece is used for the information of first file of storage tape in the tape.Because the form of tape is fixed; Therefore according to the format information of storing first file in the tape; Promptly the 3rd tape piece is the memory location of storing first file in this tape; The distance that moves two tape pieces arrives the 3rd tape piece position, with the file header position of this position as first file of storing in this tape.
Be measurement unit with the tape piece in the tape, each tape piece occupies fixing capacity, and the information of the capacity of each tape piece is also contained in the tape in the tape, and the capacity of the tape piece of each tape can be the same or different.When the metadata of tape is recovered, obtain the capacity information of each tape piece in the tape, so that according to the capacity information of this tape piece.
To preserving the long storage medium tape that lost efficacy, adopt different metadata store modes in embodiments of the present invention.Adopt the restoration methods of the metadata of the embodiment of the invention, when in each tape, writing data, to each file in the tape; When in tape, writing this document, divide attribute information, confirm information recorded in the metadata according to this document at the top of file of this document; And this has been write down the file header of the metadata store of this document attribute information at this document; Wherein, the attribute information of this document that writes down in this metadata comprises: the identification information of this document, and the bytes in information that comprises of this document etc.; And also comprise in this attribute information: the program ID under the file, the information that programm name etc. are relevant with business.Wherein the identification information of this document is used to distinguish this document, and each file has unique identification information, and wherein the quantity of this byte that comprises is the byte number information that the size of this document takies.Owing to comprise the bytes in information that file comprises in the attribute information of file, i.e. the byte number that takies of file when byte number that the capacity and the file of known tape piece takies, can calculate the quantity of the tape piece that this document takies.
When having preserved the metadata information of this document in the file header at each file; The metadata information that has promptly comprised each file in the tape, therefore, as long as tape safety; Be not damaged; Or all do not damage, the metadata information that the not broken parts in this tape is preserved can use, and can be resumed.
When file or the database of this tape metadata of storage can use; Or the metadata information of the tape of preserving in this document or the database is not when losing; Can carry out the read-write operation of each file in the tape according to the metadata information of this tape of preserving in this document or the database; When the metadata information of the tape of preserving in this document or the database is lost, can adopt the restoration methods of the tape metadata that the embodiment of the invention provides to carry out the recovery of tape metadata.
In embodiments of the present invention when carrying out the recovery of tape metadata; Can be through starting the tape metadata recovering process in the tape metadata recovery device; Establishment is used for the database of the tape metadata information of recovery of stomge; And start the driven magnetic tape drive equipment in this terminal, accomplish the recovery of this tape metadata.The detailed process that Fig. 2 recovers for the tape metadata that the embodiment of the invention provides, this process may further comprise the steps:
S201: the tape metadata recovering process in the starter gear, establishment is used for the database of the tape metadata information of recovery of stomge.
S202: be positioned at the leader tape head of tape, obtain the attribute information of said tape, wherein the attribute information of this tape comprises the capacity information of each tape piece in identification information and the tape of tape.
S203: be positioned on the current file in the tape to be recovered, read the metadata information of this current file of preserving in the file header of this current file.
S204: the metadata information of this current file that will read is kept in the database of establishment.
S205: according to the metadata information of this current file that reads, the quantity of the tape piece that the end-of-file that definite file header by this current file moves to this current file need move.
S206: according to the quantity of confirming said tape piece, the tape piece that moves respective amount arrives the end-of-file of said current file.
S207: whether the end-of-file of judging said current file is the tape tail of this tape; Judged result is carried out step S208 when being, otherwise; The end-of-file of this current file is the file header of the next file of this current file, should carry out step S203 as current file by next one file.
S208: the metadata of this tape is recovered to finish.
The recovery device of a kind of tape metadata that Fig. 3 provides for the embodiment of the invention, this device comprises:
Determination module 31 is used for confirming the file header position of current file;
Recover module 32, be used for file header position, read the metadata information of the said file of said file header location storage, and preserve the metadata information of the said file that reads according to the said file of confirming.
Said determination module 31 comprises:
First confirms unit 311; When being used for confirming that said current file is first file of said tape; Format information according to said first file of storage in the said tape; Said format information is used to identify which tape piece that said first file is positioned at said tape, and the position after the tape piece of mobile respective amount will move is as the file header position of said first file;
Second confirms unit 312; When being used for confirming first file of the non-said tape of said current file; The attribute information of a said last file that writes down in the metadata information according to the last file of the said current file that reads; The quantity of the tape piece of confirming to move to said current file by a said last file movement; Move the tape piece of respective amount, with the file header position of the position that moves to as said current file, the file header position of wherein said current file is the end-of-file position of a said last file.
Said device also comprises:
Leader tape head read module 33 is used for reading said tape leader tape head information, obtains the attribute information of said tape, and the attribute information of wherein said tape comprises the identification information of tape, and the capacity information of each tape piece in this tape.
Said device also comprises:
Judge module 34; Be used to judge whether said current file is the tape tail of said tape; When definite said current file was the tape tail of said tape, the rejuvenation of said tape metadata finished, when confirming the tape tail of the non-said tape of said current file; According to the said current file that reads metadata information in the attribute information of the said current file that writes down; Confirm to move to the quantity of the tape piece that the file header of the next file of said current file need move,, move to the file header position of the next file of said current file according to the quantity of the said tape piece of confirming by said current file.
The embodiment of the invention provides a kind of restoration methods and device of tape metadata; This method comprises: the position of confirming the file header of current file; File header position according to the said file of confirming; Read the metadata information of the said file of said file header location storage, and preserve the metadata information of the said file that reads.Owing in embodiments of the present invention the metadata information of each file is kept at the file header position of file; Metadata through a reading and saving files position realizes the recovery to this tape metadata; As long as tape does not damage; Just can adopt the method for recovering the tape metadata to recover the metadata of preserving in the tape, thus the security that has improved metadata store.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, belong within the scope of claim of the present invention and equivalent technologies thereof if of the present invention these are revised with modification, then the present invention also is intended to comprise these changes and modification interior.