[OpenAFS] flock on AFS files

2008-10-27 Thread Hans-Werner Paulsen
Hello,
today I am totally confused how the flock(2) call should work on
AFS files.
Normally locking works in the following way:
1fd = open(afs-file,O_RDWR)
 do something
2flock(fd,LOCK_EX)
 do something with afs-file
3flock(fd,LOCK_UN)
 do something
4close(fd)

When there are two processes (on different machines) executing that
code, the (2) flock call has to update the local copy of the afs-file,
otherwise locking is useless. And the (3) flock call has to sync the
local copy with the fileserver.
Writing a small test program I see that this synchronization isn't done.
How can I use the flock(2) call on AFS files?
Thank you for any help,

HW

-- 
Hans-Werner Paulsen [EMAIL PROTECTED]
MPI für Astrophysik Tel 089-3-2602
Karl-Schwarzschild-Str. 1   Fax 089-3-2235  
D-85741 Garching
___
OpenAFS-info mailing list
OpenAFS-info@openafs.org
https://lists.openafs.org/mailman/listinfo/openafs-info


Re: [OpenAFS] flock on AFS files

2008-10-27 Thread Todd M. Lewis
I've got quite a bit of code that does flock() on files in AFS, but I've 
always worked under the assumption that this would only work if a single 
client is doing the writing. I don't recall whether that assumption was 
based on empirical testing, reading it somewhere, or being told. In 
those few cases where this is not practical, I have a designated writer 
client that other clients connect to through other means (sockets) and 
coordinate the updates that way. That's reasonably straightforward, but 
painful enough that I avoid it whenever possible.


Probably not the answer you wanted...
--
[EMAIL PROTECTED]

On 10/27/2008 12:16 PM, Hans-Werner Paulsen wrote:

Hello,
today I am totally confused how the flock(2) call should work on
AFS files.
Normally locking works in the following way:
1fd = open(afs-file,O_RDWR)
 do something
2flock(fd,LOCK_EX)
 do something with afs-file
3flock(fd,LOCK_UN)
 do something
4close(fd)

When there are two processes (on different machines) executing that
code, the (2) flock call has to update the local copy of the afs-file,
otherwise locking is useless. And the (3) flock call has to sync the
local copy with the fileserver.
Writing a small test program I see that this synchronization isn't done.
How can I use the flock(2) call on AFS files?
Thank you for any help,

HW


___
OpenAFS-info mailing list
OpenAFS-info@openafs.org
https://lists.openafs.org/mailman/listinfo/openafs-info