The content of the invention
Embodiments of the invention provide a kind of data managing method and device, it is possible to increase the performance of file system.
To reach above-mentioned purpose, embodiments of the invention are adopted the following technical scheme that:
First aspect is there is provided a kind of data managing method, applied in file system, it is characterised in that the file system
The memory space of system includes m block group, and data and metadata are divided into block group and are managed by this document system, wherein, m for more than
0 integer, the data managing method includes:
Judge whether the space hold amount of n-th piece of group reaches default threshold value in the m block group, wherein, n be more than
0 is less than m integer;
If the space hold amount of n-th piece of group reaches default threshold value, migration is obtained in n-th piece of group
Catalogue;
Data and metadata in the migration subdirectory are moved in (n+1)th piece of group.
It is described that n-th piece of group is judged in the m block group with reference in a first aspect, in the first possible implementation
Space hold amount whether reach default threshold value before, in addition to:
The memory space of the file system is divided into the m block group;
Data and metadata initial in the file system are stored in the 1st piece of group in the m block group.
With reference in a first aspect, in second of possible implementation, migration subdirectory is obtained in n-th piece of group,
Including:
The searching data capacity expansion most fast subdirectory in n-th piece of group;
The data capacity found is expanded into most fast subdirectory and is used as the migration subdirectory.
With reference to first aspect to first aspect second of possible implementation in any one possible implementation,
In the third possible implementation, the data and metadata in the migration subdirectory are moved in (n+1)th piece of group, wrapped
Include:
Metadata in the migration subdirectory reads the corresponding data of metadata in the migration subdirectory;
Metadata in the migration subdirectory and the corresponding data of metadata in the migration subdirectory are moved to
In (n+1)th piece of group.
Second aspect is there is provided a kind of data administrator, applied in file system, it is characterised in that the file system
System includes m block group, and data and metadata are divided into block group and are managed by this document system, wherein, m is the integer more than 0, institute
Stating data administrator includes space management unit and data processing unit, wherein,
The space management unit, for judging it is pre- whether the space hold amount of n-th piece of group reaches in the m block group
If threshold value, wherein, n for more than 0 be less than m integer;
The data processing unit, for when the space that the judged result of the space management unit is n-th piece of group
When occupancy reaches default threshold value, in n-th piece of group obtain migration subdirectory, and by it is described migration subdirectory in number
It is moved to according to metadata in (n+1)th piece of group.
With reference to second aspect, in the first possible implementation,
The space management unit, is additionally operable to the memory space of the file system being divided into the m block group;
The data processing unit, is additionally operable in the m block group of the space management dividing elements, by the text
Initial data and metadata are stored in the 1st piece of group in part system.
With reference to second aspect, in second of possible implementation,
The data processing unit, is additionally operable in n-th piece of group searching data capacity expansion most fast subdirectory, and
The data capacity found is expanded into most fast subdirectory and is used as the migration subdirectory.
With reference to second aspect to second aspect second of possible implementation in any one possible implementation,
In the third possible implementation,
The data processing unit, the metadata being additionally operable in the migration subdirectory reads the migration subdirectory
In the corresponding data of metadata, and by it is described migration subdirectory in metadata and the metadata pair in the migration subdirectory
The data answered are moved in (n+1)th piece of group.
Data managing method and device that embodiments of the invention are provided, applied to file system, by m block group
Judge whether the space hold amount of n-th piece of group reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold
Value, then obtain migration subdirectory, and the data and metadata that migrate in subdirectory are moved into (n+1)th piece of group in n-th piece of group
In, improve the performance of file system.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made
Embodiment, belongs to the scope of protection of the invention.
Embodiments of the invention provide a kind of data managing method, applied in file system, in the present invention, file system
The memory space of system includes m block group, wherein, m is the integer more than 0, shown in reference picture 1, is comprised the following steps:
101st, judge whether the space hold amount of n-th piece of group reaches default threshold value in m block group.
Wherein, n is the integer more than 0 less than m.
If the 102, the space hold amount of n-th piece of group reaches default threshold value, migration specific item is obtained in n-th piece of group
Record.
If the space hold amount of n-th piece of group reaches default threshold value, illustrate that the space of n-th piece of group writes full, it is impossible to write again
Enter new data, in order to ensure data and metadata under same subdirectory in same piece of group, it is necessary to will selection one or
Multiple subdirectories are moved in next piece of group as migration subdirectory, so so that the subdirectory stored in each block group
Data and metadata complete under the catalogue are contained, file place directly can be determined by directory name when accessing file
Block group, improves access efficiency, and if having file corruption in a block group, do not interfere with other block groups, improve file
The performance of system.
103rd, the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group.
Wherein, data include the particular content of file in file system.Catalogue, document creation where metadata includes file
The information such as time, filename, file size, file storage location.
The data managing method that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Based on the corresponding embodiments of Fig. 1, another embodiment of the present invention provides a kind of data managing method, applied to file
System, shown in reference picture 2, specifically includes following steps:
201st, the memory space of file system is divided into m block group.
It is specific optional, the memory space of file system is divided into m block group of capacity identical;
Or, the maximum and minimum value of a block pool-size are set, dynamic tune is done according to the size of catalogue in use
It is whole.
The 202nd, data and metadata initial in file system are stored in the 1st piece of group in m block group.
203rd, judge whether the space hold amount of the 1st piece of group reaches default threshold value.
If the 204, the space hold amount of the 1st piece of group reaches default threshold value, migration specific item is obtained in the 1st piece of group
Record.
It is specific optional, when the space hold amount of the 1st piece of group reaches default threshold value, in the superblock of file system
The space hold information of subdirectory is inquired about, data capacity is expanded to most fast subdirectory as migration subdirectory.Wherein, data are held
Amount expands most refers under subdirectory that the data capacity rate of rise that stores is most fast soon, and file system superblock includes file system specific item
The information such as record, file system gross space, the space used, total files.
205th, the data and metadata that migrate in subdirectory are moved in the 2nd piece of group.
Specific optional, the metadata in migration subdirectory reads the corresponding number of metadata in migration subdirectory
According to, and the corresponding data of metadata in the metadata migrated in subdirectory and migration subdirectory are moved in the 2nd piece of group.
Repeat step 203-205, until m block group of file system is all distributed.So it is achieved that file system
Data and metadata in system are divided into block group and are managed, the access and backup of convenience file.
The data managing method that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Based on the corresponding embodiments of Fig. 1 and Fig. 2, embodiments of the invention provide a kind of file access method, the institute of reference picture 3
Show, comprise the following steps:
301st, file access request is received.
Specifically, this document access request includes filename and directory name.Because to find file according to the directory name
Place block group, so the directory name very little, can determine block group where unique block group, that is, file according to the directory name.
302nd, the block group according to where directory name determines catalogue.
Specifically, according to directory name in the file system search catalogue, if searching the catalogue, it is determined that the catalogue institute
In block group, if do not found, error reporting is returned to.
If block group where catalogue the 303, is found, according to filename lookup file metadata.
Specifically, after block group where determining catalogue, block group is according to filename lookup file metadata where catalogue.
After step 302, in addition to:
If the 304, not finding block group where catalogue, error message is returned.
After step 303, in addition to:
If the 305, finding file metadata, the block group locating file data according to where metadata in catalogue.
After step 303, in addition to:
If the 306, not finding file metadata, error message is returned.
On the basis of with block group management file system, place block group can directly be determined according to directory name by accessing file,
Only need to search the block group and can be achieved with accessing, it is not necessary to the locating file in whole file system, improve and access file
Efficiency.
The data managing method that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Based on the corresponding embodiments of Fig. 1 and Fig. 2, embodiments of the invention provide a kind of file backup method, the institute of reference picture 4
Show, comprise the following steps:
401st, the block group according to where predetermined directory name searches the predetermined directory in the memory space of file system.
When user needs one catalogue of backup, the block group according to where predetermined directory name searches the catalogue is specific optional,
When directory name is very big, data and metadata under the catalogue are stored in multiple pieces of groups, when directory name very little, under the catalogue
Data and metadata be stored in a block group.
If the 402, finding block group where predetermined directory, metadata all under predetermined directory and data Cun Chudao are preset
Backup space.
It is specific optional, can also be default standby by all metadata in block group where the catalogue and data Cun Chudao
Part space.
After step 401, in addition to:
If the 403, not finding block group where predetermined directory, error message is returned.
Because being backed up with block group, when file system breaks down, as long as recovering error block group, it becomes possible to extensive
It is multiple normal, improve the performance of file system.
The data managing method that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Embodiments of the invention provide a kind of data administrator, applied in file system, in the present invention, file system
The memory space of system includes m block group, wherein, m is the integer more than 0, and shown in reference picture 5, the data administrator 50 includes
Space management unit 501 and data processing unit 502.
Wherein, space management unit 501, for judging it is pre- whether the space hold amount of n-th piece of group reaches in m block group
If threshold value, wherein, n for more than 0 be less than m integer.
Data processing unit 502, for space hold amount of the judged result when space management unit 501 for n-th piece of group
When reaching default threshold value, migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved
Into (n+1)th piece of group.
The data administrator that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Optionally, space management unit 501, is additionally operable to the memory space of file system being divided into m block group.
Data processing unit 502, is additionally operable in the m block group that space management unit 501 is divided, will be first in file system
The data and metadata of beginning are stored in the 1st piece of group.
Specific optional, data processing unit 502 is additionally operable in n-th piece of group searching data capacity expansion most fast son
Catalogue, and the data capacity found is expanded into most fast subdirectory as migration subdirectory.
Optionally, data processing unit 502, are additionally operable to the metadata in migration subdirectory and read in migration subdirectory
The corresponding data of metadata, and the corresponding data of metadata in the metadata migrated in subdirectory and migration subdirectory are moved
Move into (n+1)th piece of group.
The data administrator that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Another embodiment of the present invention provides a kind of data administrator 6001, and shown in reference picture 6, the equipment can be embedded in
Or inherently microprocessor computer, such as:The portable equipments such as all-purpose computer, customization machine, mobile phone terminal or purl machine,
The data administrator 6001 includes:At least one processor 6011, memory 6012 and bus 6013, at least one processing
Device 6011 and memory 6012 are connected by bus 6013 and complete mutual communication.
The bus 6013 can be ISA (Industry Standard Architecture, industry standard architecture)
Bus, PCI (Peripheral Component, external equipment interconnection) buses or EISA (Extended Industry
Standard Architecture, extended industry-standard architecture) bus etc..The bus 6013 can be divided into address bus,
Data/address bus, controlling bus etc..Only represented for ease of representing, in Fig. 6 with a thick line, it is not intended that only one bus or
A type of bus.Wherein:
Memory 6012 is used to store executable program code, and the program code includes computer-managed instruction.Memory
6012 may include high-speed RAM memory, it is also possible to also including nonvolatile memory (non-volatile memory), example
Such as at least one magnetic disk storage.
Processor 6011 is probably that (Central Processing Unit are referred to as a central processing unit 6011
CPU), or specific integrated circuit (Application Specific Integrated Circuit, referred to as ASIC),
Or it is arranged to implement one or more integrated circuits of the embodiment of the present invention.
Processor 6011, it is real to perform the corresponding equipment of above-mentioned Fig. 5 for calling the program code in memory 6012
The operation of data processing unit and space management unit in example is applied, the corresponding apparatus embodiments of reference picture 5 are specifically described, here not
Repeat again.
The data administrator that embodiments of the invention are provided, applied to file system, by judging the in m block group
Whether the space hold amount of n block groups reaches default threshold value, if the space hold amount of n-th piece of group reaches default threshold value,
Migration subdirectory is obtained in n-th piece of group, and the data and metadata that migrate in subdirectory are moved in (n+1)th piece of group, is carried
The high performance of file system.
Through the above description of the embodiments, it is apparent to those skilled in the art that the present invention can be with
Realized with hardware, or firmware is realized, or combinations thereof mode is realized.When implemented in software, can be by above-mentioned functions
It is stored in computer-readable medium or is transmitted as one or more instructions on computer-readable medium or code.Meter
Calculation machine computer-readable recording medium includes computer-readable storage medium and communication media, and wherein communication media includes being easy to from a place to another
Any medium of individual place transmission computer program.Storage medium can be any usable medium that computer can be accessed.With
Exemplified by this but it is not limited to:Computer-readable medium can include RAM (Random Access Memory, random access memory), ROM
(Read Only Memory, read-only memory), EEPROM (Electrically Erasable Programmable Read
Only Memory, EEPROM), CD-ROM (Compact Disc Read Only Memory, i.e., only
Read CD) or other optical disc storages, magnetic disk storage medium or other magnetic storage apparatus or can be used in carrying or store tool
Have instruction or data structure form desired program code and can by computer access any other medium.In addition.Appoint
What connection can suitably as computer-readable medium.If for example, software is to use coaxial cable, optical fiber cable, multiple twin
Line, DSL (Digital Subscriber Line, digital subscriber line) or such as infrared ray, radio and microwave etc
Wireless technology is transmitted from website, server or other remote sources, then coaxial cable, optical fiber cable, twisted-pair feeder, DSL or
The wireless technology of person's such as infrared ray, wireless and microwave etc be included in belonging to medium it is fixing in.As used in the present invention,
Plate and dish include CD (Compact Disc, compress laser disc), laser disc, laser disc, DVD dish (Digital Versatile Disc,
Digital universal light), floppy disk and Blu-ray Disc, the replicate data of the usual magnetic of which disk, and dish is then replicated with laser come optical
Data.Above combination above should also be as being included within the protection domain of computer-readable medium.
The foregoing is only a specific embodiment of the invention, but protection scope of the present invention is not limited thereto, any
Those familiar with the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all be contained
Cover within protection scope of the present invention.Therefore, protection scope of the present invention described should be defined by scope of the claims.