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?
-
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– Random8322012-10-17 15:14:18 +00:00Commented Oct 17, 2012 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– Didi Kohen2012-10-21 16:19:14 +00:00Commented Oct 21, 2012 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– ckhan2012-10-25 23:31:14 +00:00Commented Oct 25, 2012 at 23:31
-
Across a networkKnut Saua– Knut Saua2012-11-01 12:18:37 +00:00Commented Nov 1, 2012 at 12:18
Add a comment
|
1 Answer
I don't know if it is enabled or disabled by default, but mkdir can be cached:
https://sourceforge.net/p/fuse/_list/git (cache_mkdir)
Even though the mkdir command itself looks atomic and thread safe enough...
https://sourceforge.net/p/fuse/_list/git (sshfs_mkdir)
https://sourceforge.net/p/fuse/_list/git (sftp_request_send)
I would go out on a limb and say that mkdir over sshfs is not atomic, because of the caching.