简体   繁体   English

如果我将数据块存储在Linux PAGE_SIZE的1 / n或磁盘块大小中,mmap()可以保证崩溃时的数据完整性吗?

[英]Can mmap() guarantee the data integrity on crash, if I store data chunks in 1/n of Linux PAGE_SIZE?or disk block size?

I need to design a system with data persistent and fast reload, which is implemented with mmap() . 我需要设计一个具有数据持久性和快速重载的系统,这是用mmap() But systems using mmap() for persistence often lost data integrity on system crash, like single node MongoDB. 但是使用mmap()进行持久化的系统经常会在系统崩溃时丢失数据完整性,就像单个节点MongoDB一样。

What I have is a very flat data structure to store: data are chunked into 1024 sized blocks, no dependency between blocks. 我所拥有的是一个非常平坦的数据结构来存储:数据被分块为1024个大小的块,块之间没有依赖性。 Blocks are randomly and heavily accessed and updated during the server uptime. 在服务器正常运行期间,随机且大量访问和更新块。

You can use msync to flush mmapped data to disk. 您可以使用msync将mmapped数据刷新到磁盘。

See http://linux.die.net/man/2/msync . 请参阅http://linux.die.net/man/2/msync

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM