[RFC] Understanding the locking of struct buf

Alexander Lochmann alexander.lochmann at tu-dortmund.de
Tue Mar 16 08:53:42 UTC 2021



On 14.03.21 09:35, Konstantin Belousov wrote:
> You cannot write any working code that uses buffer cache, without studying
> both buffer cache code itself, and examples using it from filesystems.
> Short (even the whole-screen short) herald comment cannot explain all the
> nuances that grown in the 40+ years codebase.
I see.
> 
>> Shouldn't that particular piece of documentation be updated?
>> For example: b_bcount /* w: b_lock, r: no lock needed */
> Do you understand the purpose of the locking?  What do you intent to do
> with the read value of b_bcount, if you do not own the buffer?  What is
> you next action with that value?
> 
I do know the purpose of locking. I have no particular usage in mind at
the moment. I'm trying to understand how locking is handled in FreeBSD.
In the Linux kernel, for example, there are such exceptions:  Read a ptr
without a lock to perform a NULL check.
All I'm asking was whether the documentation should reflect those
exceptions. I assume the answer is no.

Thank you, Konstantin, for lifting the fog.

- Alex

-- 
Technische Universität Dortmund
Alexander Lochmann                PGP key: 0xBC3EF6FD
Otto-Hahn-Str. 16                 phone:  +49.231.7556141
D-44227 Dortmund                  fax:    +49.231.7556116
http://ess.cs.tu-dortmund.de/Staff/al


More information about the freebsd-fs mailing list