Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2001 14:26:11 -0800 (PST)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        Nate Williams <nate@yogotech.com>
Cc:        Marc W <mwlist@lanfear.com>, <nate@yogotech.com>, Drew Eckhardt <drew@PoohSticks.ORG>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Is mkdir guaranteed to be 'atomic' ?? 
Message-ID:  <200102262226.f1QMQBJ44997@earth.backplane.com>
References:  <200102262202.OAA39275@akira.lanfear.com> <15002.54073.668155.728179@nomad.yogotech.com>

next in thread | previous in thread | raw e-mail | index | archive | help

    (owner-freebsd-hackers removed from list)

:You're implying that you are making two calls to create the same
:directory.  Am I correct?
:
:The answer is 'maybe'?  Depends on the remote NFS server.  Matt or one
:of the other NFS gurus may know more, but I wouldn't count on *anything*
:over NFS.  If you need atomicity, you need lockd, which isn't
:implemented on FreeBSD.
:
:Nate
    
    There are a couple of issues here.  First, I'm fairly sure that the
    NFS server side implementation of mkdir() does *not* guarentee that
    the operation will be synced to permanent storage on the server side
    before returning.  So if the NFS server crashes and reboots, the
    just-created directory could disappear.

    Second, in regards to several clients trying to mkdir() at the same
    time: mkdir() does not use the same semantics as an O_EXCL file
    create.  This means that *normally* only one of the two clients
    will succeed in the mkdir() call.  However, under certain circumstances
    (e.g. a server reboot or possibly packet loss / NFS retry) it is possible
    for the directory to be created yet for *both* client's mkdir() calls
    to *FAIL* (server reboot), or for *both* client's mkdir() calls to
    succeed (if one or both clients had packet loss and had to retry the
    request).

    Under NFSv3, the only thing that truely guarentees proper operation
    in regards to competing clients is an O_EXCL file open().  An O_EXCL
    file open() is guarenteed to succeed on precisely one client when
    multiple clients are trying to create the same file, and NFSv3 O_EXCL
    semantics guarentees that NFS retries and server reboots will still
    result in proper operation (the client doing the retry or the client
    that succeeded in the open() call will still see a 'success' even if
    the server reboots or if an NFS retry occurs).

						-Matt


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102262226.f1QMQBJ44997>