2002-07-22 15:28:00

by Gregory Giguashvili

[permalink] [raw]
Subject: Memory mapped files on NFS mounted drives

Hello,

OS/Kernel checked:
===============
RH 7.2 (kernel 2.4.7-10) and RH 7.3 (kernel 2.4.18-3) (I haven't checked the
others).

Problem description:
===============
I attempt to read/write memory mapped file from two Linux machines, which
resides on NFS mounted drive. The file gets corrupted since the changes made
on one machine aren't immediately available on the other. The sample program
is attached to this e-mail - simply run and play with it on NFS mounted
drive to make sure there is some inconsistency.
The problematic API set includes (mmap, munmap and msync system calls).

The original code uses NFS locking to assure file consistency, but the
example misses this part to simplicity (locking is simulated by the user).
The same code works on a variety of other operating systems, but fails to
work between two Linux or Linux/Other OS machines.

Known workarounds/patches:
======================
I decided to give up on the performance issue and even tried to remap the
whole file before every attempt to read/write the mapped file. Surprisingly,
even this extreme measure didn't help (the code is commented out using
preprocessor directives in the sample program).
I couldn't find any patch, which specifically fixes this problem, though I
have seen some patches related to msync, which I don't think to be relevant
(Am I wrong?).


I'm sure that someone has come across this problem and I sure hope there is
some workaround/patch available.
Any help will be greatly appreciated.

Thanks in advance.
Giga

<<mmap.cc>>


Attachments:
mmap.cc (1.34 kB)