Summary of the invention
Embodiments of the invention provide a kind of data managing method and device, can improve the performance of file system.
For achieving the above object, embodiments of the invention adopt following technical scheme:
First aspect, provides a kind of data managing method, is applied to, in file system, it is characterized in that, the storage space of described file system comprises m piece group, and wherein, m is greater than 0 integer, and described data managing method comprises:
In described m piece group, judge whether the space hold amount of n piece group reaches default threshold value, wherein, n is greater than 0 integer that is less than m;
If the space hold amount of described n piece group reaches default threshold value, in described n piece group, obtain migration sub-directory;
Data in described migration sub-directory and metadata are moved in n+1 piece group.
In conjunction with first aspect, in the possible implementation of the first, the described space hold amount that judges n piece group in described m piece group also comprises before whether reaching default threshold value:
The storage space of described file system is divided into described m piece group;
The 1st group in described m piece group by data initial in described file system and metadata store.
In conjunction with first aspect, in the possible implementation of the second, in described n piece group, obtain migration sub-directory, comprising:
In described n piece group, search data capacity and expand the fastest sub-directory;
The data capacity finding is expanded to the fastest sub-directory as described migration sub-directory.
In conjunction with first aspect, to any one possible implementation in the possible implementation of the second of first aspect, in the third possible implementation, the data in described migration sub-directory and metadata are moved in n+1 piece group, comprising:
According to the metadata in described migration sub-directory, read data corresponding to metadata in described migration sub-directory;
By data mobile corresponding to the metadata in the metadata in described migration sub-directory and described migration sub-directory in described n+1 piece group.
Second aspect, provides a kind of data administrator, is applied to, in file system, it is characterized in that, described file system comprises m piece group, and wherein, m is greater than 0 integer, and described data administrator comprises space management unit and data processing unit, wherein,
Described space management unit, for judging described m piece group whether the space hold amount of n piece group reaches default threshold value, wherein, n is greater than 0 integer that is less than m;
Described data processing unit, when reaching default threshold value when the space hold amount that judgment result is that described n piece group of described space management unit, in described n piece group, obtain migration sub-directory, and the data in described migration sub-directory and metadata are moved in n+1 piece group.
In conjunction with second aspect, in the possible implementation of the first,
Described space management unit, also for being divided into the storage space of described file system described m piece group;
Described data processing unit, also for described m the piece group in described space management dividing elements, by data initial in described file system and metadata store the 1st group.
In conjunction with second aspect, in the possible implementation of the second,
Described data processing unit, also expands the fastest sub-directory for search data capacity in described n piece group, and the data capacity finding is expanded to the fastest sub-directory as described migration sub-directory.
In conjunction with second aspect to any one possible implementation in the possible implementation of the second of second aspect, in the third possible implementation,
Described data processing unit, also for read data corresponding to metadata in described migration sub-directory according to the metadata of described migration sub-directory, and by data mobile corresponding to the metadata in the metadata in described migration sub-directory and described migration sub-directory in described n+1 piece group.
The data managing method that embodiments of the invention provide and device, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved 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 clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
Embodiments of the invention provide a kind of data managing method, are applied in file system, and in the present invention, the storage space of file system comprises m piece group, and wherein, m is greater than 0 integer, shown in Fig. 1, comprises the following steps:
101, in m piece group, judge whether the space hold amount of n piece group reaches default threshold value.
Wherein, n is greater than 0 integer that is less than m.
If the space hold amount of 102 n piece groups reaches default threshold value, in n piece group, obtain migration sub-directory.
If the space hold amount of n piece group reaches default threshold value, the space that n piece group is described is write full, can not write again new data, in order to guarantee that data under same sub-directory and metadata are in same group, need to will select one or more sub-directories to move in next piece group as migration sub-directory, like this, make the sub-directory of storing in each piece group comprise data and metadata complete under this catalogue, in the time of access file, can directly by directory name, determine file place piece group, improved access efficiency, if have file corruption in a piece group, can not affect other piece groups, improved the performance of file system.
103, data and metadata in migration sub-directory are moved in n+1 piece group.
Wherein, data comprise the particular content of file in file system.Metadata comprises the information such as file place catalogue, document creation time, filename, file size, file storage location.
The data managing method that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Based on embodiment corresponding to Fig. 1, another embodiment of the present invention provides a kind of data managing method, is applied to file system, shown in Fig. 2, specifically comprises the following steps:
201, the storage space of file system is divided into m piece group.
Concrete optional, the storage space of file system is divided into m the piece group that capacity is identical;
Or, set maximal value and the minimum value of a piece pool-size, in use according to the size of catalogue, do dynamic adjustment.
202, the 1st group in m piece group by data initial in file system and metadata store.
Whether the space hold amount that 203, judges the 1st group reaches default threshold value.
If the space hold amount of 204 the 1st groups reaches default threshold value, in the 1st group, obtain migration sub-directory.
Concrete optional, when the space hold amount of the 1st group reaches default threshold value, the space hold information of inquiring about sub-directory in the superblock of file system, expands the fastest sub-directory as migration sub-directory using data capacity.Wherein, data capacity expansion refers to that the data capacity rate of rise of storing under sub-directory is the fastest the soonest, and file system superblock comprises the information such as file system sub-directory, file system gross space, the space of having used, total files.
205, data and metadata in migration sub-directory are moved in the 2nd group.
Concrete optional, according to the metadata in migration sub-directory, read data corresponding to metadata in migration sub-directory, and by 2 groups of data mobile to the corresponding to the metadata in the metadata in migration sub-directory and migration sub-directory.
Repeating step 203-205, until the m of file system piece group all distributes.So just realized and the data in file system and metadata are divided into piece group have managed, the access of convenience file and backup.
The data managing method that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Based on Fig. 1 and embodiment corresponding to Fig. 2, embodiments of the invention provide a kind of file access method, shown in Fig. 3, comprise the following steps:
301, receive file access request.
Concrete, this document request of access comprises filename and directory name.Because will find file place piece group according to this directory name, so this directory name is very little, can determine unique piece group according to this directory name, namely file place piece group.
302, according to directory name, determine catalogue place piece group.
Concrete, according to directory name, in file system, search for this catalogue, if search this catalogue, determine this catalogue place piece group, if do not found, return to error reporting.
If 303 find catalogue place piece group, according to filename locating file metadata.
Concrete, determine after the piece group of catalogue place, in catalogue place piece group according to filename locating file metadata.
After step 302, also comprise:
If 304 do not find catalogue place piece group, return to error message.
After step 303, also comprise:
If 305 find file metadata, according to metadata in catalogue place piece group locating file data.
After step 303, also comprise:
If 306 do not find file metadata, return to error message.
On the basis with piece group managing file system, access file can directly be determined place piece group according to directory name, only need to search this piece group and just can realize access, need to be in whole file system locating file, improved the efficiency of access file.
The data managing method that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Based on Fig. 1 and embodiment corresponding to Fig. 2, embodiments of the invention provide a kind of file backup method, shown in Fig. 4, comprise the following steps:
401, according to predetermined directory name, in the storage space of file system, search this predetermined directory place piece group.
When user need to back up a catalogue, according to predetermined directory name, search this catalogue place piece group, specifically optional, when directory name is very large, data under this catalogue and metadata store are in a plurality of groups, and when directory name is very little, the data under this catalogue and metadata store are in a piece group.
If 402 find predetermined directory place piece group, store metadata all under predetermined directory and data into default backup space.
Concrete is optional, also can store all metadata and data in this catalogue place piece group into default backup space.
After step 401, also comprise:
If 403 do not find predetermined directory place piece group, return to error message.
Because back up with piece group, so when file system breaks down, as long as recover to make mistakes piece group, just can recover normal, improved the performance of file system.
The data managing method that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Embodiments of the invention provide a kind of data administrator, are applied in file system, in the present invention, the storage space of file system comprises m piece group, and wherein, m is greater than 0 integer, shown in Fig. 5, this data administrator 50 comprises space management unit 501 and data processing unit 502.
Wherein, space management unit 501, for judging m piece group whether the space hold amount of n piece group reaches default threshold value, wherein, n is greater than 0 integer that is less than m.
Data processing unit 502, when reaching default threshold value when the space hold amount that judgment result is that n piece group of space management unit 501, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group.
The data administrator that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Optionally, space management unit 501, also for being divided into the storage space of file system m piece group.
Data processing unit 502, also for 501 m the piece groups of dividing in space management unit, by data initial in file system and metadata store the 1st group.
Concrete optional, data processing unit 502, also expands the fastest sub-directory for search data capacity in n piece group, and the data capacity finding is expanded to the fastest sub-directory as migration sub-directory.
Optionally, data processing unit 502, also for reading data corresponding to metadata of migration in sub-directory according to the metadata of migration sub-directory, and by data mobile corresponding to the metadata in the metadata in migration sub-directory and migration sub-directory in n+1 piece group.
The data administrator that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Another embodiment of the present invention provides a kind of data administrator 6001, shown in Fig. 6, this equipment can embed or itself be exactly micro-process computer, such as: the portable equipments such as multi-purpose computer, customization machine, mobile phone terminal or purl machine, this data administrator 6001 comprises: at least one processor 6011, storer 6012 and bus 6013, this at least one processor 6011 is connected by bus 6013 with storer 6012 and completes mutual communication.
This bus 6013 can be ISA(Industry Standard Architecture, industry standard architecture) bus, PCI(Peripheral Component, peripheral component interconnect) bus or EISA(Extended Industry Standard Architecture, extended industry-standard architecture) bus etc.This bus 6013 can be divided into address bus, data bus, control bus etc.For ease of representing, in Fig. 6, only with a thick line, represent, but do not represent only to have the bus of a bus or a type.Wherein:
Storer 6012 is for stores executable programs code, and this program code comprises computer-managed instruction.Storer 6012 may comprise high-speed RAM storer, also may also comprise nonvolatile memory (non-volatile memory), for example at least one magnetic disk memory.
Processor 6011 may be a central processing unit 6011(Central Processing Unit, referred to as CPU), or specific integrated circuit (Application Specific Integrated Circuit, referred to as ASIC), or be configured to implement one or more integrated circuit of the embodiment of the present invention.
Processor 6011, for calling the program code of storer 6012, in order to carry out the operation of data processing unit and space management unit in the apparatus embodiments that above-mentioned Fig. 5 is corresponding, specifically describes with reference to apparatus embodiments corresponding to Fig. 5, repeats no more here.
The data administrator that embodiments of the invention provide, be applied to file system, by judging in m piece group whether the space hold amount of n piece group reaches default threshold value, if the space hold amount of n piece group reaches default threshold value, in n piece group, obtain migration sub-directory, and data and metadata in migration sub-directory are moved in n+1 piece group, improved the performance of file system.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize with hardware, or firmware realization, or their array mode realizes.When using software to realize, one or more instructions or the code that above-mentioned functions can be stored in computer-readable medium or on computer-readable medium transmit.Computer-readable medium comprises computer-readable storage medium and communication media, and wherein communication media comprises any medium of being convenient to transmit from a place to another place computer program.Storage medium can be any usable medium that computing machine can access.As example but be not limited to: computer-readable medium can comprise RAM(Random Access Memory, random access memory), ROM(Read Only Memory, read-only memory), EEPROM(Electrically Erasable Programmable Read Only Memory, EEPROM (Electrically Erasable Programmable Read Only Memo)), CD-ROM(Compact Disc Read Only Memory, be read-only optical disc) or other optical disc storage, magnetic disk storage medium or other magnetic storage apparatus, or can be used in carry or store the expectation with instruction or data structure form program code and can be by any other medium of computer access.In addition.Any connection can be suitable become computer-readable medium.For example, if software is to use concentric cable, optical fiber cable, twisted-pair feeder, DSL(Digital Subscriber Line, digital subscriber line) wireless technology or such as infrared ray, radio and microwave from website, server or other remote source transmission, so concentric cable, optical fiber cable, twisted-pair feeder, DSL or the wireless technology such as infrared ray, wireless and microwave be included under in the photographic fixing of medium.As used in the present invention, dish and dish comprise CD(Compact Disc, compression laser disc), laser dish, laser disc, DVD dish (Digital Versatile Disc, digital universal light), floppy disk and Blu-ray Disc, the copy data of the common magnetic of its mid-game, dish carrys out the copy data of optics with laser.Within combination above also should be included in the protection domain of computer-readable medium.
The above; be only the specific embodiment of the present invention, but protection scope of the present invention is not limited to this, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, within all should being encompassed in protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion by the described protection domain with claim.