JP2008191797A - File system - Google Patents
File system Download PDFInfo
- Publication number
- JP2008191797A JP2008191797A JP2007023656A JP2007023656A JP2008191797A JP 2008191797 A JP2008191797 A JP 2008191797A JP 2007023656 A JP2007023656 A JP 2007023656A JP 2007023656 A JP2007023656 A JP 2007023656A JP 2008191797 A JP2008191797 A JP 2008191797A
- Authority
- JP
- Japan
- Prior art keywords
- node
- storage means
- file
- address
- garbage collection
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Memory System (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本発明は、コンピュータやマイクロプロセッサが利用するファイルシステムに関する。 The present invention relates to a file system used by a computer or a microprocessor.
近年、デジタル家電などの組込機器用のOSにおいても、記憶装置を効率よく利用するためにファイルシステムを備える例が増えてきている。組込機器においてはフラッシュメモリを利用した記憶装置が多く用いられるが、フラッシュメモリは消去して再書込みできる回数が有限であるなどの特性を持つため、ファイルシステムにもその特性を考慮することが求められる。 In recent years, even in an OS for an embedded device such as a digital home appliance, an example in which a file system is provided in order to efficiently use a storage device is increasing. In embedded devices, a storage device using flash memory is often used. However, since flash memory has a characteristic that the number of times it can be erased and rewritten is finite, the characteristics of the file system may also be considered. Desired.
また携帯型機器では電源が不安定でファイルの書込み中に突然の電源断が起きるおそれがあるため、ファイルシステムには、そのような場合でも内容の整合性を回復する能力が求められる。 In addition, since the power source of the portable device is unstable and there is a possibility that a sudden power interruption may occur during the writing of the file, the file system is required to have the ability to restore the consistency of contents even in such a case.
それらの要求に応えるファイルシステムの例として非特許文献1に見られるjffs2がある。jffs2はこれらの要求に応えるために、ジャーナリングと、ウェアレベリングの2つの機能を持つ。
An example of a file system that meets these requirements is jffs2 found in Non-Patent
以下、この2つの機能の動作を説明する。 The operation of these two functions will be described below.
ジャーナリングとは、ファイルシステムがファイルの変更の履歴を記録する機能であり、突然の電源断があった後でファイルシステムの整合性を回復するために、この履歴を利用する。 Journaling is a function in which the file system records a history of file changes, and this history is used to restore the integrity of the file system after a sudden power failure.
jffs2におけるジャーナリングでは、ファイルそのものは記録せず、変更の履歴のみを記録する。履歴にはファイルの変更部分が差分として含まれており、ファイルを読み出す際には、そのファイルに関係した最も古い履歴を元に、それ以後の全ての履歴中の差分を上書きしていき、最終的に最新のファイルの内容を再現する。 Journaling in jffs2 does not record the file itself but records only the change history. The change part of the file is included as a difference in the history, and when reading the file, the oldest history related to the file is overwritten with the differences in all subsequent history, and the final Reproduce the contents of the latest file.
なお、jffs2では、管理を容易にするために履歴は数kバイト程度のサイズのノードに記録する。そのため、大きなファイルは、その内容をノードに記録できるサイズに分割し、便宜上、それらのノードの内容を追記していった結果として表現される。また、各ノードには管理情報が付加され、その管理情報にはノードのバージョン番号、ノードの属するファイル、ノードが保持する内容がファイル内で占める占有範囲に関する情報が含まれている。 In jffs2, the history is recorded in a node having a size of about several kilobytes for easy management. Therefore, a large file is expressed as a result of dividing its contents into sizes that can be recorded in the nodes and adding the contents of those nodes for convenience. Further, management information is added to each node, and the management information includes information regarding the version number of the node, the file to which the node belongs, and the occupation range occupied by the content held by the node in the file.
また、バージョン番号は全てのノードに振られた通し番号であり、各ノードの新旧の順序を判定するのに利用する。また、占有範囲の情報があることにより、ノードが不規則な順に読み出された場合や、ファイルの途中のみを変更した場合にも、正しくファイルの内容を再現できる。 The version number is a serial number assigned to all nodes, and is used to determine the new and old order of each node. In addition, since there is information on the occupied range, the contents of the file can be correctly reproduced even when the nodes are read in an irregular order or when only the middle of the file is changed.
また、複数のノードの間で占有範囲が重複し、より新しいノードで上書きされるために最終的なファイルに内容が全く反映されないノードは無効なノードと呼ぶ。反対に、一部のみでも最終的なファイルに内容が反映されるノードは有効なノードと呼ぶ。有効なノードであっても、その占有範囲の全てが最終的なファイルの内容に反映される場合と、占有範囲の一部のみが最終的なファイルの内容に反映され、それ以外の部分が無効となっている場合がある。 Also, a node whose occupation range overlaps among a plurality of nodes and is overwritten by a newer node and the content is not reflected in the final file is called an invalid node. Conversely, a node whose contents are reflected in the final file even if only a part is called an effective node. Even if it is a valid node, all of the occupied range is reflected in the final file contents, and only a part of the occupied range is reflected in the final file contents, and other parts are invalid It may be.
jffs2はノードの管理情報を読み出すために、毎回フラッシュメモリにアクセスする代わりにノードデータベースを使用する。jffs2は、ファイルシステムをマウントする際にフラッシュメモリ内を走査し、全てのノードの管理情報と、ノードのフラッシュメモリ上でのアドレスをノードデータベースに保存する。また、新しいノードを書き込むか、既存のノードを破棄した場合にもノードデータベースの内容を更新する。 jffs2 uses the node database instead of accessing the flash memory every time to read node management information. When jffs2 mounts the file system, it scans the flash memory, and stores management information of all nodes and addresses of the nodes in the flash memory in the node database. Also, the contents of the node database are updated when a new node is written or when an existing node is discarded.
次に、フラッシュメモリ用ファイルシステムに求められる、ウェアレベリング機能について説明する。 Next, the wear leveling function required for the flash memory file system will be described.
ウェアレベリングとは、フラッシュメモリ内のブロックの書き換え回数を均一にする機能であり、この機能が必要となる理由を説明するために、次にフラッシュメモリの書き換えの特性について説明する。 Wear leveling is a function for making the number of rewrites of blocks in the flash memory uniform. Next, in order to explain why this function is necessary, the characteristics of rewrite of the flash memory will be described.
フラッシュメモリは、書込みをする前に内容を消去する必要があり、この消去が出来る消去可能回数は1万〜100万回程度の有限の値である。フラッシュメモリは、使用上の利便性のために、その記憶領域を数k〜数十kバイト程度のブロックに分割し、このブロック単位で消去を行うことにより、特定のブロックの消去回数が上限に達して使用不可となっても、他の消去回数の少ないブロックを引き続き使用可能としている。なお、ブロックの消去回数の上限は統計的にしか分からず、特定のブロックの残りの書き換え可能回数は、実際に使用不可となるまで知ることが出来ない。 The flash memory needs to have its contents erased before writing, and the number of erasable times that can be erased is a finite value of about 10,000 to 1,000,000 times. For convenience of use, flash memory is divided into blocks of several k to several tens of kbytes, and erasing is performed in units of blocks, so that the number of erasures of a specific block is limited to the upper limit. Even if it reaches the point where it cannot be used, other blocks with a smaller number of erasures can still be used. Note that the upper limit of the number of block erasures is known only statistically, and the remaining number of rewritable times for a specific block cannot be known until it is actually disabled.
フラッシュメモリは上記のような特性を持つため、もし特定のブロックに書き換えが集中すると、そのブロックは他のブロックよりも先に使用不可となり、フラッシュメモリ全体では利用可能な容量が減ってしまう。そのため、フラッシュメモリを搭載した製品が寿命となるまでの間、フラッシュメモリの容量を一定以上に保つためには、ウェアレベリングによってできるだけ各ブロックの書き換え回数を均一にすることが重要となる。 Since the flash memory has the characteristics as described above, if rewriting concentrates on a specific block, that block becomes unusable before other blocks, and the usable capacity of the entire flash memory is reduced. Therefore, in order to keep the capacity of the flash memory at a certain level or more until the product equipped with the flash memory reaches the end of its life, it is important to make the number of rewrites of each block as uniform as possible by wear leveling.
jffs2におけるウェアレベリングは、tailポインタとheadポインタによって書き込みと有効なノードのアドレスを管理することによって行う。jffs2において、tailポインタは、次にノードを書き込むべきフラッシュメモリ上のアドレスを保持しており、headポインタは最も古い有効なノードのあるアドレスを保持している。次に図2、および図3を用いて、このtailポインタとheadポインタを使用したノードの書き込みとガベージコレクション処理の動作を説明する。 Wear leveling in jffs2 is performed by managing writing and valid node addresses using the tail pointer and head pointer. In jffs2, the tail pointer holds the address on the flash memory where the node is to be written next, and the head pointer holds the address of the oldest valid node. Next, using FIG. 2 and FIG. 3, the operation of node writing and garbage collection processing using the tail pointer and the head pointer will be described.
図2は、jffs2によって使用中のフラッシュメモリ内のノードの配置の例を示す模式図であり、(a)はノードの配置の一例であり、(b)は新しいノードを書き込んだ直後のノードの配置の一例であり、(c)はtailポインタを更新した後のノードの配置の一例であり、(d)はノードの配置の一例であり、1はフラッシュメモリであり、11はフラッシュメモリの先頭であり、12はフラッシュメモリの末尾であり、13はheadポインタが指すアドレスであり、14はtailポインタが指すアドレスであり、101は有効なノードが存在しない範囲であり、102は有効なノードが存在する範囲であり、51は新しく書き込んだノードである。
FIG. 2 is a schematic diagram showing an example of node arrangement in the flash memory being used by jffs2, (a) is an example of node arrangement, and (b) is the node immediately after writing a new node. (C) is an example of an arrangement of nodes after updating the tail pointer, (d) is an example of an arrangement of nodes, 1 is a flash memory, and 11 is the head of the flash memory. 12 is the end of the flash memory, 13 is the address pointed to by the head pointer, 14 is the address pointed to by the tail pointer, 101 is a range where there is no valid node, and 102 is the valid node An
図3は、ガベージコレクションの際のノードの配置の変化を示す模式図であり、(a)はガベージコレクション処理の前の配置の一例であり、(b)はガベージコレクション処理によってノードを破棄した後の配置の一例であり、(c)はガベージコレクション処理によってノードを変更して書き写した後の配置の一例であり、(d)はガベージコレクション処理によってノードを変更せずに書き写した後の配置の一例であり、1はフラッシュメモリであり、11はフラッシュメモリの先頭であり、12はフラッシュメモリの末尾であり、13はheadポインタが指すアドレスであり、14はtailポインタが指すアドレスであり、101は有効なノードが存在しない範囲であり、102は有効なノードが存在する範囲であり、52aはノードであり、52bはノードであり、52cはノードである。 FIG. 3 is a schematic diagram showing changes in the arrangement of nodes at the time of garbage collection. (A) is an example of arrangement before the garbage collection process, and (b) is after the node is discarded by the garbage collection process. (C) is an example of the arrangement after changing the node by garbage collection and copied, (d) is the arrangement after copying without changing the node by the garbage collection process. For example, 1 is the flash memory, 11 is the head of the flash memory, 12 is the end of the flash memory, 13 is the address pointed to by the head pointer, 14 is the address pointed to by the tail pointer, 101 Is a range where there is no valid node, 102 is a range where there is a valid node, 52a is a node, and 52b is no In it, 52c is a node.
まず図2を用いて、tailポインタの使用法を説明する。フラッシュメモリ1内のノードの配置は一例として図2(a)に示すようになる。このフラッシュメモリ1にノードを書き込む際は、tailポインタの指すアドレス14に図2(b)に示すようにノード51として書き込む。書き込み後、図2(c)に示すように、tailポインタの内容をノード51の次のアドレスに更新し、これにより、ノード51は有効なノードとなる。
First, using the tail pointer will be described with reference to FIG. As an example, the arrangement of nodes in the
ノードの書き込みを繰り返すとtailポインタの指すアドレス14はフラッシュメモリ1の末尾12に近づくが、末尾12に達した後はtailポインタの指すアドレス14をフラッシュメモリ1の先頭11に復帰してファイルシステムの動作を続ける。図2(d)に示した例では、tailポインタがフラッシュメモリ1の先頭11に復帰した後もノードの書込みを続け、そのため、有効なノードが存在する範囲102は先頭11に近い側と末尾12に近い側に分かれている。
When node writing is repeated, the
次に図3を用いて、ガベージコレクションの際のheadポインタの使用法を説明する。 Next, the usage of the head pointer at the time of garbage collection will be described with reference to FIG.
図3(a)はガベージコレクション処理前のノードの配置の一例である。有効なノードが存在しない範囲101は消去して書込みのために再利用出来る領域であるが、フラッシュメモリ1へ書込みを続けるとこの範囲は次第に狭まり、新しいノードの書込みが出来なくなる。
FIG. 3A shows an example of the arrangement of nodes before the garbage collection process. The
有効なノードが存在する範囲102には無効となったノードや一部分が無効となったノードが含まれ、ガベージコレクション処理は次の手順で、これらの無効となったノードや無効となった部分を集め、書込みのための領域を増やす。ガベージコレクション処理は、tailポインタの指すアドレス14とheadポインタの指すアドレス13の差が一定以下になることをきっかけに始める。
The
ガベージコレクション処理では、jffs2はheadポインタの指すアドレス13のノード52aを調べ、ノード52aが無効であるか、または無効な部分を持つかによって次の処理を行う。
In the garbage collection process, jffs2 examines the
ノード52aが無効なノードである場合には、ノード52aを破棄し、単にheadポインタの指すアドレス13をノード52aの次のアドレスに更新する。この処理の後のノードの配置は図3(b)のようになり、ノード52aのサイズだけ、有効なノードが存在しない範囲101が広がる。
If the
ノード52aが無効な部分を持つノードである場合には、ノード52aの内容を最終的なファイルの内容で上書き更新し、tailポインタの指すアドレス14に新しいノード52bとして書き込む。この後、headポインタの指すアドレス13をノード52aの次のアドレスに更新する。この処理の後のノードの配置は図3(c)のようになり、有効なノードが存在しない範囲101の大きさは変わらないが、ノード52bの内容は全て最終的なファイルの内容に反映される有効なノードになり、反対にノード52bと占有範囲が重複するノードは、無効なノードとなるか、または無効な部分を持ったノードとなり、無効なノードとなった場合は以降のガベージコレクションにより破棄される。
If the
なお、ノード52bがノードのサイズの上限に収まるならば、ノード52bの占有範囲を広げて上書き更新することもできる。この場合、ノード52bと占有範囲が重複するノードが無効となる機会が増える。
If the
ノード52aが、無効な部分のない有効なノードである場合には、ノード52aを単にtailポインタの指すアドレス14に新しいノード52cとして書き写し、headポインタの指すアドレス13をノード52aの次のアドレスに更新する。この処理の後のノードの配置は図3(d)のようになる。
When the
上記のガベージコレクション処理は所望の空き容量が得られるまで続けられる。 The above garbage collection process is continued until a desired free space is obtained.
上記で、無効な部分のないノードは、ガベージコレクションの際に内容を変更せずに書き写されるだけのノードであり、以下、変更不要のノードと呼ぶことにする。また、無効な部分を持つノードはガベージコレクションの際に内容の変更が必要であり、破棄される無効なノードと合わせて、以下、変更必要なノードと呼ぶことにする。 In the above, a node having no invalid part is a node that is simply copied without changing the contents at the time of garbage collection, and is hereinafter referred to as a node that does not need to be changed. Further, a node having an invalid part needs to be changed in garbage collection, and together with an invalid node to be discarded, it is hereinafter referred to as a node that needs to be changed.
上記のガベージコレクション処理の際に、headポインタの指すアドレス13がフラッシュメモリ1の末尾12に達したならば、headポインタの指すアドレス13をフラッシュメモリ1の先頭11に復帰してファイルシステムの動作を続ける。
If the
上記のように、有効なノードの配置をheadポインタで管理し、フラッシュメモリへの書き込みはtailポインタで管理し、このtailポインタがフラッシュメモリのアドレスの全範囲を走査して行くため、フラッシュメモリの全てのアドレスへの書き込み回数は均一になり、ウェアレベリングを実現できる。 As described above, the arrangement of valid nodes is managed by the head pointer, writing to the flash memory is managed by the tail pointer, and this tail pointer scans the entire range of addresses in the flash memory. The number of writes to all addresses is uniform, and wear leveling can be realized.
なお、ウェアレベリングの実現方法としては、jffs2のようにファイルシステムにその機能を持たせる方法だけでなく、特許文献1に見られるように、メモリチップにハードウェア的にウェアレベリング機能を持たせる方法や、非特許文献2に見られるように、ファイルシステムよりも下位のデバイスドライバで実現する方法もある。
In addition, as a method of realizing wear leveling, not only a method of giving a file system its function as in jffs2, but also a method of giving a memory chip a hardware leveling function as seen in
従来例であるjffs2においては、ガベージコレクションの際に、内容を変更する必要の無い変更不要のノードはフラッシュメモリ内を移動するだけであり、ガベージコレクションの目的である容量の確保には寄与しない。特に、変更頻度の低いファイルがファイルシステム中に多数あると、ガベージコレクションの際に変更不要なノードも多数になり、ガベージコレクション処理は所望の空き容量を確保するために繰り返し行われ、処理時間が増え、また書き換え回数も増える。このため、フラッシュメモリの寿命を縮めてしまうことにもなる。 In jffs2, which is a conventional example, at the time of garbage collection, nodes that do not need to be changed only move in the flash memory, and do not contribute to securing the capacity that is the purpose of garbage collection. In particular, if there are many files with low frequency in the file system, there are many nodes that do not need to be changed during garbage collection, and the garbage collection process is repeated to secure the desired free space, and the processing time Increases and the number of rewrites also increases. This shortens the lifetime of the flash memory.
本発明の課題は、jff2のガベージコレクション処理の際に発生する無駄なノードの移動を減らし、これによりガベージコレクション処理動作を速くすることと、フラッシュメモリの寿命を延ばすことが可能なファイルシステムを得ることにある。 An object of the present invention is to obtain a file system capable of reducing unnecessary node movement that occurs during jff2 garbage collection processing, thereby speeding up the garbage collection processing operation and extending the life of the flash memory. There is.
上記課題を解決するため、headポインタとtailポインタの指すアドレスがフラッシュメモリの末尾に達した場合にフラッシュメモリの先頭アドレスに最も近い変更必要なノードのアドレスへと復帰する。 To solve the above problem, when the address pointed to by the head pointer and tail pointer reaches the end of the flash memory, the address of the node that needs to be changed closest to the head address of the flash memory is restored.
本発明によれば、ガベージコレクションの際に変更不要なノードのうち、フラッシュメモリ先頭にあるものは、ガベージコレクション処理の対象とならない。また、フラッシュメモリ先頭から変更不要なノードが連続している連続領域内のノードもガベージコレクション処理の対象とならない。よって、ガベージコレクションの対象を減らすことができるため、処理動作を速くすることと、フラッシュメモリの寿命を延ばすことが可能となる。 According to the present invention, among the nodes that do not need to be changed at the time of garbage collection, those at the head of the flash memory are not subjected to garbage collection processing. Also, nodes in a continuous area in which nodes that do not need to be changed from the beginning of the flash memory are not subject to garbage collection processing. Therefore, since the number of garbage collection targets can be reduced, it is possible to speed up the processing operation and extend the life of the flash memory.
なお、上記連続領域内のノードは、ノードの変更が必要となるまでフラッシュメモリ上で位置を変えない。また連続領域の外にある変更不要なノードも、ガベージコレクションの際に上記の連続領域に接する位置に書き写されれば連続領域に組み込まれ、次回以降のガベージコレクション処理の対象から外れる。よって、ガベージコレクションを繰り返すうちに変更不要なノードは上記の連続領域に集められ、まとめてガベージコレクションの対象から外れるため、本発明の効果がいっそう高くなる。 Note that the position of the nodes in the continuous area does not change on the flash memory until the node needs to be changed. Further, nodes that do not need to be changed outside the continuous area are incorporated into the continuous area if they are copied at the position in contact with the continuous area at the time of garbage collection, and are excluded from the next garbage collection processing target. Therefore, nodes that do not need to be changed while garbage collection is repeated are collected in the above-described continuous area, and are collectively excluded from the object of garbage collection. Therefore, the effect of the present invention is further enhanced.
なお、いったん連続領域に集められたノードであっても、そのノードが属するファイルが変更され、ノードの変更が必要になれば、次回にheadポインタとtailポインタが復帰する際にそのノードのアドレスに復帰するため、再びガベージコレクションの対象となる。その際、一時的に連続領域が減るため、ガベージコレクションの対象が増え、本発明の効果が減じられるが、前記したように、ガベージコレクションが繰り返されるうちに変更不要なノードが再び連続領域に集まる。 Note that even if a node is once collected in a continuous area, if the file to which the node belongs is changed and the node needs to be changed, the next time the head pointer and tail pointer are restored, the address of that node is set. In order to return, it is again subject to garbage collection. At that time, since the continuous area temporarily decreases, the number of garbage collection targets increases and the effect of the present invention is reduced. As described above, nodes that do not need to be changed again gather in the continuous area while the garbage collection is repeated. .
以上を繰り返すうちに、変更頻度の低いファイルに属するノードはフラッシュメモリの先頭に近い位置に配置され、変更頻度の高いファイルに属するノードはフラッシュメモリの末尾に近い位置に配置され、変更頻度の低いファイルに変更があった場合でも、ガベージコレクションの際に影響が及ぶノードを最小化するように自然と最適化される。 As the above is repeated, nodes belonging to files with a low change frequency are placed near the top of the flash memory, and nodes belonging to files with a high change frequency are placed near the end of the flash memory, and the change frequency is low Even if the file changes, it is naturally optimized to minimize the nodes that are affected during garbage collection.
本発明により、ガベージコレクションによる書き換え処理はフラッシュメモリの末尾に近い位置に集中し、これはウェアレベリングの目的に反する動作であるが、特許文献1や非特許文献2に見られる技術を併用することでウェアレベリングを行うことが出来る。
According to the present invention, the rewrite processing by garbage collection is concentrated at a position near the end of the flash memory, which is an operation contrary to the purpose of wear leveling, but the technique found in
以下において、本実施の形態を図面を用いて説明する。なお、本発明は、図示例に限定されるものではない。 Hereinafter, the present embodiment will be described with reference to the drawings. The present invention is not limited to the illustrated example.
まず、図1を用いて、本実施の形態に係るファイルシステムの構成を説明する。 First, the configuration of the file system according to the present embodiment will be described with reference to FIG.
フラッシュメモリ1は、デバイスドライバ2から特定のプロトコルでアドレスとデータを指定されることにより、指定されたアドレスにデータを書き込み、または読み出しをする。デバイスドライバ2はフラッシュメモリ1に直接読み書きするソフトウェアコンポーネントであり、フラッシュメモリの品種ごとの違いを吸収して、統一したインターフェースをファイルシステム3に提供する。ファイルシステム3はデバイスドライバ2の提供するインターフェースを利用して、ノードをフラッシュメモリ1へ読み書きする。アプリケーション4は、ファイルシステム3に対してファイルの読み書きを要求する。
The
ファイルシステム3は、ファイルシステム制御部31とノードデータベース32とheadポインタ33とtailポインタ34と復帰処理用ポインタ35とからなる。
The
ノードデータベース32は、フラッシュメモリ1内にある全てのノードの管理情報と、そのノードのフラッシュメモリ1内でのアドレスを保持しており、その初期値は、本ファイルシステムをマウントする際にファイルシステム制御部31がフラッシュメモリ1内の全ノードを走査することで得る。
The node database 32 holds the management information of all the nodes in the
ノードの管理情報には、少なくともノードのバージョン番号と、ノードの属するファイル名と、ノードが保持する内容がファイル内で占める占有範囲に関する情報が含まれており、ファイルシステム制御部31は、ファイルを読み出す際にノードデータベース32を参照することで、そのファイルを再現するのに必要な全てのノードを特定し、そのノードの格納されたアドレスを得られる。
The node management information includes at least the version number of the node, the file name to which the node belongs, and information about the occupation range occupied by the content held by the node in the file. The file
またファイルシステム制御部31は、ノードデータベース32を参照することで、複数のノードの占有範囲が重複していることも検出でき、重複した範囲の内容としてどちらのノードの内容を使用すべきかをノードのバージョン番号から判定できる。
Further, the file
headポインタ33はフラッシュメモリ1内でガベージコレクションを開始するアドレスを保持しており、tailポインタ34は次にノードを書き込むべきフラッシュメモリ1内のアドレスを保持している。tailポインタ34の初期値は、ノードデータベース32が初期値を得た時点で、ノードデータベース32中で最も新しいノードの、次のアドレスを設定する。headポインタ33の初期値は、tailポインタ34の初期値が決定した時点で、tailポインタ34の示すアドレスからフラッシュメモリ内の末尾に向けてノードを走査していき、初めて見つかった有効なノードの次のアドレスを設定する。
The
復帰処理用ポインタ35は、headポインタ33とtailポインタ34の指すアドレスがフラッシュメモリ1の末尾に達した場合に、headポインタ33とtailポインタ34の内容を適切なアドレスへと復帰させる復帰処理のために使用する。
The
次に図4を用いて、本実施の形態に係るファイルシステムの書き込み動作を説明する。 Next, the write operation of the file system according to the present embodiment will be described with reference to FIG.
図4(a)の6はアプリケーション4が書込みを要求したファイルであり、アプリケーション4は書き込み要求とともにファイル6をファイルシステム制御部31に送る。ファイルシステム制御部31は、ファイル6の内容をノードに格納可能なサイズに分割し、管理情報7を付加して図4(b)に示すノード53a、ノード53b、ノード53cを生成する。次に、ファイルシステム制御部31は各ノードをデバイスドライバ2に送り、書込みを要求する。デバイスドライバ2の書込み処理の結果、ノード53a、ノード53b、ノード53cは、例えば図5(c)に示す配置のように、フラッシュメモリ1上に配置される。
4 in FIG. 4A is a file requested by the application 4 to write, and the application 4 sends the
また、ファイルシステム制御部31は、前記生成したノードの管理情報7と、ノードを書き込んだアドレスをノードデータベース32に登録し、tailポインタ34の内容を、最後に書き込んだノードの次のアドレスへと更新する。
In addition, the file
以上の動作で本実施の形態に係るファイルシステム3はファイルを書き込む。
With the above operation, the
次に図5を用いて、本実施の形態に係るファイルシステムが既存のファイルを書き換える動作を説明する。 Next, the operation of rewriting an existing file by the file system according to the present embodiment will be described with reference to FIG.
アプリケーション4はファイル6の一部の書き換えをファイルシステム制御部31に要求し、変更部分61を書き換え要求とともにファイルシステム制御部31に送る。ファイルシステム制御部31は、変更部分61をノードに格納可能なサイズに分割し、管理情報7を付加して図5(b)に示すノード53dを生成する。次に、ファイルシステム制御部31はノード53dをデバイスドライバ2に送り、書込みを要求する。
The application 4 requests the file
デバイスドライバ2の書込み処理の結果、ノード53dは、例えば図6(c)に示す配置のように、フラッシュメモリ1上に配置される。
As a result of the writing process of the
また、ファイルシステム制御部31は、前記生成したノードの管理情報7と、ノードを書き込んだアドレスをノードデータベース32に登録し、tailポインタ34の内容を、最後に書き込んだノードの次のアドレスへと更新する。
In addition, the file
以上の動作で本実施の形態に係るファイルシステム3はファイルを書き換える。
With the above operation, the
次に図6を用いて、本実施の形態に係るファイルシステムがファイルを読み出す動作を説明する。 Next, an operation of reading a file by the file system according to the present embodiment will be described with reference to FIG.
まず、アプリケーション4がファイル6の読み出し要求をファイルシステム制御部31に送る。ファイルシステム制御部31はノードデータベース32を参照し、指定されたファイル6に属するノード53a、ノード53b、ノード53c、ノード53dを特定し、これらのノードのバージョン番号と、ノードの占有範囲と、ノードのフラッシュメモリ1内でのアドレスを得る。
First, the application 4 sends a read request for the
次にファイルシステム制御部31は、デバイスドライバ2を使って、フラッシュメモリ1内に図6(a)の例のように配置されたノード53a、ノード53b、ノード53c、ノード53dを読み出し、各ノードのバージョン番号の古い順に各ノードが保持する内容を占有範囲に配置していく。この過程で、占有範囲が重複しているノードがあれば、バージョン番号の古いノードの重複した部分は、新しいノードの内容で上書きされる。図6(b)の例では、ノード53bの保持する内容の一部と、ノード53cの保持する内容の全てが、ノード53dの保持する内容によって上書きされ、結果として、図6(c)の内容のファイル6を得る。
Next, using the
なお、上記のノード53cの例のように、最終的なファイルの内容に反映されない内容しか持たないノードについては、フラッシュメモリ1から読み出す動作を省略しても良い。
Note that the operation of reading from the
ファイルシステム制御部31は、上記によって得られたファイル6をアプリケーション4に渡し、読み出し動作は終了する。
The file
次に図7と図8を用いて、本実施の形態に係るファイルシステムのガベージコレクション処理の動作を説明する。 Next, the operation of the garbage collection process of the file system according to this embodiment will be described with reference to FIGS.
図7において(a)はガベージコレクション開始前のフラッシュメモリ1内のノードの配置を示しており、tailポインタの指すアドレス14からheadポインタの指すアドレス13までの間の、有効なノードの無い範囲101が一定以下になると、ファイルシステム制御部31は図8のフローチャートに示す手順でガベージコレクション処理を始める。
FIG. 7A shows the arrangement of nodes in the
まず、図8の処理S11において、ファイルシステム制御部31はノードデータベース32を参照し、headポインタ33の指すノード54aが属するファイルを特定し、また、特定したファイルに属する全てのノードの管理情報7を取得し、次に処理S12に移る。
First, in process S11 of FIG. 8, the file
次に、処理S12において、処理S11で取得したノードの管理情報7からノード54aの内容を判断し、ノード54aが無効であるならば処理S13に分岐し、ノード54aの内容に無効な部分があるならば処理S14に分岐し、ノード54aの内容が全て有効であれば、処理S16に分岐する。
Next, in process S12, the contents of the
処理S13では、なにもせずに処理S17に移る。 In process S13, the process proceeds to process S17 without doing anything.
処理S14では、ノード54aがファイル内で占有する範囲についてファイルの読み出し処理を行い、前記占有範囲についてファイルの最終的な内容を取得し、次に処理S15に移る。なお、前記占有範囲は、ノード54aのサイズを越えてノードに収まる最大サイズまで拡張して、ファイルの最終的な内容を取得しても良い。占有範囲を拡張することにより、占有範囲の重複した他のノードを無効とする機会が増えるためである。
In the process S14, the file reading process is performed for the range occupied by the
処理S15では、処理S14で取得した内容でノード54bを生成し、tailポインタの指すアドレス14に書き込み、ノードデータベース32にノード54bを登録し、tailポインタ34を更新して次に処理S17に移る。
In the process S15, the
処理S16では、ノード54aと同じ内容のノード54cを生成し、tailポインタの指すアドレス14に書き込み、ノードデータベース32にノード54cを登録し、tailポインタ34を更新して、次に処理S17に移る。
In the process S16, a node 54c having the same contents as the
処理S17では、headポインタ33をノード54aの次のアドレスへ更新し、ノードデータベース32からノード54aを削除し。処理S18に移る。処理S17が終了した時点で、フラッシュメモリ1内のノードの配置は、処理S13を経由した場合には図7(b)の例のようになり、処理S14を経由した場合には図7(c)の例のようになり、処理S16を経由した場合には図7(d)の例のようになる。
In the process S17, the
処理S18では、headポインタ33とtailポインタ34の差を確認し、所定の値以上であれば終了する。所定の値に満たない場合は処理S11に移る。
In the process S18, the difference between the
本実施の形態においては、上記の手順により、ガベージコレクション処理を行う。 In the present embodiment, the garbage collection process is performed according to the above procedure.
次に図9と図10を用いて、本実施の形態に係るファイルシステムでのheadポインタ33とtailポインタ34の復帰処理の動作を説明する。
Next, with reference to FIGS. 9 and 10, the operation of the return processing of the
上記のガベージコレクション処理中にheadポインタの指すアドレス13がフラッシュメモリ1の末尾12に達した場合、ファイルシステム制御部31は次回のガベージコレクション処理を行うために、図10のフローチャートに示す手順で、headポインタ33を適切なアドレスに復帰する。
When the
まず、図10の処理S21において、復帰処理用ポインタ35の内容をフラッシュメモリ1の先頭11とし、処理S22に移る。
First, in process S21 of FIG. 10, the content of the
処理S22では、復帰処理用ポインタ35の指すノードが属するファイルを、ノードデータベース32を参照して特定し、また、特定したファイルに属する全てのノードの管理情報7を取得し、処理S23に移る。
In the process S22, the file to which the node pointed to by the
処理S23では、処理S22で取得した管理情報から復帰処理用ポインタ35の指すノードの内容を判断し、復帰処理用ポインタ35の指すノードの内容が全て有効な変更不要なノードであれば処理S24に分岐し、復帰処理用ポインタ35の指すノードが無効か、または内容に無効な部分がある変更必要なノードならば処理S25に分岐する。
In the process S23, the contents of the node pointed to by the
処理S24では、復帰処理用ポインタ35の内容を、復帰処理用ポインタ35の指すノードの次のアドレスに更新し、処理S22に移る。
In process S24, the contents of the
処理S25では、復帰処理用ポインタ35の内容をheadポインタ33にコピーし、終了する。
In step S25, the contents of the
図9の例では、上記の手順の結果、復帰処理用ポインタ35の内容は変更必要なノード57のアドレス15となり、headポインタ33もアドレス15に復帰する。
In the example of FIG. 9, as a result of the above procedure, the contents of the
また、tailポインタの指すアドレス14がフラッシュメモリ1の末尾12に達した場合には、tailポインタ34はheadポインタ33と同じアドレス15に復帰させる。これは、復帰処理用ポインタ35の内容を破棄せずに保持しておき、tailポインタ34を復帰する際に利用することで実現できる。
When the
図9において、従来例であるjffs2では、headポインタおよび、tailポインタの指すアドレスはフラッシュメモリ1の全範囲を移動し、フラッシュメモリ1内の全てのノードがガベージコレクション処理の対象となるが、本実施の形態では、headポインタおよび、tailポインタの指すアドレスは範囲103の間を移動し、範囲103の外にあるノードはガベージコレクション処理の対象とならない。
In FIG. 9, in jffs2, which is a conventional example, the addresses pointed to by the head pointer and tail pointer move in the entire range of the
本発明では、範囲103の外にある、ガベージコレクション処理の際に内容を変更せずに無駄に移動するだけのノードをガベージコレクション処理の対象から外すことで、処理時間を短縮し、また無駄な書き換えでフラッシュメモリの寿命を短くすることを防ぐことができる。
In the present invention, processing time is shortened and wasteful by removing nodes that are out of the
本発明は、特にフラッシュメモリを媒体として利用したファイルシステムにおいて有効であるが、フラッシュメモリ以外の媒体にも利用可能である。例えば光ディスクメディアでは、書き換え動作よりも追記動作によってデータを書き込む方が速度などの点で好ましいが、このような媒体に本発明を応用すれば、書き換え動作が少なくなり、高速化が期待できる。 The present invention is particularly effective in a file system using a flash memory as a medium, but can also be used in a medium other than the flash memory. For example, in optical disk media, it is preferable in terms of speed to write data by a write-once operation rather than a rewrite operation. However, if the present invention is applied to such a medium, the rewrite operation is reduced and high speed can be expected.
1…フラッシュメモリ、11…先頭、12 …末尾、13…headポインタの指すアドレス、
14 …tailポインタの指すアドレス、15…アドレス、101…有効なノードの無い範囲102…有効なノードの有る範囲、103…範囲、2…デバイスドライバ、3…ファイルシステム、31…ファイルシステム制御部、32…ノードデータベース、33…headポインタ、34…tailポインタ、35…復帰処理用ポインタ、4…アプリケーション、51…ノード、52a…ノード、52b…ノード、52c…ノード、53a…ノード、53b…ノード、53c…ノード、53d…ノード、54a…ノード、54b…ノード、54c…ノード、55…変更不要なノード、56…変更不要なノード、57…変更必要なノード、6… ファイル、61…変更部分、7…管理情報
1 ... flash memory, 11 ... start, 12 ... end, 13 ... address pointed to by head pointer,
14 ... address pointed to by tail pointer, 15 ... address, 101 ... range without
Claims (5)
ノードを書き込む前記一時記憶手段上のアドレスを保持する書き込み位置記憶手段と、
ファイルシステムのガベージコレクション処理の開始アドレスを保持するガベージコレクション開始位置記憶手段と、
ファイル変更を要求された場合には、前記ファイルの変更した差分を内容とするノードを生成し、前記書き込み位置記憶手段に記憶されたアドレスに、生成した前記ノードを書き込み、前記書き込み位置記憶手段の内容を、書き込んだ前記ノードの次のアドレスに更新するファイル変更処理を行い、
ファイルの読み出しを要求された場合には、前記一時記憶手段から前記ノードを読み出し、読み出した前記ノードの内容である変更の差分を累積し、前記変更の差分を累積した結果をファイルの内容として返すファイル読み出し処理を行い、
前記書き込み位置記憶手段とガベージコレクション開始位置記憶手段との差が所定の値以下になった場合にはガベージコレクション処理を行なう制御手段とを備え、
前記制御手段は、ガベージコレクションを行う際に、
前記ガベージコレクション開始位置記憶手段の内容が前記一時記憶手段の末尾のアドレスに達した場合の復帰処理として、前記一時記憶手段に前記一時記憶手段の先頭のアドレスを設定して、前記一時記憶手段の内容であるアドレスのノードを確認し、
確認した前記ノードの内容が全て有効である場合には、
前記一時記憶手段の内容を前記ノードの次のアドレスに更新した後に、再度前記ノードを確認することを特徴とするファイルシステム。 Temporary storage means;
Write position storage means for holding an address on the temporary storage means for writing a node;
A garbage collection start position storage means for holding a start address of garbage collection processing of the file system;
When a file change is requested, a node containing the changed difference of the file is generated, the generated node is written to the address stored in the write position storage means, and the write position storage means Perform file change processing to update the contents to the next address of the written node,
When reading of the file is requested, the node is read from the temporary storage means, the difference of the change that is the content of the read node is accumulated, and the result of accumulating the difference of the change is returned as the content of the file. Perform file read processing,
Control means for performing a garbage collection process when the difference between the writing position storage means and the garbage collection start position storage means is a predetermined value or less,
The control means, when performing garbage collection,
As a return process when the content of the garbage collection start position storage means reaches the end address of the temporary storage means, the head address of the temporary storage means is set in the temporary storage means, and the temporary storage means Check the node of the address that is the content,
If all the contents of the confirmed node are valid,
A file system for checking the node again after updating the contents of the temporary storage means to the next address of the node.
ノードを書き込む前記一時記憶手段上のアドレスを保持する書き込み位置記憶手段と、
ファイルシステムのガベージコレクション処理の開始アドレスを保持するガベージコレクション開始位置記憶手段と、
ファイル変更を要求された場合には、前記ファイルの変更した差分を内容とするノードを生成し、前記書き込み位置記憶手段に記憶されたアドレスに、生成した前記ノードを書き込み、前記書き込み位置記憶手段の内容を、書き込んだ前記ノードの次のアドレスに更新するファイル変更処理を行い、
ファイルの読み出しを要求された場合には、前記一時記憶手段から前記ノードを読み出し、読み出した前記ノードの内容である変更の差分を累積し、前記変更の差分を累積した結果をファイルの内容として返すファイル読み出し処理を行い、
前記書き込み位置記憶手段とガベージコレクション開始位置記憶手段との差が所定の値以下になった場合にはガベージコレクション処理を行なう制御手段とを備え、
前記制御手段は、ガベージコレクションを行う際に、
前記ガベージコレクション開始位置記憶手段の内容が前記一時記憶手段の末尾のアドレスに達した場合の復帰処理として、前記一時記憶手段に前記一時記憶手段の先頭のアドレスを設定して、前記一時記憶手段の内容であるアドレスのノードを確認し、
確認した前記ノードの内容が無効、又は一部無効である場合には、
前記一時記憶手段の内容を前記ガベージコレクション開始位置記憶手段にコピーすることを特徴とするファイルシステム。 Temporary storage means;
Write position storage means for holding an address on the temporary storage means for writing a node;
A garbage collection start position storage means for holding a start address of garbage collection processing of the file system;
When a file change is requested, a node having the changed difference of the file as a content is generated, the generated node is written at an address stored in the write position storage means, and the write position storage means Perform file change processing to update the contents to the next address of the written node,
When reading of the file is requested, the node is read from the temporary storage means, the difference of the change that is the content of the read node is accumulated, and the result of accumulating the difference of the change is returned as the content of the file. Perform file read processing,
Control means for performing a garbage collection process when the difference between the writing position storage means and the garbage collection start position storage means is a predetermined value or less,
The control means, when performing garbage collection,
As a return process when the content of the garbage collection start position storage means reaches the end address of the temporary storage means, the start address of the temporary storage means is set in the temporary storage means, and the temporary storage means Check the node of the address that is the content,
When the content of the confirmed node is invalid or partially invalid,
A file system for copying the contents of the temporary storage means to the garbage collection start position storage means.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2007023656A JP2008191797A (en) | 2007-02-02 | 2007-02-02 | File system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2007023656A JP2008191797A (en) | 2007-02-02 | 2007-02-02 | File system |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2008191797A true JP2008191797A (en) | 2008-08-21 |
Family
ID=39751863
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2007023656A Pending JP2008191797A (en) | 2007-02-02 | 2007-02-02 | File system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2008191797A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8244967B2 (en) | 2009-02-12 | 2012-08-14 | Sumitomo Electric Industries, Ltd. | Method to rewrite flash memory with exclusively activated two blocks and optical transceiver implementing controller performing the same |
JP2016505180A (en) * | 2013-01-30 | 2016-02-18 | ヒューレット−パッカード デベロップメント カンパニー エル.ピー.Hewlett‐Packard Development Company, L.P. | Non-volatile memory writing mechanism |
US10482008B2 (en) | 2015-01-23 | 2019-11-19 | Hewlett Packard Enterprise Development Lp | Aligned variable reclamation |
-
2007
- 2007-02-02 JP JP2007023656A patent/JP2008191797A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8244967B2 (en) | 2009-02-12 | 2012-08-14 | Sumitomo Electric Industries, Ltd. | Method to rewrite flash memory with exclusively activated two blocks and optical transceiver implementing controller performing the same |
JP2016505180A (en) * | 2013-01-30 | 2016-02-18 | ヒューレット−パッカード デベロップメント カンパニー エル.ピー.Hewlett‐Packard Development Company, L.P. | Non-volatile memory writing mechanism |
US10482008B2 (en) | 2015-01-23 | 2019-11-19 | Hewlett Packard Enterprise Development Lp | Aligned variable reclamation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100453053B1 (en) | Flash memory file system | |
EP2631916B1 (en) | Data deletion method and apparatus | |
KR101473344B1 (en) | Apparatus using flash memory as storage and operation method for the same | |
KR100847506B1 (en) | Storage device, memory management method and program | |
JP5347657B2 (en) | Data storage program, method, and information processing apparatus | |
KR102252419B1 (en) | System and method for efficient address translation on Flash memory device | |
JP2009199625A (en) | Memory card, and method for controlling memory card and method for controlling nonvolatile semiconductor memory | |
US20120317337A1 (en) | Managing data placement on flash-based storage by use | |
JP4215746B2 (en) | Information processing apparatus and life monitoring method | |
JP2006040264A (en) | Control method of memory card, and control method of nonvolatile semiconductor memory | |
JP2007179546A (en) | Storage device using nonvolatile memory as cache, and operation method therefor | |
JP4280055B2 (en) | Memory control method and apparatus | |
EP1811366A2 (en) | Address assigning method, disk drive and data writing method | |
JP2008299848A (en) | Data processing apparatus and method for nonvolatile memory | |
KR100703680B1 (en) | Flash file system | |
KR101738965B1 (en) | Apparatus and method for journaling based on garbage collection | |
JP2010237907A (en) | Storage device and recording method | |
JP4130808B2 (en) | Formatting method | |
JP2008191797A (en) | File system | |
JP6988445B2 (en) | Storage system, control device and control method | |
JP5002944B2 (en) | Information processing apparatus, imaging apparatus, information processing method, and computer program | |
US20050149493A1 (en) | Data recording apparatus and data recording method | |
JP5452735B2 (en) | Memory controller and memory access method | |
JP2008269520A (en) | Recorder and recording method | |
JP2010003150A (en) | Memory controller and method for managing data in flash memory |