CN108228097A - 一种基于fat32文件系统的掉电保护方法 - Google Patents
一种基于fat32文件系统的掉电保护方法 Download PDFInfo
- Publication number
- CN108228097A CN108228097A CN201711415623.5A CN201711415623A CN108228097A CN 108228097 A CN108228097 A CN 108228097A CN 201711415623 A CN201711415623 A CN 201711415623A CN 108228097 A CN108228097 A CN 108228097A
- Authority
- CN
- China
- Prior art keywords
- file system
- power
- data
- file
- application program
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0614—Improving the reliability of storage systems
- G06F3/0619—Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/0706—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
- G06F11/0727—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in a storage system, e.g. in a DASD or network based storage system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/0793—Remedial or corrective actions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0643—Management of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0674—Disk device
- G06F3/0676—Magnetic disk device
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明提出一种基于FAT32文件系统的掉电保护方法,系统电源模块在掉电后发送掉电信号给CPU的外部中断引脚,并且能够继续维持供电至少50ms;CPU接收到掉电中断后进入到中断服务流程;首先停止应用程序,禁止应用程序继续向文件系统中写入数据;其次获取底层文件系统的指针,通过指针操作FAT表,使FAT32文件系统中的两个FAT表中的数据保持一致,使得文件系统再次使用时能够正确的读取信息;最后将文件系统内存缓冲区的数据刷新到磁盘中。本发明解决了异常掉电情况下,文件系统损坏,无法读写和显示数据的问题。
Description
技术领域
本发明属于机载数据记录存储领域,具体为一种基于FAT32文件系统的掉电保护方法,能够提高数据记录的可靠性。
背景技术
机载数据记录系统中一般都使用文件系统对数据进行记录和管理,文件系统是为了长久的存储和访问数据而为用户提供的一种基于文件和目录的存储机制。FAT(FileAllocation Table,文件分配表)文件系统是目前最常用的文件系统。
在使用磁盘存储数据之前,首先要进行分区,然后对分区进行格式化,其实格式化的过程就是在分区内建立文件系统的过程。一个文件系统由系统结构和按一定规则存放的用户数据组成。FAT文件系统用“簇”作为数据单元。一个“簇”由一组连续的扇区组成,簇所含的扇区数必须是2的整数次幂。簇的最大值为64个扇区,即32KB。所有簇从2开始进行编号,每个簇都有一个自己的地址编号。用户文件和目录都存储在簇中。FAT文件系统的数据结构中有两个重要的结构:文件分配表和目录项:文件和文件夹内容储存在簇中,如果一个文件或文件夹需要大于一个簇的空间,则用FAT表来描述如何找到另外的簇。FAT结构用于指出文件的下一个簇,同时也说明了簇的分配状态。FAT12、FAT16、FAT32这三种文件系统之间的主要区别在于FAT项的大小不同。FAT文件系统的每一个文件和文件夹都被分配到一个目录项,目录项中记录着文件名、大小、文件内容起始地址以及其他一些元数据。
FAT32文件系统在文件和目录创建过程需要一系列连续操作才可以完成,在中间过程中如果发生系统下电则无法保证文件系统的完整性。因此在系统异常下电情况时需要进行一系列的操作来保证文件系统的完整性。
发明内容
为解决现有技术存在的问题,本发明提出一种基于FAT32文件系统的掉电保护方法,能够在系统掉电情况下,通过掉电中断通知软件进行处理。处理过程包括锁定磁盘、同步FAT表、刷新缓存数据到磁盘中。
本发明的技术方案为:
所述一种基于FAT32文件系统的掉电保护方法,其特征在于:系统电源模块在掉电后发送掉电信号给CPU的外部中断引脚,并且能够继续维持供电至少50ms;CPU接收到掉电中断后进入到中断服务流程;
所述中断服务流程包括:
步骤1:停止应用程序,禁止应用程序继续向文件系统中写入数据;
步骤2:同步FAT表:获取底层文件系统的指针,通过指针操作FAT表,使FAT32文件系统中的两个FAT表:FAT1和FAT2表中的数据保持一致,使得文件系统再次使用时能够正确的读取信息;
步骤3:将文件系统内存缓冲区的数据刷新到磁盘中。
有益效果
FAT32文件系统在文件和目录创建过程需要一系列连续操作才可以完成,在中间过程中如果产生系统下电则无法保证文件系统的完整性。针对该问题,本发明提出一种掉电保护方法,使用IMP系统掉电时电源模块产生的VccFail信号保护文件系统数据完整性,系统掉电前通过磁盘的锁定、FAT表同步,文件系统cache一致等操作保证文件系统的数据完整性,从而解决了异常掉电情况下,文件系统损坏,无法读写和显示数据的问题。
本发明的附加方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本发明的实践了解到。
附图说明
本发明的上述和/或附加的方面和优点从结合下面附图对实施例的描述中将变得明显和容易理解,其中:
图1:本发明的流程图。
具体实施方式
下面详细描述本发明的实施例,所述实施例是示例性的,旨在用于解释本发明,而不能理解为对本发明的限制。
本实施例中的基于FAT32文件系统的掉电保护方法,系统电源模块在掉电后发送掉电信号给CPU的外部中断引脚,并且能够继续维持供电至少50ms,供软件处理和保存数据;CPU接收到掉电中断后进入到中断服务流程;
所述中断服务流程包括:
步骤1:停止应用程序,将磁盘进行锁定,禁止应用程序继续向文件系统中写入数据。应用程序一般都是单独的任务运行,因此直接删除应用程序任务即可。
步骤2:同步FAT表:获取底层文件系统的指针,通过指针操作FAT表,使FAT32文件系统中的两个FAT表:FAT1和FAT2表中的数据保持一致,使得文件系统再次使用时能够正确的读取信息。
FAT32文件系统有两个FAT表,分别是FAT1和FAT2,FAT1表是主要表,FAT2表是FAT1表的备份。文件系统在初始化时,读取FAT表中信息用来获取文件系统信息。FAT表由一系列大小相等的FAT表项(32bit)组成,每一个FAT表项对应一个簇(FAT32文件系统使用“簇”作为基本的数据单元,一个簇由一组连续的扇区组成,文件和目录均存储在簇中)。FAT表用来描述簇的分配状态以及标明文件或目录的下一簇的簇号。同步FAT表时,将FAT1和FAT2表中的数据保持一致,使得文件系统再次使用时能够正确的读取信息。
步骤3:文件系统cache一致,将文件系统内存缓冲区的数据刷新到磁盘中。
应用程序在调用文件系统的写操作时,并不是马上就将数据写入到磁盘中,而是先写入到内存的缓冲区中,当缓冲区写满、刷新周期已到或者关闭文件系统时才会将内存中缓冲区的数据写入到磁盘中。当系统下电时,文件系统在内存缓冲区中的数据可能并没有写入到磁盘中,因此为了避免应用程序已经写入而磁盘还没有数据的情况,需要将文件系统内存缓冲区的数据刷新到磁盘中,保证应用程序的数据不会丢失。
尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在不脱离本发明的原理和宗旨的情况下在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。
Claims (1)
1.一种基于FAT32文件系统的掉电保护方法,其特征在于:系统电源模块在掉电后发送掉电信号给CPU的外部中断引脚,并且能够继续维持供电至少50ms;CPU接收到掉电中断后进入到中断服务流程;
所述中断服务流程包括:
步骤1:停止应用程序,禁止应用程序继续向文件系统中写入数据;
步骤2:同步FAT表:获取底层文件系统的指针,通过指针操作FAT表,使FAT32文件系统中的两个FAT表:FAT1和FAT2表中的数据保持一致,使得文件系统再次使用时能够正确的读取信息;
步骤3:将文件系统内存缓冲区的数据刷新到磁盘中。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711415623.5A CN108228097A (zh) | 2017-12-25 | 2017-12-25 | 一种基于fat32文件系统的掉电保护方法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711415623.5A CN108228097A (zh) | 2017-12-25 | 2017-12-25 | 一种基于fat32文件系统的掉电保护方法 |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108228097A true CN108228097A (zh) | 2018-06-29 |
Family
ID=62648636
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711415623.5A Pending CN108228097A (zh) | 2017-12-25 | 2017-12-25 | 一种基于fat32文件系统的掉电保护方法 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108228097A (zh) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109379130A (zh) * | 2018-11-21 | 2019-02-22 | 中国航空工业集团公司洛阳电光设备研究所 | 一种基于光纤通道节点卡的网络重构方法 |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101140548A (zh) * | 2007-10-23 | 2008-03-12 | 北京握奇数据系统有限公司 | 一种卡片操作系统对数据文件进行操作的方法及智能卡 |
CN101162459A (zh) * | 2006-10-13 | 2008-04-16 | 上海万安电子科技有限公司 | 嵌入式文件系统 |
CN101515276A (zh) * | 2008-12-29 | 2009-08-26 | 北京握奇数据系统有限公司 | 一种文件数据写操作的方法、文件数据恢复方法及系统 |
CN102226893A (zh) * | 2011-05-21 | 2011-10-26 | 浙江工业大学 | 一种嵌入式系统中fat文件系统修复方法 |
CN104461947A (zh) * | 2014-11-21 | 2015-03-25 | 上海宝存信息科技有限公司 | 一种掉电保护方法及固态硬盘 |
CN105511978A (zh) * | 2015-12-05 | 2016-04-20 | 中国航空工业集团公司洛阳电光设备研究所 | 一种记录设备文件系统掉电保护方法及系统 |
CN106227623A (zh) * | 2016-08-03 | 2016-12-14 | 深圳市智行畅联科技有限公司 | 一种基于智能终端的文件格式及数据掉电修复方法及系统 |
-
2017
- 2017-12-25 CN CN201711415623.5A patent/CN108228097A/zh active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101162459A (zh) * | 2006-10-13 | 2008-04-16 | 上海万安电子科技有限公司 | 嵌入式文件系统 |
CN101140548A (zh) * | 2007-10-23 | 2008-03-12 | 北京握奇数据系统有限公司 | 一种卡片操作系统对数据文件进行操作的方法及智能卡 |
CN101515276A (zh) * | 2008-12-29 | 2009-08-26 | 北京握奇数据系统有限公司 | 一种文件数据写操作的方法、文件数据恢复方法及系统 |
CN102226893A (zh) * | 2011-05-21 | 2011-10-26 | 浙江工业大学 | 一种嵌入式系统中fat文件系统修复方法 |
CN104461947A (zh) * | 2014-11-21 | 2015-03-25 | 上海宝存信息科技有限公司 | 一种掉电保护方法及固态硬盘 |
CN105511978A (zh) * | 2015-12-05 | 2016-04-20 | 中国航空工业集团公司洛阳电光设备研究所 | 一种记录设备文件系统掉电保护方法及系统 |
CN106227623A (zh) * | 2016-08-03 | 2016-12-14 | 深圳市智行畅联科技有限公司 | 一种基于智能终端的文件格式及数据掉电修复方法及系统 |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109379130A (zh) * | 2018-11-21 | 2019-02-22 | 中国航空工业集团公司洛阳电光设备研究所 | 一种基于光纤通道节点卡的网络重构方法 |
CN109379130B (zh) * | 2018-11-21 | 2021-09-10 | 中国航空工业集团公司洛阳电光设备研究所 | 一种基于光纤通道节点卡的网络重构方法 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9501231B2 (en) | Storage system and storage control method | |
CN102955720B (zh) | 一种提高ext文件系统稳定性的方法 | |
US9946655B2 (en) | Storage system and storage control method | |
CN103577121B (zh) | 一种基于Nand Flash的高可靠线性文件存取方法 | |
US20090100237A1 (en) | Storage system that dynamically allocates real area to virtual area in virtual volume | |
US20180267856A1 (en) | Distributed storage system, data storage method, and software program | |
US8930745B2 (en) | Storage subsystem and data management method of storage subsystem | |
US7681001B2 (en) | Storage system | |
US10235282B2 (en) | Computer system, computer, and method to manage allocation of virtual and physical memory areas | |
US8010490B2 (en) | Apparatus for managing remote copying between storage systems | |
US7809908B2 (en) | Disk snapshot acquisition method | |
CN103929500A (zh) | 一种分布式存储系统的数据分片方法 | |
CN103246478B (zh) | 一种基于软raid支持无分组式全局热备盘的磁盘阵列系统 | |
CN105897859B (zh) | 一种存储系统 | |
CN103516549B (zh) | 一种基于共享对象存储的文件系统元数据日志机制 | |
US20150288752A1 (en) | Application server to nvram path | |
CN106104515A (zh) | 利用非易失性存储器的文件系统设计和故障恢复方法 | |
TW201107981A (en) | Method and apparatus for protecting the integrity of cached data in a direct-attached storage (DAS) system | |
CN106709014B (zh) | 一种文件系统转换方法及装置 | |
CN101169705B (zh) | 多硬盘下基于裸文件系统实现文件级镜像的方法及装置 | |
CN107346209B (zh) | 一种多磁盘聚合式数据存储系统及其实现方法与应用方法 | |
KR101541532B1 (ko) | 스토리지 클래스 메모리의 데이터 일관성 유지를 위한 장치 및 방법 | |
CN108228097A (zh) | 一种基于fat32文件系统的掉电保护方法 | |
CN105871987A (zh) | 数据写入的高可用系统及方法 | |
CN101739308B (zh) | 映像文件的生成方法及其存放系统 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20180629 |