Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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 '12 at 15:14
    
It is atomic via NFS, but since clients cache the directory structures, it cannot be counted on as a locking mechanism. –  David 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 1 '12 at 12:18
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.