O_DIRECT到底是什么意思? [英] What does O_DIRECT really mean?

查看:486
本文介绍了O_DIRECT到底是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我打开带有O_DIRECT标志的文件,是否表示每当对该文件进行写(阻塞模式)返回时,数据就在磁盘上了?

If I open a file with O_DIRECT flag, does it mean that whenever a write(blocking mode) to that file returns, the data is on disk?

推荐答案

(此答案与Linux有关-其他OS可能有不同的警告/语义)

(This answer pertains to Linux - other OSes may have different caveats/semantics)

让我们从子问题开始:

如果我打开带有O_DIRECT标志的文件,是否意味着每当对该文件进行写(阻塞模式)返回时,数据就在磁盘上了?

If I open a file with O_DIRECT flag, does it mean that whenever a write(blocking mode) to that file returns, the data is on disk?

(如 @ michael-foukarakis评论)-如果您需要保证您的数据已存储到非易失性存储中,则必须使用/添加其他内容.

No (as @michael-foukarakis commented) - if you need a guarantee your data made it to non-volatile storage you must use/add something else.

O_DIRECT到底是什么意思?

What does O_DIRECT really mean?

这是一个提示,您希望您的I/O绕过 Linux内核的缓存.实际发生的情况取决于诸如此类的东西:

It's a hint that you want your I/O to bypass the Linux kernel's caches. What will actually happen depends on things like:

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