Possible BUG in Locking, 2.0.6 Samba. fsync()/msync() may be needed.

John E. Malmberg wb8tyw at qsl.net
Thu Feb 10 15:00:55 GMT 2000

When sharing either a file or a memmap structure between processes, a call
to fsync() or msync() may be needed to flush the program local buffers to
the disk or common memory section.

This is the case for OpenVMS and the Locking_Slow.c module.  I needed to add
an fsync() call before returning from the routines that write the file.

Since these routines exist in the X/Open Single Unix specification, It
indicates that other UNIX implementation may require this also.

The only side effects that I can see from not having these calls present, is
that SMBSTATUS may not report some share locks that exist.  Of course that
is all that showed up in my tests, which were not intensive.

I suspect it is also why OpenVMS failed the fast locking test using memmap,
but I have not recoded that to test it.

I seem to have the SHARE mode locking working now on OpenVMS with only one
apparent bug.  The share file is not being deleted when it is empty.  I will
be chasing that down tonight.

I am not enclosing a DIFF of adding the fsync() as I am not sure if ALL
UNIXes support it or need it.  This means doing this change portably may
involve a change to CONFIGURE support routines.

Also I had to make intensive modifications on Locking_Slow.c for it to work
with OpenVMS file locking, so a true DIFF of it would be hard to read.

OpenVMS does not have fcntl() locking, so I coded one up.  It uses the
native OpenVMS file/record locking services, so that it would play with
other programs running on the host operating system.  As a consequence, it
was not possible to make it work exactly like a UNIX fcntl().

In most cases, the differences would not be visable, however SAMBA does
exercise them.
OpenVMS can not lock a non-existant file record, so taking out a lock on the
first byte of an empty file will give you a file that is two bytes long.
One byte for the locked record, and the second byte as a LF character to
terminate the record.

Since Andrew Tridgell has written the tdb routines as a replacement, I
expect my VMS specific changes are best maintained in a separate file, that
I will post with the other VMS specific changes once I have everything

Thank you all for your support,

wb8tyw at qsl.net

More information about the samba-technical mailing list