Linux:脏页写回和并发写 [英] Linux : dirty page writeback and concurrent write

查看:660
本文介绍了Linux:脏页写回和并发写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:在Java中,我正在映射文件(共享).

Background : in Java I'm memory mapping a file (shared).

我正在该文件的地址0写入一些值.我了解PAGE CACHE中相应的PAGE被标记为DIRTY,并将稍后根据dirty_ratio等设置写入.

I'm writing some value at the address 0 of that file. I understand the corresponding PAGE in the PAGE CACHE is flagged as DIRTY and will be written later depending on the dirty_ratio and the like settings.

到目前为止一切都很好.

So far so good.

但是我想知道当内核将脏页写回到文件中时,再次在地址0处写入时会发生什么情况.我的进程是否以某种方式被阻塞,等待写回完成?

But I'm wondering what is happening when writing once more at the address 0 while the kernel is writing back the dirty page to the file. Is my process blocked somehow waiting for the writeback to be completed?

推荐答案

可能是.仅当设备级I/O请求在写入数据旁边包含校验和时才需要.否则,第一次写入可能会被撕裂,但随后可以通过第二次写入进行纠正.

It may be. It is only necessary when the device-level I/O requests include a checksum alongside the written data. Otherwise, the first write may be torn, but it can then be corrected by the second write.

一如既往,请仔细考虑您的电源故障,内核崩溃等安全性.

As always, carefully consider your safety against power-failure, kernel crashes etc.

据称在btrfs中避免了等待. (此外,偶然地,在旧版ext3文件系统中.但不是ext4或ext2).

The waiting is allegedly avoided in btrfs. (Also, by happenstance, in the legacy ext3 filesystem. But not ext4 or ext2).

这看起来像是一个移动的目标.上面(据我所知)描述了此稳定页写入"代码的首次优化,是在首次引入该代码后提出的抱怨.提交描述提到了未来更改的几种可能性.

This looks like it is a bit of a moving target. The above (as far as I could tell) describes the first optimization of this "stable page write" code, following the complaints when it was first introduced. The commit description mentions several possibilities for future changes.

  1. bdi:允许块设备说出它们需要稳定的页面写入
  2. mm:仅在支持设备需要时强制执行稳定的页面写入
  1. bdi: allow block devices to say that they require stable page writes
  2. mm: only enforce stable page writes if the backing device requires it

我的设备当前使用稳定页写入"吗?

您可以查看一个sysfs属性,称为 stable_pages_required

这篇关于Linux:脏页写回和并发写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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