Summary of the invention
The embodiment of the present invention provides a kind of method and device of data storage, for improving the utilization of memory spaceRate.
A method for data storage, comprises the following steps:
Receive the request of storage data, and from this request, obtain the data that need storage;
The logical storage address of the data of the need storage comprising according to described request, and according to logical storage addressWith the corresponding relation of grade, determine the data level of the data that need storage; Data level is the appearance according to dataWrong ability is set;
Store the data of need storage into the memory block corresponding with data level.
For a device for data storage, comprising:
Interface module for receiving the request of storage data, and obtains the data that need storage from this request;
Processing module, for the logical storage address of the data of the need storage that comprises according to described request, and rootAccording to the corresponding relation of logical storage address and grade, determine the data level of the data that need storage, and need are depositedThe data of storage store the memory block corresponding with data level into; Data level is to establish according to the fault-tolerant ability of dataFixed;
Memory block in memory module is used for storing data.
For a device for data storage, comprising:
File manager for receiving the request of storage data, and obtains the data that need storage from this request,And the logical storage address of the data of the need storage comprising according to described request, and according to logical storage addressWith the corresponding relation of grade, determine the data level of the data that need storage; Data level is the appearance according to dataWrong ability is set;
Driver, for storing the data of need storage into the memory block corresponding with data level.
Data and memory block are divided into multiple grades by the embodiment of the present invention, according to the logic of the data of need storageThe corresponding data level of address search, then memory block corresponding to data store into according to data level. According toThe fault-tolerant ability of data, the data of different pieces of information grade store in different good pieces. Due to data and depositingStorage piece has carried out classification, and does corresponding storage, can according to the maximum fault-tolerant ability of data set piece withThreshold value between bad piece, instead of as the fault-tolerant ability of equalization according to data in prior art set piece withThreshold value between bad piece, the present embodiment can be established higherly by the threshold value between good piece and bad piece,Can be higher than threshold value conventional in prior art, to improve the utilization rate of memory block. And, according to dataFault-tolerant ability, stores the data of different data levels in corresponding memory block into, reduces wrong data bandThe impact coming.
Detailed description of the invention
Data and memory block are divided into multiple grades by the embodiment of the present invention, according to the logic of the data of need storageThe corresponding data level of address search, then memory block corresponding to data store into according to data level. DataData level at least comprise two, memory block is Three Estate at least, a storage level pair of memory blockShould bad piece, at least two corresponding good pieces of storage level. According to the fault-tolerant ability of data, different pieces of information gradeData store in different good pieces, like this can according to the maximum fault-tolerant ability of data set piece and bad piece itBetween threshold value, instead of set the threshold value between piece and bad piece according to the fault-tolerant ability of equalization of data,The present embodiment can be established higherly by the threshold value between good piece and bad piece, can be higher than normal in prior artWith threshold value, to improve the utilization rate of memory block. And, according to the fault-tolerant ability of data, by differentThe data of data level store in corresponding memory block, reduce the impact that wrong data is brought.
Referring to Fig. 1, the main method flow process of data storage in the present embodiment is as follows:
Step 101: receive the request of storage data, and obtain the data that need storage from this request.
Step 102: the logical storage address of the data of the need storage comprising according to described request, and according to patrollingCollect the corresponding relation of memory address and grade, determine the data level of the data that need storage. Data level is to comply withSet according to the fault-tolerant ability of data. In the present embodiment, data comprise that system data is (as operating system and otherSoftware program etc.), text data (as note and telephone directory etc.) and multi-medium data be (as picture, musicWith video etc.) etc. The fault-tolerant ability of system data is minimum, and the fault-tolerant ability of multi-medium data is the highest. DataGrade is taking 3 grades as example, and the data level of system data is 0, and the data level of text data is 1, and sound is lookedThe data level of audio data is 2.
Step 103: store the data of need storage into the memory block corresponding with grade.
Referring to Fig. 2, the method detailed flow process of data storage in the present embodiment is as follows:
Step 201: obtain the request of storage data.
Step 202: obtain the data that need storage from this request.
Step 203: the logical storage address of the data of the need storage comprising according to described request, and according to patrollingCollect the corresponding relation of memory address and grade, determine the data level that needs storage data. In embedded system,Dissimilar data are the different file of correspondence conventionally, namely corresponding different logical address. For useThe file that family is self-built, although the actual type of the data of wherein depositing may be different, from recognizing in logicFor being the data of same type. Can be data level of the self-built file default configuration of user, or beUser provides interface, selects a data level by user.
Step 204: determine the storage level corresponding with data level. Storage level is the mistake according to memory blockErrored bit number is set; Data level is corresponding one by one with storage level, and the highest data level of fault-tolerant abilityCorresponding error bit is counted scope time large storage level.
Step 205: store the data of need storage into corresponding storage level corresponding memory block.
The error correcting capability of the error correction algorithm that preferably, the setting of storage level also will adopt according to memory block.Error bit is counted the large and error bit of scope time and is counted error bit between scope maximum and count dividing value and be no more than and depositThe maximum of the bit number of correcting a mistake of the error correction algorithm that storage piece adopts. For example, the correction mistake of error correction algorithmThe maximum of errored bit number is 16 bits, considers the mistake of nandflash memory block in long-term use procedureErrored bit number can increase, and in order to reduce the impact of this situation on data, the scope of error bit can being counted is inferior largeAnd error bit is counted error bit between scope maximum and is counted dividing value and be made as 12 bits. Error bit is counted scopeAs shown in table 1 with an example of the corresponding relation of storage level:
Table 1
Error bit is counted scope t |
Storage level |
0≤t<3 |
0 |
3≤t<8 |
1 |
8≤t<12 |
2 |
12≤t |
3 |
Due to only point good piece and bad piece in prior art, the maximum of the bit number of correcting a mistake of error correction algorithm with16 bits are example, and the threshold value between its good piece and bad piece is made as 8 bits conventionally. Employing the present embodiment providesScheme, can be set to 10-14 bit, apparently higher than 8 bits of prior art, improved the profit of memory blockBy rate. And in prior art, data are stored in piece, and do not done any differentiation, existed software numberStore wrong number in the such memory block of 6,7 bits according to the lower data of this fault-tolerant ability, leadCausing running software makes mistakes and maybe cannot move. And the present embodiment is by system program and this fault-tolerant ability of software dataLower data store the memory block of 0 storage level into, are no more than the wrong number of 2 bits, obviously reduceImpact on the operation of software and system. Storing the higher data of this video and audio fault-tolerant ability into 2 depositsThe memory block of storage grade, even if there are the data of several bits, verification is incorrect, also can not impact system,User is also difficult to discover.
The example of the corresponding relation of data level and storage level is as shown in table 2:
Table 2
The present embodiment is that data are provided with data level, so need to improve file manager. And,Store data into corresponding memory block according to storage level, so need to improve driver. In addition,In the management block (as using first memory block as management block) of nandflash, need to store each storageThe corresponding relation of piece and storage level. Below in conjunction with file manager and driver, the storing process of data is enteredRow is introduced.
Referring to Fig. 3, it is as follows that in the present embodiment, file manager and driver are realized the method flow of data storage:
Step 301: file manager obtains the request of storage data.
Step 302: file manager obtains the data that need storage from this request.
Step 303: file manager is determined the logical storage address that needs storage data according to described request.
Step 304: file manager, according to the corresponding relation of logical storage address and grade, is determined and needed storageThe data level of data.
Step 305: driver obtains the data, logical storage address and the number that need storage from file managerAccording to grade.
Step 306: driver is determined the storage level corresponding with data level.
Step 307: driver is stored data by need and stored the corresponding memory block of corresponding storage level into.Can also record the corresponding relation of logical storage address and actual storage address.
Along with the use of nandflash, storage level that can regular update memory block. Nandflash controllerAt every turn the nandflash Shi Junke that reads and writes data being carried out to verification to the data of read-write, as adopted error checkingWith correction (ECC) algorithm, obtain the error bit number of relevant memory block. Driver can read at every turnWhile writing data, all obtain error bit number from Nandflash controller, and judge the error bit of memory blockWhether number exceeds the corresponding error bit of its current storage level is counted scope, if so, obtains according to thisThe error bit number obtaining upgrades storage level corresponding to this memory block, and the storage level after upgrading is writeIn the management block of Nandflash, otherwise do not upgrade. Or, drive periodic (as every 3Month) obtain error bit number from Nandflash controller, and whether the error bit number that judges memory blockExceed the corresponding error bit of its current storage level and count scope, if so, according to the mistake of this acquisitionErrored bit number upgrades storage level corresponding to this memory block, otherwise does not upgrade.
Understood the implementation procedure of data storages by above description, this process can by device realize, below rightThe 26S Proteasome Structure and Function of this device is introduced.
Referring to Fig. 4, the device 400 for data storage in the present embodiment comprises: file manager 401 HesDriver 402.
File manager 401 for obtain storage data request, and from this request, obtain need storage numberAccording to, and determine the data level that needs the data of storing; Data level is to set according to the fault-tolerant ability of data. Concrete, the logical storage ground of the data of the need storage that file manager 401 comprises according to described requestLocation, and according to the corresponding relation of logical storage address and grade, determine the data level of the data that need storage.
Driver 402 is for storing the data of need storage into the memory block corresponding with grade. Concrete, driveMoving device 402 is determined the storage level corresponding with data level, and stores the data of need storage into corresponding depositThe corresponding memory block of storage grade. Driver 402 is also for according to the bit of nandflash controller error correctionNumber judges whether to adjust storage level corresponding to this memory block, in the time being judged as YES, according to the ratio of error correctionSpecial number is adjusted storage level corresponding to this memory block.
File manager 401 and driver 402 specifically can be realized by CPU, are situated between below in conjunction with hardware configurationContinue for the device 500 of data storage, shown in Figure 5, it comprises interface module 501, processing module502 and memory module 503.
Interface module 501 for obtain storage data request, and from this request, obtain need storage data.The event that interface module 501 can be passed through the triggerings such as keyboard, mouse or touch-screen obtains the request of storing dataData with need storage.
Processing module 502, as central processing unit (CPU) or micro-control unit (MCU) etc., for reallyThe data level of the fixed data that need storage, and store the data of need storage into the memory block corresponding with grade.Data level is to set according to the fault-tolerant ability of data. Concrete, processing module 502 is according to described requestThe logical storage address of the data of the need storage comprising, and according to logical storage address the corresponding pass with gradeSystem, determines the data level that needs the data of storing. Processing module 502 is determined the storage corresponding with data levelGrade, and store the data of need storage into corresponding storage level corresponding memory block.
Memory block in memory module 503 is used for storing data. Memory module 503 can be as nandflashDeng the memory of piece (block) formula structure.
Device 500 also comprises control module 504, shown in Figure 6. Control module 504 for to storageData carry out verification, obtain the bit number of error correction in memory block. Processing module 502 is also for according to error correctionBit number judge whether to adjust storage level corresponding to this memory block, in the time being judged as YES, according to entanglingWrong bit number is adjusted storage level corresponding to this memory block. Wherein, control module 504 can be nandflashThe storage controls such as controller.
Storage level is to set according to the error bit number of memory block; Data level and storage level one are a pair ofShould, and the highest corresponding error bit of data level of fault-tolerant ability is counted scope time large storage level. Mistake ratioTime large and error bit of special number scope is counted error bit between scope maximum and is counted dividing value and be no more than memory block instituteThe maximum of the bit number of correcting a mistake of the error correction algorithm adopting.
Data and memory block are divided into multiple grades by the embodiment of the present invention, and the data level of data at least comprisesTwo, memory block is Three Estate at least, the corresponding bad piece of a storage level of memory block, other storage etc.The corresponding good piece of level. According to the fault-tolerant ability of data, the data of different pieces of information grade store in different good pieces,Can set the threshold value between piece and bad piece according to the maximum fault-tolerant ability of data like this, instead of according to numberAccording to the fault-tolerant ability of equalization set the threshold value between piece and bad piece, the present embodiment can be by good piece and badThreshold value between piece is established higherly, can be higher than threshold value conventional in prior art, to improve memory blockUtilization rate. And, according to the fault-tolerant ability of data, the data of different data levels are stored into correspondingMemory block in, reduce the impact that brings of wrong data. Preferably, the embodiment of the present invention is according to error correction algorithmError correcting capability storage level is set, can substantially avoid data to make mistakes, thus avoid that wrong data causes eachPlant impact. And the embodiment of the present invention can also realize dynamically updating of storage level corresponding to memory block.
Those skilled in the art should understand, embodiments of the invention can be provided as method, system or meterCalculation machine program product. Therefore, the present invention can adopt complete hardware implementation example, completely implement software example or knotClose the form of the embodiment of software and hardware aspect. And the present invention can adopt at one or more wherein bagsThe computer-usable storage medium that contains computer usable program code (include but not limited to magnetic disc store andOptical memory etc.) form of the upper computer program of implementing.
The present invention is that reference is according to the method for the embodiment of the present invention, equipment (system) and computer program productThe flow chart of product and/or block diagram are described. Should understand can be by computer program instructions realization flow figure and/ or block diagram in each flow process and/or flow process in square frame and flow chart and/or block diagram and/Or the combination of square frame. Can provide these computer program instructions to all-purpose computer, special-purpose computer, embeddingThe processor of formula processor or other programmable data processing device, to produce a machine, makes by calculatingThe instruction that the processor of machine or other programmable data processing device is carried out produces for realizing at flow chart oneThe device of the function of specifying in square frame of individual flow process or multiple flow process and/or block diagram or multiple square frame.
These computer program instructions also can be stored in energy vectoring computer or other programmable data processing are establishedIn the standby computer-readable memory with ad hoc fashion work, make to be stored in this computer-readable memoryInstruction produce and comprise the manufacture of command device, this command device is realized in flow process or multiple of flow chartThe function of specifying in square frame of flow process and/or block diagram or multiple square frame.
These computer program instructions also can be loaded in computer or other programmable data processing device, makeMust on computer or other programmable devices, carry out sequence of operations step to produce computer implemented placeReason, thus the instruction of carrying out on computer or other programmable devices is provided for realizing one of flow chartThe step of the function of specifying in square frame of flow process or multiple flow process and/or block diagram or multiple square frame.
Obviously, those skilled in the art can carry out various changes and modification and not depart from this present inventionBright spirit and scope. Like this, if of the present invention these amendment and modification belong to the claims in the present invention andWithin the scope of its equivalent technologies, the present invention be also intended to comprise these change and modification interior.