假设为POSIX系统,使用write()系统调用执行两次写操作A和B,假设A在B前执行。无论A和B是否是对同一个文件/位置进行写操作,A和B的实际持久化顺序没有约束,即A不一定在B前持久化。

POSIX标准关于write()的行为约束是:

write

After a write() to a regular file has successfully returned:

  • Any successful read() from each byte position in the file that was modified by that write shall return the data specified by the write() for that position until such byte positions are again modified.

  • Any subsequent successful write() to the same byte position in the file shall overwrite that file data.

上述标准只对程序观测到的行为进行了约束,但并没有限制写的顺序。实际上在内核以及文件系统层级都有可能对写进行重排,并且有缓存机制。

只有使用fsync等才可以保证持久化的顺序。

  • PMEM 如果和持久内存比较的话很相似;都存在缓存导致的不确定写回,从而使得在崩溃情况下可能产生非一致的结果。
  • 崩溃一致性
  • Strict Persistency 显然不是强持久模型