CN102521289A - File synchronization method, device and system - Google Patents
File synchronization method, device and system Download PDFInfo
- Publication number
- CN102521289A CN102521289A CN2011103868296A CN201110386829A CN102521289A CN 102521289 A CN102521289 A CN 102521289A CN 2011103868296 A CN2011103868296 A CN 2011103868296A CN 201110386829 A CN201110386829 A CN 201110386829A CN 102521289 A CN102521289 A CN 102521289A
- Authority
- CN
- China
- Prior art keywords
- file
- ramdisk
- files
- flash
- registration
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/178—Techniques for file synchronisation in file systems
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Hardware Redundancy (AREA)
Abstract
本发明实施例公开了一种文件同步方法、装置及系统,其中,文件同步方法包括:将LINUX嵌入式系统中flash中的文件同步到RAMDISK中,并对RAMDISK中的文件进行inotify注册或者dnotify注册;LINUX嵌入式系统的应用程序对inotify注册后或者dnotify注册后的RAMDISK中的文件进行操作,当inotify注册后或者dnotify注册后的RAMDISK中的文件发生变化时,将发生变化的RAMDISK中的文件同步到flash中。可见,嵌入式系统的应用程序只需要读写RAMDISK中的文件,从而提高了嵌入式系统的读写速度,提高了系统的响应速度。
The embodiment of the present invention discloses a file synchronization method, device and system, wherein the file synchronization method includes: synchronizing the files in the flash in the LINUX embedded system to the RAMDISK, and performing inotify registration or dnotify registration on the files in the RAMDISK ;The application of the LINUX embedded system operates on the files in the RAMDISK after the inotify registration or the dnotify registration. When the files in the RAMDISK after the inotify registration or the dnotify registration change, the files in the changed RAMDISK will be synchronized to flash. It can be seen that the application program of the embedded system only needs to read and write the files in RAMDISK, thereby improving the reading and writing speed of the embedded system and improving the response speed of the system.
Description
技术领域 technical field
本发明实施例涉及通信技术领域,尤其涉及一种文件同步方法、装置及系统。Embodiments of the present invention relate to the field of communication technologies, and in particular to a file synchronization method, device and system.
背景技术 Background technique
目前,通常在基于LINUX的嵌入式系统中使用flash(闪存),如BMC(BaseboardManagement Controller,基板管理控制器),由于flash内部的擦除机制,即擦除后可重新写入,会导致在flash上写文件出现秒级的延时,因此,如果需要频繁地在flash上写文件,那么就会出现超时或者响应缓慢的情况。At present, flash (flash memory) is usually used in embedded systems based on LINUX, such as BMC (Baseboard Management Controller, baseboard management controller). Due to the internal erasing mechanism of flash, that is, it can be rewritten after erasing, it will cause There is a second-level delay in writing files, so if you need to frequently write files on flash, there will be timeouts or slow responses.
发明内容 Contents of the invention
本发明实施例提供一种文件同步方法、装置及系统,降低写文件的延时。Embodiments of the present invention provide a file synchronization method, device, and system to reduce the delay in writing files.
本发明实施例通过以下技术方案实现的:Embodiments of the present invention are achieved through the following technical solutions:
一方面,本发明实施例提供一种文件同步方法,包括:On the one hand, the embodiment of the present invention provides a file synchronization method, including:
将LINUX嵌入式系统中闪存flash中的文件同步到随机存储记忆体磁盘RAMDISK中,并对所述RAMDISK中的文件进行inotify注册或者dnotify注册;Synchronize the files in the flash memory flash in the LINUX embedded system to the RAM disk RAMDISK, and carry out inotify registration or dnotify registration to the files in the RAMDISK;
LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,当所述inotify注册后或者所述dnotify注册后的所述RAMDISK中的文件发生变化时,将发生变化的所述RAMDISK中的文件同步到所述flash中。The application program of the LINUX embedded system operates on the files in the RAMDISK after the inotify registration or the dnotify registration, when the files in the RAMDISK after the inotify registration or the dnotify registration change, Synchronize the changed files in the RAMDISK to the flash.
另一方面,本发明实施例提供一种文件同步装置,包括:On the other hand, an embodiment of the present invention provides a file synchronization device, including:
第一同步单元,用于将LINUX嵌入式系统中闪存flash中的文件同步到随机存储记忆体磁盘RAMDISK中;The first synchronization unit is used to synchronize the files in the flash memory flash in the LINUX embedded system to the RAM disk RAMDISK;
注册单元,用于对所述RAMDISK中的文件进行inotify注册或者dnotify注册;A registration unit, configured to perform inotify registration or dnotify registration on files in the RAMDISK;
第二同步单元,用于LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,当所述inotify注册后或者所述dnotify注册后的所述RAMDISK中的文件发生变化时,将发生变化的所述RAMDISK中的文件同步到所述flash中。The second synchronization unit is used for the application program of the LINUX embedded system to operate the files in the RAMDISK after the inotify registration or the dnotify registration, when the inotify registration or the dnotify registration The RAMDISK When the files in the RAMDISK change, the changed files in the RAMDISK are synchronized to the flash.
另一方面,本发明实施例提供一种文件同步系统,包括同步单元、flash以及RAMDISK,所述同步单元用于,将flash中的文件同步到RAMDISK中,并对所述RAMDISK中的文件进行inotify注册或者dnotify注册;LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,当所述inotify注册后或者所述dnotify注册后的所述RAMDISK中的文件发生变化时,将发生变化的所述RAMDISK中的文件同步到所述flash中。On the other hand, an embodiment of the present invention provides a file synchronization system, including a synchronization unit, a flash, and a RAMDISK, the synchronization unit is used to synchronize files in the flash to the RAMDISK, and inotify the files in the RAMDISK Registration or dnotify registration; the application program of the LINUX embedded system operates the files in the RAMDISK after the inotify registration or the dnotify registration, when the inotify registration or the dnotify registration in the RAMDISK When a file changes, the changed file in the RAMDISK is synchronized to the flash.
由上述本发明提供的技术方案可以看出,LINUX嵌入式系统使用inotify或dnotify文件通知机制,把RAMDISK中的文件和flash中的文件映射起来,嵌入式系统的应用程序只需要读写RAMDISK中的文件,从而提高了嵌入式系统的读写速度,提高了系统的响应速度。As can be seen from the technical scheme provided by the present invention above, the LINUX embedded system uses the inotify or dnotify file notification mechanism to map the files in the RAMDISK and the files in the flash, and the application program of the embedded system only needs to read and write the files in the RAMDISK. files, thereby improving the read and write speed of the embedded system and improving the response speed of the system.
附图说明 Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings that need to be used in the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For Those of ordinary skill in the art can also obtain other drawings based on these drawings on the premise of not paying creative work.
图1为本发明实施例提供的文件同步方法的流程示意图。FIG. 1 is a schematic flowchart of a file synchronization method provided by an embodiment of the present invention.
图2为本发明实施例提供的文件同步装置的构成示意图。FIG. 2 is a schematic diagram of the structure of a file synchronization device provided by an embodiment of the present invention.
图3为本发明实施例提供的文件同步方法的应用流程示意图一。FIG. 3 is a first schematic diagram of the application flow of the file synchronization method provided by the embodiment of the present invention.
图4为本发明实施例提供的文件同步方法的应用流程示意图二。FIG. 4 is a second schematic diagram of the application flow of the file synchronization method provided by the embodiment of the present invention.
图5为本发明实施例提供的文件同步方法的应用流程示意图三。FIG. 5 is a third schematic diagram of the application process of the file synchronization method provided by the embodiment of the present invention.
图6为本发明实施例提供的文件同步方法的应用流程示意图四。FIG. 6 is a fourth schematic diagram of the application flow of the file synchronization method provided by the embodiment of the present invention.
图7为本发明实施例提供的文件同步方法的应用流程示意图五。FIG. 7 is a fifth schematic diagram of the application flow of the file synchronization method provided by the embodiment of the present invention.
具体实施方式 Detailed ways
下面结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明的保护范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
如图1所述,本发明实施例提供一种文件同步方法,可以应用在基于LINUX的嵌入式系统中,方法包括:As shown in Figure 1, the embodiment of the present invention provides a kind of file synchronization method, can be applied in the embedded system based on LINUX, and method comprises:
11、将LINUX嵌入式系统中闪存flash中的文件同步到随机存储记忆体磁盘RAMDISK中,并对所述RAMDISK中的文件进行inotify注册或者dnotify注册。11. Synchronize the files in the flash memory in the LINUX embedded system to the RAM disk RAMDISK, and perform inotify registration or dnotify registration on the files in the RAMDISK.
12、LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,当所述inotify注册后或者所述dnotify注册后的所述RAMDISK中的文件发生变化时,将发生变化的所述RAMDISK中的文件同步到所述flash中。12. The application program of the LINUX embedded system operates the files in the RAMDISK after the inotify registration or the dnotify registration, when the files in the RAMDISK after the inotify registration or the dnotify registration change When, the changed files in the RAMDISK are synchronized to the flash.
本发明实施例的文件同步方法,不改变LINUX嵌入式系统的应用程序的读写文件方式的情况下,使用LINUX内核inotify或dnotify文件通知机制,把RAMDISK中的文件和flash中的文件映射起来,嵌入式系统的应用程序只需要读写RAMDISK中的文件,从而提高了嵌入式系统的读写速度,提高了系统的响应速度。The file synchronization method of the embodiment of the present invention, under the situation that does not change the read-write file mode of the application program of LINUX embedded system, uses LINUX kernel inotify or dnotify file notification mechanism, the file in RAMDISK and the file in flash are mapped, The application program of the embedded system only needs to read and write the files in RAMDISK, thus improving the reading and writing speed of the embedded system and improving the response speed of the system.
可选的,上述步骤12中,LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,可以包括:对所述inotify注册后或者所述dnotify注册后的文件进行读操作,或者写操作,或者移动操作,或者删除操作等等。Optionally, in the
可选的,上述步骤12中,所述inotify注册后或者所述dnotify注册后的所述文件发生变化,可以包括:所述inotify注册后或者所述dnotify注册后的所述文件被修改,或者被移动、或者被删除等等。Optionally, in
可选的,本发明实施例的文件同步方法,还可以包括:Optionally, the file synchronization method in the embodiment of the present invention may also include:
根据文件被修改的频度特性及文件用途,将所述flash中的文件划分为日志类型文件以及配置类型文件,所述日志类型文件被修改的频度大于所述配置类型文件被修改的频度,所述日志类型文件用于记录日志,所述配置类型文件用于应用程序加载所需环境的设置。According to the modified frequency characteristics and file usage of the files, the files in the flash are divided into log type files and configuration type files, and the frequency of modification of the log type files is greater than the modification frequency of the configuration type files , the log type file is used to record logs, and the configuration type file is used to set the environment required for application loading.
日志类型文件用于记录日志,通常操作频度大,而且而且日志类型文件只会以内容追加的方式修改。配置类型文件用于应用程序加载所需环境的设置,虽然配置类型文件会被修改,但通常操作频度小。Log type files are used to record logs, and are usually operated frequently, and log type files are only modified by appending content. The configuration type file is used to set the environment required for application loading. Although the configuration type file will be modified, the operation frequency is usually small.
进一步的,对于日志类型文件,由于通常不会被修改,则在flash中不需要进行备份。而对于配置类型文件,由于通常会被修改、增加,则需要将flash中的文件进行备份,得到对应的主文件和备份文件。Furthermore, for log type files, since they are usually not modified, there is no need to perform backup in the flash. As for the configuration type files, since they are usually modified and added, the files in the flash need to be backed up to obtain corresponding main files and backup files.
可选的,本发明实施例的文件同步方法中,可以通过读取配置文件来确定flash中的文件属于日志类型文件或者配置类型文件。Optionally, in the file synchronization method of the embodiment of the present invention, it may be determined by reading the configuration file that the file in the flash belongs to a log type file or a configuration type file.
下面对日志类型文件以及配置类型文件,分别对本发明实施例的文件同步方法进行说明:The following describes the file synchronization method of the embodiment of the present invention for log type files and configuration type files:
对于日志类型文件,将flash中的文件同步到RAMDISK中,可以包括:For log type files, the files in flash are synchronized to RAMDISK, which can include:
直接将flash中的日志类型文件复制到RAMDISK中。Directly copy log type files in flash to RAMDISK.
进一步的,对于日志类型文件,将发生变化的RAMDISK中的文件同步到flash中,可以包括:Further, for log type files, synchronizing the changed files in RAMDISK to flash may include:
使用增量同步的方法,将RAMDISK中的日志类型文件同步到flash中。基于该日志类型文件中每条记录有固定的长度,或者以换行符结束,则可以将文件中增加的记录同步到flash中,而不必将整个文件都同步到flash中。Use the method of incremental synchronization to synchronize the log type files in RAMDISK to flash. Based on the fact that each record in the log type file has a fixed length, or ends with a newline character, you can synchronize the added records in the file to the flash instead of synchronizing the entire file to the flash.
可选的,对于日志类型文件,在启动(包括初始启动和重新启动)LINUX嵌入式系统后,可以根据该日志类型文件的特点(每条记录有固定的长度,或者以换行符结束),对flash中的日志类型文件进行完整性的检验,如果日志类型文件的最后一条记录不完整,可以把最后一条记录删除掉。Optionally, for a log type file, after starting (including initial startup and restart) the LINUX embedded system, according to the characteristics of the log type file (each record has a fixed length, or ends with a newline character), the The integrity of the log type file in the flash is checked. If the last record of the log type file is incomplete, the last record can be deleted.
对于配置类型文件,将flash中的文件同步到RAMDISK中,可以包括:For configuration type files, the files in flash are synchronized to RAMDISK, which can include:
根据flash中主文件的CRC(Cyclic Redundancy Check,循环冗余校验)值或者MD5(Message-Digest Algorithm 5,信息-摘要算法5)值判断所述主文件的合法性,当所述主文件合法时,将所述主文件同步到RAMDISK中以及同步到所述备份文件中;According to the CRC (Cyclic Redundancy Check, Cyclic Redundancy Check) value or MD5 (Message-Digest Algorithm 5, information-digest algorithm 5) value of the main file in the flash to judge the legality of the main file, when the main file is legal , synchronizing the main file into RAMDISK and synchronizing into the backup file;
当所述主文件不合法时,根据flash中备份文件的CRC值或者MD5值判断所述flash中备份文件的合法性,当所述备份文件合法时,将所述备份文件同步到RAMDISK中以及同步到所述主文件中。When the main file is illegal, judge the validity of the backup file in the flash according to the CRC value or the MD5 value of the backup file in the flash, and when the backup file is legal, synchronize the backup file into RAMDISK and synchronize into the main file.
其中,CRC值或者MD5值可以包括:初始CRC值或者MD5值,或者更新CRC值或者MD5值。Wherein, the CRC value or MD5 value may include: an initial CRC value or MD5 value, or an updated CRC value or MD5 value.
其中,不限于CRC算法或者MD5,任何可以实现判断文件合法性的算法都可以适用。Wherein, it is not limited to the CRC algorithm or MD5, and any algorithm that can realize the legality of the file can be applied.
进一步的,对于配置类型文件,将发生变化的RAMDISK中的文件同步到flash中,可以包括:Further, for configuration type files, synchronizing the changed files in RAMDISK to flash may include:
根据CRC算法或者MD5,计算发生变化的RAMDISK中的文件的更新CRC值或者MD5值;According to the CRC algorithm or MD5, calculate the updated CRC value or MD5 value of the file in the changed RAMDISK;
先将所述更新CRC值或者MD5值同步给所述flash中主文件,再将所述发生变化的所述RAMDISK中的文件同步到所述flash中对应的主文件;First synchronizing the updated CRC value or MD5 value to the main file in the flash, and then synchronizing the changed file in the RAMDISK to the corresponding main file in the flash;
先将所述更新CRC值或者MD5值同步给所述flash中备份文件,再将所述发生变化的所述RAMDISK中的文件同步到所述flash中对应的备份文件。Synchronize the updated CRC value or MD5 value to the backup file in the flash, and then synchronize the changed file in the RAMDISK to the corresponding backup file in the flash.
可选的,本发明实施例的文件同步方法,可以使用硬件加密引擎,来计算文件的CRC值或者MD5值,减少CPU的开销。示例性的,例如C3硬件加密引擎,那么计算文件的CRC值或者MD5值时,可以调用C3硬件加密引擎的API(Application ProgrammingInterface,应用程序编程接口)来计算,从而减少了CPU(Central Processing Unit,中央处理器)的开销。Optionally, the file synchronization method in the embodiment of the present invention may use a hardware encryption engine to calculate the CRC value or MD5 value of the file, reducing CPU overhead. Exemplary, such as the C3 hardware encryption engine, when calculating the CRC value or MD5 value of the file, the API (Application Programming Interface, Application Programming Interface) of the C3 hardware encryption engine can be called to calculate, thereby reducing CPU (Central Processing Unit, CPU) overhead.
如图2所述,对应于上述实施例的文件同步方法,本发明实施例提供一种文件同步装置20,该装置20可以是小型计算机,或者个人计算机,网络节点等,包括:As shown in Figure 2, corresponding to the file synchronization method of the above-mentioned embodiment, the embodiment of the present invention provides a
第一同步单元21,用于将LINUX嵌入式系统中闪存flash中的文件同步到随机存储记忆体磁盘RAMDISK中。The
注册单元22,用于对所述RAMDISK中的文件进行inotify注册或者dnotify注册。The
第二同步单元23,用于LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,当所述inotify注册后或者所述dnotify注册后的所述RAMDISK中的文件发生变化时,将发生变化的所述RAMDISK中的文件同步到所述flash中。The
本发明实施例的文件同步装置,不改变LINUX嵌入式系统的应用程序的读写文件方式的情况下,使用LINUX内核inotify或dnotify文件通知机制,把RAMDISK中的文件和flash中的文件映射起来,嵌入式系统的应用程序只需要读写RAMDISK中的文件,从而提高了嵌入式系统的读写速度,提高了系统的响应速度。The file synchronizing device of the embodiment of the present invention, under the situation that does not change the read-write file mode of the application program of LINUX embedded system, uses LINUX kernel inotify or dnotify file notification mechanism, the file in RAMDISK and the file in flash are mapped together, The application program of the embedded system only needs to read and write the files in RAMDISK, thus improving the reading and writing speed of the embedded system and improving the response speed of the system.
可选的,第一同步单元21和第二同步单元23可以由一个同步单元实现,不受限制。Optionally, the
可选的,第二同步单元23,具体可以用于对所述inotify注册后或者所述dnotify注册后的文件进行读操作,或者写操作,或者移动操作,或者删除操作,所述inotify注册后或者所述dnotify注册后的所述文件被修改,或者被移动、或者被删除时,将发生变化的所述RAMDISK中的文件同步到所述flash中。Optionally, the
本发明实施例的文件同步装置,还可以包括:The file synchronization device of the embodiment of the present invention may also include:
划分单元,用于根据文件被修改的频度特性及文件用途,将所述flash中的文件划分为日志类型文件以及配置类型文件,所述日志类型文件被修改的频度大于所述配置类型文件被修改的频度,所述日志类型文件用于记录日志,所述配置类型文件用于应用程序加载所需环境的设置。以及,The division unit is used to divide the files in the flash into log type files and configuration type files according to the frequency characteristics and file usages of the files being modified, and the frequency of modification of the log type files is greater than that of the configuration type files Modified frequency, the log type file is used to record logs, and the configuration type file is used to set the environment required for application loading. as well as,
备份单元,用于对于所述配置类型文件,将flash中的文件进行备份,得到对应的主文件和备份文件。The backup unit is configured to back up the files in the flash for the configuration type files to obtain corresponding main files and backup files.
可选的,对于配置类型文件,第一同步单元21,具体可以用于:Optionally, for configuration type files, the
根据flash中主文件的CRC值或者MD5值判断所述主文件的合法性,当所述主文件合法时,将所述主文件同步到RAMDISK中以及同步到所述备份文件中;Judging the legality of the main file according to the CRC value or the MD5 value of the main file in the flash, when the main file is legal, synchronizing the main file into RAMDISK and synchronizing into the backup file;
当所述主文件不合法时,根据flash中备份文件的CRC值或者MD5值判断所述flash中备份文件的合法性,当所述备份文件合法时,将所述备份文件同步到RAMDISK中以及同步到所述主文件中。When the main file is illegal, judge the validity of the backup file in the flash according to the CRC value or the MD5 value of the backup file in the flash, and when the backup file is legal, synchronize the backup file into RAMDISK and synchronize into the main file.
其中,CRC值或者MD5值可以包括:初始设CRC值或者MD5值,或者更新CRC值或者MD5值。Wherein, the CRC value or the MD5 value may include: initially setting the CRC value or the MD5 value, or updating the CRC value or the MD5 value.
进一步的,可选的,对于配置类型文件,第二同步单元23,具体可以用于:Further, optionally, for configuration type files, the
根据CRC算法或者MD5,计算发生变化的RAMDISK中的文件的更新CRC值或者MD5值;According to the CRC algorithm or MD5, calculate the updated CRC value or MD5 value of the file in the changed RAMDISK;
先将所述更新CRC值或者MD5值同步给所述flash中主文件,再将所述发生变化的所述RAMDISK中的文件同步到所述flash中对应的主文件;First synchronizing the updated CRC value or MD5 value to the main file in the flash, and then synchronizing the changed file in the RAMDISK to the corresponding main file in the flash;
先将所述更新CRC值或者MD5值同步给所述flash中备份文件,再将所述发生变化的所述RAMDISK中的文件同步到所述flash中对应的备份文件。Synchronize the updated CRC value or MD5 value to the backup file in the flash, and then synchronize the changed file in the RAMDISK to the corresponding backup file in the flash.
本发明实施例的文件同步装置及其构成,可以对应参考上述实施例的文件同步方法的相关内容得以理解,在此不作赘述。The file synchronization device and its configuration in the embodiment of the present invention can be understood by correspondingly referring to the relevant content of the file synchronization method in the above embodiment, and details are not described here.
本发明实施例提供一种文件同步系统,包括同步单元、flash以及RAMDISK,所述同步单元用于,将flash中的文件同步到RAMDISK中,并对所述RAMDISK中的文件进行inotify注册或者dnotify注册;LINUX嵌入式系统的应用程序对所述inotify注册后或者所述dnotify注册后的RAMDISK中的文件进行操作,当所述inotify注册后或者所述dnotify注册后的所述RAMDISK中的文件发生变化时,将发生变化的所述RAMDISK中的文件同步到所述flash中。The embodiment of the present invention provides a file synchronization system, including a synchronization unit, flash and RAMDISK, the synchronization unit is used to synchronize the files in the flash to the RAMDISK, and perform inotify registration or dnotify registration on the files in the RAMDISK ; The application program of the LINUX embedded system operates the files in the RAMDISK after the inotify registration or the dnotify registration, when the files in the RAMDISK after the inotify registration or the dnotify registration change , synchronizing the changed files in the RAMDISK to the flash.
本发明实施例的文件同步系统,不改变LINUX嵌入式系统的应用程序的读写文件方式的情况下,使用LINUX内核inotify或dnotify文件通知机制,把RAMDISK中的文件和flash中的文件映射起来,嵌入式系统的应用程序只需要读写RAMDISK中的文件,从而提高了嵌入式系统的读写速度,提高了系统的响应速度。The file synchronous system of the embodiment of the present invention, under the situation that does not change the read-write file mode of the application program of LINUX embedded system, uses LINUX kernel inotify or dnotify file notification mechanism, the file in RAMDISK and the file in flash are mapped together, The application program of the embedded system only needs to read and write the files in RAMDISK, thus improving the reading and writing speed of the embedded system and improving the response speed of the system.
本发明实施例提供一种文件同步方法,为了提高嵌入式系统的响应速度和用户体验度,在不改变嵌入式系统的应用程序的读写文件方式的情况下,增加一个同步单元,使用LINUX内核inotify或dnotify文件通知机制,把RAMDISK中的文件和flash中的文件映射起来,嵌入式系统的应用程序只需要读写RAMDISK中的文件,从而提高了嵌入式系统的读写速度,提高了系统的响应速度。The embodiment of the present invention provides a file synchronization method. In order to improve the response speed and user experience of the embedded system, without changing the way of reading and writing files of the application program of the embedded system, a synchronization unit is added, and the LINUX kernel is used. The inotify or dnotify file notification mechanism maps the files in RAMDISK and the files in flash, and the application program of the embedded system only needs to read and write the files in RAMDISK, thereby improving the read and write speed of the embedded system and improving the system performance. responding speed.
如图3所示,本发明实施例的文件同步方法,包括:As shown in Figure 3, the file synchronization method of the embodiment of the present invention includes:
31、启动LINUX嵌入式系统。31. Start the LINUX embedded system.
启动LINUX嵌入式系统,由于同步单元必须在其他进程启动前,把flash中的文件同步到RAMDISK。因此,可以使用进程锁,防止其他进程在读取不到RAMDISK中文件的情况下启动,造成不可预知的错误,直到同步单元把flash中的文件同步到RAMDISK中,才能释放进程锁,让其他进程启动。Start the LINUX embedded system, because the synchronization unit must synchronize the files in the flash to the RAMDISK before other processes start. Therefore, process locks can be used to prevent other processes from starting without reading the files in RAMDISK, causing unpredictable errors. The process locks cannot be released until the synchronization unit synchronizes the files in flash to RAMDISK, allowing other processes start up.
32、将flash中的文件同步到RAMDISK中。32. Synchronize files in flash to RAMDISK.
同步单元通过读取配置文件来确定文件的类型,进而确定将flash中的哪些文件同步到RAMDISK中。The synchronization unit determines the type of the file by reading the configuration file, and then determines which files in the flash are to be synchronized into the RAMDISK.
示例性的,配置文件的ProtectType字段中“LOG”表示“日志类型”,“CONF”表示“配置类型”。Exemplarily, "LOG" in the ProtectType field of the configuration file indicates "log type", and "CONF" indicates "configuration type".
示例性的,表1:Exemplary, Table 1:
如图4所示,对于日志类型,将flash中的文件同步到RAMDISK中,具体是:直接是把flash中相应的文件,同步到RAMDISK中。As shown in Figure 4, for the log type, the files in the flash are synchronized to the RAMDISK, specifically: the corresponding files in the flash are directly synchronized to the RAMDISK.
如图5所示,对于配置类型,将flash中的文件同步到RAMDISK中,具体是:As shown in Figure 5, for the configuration type, synchronize the files in flash to RAMDISK, specifically:
51、判断master文件的合法性。51. Determine the legality of the master file.
如通过CRC算法或者MD5来判断master文件的合法性,如果master文件合法,进入52,如果master文件不合法,进入53。For example, the validity of the master file is judged by CRC algorithm or MD5, if the master file is legal, go to 52, if the master file is not legal, go to 53.
52、如果master文件合法,则把master文件同步到RAMDISK中,同时更新backup文件。52. If the master file is valid, synchronize the master file to RAMDISK and update the backup file at the same time.
如把master文件同步到RAMDISK中,同时更新backup文件,以及更新backup文件的CRC值或者MD5值。For example, synchronize the master file to RAMDISK, update the backup file at the same time, and update the CRC value or MD5 value of the backup file.
53、如果master文件不合法,判断backup文件的合法性。53. If the master file is illegal, judge the validity of the backup file.
如通过CRC算法或者MD5来判断backup文件的合法性,如果backup文件合法,进入54,如果backup文件不合法,进入异常处理。For example, the validity of the backup file is judged by the CRC algorithm or MD5. If the backup file is legal, enter 54. If the backup file is invalid, enter exception processing.
54、如果backup文件合法,则把backup文件同步到RAMDISK中,同时更新master文件。54. If the backup file is valid, synchronize the backup file to RAMDISK and update the master file at the same time.
如把backup文件同步到RAMDISK中,同时更新master文件,以及更新master文件的CRC值或者MD5值。For example, synchronize the backup file to RAMDISK, update the master file at the same time, and update the CRC value or MD5 value of the master file.
之后,将flash中的文件同步到RAMDISK后,需要释放进程锁,让其他进程启动。After that, after synchronizing the files in flash to RAMDISK, you need to release the process lock to allow other processes to start.
33、Inotify或dnotify注册RAMDISK中的文件。33. Inotify or dnotify registers files in RAMDISK.
调用LINUX内核inotify或dnotify的API(Application Programming Interface,应用程序编程接口),进行Inotify或dnotify注册RAMDISK中的文件。Call the API (Application Programming Interface, application programming interface) of LINUX kernel inotify or dnotify, and perform Inotify or dnotify to register the file in RAMDISK.
Inotify或dnotify注册RAMDISK中的文件,可以参考现有技术得以理解,在此不作赘述。Inotify or dnotify registers the files in the RAMDISK, which can be understood by referring to the prior art, and will not be described in detail here.
34、收到LINUX内核inotify或dnotify通知RAMDISK中文件有变化。34. Receive a notification from the LINUX kernel inotify or dnotify that the file in RAMDISK has changed.
使用LINUX内核inotify或dnotify的API,确定RAMDISK中文件有变化。Use the API of LINUX kernel inotify or dnotify to determine that the files in RAMDISK have changed.
收到LINUX内核inotify或dnotify通知RAMDISK中文件有变化,可以参考现有技术得以理解,在此不作赘述。Receive the Linux kernel inotify or dnotify notice that the files in the RAMDISK have changed, which can be understood by referring to the existing technology, and will not be repeated here.
35、将RAMDISK中有变化的文件同步到flash中。35. Synchronize the changed files in RAMDISK to flash.
如图6所示,对于日志类型,使用增量同步的方式,把RAMDISK中的文件同步到flash中。As shown in Figure 6, for the log type, use incremental synchronization to synchronize files in RAMDISK to flash.
如图7所示,对于配置类型,把RAMDISK中的文件同步到flash中,包括:As shown in Figure 7, for the configuration type, synchronize the files in RAMDISK to flash, including:
71、通过CRC算法或者MD5计算RAMDISK中的文件的更新CRC值或者MD5值。71. Calculate the updated CRC value or MD5 value of the file in RAMDISK through CRC algorithm or MD5.
72、先将更新CRC值或者MD5值同步给flash中主文件,再RAMDISK中的文件同步到flash中对应的主文件。72. First synchronize the updated CRC value or MD5 value to the main file in the flash, and then synchronize the file in RAMDISK to the corresponding main file in the flash.
73、先将更新CRC值或者MD5值同步给flash中备份文件,再将RAMDISK中的文件同步到flash中对应的备份文件。73. Synchronize the updated CRC value or MD5 value to the backup file in flash, and then synchronize the file in RAMDISK to the corresponding backup file in flash.
下面以LINUX嵌入式系统flash中umconfig.tx为例,对配置类型的文件同步进行简单说明:The following takes umconfig.tx in the flash of the LINUX embedded system as an example to briefly explain the file synchronization of the configuration type:
LINUX嵌入式系统初始上电启动时,flash中umconfig.txt的master文件和backup文件的MD5值都是11223344,master文件合法,将master文件同步到RAMDISK中。When the LINUX embedded system is initially powered on and started, the MD5 values of the master file and the backup file in umconfig.txt in the flash are both 11223344, and the master file is legal. Synchronize the master file to RAMDISK.
当RAMDISK中的umconfig.txt被修改时,计算RAMDISK中的umconfig.txt的MD5值,如,MD5值为55667788。更新flash中umconfig.txt的master文件的MD5值为55667788,并将RAMDISK中的umconfig.txt更新到flash中umconfig.txt的master文件。更新flash中umconfig.txt的backup文件的MD5值为55667788,并将RAMDISK中的umconfig.txt更新到flash中umconfig.txt的backup文件。此时,flash中umconfig.txt的master文件和backup文件的MD5值都是55667788。When umconfig.txt in RAMDISK is modified, calculate the MD5 value of umconfig.txt in RAMDISK, for example, the MD5 value is 55667788. Update the MD5 value of the master file of umconfig.txt in the flash to 55667788, and update the umconfig.txt in RAMDISK to the master file of umconfig.txt in the flash. Update the MD5 value of the umconfig.txt backup file in the flash to 55667788, and update the umconfig.txt in the RAMDISK to the umconfig.txt backup file in the flash. At this time, the MD5 values of the master file and the backup file of umconfig.txt in the flash are both 55667788.
如果将RAMDISK中的umconfig.txt更新到flash中umconfig.txt的master文件过程中,LINUX嵌入式系统突然掉电,则会导致flash中umconfig.txt的master文件的MD5值为55667788,但是flash中umconfig.txt的master文件的内容不完整,而flash中umconfig.txt的backup文件的内容是完整的,backup文件的MD5值仍为11223344。If the LINUX embedded system suddenly loses power during the process of updating umconfig.txt in RAMDISK to the master file of umconfig.txt in flash, the MD5 value of the master file in umconfig.txt in flash will be 55667788, but the umconfig in flash The content of the .txt master file is incomplete, but the content of the umconfig.txt backup file in the flash is complete, and the MD5 value of the backup file is still 11223344.
那么,LINUX嵌入式系统重新上电启动时,根据MD5值为55667788判断flash中umconfig.txt的master文件不合法,进而根据MD5值为11223344判断flash中umconfig.txt的backup文件合法,从而将flash中umconfig.txt的backup文件同步到RAMDISK中,并将flash中umconfig.txt的backup文件同步到flash中umconfig.txt的master文件。Then, when the LINUX embedded system is powered on again, the master file of umconfig.txt in the flash is judged to be illegal according to the MD5 value of 55667788, and the backup file of umconfig.txt in the flash is judged to be legal according to the MD5 value of 11223344. The backup file of umconfig.txt is synchronized to RAMDISK, and the backup file of umconfig.txt in flash is synchronized to the master file of umconfig.txt in flash.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAMDISK)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in a computer-readable storage medium. During execution, it may include the processes of the embodiments of the above-mentioned methods. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAMDISK), etc.
Claims (11)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2011103868296A CN102521289B (en) | 2011-11-29 | 2011-11-29 | File synchronization method, device and system |
PCT/CN2012/078911 WO2013078870A1 (en) | 2011-11-29 | 2012-07-20 | File synchronization method, device and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2011103868296A CN102521289B (en) | 2011-11-29 | 2011-11-29 | File synchronization method, device and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102521289A true CN102521289A (en) | 2012-06-27 |
CN102521289B CN102521289B (en) | 2013-12-04 |
Family
ID=46292210
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2011103868296A Expired - Fee Related CN102521289B (en) | 2011-11-29 | 2011-11-29 | File synchronization method, device and system |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN102521289B (en) |
WO (1) | WO2013078870A1 (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2013078870A1 (en) * | 2011-11-29 | 2013-06-06 | 华为技术有限公司 | File synchronization method, device and system |
CN103699846A (en) * | 2013-12-25 | 2014-04-02 | 浪潮(北京)电子信息产业有限公司 | Method and device for intercepting changed files in LINUX system |
CN103384266B (en) * | 2013-06-07 | 2016-12-28 | 曙光信息产业(北京)有限公司 | A kind of Parastor200 based on file-level real-time synchronization manages node high availability method |
CN106575233A (en) * | 2014-08-27 | 2017-04-19 | 惠普发展公司,有限责任合伙企业 | Portable storage device |
CN106850818A (en) * | 2013-11-08 | 2017-06-13 | 北京奇虎科技有限公司 | Real time data synchronization method and system |
CN106933695A (en) * | 2017-02-28 | 2017-07-07 | 武汉斗鱼网络科技有限公司 | A kind of method of calibration and system of SWF files |
CN107850883A (en) * | 2015-12-31 | 2018-03-27 | 深圳配天智能技术研究院有限公司 | A kind of system processing method and digital control system |
CN108762986A (en) * | 2018-05-24 | 2018-11-06 | 四川斐讯信息技术有限公司 | A kind of method and system for preventing abnormal power-down from leading to configuration loss |
WO2020069168A1 (en) * | 2018-09-27 | 2020-04-02 | Landis+Gyr Innovations, Inc. | Validation and installation of a file system into a transient, non-persistent storage circuit |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20040048713A (en) * | 2002-12-04 | 2004-06-10 | 엘지전자 주식회사 | Output Synchronization Method For Configuration Information Among The Network Element Manager |
US6847983B2 (en) * | 2001-02-28 | 2005-01-25 | Kiran Somalwar | Application independent write monitoring method for fast backup and synchronization of open files |
CN1912834A (en) * | 2005-08-09 | 2007-02-14 | C&S技术有限公司 | Multimedia program download control system and method of apparatus equipped with multimedia processor |
CN101004690A (en) * | 2007-01-09 | 2007-07-25 | 京信通信技术(广州)有限公司 | Integrative method for updating load program and application program in embedded type system |
WO2009125027A1 (en) * | 2008-04-11 | 2009-10-15 | Microelectronica Española S.A.U. | Method for accessing a storage system with multiple file systems |
CN102073561A (en) * | 2011-01-26 | 2011-05-25 | 浪潮电子信息产业股份有限公司 | Method for correcting error of write operation of solid state hard disk |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR100389867B1 (en) * | 2001-06-04 | 2003-07-04 | 삼성전자주식회사 | Flash memory management method |
CN1186728C (en) * | 2001-07-03 | 2005-01-26 | 联想(北京)有限公司 | Method for managing flash memory files |
US20060184719A1 (en) * | 2005-02-16 | 2006-08-17 | Sinclair Alan W | Direct data file storage implementation techniques in flash memories |
CN100449549C (en) * | 2007-09-30 | 2009-01-07 | 浙江大学 | Method for establishing file system on NAND Flash memory in embedded system |
CN201698426U (en) * | 2010-07-29 | 2011-01-05 | 郑州新开普电子股份有限公司 | File system management module based on FRAM and Flash |
CN102521289B (en) * | 2011-11-29 | 2013-12-04 | 华为技术有限公司 | File synchronization method, device and system |
-
2011
- 2011-11-29 CN CN2011103868296A patent/CN102521289B/en not_active Expired - Fee Related
-
2012
- 2012-07-20 WO PCT/CN2012/078911 patent/WO2013078870A1/en active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6847983B2 (en) * | 2001-02-28 | 2005-01-25 | Kiran Somalwar | Application independent write monitoring method for fast backup and synchronization of open files |
KR20040048713A (en) * | 2002-12-04 | 2004-06-10 | 엘지전자 주식회사 | Output Synchronization Method For Configuration Information Among The Network Element Manager |
CN1912834A (en) * | 2005-08-09 | 2007-02-14 | C&S技术有限公司 | Multimedia program download control system and method of apparatus equipped with multimedia processor |
CN101004690A (en) * | 2007-01-09 | 2007-07-25 | 京信通信技术(广州)有限公司 | Integrative method for updating load program and application program in embedded type system |
WO2009125027A1 (en) * | 2008-04-11 | 2009-10-15 | Microelectronica Española S.A.U. | Method for accessing a storage system with multiple file systems |
CN102073561A (en) * | 2011-01-26 | 2011-05-25 | 浪潮电子信息产业股份有限公司 | Method for correcting error of write operation of solid state hard disk |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2013078870A1 (en) * | 2011-11-29 | 2013-06-06 | 华为技术有限公司 | File synchronization method, device and system |
CN103384266B (en) * | 2013-06-07 | 2016-12-28 | 曙光信息产业(北京)有限公司 | A kind of Parastor200 based on file-level real-time synchronization manages node high availability method |
CN106850818A (en) * | 2013-11-08 | 2017-06-13 | 北京奇虎科技有限公司 | Real time data synchronization method and system |
CN106850818B (en) * | 2013-11-08 | 2020-02-18 | 北京奇虎科技有限公司 | Data real-time synchronization method and system |
CN103699846A (en) * | 2013-12-25 | 2014-04-02 | 浪潮(北京)电子信息产业有限公司 | Method and device for intercepting changed files in LINUX system |
CN106575233A (en) * | 2014-08-27 | 2017-04-19 | 惠普发展公司,有限责任合伙企业 | Portable storage device |
CN107850883A (en) * | 2015-12-31 | 2018-03-27 | 深圳配天智能技术研究院有限公司 | A kind of system processing method and digital control system |
CN107850883B (en) * | 2015-12-31 | 2020-07-28 | 深圳配天智能技术研究院有限公司 | A system processing method and numerical control system |
CN106933695A (en) * | 2017-02-28 | 2017-07-07 | 武汉斗鱼网络科技有限公司 | A kind of method of calibration and system of SWF files |
CN106933695B (en) * | 2017-02-28 | 2020-06-16 | 武汉斗鱼网络科技有限公司 | A SWF file verification method and system |
CN108762986A (en) * | 2018-05-24 | 2018-11-06 | 四川斐讯信息技术有限公司 | A kind of method and system for preventing abnormal power-down from leading to configuration loss |
WO2020069168A1 (en) * | 2018-09-27 | 2020-04-02 | Landis+Gyr Innovations, Inc. | Validation and installation of a file system into a transient, non-persistent storage circuit |
US11574055B2 (en) | 2018-09-27 | 2023-02-07 | Landis+Gyr Innovations, Inc. | Validation and installation of a file system |
Also Published As
Publication number | Publication date |
---|---|
CN102521289B (en) | 2013-12-04 |
WO2013078870A1 (en) | 2013-06-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102521289B (en) | File synchronization method, device and system | |
US9134914B1 (en) | Deduplication | |
CN106569738B (en) | A kind of method and device for deleting cascade snapshot | |
US10929176B2 (en) | Method of efficiently migrating data from one tier to another with suspend and resume capability | |
WO2015107666A1 (en) | Storage apparatus and cache control method for storage apparatus | |
US10120595B2 (en) | Optimizing backup of whitelisted files | |
US10649807B1 (en) | Method to check file data integrity and report inconsistencies with bulk data movement | |
US9749193B1 (en) | Rule-based systems for outcome-based data protection | |
US9361301B1 (en) | Detecting modifications to a storage that occur in an alternate operating environment | |
WO2017008648A1 (en) | Cluster switching method and equipment | |
CN107463467A (en) | A kind of method and system that can quickly reduce virtual platform | |
CN107992763B (en) | Power failure protection method and device for file system | |
CN112115515A (en) | Data protection method and device, electronic equipment and storage medium | |
CN113467698A (en) | Writing method and device based on file system, computer equipment and storage medium | |
US20070156778A1 (en) | File indexer | |
CN105653718A (en) | Method for ensuring database data consistency after snapshot in storage disk snapshot environment | |
US10423494B2 (en) | Trimming unused blocks from a versioned image backup of a source storage that is stored in a sparse storage | |
US11514002B2 (en) | Indexing splitter for any pit replication | |
US20140222876A1 (en) | File system extended attribute support in an operating system with restricted extended attributes | |
US9830471B1 (en) | Outcome-based data protection using multiple data protection systems | |
JP2009282604A (en) | Duplicated data exclusion system, duplicated data exclusion method, and duplicated data exclusion program | |
US11762756B2 (en) | System and method for startup data verification | |
US20230350765A1 (en) | Data replication using an extended file replication protocol | |
US10372683B1 (en) | Method to determine a base file relationship between a current generation of files and a last replicated generation of files | |
CN110543460B (en) | A data synchronization method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20170607 Address after: 510640 Guangdong City, Tianhe District Province, No. five, road, public education building, unit 371-1, unit 2401 Patentee after: Guangdong Gaohang Intellectual Property Operation Co., Ltd. Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen Patentee before: Huawei Technologies Co., Ltd. |
|
CB03 | Change of inventor or designer information | ||
CB03 | Change of inventor or designer information |
Inventor after: Li Fei Inventor before: Zhang Jinyi Inventor before: Zhang Yu |
|
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20171010 Address after: 061000, 2, 4 unit 301, Huabei oil first refinery District, Renqiu, Cangzhou, Hebei Patentee after: Li Fei Address before: 510640 Guangdong City, Tianhe District Province, No. five, road, public education building, unit 371-1, unit 2401 Patentee before: Guangdong Gaohang Intellectual Property Operation Co., Ltd. |
|
CP02 | Change in the address of a patent holder | ||
CP02 | Change in the address of a patent holder |
Address after: 541002 No. two, No. 5, West Road, Xiangshan District, Guilin, the Guangxi Zhuang Autonomous Region Patentee after: Li Fei Address before: 061000, 2, 4 unit 301, Huabei oil first refinery District, Renqiu, Cangzhou, Hebei Patentee before: Li Fei |
|
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20131204 Termination date: 20171129 |