Skip to contentSkip to conversation

File offsets with multiple clients

Lustre-devel office at hailoo.com 2 participants 2 messages Sep 25, 2009 – Sep 29, 2009

lore
Share & tools
lore
#0 lore raw

When a client obtains a file descriptor to a file on a Lustre file system, is the file offset pointer shared among any connected clients, or is it only meaningful to a single client?

For example, given the file "foo.txt" on a Lustre file system, suppose
there are 2 clients with an open file descriptor to "foo.txt". If Client1
calls lseek and then write, will this affect the file offset position of
Client2? Or is the application responsible for synchronizing file access
in this case?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20090925/aeffb53c/attachment.htm>

#1 lore raw

Hello!

Quoted 3 lines · office at hailoo.com

When a client obtains a file descriptor to a file on a Lustre file system, is the file offset pointer shared among any connected clients, or is it only meaningful to a single client?

It's even stricter than that. the pointer is per file-descriptor (the one you get from open(2) system call).

Quoted 6 lines

For example, given the file "foo.txt" on a Lustre file system, suppose there are 2 clients with an open file descriptor to "foo.txt". If Client1 calls lseek and then write, will this affect the file offset position of Client2? Or is the application responsible for synchronizing file access in this case?

No, since both applications on both clients did separate opens, their current file position pointer is separate.
The answer does not change even if both processes were running on the same client.
This is by design and is mandated by POSIX.

Bye,
Oleg