[OpenAFS] Is locking (flock) on OpenAFS reliable?

Jeffrey Altman jaltman@your-file-system.com
Mon, 04 Jul 2011 08:52:55 -0400

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


As far as I am aware, the 1.4.x exclusive lock processing on UNIX is
broken in that it does not properly ensure that file data modified under
the lock is stored to the file server prior to the lock being dropped.
There are a number of other lock related issues that were corrected on
the master branch as well.

The 1.6pre* releases on UNIX should to the best of my knowledge do the
right thing with regards to lock acquisition and data synchronization.

On Windows, all versions from 1.4.1 have implemented byte range locks
enforced with full file locks from the file server.  Two applications
running on the same machine can synchronize their operations using byte
range locks.  Two applications on separate machines will see all byte
range lock requests behave as full file locks.  Prior to 1.5.75, the
Windows clients failed to ensure that file length changes and data
modifications performed under the full file lock were written back to
the file server when the last byte range lock was dropped.

In both UNIX and Windows, file server locks are obtained with a five
minute lease which must be renewed.  If the client is unable to renew
the lease, the file server will release the lock.  If a file server lock
is lost and the client cannot re-obtain it under the same data version,
the client must invalidate the file descriptor to prevent potential data
corruption from occurring.

Jeffrey Altman

On 7/4/2011 7:06 AM, Matthias Gerstner wrote:
> Hello,
> I wonder what the status of using flock calls (or the flock utility)
> with OpenAFS is. Generally it seems to work to synchronize different
> machines with each other using flock on OpenAFS. But in practice I
> encountered inconsistencies.
> When doing research about this topic I found no real reliable
> information what OpenAFS does intend to provide in this area. I know
> that byte-range locking is not supported between multiple machines. But=

> that doesn't matter for me.
> So what I encounter particularly is the following:
> I'm using flock to safely get a copy of a small directory tree on AFS. =
> central machine in the network updates that data regularly so I want to=

> be able to get a consistent copy from other machines. This works well
> for most of the time but every now and then I get the following error:
> /usr/bin/flock: 3: Input/output error
> Also when testing flock interactively between different machines it
> seems that sometimes it works as expected and then at other times more
> than one machine obtains the lock at the same time.
> No obvious errors can be found in client kernel logs or server logs. I
> primarily use OpenAFS on Gentoo Linux currently at version 1.4.14. But =
> experienced the problems for a long time already not only with this
> specific version.
> Another question I have is whether locking should also work from Window=
> OpenAFS clients. I'm using cygwin on Windows7 and try using flock there=

> on OpenAFS files and it seems to do something but I'm not sure if it's
> doing the right thing.
> I'd be happy to hear any advice on this.
> Best regards,
> Matthias

Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

Version: GnuPG v1.4.9 (MingW32)