I am using mkdir as a locking mechanism, and to my knowledge mkdir is atomic, but it is not atomic over nfs. So my question is simple, is mkdir atomic over sshfs?
Asked
Active
Viewed 1,229 times
6
Knut Saua
- 61
-
1What are the actual issues over NFS? I can't find any details on this. One thing I would be suspicious of over sshfs is that it doesn't seem to provide any way to work relative to a directory handle (fchdir, mkdirat, and such), so it's by default going to rely on the full textual path of the directory you're creating a directory in. – Random832 Oct 17 '12 at 15:14
-
1It is atomic via NFS, but since clients cache the directory structures, it cannot be counted on as a locking mechanism. – Didi Kohen Oct 21 '12 at 16:19
-
I think the answer is going to depend substantially on whether you're trying to guarantee atomicity between processes on one machine or across a network. Can you clarify the use case? – ckhan Oct 25 '12 at 23:31
-
Across a network – Knut Saua Nov 01 '12 at 12:18
1 Answers
1
I don't know if it is enabled or disabled by default, but mkdir can be cached:
http://goo.gl/QIW4V (cache_mkdir)
Even though the mkdir command itself looks atomic and thread safe enough...
http://goo.gl/LC1Ze (sshfs_mkdir)
http://goo.gl/NHkNH (sftp_request_send)
I would go out on a limb and say that mkdir over sshfs is not atomic, because of the caching.
Alexander
- 9,850