Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of disk access control method; Be intended to solve prior art because disk when extracting; The document control information of this disk of metadata disc recording is deleted, and therefore causes data in magnetic disk to be lost, and can't visit the problem of the data on the original disk.
The embodiment of the invention is achieved in that a kind of disk access control method, is applied to cluster distributed storage file system, and said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and said method comprises the steps:
When disk inserts, obtain the disk sequence number of the disk that is inserted into current location;
According to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number, judge whether the disk that is inserted into current location is new disk; Perhaps, according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number, judge whether the disk that is inserted into current location is new disk;
If new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
If not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
The embodiment of the invention also provides a kind of disk access control device, is applied to cluster distributed storage file system, and said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and said device comprises:
Acquiring unit is used for when disk inserts, and obtains the disk sequence number of the disk that is inserted into current location;
Judging unit is used for judging according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk; Perhaps, judge according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk;
Updating block is used for if new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
Stick unit is used for if not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
The embodiment of the invention also provides a kind of disk access control system, and said system comprises a plurality of disks and disk access control device, and said disk access control device links to each other with said a plurality of disks;
Said a plurality of disk is used for the metadata and the file of storing metadata;
Said disk access control device comprises:
Acquiring unit is used for when disk inserts, and obtains the disk sequence number of the disk that is inserted into current location;
Judging unit is used for judging according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk; Perhaps, judge according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk;
Updating block is used for if new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
Stick unit is used for if not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
The embodiment of the invention compared with prior art; Beneficial effect is: realize the disk sequence number according to the disk of current location; The document control information of this disk of metadata disc recording is deleted or kept, avoid losing, and can't visit the data on the original disk because of data in magnetic disk.Make that in cluster distributed storage system the disk that inserts when the identification current location is the original disk in this position, owing to do not lose the document control information data, so can continue the data in this disk are conducted interviews; And when with a plurality of disk integral body during, if one of them disk failure when changing failed disk, still can conduct interviews to other the data of dish of unit, place, plug unit as a hot plug unit; Further; For the situation of disk in the exchange device more behind the electricity under the equipment,, therefore can carry out correct visit to the disk of changing owing to can discern to the disk position of changing; Avoid because the replacing of disk can't be known in following charged renewal disk management system; Thereby after device power starts, can't discern this disk, and the situation that causes disk access to be made mistakes.
Embodiment
In order to make the object of the invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with accompanying drawing and embodiment.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
The embodiment of the invention provides a kind of disk access control method, is applied to cluster distributed storage file system, and said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and said method comprises the steps:
When disk inserts, obtain the disk sequence number of the disk that is inserted into current location;
According to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number, judge whether the disk that is inserted into current location is new disk; Perhaps, according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number, judge whether the disk that is inserted into current location is new disk;
If new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
If not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
The embodiment of the invention also provides a kind of disk access control device, is applied to cluster distributed storage file system, and said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and said device comprises:
Acquiring unit is used for when disk inserts, and obtains the disk sequence number of the disk that is inserted into current location;
Judging unit is used for judging according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk; Perhaps, judge according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk;
Updating block is used for if new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
Stick unit is used for if not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
The embodiment of the invention also provides a kind of disk access control system, and said system comprises a plurality of disks and disk access control device, and said disk access control device links to each other with said a plurality of disks;
Said a plurality of disk is used for the metadata and the file of storing metadata;
Said disk access control device comprises:
Acquiring unit is used for when disk inserts, and obtains the disk sequence number of the disk that is inserted into current location;
Judging unit is used for judging according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk; Perhaps, judge according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk;
Updating block is used for if new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
Stick unit is used for if not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
Below in conjunction with specific embodiment realization of the present invention is described in detail:
Embodiment one
In the present embodiment, in the disk access control procedure, when the detection disk is extracted; Extract the document control information of disk on the preserve metadata dish; And keep or deletion according to following steps decisions, thereby make things convenient for disk to use, Fig. 1 shows the process flow diagram of the realization of the disk access control method that the embodiment of the invention one provides; This method is applied to cluster distributed storage file system; Said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and details are as follows for said method:
In step S101, when disk inserts, obtain the disk sequence number of the disk that is inserted into current location.
In the present embodiment, except the disk sequence number, other the disc information that can characterize disk characteristics also can be used in also this enforcement, all belongs to protection scope of the present invention.
In addition; As those skilled in the art, the mode of obtaining the disk sequence number has a lot, for example; Windows management regulation (Windows Management Instrumentation; WMI) (Application Programming Interface, API) mode etc. repeats no more at this for mode, application programming interfaces.
In step S102,, judge whether the disk that is inserted into current location is new disk according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number; Perhaps; According to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number; Judge whether the disk that is inserted into current location is new disk, if new disk, execution in step S103; If not new disk, execution in step S104.
In the present embodiment, for the ease of understanding, below through a realization example to according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number; Judge that whether the disk be inserted into current location is that the process of new disk describes, but exceed with the situation of this realization example: suppose that the hard disk location number when the front disk insertion that obtains is 1, sequence number is num1; Can be expressed as (1; Num1), be that the sequence number of 1 position is num2 if store this hard disk location number in advance, can be expressed as (1; Num2); Variation has taken place in the sequence number of the insertion disk of then current hard disk position 1, judges that then the disk that current location 1 is inserted is new disk, execution in step S103; The sequence number of storing this hard disk location number in advance and be 1 position is num1, can be expressed as that (1, num1), the sequence number of the insertion disk of then current hard disk position 1 does not change, and judges that then the disk that current location 1 is inserted is not new disk, execution in step S104.In addition; According to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number; Judge that whether the disk be inserted into current location is that the process of new disk is similar to the above process, repeats no more at this.
What be worth explanation is that in the present embodiment, new disk can be a new disk physically; New disk can also be to use in this position; But the used disk in other position again after extract this position, at this moment, the information of disk changes; If continue to use in this position, think that then this disk is new disk.
In step S103, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
In the present embodiment; The current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish; At this moment, deleted the document control information of current location on the metadata dish, the document control information of the old disk of metadata disk storage can't be controlled the file on this new disk; Then need be according to the document control information of new disk, to the control that conducts interviews of new disk.
In step S104, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
In the present embodiment, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish, therefore, and still can be according to the document control information of current location on the metadata dish, to the control that conducts interviews of this old disk.
In the present embodiment; According to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number; Perhaps according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number; Judge whether the disk that is inserted into current location is new disk; If new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish; If not new disk; The current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish; Realization is according to the disk sequence number of the disk of current location; The document control information of this disk of metadata disc recording is deleted or kept, avoid losing, and can't visit the data on the original disk because of data in magnetic disk.Make that in cluster distributed storage system the disk that inserts when the identification current location is the original disk in this position, owing to do not lose the document control information data, so can continue the data in this disk are conducted interviews; And when with a plurality of disk integral body during, if one of them disk failure when changing failed disk, still can conduct interviews to other the data of dish of unit, place, plug unit as a hot plug unit; Further; For the situation of disk in the exchange device more behind the electricity under the equipment,, therefore can carry out correct visit to the disk of changing owing to can discern to the disk position of changing; Avoid because the replacing of disk can't be known in following charged renewal disk management system; Thereby after device power starts, can't discern this disk, and the situation that causes disk access to be made mistakes.
Embodiment two
Present embodiment; On the basis of embodiment one; Also obtain the number of times that powers on of the disk that is inserted into current location, and the number of times that powers on that on the basis of embodiment one, combines to be inserted into the disk of current location judges whether the disk that is inserted into current location is new disk, Fig. 2 shows the process flow diagram of the realization of the disk access control method that the embodiment of the invention two provides; This method is applied to cluster distributed storage file system; Said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and details are as follows for said method:
In step S201, when disk inserts, obtain the disk sequence number of the disk that is inserted into current location and be inserted into the number of times that powers on of the disk of current location.
In step S202; Whether the current location according to the disk sequence number of the said said current location of obtaining and storage in advance is consistent with the particular disk sequence number; If consistent, if execution in step S203 is inconsistent; Judge that the disk that is inserted into current location is new disk, execution in step S204.
In step S203; Whether the number of times that powers on of judging the disk of the said current location obtain adds 1 greater than the number of times that powers on of the disk of the current location of storage in advance; If greater than, then judge and judge that the disk that is inserted into current location is new disk, execution in step S204; If be not more than, judge that the disk that is inserted into current location is to be not new disk, execution in step S205.
In step S204, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
In step S205, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
Present embodiment further obtains the number of times that powers on of disk on the basis of embodiment one; Whether the disk sequence number of the said current location of obtaining through judgement is consistent with the disk sequence number of the current location of storage in advance; If inconsistent, judge that the disk that is inserted into current location is new disk, then needn't judge again; If it is consistent; Then continue to judge judge that through the number of times that powers on of disk the disk that is inserted into current location is new disk, realization can effectively discern use, extract in current location originally the back to data carried out change, the disk that continues to use in current location again is new disk, and can this type of disk be identified as old dish; Thereby make a mistake visit, improved the accuracy of identification.
Embodiment three
Present embodiment; On the basis of embodiment one; Also obtain the number of times that powers on of the disk that is inserted into current location, and the number of times that powers on that on the basis of embodiment one, combines to be inserted into the disk of current location judges whether the disk that is inserted into current location is new disk, Fig. 3 shows the process flow diagram of the realization of the disk access control method that the embodiment of the invention three provides; This method is applied to cluster distributed storage file system; Said system comprises the metadata dish that is used for storing metadata, and the disk that is used for storage file, and details are as follows for said method:
In step S301, when disk inserts, obtain the disk sequence number of the disk that is inserted into current location and be inserted into the number of times that powers on of the disk of current location.
In step S302; Whether the device number according to current location, the disk place equipment of the disk sequence number of the said current location of obtaining and storage in advance is consistent with the particular disk sequence number; If consistent, if execution in step S303 is inconsistent; Judge that the disk that is inserted into current location is new disk, execution in step S304.
In step S303; Whether the number of times that powers on of judging the disk of the said current location obtain adds 1 greater than the number of times that powers on of the disk of the current location of storage in advance; If greater than, then judge and judge that the disk that is inserted into current location is new disk, execution in step S304; If be not more than, judge that the disk that is inserted into current location is to be not new disk, execution in step S305.
In step S304, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
In step S305, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
Present embodiment further obtains the number of times that powers on of disk on the basis of embodiment one; Whether the device number of the current location of the disk sequence number of the said current location of obtaining through judgement and storage in advance, disk place equipment is consistent with the particular disk sequence number; If inconsistent, judge that the disk that is inserted into current location is new disk, then needn't judge again; If it is consistent; Then continue to judge judge that through the number of times that powers on of disk the disk that is inserted into current location is new disk, realization can effectively discern use, extract in current location originally the back to data carried out change, the disk that continues to use in current location again is new disk, and can this type of disk be identified as old dish; Thereby make a mistake visit, improved the accuracy of identification.
Embodiment four
Fig. 4 shows the structural drawing of the disk access control device that the embodiment of the invention four provides; For the ease of explanation; Only show the part relevant with the embodiment of the invention, this disk access control device is applied to cluster distributed storage file system, and said system comprises the metadata dish that is used for storing metadata; And the disk that is used for storage file, said device comprises: acquiring unit 41, judging unit 42, updating block 43 and stick unit 44.
Acquiring unit 41 is used for when disk inserts, and obtains the disk sequence number of the disk that is inserted into current location;
Judging unit 42 is used for judging according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk; Perhaps, judge according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk;
Updating block 43 is used for if new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
Stick unit 44 is used for if not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
Optional, acquiring unit 51 also is used to obtain the number of times that powers on of the disk that is inserted into current location.
Optional, judging unit 42 can comprise: first judge module, first starts module and second and starts module.
First judge module is used to judge whether the current location of the disk sequence number of the said current location of obtaining and storage in advance is consistent with the particular disk sequence number;
First starts module; Judge that the current location and the particular disk sequence number of the disk sequence number of the said current location of obtaining and storage in advance are inconsistent if be used for first judge module; Judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 43;
Second starts module; Judge that the current location of the disk sequence number of the said current location of obtaining and storage in advance is consistent with the particular disk sequence number if be used for first judge module; Whether the number of times that powers on of judging the disk of the said current location obtain adds 1 greater than the number of times that powers on of the disk of the current location of storage in advance; If greater than, then judge and judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 43; If be not more than, judge that the disk that is inserted into current location is to be not new disk, and start above-mentioned updating block 43;
Optional, judging unit 42 can comprise: second judge module, the 3rd starts module and the 4th and starts module.
Second judge module; Whether the device number that is used for current location, disk place equipment according to the disk sequence number of the said current location obtained and storage in advance is consistent with the particular disk sequence number, and whether the disk that judgement is inserted into current location is new disk;
The 3rd starts module; Judge that the device number and the particular disk sequence number of the current location of the disk sequence number of the said current location of obtaining and storage in advance, disk place equipment are inconsistent if be used for second judge module; Judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 43;
The 4th starts module; Judge that the device number of the current location of the disk sequence number of the said current location of obtaining and storage in advance, disk place equipment is consistent with the particular disk sequence number if be used for second judge module; Whether the number of times that powers on of judging the disk of the said current location obtain adds 1 greater than the number of times that powers on of the disk of the current location of storage in advance; If greater than, then judge and judge that the disk that is inserted into current location is new disk, and start the updating block 43 in the claim 3; If be not more than, judge that the disk that is inserted into current location is to be not new disk, and start above-mentioned updating block 43.
Among the method embodiment one to three that the disk access control device that the embodiment of the invention provides can use in aforementioned correspondence, details repeat no more at this referring to the description of the foregoing description one to three.
Embodiment five
Fig. 5 shows the structural drawing that the present invention implements the five disk access control system that provide; For the ease of explanation; Only show the part relevant with the embodiment of the invention; Said system comprises a plurality of disks 51 and disk access control device 52, and said disk access control device 52 links to each other with said a plurality of disks 51;
Said a plurality of disk 51 is used for the metadata and the file of storing metadata;
Said disk access control device 52 comprises: acquiring unit 521, judging unit 522, updating block 523 and stick unit 524.
Acquiring unit 521 is used for when disk inserts, and obtains the disk sequence number of the disk that is inserted into current location;
Judging unit 522 is used for judging according to the disk sequence number of the said current location of obtaining and the current location of storage in advance and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk; Perhaps, judge according to the current location of the disk sequence number of the said current location of obtaining and storage in advance, the device number of disk place equipment and the corresponding relation of particular disk sequence number whether the disk that is inserted into current location is new disk;
Updating block 523 is used for if new disk, the current location of original preservation and to be inserted in corresponding relation between the old disk of current location be the corresponding relation between current location and the new disk on the update metadata dish;
Stick unit 524 is used for if not new disk, the current location of original preservation and be inserted in the corresponding relation between the disk of current location on the preserve metadata dish.
Optional, said acquiring unit 521 also is used to obtain the number of times that powers on of the disk that is inserted into current location;
Optional, said judging unit 522 comprises: first judge module, first starts module and second and starts module.
First judge module is used to judge whether the current location of the disk sequence number of the said current location of obtaining and storage in advance is consistent with the particular disk sequence number;
First starts module; Judge that the current location and the particular disk sequence number of the disk sequence number of the said current location of obtaining and storage in advance are inconsistent if be used for first judge module; Judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 523;
Second starts module; Judge that the current location of the disk sequence number of the said current location of obtaining and storage in advance is consistent with the particular disk sequence number if be used for first judge module; Whether the number of times that powers on of judging the disk of the said current location obtain adds 1 greater than the number of times that powers on of the disk of the current location of storage in advance; If greater than, then judge and judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 523; If be not more than, judge that the disk that is inserted into current location is to be not new disk, and start above-mentioned updating block 523;
Optional, said judging unit comprises: second judge module, the 3rd starts module and the 4th and starts module.
Second judge module; Whether the device number that is used for current location, disk place equipment according to the disk sequence number of the said current location obtained and storage in advance is consistent with the particular disk sequence number, and whether the disk that judgement is inserted into current location is new disk;
The 3rd starts module; Judge that the device number and the particular disk sequence number of the current location of the disk sequence number of the said current location of obtaining and storage in advance, disk place equipment are inconsistent if be used for second judge module; Judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 523;
The 4th starts module; Judge that the device number of the current location of the disk sequence number of the said current location of obtaining and storage in advance, disk place equipment is consistent with the particular disk sequence number if be used for second judge module; Whether the number of times that powers on of judging the disk of the said current location obtain adds 1 greater than the number of times that powers on of the disk of the current location of storage in advance; If greater than, then judge and judge that the disk that is inserted into current location is new disk, and start above-mentioned updating block 523; If be not more than, judge that the disk that is inserted into current location is to be not new disk, and start above-mentioned updating block 523.
It should be noted that in said apparatus and the system embodiment that each included unit is just divided according to function logic, but is not limited to above-mentioned division, as long as can realize function corresponding; In addition, the concrete title of each functional unit also just for the ease of mutual differentiation, is not limited to protection scope of the present invention.
In addition; One of ordinary skill in the art will appreciate that all or part of step that realizes in above-mentioned each embodiment method is to instruct relevant hardware to accomplish through program; Corresponding program can be stored in the computer read/write memory medium; Described storage medium is like ROM/RAM, disk or CD etc.
The above is merely preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of within spirit of the present invention and principle, being done, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.