EXT4的data = journal模式能否避免用户数据丢失? [英] Can the data=journal mode of EXT4 avoid user data loss?

查看:104
本文介绍了EXT4的data = journal模式能否避免用户数据丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 新闻模式

data = journal模式提供了完整的数据和元数据日志记录.全新数据首先写入日志,然后再写入最终位置.

data=journal mode provides full data and metadata journaling. All new data is written to the journal first, and then to its final location.

万一发生崩溃,可以重播日志,将两者数据和元数据进入一致状态.此模式最慢除非需要同时从磁盘读取数据和将数据写入磁盘胜过其他所有模式的时间.启用此模式将禁用延迟分配和O_DIRECT支持.

In the event of a crash, the journal can be replayed, bringing both data and metadata into a consistent state. This mode is the slowest except when data needs to be read from and written to disk at the same time where it outperforms all others modes. Enabling this mode will disable delayed allocation and O_DIRECT support.

我在这里有几个问题,请看一下:

Here I have a few questions, please take a look at it:

  1. 配置data = journal,然后用户调用write(),在数据成功写入日志后是否返回write(),还是在进入页面缓存后返回用户成功?如果是后者,则意味着日志是异步提交的,因此ext4日志的含义是确保文件系统本身的一致性,并且不能保证用户数据不会丢失?

  1. Configure data=journal, then the user calls write(), does the write() return after the data is successfully written to the journal, or does it return the user success after entering the pagecache? If it is the latter, it means that the journal is submitted asynchronously, so the meaning of the journal of ext4 is to ensure the consistency of the file system itself, and there is no guarantee that user data will not be lost?

如果ext4异步提交日记,那么何时触发日记?

If ext4 submits the journal asynchronously, when will the journal be triggered?

是否有其他文件系统允许日记在write()成功返回之前进行同步?

Is there any other file system that allows the journal to be synchronized before write() returns successfully?

根据我的本地实验结果,可以推断该期刊应异步提交.我使用了一个单独的ssd分区作为journal_dev.当我使用fio测试和写入文件时,我发现journal_dev的io是断断续续的,并不总是有IO.

According to the results of my local experiments, it is inferred that the journal should be submitted asynchronously. I used a separate ssd partition as journal_dev. When I used fio to test and write files, I found that the io of journal_dev was intermittent, not always having IO.

推荐答案

  1. write()进入页面缓存后将返回用户成功(假设您未在 open()上使用任何其他选项).
  2. 至少定期(请参见commit = " rel ="nofollow noreferrer">https://www.kernel.org/doc/Documentation/filesystems/ext4.txt ),并且可能在允许任何未完成的 sync / fsync 等之前完成.
  3. 否(否则,它将使缓冲失效).
  1. the write() will return the user success after it has entered the page cache (assuming you aren't using any extra options on open()).
  2. At least periodically (see commit= in https://www.kernel.org/doc/Documentation/filesystems/ext4.txt ) and probably before any pending sync/fsync etc are allowed to complete.
  3. No (otherwise it would defeat the point of buffering).

如果您要传递 O_SYNC open()或执行其他

If you were to pass O_SYNC to open() or to do an additional fsync you will learn about when your write made it to stable media as far as the kernel can know.

这篇关于EXT4的data = journal模式能否避免用户数据丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆