【问题标题】:Solaris - Synchronous Disk Flush/Synchronous Sync?Solaris - 同步磁盘刷新/同步同步?
【发布时间】:2012-11-06 09:32:05
【问题描述】:

在 Solaris 上进行同步磁盘刷新的最佳方法是什么?我想刷新所有磁盘,而不是单个文件。

Solaris(与 Linux 相对)上的 Sync() 异步工作,我正在寻找 SYNCHRONOUS sync() (完成后返回)

随之而来的问题:如何检查同步是否正确完成?我如何编写测试以显示它已完成?

谢谢!

【问题讨论】:

    标签: database solaris sync flush


    【解决方案1】:

    你可以运行:

    /usr/sbin/lockfs -af
    

    引用lockfs manual page:

    -f

         Force a synchronous flush of all data that is  dirty  at
         the  time  fsflush  is  run to its backing store for the
         named file system (or for all file systems.)
    
         It is a more reliable method than using sync(1M) because
         it  does  not  return  until  all possible data has been
         pushed.
    

    如果你想纯粹用 C 来做,你可以使用

      #include <sys/filio.h>
      ...    
      ioctl(fd, _FIOFFS, NULL);
    

    fd 是文件系统挂载点的文件描述符(来自 /etc/mtab)。

    请注意,_FIOFFS 是一个私有接口,因此可能随时消失,恕不另行通知。一种完全受支持且更强大的方法是简单地将行 system("/usr/sbin/lockfs -af"); 添加到您的代码中。

    【讨论】:

      猜你喜欢
      • 2011-11-19
      • 2012-08-09
      • 1970-01-01
      • 1970-01-01
      • 2020-02-12
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多