The invention concerns in general the technical field of storing important digital data in memory in a way that enables subsequently restoring the data in the case of an unexpected operational failure. Especially the invention concerns storing the frequently changing configuration data in a router, using a non-volatile flash memory and data compression.
A router must store the changes in router configuration that it receives every now and then as new connections are set up and old ones become obsolete. Configuration data is essential for the correct operation of the router, and it must be stored in a form from which it can be later retrieved even if an unexpected error has occurred and caused data in the volatile run-time memory to become corrupt or vanish. A file that contains accumulated data about changes in router configuration is frequently referred to as a delta log.
Some prior art routers utilize flash memory as a non-volatile storage, into which the delta log is stored in compressed form. The storing algorithm for storing the delta log must take into account that data is accumulated continuously, and a failure may occur at any moment, so data should not be allowed to accumulate in volatile memory only for a long time before a next copy to non-volatile flash memory is made. On the other hand the known structure and operation of flash memory is ill suited for continuous bit-by-bit storing, and favours handling the flash memory in larger units called records.
At step 111 both sections of flash memory are empty. A write pointer, illustrated schematically as a small arrow, shows the location in each section of flash memory where the next write operation will begin. At step 112 a piece of configuration data 103 is written into the flash buffer, causing the write pointer to move to the next free space in the buffer. The old location of the write pointer is shown with an arrow in brackets. Nothing happens in the flash file yet. A similar incident occurs at step 113, where a next piece of configuration data 104 is written into the flash buffer. Only at step 114, when the flash buffer becomes full, something is written to the flash file also: the accumulated contents of the flash buffer are compressed using some suitable data compression algorithm, and the compression result 105 is written to the flash file. The write pointer in the flash file advances to point at the next free location. At step 115 the flash buffer is cleared, and a new round of accumulating configuration data into the flash buffer begins. Next time when compression occurs, the new compression result will follow the previous one in the flash file.
The drawback of the arrangement of
An objective of the invention is to present a method and devices for storing a delta log with low requirements for memory space, especially flash memory. Another objective of the invention is that the method and devices for storing a delta log are simple and robust, and applicable to a wide variety of router implementations.
The objectives of the invention are achieved by maintaining a buffer for new configuration data in volatile memory, compressing the contents of the buffer after each incident of adding new data, and utilizing flash transactions to either over-write previous compression results in flash memory or write the new compression result into a new record depending on its length.
A method according to the invention is characterised by the steps recited in the characterising part of the independent claim directed to a method.
A router device according to the invention is characterised by the features recited in the characterising part of the independent claim directed to a router device.
A computer program product according to the invention is characterised by the features recited in the characterising part of the independent claim directed to a computer program product.
When new data is written into a flash memory, it can either replace an existing record (i.e. the existing record may be updated) or it can go to a completely virginal record. Here it is suggested that a choice between these two possibilities is made based on the current length of the compressed delta log buffer. If the compression result is much shorter than a record, it will only update an existing, immediately earlier written record. The constant accumulation of configuration data ensures that little by little the compression result becomes longer, until it is long enough to fill the current record, and possibly overflow partly to the next record in the flash memory. At that point the completed record is “frozen”, the buffer is cleared, and the process starts anew, with the new writing point in the flash memory being selected either from the record having leftovers from the frozen record or from next logical record in the flash memory. If the record having leftovers from the frozen records is chosen, the writing point is set immediately after the used space in the record.
The exemplary embodiments of the invention presented in this patent application are not to be interpreted to pose limitations to the applicability of the appended claims. The verb “to comprise” is used in this patent application as an open limitation that does not exclude the existence of also unrecited features. The features recited in depending claims are mutually freely combinable unless otherwise explicitly stated.
The novel features which are considered as characteristic of the invention are set forth in particular in the appended claims. The invention itself, however, both as to its construction and its method of operation, together with additional objects and advantages thereof will be best understood from the following description of specific embodiments when read in connection with the accompanying drawings.
At block 202 a compression algorithm is applied to compress the whole contents of the volatile buffer. The actual contents of the buffer, as well as the efficiency of the compression algorithm, determine how many bits will be in the compression result. If the buffer was only beginning to fill up, i.e. it only contained a single piece of configuration data before compression took place, the compression result may be even longer than the original piece of configuration data. However, already with two pieces of configuration data accumulated in the buffer the compression ratio (length of the compressed result in relation to the amount of uncompressed configuration data) will be more advantageous, and it will get even better the more pieces of configuration data had accumulated in the buffer.
We assume that there is a predetermined limit or threshold value, to which the length of the compressed result is compared. The limit or threshold value is slightly larger than the size of a record in a flash memory, so that when the length of the compressed result meets the limit or threshold, it will fill slightly more than one complete record in the flash memory. If the compression result was smaller in bytes than the limit or threshold value, it is used to overwrite (i.e. update) the immediately previously stored compression result in the flash memory according to block 203, and it remains there waiting to be in turn overwritten by the next compression result. If the compression result was large enough to fill at least a complete record, it is stored in the flash memory (i.e. it overwrites the immediately previous compression result but is thereafter “frozen”, and not subject to further over-writes) and the volatile buffer is cleared as in block 204. Next time after adding new configuration data and compressing, the write operation will target a new location in the flash memory.
At step 304 the whole contents of the volatile buffer are compressed. The compression result is written into flash memory at step 305, more particularly to a record of the flash memory pointed at by a flash write pointer. Writing to a record of a flash memory is most advantageously accomplished as a flash memory transaction, like the one explained in the patent application published as WO 01/31458 filed by the same applicant an incorporated herein by reference. A transaction is a collection of operations that must all succeed or all fail. Changing the configuration data of a router is a typical application of transactional nature, because if the routing application does not succeed in ensuring that the new configuration has been safely recorded in non-volatile memory, it must not take it into use at all. If the routing application operated according to configuration data stored only in volatile memory, and the non-volatile flash memory contained something else, a nastily timed operational failure might lead to recovering to different kind of operation than what was actually in use before the failure.
It is noted that due to the nature of flash memory, updating a record does not strictly speaking mean that data would be stored again in the exactly same memory location. As is shown in the other patent application mentioned above, updating a record involves a relatively large number of steps, during which the updated data is written into a new memory location and the old memory location is marked as dirty. A housekeeping routine of the flash memory arranges the use of memory locations, so that “dirty” locations return to use after a while. However, since the housekeeping operations are transparent to an application utilizing a flash memory, it is customary to speak about the records of a flash memory as logical memory locations, ignoring any dependence on any physically existing memory locations.
The transaction type routines of utilizing the flash memory automatically ensure that no unnecessary copies of the data are stored. The non-existence of unnecessary copies helps to keep the hardware requirements (the amount of installed flash memory) at a very reasonable level.
At step 306 a check is made, whether the amount of data written into the flash memory reached a certain threshold. If not, the method returns to step 301 with no changes in the flash write pointer. As a result, the next time a compression result is written into the flash memory, it will overwrite (i.e. update) the immediately previously written record.
If the length in bytes of the amount of data written into the flash memory had reached the threshold at step 306, the method proceeds to step 307 where the flash write pointer is advanced to point at a new record (in the same file as the previous record). At step 308 the volatile buffer is cleared, and the buffer write pointer is set to point at the very beginning of the freshly cleared buffer. Thereafter a return occurs to step 301.
It is not necessary to execute these method steps exactly in this order, as long as the same operational principle is preserved. For example, it would be possible to change step 303 from between steps 302 and 304 to before step 301. This would make it unnecessary to separately set the buffer write pointer to beginning at step 308, because immediately after clearing the buffer in step 308, setting the buffer write pointer to point to next free location would automatically make it point to the beginning.
At step 421 both the volatile buffer 401 and the flash file 402 are empty. At step 422 a piece of configuration data 404 is written into the volatile buffer. This causes the buffer write pointer to advance to the next free location. The whole contents of the volatile buffer are compressed, and the compression result 405 is written into the first record of the flash file. The compression result was shorter than a predetermined threshold, for which reason the flash write pointer is not advanced. Comparing to
Steps 423 and 424 are similar to step 422, with the newest piece of configuration data (406 at step 423 and 408 at step 424) being concatenated with the previously existing configuration data in the volatile buffer, and with each time the new compression result (407 at step 423 and 409 at step 424) updating the first record in the flash file. At step 425, after adding the piece of configuration data shown as 410, the length of the compression result reaches the threshold. Here this happens to coincide with the volatile buffer becoming full, but that is not a binding assumption; more probably the length of the compression result will reach the threshold already earlier, before the volatile buffer becomes full. It is typical to this embodiment of the invention that the threshold is bound to the length of the compressed result and not to the fill ratio or the remaining empty space of the volatile buffer before compression.
The compression result 411 that triggered the threshold condition is the last one to overwrite (update) the first record in the flash file. In conformity with step 307 in
According to an embodiment of the invention, it is not only the pure output of the compression algorithm that gets stored into the flash memory. The insert at the bottom right of
Scanning flash files may become actual in a power-on situation, which is seen in the state diagram of
At some stage the space reserved from the flash memory for the flash file will become full, which triggers regenerating the file according to state 504. Another criterion which is shown in
Number | Date | Country | Kind |
---|---|---|---|
20070520 | Jul 2007 | FI | national |
Number | Name | Date | Kind |
---|---|---|---|
5586285 | Hasbun et al. | Dec 1996 | A |
5860124 | Matthews et al. | Jan 1999 | A |
6202090 | DiSimone | Mar 2001 | B1 |
7376772 | Fallon | May 2008 | B2 |
7606954 | Brink et al. | Oct 2009 | B2 |
7676282 | Bosley | Mar 2010 | B2 |
20050071075 | Avery et al. | Mar 2005 | A1 |
20050210077 | Balakrishnan | Sep 2005 | A1 |
20050268341 | Ross | Dec 2005 | A1 |
20080228998 | Colecchia et al. | Sep 2008 | A1 |
Number | Date | Country |
---|---|---|
1 664 815 | Sep 2005 | CN |
1 357 701 | Oct 2003 | EP |
0131458 | May 2001 | WO |
Number | Date | Country | |
---|---|---|---|
20090013126 A1 | Jan 2009 | US |