








本発明は情報処理システムに係り、特にハードディスクなど2次記憶内のデータの破壊や不整合を防止するファイルシステムに関する。 The present invention relates to an information processing system, and more particularly to a file system that prevents destruction or inconsistency of data in secondary storage such as a hard disk.
近年、ハードディスク装置の小型化、低価格化が進み、情報制御装置や機器へ広く応用されている。また、フラッシュメモリデバイスの高集積化、低価格化が進み、小型軽量、低消費電力等の特徴を生かし、従来のハードディスクの代替として用いられるようになってきている。これら2次記憶装置の浸透は一方で、従来は想定されなかった使用条件の問題を孕んでいる。 In recent years, hard disk devices have been reduced in size and price, and are widely applied to information control devices and devices. In addition, flash memory devices have been increasingly integrated and reduced in price, and have been used as an alternative to conventional hard disks by taking advantage of features such as small size and light weight and low power consumption. On the other hand, the penetration of these secondary storage devices has a problem of use conditions that have not been assumed in the past.
ハードディスクはパーソナルコンピュータで標準装備されているが、その記録データの内容はファイルと呼ぶ形式で操作される。データの本体はクラスタやセクタと呼ばれる一定容量のブロックに分割して記録し、これらを複数束ねることで構成されている。そして、複数のクラスタの配置や順序を管理するテーブル情報や、ファイルの名称を関連付ける情報を付加することによってファイルシステムが構築されている。ファイルシステムは多くの情報制御機器でも、その互換性を保つことによって利便性が高まるために利用されている。 The hard disk is standard equipment in a personal computer, but the contents of the recorded data are operated in a format called a file. The data body is divided and recorded in blocks of a certain capacity called clusters and sectors, and a plurality of these are bundled. A file system is constructed by adding table information for managing the arrangement and order of a plurality of clusters and information for associating file names. The file system is used in many information control devices in order to increase convenience by maintaining compatibility.
しかしながら、データの書換えなどファイルの操作中に電源が遮断されると、データが破壊されたり、テーブルの情報の整合性が失われたりして、その後の機器の動作が正しく行えなくなることがある。突然の電源遮断は落雷や電源容量の不足、あるいは電源コードの抜けなど、原因は複数の外部要因であることが多い。 However, if the power is shut off during file operations such as data rewriting, the data may be destroyed or the consistency of the information in the table may be lost, and subsequent device operations may not be performed correctly. Sudden power cuts are often caused by a number of external factors such as lightning strikes, lack of power supply capacity, or disconnection of the power cord.
このような予期しない電源遮断に対し、無停電電源装置(Uninterruptible Power Supply;UPS)を備え、システムに悪影響が残らない状態になるまで電力を供給する方法が知られている。しかし、無停電電源装置は予備電源としてバッテリを用いるため、小型化、低価格化が容易ではない。また、耐環境性や寿命、メンテナンスの問題もある。 For such an unexpected power interruption, there is known a method of supplying an electric power until an uninterruptible power supply (UPS) is provided and no adverse effect is left on the system. However, since the uninterruptible power supply uses a battery as a standby power supply, it is not easy to reduce the size and price. There are also problems with environmental resistance, life and maintenance.
他の解決方法として、パーソナルコンピュータでは復旧処置としてスキャンディスクと呼ばれるファイルシステム情報の全体検査と修復を実行する方法が知られている。スキャンディスクによる方法では全体検査の時間が長大となる問題がある。また、データの内容は必ずしも保証できないなど、修復可能な損害の範囲が限られている。 As another solution, there is known a method of executing a whole inspection and repair of file system information called a scan disk as a recovery procedure in a personal computer. The scan disk method has a problem that it takes a long time for the entire inspection. In addition, the scope of damage that can be repaired is limited, such as the contents of data cannot always be guaranteed.
近年、これらの解決策としてジャーナリングファイルシステム(Journaling File System)が導入されてきている。ファイルへの変更作業のログを別途、常に記録し、電源の遮断が生じた際には復旧時に短時間で検査、修復を実行できる方法である。特許文献1には複数のジャーナルデータをまとめて記憶媒体(フラッシュATAカード)に書き込むことにより、性能の改善や書込み回数を低減する改良方法が示されている。特許文献2にはジャーナル記録に相当する「状況データ」を不揮発性メモリに記録する方法が示されている。 In recent years, a journaling file system has been introduced as a solution to these problems. This is a method in which a separate log of changes to files is always recorded, and when power is cut off, inspection and repair can be executed in a short time at the time of recovery.
また、他の解決方法として、特許文献3には第2の記憶媒体を更新専用として設けることによって初期的なファイルが失われないようにする方法が示されている。さらに、他の解決方法として、特許文献4には一時的にファイルインデックスを冗長に作成し、更新の際の手順を厳格に行うことによって復旧処理を簡略にする方法が示されている。 As another solution,
上記のジャーナリングファイルシステムは復旧処置の検査時間は短いが、通常動作における手順が増加するため処理性能が低下してしまう。従って、ファイルシステムを完全に保証するほどの記録をしない場合が多い。また、標準的なファイルシステムとの互換性を持ちながら問題を解決することは困難である。 The journaling file system described above has a short inspection time for the recovery procedure, but the processing performance deteriorates because the number of procedures in normal operation increases. Therefore, there are many cases where the recording is not performed so as to completely guarantee the file system. It is also difficult to solve the problem while having compatibility with a standard file system.
特許文献1に記載の方法では複数のジャーナルデータをRAMにまとめてから記憶媒体に書き込むため、複数の記録が失われてしまう場合がある。特許文献2に記載の方法では状況データの書込み手順が多すぎ、性能が低下する。また、不揮発性メモリを別途用いるためにコストが増加する。 In the method described in
特許文献3に記載の方法では2つの記憶媒体を用いるためコストが増大する。また、読み書き専用媒体のファイルシステムが破綻したときは多くの新しい情報が失われてしまう。 The method described in
特許文献4に記載の方法では一時的なファイルインデックスを作成、削除する手順が通常動作に加わり性能が低下する。また、1セクタ内での書込みは瞬時に行われ書込み不全は有り得ないとしているが、一般の記憶媒体では書込み不全は起こり得る。特に書込み動作に時間のかかるフラッシュメディアでは問題となる。 In the method described in
本発明が解決しようとする課題は、上記の従来技術の問題点に鑑み、予期せぬ電源の遮断が生じて更新処理が中断されたり、書込み不全があっても、正しいデータや管理情報を確保し、情報の整合性が失われないようにしたファイルシステムを提供することにある。また、そのためのプログラムを提供することにある。 The problem to be solved by the present invention is to ensure correct data and management information even if the update process is interrupted or there is a write failure due to unexpected power interruption due to the above-mentioned problems of the prior art And providing a file system in which the integrity of information is not lost. Another object is to provide a program for this purpose.
上記の課題を解決するための本発明は、データ領域とデータの配置を管理する管理領域を別に有するファイルシステムにおいて、データ本体の情報を読取り、新たなデータとマージし、マージしたデータをデータ領域の未使用領域へ書込み、その後に第1の管理領域(テーブルT1)を更新し、ついで第2の管理領域(テーブルT2)の情報を更新する。さらに、第1の管理領域の情報と第2の管理領域の情報を比較し異常の有無を判断する。 The present invention for solving the above-mentioned problems is a file system having a data area and a management area for managing the arrangement of data separately, reads information on the data body, merges it with new data, and merges the merged data into the data area The first management area (table T1) is updated, and then the information in the second management area (table T2) is updated. Further, the information of the first management area and the information of the second management area are compared to determine whether there is an abnormality.
これによって、常に正しい状態のデータとテーブル情報を確保できるようにしたものである。また、予期せぬ電源の遮断などが発生しても、復旧時にテーブルT1、T2のエラーチェックと内容比較を行うので、ファイルシステムの異常を容易に判断することができるようにしたものである。 As a result, data and table information in a correct state can always be secured. In addition, even if an unexpected power interruption occurs, the error check and contents comparison of the tables T1 and T2 are performed at the time of recovery, so that an abnormality in the file system can be easily determined.
本発明によれば2次記憶装置上のファイルシステムにおいて、テーブルT1、T2のエラーチェックと内容比較を行い、その比較結果によりファイルシステムの異常を判断し、正しいデータを参照できるように修復することができる。つまり、本発明によれば予期せぬ電源の遮断が生じても正しいデータが確保され、ファイルシステム情報の整合性を保つファイルシステムを、性能を大きく損なうことなく低コストで構築できる効果がある。 According to the present invention, in the file system on the secondary storage device, the error check and contents comparison of the tables T1 and T2 are performed, and the abnormality of the file system is judged based on the comparison result so that correct data can be referred to. Can do. That is, according to the present invention, it is possible to construct a file system that can secure correct data even when the power supply is unexpectedly shut down and maintain the consistency of the file system information at a low cost without greatly degrading the performance.
以下、本発明の実施形態を説明する。図1はファイルシステムを適用する装置の概略の構成図を示す。本装置はCPU101、ROM102、RAM103、I/O105、I/F106、2次記憶装置107で構成する。 Embodiments of the present invention will be described below. FIG. 1 is a schematic configuration diagram of an apparatus to which a file system is applied. This apparatus includes a
CPU101はバス104の接続により他の構成部品と情報の入出力や、プログラムに基づいて数値演算や論理演算を行い、装置全体を制御するもので半導体デバイスの代表的なものである。 The
ROM102はプログラムを記憶する半導体メモリデバイスである。読出し専用で電源を遮断しても内容は失われず、主に装置の立上げ動作に必要なプログラムを格納する。RAM103は読出しと書込みが自由な半導体メモリデバイスである。装置の動作中に2次記憶装置107のプログラムをコピーして使用したり、一時的にデータを格納する。 The
I/O105は2次記憶装置107以外の各種の入出力である。通信装置やセンサ、アクチュエータを接続する。本発明において特に関連がないので詳細説明は省略する。I/F(Interface)106は2次記憶装置107とバス104を接続するためのプロトコル変換を行うものである。 The I /
2次記憶装置107はコンパクトフラッシュ(登録商標)、フラッシュメモリカード等のリムーバブルメディア(Removable Media)、またはハードディスク、あるいはフレキシブルディスク等である。また、近年市場に現れてきたフラッシュディスクでもよい。フラッシュディスクとは磁気ディスクではなく、フラッシュメモリデバイスを内蔵して記憶装置を構成しているものでハードディスクと同一プロトコルで接続できる。 The
図2はファイルシステムの適用装置のソフトウエアの概略構成図を示す。本装置のソフトウエアはCPU101が使用するプログラム群であり、ROM102に格納している。アプリケーション201、オペレーティングシステム202、またはI/Oライブラリ203で構成する。また、復旧処理プログラム206を備える。オペレーティングシステム202とI/Oライブラリ203はいずれか一つがあれば良く、本発明はいずれの形態にも適用できる。なお、プログラム群は起動時に必要最小限のものをROM102に格納し、残りを記憶媒体107に分割格納しても良い。 FIG. 2 is a schematic configuration diagram of software of a file system application apparatus. The software of this apparatus is a program group used by the
オペレーティングシステム(OS)202は主に種々の入出力デバイスを管理するとともに、アプリケーションからのデバイスの参照を容易にする汎用性のある基本ソフトウエアである。ファイルシステム204は2次記憶上のデータをファイルとして扱うためのコンポーネントである。最下層のデバイスドライバ205は直接デバイス入出力操作を行うもので個々のデバイスに特有なプロトコルやパラメータを吸収し、上位のファイルシステム204がデバイス毎個別にならないように隠蔽する。 An operating system (OS) 202 is general-purpose basic software that mainly manages various input / output devices and facilitates reference of devices from applications. The
I/Oライブラリ203はオペレーティングシステム202を用いずに2次記憶107を参照する場合の手段である。オペレーティングシステムと同様にファイルシステム管理、デバイス入出力操作を行うためのソフトウエアインタフェースである。オペレーティングシステム202を用いるより最適化(高速、コンパクト)が期待できる。一方で最適化はI/Oライブラリの汎用性が乏しくなる場合がある。 The I /
図8にファイルシステムに必要とされる記録情報の説明図を示す。ハードディスクなどの2次記憶装置107の記憶領域801において、ファイルシステムの情報は3つの領域に配置される。3つの領域とは、テーブル領域802(T1)と803(T2)、ディレクトリ領域804、データ領域805である。それぞれは記憶領域上の固定位置に配置されている。 FIG. 8 is an explanatory diagram of recording information required for the file system. In the
テーブル領域は記録されたデータ本体がどのクラスタにどのような順序で配置されているかの情報を収めるものである。T2(803)はT1(802)と同一内容(コピー)であり、一方のテーブルが損傷しても本体配置情報が確保できるようにしている。 The table area stores information on which cluster the recorded data body is arranged in what order. T2 (803) has the same content (copy) as T1 (802), and the main body arrangement information can be secured even if one of the tables is damaged.
図の例はテーブル20番に“21”の数値が書き込まれている。これはクラスタ20番には有効データが存在し、続くデータがクラスタ21番に存在していることを示す。そして、テーブル21番には“22”の数値が書き込まれているが、これはクラスタ21番に有効データが存在し、続くデータがクラスタ22番に存在していることを示す。テーブル22番には“E”(ENDの意)のコードが書き込まれているが、これはクラスタ22番に有効データが存在し、続くデータはなく最後尾のデータが収められていることを示す。なお、図中の“−”は有効データの存在しないことを示すコードが書き込まれている。 In the example shown in the figure, a numerical value “21” is written in table 20. This indicates that valid data exists in
ディレクトリ領域804はファイル毎にファイル名、更新日時、ファイルサイズ(大きさ)などの他、先頭クラスタ番号の情報を収める。先頭クラスタ番号とはデータ本体の先頭が何番のクラスタに存在するかを示す。図の例では、あるファイルがクラスタ20番に先頭のデータを収めていることを示している。例えば、実際の使用方法としてこのファイルのデータを参照するときは、ファイル名でディレクトリ領域を検索し、そして先頭クラスタ番号が20番であることから、データの本体配置情報をT1(802)のテーブル20番から順次たどっていけばよい。 The
データ領域805はファイルデータ本体を収める。前述のようにデータはクラスタに分割して記録される。図の例はクラスタ20番から22番に渡ってデータが“A”、“B”,“C”の部分ごとに収められていることを示している。なお、クラスタの大きさは一般に512バイトから64Kバイトであり、これより小さいデータのファイルであれば1つのクラスタのみを占有する。 The
それぞれの書込みの順序は規定があるわけでなく、データ領域への書込みに先んじてテーブルの更新を行っていることが多い。 The order of writing is not specified, and the table is often updated prior to writing to the data area.
問題はファイルシステム情報の一連の更新処理の実行中に電源の遮断が起きたときに発生する。書込みが正常に終了せず内容が破壊された場合だけでなく、データ書換えが一部だけ行われたり、あるいはテーブルのみが更新されただけの段階で処理が中断すれば、一般にファイルとして参照されるデータの内容は保証されなくなる。しかも、異常の生じた個所の特定は容易ではない。 The problem occurs when a power interruption occurs during a series of file system information update processing. It is generally referred to as a file if the processing is interrupted only when a part of the data is rewritten or only the table is updated, not only when the writing does not end normally and the contents are destroyed. Data content is no longer guaranteed. Moreover, it is not easy to identify the location where an abnormality has occurred.
図3は本発明の一実施例により、ファイルの一部を更新するときの制御手順を示すフローチャートである。上位アプリケーションからファイルへの書込み要求に応じ、図8で説明したファイルシステム情報に対して一連の操作を行う。 FIG. 3 is a flowchart showing a control procedure for updating a part of a file according to an embodiment of the present invention. A series of operations are performed on the file system information described with reference to FIG.
まず、書込みデータサイズ分の未使用クラスタを検索する(ステップS01)。本発明では書込み以前のデータへの上書きはせず、新規のデータ書込みは必ず未使用状態のクラスタに対して行うので、テーブルの情報を検索すればよい。以降、検索の結果で書込みを行うことを決定したデータ領域805のクラスタに対しクラスタ毎に書込み操作を行う。 First, an unused cluster for the write data size is searched (step S01). In the present invention, data prior to writing is not overwritten, and new data writing is always performed on an unused cluster. Therefore, information in the table may be searched. Thereafter, a write operation is performed for each cluster on the cluster in the
次に部分書換えか否か判定する(ステップS02)。ここでの部分書換えとは書込みの新規データがクラスタサイズより小さく、しかも書き込み以前のデータとマージ(合併)しなければデータの一部を失ってしまうケースである。部分書換えでなければステップS05へ進む。 Next, it is determined whether or not partial rewriting is performed (step S02). The partial rewriting here is a case where the new data to be written is smaller than the cluster size and part of the data is lost unless merged with the data before writing. If it is not partial rewriting, the process proceeds to step S05.
部分書換えであれば1クラスタ分のデータ読出しを行う(ステップS03)。読み出すデータは書込み以前の有効データである。ステップS03で読出したデータに書き込みデータをマージする(ステップS04)。 If partial rewriting is performed, data for one cluster is read (step S03). The data to be read is valid data before writing. The write data is merged with the data read in step S03 (step S04).
次に、ステップS05で、1クラスタ分の新規データをステップS01で検索した未使用クラスタに書込む。そして、書き残したデータがあるか判定する(ステップS06)。言い換えれば、書込み予定の全てのクラスタへの書込みを完了したかどうかである。書き残しがあれば、次の未使用クラスタへの書込みを行うため、ステップS02へ進む。 Next, in step S05, new data for one cluster is written into the unused cluster searched in step S01. Then, it is determined whether there is unwritten data (step S06). In other words, whether or not writing to all clusters scheduled for writing has been completed. If there is any unwritten data, the process proceeds to step S02 in order to write to the next unused cluster.
書き残しがなければ、テーブルT1(802)を更新し(ステップS07)、新規データの書込みを行ったクラスタへ対応を合致させる。本実施例ではこのステップをデータ領域への書込みが完了した後に行う。さらに、テーブルT2(803)を更新し(ステップS08)、T1(802)と同一の情報を書込む。 If there is no unwritten data, the table T1 (802) is updated (step S07), and the correspondence is matched with the cluster in which the new data is written. In this embodiment, this step is performed after the writing to the data area is completed. Furthermore, the table T2 (803) is updated (step S08), and the same information as T1 (802) is written.
以上のように、新規データの書込みを全て未使用クラスタに対して行い、その後でテーブルT1の更新、続いてテーブルT2の更新を行う。 As described above, all new data is written to the unused cluster, and then the table T1 is updated, and then the table T2 is updated.
次に、本実施例の制御手順によるファイルシステムの情報操作の1例を具体的に説明する。図4はファイルのデータの一部を更新するときの一連の状態変化を示す説明図である。 Next, an example of file system information operation according to the control procedure of this embodiment will be described in detail. FIG. 4 is an explanatory diagram showing a series of state changes when a part of file data is updated.
(1)は更新前の状態である。ファイルはデータ領域805のクラスタ20番、21番、22番へ順序どおりに記録されている。データは“A”、“B”、“C”の3部位に分割管理されている。テーブルT1(802)とT2(803)、ディレクトリ804の内容も対応している。 (1) is the state before update. Files are recorded in order in clusters No. 20, No. 21, and No. 22 in the
(2)は更新動作例で、“B”の部位の一部に対応するデータを書換える。未使用クラスタ検索で決定したクラスタは23番であったことを示す(図3のステップS01)。部分書換えであるので、クラスタ21番の旧データと新規データをマージしてクラスタ23番に書込む(図3のステップS02、S03、S04、S05)。新規のデータは“B’”である。本例では1クラスタの書込みだけで書き残し無くデータ領域の書込みを完了する(図3のステップS06)。 (2) is an update operation example, and data corresponding to a part of the part “B” is rewritten. This indicates that the cluster determined by the unused cluster search is No. 23 (step S01 in FIG. 3). Since this is partial rewriting, the old data and new data in
(3)はテーブルT1(802)の更新である。データの連結順序は“A”、“B’”、“C”であり、本例ではクラスタ配置と異なる。クラスタ21番の旧データは無効化し、クラスタ23番のデータを有効化する(図3のステップS07)。 (3) is an update of the table T1 (802). The data connection order is “A”, “B ′”, “C”, which is different from the cluster arrangement in this example. The old data of
(4)はテーブルT2(803)の更新である(図3のステップS08)。以上のようにデータとテーブルの更新を行う。 (4) is an update of the table T2 (803) (step S08 in FIG. 3). Data and tables are updated as described above.
次に、本実施例の制御手順により、動作中に電源の遮断が発生した場合の対応方法を説明する。図5は、図4における動作例での3つの書込み動作中にそれぞれ電源の遮断(Power−fail)が起きた状態を示す。 Next, a description will be given of a method for dealing with a case where a power interruption occurs during operation according to the control procedure of the present embodiment. FIG. 5 shows a state in which power-off occurs during each of the three write operations in the operation example of FIG.
(a)はデータ領域(805)への書込み中に電源が遮断されたケースである。新規データのクラスタ“B’”の内容は破壊されている。この場合、再起動後にはテーブル情報とデータの対応はデータ更新直前のものと合っている。かつデータは損傷を受けていないものを参照できる。なお、データの書換えだけ完了し、テーブルは全く更新していない段階で電源遮断が生じた場合も同様である。 (A) is a case where the power supply was cut off during writing to the data area (805). The contents of the new data cluster “B ′” have been destroyed. In this case, after the restart, the correspondence between the table information and the data matches that immediately before the data update. And the data can refer to undamaged. The same applies to the case where the power is cut off at the stage where only data rewriting is completed and the table is not updated at all.
(b)はテーブルT1(802)への書込み中に電源が遮断されたケースである。テーブルT1の内容は破壊されている。この場合、再起動後にはテーブルT2(803)の情報とデータの対応はデータ更新直前のものと合っている。かつデータは損傷を受けていないものを参照できる。通常はT1を用いてデータを参照するので、再起動時にT1とT2の内容を検査し、この場合についてはT2の内容をT1にコピーして使用すればよい。検査方法については後述する。 (B) is a case where the power supply is cut off during writing to the table T1 (802). The contents of table T1 are destroyed. In this case, after the restart, the correspondence between the information in the table T2 (803) and the data matches that immediately before the data update. And the data can refer to undamaged. Usually, since data is referred to using T1, the contents of T1 and T2 are inspected at the time of restart. In this case, the contents of T2 may be copied to T1 and used. The inspection method will be described later.
(c)はテーブルT2(803)への書込み中に電源が遮断されたケースである。テーブルT2の内容は破壊されている。この場合、再起動後にはテーブルT1(802)の情報とデータの対応はデータ更新後のものと合っている。かつデータは損傷を受けていないものを参照できる。通常はT1を用いてデータを参照するが、再起動時にT1とT2の内容を検査し、この場合についてはT1の内容をT2にコピーしておく。検査方法については後述する。 (C) is a case where the power supply is cut off during writing to the table T2 (803). The contents of table T2 are destroyed. In this case, after the restart, the correspondence between the information in the table T1 (802) and the data matches that after the data update. And the data can refer to undamaged. Normally, data is referred to using T1, but the contents of T1 and T2 are inspected at the time of restart. In this case, the contents of T1 are copied to T2. The inspection method will be described later.
以上のように本実施例の制御手順によれば、動作中に電源の遮断が生じてもデータやテーブル情報が守られる。 As described above, according to the control procedure of the present embodiment, data and table information can be protected even if the power is cut off during operation.
次に、再起動後(復旧時)のテーブルの検査方法の例を説明する。図6はテーブルの検査結果と判定を示す説明図である。主な検査項目は「エラーチェック」と「内容比較」である。 Next, an example of a table inspection method after restart (during recovery) will be described. FIG. 6 is an explanatory diagram showing the inspection result and determination of the table. The main inspection items are “error check” and “content comparison”.
「エラーチェック」はテーブルT1(802)とT2(803)を読み出し、デバイス固有のエラー(サムチェックやCRCのような冗長検査符号による)が発生したかどうかを調べることを示す。デバイスへの書込みが正常に終了しなかったとき、殆どはこのチェックで検出される。 “Error check” indicates that the tables T1 (802) and T2 (803) are read to check whether a device-specific error (due to a redundancy check code such as a sum check or CRC) has occurred. When the writing to the device does not end normally, most of the time is detected by this check.
「内容比較」はテーブルT1(802)とT2(803)の内容をビット単位で比較するものである。上記の制御手順によれば、T1とT2の内容が完全に一致しているとき、テーブル情報とデータの対応は合っており、なおかつデータは損傷の無いものを参照できる。以下、検査結果によってどのように判定できるか、詳細を説明する。 “Content comparison” is to compare the contents of the tables T1 (802) and T2 (803) bit by bit. According to the above control procedure, when the contents of T1 and T2 are completely coincident with each other, the correspondence between the table information and the data matches, and the data can be referred to without any damage. Hereinafter, details of how the determination can be made based on the inspection result will be described.
結果1(601)は、T1、T2にエラーなしで、T1=T2(完全一致)である。判定は、2つのテーブルは正常で、テーブル情報とデータは正しい状態にある。 The result 1 (601) is T1 = T2 (perfect match) without error in T1 and T2. The determination is that the two tables are normal and the table information and data are in the correct state.
結果2(602)は、T1、T2にエラーなしで、かつT1≠T2(不一致)である。判定はテーブル更新中に終了で、少なくとも一方のテーブルは正常である。この場合、さらにテーブルの整合性を検査することにより正常なテーブルを選定できる。 As a result 2 (602), there is no error in T1 and T2, and T1 ≠ T2 (mismatch). The determination ends during the table update, and at least one of the tables is normal. In this case, a normal table can be selected by further checking the consistency of the table.
例えばシングルチェーン検証である。クラスタの連結は枝分かれしないので、ある一つのクラスタへは一つ(または0個)のクラスタからしか連結しないはずである。しかし、テーブル情報の更新途中では一時的に2つからの連結状態が発生しうる。また、連結先のテーブル情報は“−”(データ無効)となるはずは無いが、やはり一時的に連結先のテーブル情報が“−”になりうる。このような異常状態を検出するのがシングルチェーン検証である。なお、内容比較において不一致になった部分についてのみ検査すれば短時間で異常を判定できる。 For example, single chain verification. Since the cluster connection is not branched, a certain cluster should be connected from only one (or zero) cluster. However, during the update of the table information, a connection state from two may occur temporarily. In addition, the table information of the link destination cannot be “−” (data invalid), but the table information of the link destination can temporarily be “−”. Single chain verification detects such an abnormal state. It should be noted that an abnormality can be determined in a short time by inspecting only a portion that does not match in the content comparison.
結果3(603)は、T1にエラー検出、T2にエラーなしで、T1≠T2である。判定はT1テーブル更新中に終了で、T2テーブルは正常である。 Result 3 (603) is T1 ≠ T2 with an error detected at T1 and no error at T2. The determination ends during the T1 table update, and the T2 table is normal.
結果4(604)は、T1にエラーなし、T2にエラー検出で、T1≠T2である。判定はT1テーブルは正常で、T2テーブル更新中に終了である。 In result 4 (604), no error is detected in T1, error detection is performed in T2, and T1 ≠ T2. The determination is normal for the T1 table and ends during the T2 table update.
結果5(605)は、T1、T2にエラー検出である。判定は媒体の異常である。 Result 5 (605) is error detection at T1 and T2. The determination is a medium abnormality.
以上のように検査結果から判定して、正常なテーブルに基づけば正しくデータを参照できる。次に、この検査を実現し復旧処理を行う手順を説明する。 As described above, it is possible to correctly refer to data by determining from the inspection result and based on a normal table. Next, a procedure for realizing the inspection and performing the recovery process will be described.
図7は復旧処理手順(復旧処理プログラム)を示すフローチャートである。まず、T1のエラーチェックを行う(ステップS001)。エラーが検出されればステップS004へ進み、検出されなければステップS002へ進む。 FIG. 7 is a flowchart showing a recovery processing procedure (recovery processing program). First, an error check for T1 is performed (step S001). If an error is detected, the process proceeds to step S004, and if not detected, the process proceeds to step S002.
次に、T2のエラーチェックを行う(ステップS002)。エラーが検出されればステップS006へ進み、検出されなければステップS003へ進む。 Next, an error check of T2 is performed (step S002). If an error is detected, the process proceeds to step S006, and if not detected, the process proceeds to step S003.
T1とT2の内容を比較する(ステップS003)。一致していれば処理を終了し、不一致であればステップS005へ進む。 The contents of T1 and T2 are compared (step S003). If they match, the process ends. If they do not match, the process proceeds to step S005.
ステップS004ではT2のエラーチェックを行う。エラーが検出されればステップS008へ進み、検出されなければステップS007へ進む。 In step S004, an error check of T2 is performed. If an error is detected, the process proceeds to step S008, and if not detected, the process proceeds to step S007.
ステップS005では不一致となった部位の情報についてT1の整合性を検査する。正常であればステップS006へ進み、異常が検出されればステップS007へ進む。 In step S005, the consistency of T1 is inspected with respect to the information on the mismatched parts. If normal, the process proceeds to step S006, and if an abnormality is detected, the process proceeds to step S007.
ステップS006ではT1の内容をT2に上書きコピーした後、処理を終了する。ステップS007ではT2の内容をT1に上書きコピーした後、処理を終了する。ステップS008では媒体異常を報告した後、処理を終了する。 In step S006, the contents of T1 are overwritten and copied on T2, and then the process ends. In step S007, the contents of T2 are overwritten and copied on T1, and then the process ends. In step S008, after the medium abnormality is reported, the process is terminated.
なお、復旧処理は装置の起動時に必ず行ってもよいし、検出手段を備えて、予期せぬ電源断が生じていたことを検出したときのみ実行することもできる。また、復旧処理プログラムそのものは通常は書換えを行わないデバイス(またはパーティション)に格納されていることが望ましい。 Note that the recovery process may be always performed when the apparatus is activated, or may be executed only when it is detected that an unexpected power interruption has occurred by providing a detection unit. Further, it is desirable that the restoration processing program itself is stored in a device (or partition) that is not normally rewritten.
次に本発明の他の実施例を説明する。図9は、図4とは異なるファイルシステム情報操作の一例を示す説明図である。ファイルにデータを追記するためクラスタを増加させるときの一連の状態変化を示す。 Next, another embodiment of the present invention will be described. FIG. 9 is an explanatory diagram showing an example of file system information operation different from FIG. Shows a series of state changes when increasing clusters to append data to a file.
(1)は更新前の状態である。ファイルはデータ領域805のクラスタ20番、21番へ順序どおりに記録されている。データは“a”、“b”の2部位に分割管理されている。テーブルT1(802)とT2(803)、ディレクトリ804の内容も対応している。 (1) is the state before update. Files are recorded in order in
(2)はファイルのデータ終端に追記を行う。そのため、“b”の部位の終端の一部を書換え、さらに使用クラスタを追加してその先頭にもデータを書き加える。この場合、未使用クラスタ検索で決定したクラスタは22番と23番であったことを示す(図3のステップS01)。クラスタ22番については部分書換えであるので、クラスタ21番の旧データと新規データの一部をマージしたデータを書き込み(図3のステップS02、S03、S04、S05)、新規のデータは“b’”である。 (2) is added to the end of the file data. Therefore, a part of the end of the part “b” is rewritten, a use cluster is added, and data is also written at the head. In this case, it is indicated that the clusters determined by the unused cluster search were No. 22 and No. 23 (step S01 in FIG. 3). Since
本例では書き残しているデータをさらにもう一つのクラスタに書込む必要がある(図3のステップS06)。クラスタ23番への書込みは新規として旧データとマージせずに書き込む(図3のステップS02、S05)。こうしてデータ領域の書換えを完了する(図3のステップS06)。 In this example, it is necessary to write the remaining data into another cluster (step S06 in FIG. 3). Writing to the
(3)はテーブルT1(802)を更新する。データの連結順序は“a”、“b’”、“c”である。クラスタ21番の旧データは無効化し、クラスタ22番と23番のデータへ連結するようにして有効化する(図3のステップS07)。 (3) updates the table T1 (802). The data connection order is “a”, “b ′”, “c”. The old data of the cluster No. 21 is invalidated and validated by linking to the data of the cluster No. 22 and No. 23 (step S07 in FIG. 3).
(4)はテーブルT2(803)を更新する(図3のステップS08)。以上のように、データとテーブルの更新を行う。 (4) updates the table T2 (803) (step S08 in FIG. 3). As described above, data and tables are updated.
以上説明したように、本実施例によれば、2次記憶装置上の標準的ファイルシステムにおいて、データ本体の情報を読取り、新たなデータとマージし、マージしたデータをデータ領域の未使用領域へ書込みを行う。その後に、テーブルT1、T2の情報を更新することによって、常に正しい状態のデータとテーブル情報を確保できる。そして、予期せぬ電源の遮断が発生しても、復旧時にテーブルT1、T2のエラーチェックと内容比較の検査を行えば、検査結果によりファイルシステムの異常を容易に判断し、正しいデータを参照できるように修復することができる。 As described above, according to the present embodiment, in the standard file system on the secondary storage device, the information of the data body is read, merged with new data, and the merged data is transferred to an unused area of the data area. Write. Thereafter, by updating the information in the tables T1 and T2, data and table information in a correct state can always be secured. Even if an unexpected power interruption occurs, if an error check and content comparison check is performed on the tables T1 and T2 at the time of recovery, a file system abnormality can be easily determined based on the check result and correct data can be referred to. Can be repaired.
つまり、本発明によれば予期せぬ電源の遮断が生じても正しいデータが確保され、ファイルシステム情報の整合性を保つファイルシステムを、性能を大きく損なうことなく低コストで構築できる。 That is, according to the present invention, it is possible to construct a file system that secures correct data even when an unexpected power interruption occurs and maintains the consistency of file system information without greatly degrading performance.
本発明により、ディレクトリ領域の情報が損傷を受けた場合の対処法については、以下の改良がある。標準的なファイルシステムではディレクトリ情報の配置について2つの方法が知られている。一つは前述のように固定領域に配置する方法であり、残り一つはファイルのデータ本体と同様にデータ領域に自由に配置する方法である。 According to the present invention, there is the following improvement as a countermeasure when the information in the directory area is damaged. In a standard file system, two methods for the arrangement of directory information are known. One is a method of arranging in the fixed area as described above, and the other is a method of freely arranging in the data area in the same manner as the data body of the file.
ディレクトリ情報を固定領域に配置する場合は、テーブル情報と同様にディレクトリ領域を2つ設けても良い。テーブル情報と同じようにエラーチェックと内容比較を復旧処理プログラムで行えば良い。特許文献4に記載の方法では冗長なファイルインデックスを書込むだけでなく消去する手順が必要とされるが、本発明では書込みのみで良い。さらにファイル名の更新や先頭クラスタ番号の更新時のみ保存するなどにより、処理のオーバーヘッドが小さくなる。ファイルサイズ情報などはEOFの無い非テキストファイルについてのみ行うなどの方法もある。ディレクトリ情報はその他一般のファイルと異なり、特定のクラスタに定めるなど、それ自体の参照に問題が発生しにくいようにするのが望ましい。その他、整合性検査について既存技術も多い。 When directory information is arranged in a fixed area, two directory areas may be provided similarly to the table information. Similar to the table information, error check and content comparison may be performed by the recovery processing program. The method described in
ディレクトリ情報をデータ領域に自由に配置する場合は、データ本体と同様の手順で必ず未使用クラスタ領域に更新情報を書き込むようにすれば良い。 When directory information is freely arranged in the data area, the update information should be written in the unused cluster area by the same procedure as that for the data body.
本発明の第2の改良として、処理の高速化について説明する。ファイルデータやテーブル情報はメモリ上にコピーしたものを確保しておき、同一データを何度も2次記憶から読出さず、短時間で参照できるようにするキャッシュ方式が知られている。その場合に、部分書込みでも旧データの確保は2次記憶からではなく、高速なメモリ上から行えるケースがある。また、内容に変更が生じて2次記憶装置への反映が必要になったときには、データ領域、テーブルT1、テーブルT2への書込み制御順序を守るようにすれば良い。 As a second improvement of the present invention, the speeding up of the process will be described. A cache method is known in which file data and table information copied in a memory are secured so that the same data can be referred to in a short time without being repeatedly read from the secondary storage. In that case, there is a case where the old data can be secured from the high-speed memory instead of the secondary storage even in the partial writing. Further, when the contents are changed and need to be reflected in the secondary storage device, the order of writing control to the data area, the table T1, and the table T2 may be maintained.
101…CPU、102…ROM、103…RAM、104…バス、105…I/O、106…I/F、107…2次記憶装置、201…アプリケーション、202…オペレーティングシステム(OS)、203…I/Oライブラリ、204…ファイルシステム、205…デバイスドライバ。 101 ... CPU, 102 ... ROM, 103 ... RAM, 104 ... bus, 105 ... I / O, 106 ... I / F, 107 ... secondary storage device, 201 ... application, 202 ... operating system (OS), 203 ... I / O library, 204... File system, 205... Device driver.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2003388031AJP2005149291A (en) | 2003-11-18 | 2003-11-18 | File system, program thereof, and information processing system |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2003388031AJP2005149291A (en) | 2003-11-18 | 2003-11-18 | File system, program thereof, and information processing system |
| Publication Number | Publication Date |
|---|---|
| JP2005149291Atrue JP2005149291A (en) | 2005-06-09 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2003388031APendingJP2005149291A (en) | 2003-11-18 | 2003-11-18 | File system, program thereof, and information processing system |
| Country | Link |
|---|---|
| JP (1) | JP2005149291A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2007316944A (en)* | 2006-05-25 | 2007-12-06 | Toshiba Corp | Data processing apparatus, data processing method, and data processing program |
| US8031361B2 (en) | 2006-09-19 | 2011-10-04 | Brother Kogyo Kabushiki Kaisha | Image forming apparatus |
| US8089662B2 (en) | 2006-09-25 | 2012-01-03 | Brother Kyogo Kabushiki Kaisha | Image forming apparatus |
| US8125670B2 (en) | 2006-09-28 | 2012-02-28 | Brother Kogyo Kabushiki Kaisha | Data processing apparatus and recording medium |
| US8179557B2 (en) | 2006-09-28 | 2012-05-15 | Brother Kogyo Kabushiki Kaisha | Image forming apparatus for reading information from and writing information to a non-contact medium |
| JP2015022691A (en)* | 2013-07-23 | 2015-02-02 | コイト電工株式会社 | Signal control device, and method of preserving history data |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2007316944A (en)* | 2006-05-25 | 2007-12-06 | Toshiba Corp | Data processing apparatus, data processing method, and data processing program |
| US8031361B2 (en) | 2006-09-19 | 2011-10-04 | Brother Kogyo Kabushiki Kaisha | Image forming apparatus |
| US8089662B2 (en) | 2006-09-25 | 2012-01-03 | Brother Kyogo Kabushiki Kaisha | Image forming apparatus |
| US8125670B2 (en) | 2006-09-28 | 2012-02-28 | Brother Kogyo Kabushiki Kaisha | Data processing apparatus and recording medium |
| US8179557B2 (en) | 2006-09-28 | 2012-05-15 | Brother Kogyo Kabushiki Kaisha | Image forming apparatus for reading information from and writing information to a non-contact medium |
| JP2015022691A (en)* | 2013-07-23 | 2015-02-02 | コイト電工株式会社 | Signal control device, and method of preserving history data |
| Publication | Publication Date | Title |
|---|---|---|
| JP4371771B2 (en) | Power management block used in non-volatile memory system | |
| CN107943414B (en) | File system partition and data read-write method of embedded Linux | |
| CN101430703B (en) | Systems and methods for automatic maintenance and repair of entites in data model | |
| US8775771B2 (en) | Block management method for a flash memory and flash memory controller and storage system using the same | |
| US8745443B2 (en) | Memory system | |
| CN103577121A (en) | High-reliability linear file access method based on nand flash | |
| CN103577574A (en) | High-reliability linear file system based on nand flash | |
| US7020805B2 (en) | Efficient mechanisms for detecting phantom write errors | |
| CN112463724A (en) | Data processing method and system for lightweight file system | |
| CN101625897B (en) | Data writing method, storage system and controller for flash memory | |
| TWI459198B (en) | Memory storage device, memory controller thereof, and method for identifying valid data | |
| TWI404071B (en) | Controller circuit having functions for identifying error data in flash memory and storage system and method thereof | |
| JP2006519444A (en) | Flash memory data management method | |
| CN101944386A (en) | Control circuit for identifying error data in flash memory, storage system and method | |
| CN102890655A (en) | Memory storage device, its memory controller and effective data identification method | |
| JPH03224045A (en) | Data holding system | |
| CN119248197B (en) | Data processing method, device, equipment and medium | |
| CN115878377A (en) | Power failure protection method and device for embedded Linux system and computer equipment | |
| JP2005149291A (en) | File system, program thereof, and information processing system | |
| CN114064596A (en) | Log type embedded file system design method, system and storage medium | |
| JP3675375B2 (en) | Nonvolatile memory and data rewriting method of nonvolatile memory | |
| JP2008234446A (en) | Data consistency checking method and system | |
| CN113434086B (en) | Data storage method, device, non-volatile storage device and memory | |
| JP2010536112A (en) | Data storage method, apparatus and system for recovery of interrupted writes | |
| CN102831032A (en) | Repair system and method for master boot record of hard disc |
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination | Free format text:JAPANESE INTERMEDIATE CODE: A621 Effective date:20060316 | |
| RD02 | Notification of acceptance of power of attorney | Free format text:JAPANESE INTERMEDIATE CODE: A7422 Effective date:20060316 | |
| A977 | Report on retrieval | Free format text:JAPANESE INTERMEDIATE CODE: A971007 Effective date:20090324 | |
| A131 | Notification of reasons for refusal | Free format text:JAPANESE INTERMEDIATE CODE: A131 Effective date:20090331 | |
| A02 | Decision of refusal | Free format text:JAPANESE INTERMEDIATE CODE: A02 Effective date:20090811 |