Coder Social home page Coder Social logo

Reliable over NFS? about filelock HOT 3 CLOSED

tox-dev avatar tox-dev commented on August 31, 2024 1
Reliable over NFS?

from filelock.

Comments (3)

moi90 avatar moi90 commented on August 31, 2024 1

SoftFileLock uses O_WRONLY | O_CREAT | O_EXCL | O_TRUNC.

According to man open:

O_CREAT: If pathname does not exist, create it as a regular file.
O_EXCL: Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() fails with the error EEXIST.
On NFS, O_EXCL is supported only when using NFSv3 or later on kernel 2.6 or later.

This is in compliance with the NFS FAQ D10:

It's worth noting that until early 2.6 kernels, O_EXCL creates were not atomic on Linux NFS clients. Don't use O_EXCL creates and expect atomic behavior among multiple NFS client unless you are running a kernel newer than 2.6.5.

So the answer should be: Yes, on modern systems.

What is the reason for O_TRUNC? It seems to be superfluous, because O_CREAT | O_EXCL prevent the file from being opened if it exists.

O_TRUNC: If the file already exists and is a regular file and the access mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

from filelock.

andyneff avatar andyneff commented on August 31, 2024 1

I tested this on lusterfs and nfs both the lock mount flag enabled and disabled, and "unit tests passed". I do not know enough if this answers any of the reliability questions, but if the tests are good enough, this might be enough to verify it works on "RHEL 7" modern.

from filelock.

moi90 avatar moi90 commented on August 31, 2024

Great! Then I think this can be closed.

from filelock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.