POSIX Locking (some pointers for those not already scared)

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Mar 2 07:27:18 UTC 2018


On Fri, Mar 02, 2018 at 04:24:39PM +1300, Andrew Bartlett via samba-technical wrote:
> G'Day,
> 
> I've been working to understand locking, fork() and tdb as we move
> Samba to LMDB.  I had some fears before I realised that an fcntl() lock
> is not kept across fork(), so the stupid behaviour on close() doesn't
> matter if it is in the child.
> 
> It also doesn't matter that tdb_reopen_all() keeps the FD, as while the
> file offset is shared (we work around this), the locks are not.
> 
> Others may not be aware of the standard rant about POSIX locking,
> specifically:
> 
> https://www.samba.org/samba/news/articles/low_point/tale_two_stds_os2.html
> http://0pointer.de/blog/projects/locking.html
> http://0pointer.de/blog/projects/locking2
> 
> It is worth a read if you don't mind putting your brain though a
> blender.

You have no idea of the fun I had when working on tdb mutexes. In
particular ctdb really plays hardball with everything around locking
in tdb.

What those blog posts completely miss: fcntl locking in Linux does not
scale *AT* *ALL*. I haven't really tortured Jeff's fd-based locking
yet, but every single fcntl operation system-wide in the past went
through one single spinlock. Not sure this is still the case, but it
fully kills performance if you start using it.

Volker

-- 
Besuchen Sie die verinice.XP 2018 in Berlin,
Anwenderkonferenz für Informationssicherheit
vom 21.-23.03.2018 im Sofitel Kurfürstendamm
Info & Anmeldung hier: http://veriniceXP.org

SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de



More information about the samba-technical mailing list