本文介绍了Linux ext3 readdir和并发更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我们每小时收到大约10000条消息.我们将它们作为单个文件存储在ext3文件系统上的每小时目录中.文件名包含序列号.我们使用rsync每20秒在另一个位置镜像这些文件(通过SAN,但这没关系).

we are receiving about 10000 messages per hour. We store them as individual files in hourly directories on an ext3 filesystem. The file name includes a sequence number. We use rsync to mirror these files every 20 seconds at another location (via a SAN, but that doesn't matter).

有时rsync运行会拾取文件n-3,n-2,n-1,n + 1,然后下一次rsync运行会继续运行n,n + 2,n + 3,n + 4,依此类推.

Sometimes an rsync run picks up files n-3, n-2, n-1, n+1, and then next rsync run continues with n, n+2, n+3, n+4 and so on.

当一个进程在目录中以特定顺序创建文件时,是否有另一个进程使用readdir()看到文件以不同顺序出现?

Is it possible that when one process creates files in a certain sequence within a directory, that another process using readdir() sees the files appearing in a different sequence?

亲切的问候,塞巴斯蒂安

Kind regards,Sebastian

推荐答案

我想您的问题可以重述为:

I suppose your question can be restated as:

答案是肯定的. readdir的排序保证确实非常弱.

The answer is Yes. The ordering guarantees for readdir are very weak indeed.

如果要强制执行排序,则在创建每个文件后,需要为目录d本身显式地fsync()一个文件描述符.

If you want to enforce an ordering, you will need to explicitly fsync() a file descriptor for the directory d itself after creating each file.

这篇关于Linux ext3 readdir和并发更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-09 01:15