JP2007133535A - File system inside storage device - Google Patents

File system inside storage device Download PDF

Info

Publication number
JP2007133535A
JP2007133535A JP2005324444A JP2005324444A JP2007133535A JP 2007133535 A JP2007133535 A JP 2007133535A JP 2005324444 A JP2005324444 A JP 2005324444A JP 2005324444 A JP2005324444 A JP 2005324444A JP 2007133535 A JP2007133535 A JP 2007133535A
Authority
JP
Japan
Prior art keywords
file
area
data
storage device
flag information
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
Application number
JP2005324444A
Other languages
Japanese (ja)
Inventor
Tetsuya Takahashi
哲哉 高橋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yaskawa Electric Corp
Original Assignee
Yaskawa Electric Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Yaskawa Electric Corp filed Critical Yaskawa Electric Corp
Priority to JP2005324444A priority Critical patent/JP2007133535A/en
Publication of JP2007133535A publication Critical patent/JP2007133535A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a file system capable of certainly holding management information even if power shutoff during writing occurs, and holding a state at least just before a writing start about a data body. <P>SOLUTION: This file system has: a data area storing a first file and the data body of a second file copied with the first file; a management area managing disposal of the data body inside a storage device; and an area storing flag information showing the file performed with the latest writing of the first file and the second file. When newly producing the file, information related to the disposal of the first file and the second file is produced in the management area, the first file and the second file are produced in the data area, and the file performed with the latest writing is stored in the flag information. <P>COPYRIGHT: (C)2007,JPO&INPIT

Description

本発明は、記憶装置内のファイルシステムに関し、特に組み込みシステムにおいて、書き込み処理を行っている最中に電源が遮断されてもデータの破壊や不整合を防止できる記憶装置内のファイルシステムに関する。   The present invention relates to a file system in a storage device, and more particularly to a file system in a storage device that can prevent data destruction and inconsistency even when a power supply is cut off during a writing process in an embedded system.

小型軽量、低消費電力、耐衝撃性などの特長を備えた半導体メモリデバイスとしてフラッシュメモリデバイスがある。近年、このフラッシュメモリデバイスの高集積化、低価格化が進んだことにより、組み込みシステムにおいても、記憶装置として用いられるようになってきた。   There is a flash memory device as a semiconductor memory device having features such as a small size, light weight, low power consumption, and impact resistance. In recent years, with the progress of higher integration and lower cost of this flash memory device, it has come to be used as a storage device even in an embedded system.

フラッシュメモリデバイスでは、ファイルシステムと呼ばれる形式でデータを操作することが一般的である。ファイルシステムでは、アクセスしたい内容をファイルという単位で操作する。ファイルはデータ本体と管理情報とに分られる。
データ本体には、単独あるいは複数の固定長領域に格納されている。
一方管理情報には、データ本体がいずれの固定長領域から格納開始されているか、複数の固定長領域が使用されている場合はどのような順番で格納されているかという内容が格納されている。管理情報にはまた、データ本体のサイズ、ファイルの名称、ファイル生成日時といった内容も格納されている。
In flash memory devices, it is common to manipulate data in a format called a file system. In the file system, the contents to be accessed are manipulated in units of files. The file is divided into a data body and management information.
The data body is stored in a single or a plurality of fixed length areas.
On the other hand, the management information stores the contents of which fixed-length area the data body starts to be stored and in what order when a plurality of fixed-length areas are used. The management information also stores contents such as the size of the data body, the file name, and the file creation date and time.

上記のファイルシステムとして代表的なものにFAT(File Allocation Table)がある。このファイルシステムは多くのコンピュータで利用可能であるため、組み込みシステムにおいても、利便性を高める目的でFATは特に広く採用されるようになってきている。 A typical example of the file system is FAT (File Allocation Table). Since this file system can be used by many computers, FAT has been particularly widely adopted in embedded systems for the purpose of improving convenience.

しかしながら、メモリにファイルを書き込んでいる最中に電源が遮断されると、データ本体が破壊されたり、管理情報の整合性が失われたりして、その後のファイルアクセスが正しく行えなくなることがある。
ファイルを書き込んでいる最中に電源が遮断される原因としては、落雷や電源の不良による物的要因のほか、ファイル書き込み中に作業者が電源OFF操作を行ってしまうといった人的要因もある。
However, if the power is turned off while a file is being written to the memory, the data body may be destroyed or the consistency of management information may be lost, making subsequent file access impossible.
The cause of the power being cut off while writing a file is not only a physical factor due to lightning or a power failure, but also a human factor such as an operator turning off the power while writing a file.

このような、書き込み処理を行っている最中の電源遮断に対し、無停電電源装置(UPS:Uninterruptible Power Supply)を備え、書き込みが完了するまで電力を供給する方法が知られている。しかし、無停電電源装置は予備電源としてバッテリを用いるため、小型化、低価格化が容易ではない。また、耐環境性、寿命、メンテナンス性にも問題がある。さらにこの方法では、ソフトウェアの不具合等でファイルの書き込み中にシステムがハングアップしてしまった場合には対処することができない。   A method is known in which an uninterruptible power supply (UPS) is provided and power is supplied until writing is completed in response to such power interruption during the writing process. 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 maintainability. Furthermore, this method cannot cope with the case where the system hangs up while writing a file due to a software defect or the like.

他の解決方法として、パーソナルコンピュータでは障害の発生を避けられないものとし障害が発生した後にファイルシステム情報の全体検査と修復を実行する方法が知られている。この方法では、全体検査の時間が長大となる上、そもそも全てのファイル復旧が保証できないなど修復可能な障害の範囲が限られているという問題がある。   As another solution, there is known a method in which the occurrence of a failure is unavoidable in a personal computer and the entire inspection and repair of file system information is executed after the failure has occurred. In this method, there is a problem that the range of failures that can be repaired is limited such that the entire inspection time is long and the restoration of all files cannot be guaranteed in the first place.

このため従来の技術では、書き込みデータを既存のデータとマージし、未使用領域に追加記述し、2組の管理領域に順次書き込むようにしていた(例えば、特許文献1参照)。また、3組の管理領域に順次書き込むことで修復を可能にしていた(例えば、特許文献2参照)。   For this reason, in the conventional technique, the write data is merged with the existing data, additionally described in the unused area, and sequentially written in the two sets of management areas (see, for example, Patent Document 1). Further, the restoration can be performed by sequentially writing to the three sets of management areas (for example, see Patent Document 2).

特開2005−149291号公報JP 2005-149291 A 特開2005−235028号公報Japanese Patent Laid-Open No. 2005-235028

しかしながら特許文献1の方法では、データが書き込まれるたびに未使用領域を消費してゆくため、長期間の運用には耐えられないという問題があった。また、2組の管理領域のいずれが正しいものであるかどうかの判断が難しいという問題もあった。   However, the method of Patent Document 1 consumes an unused area every time data is written, and thus cannot withstand long-term operation. There is also a problem that it is difficult to determine which of the two management areas is correct.

さらに特許文献2の方法では、書き込み中であったファイルのデータ本体は復旧することができないという問題があった。   Furthermore, the method of Patent Document 2 has a problem that the data body of the file being written cannot be recovered.

本発明はこのような問題点に鑑みてなされたものであり、書き込み中の電源遮断が発生しても管理情報は必ず保持されるとともに、データ本体については、少なくとも書き込み開始直前の状態を保持することができるファイルシステムを提供することを目的とする。   The present invention has been made in view of such problems, and management information is always retained even when a power interruption occurs during writing, and at least the state immediately before the start of writing is retained for the data body. The object is to provide a file system that can be used.

上記問題を解決するため、本発明は、次のようにしたのである。   In order to solve the above problem, the present invention is as follows.

請求項1に記載の発明は、記憶装置内に構築されるファイルシステムであって、第1のファイルおよび前記第1のファイルをコピーした第2のファイルのデータ本体を格納するデータ領域と、前記記憶装置内における前記データ本体の配置を管理する管理領域と、前記第1のファイルおよび前記第2のファイルのうち、最新の書き込みが行われたのはどちらかを示すフラグ情報を格納する領域とを備え、ファイルを新規作成する場合には、前記管理領域に前記第1のファイルおよび前記第2のファイルの配置に関する情報を作成し、前記データ領域に前記第1のファイルおよび前記第2のファイルを生成するとともに、前記フラグ情報には、最新の書き込みが行われたのは前記第1のファイルであることを記憶しておき、ファイルへの書き込みを行う場合には、前記フラグ情報に従って前記第1のファイルまたは前記第2のファイルのいずれかのデータ領域にのみ書き込みを行うことを特徴とする。   The invention according to claim 1 is a file system constructed in a storage device, wherein a data area storing a data body of a first file and a second file obtained by copying the first file, A management area for managing the arrangement of the data body in the storage device; an area for storing flag information indicating which of the first file and the second file has been most recently written; When creating a new file, information on the arrangement of the first file and the second file is created in the management area, and the first file and the second file are created in the data area. In the flag information, it is stored that the latest writing was performed for the first file, and writing to the file is performed. When performing is characterized by that write only one of the data area of the first file or the second file in accordance with the flag information.

請求項2に記載の発明は、前記フラグ情報を格納する領域は、前記第1のファイルおよび前記第2のファイルの前記データ領域に確保されることを特徴とする。   The invention described in claim 2 is characterized in that an area for storing the flag information is secured in the data area of the first file and the second file.

請求項3に記載の発明は、前記フラグ情報を格納する領域は、バッテリによりバックアップされた揮発性メモリ上に確保されることを特徴とする。   According to a third aspect of the present invention, the area for storing the flag information is secured on a volatile memory backed up by a battery.

請求項4に記載の発明は、前記第1のファイルまたは前記第2のファイルへの書き込み後、前記フラグ情報が前記第1のファイルを指示していた場合には前記第2のファイルを指示するように前記フラグ情報を変更し、前記フラグ情報が前記第2のファイルを指示していた場合には前記第1のファイルを指示するように前記フラグ情報を変更することを特徴とする。   The invention according to claim 4 indicates the second file when the flag information indicates the first file after writing to the first file or the second file. The flag information is changed, and when the flag information indicates the second file, the flag information is changed so as to indicate the first file.

本発明によれば、既存のファイルシステムと互換性を保ったままで、予期せぬ電源の遮断が生じてもファイルシステム全体に矛盾を引き起こすことがなくなり、かつ、二重化されたファイルのうち、正常な書き込みが最後に完了したファイルを必ず読み出すことができるようになる。
つまり、予期せぬ電源の遮断が生じても正しいデータにアクセスすることができるシステムを、性能を損なうことなく低コストで実現できるという効果がある。
According to the present invention, while maintaining compatibility with an existing file system, even if an unexpected power interruption occurs, the entire file system will not be inconsistent. It becomes possible to read the file that has been written last.
That is, there is an effect that a system capable of accessing correct data even when an unexpected power interruption occurs can be realized at a low cost without impairing performance.

以下、本発明の方法の具体的実施例について、図に基づいて説明する。   Hereinafter, specific examples of the method of the present invention will be described with reference to the drawings.

図1は、本発明を適用する記憶装置の構成を示す概略図である。この装置はCPU101、ROM102、RAM103、I/O(Input/Output)105、2次記憶装置用I/F(Interface)106、2次記憶装置107で構成される。   FIG. 1 is a schematic diagram showing the configuration of a storage device to which the present invention is applied. This apparatus includes a CPU 101, ROM 102, RAM 103, I / O (Input / Output) 105, secondary storage device I / F (Interface) 106, and secondary storage device 107.

CPU101はバス104を介した他の構成部品との情報の入出力やプログラムに基づいた数値演算や論理演算を行い、装置全体を制御するもので半導体デバイスの代表的なものである。   The CPU 101 performs input / output of information with other components via the bus 104 and performs numerical operations and logical operations based on programs to control the entire apparatus, and is a typical semiconductor device.

ROM102はプログラムを記憶する半導体メモリデバイスである。読み出し専用で電源を遮断しても内容は失われず、主に装置の立ち上げ動作に必要なプログラムを格納する。RAM103は読み出しと書き込みが自由な半導体メモリデバイスである。装置の動作中に2次記憶装置107のプログラムをコピーして使用したり、一時的にデータを格納したりする。   The ROM 102 is a semiconductor memory device that stores programs. The contents are not lost even when the power is turned off for read-only purposes, and mainly stores the programs necessary for the startup operation of the device. The RAM 103 is a semiconductor memory device that can be freely read and written. During the operation of the apparatus, the program in the secondary storage device 107 is copied and used, or data is temporarily stored.

I/O105は2次記憶装置107以外の各種の入出力である。通信装置やセンサ、アクチュエータを接続する。本発明において特に関連がないので詳細説明は省略する。2次記憶装置用I/F106は2次記憶装置107とバス104を接続するためのプロトコル変換を行うためのものである。   The I / O 105 is various inputs / outputs other than the secondary storage device 107. Connect communication devices, sensors, and actuators. Since there is no particular relevance in the present invention, detailed description is omitted. The secondary storage device I / F 106 is used to perform protocol conversion for connecting the secondary storage device 107 and the bus 104.

2次記憶装置107はフレキシブルディスク、コンパクトフラッシュ(登録商標)、フラッシュメモリカード等のリムーバブルメディア(Removable Media)、あるいはハードディスク等である。また、近年市場に現れてきたフラッシュディスクでもよい。フラッシュディスクとは磁気ディスクではなく、フラッシュメモリデバイスを内蔵して記憶装置を構成しているものでハードディスクと同一のプロトコルで接続できる。   The secondary storage device 107 is a flexible disk, a compact flash (registered trademark), a removable media such as a flash memory card, or a hard disk. Also, a flash disk that has recently appeared on the market may be used. A flash disk is not a magnetic disk, but a flash memory device is built in to constitute a storage device, and can be connected with the same protocol as a hard disk.

図2は、本発明のファイルシステムを適用する装置のソフトウェア概略構成図を示す。本装置のソフトウェアはCPU101上にて実行されるプログラム群であり、ROM102に格納されている。
プログラム群はアプリケーション201、OS(オペレーティングシステム)202、およびI/Oライブラリ203にて構成される。
なお通常の構成では、OS202とI/Oライブラリ203はそれぞれ1つずつ存在するが、アプリケーション201は1つだけ存在する場合と複数存在する場合の両方がある。
いずれの場合でも、プログラム群のうち起動時に必要な最小限のものをROM102に格納し、残りを2次記憶装置107に格納してもよい。
FIG. 2 shows a schematic software configuration diagram of an apparatus to which the file system of the present invention is applied. The software of this apparatus is a group of programs executed on the CPU 101 and is stored in the ROM 102.
The program group includes an application 201, an OS (operating system) 202, and an I / O library 203.
In a normal configuration, there is one OS 202 and one I / O library 203, but there are both cases where there is only one application 201 and a plurality of applications 201.
In any case, the minimum necessary program group may be stored in the ROM 102 and the rest may be stored in the secondary storage device 107.

OS202は汎用性の高い基本ソフトウェアであり、アプリケーション201から、I/O105や2次記憶装置107へのアクセスを容易にする。ファイルシステム204は2次記憶装置107上のデータをファイルとして扱うためのコンポーネントである。最下層のデバイスドライバ205は、直接2次記憶装置107との入出力操作を行うもので、個々の記憶装置に特有なプロトコルやパラメータの差を吸収し、上位のファイルシステム204が2次記憶装置毎に必要となることがないように抽象化している。   The OS 202 is highly versatile basic software that makes it easy to access the I / O 105 and the secondary storage device 107 from the application 201. The file system 204 is a component for handling data on the secondary storage device 107 as a file. The lowermost device driver 205 directly performs input / output operations with the secondary storage device 107, absorbs differences in protocols and parameters peculiar to individual storage devices, and the upper file system 204 makes the secondary storage device It is abstracted so that it is not necessary every time.

I/Oライブラリ203はOS202を用いずにI/O105や2次記憶装置107にアクセスする場合の手段である。OS202の場合と同様に2次記憶装置107との入出力操作を行うためのソフトウェアインターフェースである。OS202を用いるよりも最適化(高速、コンパクト)が期待できる。一方で、最適化によりI/Oライブラリ203の汎用性が乏しくなる場合がある。   The I / O library 203 is a means for accessing the I / O 105 and the secondary storage device 107 without using the OS 202. This is a software interface for performing input / output operations with the secondary storage device 107 as in the case of the OS 202. Optimization (high speed, compact) can be expected rather than using the OS 202. On the other hand, the versatility of the I / O library 203 may become poor due to optimization.

図3に標準的なファイルシステムに必要とされる記録情報の説明図を示す。2次記憶装置107の記憶領域301において、ファイルシステムの情報は3つの領域に配置される。3つの領域とは、クラスタ番号テーブル領域(1)302および同(2)303、ディレクトリ領域304、データ領域305である。それぞれは記憶領域301上の固定位置に配置されている。   FIG. 3 is an explanatory diagram of recording information required for a standard file system. In the storage area 301 of the secondary storage device 107, file system information is arranged in three areas. The three areas are a cluster number table area (1) 302 and (2) 303, a directory area 304, and a data area 305. Each is arranged at a fixed position on the storage area 301.

2次記憶装置107のアクセス単位は、セクタとよばれる固定サイズである。前記の3つの領域は、物理的にはこのセクタと呼ばれる単位でアクセスされる。ただし、データ領域305の論理的なアクセスに限っては、セクタを複数個まとめたクラスタと呼ばれる単位が使用される。1クラスタ=4セクタ、または1クラス=8セクタという使い方が一般的である。 An access unit of the secondary storage device 107 has a fixed size called a sector. The three areas are physically accessed in units called sectors. However, only a logical access to the data area 305 uses a unit called a cluster in which a plurality of sectors are collected. It is common to use 1 cluster = 4 sectors or 1 class = 8 sectors.

クラスタ番号テーブル領域(1)302は、記録されたデータ本体がどのクラスタにどのような順序で配置されているかの情報を収めるものである。クラスタ番号テーブル領域(2)303は、クラスタ番号テーブル領域(1)をバックアップするためのコピーであり、いずれかのクラスタ番号テーブルが損傷しても本体配置情報が確保できるようにしている。   The cluster number table area (1) 302 stores information indicating in which cluster the recorded data body is arranged in what order. The cluster number table area (2) 303 is a copy for backing up the cluster number table area (1), and the main body arrangement information can be secured even if any of the cluster number tables is damaged.

図3の例ではクラスタ番号テーブルの20番に数値‘21’が書き込まれている。これはクラスタの20番には有効データが存在し、続くデータがクラスタの21番に存在していることを示す。クラスタ番号テーブルの21番には数値‘22’が書き込まれている。これはクラスタの21番に有効データが存在し、続くデータがクラスタの22番に存在していることを示す。クラスタ番号テーブルの22番には“E”(ENDの意)のコードが書き込まれているが、これはクラスタの22番に有効データが存在し、続くデータはなく、最後尾のデータが収められていることを示す。   In the example of FIG. 3, a numerical value “21” is written in No. 20 of the cluster number table. This indicates that valid data exists in No. 20 of the cluster, and subsequent data exists in No. 21 of the cluster. The number “22” is written in No. 21 of the cluster number table. This indicates that valid data exists in the cluster No. 21 and the following data exists in the cluster No. 22. A code of “E” (meaning END) is written in No. 22 of the cluster number table, but there is valid data in No. 22 of the cluster, there is no following data, and the last data is stored. Indicates that

ディレクトリ領域304にはファイル毎にファイル名、更新日時、ファイルサイズ(大きさ)などの他、先頭クラスタ番号の情報を収める。先頭クラスタ番号とは、データ本体の先頭が何番のクラスタに存在するかを示す。
図3の例では、あるファイルがクラスタの20番に先頭のデータを収めていることを示している。このファイルのデータ本体を参照する場合は、まずファイル名でディレクトリ領域を検索し、その結果から先頭クラスタ番号が20番であることを知る。次にクラスタ番号テーブル領域を20番から順次辿っていけば、クラスタ番号テーブルの21番、22番を参照すればよいことがわかる。
なお、クラスタ番号テーブル領域とディレクトリ領域304とをまとめて管理領域とも言う。
The directory area 304 stores the information of the head cluster number in addition to the file name, update date and time, file size (size), etc. for each file. The head cluster number indicates in what number cluster the head of the data body exists.
The example of FIG. 3 shows that a certain file contains the first data in the 20th cluster. When referring to the data body of this file, the directory area is first searched by the file name, and it is known from the result that the first cluster number is 20. Next, if the cluster number table area is traced sequentially from No. 20, it can be seen that it is sufficient to refer to No. 21 and No. 22 of the cluster number table.
The cluster number table area and the directory area 304 are collectively referred to as a management area.

データ領域305はファイルデータ本体を収める。前述のようにデータはクラスタに分割して記録される。図の例はクラスタ20番、21番、22番の順で、データが“A”、“B”、“C”の部分ごとに収められていることを示している。   The data area 305 stores the file data body. As described above, data is divided and recorded in clusters. The example in the figure shows that data is stored for each part of “A”, “B”, and “C” in the order of clusters 20, 21, and 22.

クラスタ番号テーブル領域302/303、ディレクトリ領域304、データ領域305への書き込み順序は規定されているわけではない。特にファイルシステムはファイル内容の変更があった場合に逐一書き込みを行うわけではなく、内部バッファを使用してある程度の変更が蓄積された時点で書き込みを行っている。このため、どの領域にいつ書き込みが行われているかをアプリケーション201から知ることはできない。   The order of writing to the cluster number table area 302/303, the directory area 304, and the data area 305 is not specified. In particular, the file system does not write each time when the file contents are changed, but writes when a certain amount of changes are accumulated using the internal buffer. For this reason, it is impossible for the application 201 to know which area is being written to when.

ここで問題となるのは、ファイルの書き込みのための一連の処理を行っている最中に電源の遮断が発生すると、復旧が非常に困難であるということである。データ領域305への書き込み中に電源が遮断されるとデータ領域305の内容は保証されない。また、クラスタ番号テーブル領域302、303やディレクトリ領域304への書き込み中に電源が遮断されると、ファイルとしての一貫性が保持されない。
しかも、2次記憶装置107がフラッシュメモリデバイスで構成されている場合、当該のファイルだけでなく、同一のセクタにある情報の全てが信頼できないものとなってしまう。これは、フラッシュメモリデバイスの特性として、単純な上書きを行うことができず、既定の領域をすべて消去した後に書き込むという手順が必要となるためである。
The problem here is that if a power interruption occurs during a series of processes for writing a file, recovery is very difficult. If the power is turned off during writing to the data area 305, the contents of the data area 305 are not guaranteed. Also, if the power is shut off during writing to the cluster number table areas 302 and 303 and the directory area 304, the consistency as a file is not maintained.
In addition, when the secondary storage device 107 is composed of a flash memory device, not only the file but also all information in the same sector becomes unreliable. This is because, as a characteristic of the flash memory device, simple overwriting cannot be performed, and a procedure of writing after erasing all predetermined areas is necessary.

図4は、本発明の一実施例により、ファイルの書き込みを行う際の手順を示すフローチャートである。アプリケーション201からのファイル書き込み要求に応じ、図3で説明したクラスタ番号テーブル領域302、303、ディレクトリ領域304、データ領域305への書き込み処理を行う。   FIG. 4 is a flowchart showing a procedure for writing a file according to an embodiment of the present invention. In response to a file write request from the application 201, the cluster number table areas 302 and 303, the directory area 304, and the data area 305 described in FIG.

まず、書き込み処理が初回であるかどうかを判断する(ステップS01)。初回かどうかは、書き込みを行おうとする名称のファイルが存在するかどうかで判定できる。初回であれば、ファイルサイズを規定する(ステップS02)。サイズが変動する可能性のあるファイルであれば、所定の最大サイズで規定する。ファイルサイズが規定されれば、ファイルの書き込みを行う(ステップS03)。書き込むべきデータのサイズが最大サイズより小さければ、不足分はダミーデータで埋めて置く。このファイルを「1」とする。
続いて、ファイル「1」をコピーしたファイル「2」の書き込みを行う(ステップS04)。
実際には、ファイル「1」とファイル「2」が同じ内容のものであることをOS202が認識できるよう、予め命名についてルールを定めておく。
例えば、アプリケーション201からの要求により「DATA」という名前のファイルを生成する場合、自動的に拡張子を追加し、上記のファイル「1」として「DATA.1」というファイルを生成し、上記のファイル「2」として「DATA.2」というファイルを生成するようにしておく。拡張子より前の部分の名前が同一であることにより、OS202はファイル「DATA.1」とファイル「DATA.2」とが一組として扱うべきファイルであると判断できる。
First, it is determined whether or not the writing process is the first time (step S01). Whether it is the first time or not can be determined by whether or not a file with the name to be written exists. If it is the first time, the file size is defined (step S02). If the file has a possibility of changing its size, the file is defined with a predetermined maximum size. If the file size is specified, the file is written (step S03). If the size of the data to be written is smaller than the maximum size, the shortage is filled with dummy data. This file is set to “1”.
Subsequently, the file “2” copied from the file “1” is written (step S04).
In practice, a naming rule is set in advance so that the OS 202 can recognize that the file “1” and the file “2” have the same contents.
For example, when a file named “DATA” is generated in response to a request from the application 201, an extension is automatically added, a file “DATA.1” is generated as the file “1”, and the file A file “DATA.2” is generated as “2”. Since the names of the parts before the extension are the same, the OS 202 can determine that the file “DATA.1” and the file “DATA.2” should be handled as a set.

この後、最新の書き込みが行われたファイルはどちらのファイルであるかを示すフラグ情報に「1」を記録する(ステップS05)。
このフラグ情報は、各ファイルのデータ領域中に保持することができる。例えば、データ本体の最終バイトを使用し、この最終バイトを初回には‘0’とし、以降書き込むごとに1を加算した値を記録するという方法である。この方法では、ファイル「1」とファイル「2」の最終バイトを比較し、大きい値が入っている方が最後に書き込みを行ったファイルであると判定される。この方法では、ファイル「1」とファイル「2」両方の最終バイトの内容を比較する手間がかかる。その手間を省くため、フラグ情報は2次記憶装置107ではなく、バッテリバックアップされた揮発性メモリ(図示せず)に保持してもよい。
この場合、ファイル「1」に書き込んだ場合は数値の「1」を書き込み、ファイル「2」に書き込んだ場合は数値の「2」を書き込む。この方法では、書き込まれた数値がそのまま最後に書き込みを行ったファイルであると判定される。
また、書き込み中に電源遮断が発生しても、揮発性メモリの内容はバッテリにより保持される。
Thereafter, “1” is recorded in the flag information indicating which file is the most recently written file (step S05).
This flag information can be held in the data area of each file. For example, the last byte of the data body is used, the last byte is set to “0” for the first time, and a value obtained by adding 1 each time it is written is recorded. In this method, the last bytes of the file “1” and the file “2” are compared, and it is determined that the file with the larger value is the last file written. In this method, it takes time and effort to compare the contents of the last bytes of both the file “1” and the file “2”. In order to save the time and effort, the flag information may be held not in the secondary storage device 107 but in a battery-backed volatile memory (not shown).
In this case, the numerical value “1” is written when writing to the file “1”, and the numerical value “2” is written when writing to the file “2”. In this method, it is determined that the written numerical value is the file that was last written as it is.
Even if the power is cut off during writing, the contents of the volatile memory are retained by the battery.

ただし、初回の書き込み中は電源遮断に耐えられないため、ステップS01〜S05の処理はシステムの本稼動が始まる前に行っておかなければならない。
以上の手順により構築されるファイルシステムの構造を図5に示す。
However, since the power supply cannot be cut off during the first writing, the processes in steps S01 to S05 must be performed before the system starts actual operation.
The structure of the file system constructed by the above procedure is shown in FIG.

続いてファイルの更新処理の場合について説明する。指定された名称のファイルが存在すれば、初回ではないと判断される(ステップS01)。次にフラグ情報の判定を行う(ステップS06)。フラグ情報が「1」を指示していた場合、前回の書き込みはファイル「1」に対するものであったと判断できるので、ファイル「2」への書き込みを行う(ステップS07)。
ここで重要なのは、クラスタ番号テーブル領域302、303やディレクトリ領域304はそのままで、データ領域305だけに書き込みを行うということである。
ファイルは所定の最大サイズにて生成済みであるため、クラスタ番号テーブル領域302、303やディレクトリ領域304を更新する必要はない。データ領域305への書き込みが正常終了したら、フラグ情報に「2」を記録する(ステップS08)。
Next, the case of file update processing will be described. If there is a file with the specified name, it is determined that it is not the first time (step S01). Next, flag information is determined (step S06). If the flag information indicates “1”, it can be determined that the previous writing was for the file “1”, so the file “2” is written (step S07).
What is important here is that the cluster number table areas 302 and 303 and the directory area 304 remain as they are, and only the data area 305 is written.
Since the file has been generated with a predetermined maximum size, there is no need to update the cluster number table areas 302 and 303 and the directory area 304. When the writing to the data area 305 is normally completed, “2” is recorded in the flag information (step S08).

フラグ情報が「2」を指示していた場合、前回の書き込みはファイル「2」に対するものであったと判断できるので、ファイル「1」へデータ領域305のみの書き込みを行う(ステップS09)。データ領域305への書き込みが正常終了したら、フラグ情報に「1」を記録する。   If the flag information indicates “2”, it can be determined that the previous writing was for the file “2”, so only the data area 305 is written to the file “1” (step S09). When the writing to the data area 305 is normally completed, “1” is recorded in the flag information.

図6は、本発明の一実施例により、ファイルを読み出すときの制御手順を示すフローチャートである。アプリケーション201からのファイル読み出し要求に応じ、図5で説明したクラスタ番号テーブル領域302、303、ディレクトリ領域304、データ領域305を使ってファイルデータ本体を読み出す。   FIG. 6 is a flowchart showing a control procedure for reading a file according to an embodiment of the present invention. In response to a file read request from the application 201, the file data body is read using the cluster number table areas 302 and 303, the directory area 304, and the data area 305 described with reference to FIG.

まず、フラグ情報の判定を行う(ステップS20)。フラグ情報が「1」を指示していた場合、ファイル「1」のデータを読み出す(ステップS21)。もし、フラグ情報が「2」を指示していた場合、ファイル「2」のデータを読み出す(ステップS22)。   First, flag information is determined (step S20). If the flag information indicates “1”, the data of the file “1” is read (step S21). If the flag information indicates “2”, the data of the file “2” is read (step S22).

いずれの場合も、フラグ情報は書き込みが正常終了しているファイルを指示しているので、書き込み中に電源遮断が発生し矛盾を含んだファイルを読み出すことはない。   In either case, since the flag information indicates a file for which writing has been normally completed, the power supply is interrupted during writing, and a file containing a contradiction is not read.

以上説明したように、本実施例によれば、既存のファイルシステムと互換性を保ったままで、予期せぬ電源の遮断が生じてもファイルシステム全体に矛盾を引き起こすことがなくなり、かつ、二重化されたファイルのうち、正常な書き込みが最後に完了したファイルを必ず読み出すことができるようになる。   As described above, according to this embodiment, compatibility with the existing file system is maintained, and no conflict is caused in the entire file system even if an unexpected power interruption occurs, and the file system is duplicated. Of these files, the file that has been successfully written last can be read.

本発明によれば、予期せぬ電源の遮断が生じても正しいデータにアクセスすることができるシステムを、性能を損なうことなく低コストで実現できる。
例えば、産業用ロボットの制御装置には以下のように適用できる。
産業用ロボットの制御装置においても、その記憶装置に関する部分は図1と同様の構成を有している。一般に、作業者は制御装置に接続された教示装置などによってロボットを操作してロボットに行わせたい動作パターンを作成し、制御装置内の2次記憶装置に記録する。また、ロボットの制御に関するパラメータなど、他の情報や設定内容についても2次記憶装置に記録することができる。
しかしながら、教示した動作パターンを2次記憶装置に書き込みしている際に作業者の操作ミスなどにより制御装置の電源が遮断されると、長時間かけて教示したロボットの動作パターンが失われる恐れがある。
産業用ロボットの制御装置に本発明のファイルシステムを適用することにより、このような問題を解消し、少なくとも書き込み開始直前の動作パターンの内容を保持することができる。
According to the present invention, it is possible to realize a system capable of accessing correct data even if an unexpected power interruption occurs, at a low cost without impairing performance.
For example, the present invention can be applied to a control device for an industrial robot as follows.
Also in the control device for the industrial robot, the part related to the storage device has the same configuration as in FIG. In general, an operator operates a robot with a teaching device or the like connected to the control device to create an operation pattern desired to be performed by the robot, and records the operation pattern in a secondary storage device in the control device. Also, other information such as parameters related to robot control and setting contents can be recorded in the secondary storage device.
However, if the control device is turned off due to an operator's operation error while the taught motion pattern is being written to the secondary storage device, the robot motion pattern taught over a long time may be lost. is there.
By applying the file system of the present invention to an industrial robot controller, such a problem can be solved and at least the contents of the operation pattern immediately before the start of writing can be retained.

本発明を適用する記憶装置の構成図Configuration diagram of a storage device to which the present invention is applied 本発明の適用形態例を示すソフトウェアの概略構成図Schematic configuration diagram of software showing an application form example of the present invention 標準的ファイルシステムの構造を示す説明図Explanatory diagram showing the structure of a standard file system 本発明によるファイルの書き込み手順の一例を示すフローチャートThe flowchart which shows an example of the write-in procedure of the file by this invention 本発明のファイルシステムの構造を示す説明図Explanatory drawing which shows the structure of the file system of this invention 本発明によるファイルの読み出し手順の一例を示すフローチャートThe flowchart which shows an example of the reading procedure of the file by this invention

符号の説明Explanation of symbols

101 CPU
102 ROM
103 RAM
104 バス
105 I/O
106 2次記憶装置用I/F
107 2次記憶装置
201 アプリケーション
202 オペレーティングシステム(OS)
203 I/Oライブラリ
204 ファイルシステム
205 デバイスドライバ
301 2次記憶装置107の記憶領域
302 クラスタ番号テーブル領域(1)
303 クラスタ番号テーブル領域(2)
304 ディレクトリ領域
305 データ領域
310 クラスタ番号テーブル(データ本体記録情報)
311 ディレクトリ情報
312 データ本体
101 CPU
102 ROM
103 RAM
104 Bus 105 I / O
106 I / F for secondary storage
107 Secondary storage device 201 Application 202 Operating system (OS)
203 I / O library 204 File system 205 Device driver 301 Storage area 302 of secondary storage device 107 Cluster number table area (1)
303 Cluster number table area (2)
304 Directory area 305 Data area 310 Cluster number table (data recording information)
311 Directory information 312 Data body

Claims (4)

記憶装置内に構築されるファイルシステムであって、
第1のファイルおよび前記第1のファイルをコピーした第2のファイルのデータ本体を格納するデータ領域と、
前記記憶装置内における前記データ本体の配置を管理する管理領域と、
前記第1のファイルおよび前記第2のファイルのうち、最新の書き込みが行われたのはどちらかを示すフラグ情報を格納する領域とを備え、
ファイルを新規作成する場合には、前記管理領域に前記第1のファイルおよび前記第2のファイルの配置に関する情報を作成し、前記データ領域に前記第1のファイルおよび前記第2のファイルを生成するとともに、前記フラグ情報には、最新の書き込みが行われたのは前記第1のファイルであることを記憶しておき、
ファイルへの書き込みを行う場合には、前記フラグ情報に従って前記第1のファイルまたは前記第2のファイルのいずれかのデータ領域にのみ書き込みを行うことを特徴とする記憶装置内のファイルシステム。
A file system constructed in a storage device,
A data area for storing a first file and a data body of a second file obtained by copying the first file;
A management area for managing the arrangement of the data body in the storage device;
An area for storing flag information indicating which of the first file and the second file has been most recently written;
When a new file is created, information on the arrangement of the first file and the second file is created in the management area, and the first file and the second file are created in the data area. At the same time, in the flag information, it is stored that the latest file was written in the first file,
A file system in a storage device, wherein when writing to a file, writing is performed only to the data area of either the first file or the second file according to the flag information.
前記フラグ情報を格納する領域は、前記第1のファイルおよび前記第2のファイルの前記データ領域に確保されることを特徴とする請求項1記載の記憶装置内のファイルシステム。   2. The file system in the storage device according to claim 1, wherein an area for storing the flag information is secured in the data area of the first file and the second file. 前記フラグ情報を格納する領域は、バッテリによりバックアップされた揮発性メモリ上に確保されることを特徴とする請求項1記載の記憶装置内のファイルシステム。   2. The file system in the storage device according to claim 1, wherein an area for storing the flag information is secured on a volatile memory backed up by a battery. 前記第1のファイルまたは前記第2のファイルへの書き込み後、前記フラグ情報が前記第1のファイルを指示していた場合には前記第2のファイルを指示するように前記フラグ情報を変更し、前記フラグ情報が前記第2のファイルを指示していた場合には前記第1のファイルを指示するように前記フラグ情報を変更することを特徴とする請求項1記載の記憶装置内のファイルシステム。   If the flag information indicates the first file after writing to the first file or the second file, the flag information is changed to indicate the second file; 2. The file system in the storage device according to claim 1, wherein when the flag information indicates the second file, the flag information is changed so as to indicate the first file.
JP2005324444A 2005-11-09 2005-11-09 File system inside storage device Pending JP2007133535A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005324444A JP2007133535A (en) 2005-11-09 2005-11-09 File system inside storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005324444A JP2007133535A (en) 2005-11-09 2005-11-09 File system inside storage device

Publications (1)

Publication Number Publication Date
JP2007133535A true JP2007133535A (en) 2007-05-31

Family

ID=38155157

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005324444A Pending JP2007133535A (en) 2005-11-09 2005-11-09 File system inside storage device

Country Status (1)

Country Link
JP (1) JP2007133535A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012064094A (en) * 2010-09-17 2012-03-29 Fujitsu Ten Ltd Information recording device
DE102016008046A1 (en) 2015-07-10 2017-01-12 Fanuc Corporation Control file system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012064094A (en) * 2010-09-17 2012-03-29 Fujitsu Ten Ltd Information recording device
DE102016008046A1 (en) 2015-07-10 2017-01-12 Fanuc Corporation Control file system

Similar Documents

Publication Publication Date Title
TWI375962B (en) Data writing method for flash memory and storage system and controller using the same
US7472139B2 (en) Database recovery method applying update journal and database log
US7055010B2 (en) Snapshot facility allowing preservation of chronological views on block drives
US20100070729A1 (en) System and method of managing metadata
CN103577121A (en) High-reliability linear file access method based on nand flash
US20150378642A1 (en) File system back-up for multiple storage medium device
TW200929224A (en) Data writing method for flash memory and controller thereof
CN103577574A (en) High-reliability linear file system based on nand flash
CN105468544B (en) Method and device for realizing power-down prevention file system and power-down prevention file system
TWI459198B (en) Memory storage device, memory controller thereof, and method for identifying valid data
JP2013222435A (en) Semiconductor storage device and method of controlling the same
JP2006519444A (en) Flash memory data management method
JP4755244B2 (en) Information generation method, information generation program, and information generation apparatus
JP5057887B2 (en) Data update device, data update method, and data update program
TWI493341B (en) Memory storage device and repairing method thereof
CN114063901A (en) SSD-supported read-only mode after PLP backup failure
JP2007133535A (en) File system inside storage device
US7657719B2 (en) Controller for a copy operation between a host computer and hard disks, a control method thereof, and a recording medium storing a program for executing the control method
JP2007128448A (en) File system and file information processing method
US20070271311A1 (en) Disk array device and data management method for managing master data and replication data replicated from master data
JP2005149291A (en) Filesystem, program therefor, and information processing system
JP2001101087A (en) Memory and memory controlling method
JP2005353046A (en) Recording medium, host device, and data processing method
JP2004062851A (en) Storage system for directly and redundantly writable nonvolatile memory without needing use of redundant field, and writing method therefor
TWI669610B (en) Data storage device and control method for non-volatile memory