Background technology
The software mechanism of being in charge of in the operating system with storage file information is called file management system, is called for short file system.File system is made up of three parts: the software relevant with file management, the file of being managed and the required data structure of enforcement file management.From system perspective, file system is that the file memory space is organized and distributed, and is responsible for the storage of file and the system that the file that deposits in is protected and retrieved.
File system is based upon on the physical storage device, for embedded device, the memory device that embedded device uses generally is not the disk on the multi-purpose computer, but Flash flash chip, compact flash cards, memory stick etc. aim at the storage medium of Embedded System Design.
The Flash storage medium can realize that the byte of completely random reads, but can not write twice to same memory address, and must just can write through behind the erase operation earlier.Because special Journal File System at flash memory has appearred in the uniqueness of storage medium in the embedded device.Journal File System has higher security than file system, write operation at first is that log file is operated, if whole write operation interrupts for a certain reason, then system reads the write operation that the content of log record file is recovered not finish when start next time.
Concrete, the design philosophy of journal file is: the variation of track record file system, and changing content is recorded into daily record.Journal File System is preserved log record in disk partition, write operation at first is that log file is operated, if whole write operation is (as system's power down) and interrupt for a certain reason, when Journal File System is restarted, the write operation before can recovering to interrupt according to log record.In Journal File System, the variation of all file system, interpolation and change all are recorded to daily record, promptly in the data of log file metadata information (information relevant with file).At regular intervals, file system can write disk with file metadata information and the file content after upgrading, and deletes this part daily record afterwards, restarts new log record.
In the prior art, Journal File System is managed data on the whole file system with the daily record node, the daily record node is called data entity again, for example use more at present JFFS2 just has only two types data entity jffs2_raw_inode and jffs2_raw_dirent on FLASH, the management information of the former include file, the latter is used for the position of description document in file system, and real data message just is kept at the back of jffs2_raw_inode node.
The daily record node is a data memory format unique on the flash memory device, and index is to help the data message of location daily record node fast.Journal File System of the prior art (for example JFFS2) is kept at index in the internal memory, and such design embodies great advantage on the flash memory of low capacity.When Journal File System is mounted to operating system, operating system scans full wafer flash storage medium rapidly, in internal memory, write the index of Journal File System, further set up various chained lists, for example chained list, the chained list of " dirty " and the chained list of erase block etc. of " clean piece " manage operation to file.
For high-capacity flash memory, when Journal File System is mounted to operating system, operating system scanning full wafer flash storage medium obtains the needed time of index will be very long. when Journal File System unloads, operating system is deleted the various information of buffer memory from internal memory, the index that comprises Journal File System, when time Journal File System is mounted to operating system again instantly, operating system re-executes scanning full wafer flash storage medium, and in internal memory, write the operation of the index of Journal File System. in the face of the embedded rapidly industry of development, the capacity of flash memory is increasing, the long bottleneck that has become prior art of mounting time.
There is following shortcoming in prior art:
When each Journal File System was mounted to operating system, operating system all needed to scan the full wafer storage medium, causes mounting time of journal file system long.
Summary of the invention
The invention provides a kind of method and apparatus that improves speed of mounting journal file system, to realize reducing mounting time of journal file system.
The invention provides a kind of method that improves speed of mounting journal file system, be applied to the embedded device of configuration log formula file system, dispose the chained list index information of index stores medium with storing daily record formula file system in the described embedded device, this method further may further comprise the steps:
When described Journal File System was mounted to the operating system of described embedded device for the first time, the storage medium of described Journal File System was set up in described operating system scanning, obtained the chained list index information of described Journal File System;
When described Journal File System unloaded for the first time, described operating system write described index stores medium with the chained list index information of described Journal File System, and according to writing described chained list index information different flag was set normally or unusually;
Follow-up described Journal File System is to described operating system carry, and described operating system reads flag information; If the chained list index information writes normally, described operating system directly reads described chained list index information from described index stores medium; If the chained list index information writes unusually, described operating system rescans the storage medium of setting up described Journal File System, obtains described chained list index information.
Described basis writes described chained list index information and different flag normally or unusually is set comprises: when writing described chained list index information just often, it is normal that described flag sign is set; When writing described chained list index information when unusual, it is unusual that described flag sign is set;
Described operating system also comprises after described index stores medium directly reads described chained list index information: the described flag of described operating system update is unusual for sign.
Described operating system also comprises after described index stores medium directly reads described chained list index information: described operating system normally is updated to sign unusually with described flag by sign.
Configuration comprises in order to the index stores medium of the chained list index information of storing daily record formula file system in the described embedded device:
In described embedded device, dispose independently index stores medium, to be specifically designed to the chained list index information of storing daily record formula file system; Perhaps
Reading speed storage area fast, easy to operate, that be not prone to bad piece is configured to described index stores medium in the storage medium of described Journal File System with setting up, and stores the chained list index information of described Journal File System.
Described operating system directly reads described chained list index information from described index stores medium and comprises:
Described chained list index information is read according to described memory location in the memory location of the pre-configured described chained list index information of described operating system in described index stores medium; Perhaps
Described operating system is searched the system banner of storage in advance and the corresponding relation of memory location according to the system banner of described Journal File System, obtains the memory location of described chained list index information in described index stores medium, reads described chained list index information.
Described operating system writes described index stores medium with the chained list index information of described Journal File System and comprises:
Described operating system is disposable to write described index stores medium with described chained list index information; Perhaps
Described operating system writes described index stores medium according to setting in advance several times with described chained list index information.
Described index stores medium is specially the Nor-Flash storage medium.
The invention provides a kind of equipment that is applied to said method, this equipment comprises that storage medium, dispensing unit, scanning element, writing unit, the sign of index stores medium, Journal File System are provided with unit and reading unit, wherein
Described dispensing unit is connected with described index stores medium, is used for the chained list index information of configuration index storage medium stores Journal File System;
Described scanning element, be connected with the storage medium of described reading unit and Journal File System, be used for when described Journal File System is mounted to the operating system of described embedded device for the first time, the storage medium of described Journal File System is set up in scanning, obtains the chained list index information of described Journal File System; The follow-up flag sign chained list index information that reads when described reading unit writes when unusual, rescans the storage medium of setting up described Journal File System, obtains described chained list index information;
The said write unit is connected with described index stores medium, is used for when the unloading of described Journal File System, and the chained list index information of described Journal File System is write described index stores medium;
Described sign is provided with the unit, is connected with said write unit and reading unit, is used for writing described chained list index information according to the said write unit different flag normally or unusually is set, and follow-uply read this flag by reading unit;
Described reading unit is provided with the unit with described sign and scanning element is connected, and is used for follow-up described Journal File System when described operating system carry, reads described sign the flag that the unit is provided with is set; If the chained list index information writes normally, directly read described chained list index information from described index stores medium, and writing when unusual, notify described scanning element to scan and obtain the chained list index information.
Described sign is provided with the unit and also is used for: when the said write unit writes described chained list index information just often, described flag sign is set normally; When the said write unit writes described chained list index information when unusual, it is unusual that described flag sign is set; When described reading unit after described index stores medium directly reads described chained list index information, it is unusual that described flag normally is updated to sign by sign.
Described dispensing unit also is used for:
Setting need write the chained list index information content in the described index stores medium.
Described reading unit also is used for:
According to the pre-configured memory location of described chained list index information in described index stores medium, read described chained list index information; Perhaps
Search the system banner of storage in advance and the corresponding relation of memory location according to the system banner of described Journal File System, obtain the memory location of described chained list index information in described index stores medium, read described chained list index information.
The said write unit also is used for:
With the described index stores medium of described chained list index information one-time write; Perhaps described chained list index information is write described index stores medium according to setting in advance several times.
Compared with prior art, the present invention has the following advantages:
Among the present invention, use the chained list index information of index stores medium memory Journal File System, when Journal File System is mounted to operating system, operating system can directly read the chained list index information of Journal File System from the index stores medium, do not need to scan the storage medium of setting up this Journal File System, thereby reduce mounting time of journal file system.
Embodiment
Core concept of the present invention is: the configuration index storage medium is preserved the various chained list index informations of Journal File System, utilizes the thought of space change time to improve the carry performance of Journal File System.The index stores medium when operating system unloads, is kept at the various chained list index informations of the Journal File System in the internal memory at Journal File System; When this Journal File System is mounted to operating system next time, operating system directly reads the chained list index information of this Journal File System from the index stores medium, do not need to scan the storage medium of setting up Journal File System, thereby reduce mounting time of journal file system.
The invention provides a kind of method that improves speed of mounting journal file system, be applied to the embedded device of configuration log formula file system, dispose the chained list index information of index stores medium in the described embedded device separately, and the obtain manner of flag sign chained list index information further is set in described index stores medium with storing daily record formula file system; As shown in Figure 1, this method further comprises:
Step 101, when described Journal File System was mounted to the operating system of described embedded device for the first time, the storage medium of described Journal File System was set up in described operating system scanning, obtained the chained list index information of described Journal File System;
Step 102, when described Journal File System unloads for the first time, described operating system writes described index stores medium with the chained list index information of described Journal File System, and according to writing described chained list index information different flag is set normally or unusually;
Step 103, follow-up described Journal File System is to described operating system carry, and described operating system reads flag information; If the chained list index information writes normally execution in step 104; If the chained list index information writes unusually execution in step 105;
Step 104, described operating system directly reads described chained list index information from described index stores medium;
Step 105, described operating system rescans the storage medium of setting up described Journal File System, obtains described chained list index information.
Introduce the method for raising speed of mounting journal file system provided by the invention in detail below in conjunction with concrete application scenarios.
Application scenarios of the present invention provides a kind of method that improves speed of mounting journal file system, as shown in Figure 2, may further comprise the steps:
Step 201, independent configuration index storage medium in embedded device.
Concrete, the index stores medium that provides in the application scenarios of the present invention, have and be not prone to bad piece, have enough address pin to come addressing, easily each byte and the fast characteristics of reading speed of its inside of access, be specifically as follows the Nor-Flash storage medium.
Step 202 after embedded device starts, is mounted to operating system with Journal File System for the first time, writes the index of Journal File System in internal memory.
Concrete, have a Journal File System in the embedded device usually.But, because embedded device can comprise a plurality of disk partition, handle the difference of file according to each disk partition, each disk partition can corresponding different file system, so, can have plural Journal File System in the embedded device.
After embedded device started, operating system was set up root directory, the Journal File System that uses this root directory carry to need.When having only a Journal File System in the embedded device, when embedded device powers on, the operating system mounting journal file system; When embedded device is electric down, operating system unloading Journal File System, wherein the following electric mode of embedded device can be normal electricity or abnormal power-down down.When comprising two above Journal File Systems in the embedded device, operating system also can be switched different Journal File Systems as required.
When the operating system mounting journal file system first time, operating system scans the disk partition of this Journal File System correspondence, the daily record node of location Journal File System, and, call the file of the disk partition storage of Journal File System correspondence according to the index information in the internal memory and handle index and other chained list index information write memories of daily record node.
Step 203, before above-mentioned Journal File System unloading, operating system all writes the index stores medium with the index information of storing in the internal memory.
Provide special index stores medium to be used for the index information of stored memory in the application scenarios of the present invention.The capacity of this index stores medium is a principle with the index information of enough memory devices, have enough address pin to come addressing since simple index information to take capacity less, therefore, the index stores medium does not need jumbo storage medium.Consider that the index in the index stores medium will preserve for a long time, and when the index error of storage, will cause equipment not carry out operate as normal, so the index stores medium should have the performance that is not easy to occur bad piece according to index.Simultaneously, operating system will influence mounting time of journal file system in embedded device from the speed that the index stores medium reads index, and therefore, the index stores medium should possess the fast characteristics of reading speed.Satisfying the index stores medium of above-mentioned performance can select according to actual needs flexibly, for example can adopt the Nor-Flash storage medium.
Operating system writes index in internal memory after, can gradually the index in the internal memory be write the index stores medium according to the pre-configured time, for example every interval certain hour read one time in the internal memory index and the index that reads write the index stores medium; Also can when unload, Journal File System read all index in the internal memory and write the index stores medium.
Variation for the whole Journal File System of complete documentation, operating system adopts first kind of mode when the index stores medium writes index, write the operation that needs to finish before the index to the Journal File System All Files for the last time, comprise file read-write operation and refuse collection work; If operating system adopts the second way to write index to the index stores medium, then operating system is chosen in the process of unloading index is write the index stores medium, the All Files read-write operation of operating system closing journal formula file system, and refuse collection work before this.The employing of this dual mode can be selected according to actual needs flexibly by the user, and for example, when the index information data volume is very big, the user thinks when index information one-time write storage medium needed overlong time, can adopt first kind of mode to write several times; If the index information data volume is little or repeatedly write in the time of can impacting user's use, the user can adopt second way one-time write.
When operating system writes index in the index stores medium, follow-uply from medium, read index and write memory is a principle with convenient, for example can with index according to the time sequencing that produces, according to the address from small to large order write the index stores medium, certainly, also can order descending according to the address or that other conveniently read in the index stores medium, write index.
In the application scenarios of the present invention, when having only a Journal File System in the embedded device, operating system writes index according to above-mentioned index writing mode in the index stores medium; When embedded device has a plurality of Journal File System, accordingly, can dispose two above index stores media, perhaps in same index stores medium, divide the index that a plurality of storage areas are used for storing respectively each Journal File System.
Step 204 when operating system mounting journal file system subsequently, reads the flag in the index stores medium, need to judge whether the storage medium of this Journal File System correspondence of scanning; If judged result is for being execution in step 205; Otherwise, execution in step 206.
Concrete, when embedded device has a plurality of Journal File System, the system banner of the pre-configured Journal File System of operating system is distinguished the flag of different Journal File Systems and the storage area of various chained list index informations in the index stores medium of Journal File System according to system banner.
Consider that there is the situation of abnormal power-down in embedded device, at this moment, the uninstall process of last Journal File System is not finished smoothly, therefore, can not guarantee to write in the index stores medium all index in the preceding internal memory of unloading.Corresponding with daily record node in the Journal File System in order to guarantee the index in the index stores medium, when abnormal power-down, operating system need rescan the storage medium of Journal File System correspondence, obtains the index of daily record node, and promptly execution in step 205.Otherwise operating system can execution in step 206, with the index write memory in the index stores medium.
The obtain manner of flag sign chained list index information is set in the index stores medium, operating system perhaps directly reads the chained list index information from the index stores medium by reading the storage medium that this flag need to judge whether this Journal File System correspondence of scanning.During the each mounting journal file system of operating system, can judge whether that needs scan the storage medium of this Journal File System correspondence according to flag, when comprising the operating system mounting journal file system first time, operating system also can scan the storage medium of this Journal File System correspondence according to the flag judged result, obtains the index of daily record node in the Journal File System.
Concrete, operating system is when writing index in storage medium, and (for example first storage area) writes flag at first in predefined memory location, and this flag is initially 00; After operating system writes the index stores medium fully with index, flag is updated to FF.Next time is during the operating system mounting journal file system, operating system at first reads the flag in the index stores medium, if this flag is FF, then operating system directly reads index from the index stores medium, and flag is updated to 00, after the index in the internal memory is write the index stores medium fully, again flag is updated to FF.If Journal File System generation abnormal power-down, i.e. not smoothly unloading, flag remains 00, during next operating system mounting journal file system, finds this flag 00, then scans the storage medium of Journal File System correspondence.
Step 205, operating system scans the storage medium of Journal File System correspondence, obtains the index of daily record node in the Journal File System, writes index in internal memory.
Concrete, after the step 205, when Journal File System unloaded, operating system write the index stores medium with the index in the internal memory, and detailed process is with reference to above-mentioned steps 203.
Step 206, operating system read index and the write memory of storing in the index stores medium, carry out file processing according to index.
Concrete, when having only a Journal File System in the embedded device, the index of the single Journal File System of index stores medium memory, operating system directly reads the index of storing in the index stores medium.
When having a plurality of Journal File System in the embedded device, the index stores medium is at the index of the different Journal File Systems of a plurality of area stores, at this moment, operating system need be searched corresponding storage area according to being identified at of Journal File System in the index stores medium, read the index of this Journal File System correspondence.
The index stores medium that disposes in the application scenarios of the present invention can be a storage medium independently, a part that also can be used as the storage medium of existing Journal File System correspondence exists, at this moment, the storage medium of Journal File System correspondence is divided into two parts storage area, part storage area capacity is less, exist as above-mentioned index stores medium, this part storage area has that data reading speed is fast, easy operating and be not easy to occur the performance of bad piece, be used to store various chained list index informations, the start-up code of running log formula file system; Another part storage area capacity is big, is used for the alternative document or the data of storing daily record formula file system correspondence.
When adopting this storage medium, if Journal File System is mounted to operating system, then operating system at first reads the index stores zone of storage medium, judges whether another part storage area that needs scanning index storage medium is outer according to flag.If judged result is to need, operating system scans the chained list index information that another storage area obtains Journal File System, and when Journal File System unloads the chained list index information is write the index stores area stores.If judged result is not for needing, operating system directly reads the chained list index information index and the write memory of index stores area stores, does not need to scan another storage area.
By adopting method provided by the invention, the chained list index information of configuration index storage medium stores Journal File System, when Journal File System is mounted to operating system, operating system can directly read the chained list index information of Journal File System from the index stores medium, do not need to scan the storage medium of setting up this Journal File System, thereby reduce mounting time of journal file system.
The invention provides a kind of equipment that improves speed of mounting journal file system, as embedded device, perhaps be integrated in the embedded device as a functional module, as shown in Figure 3, this equipment comprises that storage medium, dispensing unit 301, scanning element 302, writing unit 303, the sign of index stores medium, Journal File System are provided with unit 304 and reading unit 305, wherein
Described dispensing unit 301 is connected with described index stores medium, is used for the chained list index information of configuration index storage medium stores Journal File System.Concrete; described dispensing unit 301 can also be provided with unit 304 with reading unit 305, writing unit 303 and sign and be connected; setting need write the chained list index information content in the described index stores medium; chained list index information content that configuration reading unit 305 need read or writing unit 303 need write the chained list index information content in the index stores medium; dispensing unit 301 can also the configuration identifier positions concrete form, for sign unit 304 is set and uses the concrete form sign of these flag normal or unusually.
Described scanning element 302, be connected with described reading unit 305 and file system storage medium, be used for when described Journal File System is mounted to the operating system of described embedded device for the first time, the storage medium of described Journal File System is set up in scanning, obtains the chained list index information of described Journal File System; The follow-up flag sign chained list index information that reads when described reading unit 305 writes when unusual, rescans the storage medium of setting up described Journal File System, obtains described chained list index information.
Said write unit 303, unit 304, reading unit 305 and index stores medium are set are connected with described dispensing unit 301, sign, be used for when the unloading of described Journal File System, the chained list index information of described Journal File System is write described index stores medium.Concrete, said write unit 303 can perhaps write described index stores medium according to setting in advance several times with described chained list index information with the described index stores medium of described chained list index information one-time write.
Described sign is provided with unit 304, is connected with reading unit 305 with said write unit 303, is used for writing described chained list index information according to said write unit 303 different flag normally or unusually is set.Concrete, when said write unit 303 writes described chained list index information just often, described sign is provided with unit 304, and that described flag sign is set is normal; When said write unit 303 writes described chained list index information when unusual, described sign is provided with unit 304, and that described flag sign is set is unusual.When described reading unit 305 after described index stores medium directly reads described chained list index information, described sign is provided with unit 304, and also to be used to upgrade described flag unusual for sign.
Described reading unit 305, with sign unit 304, index stores medium, writing unit 303 and scanning element 302 being set is connected, be used for follow-up described Journal File System when described operating system carry, read described sign the flag that unit 304 is provided with is set; If the chained list index information writes normally, directly read described chained list index information from described index stores medium; And writing when unusual, notify described scanning element 302 scannings to obtain the chained list index information.Concrete, described reading unit 305 reads described chained list index information according to the pre-configured memory location of described chained list index information in described index stores medium; Perhaps search the system banner of storage in advance and the corresponding relation of memory location, obtain the memory location of described chained list index information in described index stores medium, read described chained list index information according to the system banner of described Journal File System.
By adopting equipment provided by the invention, the chained list index information of configuration index storage medium stores Journal File System, when Journal File System is mounted to operating system, operating system can directly read the chained list index information of Journal File System from the index stores medium, do not need to scan the storage medium of setting up this Journal File System, thereby reduce mounting time of journal 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 by the mode that software adds essential general hardware platform, can certainly pass through hardware, but the former is better embodiment under a lot of situation.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in the storage medium, comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
It will be appreciated by those skilled in the art that accompanying drawing is the synoptic diagram of a preferred embodiment, module in the accompanying drawing or flow process might not be that enforcement the present invention is necessary.
It will be appreciated by those skilled in the art that the module in the device among the embodiment can be distributed in the device of embodiment according to the embodiment description, also can carry out respective change and be arranged in the one or more devices that are different from present embodiment.The module of the foregoing description can be merged into a module, also can further split into a plurality of submodules.
The invention described above embodiment sequence number is not represented the quality of embodiment just to description.
More than disclosed only be several specific embodiment of the present invention, still, the present invention is not limited thereto, any those skilled in the art can think variation all should fall into protection scope of the present invention.