免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3001 | 回复: 3
打印 上一主题 下一主题

[Linux] 问:O_SYNC与fsync系统调用的区别与联系 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-12-02 08:59 |只看该作者 |倒序浏览
      O_SYNC是每次write系统调用后都等待实际的物理I/O完成。而fsync也是会等待物理I/O完成后才返回。apue上是这样写的,但我没有明白:Compare fsync and fdatasync,which update a file's contents when we say so,with the O_SYNC flag,which updates a file's contents every time we write to the file. 我不明白这里的"fsync which update a file's contents when we say so"到底是什么意思。O_SYNC和fsync之间有什么样的区别和联系?这样的问题我没有办法去写程序实践。 小弟想请教大家,非常感谢!

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
2 [报告]
发表于 2012-12-02 18:25 |只看该作者
  1.        POSIX  provides  for three different variants of synchronized I/O, corresponding to the flags O_SYNC, O_DSYNC, and O_RSYNC.  Currently (2.6.31),
  2.        Linux only implements O_SYNC, but glibc maps O_DSYNC and O_RSYNC to the same numerical value as O_SYNC.  Most Linux file systems don’t  actually
  3.        implement  the  POSIX  O_SYNC  semantics,  which  require  all metadata updates of a write to be on disk on returning to userspace, but only the
  4.        O_DSYNC semantics, which require only actual file data and metadata necessary to retrieve it to be on disk by the time the system call  returns.
复制代码
  1.        Calling fsync() does not necessarily ensure that the entry in the directory containing the file has also reached disk.   For  that  an  explicit
  2.        fsync() on a file descriptor for the directory is also needed.
复制代码

论坛徽章:
0
3 [报告]
发表于 2012-12-02 21:38 |只看该作者
回复 2# linux_c_py_php
您好,我无法理解这两句话的因果关系“Calling fsync() does not necessarily ensure that the entry in the directory containing the file has also reached disk.   For  that  an  explicit
       fsync() on a file descriptor for the directory is also needed.”请问,为什么"无法确保该条目是否写入磁盘就会导致需要对目录来调用fsync"?或者是我的翻译有误?


   

论坛徽章:
0
4 [报告]
发表于 2012-12-04 12:21 来自手机 |只看该作者
一个是原语,一个不是。我猜的。别喷。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP