Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we support O_EXCL emulation (for old NFS mounts)? #4

Open
vtjnash opened this issue Nov 26, 2019 · 0 comments
Open

Should we support O_EXCL emulation (for old NFS mounts)? #4

vtjnash opened this issue Nov 26, 2019 · 0 comments

Comments

@vtjnash
Copy link
Owner

vtjnash commented Nov 26, 2019

On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

I say no, since this has been available since June 1995, and the lockfile mechanism is necessarily always best-effort anyways (especially if you get the network involved).

source: O_EXCL https://linux.die.net/man/2/open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant