Linux ext3 readdir and concurrent updates

寵の児 提交于 2019-12-11 11:09:50

问题


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).

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.

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


回答1:


I suppose your question can be restated as:

If process A creates file d/x and then creates file d/y, is it possible for process B to peform a concurrent readdir() on directory d and see an entry d/y, but not see an entry d/x?

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

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.



来源:https://stackoverflow.com/questions/2928459/linux-ext3-readdir-and-concurrent-updates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!