6

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?

4
  • 1
    What 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, 2012 at 15:14
  • 1
    It is atomic via NFS, but since clients cache the directory structures, it cannot be counted on as a locking mechanism.
    – Didi Kohen
    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
    Oct 25, 2012 at 23:31
  • Across a network
    – Knut Saua
    Nov 1, 2012 at 12:18

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .